/* Cab Battle — Spectator View
   Vampire Survivors aesthetic: dark bg, neon accents, retro energy */

:root {
  --bg: #0a0a0f;
  --bg-panel: #12121a;
  --border: #2a2a3a;
  --text: #e0e0e0;
  --text-dim: #888;
  --neon-yellow: #ffe66d;
  --neon-cyan: #4ecdc4;
  --neon-red: #ff6b6b;
  --neon-purple: #a29bfe;
  --wall: #2a2a3a;
  --open: #16161e;
  --pax: #ffe66d;
  --dest: #4ecdc455;
}

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

/* Nav bar */
.nav-bar {
  display: flex;
  gap: 0;
  background: #0d0d14;
  border-bottom: 1px solid var(--border, #2a2a3a);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}
.nav-link {
  color: #888;
  text-decoration: none;
  padding: 0.3rem 1rem;
  text-transform: uppercase;
  font-weight: bold;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
  color: #4ecdc4;
  background: rgba(78,205,196,0.08);
}
.nav-link.active {
  color: #ffe66d;
  border-bottom: 2px solid #ffe66d;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', 'Consolas', monospace;
  overflow: hidden;
  height: 100vh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--neon-yellow);
}

.header h1 {
  font-size: 1.8rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 20px rgba(255,230,109,0.5);
  letter-spacing: 0.3em;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.map-select {
  background: var(--bg-panel);
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  padding: 0.3rem 0.5rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: bold;
  border-radius: 3px;
  cursor: pointer;
}
.map-select:hover {
  box-shadow: 0 0 8px rgba(78,205,196,0.4);
}

.restart-btn {
  background: var(--neon-red);
  color: #fff;
  border: none;
  padding: 0.3rem 1rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 3px;
  text-transform: uppercase;
}
.restart-btn:hover {
  background: #ff4444;
  box-shadow: 0 0 12px rgba(255,107,107,0.5);
}

.lightning-btn {
  background: #2244aa;
  color: #aaddff;
  border: 1px solid #4488ff;
  padding: 0.3rem 1rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 3px;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(100,180,255,0.6);
}
.lightning-btn:hover {
  background: #3366cc;
  box-shadow: 0 0 12px rgba(100,180,255,0.6), 0 0 24px rgba(80,140,255,0.3);
  color: #fff;
}
.lightning-btn:active {
  background: #5588ee;
  box-shadow: 0 0 20px rgba(150,200,255,0.8);
}

/* Tick scrubber */
.scrubber {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.tick-input {
  background: var(--bg);
  color: var(--neon-cyan);
  border: 1px solid var(--border);
  padding: 0.25rem 0.4rem;
  font-family: inherit;
  font-size: 0.8rem;
  width: 5rem;
  text-align: center;
  border-radius: 3px;
}
.tick-input:focus {
  border-color: var(--neon-cyan);
  outline: none;
  box-shadow: 0 0 6px rgba(78,205,196,0.3);
}
.tick-input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}
/* Hide number input spinners */
.tick-input::-webkit-inner-spin-button,
.tick-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tick-input { -moz-appearance: textfield; }

.scrub-btn {
  background: var(--bg-panel);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
}
.scrub-btn:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 6px rgba(78,205,196,0.3);
}
.scrub-btn.resume-btn {
  color: var(--text-dim);
  letter-spacing: -0.1em;
}
.scrub-btn.resume-btn:hover {
  color: #00b894;
  border-color: #00b894;
  box-shadow: 0 0 6px rgba(0,184,148,0.3);
}

#game-info {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

#game-info .tick { color: var(--neon-cyan); }
#game-info .players { color: var(--neon-purple); }
#game-info .passengers { color: var(--neon-yellow); }

/* Arena layout */
.arena {
  display: flex;
  height: calc(100vh - 5rem);
  gap: 1rem;
  padding: 1rem;
}

/* Map */
.map-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 1px;
  background: var(--bg);
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: background-color 0.15s ease;
}

.cell.wall { background: var(--wall); }
.cell.open { background: var(--open); }
.cell.passenger { background: var(--open); }
.cell.destination { background: var(--dest); }
.cell.player {
  background: var(--open) !important;
  border-radius: 2px;
  position: relative;
}

/* ===== ANIMATED SPRITE SYSTEM ===== */
.sprite-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 0;
}

.sprite {
  position: relative;
  display: inline-block;
  width: 1.4rem;
  height: 1.4rem;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
  cursor: default;
  flex-shrink: 0;
  overflow: hidden;
}

