:root {
  --font-display: "Chakra Petch", -apple-system, sans-serif;
  --font-heading: "Rajdhani", sans-serif;
  --font-mono: "Space Grotesk", monospace;
  --font-body: "Space Grotesk", -apple-system, sans-serif;

  --bg-main: #080b11;
  --bg-surface: #0e131d;
  --bg-card: rgba(14, 20, 31, 0.95);
  --bg-input: rgba(255, 255, 255, 0.05);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(0, 229, 255, 0.35);
  --border-focus: #00e5ff;

  --color-text: #e2e8f0;
  --color-text-dim: #8b9bb4;
  --color-cyan: #00e5ff;
  --color-cyan-glow: rgba(0, 229, 255, 0.4);
  --color-amber: #ffb800;
  --color-crimson: #ff3366;
  --color-emerald: #10b981;

  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  color: var(--color-text);
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  align-items: start;
  justify-items: center;
  padding: 10px 14px 24px;
  row-gap: 8px;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(circle at 50% 0%, #151e2c 0%, #080b11 70%),
    linear-gradient(rgba(0, 229, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 36px 36px, 36px 36px;
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ==========================================================================
   Header & Brand
   ========================================================================== */

header {
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  background: rgba(0, 229, 255, 0.12);
  color: var(--color-cyan);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 16px var(--color-cyan-glow);
}

.subtitle {
  margin: 0;
  color: var(--color-text-dim);
  text-align: right;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  flex: 1;
}

/* ==========================================================================
   HUD (Heads-Up Display)
   ========================================================================== */

#hud {
  width: min(1080px, 98vw);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(14, 20, 31, 0.94);
  border: 1px solid var(--border-highlight);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-xs);
}

.stat-lbl {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-text-dim);
}

.stat-val {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  line-height: 1;
}

#score {
  color: var(--color-cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

#missed {
  color: #ff5252;
}

.accent-combo {
  color: var(--color-amber);
}

.accent-super {
  color: var(--color-emerald);
}

#super.ready {
  color: #00e5ff;
  animation: superPulse 1s infinite alternate;
}

@keyframes superPulse {
  from { filter: drop-shadow(0 0 2px #00e5ff); }
  to { filter: drop-shadow(0 0 8px #00e5ff); }
}

#gun.active {
  color: var(--color-crimson);
  font-weight: 800;
}

.stat-mode select {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.5);
  color: var(--color-cyan);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  outline: none;
}

.hud-buttons {
  display: flex;
  gap: 6px;
}

.hud-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transition: all 120ms ease;
  text-transform: uppercase;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.hud-btn.secondary {
  background: transparent;
  color: var(--color-text-dim);
  border-color: rgba(255, 255, 255, 0.08);
}

.hud-btn.secondary:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */

.btn-primary {
  appearance: none;
  border: 1px solid #00f0ff;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  background: linear-gradient(135deg, #00d9ff, #0088ff);
  color: #030811;
  box-shadow: 0 4px 14px rgba(0, 217, 255, 0.3);
  transition: all 120ms ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 217, 255, 0.5);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(1px);
}

.menu-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}

.menu-input,
#mode-select,
#menu-mode,
#menu-game-type {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--bg-input);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 150ms ease;
}

.menu-input:focus,
#menu-mode:focus,
#menu-game-type:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--color-cyan-glow);
}

.menu-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

