@font-face {
  font-family: "VT323";
  src: url("/vendor/fonts/vt323-latin-400-normal.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/vendor/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/vendor/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #010805;
  --panel: rgb(2 16 9 / 0.78);
  --fg: #3dff8f;
  --hi: #c9ffe0;
  --mid: #25b866;
  --dim: #177040;
  --line: #0f4a2a;
  --bad: #ff3b5c;
  --warn: #ffc23d;
  --glow: 0 0 4px rgb(61 255 143 / 0.6), 0 0 14px rgb(61 255 143 / 0.3);
  --mono: "JetBrains Mono", ui-monospace, Consolas, Menlo, monospace;
  --crt: "VT323", "JetBrains Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--mono);
  text-shadow: 0 0 3px rgb(61 255 143 / 0.35);
  overflow-x: hidden;
}

::selection { background: var(--fg); color: var(--bg); }
[hidden] { display: none !important; }
.dim { color: var(--dim); }
.ok { color: var(--fg); }
.bad { color: var(--bad); }

/* ---------- atmosphere ---------- */

#rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.22;
  transition: opacity 0.6s;
}
body.playing #rain { opacity: 0.06; }

.crt {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgb(0 0 0 / 0.22) 3px, transparent 4px),
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.65) 100%);
  animation: flicker 7s infinite;
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, var(--bad) 140%);
  opacity: 0;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  46% { opacity: 0.94; }
  47% { opacity: 1; }
  78% { opacity: 0.97; }
}
@keyframes blink { 50% { opacity: 0; } }

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--fg);
  box-shadow: var(--glow);
  animation: blink 1s steps(1) infinite;
}

/* ---------- layout ---------- */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "bar bar" "main side" "foot foot";
  gap: 22px 18px;
}

.statusbar { grid-area: bar; }
.stage { grid-area: main; min-width: 0; container-type: inline-size; }
.side { grid-area: side; display: grid; align-content: start; gap: 22px; }
.foot { grid-area: foot; color: var(--dim); font-size: 11px; text-align: center; }

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "bar" "main" "side" "foot";
  }
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 14px 14px;
  box-shadow: inset 0 0 24px rgb(61 255 143 / 0.04);
}

.ptitle {
  position: absolute;
  top: 0;
  left: 10px;
  transform: translateY(-50%);
  margin: 0;
  padding: 0 6px;
  background: var(--bg);
  color: var(--mid);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.ptitle::before { content: "[ "; color: var(--dim); }
.ptitle::after { content: " ]"; color: var(--dim); }

/* ---------- controls ---------- */

button {
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--dim);
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: inherit;
}
button:hover,
button:focus-visible {
  outline: none;
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
  box-shadow: var(--glow);
}
button[aria-pressed="true"] {
  border-color: var(--fg);
  background: rgb(61 255 143 / 0.16);
  color: var(--hi);
}
button:disabled,
button:disabled:hover {
  opacity: 0.3;
  cursor: not-allowed;
  background: transparent;
  color: var(--fg);
  box-shadow: none;
}
button.big { font-size: 20px; padding: 12px 28px; font-weight: 700; }
button.tiny { font-size: 10px; padding: 2px 8px; color: var(--dim); border-color: var(--line); }

input {
  font: inherit;
  width: 14ch;
  color: var(--hi);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--dim);
  outline: none;
  text-transform: uppercase;
  caret-color: var(--fg);
  text-shadow: inherit;
}
input:focus { border-color: var(--fg); }
input::placeholder { color: var(--dim); }

.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }

/* ---------- status bar ---------- */

.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand { margin-right: auto; color: var(--hi); font-weight: 700; }
.brand .dim { font-weight: 400; }
.stat { color: var(--dim); }
.stat b { font-weight: 700; }
.stat.ok b { color: var(--fg); }
.stat.warn b { color: var(--warn); }
.stat.bad b { color: var(--bad); }
#st-engine.warn b { animation: blink 1s steps(1) infinite; }
/* Fixed widths for values that change, so the rest of the bar never shifts. */
#st-engine b, #st-mic b, #st-rtt b { display: inline-block; font-variant-numeric: tabular-nums; }
#st-engine b { min-width: 8.5ch; }
#st-mic b { min-width: 10.5ch; }
#st-rtt b { min-width: 6ch; text-align: right; }
button.stat { padding: 2px 8px; border-color: var(--line); font-size: 12px; }
button.stat b { color: var(--fg); }
button.stat:hover b, button.stat:focus-visible b { color: var(--bg); }