/* 4 frame spans stacked on top of each other — CSS cycles visibility.
   All hidden by default. Each frame becomes visible for its 25% window. */
.sf {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0;
}
.sf0 { animation: sf-show 1s steps(1) infinite 0s; }
.sf1 { animation: sf-show 1s steps(1) infinite -0.75s; }
.sf2 { animation: sf-show 1s steps(1) infinite -0.5s; }
.sf3 { animation: sf-show 1s steps(1) infinite -0.25s; }

@keyframes sf-show {
  0%   { opacity: 1; }
  25%  { opacity: 0; }
  100% { opacity: 0; }
}

/* PNG sprite sheet — composed visibility-cycling frames (same pattern as emoji .sf*) */
.sprite-composed {
  position: relative;
  display: inline-block;
  aspect-ratio: var(--sprite-aspect, 1.333);
}
/* Grid sprite (.gs) — fills cell width */
.sprite-composed.gs {
  width: 100% !important;
  height: auto !important;
  overflow: visible;
}
/* Scoreboard sprite (.sbs) — compact inline */
.sprite-composed.sbs {
  width: 1.6rem;
  height: auto;
}
/* Grid rank badge — small accent above sprite */
.rank-badge.rank-grid {
  width: 40%;
  margin-bottom: -2px;
}
.rank-badge.rank-grid .rank-img {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  display: block;
}
.sprite-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-size: var(--sprite-bg-size, 400% 100%);
  overflow: hidden;
  opacity: 0;
}
.pf0 { animation: pf-show 1s steps(1) infinite 0s; }
.pf1 { animation: pf-show 1s steps(1) infinite -0.75s; }
.pf2 { animation: pf-show 1s steps(1) infinite -0.5s; }
.pf3 { animation: pf-show 1s steps(1) infinite -0.25s; }

@keyframes pf-show {
  0%   { opacity: 1; }
  25%  { opacity: 0; }
  100% { opacity: 0; }
}

.rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.rank-badge .rank-img {
  image-rendering: pixelated;
  display: block;
}

/* Text fallback for ranks without PNG */
.rank-badge .rank-num {
  color: var(--neon-yellow);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-weight: 900;
  font-size: 0.65rem;
  text-shadow: 0 0 6px rgba(255,230,109,0.5), 0 1px 2px rgba(0,0,0,0.8);
}

.pax-icon {
  color: var(--neon-yellow);
  font-weight: bold;
  font-size: 0.9rem;
  text-shadow: 0 0 8px rgba(255,230,109,0.8);
}

.loading {
  color: var(--text-dim);
  font-size: 1.2rem;
  text-align: center;
}

/* Sidebar */
.sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.panel h2 {
  font-size: 0.85rem;
  color: var(--neon-cyan);
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

/* Scoreboard — big ranks, medals, HP bars */
.score-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  border-radius: 3px;
  margin-bottom: 2px;
  transition: background-color 0.3s;
}

.score-row.dead { opacity: 0.35; }
.score-row.gold   { background: rgba(255, 215, 0, 0.12); }
.score-row.silver { background: rgba(192, 192, 192, 0.1); }
.score-row.bronze { background: rgba(205, 127, 50, 0.08); }

.score-row .rank-num {
  font-size: 1.2rem;
  font-weight: bold;
  min-width: 2.2rem;
  text-align: center;
  color: var(--text-dim);
}
.score-row.gold .rank-num {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255,215,0,0.5);
}
.score-row.silver .rank-num {
  color: #c0c0c0;
  text-shadow: 0 0 6px rgba(192,192,192,0.4);
}
.score-row.bronze .rank-num {
  color: #cd7f32;
  text-shadow: 0 0 6px rgba(205,127,50,0.4);
}

.score-row .sprite {
  font-size: 1rem;
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
}

.score-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pax-badge {
  background: var(--neon-yellow);
  color: #000;
  font-size: 0.6rem;
  padding: 0 4px;
  border-radius: 2px;
  font-weight: bold;
}

