* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background: #000; font-family: 'Segoe UI', sans-serif; }
canvas { display: block; }

/* ─── HUD ─────────────────────────────────────────── */
#hud {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 10;
}
#network-status {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  color: #ff8844; font-size: 12px; text-transform: uppercase;
  letter-spacing: 2px; opacity: 0.8;
  background: rgba(0,0,0,0.4); padding: 4px 16px; border-radius: 3px;
}
#match-timer {
  position: absolute; top: 36px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 22px; font-weight: bold;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
#kill-feed {
  position: absolute; top: 70px; right: 20px;
  color: #fff; font-size: 13px; text-align: right;
  line-height: 1.8;
}
.kill-feed-entry { opacity: 0.8; transition: opacity 1s; }
.kill-feed-entry.fade { opacity: 0; }

#health-bar-container {
  position: absolute; bottom: 40px; left: 40px;
  width: 240px; height: 20px;
  background: rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.3);
  border-radius: 4px; overflow: hidden;
}
#health-bar {
  width: 100%; height: 100%;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  transition: width 0.3s;
}
#health-label {
  position: absolute; bottom: 64px; left: 40px;
  color: #fff; font-size: 13px; text-transform: uppercase;
  letter-spacing: 2px; opacity: 0.7;
}
#kills-display {
  position: absolute; top: 16px; right: 20px;
  color: #fff; font-size: 11px; text-transform: uppercase;
  letter-spacing: 2px; opacity: 0.5;
}
#kills-count {
  position: absolute; top: 30px; right: 20px;
  color: #fff; font-size: 28px; font-weight: bold;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
#ammo {
  position: absolute; bottom: 190px; right: 40px;
  color: #fff; font-size: 24px; font-weight: bold;
}
#ammo-label {
  position: absolute; bottom: 214px; right: 40px;
  color: #fff; font-size: 11px; text-transform: uppercase;
  letter-spacing: 2px; opacity: 0.5;
}

#crosshair {
  position: fixed;
  transform: translate(-50%, -50%);
  width: 30px; height: 30px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  pointer-events: none;
  z-index: 11;
}
#crosshair::before {
  content: ''; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 4px; height: 4px; background: rgba(255,255,255,0.8);
  border-radius: 50%;
}

/* ─── HITMARKER ───────────────────────────────────── */
#hitmarker {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px; font-weight: bold;
  color: #fff; pointer-events: none;
  opacity: 0; z-index: 12;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  transition: opacity 0.08s;
}
#hitmarker.hit { opacity: 1; color: #fff; }
#hitmarker.critical { opacity: 1; color: #ffaa00; font-size: 32px; text-shadow: 0 0 8px rgba(255,170,0,0.6); }
#hitmarker.kill { opacity: 1; color: #ff4444; font-size: 36px; }

/* ─── CRITICAL HIT TEXT ──────────────────────────────── */
#critical-text {
  position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px; font-weight: bold;
  color: #ffaa00; letter-spacing: 4px;
  text-transform: uppercase; pointer-events: none;
  opacity: 0; z-index: 12;
  text-shadow: 0 0 10px rgba(255,170,0,0.5), 0 2px 4px rgba(0,0,0,0.8);
  transition: opacity 0.15s;
}
#critical-text.show { opacity: 1; }

#damage-flash {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,0,0,0.3); pointer-events: none; opacity: 0;
  transition: opacity 0.1s; z-index: 5;
}
#minimap {
  position: fixed; bottom: 20px; right: 20px;
  width: 150px; height: 150px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  background: rgba(0,0,0,0.6);
  z-index: 15; pointer-events: none;
}

/* ─── MUSIC BUTTON ────────────────────────────────── */
#music-wrap {
  position: fixed; top: 16px; right: 16px;
  z-index: 150; display: flex; flex-direction: column;
  align-items: center; pointer-events: auto;
}
#music-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,0.4); color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  opacity: 1; user-select: none;
}
#music-btn:hover { background: rgba(0,0,0,0.6); }
#music-btn.muted { opacity: 0.5; }
#music-btn.glow {
  animation: musicGlow 1.5s ease-in-out infinite;
}
@keyframes musicGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(255,255,255,0.1); }
  50% { box-shadow: 0 0 16px rgba(255,255,255,0.35); }
}

