/* Auditorium: the page is the dark room, the clue is on the silver screen. */
:root {
  color-scheme: dark;
  --room: #2a2140;          /* auditorium aubergine */
  --room-deep: #1f1830;     /* the back rows */
  --screen: #eef1f5;        /* silver screen */
  --ink: #1d1729;           /* text on the screen */
  --text: #f1edf8;
  --dusk: #a79dbf;          /* secondary text */
  --rule: #40355a;
  --velvet: #b52a47;        /* seat-velvet crimson */
  --velvet-hi: #c9375a;
  --good: #3fbf7f;
  --star: #f5c451;          /* rating stars */
  --bad: #ff8a8a;
  --skip: #eef1f5;
  --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(--room-deep); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--room) 0, var(--room) 600px, var(--room-deep) 1400px);
  color: var(--text);
  font: 17px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none; }
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;
}
.puzzle-label { color: var(--dusk); font-size: 0.95rem; font-variant-numeric: tabular-nums; }

/* ---------- the screen ---------- */
.screen {
  position: relative;
  background: var(--screen);
  color: var(--ink);
  border-radius: 6px;
  min-height: 0;
  aspect-ratio: 2.39 / 1;   /* CinemaScope */
  display: grid;
  place-items: center;
  padding: 16px 18px;
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.6) inset,
    0 0 40px rgb(238 241 245 / 0.18),
    0 30px 80px -10px rgb(238 241 245 / 0.14);
}
.clue {
  margin: 0;
  font-family: var(--screen-font);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.15;
  text-align: center;
  /* font-size is set by app.js to fit the screen; 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 { animation: flicker 0.32s steps(1, end); }
@keyframes flicker {
  0% { background: #c9ccd3; }
  25% { background: var(--screen); }
  50% { background: #dfe2e8; }
  75% { background: var(--screen); }
}
.screen.solved { background: #d9f5e6; transition: background-color 0.2s; }
.screen.solved .clue { color: #0f5132; }

.caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 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(--velvet); }
.btn.primary:hover { background: var(--velvet-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):focus-visible, input:focus-visible {
  outline: 3px solid var(--screen);
  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(--screen);
  text-shadow: 0 0 28px rgb(238 241 245 / 0.22);
}
.wordmark .word { display: block; }
.wordmark .v {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--dusk);
  text-shadow: none;
  animation: vowel-out 0.9s 0.5s ease-in both;
}
@keyframes vowel-out {
  from { color: var(--screen); -webkit-text-stroke-color: transparent; }
  to { color: transparent; -webkit-text-stroke-color: var(--dusk); }
}
/* The header (logo and puzzle number) only appears once the 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; }
.intro .btn { width: 100%; }

/* ---------- play ---------- */
.play-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.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.skipped, .squares .skipped { background: var(--skip); box-shadow: none; }
.pips li.current { box-shadow: inset 0 0 0 2px var(--screen); }

.guess { margin-top: 22px; }
.guess input {
  width: 100%;
  padding: 15px 16px;
  font-size: 1.15rem;
  border-radius: 10px;
  border: 0;
  background: var(--room-deep);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--rule);
}
.guess input::placeholder { color: #7d7398; }
.guess input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--screen); }
.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;
}
.result-screen .squares { justify-content: center; flex-wrap: wrap; width: calc(5 * 16px + 4 * 5px); }
.result-screen .squares span { box-shadow: inset 0 0 0 1.5px #c4c0cf; }
.result-screen .squares .correct { background: #2ea86c; box-shadow: none; }
.result-screen .squares .skipped { background: #fff; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 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%; }
.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: 1fr 68px;
  gap: 16px;
  align-items: start;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}
.result-list .review > * { margin: 0; }

/* Where a Letterboxd review shows the reviewer: green or white dot, then the outcome. */
.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 .skipped .dot { background: var(--skip); }

.result-list .review > .film { 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 .year { color: var(--dusk); font-size: 1rem; font-weight: 400; white-space: nowrap; }

/* Five stars, filled in proportion to the rating, then the number. */
.result-list .review > .rating {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--dusk);
  font-size: 0.95rem;
}
.result-list .stars {
  position: relative;
  font-size: 1.05rem;
  letter-spacing: 2px;
  line-height: 1;
  color: #4a3f66;
}
.result-list .stars::before {
  content: "★★★★★";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill);
  overflow: hidden;
  white-space: nowrap;
  color: var(--star);
}
.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 > .time { margin-top: 8px; color: var(--dusk); font-size: 0.9rem; }


.result-list .poster {
  display: block;
  width: 68px;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: var(--room-deep);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08), 0 6px 16px -6px rgb(0 0 0 / 0.6);
}
.result-list .poster 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: #7d7398; font-size: 0.78rem; text-align: center; margin: 18px auto 0; max-width: 40ch; }
.credit a { color: inherit; }

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