:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --ink: #2b211b;
  --muted: #6f625a;
  --line: #e4dbd2;
  --accent: #8a4b2a;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e5f4ec;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --warn-bg: #fff4d6;
  --easy: #2f7d5b;
  --medium: #a66a00;
  --hard: #9b2c2c;
  --c0: #b3261e;
  --c1: #1d5fa8;
  --c2: #a66a00;
  --c3: #1f7a4d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 33, 27, 0.06), 0 4px 16px rgba(43, 33, 27, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1613;
    --surface: #262019;
    --ink: #f2ebe4;
    --muted: #b5a89d;
    --line: #3b3129;
    --accent: #d08a5c;
    --accent-ink: #1b1613;
    --ok: #6fd3a0;
    --ok-bg: #173527;
    --bad: #ff8a80;
    --bad-bg: #3d1d1a;
    --warn-bg: #3a3017;
    --easy: #6fd3a0;
    --medium: #f0b44a;
    --hard: #ff8a80;
    --c0: #e5534b;
    --c1: #4c8fd6;
    --c2: #d4952a;
    --c3: #3fa874;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
p { margin: 0 0 0.8em; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.brand span { font-weight: 400; color: var(--muted); }
.status { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.status.urgent { color: var(--bad); font-weight: 700; }

.wrap { max-width: 920px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.lede { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.92rem; }
.msg { min-height: 1.5em; color: var(--bad); margin-top: 0.6em; }
.msg:empty { min-height: 0; margin: 0; }
.step {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin-right: 0.5em;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 0.85em;
}

label { display: block; margin: 0 0 12px; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin-right: 16px; }
input[type=text], input:not([type]), input[type=url], input[type=password], input[type=number], select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input[type=file] { display: block; max-width: 100%; margin: 4px 0; font: inherit; }
input.upper { text-transform: uppercase; }
input.minutes { display: inline-block; width: 5em; margin: 0 4px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.packs { display: grid; gap: 8px; }
.pack-option {
  display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.pack-option span { display: grid; }
.pack-option small { color: var(--muted); }
.pack-change { max-width: 360px; font-weight: 400; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; font: inherit; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled, .button.disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.wrap-row { gap: 8px; }
.group { display: inline-flex; align-items: center; }

.banner { background: var(--warn-bg); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.banner p { margin: 0; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  border: 1px solid currentColor;
}
.badge.easy { color: var(--easy); }
.badge.medium { color: var(--medium); }
.badge.hard { color: var(--hard); }
.verified-inline { color: var(--ok); }

.verified-box, .pending-box, .fail-box { border-radius: 8px; padding: 10px 12px; font-weight: 600; }
.verified-box { background: var(--ok-bg); color: var(--ok); }
.pending-box { background: var(--warn-bg); }
.fail-box { background: var(--bad-bg); color: var(--bad); font-weight: 400; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks > li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.checks .mark {
  flex: 0 0 4.2em; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; padding-top: 3px;
}
.checks li.ok > .mark { color: var(--ok); }
.checks li.bad > .mark { color: var(--bad); }
.checks small { color: var(--muted); }
.checks .detail { display: block; color: var(--bad); }
.attacks { list-style: none; padding: 4px 0 0 0; margin: 0; font-size: 0.88rem; }
.attacks li.ok { color: var(--ok); }
.attacks li.bad { color: var(--bad); }
.submitted { background: var(--ok-bg); border-radius: 8px; padding: 10px 12px; }

.intro { margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.entry {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.entry.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.entry .row { margin-top: auto; padding-top: 8px; }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kind { color: var(--muted); font-size: 0.85rem; }
.by { color: var(--muted); }

.criteria { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.criteria dt { font-weight: 700; }
.criteria dd { margin: 0; }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.diff {
  overflow-x: auto; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre;
}
.diff .add { background: var(--ok-bg); color: var(--ok); }
.diff .del { background: var(--bad-bg); color: var(--bad); }
.diff .hunk { color: var(--muted); }
.diff .file { font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td .button, td button { min-height: 32px; padding: 4px 10px; }
tr.finalist { background: var(--warn-bg); }
td.flag { color: var(--bad); }
.code { letter-spacing: 0.08em; }
.big-status { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* projector */
.page-projector .wrap { max-width: none; }
.stage { text-align: center; padding: 4vh 2vw; }
.stage .eyebrow, .eyebrow { text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.huge { font-size: clamp(2.5rem, 8vw, 7rem); word-break: break-word; }
.big { font-size: clamp(1.2rem, 2.6vw, 2.2rem); }
.small { font-size: 1.1rem; color: var(--muted); }
.clock { font-size: clamp(5rem, 22vw, 18rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; margin: 2vh 0; }
.clock.urgent { color: var(--bad); }
.ticker ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font-size: 1.4rem; }
.slide { margin-top: 2vh; }
.slide-head h2 { font-size: 2rem; }
.slide-body iframe, .slide-body img {
  width: min(1200px, 100%); height: 62vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  object-fit: contain;
}
.linkcard { font-size: 1.6rem; word-break: break-all; }
.finalists { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; text-align: left; }
.big-entry h2 { font-size: 1.8rem; }

/* quiz */
.choices { display: grid; gap: 10px; }
.choice {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 64px; padding: 12px 14px; text-align: left; font-weight: 600;
  color: #fff; border: 3px solid transparent; border-radius: 10px; justify-content: flex-start;
}
.choice.c0 { background: var(--c0); }
.choice.c1 { background: var(--c1); }
.choice.c2 { background: var(--c2); }
.choice.c3 { background: var(--c3); }
.choice .letter {
  flex: 0 0 auto; display: inline-grid; place-items: center; width: 2em; height: 2em; border-radius: 6px;
  background: rgba(0, 0, 0, 0.22); font-weight: 800;
}
.choice .ctext { position: relative; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; }
.choice:disabled { opacity: 0.55; cursor: default; }
.choice.chosen { opacity: 1; border-color: var(--ink); box-shadow: 0 0 0 3px var(--surface) inset; }
.choice.right { opacity: 1; border-color: var(--ok); box-shadow: 0 0 0 4px var(--ok); }
.choice.wrong { opacity: 1; text-decoration: line-through; }
.choice.dim { opacity: 0.35; }
.choice .bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.18); }
.choice .count { position: relative; margin-left: auto; font-size: 1.4rem; font-weight: 800; }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.q-top .eyebrow { margin: 0; }
.q-clock { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.q-clock.urgent { color: var(--bad); }
.q-big { font-size: 1.4rem; font-weight: 700; margin-top: 12px; }
.q-note { font-weight: 700; margin: 12px 0; }
.q-note.ok { color: var(--ok); }
.q-note.bad { color: var(--bad); }
.q-foot { margin: 16px 0 0; color: var(--muted); }
.podium { font-size: 1.1rem; }
.quiz-stage { text-align: left; max-width: 1400px; margin: 0 auto; }
.quiz-stage .q-prompt { font-size: clamp(1.6rem, 3.4vw, 3rem); margin: 1vh 0 2vh; }
.big-clock { font-size: clamp(2.5rem, 6vw, 5rem); }
.q-code {
  font: clamp(1rem, 1.7vw, 1.6rem)/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px;
  overflow-x: auto; margin: 0 0 2vh;
}
.projector-choices { grid-template-columns: 1fr 1fr; gap: 14px; }
.projector-choices .choice { min-height: 10vh; font-size: clamp(1rem, 1.8vw, 1.6rem); }
.projector-choices .ctext { font-size: inherit; }
.q-explain { font-size: clamp(1.1rem, 2vw, 1.8rem); margin-top: 2vh; }
.board { list-style-position: inside; padding: 0; margin: 0 auto; max-width: 900px; font-size: clamp(1.1rem, 2.2vw, 2rem); text-align: left; }
.board li { display: list-item; padding: 6px 0; border-bottom: 1px solid var(--line); }
.board .who { font-weight: 700; margin-right: 1em; }
.board .pts { font-variant-numeric: tabular-nums; }
.board .secs { color: var(--muted); margin-left: 1em; font-size: 0.8em; }
.q-board { margin-top: 2vh; }
.quiz-stage .board { margin-left: 0; }
.stage > .board { margin-bottom: 3vh; }

@media (max-width: 600px) {
  .card { padding: 16px; }
  h1 { font-size: 1.35rem; }
  .criteria { grid-template-columns: 1fr; }
  .projector-choices { grid-template-columns: 1fr; }
}

/* Round progress on the player page */
ol.rounds { margin: 1rem 0 0; padding-left: 1.4rem; color: var(--muted); }
ol.rounds li { margin: 0.2rem 0; }
ol.rounds li.now { color: var(--ink); font-weight: 600; }
ol.rounds li.ok { color: var(--ok); }
.round-prompt { font-size: 1.1rem; line-height: 1.5; padding: 0.75rem 1rem; border-left: 4px solid var(--accent); background: var(--warn-bg); border-radius: 6px; }
