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

:root {
  --bg: #eef0f4;
  --ink: #16181d;
  --ink-soft: #4a4f5a;
  --ink-faint: #8a8f9a;
  --panel: #ffffff;
  --laser: #12b8a0;
  --alien: #59c94f;
  --moon: #a9a9b6;
}

html, body { height: 100%; }

body {
  font-family: "Public Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "IBM Plex Mono", monospace; }

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.back {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color 0.15s;
}
.back:hover { color: var(--ink); }

.head { margin: 26px 0 18px; }

.wordmark {
  position: relative;
  display: inline-block;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}

.zapline {
  position: absolute;
  left: 2px;
  bottom: -14px;
  width: 100%;
  height: 20px;
  overflow: visible;
}
.zap-beam, .zap-core {
  stroke-dasharray: 212;
  stroke-dashoffset: 212;
  animation: zap-in 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) 0.25s forwards;
}
.zap-alien {
  opacity: 0;
  animation: alien-pop 0.35s ease-out 0.85s forwards;
}
@keyframes zap-in { to { stroke-dashoffset: 0; } }
@keyframes alien-pop {
  0% { opacity: 0; transform: translateY(6px) scale(0.6); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.1); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.tag {
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.hud {
  display: flex;
  gap: 10px;
  margin: 18px 0 12px;
  flex-wrap: wrap;
}
.hud-item {
  background: var(--panel);
  border: 1px solid #dde0e8;
  border-radius: 10px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 92px;
}
.hud-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.hud-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#kills { color: var(--alien); }
#speed { color: var(--laser); }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #05050a;
  box-shadow: 0 18px 44px rgba(20, 24, 40, 0.28);
}
.stage canvas { display: block; width: 100%; height: 100%; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 12, 0.62);
  backdrop-filter: blur(3px);
  transition: opacity 0.25s;
  z-index: 5;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-inner { text-align: center; color: #f2f3f8; padding: 20px; }

.overlay-title {
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.01em;
}

.overlay-sub {
  margin-top: 10px;
  color: #b8bdd0;
  font-size: 1rem;
}

.overlay-controls {
  list-style: none;
  margin-top: 18px;
  font-size: 0.82rem;
  color: #9aa0b6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.overlay-controls b { color: #e4e7f2; font-weight: 600; }

.restart {
  margin-top: 20px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: #05050a;
  background: var(--laser);
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.restart:hover { background: #17d4b9; transform: translateY(-1px); }
.restart.hidden { display: none; }

.hint {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-align: center;
}

.mute-btn {
  margin-left: 10px;
  font-size: 0.9rem;
  background: none;
  border: 1px solid #dde0e8;
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  vertical-align: middle;
}
.mute-btn:hover { border-color: var(--ink-faint); }

/* in-stage feedback layers (populated by app.js) */
.popup-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}

.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 1.1rem;
  color: #7df06f;
  text-shadow: 0 0 12px rgba(89, 201, 79, 0.8), 0 1px 2px rgba(0, 0, 0, 0.6);
  animation: pop-float 0.9s ease-out forwards;
}
@keyframes pop-float {
  0% { opacity: 0; margin-top: 0; scale: 0.6; }
  15% { opacity: 1; scale: 1.15; }
  30% { scale: 1; }
  100% { opacity: 0; margin-top: -52px; scale: 1; }
}

.popup.crystal {
  color: #7ce9ff;
  text-shadow: 0 0 12px rgba(90, 200, 255, 0.85), 0 1px 2px rgba(0, 0, 0, 0.6);
}
.popup.streak {
  color: #ffd75e;
  font-size: 1.35rem;
  text-shadow: 0 0 14px rgba(255, 190, 60, 0.9), 0 1px 2px rgba(0, 0, 0, 0.6);
}
.popup.huge {
  color: #ff9d5c;
  font-size: 1.7rem;
  text-shadow: 0 0 18px rgba(255, 130, 60, 0.95), 0 1px 2px rgba(0, 0, 0, 0.6);
}

.milestone {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translate(-50%, -50%);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  color: #eef2f8;
  text-shadow: 0 0 18px rgba(95, 245, 220, 0.75);
  animation: milestone-pulse 1.4s ease-out forwards;
}
@keyframes milestone-pulse {
  0% { opacity: 0; scale: 0.7; }
  12% { opacity: 1; scale: 1.08; }
  24% { scale: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; scale: 1.04; }
}

.hit-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at center, rgba(226, 69, 60, 0) 40%, rgba(226, 69, 60, 0.45) 100%);
  opacity: 0;
  transition: opacity 0.9s ease-out;
}
.hit-flash.on { opacity: 1; transition: opacity 0.05s; }

/* blaster heat gauge, bottom-centre of the stage so eyes stay on the track */
.heat {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 10, 18, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.25s;
}
.heat.on { opacity: 1; }

.heat-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8d93a8;
}

.heat-track {
  position: relative;
  display: block;
  width: 128px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.heat-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #12b8a0, #7ee6a8 55%, #e8c53c);
  transition: width 0.06s linear, background 0.2s;
}
.heat.hot .heat-fill { background: linear-gradient(90deg, #e8a03c, #e2453c); }
.heat.locked .heat-fill { background: repeating-linear-gradient(45deg, #e2453c 0 6px, #8f2018 6px 12px); }

.heat-status {
  min-width: 74px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e2453c;
}
.heat.locked .heat-status { animation: heat-blink 0.45s steps(2, end) infinite; }
@keyframes heat-blink { 50% { opacity: 0.25; } }

/* incoming-raid warning */
.raid-warn {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  z-index: 4;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ff6a5c;
  text-shadow: 0 0 20px rgba(226, 69, 60, 0.9);
  animation: raid-pulse 0.5s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes raid-pulse {
  from { opacity: 0.45; scale: 0.98; }
  to { opacity: 1; scale: 1.03; }
}

.raid-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(226, 69, 60, 0) 45%, rgba(226, 69, 60, 0.4) 100%);
  opacity: 0;
  transition: opacity 0.4s;
}
.raid-vignette.on { opacity: 1; }

/* score entry + leaderboard */
.score-entry {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.score-entry.hidden { display: none; }

.score-entry input {
  width: 150px;
  padding: 9px 12px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f2f3f8;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
}
.score-entry input:focus { outline: none; border-color: var(--laser); }

.score-entry button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: #05050a;
  background: var(--laser);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  cursor: pointer;
}
.score-entry button:hover { background: #17d4b9; }

.leaderboard {
  margin-top: 26px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid #dde0e8;
  border-radius: 12px;
}

.leaderboard-list {
  list-style: none;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leaderboard-list li {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 6px;
  overflow: hidden;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.leaderboard-list li .gauge {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(18, 184, 160, 0.14);
  border-radius: 6px;
}
.leaderboard-list li .rank { position: relative; color: var(--ink-faint); width: 1.4em; }
.leaderboard-list li .who { position: relative; flex: 1; font-weight: 600; }
.leaderboard-list li .pts { position: relative; font-variant-numeric: tabular-nums; font-weight: 700; }
.leaderboard-list li.empty { color: var(--ink-faint); justify-content: center; }

.foot {
  margin-top: 40px;
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-align: center;
}

@media (max-width: 640px) {
  .hud-item { min-width: 72px; padding: 6px 12px; }
  .hud-value { font-size: 1rem; }
}