/* Volume slider (appears on hover) */
#music-volume-slider {
  position: relative; bottom: 0;
  width: 34px; height: 100px;
  background: rgba(0,0,0,0.5); border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
#music-wrap:hover #music-volume-slider,
#music-volume-slider.visible {
  opacity: 1; pointer-events: auto;
}
#music-volume {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 80px; height: 80px;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
#music-volume::-webkit-slider-runnable-track {
  width: 4px; background: rgba(255,255,255,0.2); border-radius: 2px;
}
#music-volume::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; margin-left: -4px;
}

/* ─── MENU BACKGROUND (3D canvas) ────────────────── */
#menu-canvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; display: block;
}

/* ─── MAIN MENU OVERLAY ─────────────────────────── */
#main-menu {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 100; pointer-events: none;
  opacity: 0; transition: opacity 1.5s;
}
#main-menu.visible { opacity: 1; }
#menu-panel {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.2) 100%);
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
}
#menu-content {
  padding: 0 40px; text-align: center;
}
#menu-title h1 {
  font-size: 52px; font-weight: 900; color: #fff;
  letter-spacing: 6px; margin: 0;
  text-shadow: 0 0 30px rgba(255,140,66,0.8), 0 2px 10px rgba(0,0,0,0.6);
}
.menu-title-line {
  width: 60px; height: 3px; margin: 10px auto 8px;
  background: #ff8c42;
  animation: titleLinePulse 2s ease-in-out infinite;
}
@keyframes titleLinePulse {
  0%, 100% { width: 60px; opacity: 0.7; }
  50% { width: 90px; opacity: 1; }
}
.menu-subtitle {
  font-size: 13px; letter-spacing: 4px; color: rgba(255,255,255,0.6);
  margin-bottom: 40px;
}
#menu-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 40px; align-items: center; }
.menu-btn {
  width: 220px; border: none; border-radius: 6px;
  font-family: inherit; font-weight: bold; cursor: pointer;
  letter-spacing: 3px; transition: all 0.2s;
  pointer-events: auto;
}
.menu-btn.primary {
  height: 52px; font-size: 16px; color: #fff;
  background: rgba(255,100,30,0.9);
  border: 1px solid rgba(255,140,66,0.6);
}
.menu-btn.primary:hover { background: rgba(255,120,50,1); transform: scale(1.02); }
.menu-btn.secondary {
  height: 44px; font-size: 14px; color: #fff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
}
.menu-btn.secondary:hover { background: rgba(255,255,255,0.15); }
#menu-bottom { opacity: 0.3; font-size: 11px; color: #fff; line-height: 1.8; }
#menu-version { letter-spacing: 2px; }
#menu-copyright { font-size: 10px; }

/* Menu top right */
#menu-top-right {
  position: absolute; top: 16px; right: 16px;
  display: flex; align-items: center; gap: 14px;
  pointer-events: auto;
}
#online-count {
  color: rgba(255,255,255,0.6); font-size: 12px;
  letter-spacing: 1px;
}

/* Menu anim (slide-in from left) */
.menu-anim {
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
#main-menu.visible .menu-anim { opacity: 1; transform: translateY(0); }
#main-menu.visible #menu-title { transition-delay: 0.5s; }
#main-menu.visible #menu-buttons { transition-delay: 0.8s; }
#main-menu.visible #menu-bottom { transition-delay: 1.0s; }
#main-menu.fadeout {
  opacity: 0; transition: opacity 0.5s;
}