select option {
  background: #0f1522;
  color: #e2e8f0;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

/* ==========================================================================
   Toggles (Tactical Rocker Switch)
   ========================================================================== */

.menu-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 14px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.toggle-desc {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.toggle {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.toggle input {
  appearance: none;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.toggle-slider {
  position: absolute;
  inset: 2px;
  border-radius: 9px;
  background: #1a2230;
  transition: background 150ms ease;
  pointer-events: none;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #94a3b8;
  top: 1px;
  left: 1px;
  transform: translateX(0);
  transition: transform 150ms ease, background 150ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toggle input:checked + .toggle-slider {
  background: rgba(0, 229, 255, 0.25);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(22px);
  background: var(--color-cyan);
  box-shadow: 0 0 8px var(--color-cyan);
}

/* ==========================================================================
   Typing Row
   ========================================================================== */

#typing-row {
  width: min(1080px, 98vw);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 20, 31, 0.94);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

#typing-row label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-cyan);
}

#typing-box {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  outline: none;
}

#typing-box:focus {
  border-color: var(--color-cyan);
  box-shadow: 0 0 8px var(--color-cyan-glow);
}

/* ==========================================================================
   Play Container & Panes
   ========================================================================== */

#play-container {
  width: min(1200px, 98vw);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  margin: 0 auto;
}

.pane {
  background: rgba(14, 20, 31, 0.9);
  border-radius: var(--radius-lg);
  padding: 12px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  flex: 1 1 480px;
  max-width: 580px;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 4px;
}

.pane-title {
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-indicator {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.player-indicator.live {
  background: var(--color-cyan);
  box-shadow: 0 0 8px var(--color-cyan);
}

.player-indicator.rival {
  background: var(--color-crimson);
  box-shadow: 0 0 8px var(--color-crimson);
}

.mode-tag {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-dim);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#remote-stage-wrapper {
  position: relative;
}

#remote-stage-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 4;
}

#remote-board {
  display: flex;
  gap: 6px;
  background: rgba(8, 12, 18, 0.85);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-family: var(--font-heading);
  font-weight: 700;
}

.chip-lbl {
  font-family: var(--font-display);
  font-size: 0.62rem;
  color: var(--color-text-dim);
}

/* ==========================================================================
   Game Stage & Arenas
   ========================================================================== */

.game-stage {
  position: relative;
  width: 100%;
  max-width: 550px;
  height: min(650px, 68vh);
  background-color: #060910;
  background-image:
    linear-gradient(180deg, rgba(10, 18, 30, 0.8) 0%, rgba(4, 7, 12, 0.95) 100%),
    linear-gradient(rgba(0, 229, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px, 24px 24px;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.9),
    0 18px 36px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 229, 255, 0.2);
  cursor: none;
  margin: 0 auto;
}

#game-area {
  cursor: none;
}

.game-stage.mirror {
  cursor: default;
  opacity: 0.95;
  border-color: rgba(255, 51, 102, 0.2);
}

.game-stage.paused::after {
  content: "PAUSED";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--color-cyan);
  text-shadow: 0 0 20px var(--color-cyan-glow);
  background: rgba(4, 7, 12, 0.75);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.remote-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: var(--color-text-dim);
  background: rgba(6, 9, 16, 0.85);
  text-transform: uppercase;
}

/* Match Countdown */
.match-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 800;
  color: var(--color-cyan);
  text-shadow: 0 0 30px var(--color-cyan);
  background: rgba(4, 7, 12, 0.6);
  backdrop-filter: blur(2px);
  z-index: 15;
  pointer-events: none;
  animation: countdownPulse 0.9s ease-out infinite;
}

@keyframes countdownPulse {
  0% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}

/* ==========================================================================
   Tactical Crosshair
   ========================================================================== */

.crosshair {
  position: absolute;
  width: 38px;
  height: 38px;
  border: 1.5px solid rgba(0, 229, 255, 0.8);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 4px var(--color-cyan-glow));
  z-index: 6;
  opacity: 0.9;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(0, 229, 255, 0.95);
}

.crosshair::before {
  width: 2px;
  height: 24px;
  transform: translate(-50%, -50%);
}

.crosshair::after {
  width: 24px;
  height: 2px;
  transform: translate(-50%, -50%);
}

.crosshair.chaingun {
  border-color: rgba(255, 51, 102, 0.95);
  filter: drop-shadow(0 0 6px rgba(255, 51, 102, 0.6));
  animation: reticleSpin 4s linear infinite;
}

