* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: auto; background: #1a1a1a; font-family: 'Courier New', monospace; }

canvas#gameCanvas {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 0;
}

/* Role badge - top left */
.role-badge {
  position: fixed; top: 15px; left: 15px; z-index: 150;
  padding: 6px 16px; border-radius: 4px;
  font-size: 0.85em; letter-spacing: 0.1em;
  font-family: 'Courier New', monospace;
}
.badge-player {
  background: rgba(76, 175, 80, 0.2); border: 1px solid #4caf50; color: #4caf50;
}
.badge-spectator {
  background: rgba(150, 150, 150, 0.15); border: 1px solid #666; color: #999;
}

/* User info - top left below badge */
.user-info {
  position: fixed; top: 45px; left: 15px; z-index: 150;
  font-family: 'Courier New', monospace;
}
.user-name { color: #d4a843; font-size: 0.9em; margin-right: 10px; }
.user-stats { color: #666; font-size: 0.75em; }

/* Leaderboard button - top right */
.lb-btn {
  position: fixed; top: 15px; right: 15px; z-index: 150;
  padding: 6px 16px; border-radius: 4px;
  background: rgba(212, 168, 67, 0.15); border: 1px solid #d4a843; color: #d4a843;
  font-family: 'Courier New', monospace; font-size: 0.85em;
  cursor: pointer; letter-spacing: 0.1em; transition: all 0.3s;
}
.lb-btn:hover { background: rgba(212, 168, 67, 0.3); }

/* Leaderboard overlay */
.lb-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 500;
  background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center;
}
.lb-panel {
  background: #1a2332; border: 1px solid #333; border-radius: 10px;
  padding: 30px 40px; min-width: 420px; max-width: 90vw; max-height: 80vh; overflow-y: auto;
}
.lb-title { color: #d4a843; text-align: center; margin-bottom: 20px; font-size: 1.3em; letter-spacing: 0.2em; }
.lb-table { width: 100%; border-collapse: collapse; font-family: 'Courier New', monospace; }
.lb-table th { color: #888; font-size: 0.8em; padding: 8px 12px; border-bottom: 1px solid #333; text-align: left; letter-spacing: 0.1em; }
.lb-table td { color: #ccc; font-size: 0.85em; padding: 8px 12px; border-bottom: 1px solid #222; }
.lb-table tr:hover { background: rgba(255,255,255,0.03); }
.lb-table tr.lb-me { background: rgba(76, 175, 80, 0.1); }
.lb-table tr.lb-me td { color: #4caf50; }
.lb-close {
  display: block; margin: 20px auto 0; padding: 8px 30px;
  background: transparent; border: 1px solid #555; color: #888;
  font-family: 'Courier New', monospace; cursor: pointer; border-radius: 4px;
}
.lb-close:hover { border-color: #d4a843; color: #d4a843; }

/* Player name in slot */
.slot-player-name { color: #d4a843; font-size: 1em; margin-bottom: 5px; min-height: 1.2em; }

/* Online users panel */
.online-panel {
  margin-top: 25px; padding: 15px 20px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; max-width: 400px; margin-left: auto; margin-right: auto;
}
.online-title {
  color: #888; font-size: 0.8em; letter-spacing: 0.2em; margin-bottom: 10px; text-align: center;
}
.online-list { display: flex; flex-direction: column; gap: 6px; }
.ol-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 4px;
  background: rgba(255,255,255,0.02);
}
.ol-item.ol-me { background: rgba(76, 175, 80, 0.08); }
.ol-tag {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 0.7em; letter-spacing: 0.1em; font-weight: bold; min-width: 50px; text-align: center;
}
.ol-tag-player { background: rgba(76, 175, 80, 0.2); color: #4caf50; border: 1px solid rgba(76, 175, 80, 0.3); }
.ol-tag-wait { background: rgba(150, 150, 150, 0.1); color: #777; border: 1px solid rgba(150, 150, 150, 0.2); }
.ol-tag-lobby { background: rgba(212, 168, 67, 0.15); color: #d4a843; border: 1px solid rgba(212, 168, 67, 0.25); }
.ol-name { color: #ccc; font-size: 0.9em; flex: 1; }
.ol-ready { color: #4caf50; font-size: 0.85em; }

/* Lobby */
#lobby {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 100;
  background: linear-gradient(180deg, #0d0d0d 0%, #1a2332 50%, #0d0d0d 100%);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.lobby-container { padding: 30px 0 60px; }
.lobby-container { text-align: center; }
.game-title {
  font-size: 4em; color: #c41e1e; text-shadow: 0 0 30px rgba(196,30,30,0.5);
  letter-spacing: 0.15em; margin-bottom: 0;
}
.game-subtitle {
  font-size: 1.5em; color: #d4a843; letter-spacing: 0.5em;
  margin-bottom: 50px; font-weight: 300;
}
.player-slots { display: flex; align-items: center; gap: 15px; justify-content: center; margin-bottom: 30px; flex-wrap: wrap; }
.player-slot {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 18px 22px; min-width: 150px;
}
.slot-label { color: #888; font-size: 0.9em; margin-bottom: 8px; letter-spacing: 0.2em; }
.slot-weapon { color: #d4a843; font-size: 1.1em; margin-bottom: 8px; }
.slot-ready { color: #666; font-size: 0.85em; margin-top: 5px; }
.slot-ready.ready-yes { color: #4caf50; font-weight: bold; }
.vs-divider { color: #c41e1e; font-size: 2em; font-weight: bold; }

.spec-text { color: #777; font-size: 1em; letter-spacing: 0.1em; margin-bottom: 20px; }

.ready-btn {
  padding: 12px 30px; font-size: 1.1em; font-family: 'Courier New', monospace;
  border: 2px solid #555; background: transparent; color: #888;
  cursor: not-allowed; letter-spacing: 0.1em; transition: all 0.3s;
}
.ready-btn.active {
  border-color: #d4a843; color: #d4a843; cursor: pointer;
}
.ready-btn.active:hover { background: rgba(212,168,67,0.15); }
.ready-btn.ready-done {
  border-color: #4caf50; color: #4caf50; cursor: default;
}

.status { margin-top: 10px; font-size: 0.8em; height: 20px; }
.start-btn {
  padding: 15px 60px; font-size: 1.3em; font-family: 'Courier New', monospace;
  border: 2px solid #c41e1e; background: transparent; color: #c41e1e;
  cursor: pointer; letter-spacing: 0.3em; transition: all 0.3s;
  margin-top: 10px;
}
.start-btn:hover { background: rgba(196,30,30,0.2); box-shadow: 0 0 20px rgba(196,30,30,0.3); }
.wait-msg { color: #888; margin-top: 20px; font-size: 0.9em; height: 24px; }
.controls-info { color: #555; margin-top: 40px; font-size: 0.8em; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 50; pointer-events: none; }
.hp-bars { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 40px; }
.hp-bar-wrapper { width: 200px; }
.hp-label { color: #aaa; font-size: 0.75em; margin-bottom: 4px; letter-spacing: 0.1em; text-align: center; }
.hp-bar-bg { background: rgba(0,0,0,0.6); border: 1px solid #555; height: 16px; border-radius: 2px; }
.hp-bar { height: 100%; background: #4caf50; transition: width 0.3s; width: 100%; border-radius: 2px; }
.hp-bar-enemy { background: #c41e1e; }

.crosshair-scope { position: absolute; top: 35%; left: calc(50% + 30px); transform: translateY(-50%); width: 6px; height: 100px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 3px; pointer-events: none; }
.ch-inner { position: absolute; left: 50%; transform: translateX(-50%); transition: top 0.1s ease-out; width: 16px; height: 4px; background: #ff4444; border-radius: 2px; box-shadow: 0 0 6px rgba(255,68,68,0.6); }
.ch-h { display: none; }
.ch-v { display: none; }
.ch-dot { display: none; }

.cooldown-indicator {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
  color: #4caf50; font-size: 1em; letter-spacing: 0.2em;
}
.cooldown-indicator.reloading { color: #c41e1e; }

/* Game Over */
#gameOverUI {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 200;
  background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center;
}
.gameover-container { text-align: center; }
.gameover-container h1 { font-size: 3em; color: #d4a843; margin-bottom: 30px; letter-spacing: 0.2em; }

/* Full message */
#fullMsg {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 300;
  background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; color: #888;
}
.full-container { text-align: center; }
.full-container h2 { color: #c41e1e; margin-bottom: 15px; }

/* Choose Player */
.choose-title {
  color: #d4a843; font-size: 1.3em; margin-bottom: 25px; letter-spacing: 0.2em;
}
.choose-slots {
  display: flex; gap: 30px; justify-content: center; margin-bottom: 20px;
}
.choose-btn {
  background: rgba(255,255,255,0.03); border: 2px solid rgba(255,255,255,0.15);
  border-radius: 10px; padding: 25px 30px; min-width: 180px;
  cursor: pointer; transition: all 0.3s; font-family: 'Courier New', monospace;
  text-align: center;
}
.choose-btn:disabled {
  opacity: 0.3; cursor: not-allowed;
}
.choose-btn.slot-available:hover {
  border-color: #d4a843; background: rgba(212,168,67,0.1);
  box-shadow: 0 0 15px rgba(212,168,67,0.2);
}
.choose-num {
  color: #aaa; font-size: 0.85em; letter-spacing: 0.2em; margin-bottom: 10px;
}
.choose-weapon {
  color: #d4a843; font-size: 1.4em; font-weight: bold; margin-bottom: 8px;
}
.choose-icon {
  font-size: 2em; margin-bottom: 8px;
}
.choose-desc {
  color: #666; font-size: 0.8em;
}

@media (max-width: 600px) {
  .choose-slots { flex-direction: column; gap: 15px; align-items: center; }
  .choose-btn { min-width: 160px; padding: 18px 20px; }
  .choose-weapon { font-size: 1.1em; }
}

/* ===== Mobile Touch Controls ===== */
#touch-controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 200px;
  z-index: 60;
  pointer-events: none;
}

.joystick-zone {
  position: absolute;
  bottom: 20px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
}
.joystick-left { left: 25px; }
.joystick-right { right: 25px; }

.joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
  margin: 10px auto;
}

.joystick-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.joystick-stick {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.4);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
}
.joystick-stick:active {
  background: rgba(255, 255, 255, 0.4);
}

.fire-button {
  position: absolute;
  bottom: 60px;
  right: 170px;
  left: auto;
  transform: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(196, 30, 30, 0.4);
  border: 3px solid rgba(196, 30, 30, 0.7);
  color: #fff;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.fire-button.fire-active {
  background: rgba(196, 30, 30, 0.8);
  border-color: #ff4444;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

/* Hide touch controls on desktop */
@media (hover: hover) and (pointer: fine) {
  #touch-controls { display: none !important; }
}

/* Mobile lobby adjustments */
@media (max-width: 600px) {
  .game-title { font-size: 2.2em; }
  .game-subtitle { font-size: 1em; margin-bottom: 25px; letter-spacing: 0.3em; }
  .player-slots { flex-direction: column; gap: 15px; }
  .vs-divider { font-size: 1.2em; }
  .player-slot { padding: 15px 25px; min-width: 160px; }
  .ready-btn { padding: 10px 20px; font-size: 0.95em; }
  .start-btn { padding: 12px 40px; font-size: 1.1em; }
  .hp-bar-wrapper { width: 130px; }
  .cooldown-indicator { bottom: 210px; }
}

/* Cannon charge bar */
.cannon-charge-wrap {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 12px; background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,170,50,0.4); border-radius: 6px; overflow: hidden;
}
.cannon-charge-fill {
  height: 100%; width: 0%; border-radius: 6px;
  background: #ffaa33; transition: width 0.05s linear;
}
.cannon-cd {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  color: #ffaa33; font-size: 0.8em; letter-spacing: 0.15em; pointer-events: none;
}
/* Mobile cannon button */
.cannon-button {
  position: absolute; bottom: 170px; right: 25px;
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,140,0,0.3); border: 3px solid rgba(255,140,0,0.6);
  color: #ffaa33; font-size: 12px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.cannon-button.cannon-active {
  background: rgba(255,100,0,0.7); border-color: #ff6600;
  box-shadow: 0 0 20px rgba(255,100,0,0.5);
}

/* Mute button */
.mute-btn {
  position: absolute; top: 20px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; font-size: 18px; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  z-index: 100; user-select: none;
  transition: background 0.2s;
}
.mute-btn:hover { background: rgba(0,0,0,0.7); }

/* Lock scroll during gameplay */
body.in-game { overflow: hidden !important; }

@media (hover: none) and (pointer: coarse) {
  .cannon-cd {
    left: auto; right: 10px; bottom: 240px; transform: none;
    text-align: center; width: 84px; font-size: 0.7em;
  }
  .cannon-charge-wrap {
    left: auto; right: 100px; bottom: 190px; transform: none;
    width: 80px; height: 8px; border-radius: 4px;
  }
  .cannon-charge-fill {
    height: 100% !important; transition: width 0.05s linear !important;
    border-radius: 4px;
  }
}

/* Pitch buttons (mobile) */
.pitch-button {
  position: absolute; right: 100px;
  width: 40px; height: 40px; border-radius: 8px;
  background: rgba(100,150,255,0.25); border: 2px solid rgba(100,150,255,0.5);
  color: #88bbff; font-size: 16px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.pitch-up { bottom: 200px; }
.pitch-down { bottom: 150px; }
.pitch-button.pitch-active {
  background: rgba(100,150,255,0.5); border-color: #88bbff;
  box-shadow: 0 0 10px rgba(100,150,255,0.4);
}
@media (hover: hover) and (pointer: fine) {
  .pitch-button { display: none !important; }
}

/* Center crosshair (aiming reticle) */
#centerCrosshair {
  position: absolute; top: 35%; left: 50%; transform: translate(-50%, -50%);
  pointer-events: none; z-index: 55;
}
#centerCrosshair .cx-h {
  position: absolute; width: 24px; height: 2px; background: rgba(255,255,255,0.7);
  top: -1px;
}
#centerCrosshair .cx-h.cx-l { right: 8px; }
#centerCrosshair .cx-h.cx-r { left: 8px; }
#centerCrosshair .cx-v {
  position: absolute; height: 24px; width: 2px; background: rgba(255,255,255,0.7);
  left: -1px;
}
#centerCrosshair .cx-v.cx-t { bottom: 8px; }
#centerCrosshair .cx-v.cx-b { top: 8px; }
#centerCrosshair .cx-dot {
  position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255,100,100,0.9); top: -2px; left: -2px;
  box-shadow: 0 0 6px rgba(255,100,100,0.5);
}

/* Hit flash vignette */
#hitFlash {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 55; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(255,0,0,0.4) 100%);
  transition: opacity 0.1s ease-in;
}
#hitFlash.active { opacity: 1; }

/* Tank model viewer button */
.viewer-btn {
  position: fixed; top: 15px; right: 130px; z-index: 150;
  padding: 6px 16px; border-radius: 4px;
  background: rgba(196, 30, 30, 0.15); border: 1px solid #c41e1e; color: #c41e1e;
  font-family: 'Courier New', monospace; font-size: 0.85em;
  cursor: pointer; letter-spacing: 0.1em; transition: all 0.3s;
  text-decoration: none;
}
.viewer-btn:hover { background: rgba(196, 30, 30, 0.3); }