/* ─── LOBBY ───────────────────────────────────────── */
#lobby {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 100; display: none;
  align-items: center; justify-content: center; cursor: default;
}
#lobby-box {
  text-align: center; color: #fff;
}
#lobby-box h1 {
  font-size: 56px; letter-spacing: 6px; margin-bottom: 6px;
}
#lobby-box .sub {
  font-size: 14px; opacity: 0.4; margin-bottom: 36px;
}
#lobby-box label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 2px; opacity: 0.5; margin-bottom: 8px;
}
#username-input {
  width: 260px; padding: 10px 16px; font-size: 16px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; color: #fff; text-align: center;
  outline: none; font-family: inherit; cursor: text;
}
#username-input:focus { border-color: rgba(255,255,255,0.5); }
#lobby-info {
  margin: 20px 0; font-size: 13px; opacity: 0.5; line-height: 2;
}
#play-btn {
  padding: 14px 60px; font-size: 20px; cursor: pointer;
  background: #22c55e; color: #fff; border: none; border-radius: 6px;
  font-weight: bold; letter-spacing: 1px; margin-top: 10px;
}
#play-btn:hover { background: #16a34a; }
#lobby-controls {
  margin-top: 24px; font-size: 12px; opacity: 0.3; line-height: 1.8;
}

/* ─── END SCREEN ──────────────────────────────────── */
#end-screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); z-index: 100;
  display: none; align-items: center; justify-content: center;
  cursor: default;
}
#end-box {
  text-align: center; color: #fff; max-width: 500px; width: 90%;
}
#end-box h1 { font-size: 42px; margin-bottom: 6px; }
#end-box .end-reason { font-size: 14px; opacity: 0.5; margin-bottom: 20px; }

#scoreboard {
  width: 100%; border-collapse: collapse; margin: 16px 0;
  font-size: 14px;
}
#scoreboard th {
  text-transform: uppercase; font-size: 11px; letter-spacing: 1px;
  opacity: 0.5; padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
#scoreboard td {
  padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05);
}
#scoreboard .local-player { color: #4ade80; font-weight: bold; }
#scoreboard .rank { opacity: 0.4; }

#player-stats {
  margin: 16px 0; font-size: 13px; opacity: 0.6; line-height: 2;
}
#end-buttons { margin-top: 20px; }
#end-buttons button {
  padding: 10px 30px; font-size: 16px; cursor: pointer;
  border: none; border-radius: 6px; font-weight: bold;
  margin: 0 8px; pointer-events: auto;
}
#btn-play-again { background: #22c55e; color: #fff; }
#btn-play-again:hover { background: #16a34a; }
#btn-main-menu { background: rgba(255,255,255,0.1); color: #fff; }
#btn-main-menu:hover { background: rgba(255,255,255,0.2); }

/* ─── DEATH OVERLAY ──────────────────────────────── */
#death-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(139, 0, 0, 0.3);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 50; pointer-events: none;
}
#death-text { color: #ff4444; font-size: 36px; letter-spacing: 4px; font-weight: bold; }
#respawn-timer { color: #fff; font-size: 18px; margin-top: 12px; opacity: 0.7; }

/* ─── MAP SELECT ─────────────────────────────────── */
#map-select {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 100; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  cursor: default;
}
#map-select h2 {
  color: #fff; font-size: 28px; letter-spacing: 4px;
  margin-bottom: 8px; text-transform: uppercase;
}
#map-select .sub { color: #fff; font-size: 13px; opacity: 0.4; margin-bottom: 32px; }
.map-cards { display: flex; gap: 20px; margin-bottom: 32px; }
.map-card {
  width: 220px; border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  cursor: pointer; transition: all 0.2s; overflow: hidden;
}
.map-card:hover { border-color: rgba(255,255,255,0.4); transform: translateY(-4px); }
.map-card.selected { border-color: #22c55e; box-shadow: 0 0 20px rgba(34,197,94,0.3); }
.map-card-preview { width: 100%; height: 120px; }
.map-card-info { padding: 16px; color: #fff; }
.map-card-info h3 { font-size: 18px; letter-spacing: 2px; margin-bottom: 4px; }
.map-card-info .map-subtitle {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  opacity: 0.5; margin-bottom: 8px;
}
.map-card-info p { font-size: 12px; opacity: 0.6; line-height: 1.5; }
#start-battle-btn {
  padding: 14px 60px; font-size: 20px; cursor: pointer;
  background: #22c55e; color: #fff; border: none; border-radius: 6px;
  font-weight: bold; letter-spacing: 1px;
}
#start-battle-btn:hover { background: #16a34a; }
#map-back-btn {
  margin-top: 16px; padding: 8px 24px; font-size: 13px;
  background: rgba(255,255,255,0.1); color: #fff; border: none;
  border-radius: 4px; cursor: pointer; letter-spacing: 1px;
}
#map-back-btn:hover { background: rgba(255,255,255,0.2); }

