/* ---------- Tokens ---------- */
:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #eee8da;
  --text: #1c1f26;
  --muted: #5f6470;
  --border: #e2dac8;
  --border-strong: #cfc5ae;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fbe7da;
  --accent-text: #ffffff;
  --good: #166534;
  --good-bg: #e2f3e7;
  --bad: #b42318;
  --bad-bg: #fbe6e3;
  --grid: rgb(28 31 38 / .045);
  --photo-bg: #0c0e12;
  --shadow-sm: 0 1px 2px rgb(28 31 38 / .06);
  --shadow: 0 1px 2px rgb(28 31 38 / .05), 0 8px 24px -8px rgb(28 31 38 / .14);
  --shadow-lg: 0 2px 4px rgb(28 31 38 / .06), 0 18px 48px -12px rgb(28 31 38 / .28);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --column: 820px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141a;
    --surface: #191d25;
    --surface-2: #232834;
    --text: #eef0f4;
    --muted: #a2a9b6;
    --border: #2b313e;
    --border-strong: #3b4252;
    --accent: #fb8a4c;
    --accent-hover: #fda26f;
    --accent-soft: #3a2318;
    --accent-text: #1a0e07;
    --good: #4ade80;
    --good-bg: #10281a;
    --bad: #f87171;
    --bad-bg: #321619;
    --grid: rgb(238 240 244 / .035);
    --photo-bg: #07080b;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -8px rgb(0 0 0 / .5);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / .3), 0 18px 48px -12px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* A faint map graticule behind everything, fading out towards the bottom. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 85%);
  pointer-events: none;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

h1, h2, .display { font-family: var(--font-display); letter-spacing: -.02em; }

/* ---------- Header ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 18px 16px 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
}
.brand:hover { color: var(--text); }
.brand:hover .brand-mark { transform: rotate(-12deg); }
.brand-mark { width: 30px; height: 30px; transition: transform .3s ease; }
.brand-name { font-family: var(--font-display); font-weight: 750; font-size: 1.3rem; letter-spacing: -.02em; }

.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: .9rem;
}
.stat-label { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat b { font-family: var(--font-display); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat-of { color: var(--muted); font-variant-numeric: tabular-nums; }

.progress {
  width: calc(100% - 32px);
  max-width: calc(var(--column) - 32px);
  height: 4px;
  margin: 0 auto 18px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

main { flex: 1; width: 100%; max-width: var(--column); margin: 0 auto; padding: 0 16px 32px; }

/* ---------- Shared pieces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 650;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; border-radius: 14px; }

/* ---------- Setup ---------- */
.hero { padding: 18px 4px 26px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(2rem, 5.5vw, 3.1rem); line-height: 1.05; font-weight: 800; max-width: 15ch; }
.lede { margin: 0; color: var(--muted); font-size: 1.08rem; max-width: 52ch; }
.count { color: var(--text); font-weight: 600; }

.setup-card { display: grid; gap: 22px; }

