/* Neon Strike — HUD and screen chrome.
   Layout rule: the centre 60% of the viewport is reserved for gameplay. Everything
   informational lives in a corner; only transient banners cross the middle, and they
   sit high enough to clear the play plane. */

:root {
  --bg: #05030f;
  --cyan: #00e5ff;
  --blue: #3b82f6;
  --violet: #8b5cf6;
  --magenta: #ff2fd0;
  --red: #ff2b4a;
  --green: #39ff88;
  --amber: #ffe93a;
  --orange: #ff7a1a;
  --ink: #dff6ff;
  --dim: #7f9dc0;
  --panel: rgba(8, 8, 26, 0.82);
  --font: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  --clip: polygon(0 12px, 12px 0, calc(100% - 12px) 0, 100% 12px,
                  100% calc(100% - 12px), calc(100% - 12px) 100%,
                  12px 100%, 0 calc(100% - 12px));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#scene { display: block; width: 100%; height: 100%; }

/* ------------------------------------------------------------------ effects */

#fx { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.fx-layer { position: absolute; inset: 0; }

[data-fx="flash"] {
  background: var(--red);
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 60ms linear;
}

/* Chromatic split: two offset copies of the frame tinted cyan/magenta. */
[data-fx="glitch"] { opacity: 0; }
[data-fx="glitch"].is-active {
  opacity: 1;
  animation: glitch 320ms steps(3, end);
  background:
    linear-gradient(90deg, rgba(255, 47, 208, 0.12), transparent 22%),
    linear-gradient(270deg, rgba(0, 229, 255, 0.12), transparent 22%);
  mix-blend-mode: screen;
}
@keyframes glitch {
  0%   { transform: translate3d(-7px, 2px, 0); filter: hue-rotate(0deg); }
  33%  { transform: translate3d(6px, -3px, 0); filter: hue-rotate(70deg); }
  66%  { transform: translate3d(-4px, 1px, 0); filter: hue-rotate(-40deg); }
  100% { transform: none; filter: none; opacity: 0; }
}

.fx-vignette {
  background: radial-gradient(ellipse at 50% 55%, transparent 42%, rgba(2, 0, 12, 0.72) 100%);
}
.fx-scanlines {
  background: repeating-linear-gradient(
    to bottom, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 3px);
  opacity: 0.6;
}

/* ---------------------------------------------------------------------- HUD */

#hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#hud[hidden] { display: none; }

/* Each corner carries its own soft scrim: the arena behind the HUD is bright neon, and
   thin cyan text on a bright cyan grid is unreadable without one. */
.hud-corner { position: absolute; padding: clamp(14px, 1.6vw, 26px); }
.hud-tl { top: 0; left: 0; background: radial-gradient(ellipse 130% 130% at 0% 0%, rgba(2, 0, 12, 0.8), transparent 70%); }
.hud-tr { top: 0; right: 0; text-align: right; background: radial-gradient(ellipse 130% 130% at 100% 0%, rgba(2, 0, 12, 0.8), transparent 70%); }
.hud-bl { bottom: 0; left: 0; background: radial-gradient(ellipse 130% 130% at 0% 100%, rgba(2, 0, 12, 0.8), transparent 70%); }
.hud-br { bottom: 0; right: 0; text-align: right; background: radial-gradient(ellipse 130% 130% at 100% 100%, rgba(2, 0, 12, 0.8), transparent 70%); }

.hud-label {
  font-size: clamp(9px, 0.75vw, 12px);
  letter-spacing: 0.34em;
  color: var(--dim);
  text-transform: uppercase;
}

.hud-value {
  font-size: clamp(26px, 3.1vw, 50px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.hud-score { color: var(--cyan); text-shadow: 0 0 18px rgba(0, 229, 255, 0.65); }
.hud-wave { color: var(--violet); text-shadow: 0 0 18px rgba(139, 92, 246, 0.7); }
.hud-combo { color: var(--amber); text-shadow: 0 0 18px rgba(255, 233, 58, 0.6); }

.hud-value.is-bumped { animation: bump 260ms cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.hud-sub {
  font-size: clamp(10px, 0.82vw, 13px);
  letter-spacing: 0.18em;
  color: var(--dim);
  margin-top: 4px;
}

/* Hull bar: a fast red fill plus a slower "ghost" that drains behind it, so the size
   of a hit stays legible for a moment after it lands. */
.hp-bar {
  position: relative;
  width: clamp(150px, 15vw, 260px);
  height: 14px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(0, 229, 255, 0.35);
  clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  overflow: hidden;
}
.hp-fill, .hp-ghost {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transform-origin: left center;
}
.hp-fill {
  background: linear-gradient(90deg, var(--green), var(--cyan));
  box-shadow: 0 0 14px rgba(57, 255, 136, 0.6);
  transition: transform 120ms ease-out, background 200ms linear;
  z-index: 1;
}
.hp-ghost {
  background: rgba(255, 43, 74, 0.75);
  transition: transform 520ms 120ms cubic-bezier(0.2, 0, 0.1, 1);
}
.hp-bar.is-low .hp-fill { background: linear-gradient(90deg, var(--red), var(--orange)); }
.hp-bar.is-hit { animation: hpshake 240ms ease-out; }
@keyframes hpshake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
}

.dash-meter { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.dash-label { font-size: 10px; letter-spacing: 0.3em; color: var(--dim); }
.dash-track {
  display: block;
  width: clamp(70px, 7vw, 110px);
  height: 5px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.dash-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--blue);
  transition: transform 160ms ease-out, background 200ms linear, box-shadow 160ms ease-out;
}
.dash-meter[data-ready="true"] .dash-fill {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}
.dash-meter[data-ready="true"] .dash-label { color: var(--cyan); }

.hud-pips { display: flex; gap: 3px; justify-content: flex-end; margin-top: 6px; }
.pip {
  width: 8px; height: 8px;
  background: rgba(255, 255, 255, 0.14);
  transform: skewX(-18deg);
}
.pip.on { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* Transient centre-screen messaging — high enough to clear the craft. */
.hud-banner {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px clamp(30px, 5vw, 70px);
  text-align: center;
  font-size: clamp(24px, 3.4vw, 54px);
  font-weight: 700;
  letter-spacing: 0.3em;
  opacity: 0;
  white-space: nowrap;
  color: var(--cyan);
  /* Dark halo first, neon bloom second — the banner crosses the brightest part of the
     corridor and needs to survive being drawn over the ceiling grid. */
  text-shadow: 0 0 4px #03000c, 0 2px 10px #03000c, 0 0 30px currentColor;
  background: radial-gradient(ellipse 60% 130% at 50% 50%, rgba(3, 0, 12, 0.86), transparent 78%);
}
.hud-banner.show { animation: banner 1.9s ease-out forwards; }
.hud-banner.surge { color: var(--red); }
@keyframes banner {
  0% { opacity: 0; transform: translateX(-50%) scale(0.86); letter-spacing: 0.7em; }
  18% { opacity: 1; transform: translateX(-50%) scale(1); letter-spacing: 0.3em; }
  74% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.05); }
}
.hud-banner .banner-sub {
  display: block;
  font-size: 0.34em;
  letter-spacing: 0.4em;
  color: #b9d4ec;
  margin-top: 10px;
  text-shadow: 0 0 4px #03000c, 0 1px 6px #03000c;
}

.hud-toasts {
  position: absolute;
  top: 27%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 60vw;
  pointer-events: none;
}
.toast {
  font-size: clamp(13px, 1.25vw, 21px);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--green);
  text-shadow: 0 0 3px #03000c, 0 1px 8px #03000c, 0 0 18px currentColor;
  animation: toast 900ms ease-out forwards;
  white-space: nowrap;
}
.toast.graze { color: var(--amber); }
.toast.power { color: var(--green); }
/* Distinct from graze (amber) and power (green): the cannon's cool cyan/blue ties the
   readout back to the meter and muzzle-flash colour so an intercept reads as "your shot",
   not just another point pop. */
.toast.intercept { color: #60a5fa; text-shadow: 0 0 3px #03000c, 0 1px 8px #03000c, 0 0 18px currentColor; }
/* Damage toasts appear on top of the red damage flash, so they cannot be red — near-white
   with a red halo keeps them readable at the exact moment they matter most. */
.toast.hurt { color: #fff2f5; text-shadow: 0 0 3px #2a0008, 0 1px 8px #2a0008, 0 0 20px var(--red); }
@keyframes toast {
  0% { opacity: 0; transform: translateY(12px) scale(0.9); }
  16% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-34px) scale(0.98); }
}

.hud-buffs {
  position: absolute;
  bottom: clamp(12px, 1.6vw, 26px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}
.buff {
  font-size: 11px;
  letter-spacing: 0.22em;
  padding: 4px 10px;
  border: 1px solid currentColor;
  color: var(--green);
  background: rgba(0, 0, 0, 0.45);
}
.buff.slow { color: var(--blue); }
.buff.double { color: var(--amber); }
.buff.shield { color: var(--green); }

/* ------------------------------------------------------------------ screens */

#screens { position: absolute; inset: 0; z-index: 4; }

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  background: radial-gradient(ellipse at 50% 45%, rgba(6, 2, 22, 0.72), rgba(3, 1, 10, 0.94));
  backdrop-filter: blur(3px);
  animation: fadein 220ms ease-out;
}
.screen[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh;
  padding: clamp(22px, 3vw, 40px);
  background: var(--panel);
  border: 1px solid rgba(0, 229, 255, 0.4);
  clip-path: var(--clip);
  box-shadow: 0 0 60px rgba(0, 229, 255, 0.14), inset 0 0 50px rgba(0, 40, 80, 0.35);
  text-align: center;
}
.panel-wide { width: min(940px, 100%); }
.panel-scroll { overflow-y: auto; text-align: left; }

.title {
  margin: 0 0 6px;
  font-size: clamp(38px, 7.2vw, 96px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  position: relative;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.6),
    0 0 34px var(--cyan),
    0 0 70px var(--magenta);
}
.title::before, .title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.title::before { color: var(--magenta); transform: translate(-3px, 1px); opacity: 0.55; z-index: -1; }
.title::after { color: var(--cyan); transform: translate(3px, -1px); opacity: 0.55; z-index: -1; }

.tagline {
  margin: 0 0 26px;
  color: var(--dim);
  letter-spacing: 0.2em;
  font-size: clamp(11px, 1.1vw, 15px);
}
.tagline em { color: var(--amber); font-style: normal; }

.heading {
  margin: 0 0 22px;
  font-size: clamp(20px, 2.6vw, 34px);
  letter-spacing: 0.3em;
  color: var(--cyan);
  text-shadow: 0 0 22px rgba(0, 229, 255, 0.55);
}
.heading-dead {
  color: var(--red);
  text-shadow: 0 0 26px rgba(255, 43, 74, 0.7);
  animation: deadflicker 2.4s infinite steps(12, end);
}
@keyframes deadflicker {
  0%, 92%, 100% { opacity: 1; }
  94% { opacity: 0.45; }
  96% { opacity: 1; }
  97% { opacity: 0.6; }
}

.menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.menu-row { flex-direction: row; justify-content: center; }

.btn {
  appearance: none;
  font: inherit;
  font-size: clamp(13px, 1.2vw, 17px);
  letter-spacing: 0.24em;
  padding: 13px 26px;
  color: var(--ink);
  background: rgba(0, 40, 70, 0.35);
  border: 1px solid rgba(0, 229, 255, 0.45);
  cursor: pointer;
  transition: background 140ms, color 140ms, box-shadow 140ms, transform 100ms;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.btn:hover, .btn:focus-visible {
  background: rgba(0, 229, 255, 0.18);
  color: #fff;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.45);
  outline: none;
  transform: translateY(-1px);
}
.btn:focus-visible { border-color: #fff; }
.btn:active { transform: translateY(1px); box-shadow: 0 0 10px rgba(0, 229, 255, 0.35); }
.btn-primary {
  border-color: var(--magenta);
  background: rgba(255, 47, 208, 0.16);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: rgba(255, 47, 208, 0.34);
  box-shadow: 0 0 30px rgba(255, 47, 208, 0.55);
}
.btn-quiet { border-color: rgba(255, 255, 255, 0.2); color: var(--dim); font-size: 12px; }
.btn[data-back] { margin-top: 22px; }

.hint {
  margin: 24px 0 0;
  font-size: clamp(10px, 0.95vw, 13px);
  letter-spacing: 0.14em;
  color: var(--dim);
}
kbd {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 2px;
  border: 1px solid rgba(0, 229, 255, 0.5);
  border-radius: 3px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan);
  font: inherit;
  font-size: 0.92em;
}

/* -------------------------------------------------------------- how to play */

.howto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(16px, 2vw, 30px);
  text-align: left;
}
.howto-grid h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--magenta);
}
.keylist, .bullets { margin: 0; padding: 0; list-style: none; font-size: clamp(11px, 1.02vw, 14px); }
.keylist li { display: flex; gap: 10px; align-items: baseline; margin-bottom: 7px; color: var(--dim); }
.keylist li span { flex: 0 0 auto; min-width: 88px; display: flex; gap: 4px; flex-wrap: wrap; }
.bullets li { margin-bottom: 9px; color: var(--dim); line-height: 1.55; padding-left: 14px; position: relative; }
.bullets li::before { content: "\203A"; position: absolute; left: 0; color: var(--cyan); }
.bullets b, .keylist b { color: var(--ink); }
.c-danger { color: var(--red); }
.c-scene { color: var(--cyan); }
.c-good { color: var(--green); }
.c-fake { color: #7fe9ff; }
.pu-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 7px;
  transform: skewX(-18deg);
  vertical-align: baseline;
}

