/* Hi-fi: the page is the cabinet, the clue glows on the amber display. */
:root {
  color-scheme: dark;
  --cabinet: #14202a;       /* smoked-glass blue-black */
  --cabinet-deep: #0e171e;
  --display: #0b1110;       /* the unlit display */
  --glow: #ffb347;          /* amber segments */
  --glow-dim: #6b4a20;
  --text: #eef2f4;
  --dusk: #93a4b0;          /* secondary text */
  --rule: #26384a;
  --knob: #e0533d;          /* the volume knob */
  --knob-hi: #ec6a54;
  --good: #3fbf7f;
  --hint: #f2c94c;          /* used the artist hint */
  --gold: #e8c158;
  --platinum: #cfd8de;
  --bad: #ff8a8a;
  --skip: #eef2f4;
  --screen-font: "Courier Prime", "Courier New", Courier, monospace;
  --ui-font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--cabinet-deep); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--cabinet) 0, var(--cabinet) 600px, var(--cabinet-deep) 1400px);
  color: var(--text);
  font: 17px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px 48px;
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0 22px;
}
.logo {
  font-family: var(--screen-font);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.06em;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
.top-right { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.puzzle-label { color: var(--dusk); font-size: 0.95rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The game being played; tap it to choose another. */
.games-link { color: var(--glow); font-size: 0.95rem; font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.games-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- the display ---------- */
.screen {
  position: relative;
  background: var(--display);
  color: var(--glow);
  border-radius: 8px;
  min-height: 0;
  aspect-ratio: 2.6 / 1;
  display: grid;
  place-items: center;
  padding: 16px 18px;
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.07) inset,
    0 0 0 6px #1b2a36,
    0 0 0 7px #2c4152,
    0 24px 60px -16px rgb(0 0 0 / 0.7);
}
/* Faint scan lines, like a vacuum-fluorescent display. */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(180deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.clue {
  margin: 0;
  font-family: var(--screen-font);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 0 6px rgb(255 179 71 / 0.55), 0 0 18px rgb(255 179 71 / 0.25);
  /* font-size is set by app.js to fit the display; this is the fallback */
  font-size: clamp(20px, 7vw, 40px);
  overflow-wrap: anywhere;
}
.clue .line { display: block; margin-right: -0.12em; } /* cancel the trailing letter-space so lines centre */

.screen.flicker .clue { animation: flicker 0.32s steps(1, end); }
@keyframes flicker {
  0% { opacity: 0.25; }
  25% { opacity: 1; }
  50% { opacity: 0.6; }
  75% { opacity: 1; }
}
.screen.solved { background: #08160f; transition: background-color 0.2s; }
.screen.solved .clue { color: #7dffb5; text-shadow: 0 0 6px rgb(125 255 181 / 0.6), 0 0 18px rgb(125 255 181 / 0.3); }

.caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 2px 0;
  color: var(--dusk);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.intro .caption { justify-content: center; }

/* ---------- buttons & input ---------- */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 14px 22px;
  font-weight: 650;
  font-size: 1.02rem;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, transform 0.06s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--knob); }
.btn.primary:hover { background: var(--knob-hi); }
.btn.quiet { background: transparent; color: var(--dusk); box-shadow: inset 0 0 0 1px var(--rule); }
.btn.quiet:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--dusk); }
:is(.btn, a, .hint-btn):focus-visible, input:focus-visible {
  outline: 3px solid var(--glow);
  outline-offset: 2px;
}

/* ---------- intro ---------- */
/* The wordmark: the name with its vowels emptied out, which is the game itself. */
.wordmark {
  margin: 4px 0 0;
  font-family: var(--screen-font);
  font-weight: 700;
  /* "MISSING" is 7 characters wide; fill the column, up to 84px. */
  font-size: min(84px, calc((100vw - 32px) / 4.55));
  line-height: 0.92;
  letter-spacing: 0.04em;
  color: var(--glow);
  text-shadow: 0 0 10px rgb(255 179 71 / 0.45), 0 0 32px rgb(255 179 71 / 0.2);
}
.wordmark .word { display: block; }
.wordmark .v {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--glow-dim);
  text-shadow: none;
  animation: vowel-out 0.9s 0.5s ease-in both;
}
@keyframes vowel-out {
  from { color: var(--glow); -webkit-text-stroke-color: transparent; }
  to { color: transparent; -webkit-text-stroke-color: var(--glow-dim); }
}
/* The header (logo and puzzle number) only appears once a game starts. */
body[data-screen="intro"] .top { display: none; }
.intro { padding-top: 28px; }
.intro-title {
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 36px 0 12px;
  max-width: 18ch;
}
.intro-text { color: var(--dusk); margin: 0 0 28px; max-width: 46ch; }

/* Choosing a game: tiles, each showing whether it's been played today. */
.choose-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 2px; }
.choose-note { color: var(--dusk); font-size: 0.9rem; margin: 0 0 14px; }
.games-heading { font-size: 0.85rem; font-weight: 600; color: var(--dusk); text-transform: uppercase; letter-spacing: 0.08em; margin: 22px 0 8px; }
.games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.games-all { grid-template-columns: 1fr; }
.games-decade { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.game-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--cabinet-deep);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--rule);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.15s, transform 0.06s;
}
.game-tile:hover { box-shadow: inset 0 0 0 1.5px var(--dusk); }
.game-tile:active { transform: translateY(1px); }
.game-tile:focus-visible { outline: 3px solid var(--glow); outline-offset: 2px; }
.game-name { font-weight: 650; font-size: 1rem; line-height: 1.25; }
.game-status { color: var(--dusk); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.games-all .game-tile { background: var(--knob); box-shadow: none; padding: 15px 18px; }
.games-all .game-tile:hover { background: var(--knob-hi); }
.games-all .game-name { font-size: 1.08rem; }
.games-all .game-status { color: rgb(255 255 255 / 0.8); }
.game-tile.started .game-status { color: var(--glow); }
.game-tile.done .game-status { color: var(--good); }
.games-all .game-tile.done .game-status, .games-all .game-tile.started .game-status { color: #fff; }
.game-tile.suggested { box-shadow: inset 0 0 0 2px var(--glow); }
.games-all .game-tile.suggested { box-shadow: inset 0 0 0 2px var(--glow); }

/* ---------- play ---------- */
.play-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.total { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* The progress is the share grid filling in. */
.pips, .squares { display: flex; gap: 5px; list-style: none; padding: 0; margin: 0; }
.pips li, .squares span {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1.5px var(--rule);
}
.pips li.correct, .squares .correct { background: var(--good); box-shadow: none; }
.pips li.hinted, .squares .hinted { background: var(--hint); box-shadow: none; }
.pips li.skipped, .squares .skipped { background: var(--skip); box-shadow: none; }
.pips li.current { box-shadow: inset 0 0 0 2px var(--glow); }

/* The artist hint: a quiet link-like button, then the artist's name in its place. */
.hint-row { min-height: 1.6em; margin: 10px 2px 0; display: flex; align-items: center; }
.hint-btn {
  border: 0;
  background: none;
  padding: 2px 0;
  color: var(--hint);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 4px;
}
.hint-btn:hover { text-decoration-style: solid; }
.artist-hint { margin: 0; font-size: 1rem; font-weight: 650; color: var(--text); }
.artist-hint::before { content: "Artist: "; color: var(--hint); font-weight: 600; }

.guess { margin-top: 14px; }
.guess input {
  width: 100%;
  padding: 15px 16px;
  font-size: 1.15rem;
  border-radius: 10px;
  border: 0;
  background: var(--cabinet-deep);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--rule);
}
.guess input::placeholder { color: #66798a; }
.guess input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--glow); }
.guess input.wrong { box-shadow: inset 0 0 0 2px var(--bad); }
.guess-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 10px; }

