* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-touch-callout: none;
}

html, body {
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  position: fixed;
  width: 100%;
  height: 100%;
}

#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

#sideViewCanvas {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70vw;
  height: 50vh;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.85);
  z-index: 20;
  display: none;
  pointer-events: none;
}

/* Screens */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.9);
  z-index: 100;
}

.screen.hidden {
  display: none;
}

#gameOverScreen {
  background: rgba(0, 0, 0, 0.45);
  transition: background 0.5s;
}

.screen h1 {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -2px;
  margin-bottom: 0.25em;
  background: linear-gradient(135deg, #4fc3f7, #ef5350);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.screen .subtitle {
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 1.5em;
}

.screen button {
  padding: 16px 56px;
  font-size: 1.3rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #4fc3f7, #29b6f6);
  color: #000;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.screen button:active {
  transform: scale(0.95);
}

.controls-info {
  margin-top: 1.5em;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 1.2em 1.8em;
  border-radius: 12px;
  max-width: 400px;
}

.controls-info h3 {
  margin-bottom: 0.5em;
  color: #aaa;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 2px;
}

.controls-list p {
  font-size: 0.9rem;
  color: #bbb;
  margin-bottom: 0.5em;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* HUD */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

#hud button, #hud .touch-active {
  pointer-events: auto;
}

/* Top Bar */
#topBar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
}

.player-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-name {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.health-bar {
  width: 120px;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
}

.health-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.health-fill.p1 {
  background: linear-gradient(90deg, #4fc3f7, #29b6f6);
  width: 100%;
}

.health-fill.p2 {
  background: linear-gradient(90deg, #ef5350, #e53935);
  width: 100%;
}

.health-text {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 2em;
}

#windIndicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.wind-label {
  font-size: 0.6rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 2px;
}

#windCanvas {
  display: block;
}

#windSpeed {
  font-size: 0.7rem;
  color: #aaa;
}

/* Turn Banner */
#turnBanner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
  animation: bannerPulse 0.6s ease-out;
  z-index: 30;
}

@keyframes bannerPulse {
  0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Touch Controls */
#touchControls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

#touchControls button, #touchControls .touch-active {
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Left Controls */
#leftControls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#aimPad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.aim-mid-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.aim-center-label {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #666;
  letter-spacing: 1px;
}

.aim-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.aim-btn:active, .aim-btn.pressed {
  background: rgba(79, 195, 247, 0.4);
}

/* Joystick */
#joystickArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.joystick-label {
  font-size: 0.6rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  pointer-events: none;
}

#joystickBase {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

#joystickKnob {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(102, 187, 106, 0.5);
  border: 2px solid rgba(102, 187, 106, 0.7);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: background 0.1s;
}

#joystickKnob.active {
  background: rgba(102, 187, 106, 0.8);
}

/* Fuel */
#fuelInfo {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

#fuelInfo label {
  font-size: 0.6rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.fuel-bar-container {
  width: 70px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.fuel-bar-fill {
  height: 100%;
  width: 100%;
  background: #66bb6a;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Center Controls */
#centerControls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 300px;
}

#aimInfo {
  display: flex;
  gap: 16px;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 14px;
  border-radius: 8px;
  pointer-events: none;
}

.aim-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
}

.aim-row label {
  color: #888;
  text-transform: uppercase;
  font-size: 0.55rem;
  letter-spacing: 1px;
}

.aim-value {
  font-weight: 700;
  font-family: monospace;
  font-size: 0.9rem;
}

/* Power Controls */
#powerControls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.power-btn {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.power-btn:active, .power-btn.pressed {
  background: rgba(253, 216, 53, 0.3);
  color: #fdd835;
}

.power-bar-container {
  width: 90px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
}

.power-bar-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #66bb6a, #fdd835, #ef5350);
  border-radius: 4px;
  transition: width 0.1s;
}

/* Right Controls */
#rightControls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fire-btn {
  width: 90px;
  height: 90px;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle, #ef5350, #c62828);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(239, 83, 80, 0.4);
}

.fire-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(239, 83, 80, 0.6);
}

/* Weapon Selector */
#weaponSelector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 10px;
  border-radius: 8px;
}

.weapon-cycle-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fdd835;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.weapon-cycle-btn:active {
  background: rgba(253, 216, 53, 0.3);
}

.weapon-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  pointer-events: none;
}

.weapon-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: #fdd835;
}

.weapon-ammo {
  font-size: 0.7rem;
  color: #aaa;
}

/* Side View Button */
.side-view-btn {
  background: rgba(79, 195, 247, 0.15);
  border: 1px solid rgba(79, 195, 247, 0.3);
  color: #4fc3f7;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.side-view-btn:active {
  background: rgba(79, 195, 247, 0.3);
}

#sideViewTimer {
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
}

.side-view-time-fill {
  height: 100%;
  width: 100%;
  background: #4fc3f7;
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* Camera Toggle Button */
.camera-toggle-btn {
  background: rgba(255, 152, 0, 0.15);
  border: 1px solid rgba(255, 152, 0, 0.3);
  color: #ff9800;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.camera-toggle-btn:active {
  background: rgba(255, 152, 0, 0.3);
}

.camera-toggle-btn.active {
  background: rgba(255, 152, 0, 0.35);
  border-color: rgba(255, 152, 0, 0.6);
}

/* Move Confirm Buttons */
#moveConfirm {
  display: flex;
  gap: 6px;
  justify-content: center;
}

#moveConfirm.hidden {
  display: none;
}

.move-confirm-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.move-confirm-btn.ok {
  background: rgba(102, 187, 106, 0.4);
  color: #66bb6a;
  border: 1px solid rgba(102, 187, 106, 0.5);
}

.move-confirm-btn.ok:active {
  background: rgba(102, 187, 106, 0.6);
}

.move-confirm-btn.cancel {
  background: rgba(239, 83, 80, 0.3);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.4);
}

.move-confirm-btn.cancel:active {
  background: rgba(239, 83, 80, 0.5);
}