.meter {
  position: relative;
  width: 90px;
  height: 8px;
  border: 1px solid var(--dim);
  overflow: hidden;
}
.meter i {
  position: absolute;
  inset: 0;
  background: var(--fg);
  box-shadow: var(--glow);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- boot ---------- */

.bootlog { display: grid; gap: 4px; }
.bootlog .line::before { content: "> "; color: var(--dim); }
.press { margin-top: 18px; color: var(--hi); }

/* Model loading bar: segmented phosphor blocks with a light sweep running through them. */
.loader { margin: 22px 0 0; }
.ld-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  color: var(--mid);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.ld-phase::before { content: "» "; color: var(--dim); }
.ld-pct {
  font-family: var(--crt);
  font-size: 46px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  color: var(--hi);
  text-shadow: 0 0 10px rgb(61 255 143 / 0.7);
  font-variant-numeric: tabular-nums;
}
.pbar {
  --seg: repeating-linear-gradient(90deg, #000 0 10px, transparent 10px 14px);
  position: relative;
  height: 30px;
  margin-top: 6px;
  padding: 4px;
  border: 1px solid var(--dim);
  background: repeating-linear-gradient(90deg, rgb(61 255 143 / 0.08) 0 10px, transparent 10px 14px) content-box;
}
.pglow { display: block; height: 100%; filter: drop-shadow(0 0 5px rgb(61 255 143 / 0.75)); }
.ld-bar {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--hi), var(--fg) 45%, var(--mid));
  -webkit-mask: var(--seg);
  mask: var(--seg);
}
.ld-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 25%;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.85), transparent);
  animation: sweep 1.3s linear infinite;
}
@keyframes sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(400%); }
}
.ld-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  color: var(--dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.loader.done .pbar { border-color: var(--fg); box-shadow: var(--glow); animation: online 0.6s ease-out; }
.loader.done .ld-bar::after { animation: none; opacity: 0; }
.loader.done .ld-phase { color: var(--fg); }
.loader.fail .ld-bar { background: var(--bad); }
.loader.fail .pglow { filter: drop-shadow(0 0 5px rgb(255 59 92 / 0.75)); }
.loader.fail .ld-phase, .loader.fail .ld-pct { color: var(--bad); text-shadow: none; }
@keyframes online {
  0% { box-shadow: 0 0 0 rgb(61 255 143 / 0); }
  30% { box-shadow: 0 0 24px rgb(61 255 143 / 0.9), inset 0 0 18px rgb(61 255 143 / 0.5); }
  100% { box-shadow: var(--glow); }
}

/* ---------- menu ---------- */

.banner {
  margin: 4px 0 0;
  filter: drop-shadow(0 0 6px rgb(61 255 143 / 0.45));
}
/* 545px is the old text banner's width: 66 columns of 15px Consolas. */
.banner svg { display: block; width: 100%; max-width: 545px; height: auto; }

.tagline { margin: 10px 0 26px; color: var(--mid); }

.config { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.key { min-width: 14ch; white-space: nowrap; color: var(--dim); text-transform: uppercase; font-size: 12px; letter-spacing: 0.08em; }
.key::before { content: "> "; }
#ear-check { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#ear-check.live { color: var(--hi); }

.launch { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 24px 0 30px; }

.matrix {
  display: grid;
  grid-template-columns: 2.4em repeat(10, minmax(0, 1fr));
  gap: 2px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.matrix span { padding: 4px 0; text-align: center; }
.matrix .h { color: var(--dim); }
.matrix .c {
  background: hsl(var(--hue) 100% 50% / 0.16);
  color: hsl(var(--hue) 100% 66%);
  text-shadow: none;
}
.matrix .c.none { background: rgb(61 255 143 / 0.03); color: var(--line); }
.matrix .missed, .legend .missed { outline: 1px solid var(--bad); outline-offset: -1px; }
/* Weak-spot drill targets: an amber corner marker, so it combines with the missed outline. */
.matrix .c.target { position: relative; }
.matrix .c.target::after, .legend .target::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 5px;
  height: 5px;
  background: var(--warn);
  box-shadow: 0 0 4px var(--warn);
}
.legend .swatch.target { position: relative; background: rgb(61 255 143 / 0.08); margin-left: 10px; }
.targets { flex: 1; min-width: 0; color: var(--warn); overflow-wrap: anywhere; }

.legend { margin: 10px 0 0; color: var(--dim); font-size: 11px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; background: hsl(var(--hue, 150) 100% 50% / 0.35); }
.swatch.missed { background: transparent; margin-left: 10px; }

/* ---------- play ---------- */

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 28px;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.hud b { color: var(--hi); font-size: 18px; font-variant-numeric: tabular-nums; }
.hud .ok b { color: var(--fg); }
.hud .bad b { color: var(--bad); }
.hud .tag { align-self: center; padding: 0 8px; border: 1px solid var(--warn); color: var(--warn); font-size: 11px; }

.track { display: grid; grid-template-columns: repeat(var(--n, 20), 1fr); gap: 3px; margin: 14px 0 0; }
.track.dense { grid-template-columns: repeat(50, 1fr); gap: 3px 2px; }
.track i { height: 6px; background: var(--line); }
.track i.now { background: var(--hi); animation: blink 0.7s steps(1) infinite; }
.track i.ok { background: var(--fg); box-shadow: var(--glow); }
.track i.bad { background: var(--bad); }

.question {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.22em;
  margin: 6vh 0 2vh;
  font-family: var(--crt);
  font-size: clamp(96px, 17cqw, 220px);
  line-height: 1;
  color: var(--hi);
  text-shadow: 0 0 8px rgb(61 255 143 / 0.8), 0 0 34px rgb(61 255 143 / 0.45);
  font-variant-numeric: tabular-nums;
}
.question .op { color: var(--mid); font-size: 0.7em; }
.question.count { color: var(--warn); text-shadow: 0 0 12px rgb(255 194 61 / 0.6); }

.prompt { min-height: 1.6em; font-size: 26px; text-align: center; color: var(--fg); }
.notice { text-align: center; color: var(--warn); }
.hint { text-align: center; color: var(--dim); font-size: 12px; }

.trace {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.trace li { display: grid; grid-template-columns: 3ch 1fr 6ch 7ch; gap: 8px; }
.trace .n { color: var(--dim); }
.trace .t { text-align: right; }
.trace .v { text-align: right; }
.trace li.bad { color: var(--bad); }

/* ---------- results ---------- */

.glitch {
  position: relative;
  margin: 10px 0 6px;
  font-family: var(--crt);
  font-size: clamp(48px, 10cqw, 84px);
  font-weight: 400;
  line-height: 1;
  color: var(--hi);
  text-shadow: 0 0 10px rgb(61 255 143 / 0.6);
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  text-shadow: none;
}
.glitch::before { color: #3df5ff; opacity: 0.6; animation: glitch-a 3.1s infinite steps(1); }
.glitch::after { color: var(--bad); opacity: 0.6; animation: glitch-b 2.3s infinite steps(1); }
@keyframes glitch-a {
  0%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  12% { clip-path: inset(10% 0 60% 0); transform: translate(-3px, 0); }
  14% { clip-path: inset(0 0 100% 0); transform: none; }
  61% { clip-path: inset(55% 0 20% 0); transform: translate(3px, 0); }
  63% { clip-path: inset(0 0 100% 0); transform: none; }
}
@keyframes glitch-b {
  0%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  33% { clip-path: inset(40% 0 35% 0); transform: translate(3px, 0); }
  35% { clip-path: inset(0 0 100% 0); transform: none; }
  80% { clip-path: inset(75% 0 5% 0); transform: translate(-2px, 0); }
  82% { clip-path: inset(0 0 100% 0); transform: none; }
}

.badge {
  display: inline-block;
  margin: 4px 0 0;
  padding: 2px 10px;
  color: var(--bg);
  background: var(--warn);
  text-shadow: none;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: blink 1.2s steps(1) infinite;
}

.bigstats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 28px;
}
.bigstats div { border-left: 2px solid var(--dim); padding-left: 12px; }
.bigstats span { display: block; color: var(--dim); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.bigstats b { font-family: var(--crt); font-size: 44px; font-weight: 400; color: var(--hi); line-height: 1.1; }
@container (max-width: 560px) {
  .bigstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px 18px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; max-height: 40vh; overflow-y: auto; font-variant-numeric: tabular-nums; }
.list .dim { font-size: 12px; }
.list .better .dim { color: var(--fg); }
.list .worse .dim { color: var(--warn); }

/* ---------- leaderboard ---------- */

.tabs { margin-bottom: 10px; }
.tabs button { font-size: 11px; padding: 2px 8px; }

.board { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.board th {
  padding: 2px 4px;
  color: var(--dim);
  font-weight: 400;
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px dashed var(--line);
}
.board td { padding: 3px 4px; white-space: nowrap; }
.board .num { text-align: right; }
.board td:first-child { color: var(--dim); }
.board td:last-child { color: var(--dim); font-size: 11px; }
.board th:last-child, .board td:last-child { padding-left: 12px; }
.board tr.mine td { color: var(--hi); }
.board tr.me td { color: var(--warn); }
.board tr.gap td { color: var(--line); padding: 0 4px; line-height: 1; }
#wipe { margin-top: 12px; }

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #rain { display: none; }
}
