:root {
  --bg: #f7f5f0;
  --fg: #22201c;
  --muted: #8a857c;
  --card: #ffffff;
  --line: #e6e1d8;
  --accent: #3d5a80;
  --right: #3c8d5a;
  --right-bg: #eef7f1;
  --wrong: #c4553f;
  --wrong-bg: #fbefec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b; --fg: #eeeae3; --muted: #8f8a82; --card: #222226;
    --line: #34343a; --accent: #8fb0d8; --right: #6cc08a; --right-bg: #1f2e25;
    --wrong: #e07a64; --wrong-bg: #33221f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header { text-align: center; padding: 32px 16px 8px; }
h1 { margin: 0; font-size: 1.9rem; font-weight: 700; letter-spacing: 0.01em; }
.date { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

main { max-width: 560px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.empty { text-align: center; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 18px 14px; transition: border-color 0.3s;
}
.card.solved { border-color: var(--right); }
.card.missed { border-color: var(--wrong); }
.card-head { display: flex; align-items: center; gap: 10px; }


.num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); font-size: 0.85rem; font-weight: 600;
}
.help {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line);
  background: none; color: var(--muted); font-size: 0.8rem; cursor: pointer; padding: 0;
}
.help:hover { color: var(--fg); border-color: var(--fg); }
.score { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.status {
  display: none; width: 26px; height: 26px; border-radius: 50%; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.9rem;
}
.card.solved .status { display: grid; background: var(--right); animation: pop 0.3s ease-out; }
.card.missed .status { display: grid; background: var(--wrong); animation: pop 0.3s ease-out; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

.instructions { color: var(--muted); font-size: 0.9rem; margin: 8px 0 12px; }
.prompt { font-size: 1.15rem; font-style: italic; margin: 0 0 14px; }

.field { display: block; margin-bottom: 12px; }
.field > span:first-child { display: block; font-size: 0.85rem; margin-bottom: 4px; }
.field.bonus > span:first-child { color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; }
input, select {
  flex: 1; width: 100%; font: inherit; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.right input, .right select { border-color: var(--right); background: var(--right-bg); color: var(--fg); opacity: 1; }
.revealed input, .revealed select { border-style: dashed; color: var(--muted); opacity: 1; }
.mark { width: 18px; color: var(--right); font-weight: 700; }

.match-row { display: grid; grid-template-columns: minmax(5.5em, 8.5em) 1fr 18px; align-items: center; gap: 10px; margin-bottom: 8px; }
.term { font-weight: 600; overflow-wrap: anywhere; }
.match-row select { font-size: 0.95rem; }

.choices { display: grid; gap: 8px; }
.choice {
  display: grid; gap: 2px; text-align: left; font: inherit; color: var(--fg); cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; color: var(--fg); }
.choice-text { font-weight: 600; }
.choice-year, .choice-detail { display: none; font-size: 0.85rem; color: var(--muted); }
.answered .choice-year, .answered .choice-detail { display: block; }
.answered .choice:not(.right):not(.wrong) { opacity: 0.6; }
.choice.right { border-color: var(--right); background: var(--right-bg); }
.choice.wrong { border-color: var(--wrong); background: var(--wrong-bg); }

.actions { display: flex; align-items: center; gap: 16px; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px;
  padding: 9px 20px; font: inherit; font-weight: 600; cursor: pointer; margin-top: 4px;
}
@media (prefers-color-scheme: dark) { .btn { color: #16161a; } }
.link {
  background: none; border: 0; padding: 0; margin-top: 4px; font: inherit; font-size: 0.85rem;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}
.link:hover { color: var(--fg); }
.feedback { min-height: 1.2em; margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }

.note { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; font-size: 0.92rem; }
.note p { margin: 0 0 6px; }
.caveat { color: var(--muted); font-size: 0.8rem; font-style: italic; }

.shake { animation: shake 0.35s; }
.shake input, .shake select { border-color: var(--wrong); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.done { text-align: center; margin: 8px auto 48px; padding: 0 16px; }
.done p { color: var(--fg); font-weight: 600; margin: 0 0 8px; }

dialog {
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--fg);
  width: min(92vw, 420px); padding: 22px 24px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog h2 { margin: 0 0 8px; }
dialog p { margin: 0 0 10px; }
.guest-line { border-left: 3px solid var(--accent); padding-left: 10px; }
.eyebrow { color: var(--accent); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 4px !important; }
dialog .btn { margin-top: 8px; }

/* Theme name with the guest group underneath */
.title { flex: 1; min-width: 0; }
.title h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; }
.title .guest { margin: 0; color: var(--muted); font-size: 0.85rem; }

/* Match it, tap style */
.tap-row { display: grid; grid-template-columns: minmax(4.5em, 7em) 1fr 18px; align-items: center; gap: 10px; margin-bottom: 8px; }
.tap-row .term { cursor: pointer; }
.slot {
  font: inherit; font-size: 0.95rem; text-align: left; color: var(--fg); cursor: pointer;
  padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); min-height: 42px;
}
.slot.empty { color: var(--muted); border-style: dashed; }
.tap-row.active .slot { outline: 2px solid var(--accent); outline-offset: -1px; }
.tap-row.right .slot { border-color: var(--right); background: var(--right-bg); cursor: default; }
.tap-row.revealed .slot { border-style: dashed; color: var(--muted); cursor: default; }
.tap-row.shake .slot { border-color: var(--wrong); }
.pool-hint { margin: 12px 0 6px; font-size: 0.8rem; color: var(--muted); }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  font: inherit; font-size: 0.9rem; color: var(--fg); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}
.chip:hover { border-color: var(--accent); }

/* Small links under the title */
.nav { margin: 6px 0 0; font-size: 0.85rem; }
.nav a { color: var(--muted); margin: 0 8px; }
.nav a:hover { color: var(--fg); }
main.page { display: block; }
.page p { margin: 0 0 10px; }
.page { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.page h2 { font-size: 1.1rem; margin: 24px 0 6px; }
.archive-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.archive-list a {
  display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--fg);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.archive-list a:hover { border-color: var(--accent); }
.archive-date { font-weight: 600; min-width: 7.5em; }
.archive-themes { flex: 1; color: var(--muted); font-size: 0.85rem; }
.archive-score { font-size: 0.85rem; white-space: nowrap; }
.muted { color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: default; }