.feedback { min-height: 1.5em; margin: 14px 2px 0; color: var(--dusk); }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }
.feedback strong { color: var(--text); font-weight: 600; }

.shake { animation: shake 0.32s; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ---------- results ---------- */
.result-screen { gap: 12px; align-content: center; }
.score {
  margin: 0;
  font-family: var(--screen-font);
  font-weight: 700;
  font-size: clamp(2.6rem, 13vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 0 8px rgb(255 179 71 / 0.5);
}
.result-screen .squares { justify-content: center; flex-wrap: wrap; width: calc(5 * 16px + 4 * 5px); position: relative; z-index: 1; }
.result-screen .squares span { box-shadow: inset 0 0 0 1.5px var(--glow-dim); }
.result-screen .squares .correct { background: #2ea86c; box-shadow: none; }
.result-screen .squares .hinted { background: var(--hint); box-shadow: none; }
.result-screen .squares .skipped { background: #fff; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 30px 0 20px;
}
.stats dt { color: var(--dusk); font-size: 0.85rem; }
.stats dd { margin: 2px 0 0; font-size: 1.3rem; font-weight: 650; }
.results > .btn { width: 100%; }
.more-games { width: 100%; margin-top: 6px; }
.share-msg { min-height: 1.4em; margin: 10px 0 0; color: var(--dusk); font-size: 0.9rem; text-align: center; white-space: pre-line; }

.list-title { font-size: 1.15rem; font-weight: 700; margin: 30px 0 2px; }
.list-note { color: var(--dusk); font-size: 0.88rem; margin: 0 0 8px; }
.result-list { list-style: none; padding: 0; margin: 0; }
.result-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 16px;
  align-items: start;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}
.result-list .review > * { margin: 0; }

/* Dot (green got it, yellow with the hint, white skipped), then the clue. */
.result-list .outcome { display: flex; align-items: center; gap: 9px; }
.result-list .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--good); flex: none; }
.result-list .hinted .dot { background: var(--hint); }
.result-list .skipped .dot { background: var(--skip); }
.result-list .clue-small {
  /* Trim the line box to the capitals so they centre exactly against the dot. */
  text-box: trim-both cap alphabetic;
  line-height: 1.2;
  font-family: var(--screen-font);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--dusk);
  overflow-wrap: anywhere;
}
/* Browsers without text-box trimming (e.g. Firefox): nudge the capitals down to the dot's centre. */
@supports not (text-box: trim-both cap alphabetic) {
  .result-list .clue-small { position: relative; top: 0.08em; }
}

