:root {
  --bg: #05060a;
  --fg: #f4f1ea;
  --dim: #8a90a3;
  --amber: #ffb000;
  --cyan: #3ec7ff;
  --green: #5dff7a;
  --red: #ff5a3c;
  --magenta: #ff4fd8;
  --line: #2a2f40;
  --font: "Press Start 2P", ui-monospace, "Courier New", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-snap-type: y proximity; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 12px/1.9 var(--font);
  letter-spacing: 0.02em;
  overflow-x: hidden;
  -webkit-font-smoothing: none;
}
h1, h2, p { margin: 0; font-weight: normal; }
button {
  font: inherit; color: inherit; background: none; cursor: pointer;
  border: 2px solid currentColor; padding: 10px 14px; text-transform: uppercase;
}
button:hover { color: var(--amber); }
:focus-visible { outline: 3px dashed var(--amber); outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- CRT shell ---------- */
.crt { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.crt::before {             /* scanlines */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);  /* static: nothing rolls */
}
.crt::after {              /* tube vignette + slight curvature shading */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,.75) 100%);
  box-shadow: inset 0 0 140px rgba(0,0,0,.9), inset 0 0 18px rgba(62,199,255,.08);
}
main { text-shadow: 0 0 6px rgba(244,241,234,.45); }
/* Calm by design: no flicker, no blinking, no flashes (photosensitivity, WCAG 2.3.1 / 2.2.2). */
body.locked { overflow: hidden; }
.start {
  position: fixed; inset: 0; z-index: 45; background: var(--bg);
  display: grid; place-content: center; justify-items: center; gap: 34px; text-align: center; padding: 16px;
}
.start-title { font-size: clamp(16px, 3vw, 28px); color: var(--amber); text-shadow: 0 0 10px rgba(255,176,0,.7); }
.start-btn { border: 0; font-size: clamp(11px, 1.6vw, 14px); color: var(--fg); }
.start-btn:focus-visible { outline-offset: 10px; }
.start-note { font-size: 8px; color: var(--dim); }
.start.gone { display: none; }

.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-between; padding: 16px 20px;
  font-size: 10px; color: var(--amber); text-shadow: 0 0 6px rgba(255,176,0,.6);
  pointer-events: none;
}
.corner {
  position: fixed; right: 20px; bottom: 18px; z-index: 30;
  font-size: 10px; padding: 8px 10px; border-color: var(--dim); color: var(--fg);
  background: rgba(5,6,10,.7);
}
.corner[aria-pressed="true"] { color: var(--green); border-color: var(--green); }


/* ---------- screens ---------- */
.screen {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center; padding: 72px 16px 64px;
  scroll-snap-align: start;
}
.attract { text-align: center; display: grid; gap: 22px; justify-items: center; }
.welcome { font-size: clamp(12px, 2.4vw, 22px); line-height: 1.7; max-width: 22ch; }
.sub { font-size: 10px; color: var(--dim); }
.arrow { font-size: 28px; color: var(--amber); }
.footnote { position: absolute; bottom: 22px; left: 20px; font-size: 8px; color: var(--dim); }
.cursor::after { content: "_"; }

.coinbox { display: grid; gap: 34px; justify-items: center; text-align: center; }
.insert { font-size: clamp(12px, 2vw, 18px); color: var(--amber); text-shadow: 0 0 8px rgba(255,176,0,.7); }
.machine { position: relative; display: grid; grid-template-columns: auto auto; gap: clamp(32px, 10vw, 120px); align-items: center; }
#slot, #coinArt { image-rendering: pixelated; display: block; }
#slot { width: 120px; height: 120px; }
.coin { padding: 6px; user-select: none; }
.coin canvas { width: 96px; height: 96px; filter: drop-shadow(0 0 10px rgba(255,176,0,.45)); }
.help { font-size: 9px; color: var(--dim); }
.help.big { font-size: 11px; color: var(--fg); }
.warn { color: var(--red); max-width: 48ch; }