/* ----------------------------------------------------------------- settings */

.setting {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  text-align: left;
}
.setting label { font-size: 12px; letter-spacing: 0.24em; color: var(--dim); }
.setting output { font-size: 13px; color: var(--cyan); text-align: right; }
.setting-check { grid-template-columns: 110px 1fr; }
.setting-check input { justify-self: start; width: 18px; height: 18px; accent-color: var(--cyan); }

.setting select {
  font: inherit;
  font-size: 12px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(0, 30, 55, 0.8);
  border: 1px solid rgba(0, 229, 255, 0.4);
}
.setting select:focus-visible { outline: 1px solid var(--cyan); }

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 18px;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 18px;
  border: none;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  cursor: pointer;
}
.note { font-size: 11px; letter-spacing: 0.12em; color: var(--dim); line-height: 1.6; }

/* ------------------------------------------------------- records / game over */

.record-score, .result-score strong {
  display: block;
  font-size: clamp(38px, 5.4vw, 68px);
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 28px rgba(0, 229, 255, 0.6);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.result-score { margin-bottom: 22px; }
.new-record {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 12px;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #06121a;
  background: var(--amber);
  animation: bump 700ms ease-out;
}
.new-record[hidden] { display: none; }

.record-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px 22px;
  margin: 18px 0 0;
}
.record-list div {
  padding: 10px 12px;
  border: 1px solid rgba(0, 229, 255, 0.18);
  background: rgba(0, 20, 40, 0.35);
  text-align: left;
}
/* Game over shows seven stats; auto-fit packs unevenly (e.g. six across, one orphaned
   on its own row). A fixed 4-up grid gives two balanced-enough rows (4 + 3), and still
   suits the 3-stat high-score panel as a single row. */
