/* Oh Hell Noel */
:root {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #f1ece3;
  --text: #1f2a24;
  --muted: #5f6b64;
  --line: #e2dbcf;
  --green: #1f5a40;
  --green-ink: #ffffff;
  --red: #b3263a;
  --gold: #b8892a;
  --ok-bg: #e5f3ea; --ok-ink: #17603a; --ok-line: #9fd0b2;
  --bad-bg: #fbe8ea; --bad-ink: #a11d31; --bad-line: #ecaab4;
  --warn-bg: #fdf3dc; --warn-ink: #7a5600;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .06), 0 4px 16px rgba(31, 42, 36, .05);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121815; --surface: #1b231f; --surface-2: #232d28; --text: #ebe7df; --muted: #a2ada6;
    --line: #2f3b35; --green: #3f9a6e; --green-ink: #0d1411; --red: #e0596c; --gold: #d9b057;
    --ok-bg: #173327; --ok-ink: #8fdcb0; --ok-line: #2c6a4b;
    --bad-bg: #3a1a20; --bad-ink: #f3a3ae; --bad-line: #7a2f3b;
    --warn-bg: #3a2f14; --warn-ink: #f0d18a;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--sans);
  min-height: 100vh; display: flex; flex-direction: column;
}
main.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 8px 16px 48px; flex: 1; }
body.admin main.wrap { max-width: 920px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
a { color: var(--green); }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.lede { font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 .5em; }
.muted-link { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 920px; margin: 0 auto; width: 100%; padding: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.holly { width: 30px; height: 30px; color: var(--green); }
.holly .berry { fill: var(--red); }
.top-nav { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: .95rem; }
.top-nav a { text-decoration: none; padding: 4px 2px; }
.top-nav a[aria-current="page"] { font-weight: 600; border-bottom: 2px solid var(--red); }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 32px; }

/* Stage tracker */
.stages { list-style: none; display: flex; justify-content: center; gap: 6px; padding: 0 16px; margin: 0 auto 12px; max-width: 720px; width: 100%; }
.stages li { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); flex: 1; justify-content: center; position: relative; }
.stages .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.stages .done .dot { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.stages .current { color: var(--text); font-weight: 600; }
.stages .current .dot { background: var(--red); border-color: var(--red); color: #fff; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card.subtle { background: var(--surface-2); box-shadow: none; }
.card.narrow { max-width: 420px; margin-inline: auto; }
.hero { text-align: center; padding: 32px 20px; }
.hero form { max-width: 340px; margin: 16px auto 0; text-align: left; }
@media (min-width: 600px) { .card { padding: 24px 28px; } h1 { font-size: 1.85rem; } }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field .hint { margin: 0; }
label { font-weight: 600; }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=number], input:not([type]), textarea, select {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--green) 35%, transparent); outline-offset: 1px; border-color: var(--green); }
[aria-invalid="true"] { border-color: var(--red); }
.field-error { color: var(--bad-ink); font-size: .9rem; margin: 2px 0 0; }
.counter { text-align: right; }
.num-input { width: 5em !important; display: inline-block; min-height: 0; padding: 4px 8px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 11px 18px; min-height: 46px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--green); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn-tiny { padding: 2px 8px; min-height: 0; font-size: .75rem; border-radius: 6px; }

.linkbox label { display: block; margin-bottom: 4px; }
.linkbox-row { display: flex; gap: 8px; }
.linkbox-row input { min-width: 0; font-size: .9rem; }

/* Notices */
.notice { border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
.notice-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.notice-error { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }

/* Profile */
.profile { margin: 16px 0 0; display: grid; gap: 10px; }
.profile div { display: grid; gap: 2px; }
.profile dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.profile dd { margin: 0; overflow-wrap: anywhere; }
.fact-text { font-family: var(--serif); font-size: 1.08rem; }

/* Chips */
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .95rem; cursor: default; transition: opacity .2s; }
.chip a { text-decoration: none; color: inherit; }
#name-pool .chip { cursor: pointer; }
#name-pool .chip.used { opacity: .45; text-decoration: line-through; }