.result-list .review > .song { margin-top: 12px; line-height: 1.25; }
.result-list .title {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}
.result-list .title:hover { text-decoration: underline; text-underline-offset: 3px; }
.result-list .review > .byline { margin-top: 2px; font-size: 1rem; }
.result-list .artist { color: var(--text); }
.result-list .year { color: var(--dusk); white-space: nowrap; }

/* The UK certification, with a small disc in its colour. */
.result-list .review > .cert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--dusk);
  font-size: 0.92rem;
}
.result-list .disc {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  background: radial-gradient(circle, var(--cabinet) 0 2px, var(--gold) 2.5px 100%);
}
.result-list .cert[data-level="platinum"] .disc { background: radial-gradient(circle, var(--cabinet) 0 2px, var(--platinum) 2.5px 100%); }
.result-list .review > .time { margin-top: 8px; color: var(--dusk); font-size: 0.9rem; }
.result-list .review > .listen { margin-top: 4px; color: #66798a; font-size: 0.82rem; }
.result-list .listen a { color: var(--dusk); white-space: nowrap; }
.result-list .listen a:hover { color: var(--text); }

.result-list .cover {
  display: block;
  width: 84px;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  /* An empty sleeve: shown when there's no cover. */
  background: radial-gradient(circle, var(--cabinet-deep) 0 4px, #1d2b37 5px 30%, #22323f 31% 70%, var(--cabinet-deep) 71%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08), 0 6px 16px -6px rgb(0 0 0 / 0.6);
}
.result-list .cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.next { color: var(--dusk); margin: 24px 0 0; text-align: center; }
.next span { color: var(--text); }
.credit { color: #66798a; font-size: 0.78rem; text-align: center; margin: 18px auto 0; max-width: 44ch; }
.credit a { color: inherit; }
.credit .scrobbler { display: inline-block; margin-bottom: 6px; font-weight: 600; color: var(--dusk); }

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