#screen-gameover .record-list { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  #screen-gameover .record-list { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  #screen-gameover .record-list { grid-template-columns: repeat(2, 1fr); }
}

.record-list dt { font-size: 10px; letter-spacing: 0.24em; color: var(--dim); }
.record-list dd {
  margin: 4px 0 0;
  font-size: clamp(16px, 1.7vw, 22px);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.result { margin-bottom: 26px; }

.loader {
  width: 180px; height: 3px;
  margin: 0 auto 16px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.loader::after {
  content: "";
  display: block;
  width: 40%; height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: load 1.1s infinite ease-in-out;
}
@keyframes load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* --------------------------------------------------------------- responsive */

/* 1366x768 and 1280x720: shrink the vertical footprint of the HUD corners. */
@media (max-height: 800px) {
  .hud-corner { padding: 14px 16px; }
  .hud-value { font-size: clamp(22px, 2.7vw, 38px); }
  .hud-banner { top: 11%; padding: 10px 30px; }
  .hud-toasts { top: 24%; }
  .dash-meter { margin-top: 7px; }
  .panel { padding: 20px 24px; }
  .title { font-size: clamp(34px, 6vw, 68px); }
  .tagline { margin-bottom: 18px; }
  .btn { padding: 10px 22px; }
  .hint { margin-top: 16px; }
}

@media (max-width: 780px) {
  .hud-value { font-size: 26px; }
  .hp-bar { width: 130px; }
  .howto-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .hud-banner.show, .toast, .heading-dead, .loader::after { animation-duration: 0.01ms; }
  [data-fx="glitch"].is-active { animation: none; opacity: 0.4; }
}
