/* Billing block: the wall is a stack of poster names in tall condensed caps. */
:root {
  color-scheme: dark;
  --room: #16171c;
  --room-deep: #0f1013;
  --paper: #f4efe4;        /* poster cream, the tiles */
  --paper-dim: #e4dccb;
  --ink: #1b1a1f;
  --text: #f3f0ea;
  --muted: #a7a3ad;
  --rule: #2e2f37;
  --gold: #f2c14e;
  --gold-hi: #f7cf6c;
  --good: #7cc47f;
  --bad: #ff8a7a;
  --g0: #f2c14e;           /* row colours, in the order rows are found */
  --g1: #f08a4b;
  --g2: #7cc47f;
  --g3: #b39ddb;
  --name-font: "Oswald", "Arial Narrow", "Roboto Condensed", sans-serif-condensed, sans-serif;
  --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: radial-gradient(120% 60% at 50% 0, #20222a 0, var(--room) 55%, var(--room-deep) 100%);
  color: var(--text);
  font: 17px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; }

.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 18px; }
.logo { font-family: var(--name-font); font-weight: 700; font-size: 1.35rem; letter-spacing: 0.12em; color: var(--paper); }
.puzzle-label { color: var(--muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
body[data-screen="intro"] .top { display: none; }

/* ---------- buttons ---------- */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 14px 20px;
  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, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); color: var(--ink); }
.btn.primary:hover { background: var(--gold-hi); }
.btn.primary:disabled { opacity: 0.35; cursor: default; transform: none; }
.btn.quiet { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--rule); }
.btn.quiet:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--muted); }
.btn.wide { width: 100%; }
:is(.btn, a, .tile):focus-visible, input:focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }

/* ---------- intro ---------- */
.intro { padding-top: 24px; }
.wordmark { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.wm-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1.35 / 1;
  border-radius: 10px;
  font-family: var(--name-font);
  font-weight: 700;
  font-size: min(64px, calc((100vw - 40px) / 6.4));
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--paper);
  animation: drop 0.5s both cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.wm-tile.a { background: var(--g0); }
.wm-tile.b { background: var(--paper); animation-delay: 0.12s; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }
.intro-title { font-size: 1.7rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; margin: 32px 0 14px; }
.rules { margin: 0 0 24px; padding: 0; list-style: none; counter-reset: r; color: var(--muted); }
.rules li { counter-increment: r; position: relative; padding-left: 34px; margin-bottom: 12px; }
.rules li::before {
  content: counter(r);
  position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--paper); color: var(--ink);
  font: 600 0.8rem/1 var(--name-font);
}
.rules strong { color: var(--text); font-weight: 600; }
.preview-note { background: #2a2617; color: var(--gold); border-radius: 10px; padding: 12px 14px; margin: 0 0 18px; font-size: 0.95rem; }
.new-daily { color: var(--muted); text-align: center; font-size: 0.9rem; margin: 14px 0 0; }
.intro > .btn { width: 100%; }

/* ---------- wall ---------- */
.wall-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; min-height: 36px; }
.clock { font: 600 1.6rem/1 var(--name-font); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.clock.low { color: var(--bad); }
.strikes { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.strikes .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--muted); }
.strikes .dot.used { background: var(--bad); box-shadow: none; }