/* ─── LOADING SCREEN ─────────────────────────────── */
#loading-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); z-index: 100; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  cursor: default;
}
#loading-map-name { color: #fff; font-size: 36px; letter-spacing: 6px; margin-bottom: 8px; }
#loading-text { color: #fff; font-size: 14px; opacity: 0.5; margin-bottom: 24px; letter-spacing: 2px; }
#loading-progress {
  width: 300px; height: 4px; background: rgba(255,255,255,0.1);
  border-radius: 2px; overflow: hidden;
}
#loading-progress-fill {
  width: 0%; height: 100%; background: #22c55e;
  transition: width 0.03s linear;
}
/* ─── MUTE BUTTON ──────────────────────────────── */
#mute-btn {
  position: fixed; top: 10px; right: 10px;
  background: rgba(0,0,0,0.5); color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px; padding: 4px 10px;
  font-size: 12px; cursor: pointer; z-index: 60;
  font-family: 'Segoe UI', sans-serif;
  pointer-events: auto; display: none;
  user-select: none;
}
#mute-btn:hover { background: rgba(255,255,255,0.15); }

/* ─── TEAM SCORES (TDM) ─────────────────────────── */
#team-scores {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 14px;
  font-size: 20px; font-weight: bold; letter-spacing: 2px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  background: rgba(0,0,0,0.35); padding: 4px 20px; border-radius: 4px;
}
.team-blue { color: #4488ff; }
.team-red { color: #ff4444; }
.team-vs { color: rgba(255,255,255,0.3); font-size: 12px; }
#team-indicator {
  position: absolute; bottom: 90px; left: 40px;
  font-size: 12px; font-weight: bold; letter-spacing: 2px;
  text-transform: uppercase; pointer-events: none;
}

/* ─── MODE SELECTOR (LOBBY) ─────────���────────────── */
#mode-select { margin: 16px 0 8px; }
#mode-select label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 2px; opacity: 0.5; margin-bottom: 8px;
}
.mode-buttons { display: flex; gap: 8px; justify-content: center; }
.mode-btn {
  padding: 8px 24px; font-size: 14px; cursor: pointer;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  font-family: inherit; font-weight: bold; letter-spacing: 1px;
  transition: all 0.15s; pointer-events: auto;
}
.mode-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.mode-btn.selected { background: rgba(34,197,94,0.2); border-color: #22c55e; color: #22c55e; }

/* ─── SETTINGS OVERLAY ───────────────────────────── */
#settings-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); z-index: 200; display: none;
  align-items: center; justify-content: center; cursor: default;
}
#settings-box {
  text-align: center; color: #fff;
  background: rgba(20,20,40,0.85); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px; padding: 40px 50px; min-width: 340px;
}
#settings-box h2 {
  font-size: 28px; letter-spacing: 4px; margin-bottom: 8px;
  text-transform: uppercase;
}
#settings-box .sub { font-size: 13px; opacity: 0.4; margin-bottom: 32px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 20px;
}
.setting-label {
  font-size: 13px; text-transform: uppercase; letter-spacing: 2px; opacity: 0.7;
}
.setting-value {
  font-size: 14px; font-weight: bold; min-width: 36px; text-align: center;
}
.setting-slider {
  width: 180px; height: 6px;
  -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.15); border-radius: 3px;
  cursor: pointer; outline: none;
}
.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ff8c42; cursor: pointer;
}
#settings-back-btn {
  margin-top: 20px; padding: 10px 40px; font-size: 14px;
  background: rgba(255,255,255,0.1); color: #fff; border: none;
  border-radius: 6px; cursor: pointer; font-weight: bold;
  letter-spacing: 2px; font-family: inherit;
}
#settings-back-btn:hover { background: rgba(255,255,255,0.2); }
