/* LAST ROUND QUIZ — Studio BOLO */
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-900-normal.woff2) format("woff2"); font-weight: 900; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Big Shoulders Display"; src: url(fonts/big-shoulders-display-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --charcoal: #202622;
  --cream: #F3EAD6;
  --brass: #B99A5D;
  --wood: #35271F;
  --ink: #2A221C;          /* text on cream */
  --ink-soft: #5A4C40;     /* secondary text on cream, 7.1:1 */
  --brass-ink: #6E5A2E;    /* brass-coloured text on cream, 5.6:1 */
  --cream-dim: #C9BFA8;    /* secondary text on charcoal, 9:1 */
  --f-display: "Fraunces", Georgia, "Times New Roman", serif;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-board: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--wood);
  color: var(--cream);
  font: 400 1.0625rem/1.5 var(--f-body);
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Dark wood surround: a few long, quiet grain lines, never behind text. */
.frame {
  min-height: 100vh;
  min-height: 100svh; /* the visible area with browser bars shown: nothing hides behind Safari's toolbar */
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 10px) calc(env(safe-area-inset-bottom, 0px) + 10px) calc(env(safe-area-inset-left, 0px) + 10px);
  background:
    repeating-linear-gradient(97deg, rgba(0,0,0,.10) 0 2px, transparent 2px 23px, rgba(255,220,170,.035) 23px 24px, transparent 24px 61px),
    var(--wood);
}
/* The board inside the frame: a real box, so everything (incl. the sticky button) stays inside it. */
.board {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: var(--charcoal);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(185,154,93,.55), inset 0 0 0 5px var(--charcoal), inset 0 0 0 6px rgba(185,154,93,.22), 0 2px 0 rgba(0,0,0,.35);
  padding-bottom: 8px;
}

/* Header: wordmark · scoreboard · menu */
.bar {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 10px 0 20px;
}
.mark {
  margin: 0; margin-right: auto;
  font: 900 1.05rem/1 var(--f-display); letter-spacing: .07em; white-space: nowrap;
  color: var(--brass);
}
.score { white-space: nowrap; display: flex; align-items: center; gap: 7px; font-family: var(--f-board); font-weight: 700; color: var(--cream-dim); }
.score-label { font-size: .82rem; letter-spacing: .16em; }
.score-tile {
  display: inline-grid; place-items: center; min-width: 30px; height: 34px; padding: 0 6px;
  font-size: 1.45rem; line-height: 1; color: var(--cream);
  background: #171C19; border: 1px solid rgba(185,154,93,.6); border-radius: 4px;
  box-shadow: inset 0 -12px 0 rgba(255,255,255,.03);
}
.icon-btn {
  display: grid; place-items: center; width: 48px; height: 48px; margin-right: -4px;
  background: none; border: 0; border-radius: 50%; color: var(--cream-dim); cursor: pointer;
}
.icon-btn svg { fill: currentColor; }

main {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 6px 20px 8px; outline: none;
}

/* The beer mat. */
.coaster {
  position: relative;
  margin-top: 6px;
  background: var(--cream); color: var(--ink);
  border-radius: 26px;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 10px 24px rgba(0,0,0,.35);
}
.coaster-in {
  margin: 9px; padding: 22px 20px 26px;
  border: 1.5px solid var(--brass); border-radius: 19px;
  box-shadow: inset 0 0 0 3px var(--cream), inset 0 0 0 4px rgba(185,154,93,.55);
  min-height: clamp(220px, 40svh, 420px);
  display: flex; flex-direction: column; justify-content: center; text-align: center;
}
.cat {
  align-self: center; margin: 0 0 auto; padding-bottom: 14px;
  font-weight: 700; font-size: .95rem; letter-spacing: .02em; color: var(--brass-ink);
}
.q {
  margin: 0 auto; max-width: 22ch;
  font-size: clamp(1.55rem, 6.6vw, 2.25rem); line-height: 1.24; font-weight: 400;
  overflow-wrap: anywhere; hyphens: auto; outline: none;
}
.q.long { font-size: clamp(1.35rem, 5.6vw, 1.95rem); max-width: 26ch; }
.spacer { margin-top: auto; }