.field { display: block; border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend, .field-label {
  display: block;
  padding: 0;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Visually hidden radios that still take focus and keyboard input. */
.chip input, .mode-card input, .segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; }
.chip span {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover span { border-color: var(--border-strong); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.select-wrap { position: relative; display: block; max-width: 340px; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select, .type-form input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  transition: border-color .15s;
}
select { appearance: none; padding-right: 40px; cursor: pointer; }
select:hover, .type-form input:hover { border-color: var(--border-strong); }

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .mode-cards { grid-template-columns: 1fr; } }
.mode-card { cursor: pointer; }
.mode-body {
  position: relative;
  display: grid;
  gap: 2px;
  height: 100%;
  padding: 14px 44px 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.mode-body small { color: var(--muted); font-size: .88rem; }
/* Radio dot on the right. */
.mode-body::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  transition: border-color .15s, box-shadow .15s;
}
.mode-card:hover .mode-body { border-color: var(--border-strong); }
.mode-card input:checked + .mode-body { background: var(--accent-soft); border-color: var(--accent); }
.mode-card input:checked + .mode-body::after { border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--accent-soft), inset 0 0 0 10px var(--accent); }
.mode-card input:focus-visible + .mode-body { outline: 3px solid var(--accent); outline-offset: 2px; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.segmented label { cursor: pointer; }
.segmented span {
  display: block;
  min-width: 56px;
  padding: 7px 14px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 650;
  border-radius: 10px;
  color: var(--muted);
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding-top: 4px; }
.best { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- Game ---------- */
.stage { margin: 0 0 14px; }
.clue { position: relative; isolation: isolate; margin: 0; }
.clue img {
  display: block;
  width: 100%;
  min-height: 220px;
  /* Leave room for the options (and the reveal panel) on short screens. */
  max-height: min(480px, 46vh);
  object-fit: contain;
  background: var(--photo-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transition: opacity .25s ease;
}
/* Between rounds: hide the old photo but keep its space, so the layout doesn't jump. */
.clue.loading img { opacity: 0; }
.clue::after {
  /* Placeholder frame shown while the photo loads. */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--photo-bg);
  border-radius: var(--radius);
}
.clue-tags { position: absolute; top: 12px; left: 12px; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tag {
  padding: 4px 11px;
  color: #fff;
  background: rgb(12 14 18 / .62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgb(255 255 255 / .16);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .02em;
}

.hint {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: .97rem;
}
.hint::before {
  content: "Hint";
  flex-shrink: 0;
  padding-top: 2px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 700px) { .choices { grid-template-columns: 1fr 1fr; } }
.choices .btn {
  justify-content: flex-start;
  gap: 10px;
  min-height: 52px;
  padding: 10px 12px;
  text-align: left;
  line-height: 1.25;
  box-shadow: var(--shadow-sm);
}
.choices .btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.choices .btn kbd {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font: 700 .75rem/1 var(--font-body);
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
}
.choices .btn:disabled:not(.right):not(.wrong) { opacity: .55; }
.choices .btn.right { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.choices .btn.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.choices .btn.right kbd { background: var(--good); color: var(--good-bg); }
.choices .btn.wrong kbd { background: var(--bad); color: var(--bad-bg); }

.type-form { display: flex; gap: 10px; margin-bottom: 16px; }
.type-form input { flex: 1; background: var(--surface); padding: 13px 16px; font-size: 1.05rem; }

/* Hint and answer panel share one grid cell, so the answer cross-fades in where the hint was. */
.slot { display: grid; margin: 0 0 16px; }
.slot > * { grid-area: 1 / 1; min-width: 0; }
.slot:not(:has(> :not([hidden]))) { margin: 0; }
.slot .hint { margin: 0; transition: opacity .25s ease, visibility 0s linear 0s; }
.slot.answered .hint { opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility 0s linear .5s; }

.reveal {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  /* Coloured edge: green for right, red for wrong. */
  border-left: 4px solid var(--rc, var(--accent));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: fade .8s ease both;
}
.reveal.right { --rc: var(--good); }
.reveal.wrong { --rc: var(--bad); }
#verdict-box { margin-bottom: 8px; }
.verdict-label { margin: 0; color: var(--rc); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.verdict { margin: 2px 0 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 750; line-height: 1.15; letter-spacing: -.02em; }
.description { margin: 0 0 10px; font-size: 1rem; }

.next-row { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.reveal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; font-size: .86rem; }
.reveal-meta .sep { color: var(--muted); }
.credit { flex-basis: 100%; color: var(--muted); }

/* Wide screens: park Next in the empty space right of the column, centred in that gap. */
@media (min-width: 1200px) {
  .next-row { margin: 0; }
  .next-btn {
    position: fixed;
    top: 50%;
    right: max(16px, calc((100vw - var(--column)) / 4 - 75px));
    width: 150px;
    padding: 18px 0;
    font-size: 1.2rem;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    transform: translateY(-50%);
    animation: pop .3s ease both;
  }
  .next-btn:active:not(:disabled) { transform: translateY(calc(-50% + 1px)); }
}

/* ---------- Results ---------- */
.results { text-align: center; padding: 32px 24px; animation: rise .35s ease both; }
.results .eyebrow { font-size: .9rem; }
.result-score { margin: 0; font-family: var(--font-display); font-size: clamp(4rem, 14vw, 6rem); font-weight: 800; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.result-of { color: var(--muted); font-size: .45em; letter-spacing: 0; }
.result-text { margin: 10px 0 22px; color: var(--muted); }
.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
  text-align: left;
}
.result-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .93rem;
  line-height: 1.3;
}
.result-list .mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 800;
}
.result-list .right .mark { background: var(--good-bg); color: var(--good); }
.result-list .wrong .mark { background: var(--bad-bg); color: var(--bad); }
.result-list .said { display: block; color: var(--muted); font-size: .82rem; }

/* ---------- Footer ---------- */
footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 28px;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}
footer a { color: inherit; }
footer a:hover { color: var(--text); }

/* ---------- Motion ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-50%) scale(.9); } to { opacity: 1; transform: translateY(-50%); } }

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