/* ---------- jukebox ---------- */
.play { align-content: start; gap: 18px; }
.playgrid {
  width: min(1320px, 100%); display: grid; gap: 22px; align-items: start;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "deck" "stage" "board" "panel";
}
.deck { grid-area: deck; display: grid; gap: 14px; justify-items: start; }
.stage { grid-area: stage; }
.boardwrap { grid-area: board; }
.panel { grid-area: panel; }
@media (min-width: 720px) {
  .playgrid { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); grid-template-areas: "deck stage" "board board" "panel panel"; }
}
@media (min-width: 1180px) {
  .playgrid { grid-template-columns: 260px minmax(0, 1fr) 270px; grid-template-areas: "deck stage panel" "board board panel"; }
}
#disc { width: 100%; max-width: 280px; height: auto; display: block; }
.np { font-size: 9px; line-height: 2; }
.np b { color: var(--amber); font-weight: normal; }
.boardtitle { font-size: 10px; color: var(--cyan); margin: 0 0 10px; font-weight: normal; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.strip {
  display: grid; grid-template-columns: 3ch 1fr; gap: 8px; align-items: center; text-align: left;
  font-size: 8px; padding: 8px; border: 2px solid var(--line); background: #0d0f16; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip b { color: var(--amber); font-weight: normal; font-size: 9px; }
.strip span { overflow: hidden; text-overflow: ellipsis; }
.strip[aria-current="true"] { border-color: var(--amber); background: #1d1606; }
.strip.match { border-color: var(--cyan); }
.code { font-size: 18px; color: var(--amber); letter-spacing: .2em; }

.stage { position: relative; z-index: 55; /* above the CRT scanlines: a stable picture */ border: 2px solid var(--line); background: #000; box-shadow: 0 0 30px rgba(62,199,255,.12); }
#view { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.titlecard {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 16px; text-align: center;
  background: rgba(5,6,10,.82); padding: 16px;
}
.titlecard.gone { opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }
.trackno { font-size: 10px; color: var(--cyan); }
.place { font-size: clamp(16px, 3.2vw, 30px); color: var(--amber); text-shadow: 0 0 10px rgba(255,176,0,.7); text-transform: uppercase; }
.ttitle { font-size: 10px; color: var(--fg); max-width: 40ch; margin: 0 auto; }
.ready { font-size: 10px; color: var(--green); margin-top: 8px; }
.endmsg { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 12px; color: var(--amber); text-shadow: 0 0 8px #000, 0 0 8px rgba(255,176,0,.8); }

.panel { display: grid; gap: 20px; grid-area: panel; }
.readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.readout div { border: 2px solid var(--line); padding: 8px; }
.readout dt { font-size: 8px; color: var(--dim); }
.readout dd { margin: 4px 0 0; font-size: 12px; color: var(--amber); white-space: nowrap; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 7ch 1fr; align-items: center; gap: 10px; font-size: 8px; }
.cells { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.cells i { height: 10px; background: #14171f; }
.cells i.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
.keysel { display: flex; align-items: center; gap: 10px; font-size: 9px; flex-wrap: wrap; }
.keysel button { padding: 6px 10px; font-size: 10px; }
.keysel output { min-width: 3ch; text-align: center; font-size: 14px; color: var(--amber); }
.keysel #modeName { font-size: 9px; color: var(--dim); text-align: left; }
.dimtxt { color: var(--dim); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.controls button { font-size: 9px; }
.controls .primary { color: var(--amber); }
.legend { border: 2px solid var(--line); padding: 12px; font-size: 8px; }
.legend summary { cursor: pointer; color: var(--cyan); font-size: 9px; }
.legend ul { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.legend li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: start; }
.legend li b { color: var(--c); font-weight: normal; }
.swatch { width: 14px; height: 14px; background: var(--c); box-shadow: 0 0 6px var(--c); margin-top: 2px; }
.legend .rules { color: var(--dim); line-height: 2.1; }
.credit { width: min(1240px, 100%); font-size: 8px; color: var(--dim); line-height: 2; }
.credit a { color: var(--cyan); }
.keys { width: min(1240px, 100%); font-size: 8px; color: var(--dim); }

@media (max-width: 520px) {
  body { font-size: 10px; }
  .readout dd { font-size: 10px; }
  .hud-top { padding: 12px 16px; font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-snap-type: none; }
}

/* ---------- the four elements (sound tour) ---------- */
.elements { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; width: min(640px, 92vw); }
.elements li { border: 2px solid var(--line); padding: 12px 6px; display: grid; justify-items: center; gap: 8px; opacity: .5; transition: opacity .3s, border-color .3s; }
.elements li.on { opacity: 1; border-color: var(--c); }
.elements canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.elements b { font-weight: normal; font-size: 10px; color: var(--c); }
.elements small { font-size: 7px; color: var(--dim); }
.hear { font-size: 9px; color: var(--cyan); }
@media (max-width: 520px) { .elements { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .elements li { transition: none; } }