.crosshair.chaingun::before,
.crosshair.chaingun::after {
  background: rgba(255, 51, 102, 0.95);
}

@keyframes reticleSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

#remote-crosshair {
  border-color: rgba(255, 51, 102, 0.85);
}

#remote-crosshair::before,
#remote-crosshair::after {
  background: rgba(255, 51, 102, 0.9);
}

/* ==========================================================================
   Balloons (Tactical Shapes & Vibrant Gloss)
   ========================================================================== */

.balloon {
  position: absolute;
  top: 0;
  left: 0;
  --balloon-x: 0px;
  --balloon-y: 0px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background:
    radial-gradient(
      circle at 32% 28%,
      rgba(255, 255, 255, 0.85),
      rgba(255, 255, 255, 0) 38%
    ),
    var(--balloon-color, #00e5ff);
  box-shadow:
    inset -4px -10px 18px rgba(0, 0, 0, 0.35),
    0 10px 18px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transform: translate3d(var(--balloon-x, 0px), var(--balloon-y, 0px), 0)
    scale(1) rotate(calc(var(--twist, 0deg)));
  transition: transform 90ms ease;
  will-change: transform;
}

/* Balloon knot */
.balloon::before {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 8px;
  height: 5px;
  background: inherit;
  border-radius: 2px 2px 50% 50%;
  transform: translateX(-50%);
  filter: brightness(0.85);
  pointer-events: none;
}

/* Balloon string */
.balloon::after {
  content: "";
  width: 1.5px;
  height: 22px;
  background: rgba(255, 255, 255, 0.35);
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Balloon word label */
.balloon-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translate(-50%, 0);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(4, 7, 12, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.balloon.typing-target .balloon-label {
  color: #00e5ff;
  border-color: #00e5ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.balloon.typing-target-danger .balloon-label {
  color: var(--color-crimson);
  border-color: var(--color-crimson);
  box-shadow: 0 0 8px rgba(255, 51, 102, 0.6);
}

/* Bomb balloon */
.balloon-bomb {
  --balloon-color: radial-gradient(circle at 35% 30%, #3a3d42, #08090a);
  border: 1.5px solid rgba(255, 51, 102, 0.6);
  box-shadow:
    inset -5px -8px 16px rgba(0, 0, 0, 0.9),
    0 8px 18px rgba(255, 51, 102, 0.3);
}

.balloon-bomb .danger-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 35% 40%, #000 2.5px, transparent 3px),
    radial-gradient(circle at 65% 40%, #000 2.5px, transparent 3px),
    radial-gradient(circle at 50% 70%, #000 3px, transparent 3.5px),
    #ff3366;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 6px #ff3366;
}

/* Powerup balloon */
.balloon-power {
  --balloon-color: linear-gradient(150deg, #ffc837, #ff8008);
  box-shadow:
    0 8px 20px rgba(255, 160, 0, 0.45),
    inset -4px -8px 12px rgba(180, 80, 0, 0.5);
}

/* Gold balloon */
.balloon-gold {
  --balloon-color: linear-gradient(140deg, #fff7c2, #f59e0b 60%, #b45309);
  border: 1.5px solid #ffea79;
  box-shadow:
    0 0 20px rgba(245, 158, 11, 0.5),
    inset -5px -10px 14px rgba(120, 53, 15, 0.6);
}

.balloon-gold .gold-icon {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fff 0%, #ffd700 70%);
  box-shadow: 0 0 10px #ffd700;
  pointer-events: none;
}

/* Ice balloon */
.balloon-ice {
  --balloon-color: linear-gradient(140deg, #e0f2fe, #38bdf8 65%, #0284c7);
  border: 1.5px solid #bae6fd;
  box-shadow:
    0 0 18px rgba(56, 189, 248, 0.5),
    inset -4px -8px 12px rgba(3, 105, 161, 0.5);
}

/* Shield balloon */
.balloon-shield {
  --balloon-color: linear-gradient(140deg, #94a3b8, #475569 80%);
  border: 2px solid var(--color-cyan);
  box-shadow:
    0 0 16px rgba(0, 229, 255, 0.4),
    inset -4px -8px 12px rgba(15, 23, 42, 0.7);
}

.balloon-shield::before {
  content: attr(data-shield);
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--color-cyan);
  text-shadow: 0 0 8px var(--color-cyan);
}

/* Ghost balloon */
.balloon-ghost {
  --balloon-color: linear-gradient(140deg, #e2e8f0, #818cf8 80%);
  box-shadow:
    0 0 16px rgba(129, 140, 248, 0.35),
    inset -4px -8px 12px rgba(49, 46, 129, 0.4);
  animation: ghostFade 2s infinite alternate;
}

@keyframes ghostFade {
  0% { opacity: 0.25; }
  100% { opacity: 0.92; }
}

/* Balloon Pop Animations */
.balloon.pop {
  animation: pop 280ms forwards ease-out;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.8));
}

@keyframes pop {
  0% {
    transform: translate3d(var(--balloon-x, 0px), var(--balloon-y, 0px), 0) scale(1);
  }
  50% {
    transform: translate3d(var(--balloon-x, 0px), var(--balloon-y, 0px), 0) scale(1.35);
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--balloon-x, 0px), var(--balloon-y, 0px), 0) scale(1.7);
  }
}

.pop-burst {
  position: absolute;
  width: 80px;
  height: 80px;
  margin-left: -40px;
  margin-bottom: -40px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(0, 229, 255, 0.3) 55%, transparent 75%);
  box-shadow: 0 0 25px rgba(0, 229, 255, 0.4);
  animation: popBurst 380ms ease-out forwards;
  z-index: 6;
}

@keyframes popBurst {
  from { opacity: 0.95; transform: scale(0.3); }
  to { opacity: 0; transform: scale(1.3); }
}

/* Screen Shake */
@keyframes screenShake {
  0% { transform: translate(1px, 1px); }
  25% { transform: translate(-2px, -1px); }
  50% { transform: translate(2px, 1px); }
  75% { transform: translate(-1px, 2px); }
  100% { transform: translate(0px, 0px); }
}
.shake {
  animation: screenShake 0.22s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Balloon Hit Flash */
@keyframes balloonHit {
  0% { filter: brightness(1); }
  50% { filter: brightness(2) drop-shadow(0 0 10px #00e5ff); }
  100% { filter: brightness(1); }
}
.balloon-hit {
  animation: balloonHit 0.14s ease-out;
}

/* Floating Points */
.floating-text {
  position: absolute;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 20;
  animation: floatUp 0.75s ease-out forwards;
}

.floating-text.combo-text {
  color: var(--color-amber);
  font-size: 1.5rem;
  text-shadow: 0 0 12px rgba(255, 184, 0, 0.9), 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.9); }
  100% { opacity: 0; transform: translate(-50%, -45px) scale(1.2); }
}

/* Particles */
.particle {
  position: absolute;
  border-radius: var(--radius-xs);
  pointer-events: none;
  z-index: 15;
  animation: particleFade 0.55s ease-out forwards;
}

@keyframes particleFade {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); }
}

/* Bullet Trails & Impacts */
.bullet-trail {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.95), rgba(0, 229, 255, 0));
  transform-origin: 0 50%;
  pointer-events: none;
  opacity: 0.9;
  animation: bulletZap 200ms ease-out forwards;
  filter: drop-shadow(0 0 4px var(--color-cyan));
  z-index: 6;
}

.bullet-trail.shotgun {
  height: 4px;
  background: linear-gradient(90deg, rgba(255, 184, 0, 0.95), rgba(255, 184, 0, 0));
  filter: drop-shadow(0 0 6px var(--color-amber));
}

.bullet-impact {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--color-cyan) 60%, transparent 80%);
  box-shadow: 0 0 8px var(--color-cyan);
  transform: translate(-50%, -50%) scale(0.6);
  pointer-events: none;
  animation: bulletImpact 240ms ease-out forwards;
  z-index: 7;
}