.hint-box {
  margin: 18px auto 0; max-width: 30ch; padding: 10px 14px;
  border-top: 1px dashed rgba(110,90,46,.6); color: var(--ink-soft); font-size: 1.05rem;
}
.hint-box strong { color: var(--brass-ink); }

/* Answer drawer: reveals with a gentle grow; fully readable without animation. */
.answer-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s var(--ease); }
.answer-wrap.open { grid-template-rows: 1fr; }
.answer-wrap > div { overflow: hidden; }
.answer {
  margin-top: 22px; padding-top: 18px; position: relative;
  border-top: 1px solid var(--brass);
  opacity: 0; transform: translateY(6px); transition: opacity .3s .08s, transform .3s .08s var(--ease);
}
.answer-wrap.open .answer { opacity: 1; transform: none; }
.answer::before { /* brass lozenge on the rule */
  content: ""; position: absolute; top: -5px; left: 50%; width: 9px; height: 9px; margin-left: -4.5px;
  background: var(--cream); border: 1px solid var(--brass); transform: rotate(45deg);
}
.a {
  margin: 0; font: 900 clamp(1.75rem, 8vw, 2.5rem)/1.12 var(--f-display); color: var(--ink);
  overflow-wrap: anywhere;
}
.alts { margin: 8px 0 0; font-size: .95rem; color: var(--ink-soft); }
.fact { margin: 14px auto 0; max-width: 34ch; font-size: 1.05rem; line-height: 1.45; color: var(--ink-soft); }

/* Actions sit in the thumb zone. */
.actions { margin-top: auto; padding-top: 18px; display: grid; gap: 6px; }
.actions.sticky {
  position: sticky; bottom: 0; z-index: 2;
  margin: auto -6px 0; padding: 18px 6px 6px;
  background: linear-gradient(to bottom, rgba(32,38,34,0), var(--charcoal) 16px);
  border-radius: 0 0 12px 12px;
}
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; width: 100%; padding: 12px 20px;
  border: 0; border-radius: 14px; cursor: pointer;
  font-weight: 700; font-size: 1.15rem; letter-spacing: .01em;
  background: var(--brass); color: #1A1F1C;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 1px 0 rgba(255,255,255,.12) inset;
}
.btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); }
.btn.ghost { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 1.5px rgba(185,154,93,.7); }
.link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 12px;
  background: none; border: 0; cursor: pointer; color: var(--cream-dim);
  font-size: 1rem; text-decoration: underline; text-decoration-color: rgba(185,154,93,.7); text-underline-offset: 4px;
}
.link.small { font-size: .92rem; }
.row-center { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 12px; }

/* Title cards: start, end of round, notices. */
.word {
  margin: 0; font: 900 clamp(3rem, 16vw, 4.6rem)/.92 var(--f-display); letter-spacing: .01em; color: var(--ink);
}
.word small { display: block; margin-top: 10px; font: 600 1.05rem/1.3 var(--f-display); letter-spacing: .02em; color: var(--brass-ink); }
.title { margin: 0; font: 900 clamp(2rem, 9.5vw, 2.8rem)/1.05 var(--f-display); color: var(--ink); outline: none; }
.sub { margin: 12px auto 0; max-width: 28ch; font-size: 1.15rem; color: var(--ink-soft); }
.note { margin: 14px auto 0; max-width: 32ch; font-size: .98rem; color: var(--ink-soft); }
.rule { width: 56px; height: 1px; margin: 18px auto; background: var(--brass); border: 0; }
.nfc { width: 64px; height: 64px; margin: 0 auto 16px; color: var(--brass-ink); }

/* Next-round category picker */
.picker { margin: 14px 0 0; padding: 0; border: 0; text-align: center; }
.picker legend { padding: 0; margin: 0 auto 8px; font-size: .95rem; color: var(--cream-dim); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid rgba(185,154,93,.5); color: var(--cream-dim); font-size: .98rem;
}
.chip input:checked + span { background: rgba(185,154,93,.18); border-color: var(--brass); color: var(--cream); font-weight: 700; }
.chip input:focus-visible + span { outline: 3px solid var(--cream); outline-offset: 2px; }

