/* Trivia Gym: a chalkboard at the pub, with game-show energy for the moments that
   matter (round intros, scores, reveals). Always dark, like the board itself. */

:root {
  --board: #1d2b26;          /* slate, green-black */
  --board-2: #24352f;        /* a slightly cleaner patch of board */
  --board-3: #2d4039;
  --frame: #6e4b2e;          /* wooden frame */
  --frame-2: #8a6240;
  --chalk: #f2efe4;
  --chalk-dim: #b8b9ad;
  --line: rgba(242, 239, 228, .28);
  --line-soft: rgba(242, 239, 228, .14);
  --yellow: #f7d65c;
  --yellow-ink: #2a2410;
  --pink: #f49ab7;
  --blue: #8fd0f2;
  --green: #9fe29a;
  --red: #ff8f85;
  --orange: #ffb766;
  --display: 'Cabin Sketch', 'Marker Felt', 'Comic Sans MS', cursive;
  --score: 'Bungee', 'Impact', 'Arial Black', sans-serif;
  --hand: 'Caveat', 'Bradley Hand', 'Segoe Print', cursive;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 16px 18px 14px 17px;   /* hand-drawn, never perfectly even */
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--chalk); font: 17px/1.5 var(--body);
  background-color: var(--board);
  /* chalk dust and old smudges */
  background-image:
    radial-gradient(ellipse 60% 40% at 15% 10%, rgba(255, 255, 255, .05), transparent 70%),
    radial-gradient(ellipse 50% 35% at 85% 55%, rgba(255, 255, 255, .04), transparent 70%),
    radial-gradient(ellipse 70% 30% at 40% 95%, rgba(255, 255, 255, .035), transparent 70%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .035) 1px, transparent 1.5px);
  background-size: auto, auto, auto, 5px 5px;
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--blue); }