.bullet-impact.shotgun {
  background: radial-gradient(circle, #fff 0%, var(--color-amber) 60%, transparent 80%);
  box-shadow: 0 0 10px var(--color-amber);
}

.bullet-impact.miss {
  background: radial-gradient(circle, rgba(200, 200, 200, 0.8) 0%, rgba(100, 100, 100, 0.3) 60%, transparent 80%);
  box-shadow: none;
}

@keyframes bulletZap {
  from { opacity: 0.95; }
  to { opacity: 0; transform: translate(0, -50%) scaleX(1.1); }
}

@keyframes bulletImpact {
  from { opacity: 0.95; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

/* ==========================================================================
   Overlays & Modals
   ========================================================================== */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 12, 0.82);
  backdrop-filter: blur(5px);
  color: #fff;
  text-align: center;
  z-index: 25;
  pointer-events: auto;
}

#main-menu.overlay,
#lobby.overlay {
  position: fixed;
  z-index: 50;
}

#menu-card,
#lobby-card,
#overlay-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-lg);
  width: min(380px, 92%);
  border: 1px solid var(--border-highlight);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  pointer-events: all;
  text-align: left;
}

#overlay-card {
  width: min(440px, 94%);
}

.card-header {
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

#menu-card h2,
#lobby-card h2,
#overlay-card h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

#reason {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-crimson);
  margin-bottom: 12px;
}