.tie-unit { margin: 14px 0 0; font-weight: 700; color: var(--brass-ink); }

.spinner { width: 26px; height: 26px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(185,154,93,.3); border-top-color: var(--brass-ink); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.demo-flag {
  margin: 0 auto; padding: 4px 12px 2px; font-size: .82rem; color: var(--brass); text-align: center;
}

/* Bottom sheet dialog */
.sheet {
  width: min(560px, 100%); max-width: 100%; max-height: 88dvh; margin: auto auto 0;
  padding: 0; border: 0; border-radius: 22px 22px 0 0;
  background: var(--cream); color: var(--ink); color-scheme: light;
  box-shadow: 0 -12px 40px rgba(0,0,0,.45);
}
.sheet::backdrop { background: rgba(10,12,11,.62); }
.sheet-in { padding: 22px 22px calc(env(safe-area-inset-bottom, 0px) + 22px); border-top: 3px double var(--brass); border-radius: 22px 22px 0 0; }
.sheet h2 { margin: 0 0 4px; font: 900 1.6rem/1.15 var(--f-display); }
.sheet p { margin: 8px 0; color: var(--ink-soft); }
.sheet .menu-list { list-style: none; margin: 10px 0 0; padding: 0; }
.sheet .menu-list button {
  display: flex; width: 100%; min-height: 54px; align-items: center; justify-content: space-between;
  padding: 10px 2px; background: none; border: 0; border-bottom: 1px solid rgba(110,90,46,.25);
  font-size: 1.12rem; text-align: left; cursor: pointer; color: var(--ink);
}
.sheet .menu-list small { color: var(--ink-soft); font-size: .9rem; }
.sheet .btn.ghost { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--brass); }
.sheet .link { color: var(--ink-soft); }
.sheet fieldset { border: 0; margin: 12px 0 0; padding: 0; }
.sheet legend { font-weight: 700; margin-bottom: 4px; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; font-size: 1.08rem; }
.opt input { width: 22px; height: 22px; accent-color: var(--brass-ink); margin: 0; }
.sheet textarea {
  width: 100%; min-height: 88px; margin-top: 6px; padding: 10px 12px; resize: vertical;
  border: 1px solid rgba(110,90,46,.5); border-radius: 10px; background: #FBF6EA; color: var(--ink);
}
.sheet label.lbl { display: block; margin-top: 12px; font-weight: 700; }
.sheet .sheet-actions { display: grid; gap: 8px; margin-top: 18px; }
.counts { width: 100%; border-collapse: collapse; margin: 10px 0 4px; font-size: 1.02rem; }
.counts td { padding: 8px 2px; border-bottom: 1px solid rgba(110,90,46,.2); }
.counts td:last-child { text-align: right; font-family: var(--f-board); font-weight: 700; font-size: 1.2rem; }
.warn { padding: 10px 12px; border-left: 3px solid var(--brass); background: rgba(185,154,93,.12); color: var(--ink) !important; }

:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.q:focus, .title:focus, .sheet h2:focus, main:focus { outline: none; }
.coaster :focus-visible, .sheet :focus-visible { outline-color: var(--ink); }

/* Calm swap between questions */
.swap { animation: swap .26s var(--ease); }
@keyframes swap { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-height: 760px) { main { padding-top: 16px; } }
@media (max-width: 350px) {
  main { padding-left: 14px; padding-right: 14px; }
  .coaster-in { padding: 18px 14px 22px; }
  .score-label { font-size: .7rem; letter-spacing: .08em; }
  .score { gap: 5px; }
  .mark { font-size: .9rem; letter-spacing: .04em; }
  .bar { padding-left: 14px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.note.on-board { text-align: center; color: var(--cream-dim); }
.picker.in-sheet { text-align: left; }
.picker.in-sheet legend { color: var(--ink); font-weight: 700; margin-left: 0; }
.sheet .chip span { color: var(--ink); border-color: rgba(110,90,46,.5); }
.sheet .chip input:checked + span { color: var(--ink); background: rgba(185,154,93,.3); }