/* Matching game */
.facts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; }
.fact-card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 16px 56px; box-shadow: var(--shadow); transition: border-color .2s, background-color .2s;
}
.fact-num {
  position: absolute; left: 14px; top: 16px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--surface-2); border: 1px solid var(--line);
}
.fact-card blockquote { margin: 0 0 12px; }
.fact-card.is-matched { border-color: var(--ok-line); }
.fact-card.is-matched .fact-num { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.fact-card.needs-answer { border-color: var(--red); background: var(--bad-bg); }
.fact-card.flash { animation: flash 1s ease; }
@keyframes flash { 0% { background: var(--warn-bg); } 100% { background: var(--surface); } }
.pool { position: relative; }

.submit-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px;
}
.submit-bar .progress { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.submit-bar .progress span { display: block; height: 100%; width: 0; background: var(--green); transition: width .25s; }
.submit-bar p { margin: 0; font-size: .95rem; color: var(--muted); }
#submit-btn:not(.ready) { opacity: .75; }

.dialog { border: none; border-radius: var(--radius); padding: 24px; max-width: 380px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(10, 20, 15, .5); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Pairs (read-only & scored) */
.pairs { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.pairs li { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; }
.pairs blockquote { margin: 0; }
.pair-name { font-weight: 600; }
.pairs.scored .right { background: var(--ok-bg); border-color: var(--ok-line); }
.pairs.scored .wrong { background: var(--bad-bg); border-color: var(--bad-line); }
.pairs.scored .right .pair-name, .pairs.scored .right .mark { color: var(--ok-ink); }
.pairs.scored .wrong .pair-name, .pairs.scored .wrong .mark { color: var(--bad-ink); }
.mark { font-weight: 800; margin-right: 4px; }
.actual { font-size: .92rem; color: var(--muted); }
.score-big { font-size: 1.2rem; }
.score-big strong { font-family: var(--serif); font-size: 2.4rem; color: var(--green); margin-right: 4px; }

/* Awards */
.winners { text-align: center; }
.award-grid { display: grid; gap: 12px; margin: 8px 0 16px; }
@media (min-width: 560px) { .award-grid { grid-template-columns: 1fr 1fr; } }
.award { border-radius: 12px; padding: 18px; text-align: center; display: grid; gap: 4px; justify-items: center; }
.award-1 { background: color-mix(in srgb, var(--gold) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); }
.award-2 { background: color-mix(in srgb, var(--text) 8%, var(--surface)); border: 1px solid var(--line); }
.award-name { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--muted); margin: 0; }
.winner { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; margin: 4px 0 0; }
.award-detail { color: var(--muted); font-size: .9rem; margin: 0 0 6px; }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; display: grid; color: var(--muted); font-size: .9rem; }
.stat-num { font-family: var(--serif); font-size: 1.9rem; color: var(--text); line-height: 1.1; }
.stage-list { display: grid; gap: 8px; }
.stage-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stage-option .hint { margin: 2px 0 0; }
.stage-option.is-current { border-color: var(--green); background: var(--ok-bg); }
.reveal { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; font-family: var(--sans); }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.badge.gold { background: color-mix(in srgb, var(--gold) 20%, var(--surface)); color: var(--text); border-color: var(--gold); }
.badge.dark { background: var(--text); color: var(--bg); border-color: var(--text); }
.table-wrap { overflow-x: auto; margin: 0 -4px 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table tr.dim td { color: var(--muted); }
.inline-form { margin-top: 14px; }
.inline-form label { display: block; margin-bottom: 4px; font-size: .9rem; }
.all-links summary, .danger-zone summary { cursor: pointer; font-weight: 600; }
.all-links textarea { margin-top: 8px; font-size: .85rem; font-family: ui-monospace, monospace; }
.danger-zone { border-color: var(--bad-line); }
.danger-zone form { margin-top: 12px; }
form[data-confirm] { margin-top: 10px; }
.stage-option[data-confirm] { margin-top: 0; }