.final-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.final-line {
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.f-lbl {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-dim);
  text-transform: uppercase;
}

.final-line strong {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: #fff;
}

/* Leaderboard Save */
#save-score-row {
  width: 100%;
  margin: 10px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.save-score-controls {
  display: flex;
  gap: 8px;
}

#score-name-input {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--bg-input);
  color: #fff;
  font-family: var(--font-mono);
}

#score-name-input:focus {
  border-color: var(--color-cyan);
}

#save-score-status {
  min-height: 18px;
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

#scoreboard {
  margin: 12px 0 16px;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-family: var(--font-mono);
}

#scoreboard tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

#scoreboard td {
  padding: 6px 8px;
}

#scoreboard tr.you td {
  color: var(--color-cyan);
  font-weight: 700;
}

#survivor-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

/* Lobby Overlay Styles */
.lobby-code-box {
  margin: 12px 0;
  padding: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.lobby-code-row {
  display: flex;
  gap: 8px;
}

#lobby-code-input {
  flex: 1;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.14em;
  font-weight: 700;
  text-align: center;
}

.lobby-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

#lobby-wait {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin: 10px 0;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

#lobby-code {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  letter-spacing: 0.16em;
  color: var(--color-cyan);
}

.waiting-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 229, 255, 0.3);
  border-top-color: var(--color-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.lobby-list-container {
  margin-top: 10px;
}

.lobby-list-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

#lobby-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
}

.lobby-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.lobby-item span {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.lobby-item button {
  appearance: none;
  background: var(--color-cyan);
  border: none;
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #050b14;
  cursor: pointer;
  text-transform: uppercase;
}

.lobby-item button:hover {
  filter: brightness(1.15);
}

.lobby-item button:disabled {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  cursor: not-allowed;
}

/* Status Message */
#status-message {
  min-height: 22px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-cyan);
  text-shadow: 0 0 10px var(--color-cyan-glow);
  opacity: 0;
  transition: opacity 160ms ease;
  text-transform: uppercase;
  font-size: 0.88rem;
}

#status-message.visible {
  opacity: 1;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 820px) {
  #hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .hud-buttons {
    grid-column: span 3;
    justify-content: center;
  }

  .game-stage {
    height: min(520px, 65vh);
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .subtitle {
    text-align: left;
  }
}
