* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --accent: #44bd87;
  --accent2: #ffc94d;
  --danger: #ef4444;
  --bg: #0d1117;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); font-family: "Segoe UI", system-ui, sans-serif; }

.hidden { display: none !important; }

#game-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

@keyframes screenshake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(var(--shake, 6px), calc(var(--shake, 6px) * -0.6)); }
  45% { transform: translate(calc(var(--shake, 6px) * -0.7), calc(var(--shake, 6px) * 0.4)); }
  70% { transform: translate(calc(var(--shake, 6px) * 0.35), calc(var(--shake, 6px) * -0.2)); }
  100% { transform: translate(0, 0); }
}

/* ============ MENU ============ */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; }
.menu-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(68, 189, 135, 0.18), transparent 55%),
    radial-gradient(ellipse at 80% 75%, rgba(255, 201, 77, 0.12), transparent 55%),
    linear-gradient(160deg, #0d1117 0%, #101826 60%, #0d1420 100%);
}
.menu-card {
  position: relative; width: 380px; padding: 36px 34px;
  background: rgba(16, 22, 32, 0.92); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  display: flex; flex-direction: column; gap: 12px;
}
.logo { font-size: 46px; font-weight: 900; letter-spacing: 3px; color: #fff; text-align: center; }
.logo span { color: var(--accent); font-size: 24px; }
.tagline { text-align: center; color: #7b8794; font-size: 12px; letter-spacing: 1px; margin-bottom: 10px; }

#menu-main, #lobby-panel { display: flex; flex-direction: column; gap: 10px; }

input, select {
  width: 100%; padding: 11px 13px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05); color: #e8edf2; font-size: 14px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
select option { background: #101826; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.btn {
  padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07); color: #e8edf2; font-weight: 700; font-size: 13px;
  letter-spacing: 1px; cursor: pointer; transition: all 0.15s;
}
.btn:hover { background: rgba(255,255,255,0.14); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06130c; }
.btn-primary:hover { background: #5cd49c; }
.btn-ghost { background: transparent; }
.btn-small { padding: 4px 10px; font-size: 11px; flex: 0; }

#menu-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 16px; }
.controls-hint { color: #5a6572; font-size: 11px; text-align: center; line-height: 1.7; margin-top: 6px; }

.lobby-code-row { display: flex; align-items: center; gap: 10px; justify-content: center; color: #7b8794; font-size: 13px; }
.lobby-code-row b { font-size: 26px; color: var(--accent2); letter-spacing: 5px; font-family: monospace; }
#lobby-players { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.lobby-player { padding: 8px 12px; border-radius: 6px; background: rgba(255,255,255,0.05); color: #e8edf2; font-size: 14px; }
.lobby-player.team-0 { border-left: 3px solid #3b82f6; }
.lobby-player.team-1 { border-left: 3px solid #ef4444; }
.lobby-wait { text-align: center; color: #5a6572; font-size: 12px; }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.ch-dot { position: absolute; width: 3px; height: 3px; background: #fff; border-radius: 50%; left: -1.5px; top: -1.5px; box-shadow: 0 0 2px #000; }
.ch-l { position: absolute; background: #fff; box-shadow: 0 0 2px #000; }
.ch-t { width: 2px; height: 8px; left: -1px; top: -14px; }
.ch-b { width: 2px; height: 8px; left: -1px; top: 6px; }
.ch-lf { width: 8px; height: 2px; left: -14px; top: -1px; }
.ch-rt { width: 8px; height: 2px; left: 6px; top: -1px; }

#scope-overlay { position: absolute; inset: 0; overflow: hidden; }
.scope-circle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(88vh, 88vw); height: min(88vh, 88vw); border-radius: 50%;
  box-shadow: 0 0 0 3000px rgba(0,0,0,0.97), inset 0 0 60px rgba(0,0,0,0.85);
  background: transparent;
}
.scope-cross-h { position: absolute; left: 0; right: 0; top: 50%; height: 1.5px; background: rgba(0,0,0,0.9); }
.scope-cross-v { position: absolute; top: 0; bottom: 0; left: 50%; width: 1.5px; background: rgba(0,0,0,0.9); }

#hitmarker { position: absolute; left: 50%; top: 50%; }
.hm { position: absolute; animation: hm-pop 0.28s ease-out forwards; }
.hm-l { position: absolute; width: 3px; height: 13px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,0.8); border-radius: 1px; }
.hm-head .hm-l { background: #ffd23f; }
.hm-kill .hm-l { background: #ff4444; height: 17px; }
.hm-1 { transform: rotate(45deg) translate(0, -14px); }
.hm-2 { transform: rotate(135deg) translate(0, -14px); }
.hm-3 { transform: rotate(225deg) translate(0, -14px); }
.hm-4 { transform: rotate(315deg) translate(0, -14px); }
@keyframes hm-pop {
  0% { transform: scale(0.6); opacity: 1; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

#damage-vignette {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(220, 30, 30, 0.55) 100%);
}

#killfeed { position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.kf-entry {
  padding: 6px 12px; background: rgba(10, 14, 20, 0.82); border-radius: 6px; color: #dfe6ee; font-size: 13px;
  border-right: 3px solid var(--accent); animation: kf-in 0.22s ease-out;
}
.kf-entry b { color: var(--accent); }
.kf-tags { color: var(--accent2); font-weight: 800; font-size: 11px; }
@keyframes kf-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

#mlg-banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mlg-pop {
  font-size: 34px; font-weight: 900; letter-spacing: 3px; color: #fff; white-space: nowrap;
  text-shadow: 0 0 18px var(--accent), 0 2px 0 #000;
  animation: mlg-in 0.35s cubic-bezier(0.2, 2.4, 0.4, 1) forwards, mlg-out 0.3s ease-in 1.2s forwards;
}
.mlg-epic {
  font-size: 46px;
  background: linear-gradient(90deg, #ff4757, #ffa502, #ffd23f, #2ed573, #1e90ff, #a55eea);
  background-size: 400% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 12px rgba(255, 210, 63, 0.8)) drop-shadow(0 2px 0 #000);
  animation: mlg-in 0.35s cubic-bezier(0.2, 2.4, 0.4, 1) forwards, rainbow 1s linear infinite, mlg-out 0.4s ease-in 2s forwards;
}
@keyframes mlg-in { from { transform: scale(0.2) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes mlg-out { to { transform: scale(1.3); opacity: 0; } }
@keyframes rainbow { to { background-position: 400% 0; } }

#sticker-layer { position: absolute; inset: 0; overflow: hidden; }
.sticker {
  position: absolute; top: -80px; font-size: 52px;
  animation: sticker-fall var(--dur, 2s) ease-in forwards;
}
.sticker img { width: 72px; height: 72px; object-fit: contain; }
@keyframes sticker-fall {
  from { transform: translateY(0) rotate(0); opacity: 1; }
  to { transform: translateY(115vh) rotate(var(--rot, 360deg)); opacity: 0.9; }
}

#center-msg { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); }
.center-pop {
  font-size: 40px; font-weight: 900; color: #fff; letter-spacing: 4px; white-space: nowrap;
  text-shadow: 0 0 24px rgba(68, 189, 135, 0.9), 0 3px 0 #000;
  animation: mlg-in 0.3s ease-out;
}

#killcam-label {
  position: absolute; top: 8%; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 900; letter-spacing: 8px; color: var(--danger);
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.7);
  animation: kc-blink 1s step-end infinite;
}
@keyframes kc-blink { 50% { opacity: 0.4; } }

#death-overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  font-size: 60px; font-weight: 900; letter-spacing: 10px; color: var(--danger);
  background: rgba(10, 5, 5, 0.45); text-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
  pointer-events: none;
}

#hud-bottom { position: absolute; bottom: 22px; left: 26px; right: 26px; display: flex; align-items: flex-end; gap: 18px; }
#hud-hp { display: flex; align-items: center; gap: 10px; }
.hp-num { font-size: 34px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #000; min-width: 60px; }
.hp-bar { width: 160px; height: 9px; background: rgba(255,255,255,0.14); border-radius: 5px; overflow: hidden; }
.hp-fill { height: 100%; width: 100%; background: #4ade80; transition: width 0.2s, background 0.2s; }
#hud-weapon { color: #e8edf2; font-weight: 800; font-size: 15px; letter-spacing: 2px; background: rgba(10,14,20,0.7); padding: 6px 14px; border-radius: 6px; }
#hud-gadget { color: var(--accent2); font-weight: 800; font-size: 13px; letter-spacing: 1px; background: rgba(10,14,20,0.7); padding: 6px 12px; border-radius: 6px; animation: kc-blink 1.6s step-end infinite; }
#hud-speed { margin-left: auto; color: #7b8794; font-family: monospace; font-size: 15px; }

#hud-top { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); text-align: center; }
#hud-score { font-size: 30px; font-weight: 900; color: #fff; letter-spacing: 4px; text-shadow: 0 2px 0 #000; }
#hud-phase { font-size: 13px; color: var(--accent2); font-weight: 700; letter-spacing: 2px; }