/* ---- the frame ---- */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.55rem + env(safe-area-inset-top)) 16px .55rem;
  background: linear-gradient(180deg, var(--frame-2), var(--frame));
  box-shadow: 0 3px 0 #4c3220, 0 6px 14px rgba(0, 0, 0, .35);
}
.brand { background: none; border: 0; padding: 0; cursor: pointer; font: 1.25rem var(--score); color: var(--yellow); letter-spacing: .04em; text-shadow: 0 2px 0 #4c3220; }
.who { color: #f3e3cf; font-size: .9rem; }
.who .linkish { color: #f3e3cf; }
.who .mute { text-decoration: none; font-size: 1rem; padding: 4px 6px; }

main { max-width: 560px; margin: 0 auto; padding: 18px 16px 32px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.muted { color: var(--chalk-dim); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* ---- chalk-drawn cards ---- */
.card {
  background: rgba(255, 255, 255, .025); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: inset 0 0 22px rgba(255, 255, 255, .02);
}
.card.tight { padding: 12px 14px; }

/* ---- buttons: chunky, game-show, with a press ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 10px 18px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--line); background: var(--board-2); color: var(--chalk);
  font-weight: 800; text-align: center; box-shadow: 0 4px 0 rgba(0, 0, 0, .35);
  transition: transform .06s ease, box-shadow .06s ease, background .15s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.btn.block { width: 100%; }
.btn.primary {
  background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink);
  text-transform: uppercase; letter-spacing: .06em; box-shadow: 0 4px 0 #b39223;
}
.btn.primary:active { box-shadow: 0 1px 0 #b39223; }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn.joker { border-color: var(--pink); color: var(--pink); background: transparent; }
.btn.joker.on { background: var(--pink); color: #2b1520; box-shadow: 0 4px 0 #b9637f; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .tab:focus-visible, .slot:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
.linkish { background: none; border: 0; color: var(--chalk-dim); text-decoration: underline dotted; cursor: pointer; padding: 4px 0; font-size: .85rem; }

/* home menu: big chalk tiles */
.menu { display: grid; gap: 12px; }
.menu .btn { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 18px; text-transform: none; letter-spacing: 0; }
.menu .btn { font-family: var(--display); font-size: 1.3rem; font-weight: 700; }
.menu .btn small { font-family: var(--body); font-size: .9rem; font-weight: 600; color: var(--chalk-dim); }
.menu .btn.primary small { color: #4a3f17; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- form fields: chalk boxes ---- */
input[type=text], select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: rgba(0, 0, 0, .22); font-size: 1.1rem; color: var(--chalk);
}
input[type=text]::placeholder, textarea::placeholder { color: rgba(242, 239, 228, .45); }
input[type=text]:focus, textarea:focus { border-color: var(--yellow); outline: none; }
select option { background: var(--board); }
label { display: block; font-weight: 800; font-size: .9rem; margin-bottom: 4px; color: var(--chalk-dim); }
pre { white-space: pre-wrap; }

/* ---- chips and scoreboard type ---- */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1.5px solid var(--line);
  font-size: .78rem; font-weight: 800; color: var(--chalk); background: rgba(0, 0, 0, .18);
}
.chip.joker { background: var(--pink); border-color: var(--pink); color: #2b1520; }
.chip.host { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.chip.off { opacity: .5; }
.code { font: 2.8rem/1 var(--score); letter-spacing: .18em; color: var(--yellow); text-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.round-num { font: 1rem var(--score); color: var(--yellow); letter-spacing: .12em; }
.round-num span { font-family: var(--body); font-weight: 800; color: var(--chalk-dim); letter-spacing: 0; text-transform: none; }
.qnum { font: .85rem var(--score); color: var(--yellow); letter-spacing: .06em; }
.score-big {
  font: 2.6rem/1.1 var(--score); color: var(--yellow);
  text-shadow: 0 0 18px rgba(247, 214, 92, .35), 0 3px 0 rgba(0, 0, 0, .45);
}

.players { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.players li { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 12px; border: 1.5px dashed var(--line-soft); font-weight: 800; }

/* ---- the question ---- */
.timer { height: 6px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.timer > i { display: block; height: 100%; background: var(--yellow); width: 100%; transform-origin: left; border-radius: 99px; }
.timer.low > i { background: var(--red); }
.prompt { font-size: 1.3rem; font-weight: 800; line-height: 1.35; margin: 0; }
.prompt.rebus, p.rebus { font-size: 1.9rem; letter-spacing: .05em; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.choice { min-height: 60px; font-weight: 800; }
.btn.choice:nth-child(4n+1) { border-color: var(--blue); }
.btn.choice:nth-child(4n+2) { border-color: var(--pink); }
.btn.choice:nth-child(4n+3) { border-color: var(--green); }
.btn.choice:nth-child(4n+4) { border-color: var(--orange); }
.clues { margin: 10px 0 0; padding-left: 1.4rem; display: grid; gap: 4px; font-family: var(--hand); font-size: 1.3rem; }
.clues li { animation: chalk-in .4s ease both; }

/* ---- the reveal: game-show beats ---- */
.reveal-q { position: relative; border-left-width: 6px; animation: chalk-in .45s ease both; }
.reveal-q:nth-child(2) { animation-delay: .05s; } .reveal-q:nth-child(3) { animation-delay: .1s; }
.reveal-q:nth-child(4) { animation-delay: .15s; } .reveal-q:nth-child(5) { animation-delay: .2s; }
.reveal-q:nth-child(6) { animation-delay: .25s; } .reveal-q:nth-child(7) { animation-delay: .3s; }
.reveal-q:nth-child(8) { animation-delay: .35s; } .reveal-q:nth-child(n+9) { animation-delay: .4s; }
.reveal-q.right { border-left-color: var(--green); }
.reveal-q.wrong { border-left-color: var(--red); }
.reveal-q.half { border-left-color: var(--orange); }
/* confidence: three lock-in buttons, cool to hot */
.confidence { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 8px; }
.btn.conf { min-height: 56px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; padding: 10px 6px; }
.btn.conf.guess { border-color: var(--blue); color: var(--blue); }
.btn.conf.think { background: var(--yellow); border-color: var(--yellow); color: #2a2410; box-shadow: 0 4px 0 #b3962f; }
.btn.conf.sure { border-color: var(--pink); color: var(--pink); }
.callout { margin: 8px 0; padding: 8px 12px; border-radius: 10px; border: 1.5px dashed var(--blue); color: var(--blue); font-size: .9rem; }
.callout.hot { border-color: var(--pink); color: var(--pink); }
.recap-item.hot { border-color: var(--pink); }
.tag-hot { color: var(--pink); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }

/* week-by-week bars */
.weeks { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 4px; }
.week { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.week > i { display: block; width: 100%; max-width: 44px; background: var(--yellow); border-radius: 6px 6px 0 0; }
.week .num { font-family: var(--score); font-size: .8rem; color: var(--yellow); }

/* pictures and clips */
.qpic { display: block; width: 100%; max-width: 420px; aspect-ratio: 1; object-fit: cover; margin: 12px auto 0;
  border-radius: 12px; border: 3px solid var(--chalk); box-shadow: 4px 4px 0 rgb(0 0 0 / .35); background: var(--line-soft); }
.qpic.small { max-width: 160px; margin: 6px 0; border-width: 2px; }
.btn.clip { display: block; width: 100%; margin-top: 12px; font-family: var(--score); font-size: 1.1rem; letter-spacing: .04em;
  border-color: var(--blue); color: var(--blue); }
.btn.clip.small { display: inline-block; width: auto; margin: 6px 0; font-size: .85rem; padding: 6px 14px; }
.reveal-q .prompt { font-size: 1.05rem; padding-right: 28px; }
.reveal-q .prompt.rebus, .reveal-q p.rebus { font-size: 1.35rem; }
.reveal-q.right::after, .reveal-q.wrong::after, .reveal-q.half::after {
  position: absolute; top: 8px; right: 12px; font: 1.6rem var(--score); transform: rotate(-12deg);
  animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: inherit;
}
.reveal-q.right::after { content: '✓'; color: var(--green); }
.reveal-q.wrong::after { content: '✗'; color: var(--red); }
.reveal-q.half::after { content: '½'; color: var(--orange); }
.reveal-q > p { padding-right: 2rem; }
.answer { font-weight: 900; color: var(--yellow); font-size: 1.1rem; }
.fact {
  margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(247, 214, 92, .07);
  border: 1.5px dashed rgba(247, 214, 92, .4); font: 1.3rem/1.25 var(--hand); color: #f6ecc4;
}
.fact::before { content: 'Remember: '; color: var(--yellow); }
.responses { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.resp { border: 1.5px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: .9rem; background: rgba(0, 0, 0, .2); text-align: left; font-weight: 700; color: var(--chalk); }
.resp.ok { border-color: var(--green); color: var(--green); }
.resp.no { border-color: var(--red); color: var(--red); }
.resp.partial { border-color: var(--orange); color: var(--orange); }
button.resp { cursor: pointer; min-height: 38px; }

/* ---- scoreboards and stats ---- */
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1.5px dashed var(--line-soft); font-size: 1.1rem; font-weight: 800; }
.board li span:last-child { font-family: var(--score); color: var(--yellow); }
.board li:first-child { font-size: 1.3rem; }
.board li:first-child span:first-child::before { content: '👑 '; }

.bars { display: grid; gap: 10px; }
.barrow { display: grid; grid-template-columns: 7.5rem 1fr 3.2rem; gap: 8px; align-items: center; font-size: .95rem; font-weight: 700; }
.barrow .track { height: 12px; border: 1.5px solid var(--line); border-radius: 99px; overflow: hidden; }
.barrow .fill { height: 100%; background: var(--green); }
.barrow .fill.weak { background: var(--red); }
.barrow .num { text-align: right; font-variant-numeric: tabular-nums; }
.heat { width: 100%; border-collapse: collapse; font-size: .82rem; font-weight: 700; }
.heat th, .heat td { padding: 6px 4px; text-align: center; border-bottom: 1px dashed var(--line-soft); }
.heat th:first-child, .heat td:first-child { text-align: left; }
.heat-wrap { overflow-x: auto; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 52px; }
.spark i { flex: 1; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; }

/* ---- learned today ---- */
.recap { display: grid; gap: 10px; }
.recap-item { padding: 12px 14px; border-radius: var(--radius); border: 1.5px dashed var(--line); }
.recap-item .q { font-weight: 700; margin: 0 0 4px; }
.recap-item .fact { margin-top: 6px; font-size: 1.15rem; }

/* ---- co-op drafting ---- */
.team-answer { border-color: var(--yellow); }
.final-draft { font-size: 1.25rem; }
.sugs { display: grid; gap: 8px; }
.sug-item { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1.5px dashed var(--line); flex-wrap: wrap; animation: chalk-in .3s ease both; }
.sug-item .grow { flex: 1 1 8rem; min-width: 0; }
.sug-text { font-weight: 800; overflow-wrap: anywhere; }
.sug-item.editing { border-color: var(--yellow); border-style: solid; }
.btn.tiny { min-height: 38px; padding: 4px 11px; font-size: .85rem; border-radius: 10px; box-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.btn.tiny.voted { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.btn.tiny.primary { box-shadow: 0 2px 0 #b39223; }

/* ---- live night sheet ---- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; }
.tab { flex: 0 0 auto; min-height: 42px; min-width: 50px; border-radius: 12px; border: 2px solid var(--line); background: var(--board-2); font: .85rem var(--score); color: var(--chalk); cursor: pointer; }
.tab.on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 58px; padding: 6px 8px; border-radius: 12px;
  border: 1.5px dashed var(--line); background: transparent; cursor: pointer; text-align: left; font-size: .8rem; overflow: hidden; color: var(--chalk); }
.slot b { font-family: var(--score); font-weight: 400; color: var(--yellow); }
.slot span { color: var(--chalk-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.slot i { position: absolute; top: 4px; right: 6px; font-style: normal; color: var(--green); font-weight: 900; }
.slot.on { border: 2px solid var(--yellow); }
.slot.now { background: rgba(247, 214, 92, .08); }
.slot.entered span { color: var(--chalk); }
.slot.res-right { border-color: var(--green); }
.slot.res-wrong { border-color: var(--red); }
.res-card input, .res-card select { min-height: 42px; font-size: 1rem; }

/* ---- misc ---- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto;
  padding: 12px 16px; border-radius: 14px; background: var(--yellow); color: var(--yellow-ink); font-weight: 800; z-index: 20;
  box-shadow: 0 4px 0 #b39223, 0 8px 20px rgba(0, 0, 0, .4); animation: chalk-in .25s ease both;
}
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes chalk-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes stamp { from { opacity: 0; transform: scale(2.2) rotate(-12deg); } to { opacity: 1; transform: scale(1) rotate(-12deg); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.pop { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition: none !important; }
}

/* Lobby QR code and the live sheet's question box */
.qr { display: block; margin: 10px auto; background: #fff; padding: 8px; border-radius: 12px; }
textarea.lnote { width: 100%; box-sizing: border-box; resize: none; font: inherit; font-size: 1.1rem; line-height: 1.35; overflow-y: auto; }

/* Home: the link under Quick practice, and a nudge when reviews are due */
.quick-change { justify-self: end; margin: -6px 4px 2px; font-size: .9rem; }
#review-btn.due { border-color: var(--yellow); }
#review-btn.due small { color: var(--yellow); }
/* Settings selects need the full width on a phone to show their text */
@media (max-width: 480px) { .grid2.roomy { grid-template-columns: 1fr; } }
/* Reveal: the way forward stays in reach however long the round was */
.sticky-next { position: sticky; bottom: 10px; z-index: 5; padding-top: 6px; }
.sticky-next .btn { box-shadow: 0 6px 18px rgba(0, 0, 0, .55); }