/* HP bar */
.hp-bar {
  width: 40px;
  height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.hp-fill {
  height: 100%;
  background: linear-gradient(to right, var(--neon-red), var(--neon-cyan));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.score-row .score {
  color: var(--neon-yellow);
  font-weight: bold;
  min-width: 50px;
  text-align: right;
}

/* Event feed */
.events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.event {
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: 2px;
  animation: event-flash 0.3s ease-out;
}

.event.kill { color: var(--neon-red); background: rgba(255,107,107,0.1); }
.event.delivery { color: var(--neon-yellow); background: rgba(255,230,109,0.1); }
.event.player-joined { color: var(--neon-cyan); background: rgba(78,205,196,0.1); }
.event.respawn { color: var(--neon-purple); background: rgba(162,155,254,0.1); }
.event.game-over {
  color: var(--neon-yellow);
  background: rgba(255,230,109,0.2);
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  padding: 0.5rem;
}

.empty {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem 0;
}

/* ===== LASER BEAM TRACERS ===== */
/* Beam sweeps across the screen during a tick.
   --d  = this cell's distance from shooter (1-based)
   --tt = total travel distance (cells the beam traverses)
   --tl = tracer length (cells visible at once)
   Each cell: appears at (d/tt), stays lit for (tl/tt) of the animation period.
   Result: a tl-cell beam sliding across tt cells. */
.cell.tracer {
  position: relative;
  overflow: hidden;
  --anim-period: 0.45s;
  animation: laser-cell calc(var(--tl) / var(--tt) * var(--anim-period)) ease-in-out both;
  animation-delay: calc((var(--d) - 1) / var(--tt) * var(--anim-period));
}

/* Horizontal beams — thin bright line through middle */
.cell.tracer-east,
.cell.tracer-west {
  background: var(--open) !important;
}
.cell.tracer-east::after,
.cell.tracer-west::after {
  content: '';
  position: absolute;
  top: 40%;
  left: 0;
  right: 0;
  height: 20%;
  border-radius: 1px;
}
.cell.tracer-east::after {
  background: linear-gradient(to right, rgba(255,60,20,0.3), #ff4400 40%, #ffcc00 80%, #fff);
  box-shadow: 0 0 6px #ff4400, 0 0 12px #ff8800, 0 0 20px rgba(255,200,0,0.5);
}
.cell.tracer-west::after {
  background: linear-gradient(to left, rgba(255,60,20,0.3), #ff4400 40%, #ffcc00 80%, #fff);
  box-shadow: 0 0 6px #ff4400, 0 0 12px #ff8800, 0 0 20px rgba(255,200,0,0.5);
}

/* Vertical beams — thin bright line through center */
.cell.tracer-north,
.cell.tracer-south {
  background: var(--open) !important;
}
.cell.tracer-north::after,
.cell.tracer-south::after {
  content: '';
  position: absolute;
  left: 40%;
  top: 0;
  bottom: 0;
  width: 20%;
  border-radius: 1px;
}
.cell.tracer-south::after {
  background: linear-gradient(to bottom, rgba(255,60,20,0.3), #ff4400 40%, #ffcc00 80%, #fff);
  box-shadow: 0 0 6px #ff4400, 0 0 12px #ff8800, 0 0 20px rgba(255,200,0,0.5);
}
.cell.tracer-north::after {
  background: linear-gradient(to top, rgba(255,60,20,0.3), #ff4400 40%, #ffcc00 80%, #fff);
  box-shadow: 0 0 6px #ff4400, 0 0 12px #ff8800, 0 0 20px rgba(255,200,0,0.5);
}

@keyframes laser-cell {
  0% { opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== HIT — sparks burst from car ===== */
.cell.hit {
  position: relative;
  overflow: visible;
  z-index: 5;
  animation: hit-shake 0.3s ease-out;
}

.hit-fx {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hit-fx .sprite-cell { z-index: 2; }

.sparks.small {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sparks.small .spark {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffcc00;
  box-shadow: 0 0 4px #ff8800;
}

.sparks.small .spark:nth-child(1) { top: 50%; left: 50%; animation: spark-fly 0.4s ease-out forwards; --sx: -12px; --sy: -10px; }
.sparks.small .spark:nth-child(2) { top: 50%; left: 50%; animation: spark-fly 0.4s 0.05s ease-out forwards; --sx: 10px; --sy: -8px; }
.sparks.small .spark:nth-child(3) { top: 50%; left: 50%; animation: spark-fly 0.4s 0.08s ease-out forwards; --sx: -8px; --sy: 12px; }
.sparks.small .spark:nth-child(4) { top: 50%; left: 50%; animation: spark-fly 0.4s 0.03s ease-out forwards; --sx: 11px; --sy: 9px; }

@keyframes spark-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--sx), var(--sy)) scale(0.3); opacity: 0; }
}

@keyframes hit-shake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1px, -1px); }
}

/* ===== NUCLEAR KILL — 3x smoke + massive sparks ===== */
.cell.nuke {
  position: relative;
  overflow: visible;
  z-index: 10;
  background: rgba(255, 68, 0, 0.6) !important;
  animation: nuke-cell 0.8s ease-out;
  box-shadow: 0 0 50px rgba(255,68,0,1), 0 0 100px rgba(255,200,0,0.5);
}

.nuke-fx {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Massive smoke cloud — 3x bigger */
.smoke {
  position: absolute;
  inset: -150%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,100,0,0.7) 0%,
    rgba(120,60,0,0.5) 25%,
    rgba(80,80,80,0.6) 45%,
    rgba(40,40,40,0.3) 65%,
    transparent 80%);
  animation: smoke-rise 1s ease-out forwards;
  z-index: 1;
}

/* Sparks burst outward — bigger, more */
.sparks {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.sparks .spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
}

.sparks .spark:nth-child(1)  { background: #fff; box-shadow: 0 0 10px #ff8800, 0 0 20px #ff4400; animation: spark-fly 0.7s ease-out forwards; --sx: -45px; --sy: -35px; }
.sparks .spark:nth-child(2)  { background: #ffcc00; box-shadow: 0 0 10px #ff4400, 0 0 20px #ff0000; animation: spark-fly 0.7s 0.03s ease-out forwards; --sx: 40px; --sy: -30px; }
.sparks .spark:nth-child(3)  { background: #ff8800; box-shadow: 0 0 10px #ff0000, 0 0 20px #cc0000; animation: spark-fly 0.7s 0.06s ease-out forwards; --sx: -35px; --sy: 40px; }
.sparks .spark:nth-child(4)  { background: #fff; box-shadow: 0 0 10px #ffcc00, 0 0 20px #ff8800; animation: spark-fly 0.7s 0.02s ease-out forwards; --sx: 45px; --sy: 25px; }
.sparks .spark:nth-child(5)  { background: #ffcc00; box-shadow: 0 0 10px #ff8800, 0 0 20px #ff4400; animation: spark-fly 0.7s 0.05s ease-out forwards; --sx: -15px; --sy: -48px; }
.sparks .spark:nth-child(6)  { background: #ff4400; box-shadow: 0 0 10px #ff0000, 0 0 20px #cc0000; animation: spark-fly 0.7s 0.08s ease-out forwards; --sx: 20px; --sy: 48px; }
.sparks .spark:nth-child(7)  { background: #fff; box-shadow: 0 0 8px #ffcc00; animation: spark-fly 0.8s 0.04s ease-out forwards; --sx: -50px; --sy: 5px; width: 4px; height: 4px; }
.sparks .spark:nth-child(8)  { background: #ffcc00; box-shadow: 0 0 8px #ff8800; animation: spark-fly 0.8s 0.07s ease-out forwards; --sx: 50px; --sy: -8px; width: 4px; height: 4px; }
.sparks .spark:nth-child(9)  { background: #ff8800; box-shadow: 0 0 8px #ff4400; animation: spark-fly 0.8s 0.1s ease-out forwards; --sx: 5px; --sy: 52px; width: 3px; height: 3px; }
.sparks .spark:nth-child(10) { background: #fff; box-shadow: 0 0 8px #ff8800; animation: spark-fly 0.8s 0.02s ease-out forwards; --sx: -8px; --sy: -52px; width: 3px; height: 3px; }
.sparks .spark:nth-child(11) { background: #ffcc00; box-shadow: 0 0 12px #ff4400; animation: spark-fly 0.9s 0.06s ease-out forwards; --sx: -38px; --sy: -38px; width: 6px; height: 6px; }
.sparks .spark:nth-child(12) { background: #ff4400; box-shadow: 0 0 12px #ff0000; animation: spark-fly 0.9s 0.09s ease-out forwards; --sx: 38px; --sy: 38px; width: 6px; height: 6px; }

@keyframes smoke-rise {
  0% { transform: scale(0.2); opacity: 0; }
  15% { transform: scale(0.8); opacity: 1; }
  40% { transform: scale(1.2); opacity: 0.8; }
  100% { transform: scale(2) translateY(-20%); opacity: 0; }
}

@keyframes nuke-cell {
  0% { background: #ffffff !important; box-shadow: 0 0 80px rgba(255,255,255,1), 0 0 150px rgba(255,200,0,0.8); transform: scale(1.3); }
  15% { background: #ffcc00 !important; box-shadow: 0 0 60px rgba(255,200,0,1); transform: scale(1.2); }
  35% { background: #ff8800 !important; box-shadow: 0 0 40px rgba(255,136,0,0.8); transform: scale(1.1); }
  100% { background: rgba(255,68,0,0.2) !important; box-shadow: none; transform: scale(1); }
}

/* ===== BASE ANIMATIONS ===== */

@keyframes event-flash {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== BATTLE ROYALE SHRINK WARNING — ring of fire ===== */

.cell.shrink-warning {
  position: relative;
  overflow: visible;
  z-index: 10;
  background: rgba(255, 80, 0, 0.4) !important;
  animation: fire-pulse 0.4s ease-in-out infinite alternate;
  box-shadow:
    inset 0 0 8px rgba(255, 100, 0, 0.8),
    0 0 12px rgba(255, 60, 0, 0.6),
    0 0 24px rgba(255, 40, 0, 0.3);
}

.cell.shrink-warning::before {
  content: '';
  position: absolute;
  inset: -20% -20%;
  background: radial-gradient(circle,
    rgba(255, 200, 50, 0.6) 0%,
    rgba(255, 100, 0, 0.4) 40%,
    rgba(255, 40, 0, 0.2) 70%,
    transparent 100%);
  animation: fire-flicker 0.25s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes fire-pulse {
  0%   { background: rgba(255, 80, 0, 0.3) !important;
         box-shadow: inset 0 0 6px rgba(255,100,0,0.6), 0 0 8px rgba(255,60,0,0.4); }
  100% { background: rgba(255, 120, 0, 0.6) !important;
         box-shadow: inset 0 0 12px rgba(255,160,0,1), 0 0 20px rgba(255,80,0,0.8), 0 0 40px rgba(255,40,0,0.4); }
}

@keyframes fire-flicker {
  0%   { opacity: 0.5; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.1); }
}

/* ===== CRATER FIRE — burning aftermath of lightning ===== */

.cell.crater-fire {
  position: relative;
  overflow: visible;
  background: rgba(180, 60, 0, 0.5) !important;
  animation: crater-burn 0.5s ease-in-out infinite alternate;
  box-shadow:
    inset 0 0 6px rgba(255, 120, 0, 0.7),
    0 0 8px rgba(255, 60, 0, 0.4);
}

.cell.crater-fire::before {
  content: '';
  position: absolute;
  inset: -10%;
  background: radial-gradient(circle,
    rgba(255, 160, 40, 0.5) 0%,
    rgba(255, 80, 0, 0.3) 50%,
    transparent 100%);
  animation: crater-fire-flicker 0.3s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes crater-burn {
  0%   { background: rgba(160, 50, 0, 0.4) !important;
         box-shadow: inset 0 0 4px rgba(255,100,0,0.5), 0 0 6px rgba(255,50,0,0.3); }
  100% { background: rgba(200, 80, 0, 0.6) !important;
         box-shadow: inset 0 0 10px rgba(255,140,0,0.8), 0 0 14px rgba(255,60,0,0.5); }
}

@keyframes crater-fire-flicker {
  0%   { opacity: 0.6; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}

/* ===== LIGHTNING STRIKE — electric blue catastrophe ===== */

/* Center cell — the strike point. Massive flash + bolt */
.cell.lightning-center {
  position: relative;
  overflow: visible;
  z-index: 20;
  background: rgba(100, 180, 255, 0.9) !important;
  animation: lightning-flash-cell 1s ease-out;
  box-shadow: 0 0 80px rgba(100,180,255,1), 0 0 160px rgba(150,220,255,0.8), 0 0 240px rgba(80,140,255,0.4);
}

.lightning-fx {
  position: relative;
  width: 100%;
  height: 100%;
}

/* The bolt — a bright vertical line */
.lightning-bolt {
  position: absolute;
  left: 40%;
  top: -400%;
  width: 20%;
  height: 500%;
  background: linear-gradient(to bottom,
    rgba(200,220,255,0) 0%,
    rgba(200,220,255,0.6) 20%,
    #fff 50%,
    rgba(150,200,255,0.8) 80%,
    rgba(100,180,255,0.3) 100%);
  filter: blur(1px);
  animation: bolt-strike 0.8s ease-out forwards;
  z-index: 3;
}

/* Screen flash overlay on the center cell */
.lightning-flash {
  position: absolute;
  inset: -300%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,255,255,0.9) 0%,
    rgba(150,200,255,0.7) 20%,
    rgba(100,160,255,0.4) 40%,
    rgba(60,120,255,0.2) 60%,
    transparent 80%);
  animation: lightning-flash-expand 1s ease-out forwards;
  z-index: 1;
}

/* Sparks from lightning reuse the nuke spark styles but electric blue */
.lightning-fx .sparks .spark {
  background: #aaddff !important;
  box-shadow: 0 0 10px #66bbff, 0 0 20px #4488ff !important;
}

/* Blast radius cells — scorched crater */
.cell.lightning-blast {
  position: relative;
  overflow: visible;
  z-index: 8;
  background: rgba(60, 100, 160, 0.5) !important;
  animation: crater-form 0.8s ease-out;
  box-shadow: inset 0 0 8px rgba(100,180,255,0.4), 0 0 15px rgba(80,140,255,0.3);
}

.crater-fx {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle,
    rgba(40,60,80,0.8) 0%,
    rgba(30,40,60,0.6) 60%,
    rgba(20,30,50,0.4) 100%);
  border-radius: 2px;
  animation: crater-glow 1.2s ease-out forwards;
}

@keyframes lightning-flash-cell {
  0% { background: #ffffff !important; box-shadow: 0 0 120px rgba(255,255,255,1), 0 0 200px rgba(150,200,255,1); transform: scale(1.5); }
  10% { background: #aaddff !important; box-shadow: 0 0 100px rgba(150,200,255,1); transform: scale(1.4); }
  30% { background: #6699cc !important; box-shadow: 0 0 60px rgba(100,160,255,0.8); transform: scale(1.2); }
  100% { background: rgba(60,100,160,0.4) !important; box-shadow: none; transform: scale(1); }
}

@keyframes bolt-strike {
  0% { opacity: 0; transform: scaleY(0.3) scaleX(2); }
  8% { opacity: 1; transform: scaleY(1) scaleX(1); }
  15% { opacity: 0.4; transform: scaleY(1) scaleX(0.8); }
  22% { opacity: 1; transform: scaleY(1) scaleX(1.5); }
  35% { opacity: 0.8; }
  100% { opacity: 0; transform: scaleY(1) scaleX(0.5); }
}

@keyframes lightning-flash-expand {
  0% { transform: scale(0.3); opacity: 1; }
  15% { transform: scale(1); opacity: 0.8; }
  30% { transform: scale(1.5); opacity: 0.4; }
  100% { transform: scale(2.5); opacity: 0; }
}

@keyframes crater-form {
  0% { background: rgba(200,230,255,0.8) !important; box-shadow: 0 0 30px rgba(150,200,255,0.8); transform: scale(1.2); }
  30% { background: rgba(100,150,200,0.6) !important; box-shadow: 0 0 15px rgba(100,160,255,0.5); transform: scale(1.05); }
  100% { background: rgba(40,60,80,0.5) !important; box-shadow: inset 0 0 5px rgba(60,100,140,0.3); transform: scale(1); }
}

@keyframes crater-glow {
  0% { box-shadow: inset 0 0 10px rgba(100,180,255,0.6); }
  100% { box-shadow: inset 0 0 3px rgba(60,100,140,0.2); }
}

/* Event feed — lightning events are LOUD */
.event.lightning {
  color: #66ccff;
  background: rgba(100,180,255,0.2);
  font-size: 0.9rem;
  font-weight: bold;
  border-left: 3px solid #4488ff;
  padding: 0.3rem 0.5rem;
  text-shadow: 0 0 8px rgba(100,180,255,0.5);
  animation: lightning-event-flash 0.5s ease-out;
}

@keyframes lightning-event-flash {
  0% { background: rgba(200,230,255,0.6); color: #fff; }
  30% { background: rgba(100,180,255,0.3); }
  100% { background: rgba(100,180,255,0.2); }
}

/* Responsive — scale to projector */
@media (min-width: 1920px) {
  .header h1 { font-size: 2.5rem; }
  .cell { font-size: 1rem; }
  .sprite { font-size: 1.6rem; }
  .rank-badge .rank-num { font-size: 0.7rem; }
  .rank-badge .color-dot { width: 8px; height: 8px; }
  .score-row .rank-num { font-size: 1.6rem; }
  .score-row .sprite { font-size: 1.3rem; }
  .sidebar { width: 350px; }
}