.wall { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tile, .row-solved > span {
  font-family: var(--name-font);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.08;
  text-align: center;
  overflow-wrap: normal;
  hyphens: none;
}
.tile {
  appearance: none;
  min-width: 0;
  border: 0;
  border-radius: 8px;
  padding: 6px 4px;
  aspect-ratio: 1 / 0.82;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  font-size: 17px; /* app.js shrinks long names to fit */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, background-color 0.12s, color 0.12s;
  user-select: none;
}
.tile > span, .row-solved > span > span { display: block; max-width: 100%; text-wrap: balance; }
.tile:hover { background: #fffaf0; }
.tile.selected { background: #3a3b45; color: var(--paper); transform: translateY(-2px); }
.wall.frozen .tile { cursor: default; background: var(--paper-dim); }

.row-solved {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  border-radius: 8px;
  padding: 0;
}
.row-solved.new { animation: settle 0.35s both cubic-bezier(0.2, 0.9, 0.3, 1.15); }
.row-solved > span {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 0.82;
  padding: 6px 4px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 17px;
}
.row-solved.c0 > span { background: var(--g0); }
.row-solved.c1 > span { background: var(--g1); }
.row-solved.c2 > span { background: var(--g2); }
.row-solved.c3 > span { background: var(--g3); }
.row-solved.revealed > span { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px #4a4b55; }
@keyframes settle { from { transform: scale(0.96); opacity: 0.4; } }

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

.toast { min-height: 1.5em; margin: 12px 2px 0; text-align: center; color: var(--muted); font-weight: 600; }
.toast.bad { color: var(--bad); }
.toast.good { color: var(--good); }
.wall-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
#to-names-btn { margin-top: 8px; }

/* ---------- naming ---------- */
.section-title { font-size: 1.25rem; font-weight: 700; margin: 4px 0 2px; }
.section-note { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }
.name-cards { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 12px; }
.name-card {
  border-radius: 12px;
  background: #1f2027;
  box-shadow: inset 0 0 0 1px var(--rule);
  padding: 12px;
  border-left: 6px solid var(--c, #4a4b55);
}
.name-card .cast { margin: 0 0 10px; font-family: var(--name-font); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; font-size: 1rem; line-height: 1.35; }
.name-card .cast span + span::before { content: " · "; color: var(--muted); }
.name-card form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.name-card input {
  min-width: 0;
  padding: 11px 12px;
  border-radius: 8px;
  border: 0;
  background: var(--room-deep);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--rule);
}
.name-card input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--paper); }
.name-card .field { position: relative; min-width: 0; }
.name-card .field input { width: 100%; }
.suggest {
  position: absolute;
  z-index: 5;
  left: 0;
  right: -120px; /* run under the buttons, so long titles fit on a phone */
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #26272f;
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--rule), 0 14px 30px -8px rgb(0 0 0 / 0.7);
}
.suggest li { padding: 9px 10px; border-radius: 7px; cursor: pointer; line-height: 1.25; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: #363844; }
.suggest .y { color: var(--muted); font-size: 0.88rem; margin-left: 4px; }
.name-card .btn { padding: 10px 14px; font-size: 0.95rem; }
.name-card .answer { display: grid; grid-template-columns: 1fr 44px; gap: 12px; align-items: center; }
.name-card .answer p { margin: 0; }
.name-card .verdict { font-weight: 700; }
.name-card .verdict.good { color: var(--good); }
.name-card .verdict.bad { color: var(--bad); }
.name-card .film-title { font-weight: 650; }
.name-card .you-said { color: var(--muted); font-size: 0.88rem; }
.name-card .thumb { width: 44px; aspect-ratio: 2 / 3; border-radius: 4px; overflow: hidden; background: var(--room-deep); }
.name-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- results ---------- */
.scorecard {
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 22px 18px 18px;
  display: grid;
  justify-items: center;
  gap: 14px;
}
.score { margin: 0; font: 700 clamp(3rem, 16vw, 4.4rem)/1 var(--name-font); letter-spacing: 0.02em; }
.score .out-of { font-size: 0.5em; color: #6d6874; margin-left: 4px; }
.score-rows { display: grid; gap: 5px; }
.score-rows .r { display: flex; gap: 5px; align-items: center; }
.score-rows .sq { width: 18px; height: 18px; border-radius: 4px; background: var(--c, #2b2b31); }
.score-rows .mark { margin-left: 6px; font-size: 0.95rem; width: 1.4em; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0 18px; }
.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.share-msg { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); font-size: 0.9rem; text-align: center; white-space: pre-line; }
.results .section-title { margin-top: 26px; }

.result-list { list-style: none; padding: 0; margin: 0; }
.result-list > li { display: grid; grid-template-columns: 1fr 110px; gap: 14px; align-items: stretch; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.result-list .film { margin: 0; line-height: 1.25; }
.result-list .film .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--c); margin-right: 8px; vertical-align: 0.05em; }
.result-list .year { margin-left: 6px; white-space: nowrap; }
.result-list .title { color: var(--text); font-size: 1.15rem; font-weight: 700; text-decoration: none; }
.result-list .title:hover { text-decoration: underline; text-underline-offset: 3px; }
.result-list .year { color: var(--muted); }
.result-list .outcome { margin: 4px 0 10px; color: var(--muted); font-size: 0.88rem; }
.result-list .people { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.result-list .people li { display: grid; justify-items: center; gap: 4px; text-align: center; font-size: 0.72rem; line-height: 1.15; color: var(--muted); }
.result-list .face { width: 44px; aspect-ratio: 2 / 3; border-radius: 6px; /* TMDB headshots are 2:3 portraits: show them whole */ overflow: hidden; background: #2a2b33; display: grid; place-items: center; font: 600 0.9rem var(--name-font); color: var(--muted); }
.result-list .face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-list .poster { display: block; width: 110px; height: 100%; min-height: 165px; /* the full row; the image is cropped to fit */ border-radius: 4px; overflow: hidden; background: var(--room-deep); box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08); }
.result-list .poster img { display: block; width: 100%; height: 100%; object-fit: cover; }

.next { color: var(--muted); margin: 24px 0 0; text-align: center; }
.next span { color: var(--text); }
.credit { color: #77737e; font-size: 0.78rem; text-align: center; margin: 18px auto 0; max-width: 42ch; }
.credit a { color: inherit; }

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .wall, .row-solved { gap: 5px; }
}

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