:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #1b2a1f;
  --muted: #5b6b5f;
  --line: #d5ddd4;
  --accent: #14532d;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok: #0f7a3d;
  --field: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1511;
    --card: #19211b;
    --text: #e8efe9;
    --muted: #9bab9f;
    --line: #2c382e;
    --accent: #4ade80;
    --accent-text: #05210f;
    --danger: #ff8b7e;
    --ok: #4ade80;
    --field: #111812;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card);
}
.topbar a { color: var(--text); text-decoration: none; }
.brand { font-weight: 800; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.who { font-size: 14px; color: var(--muted); }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 22px 0 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin: 12px 0;
}
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; white-space: pre-wrap; }
.ok { color: var(--ok); }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input, select {
  width: 100%; padding: 12px; font-size: 16px; color: var(--text);
  background: var(--field); border: 1px solid var(--line); border-radius: 10px;
}
.btn {
  display: inline-block; text-align: center; text-decoration: none; cursor: pointer;
  padding: 12px 14px; font-size: 16px; font-weight: 600; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .55; }
.bigcode {
  font: 800 34px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em;
}
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a, .list .item { display: block; padding: 12px 4px; color: var(--text); text-decoration: none; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 4px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; border-top: 0; }
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13px; margin: 2px 4px 2px 0;
}
.live { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.qrbox { background: #fff; padding: 8px; border-radius: 10px; max-width: 320px; margin: 10px auto; }
.qrbox svg { display: block; width: 100%; height: auto; }
video.cam { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; object-fit: cover; }
.flash { animation: flash 2s ease-out; }
@keyframes flash { from { background: rgba(74, 222, 128, .35); } to { background: transparent; } }

/* ---------- banners, toast, results ---------- */
body.wide main { max-width: 960px; }
.banner {
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  border: 1px solid var(--accent); border-radius: 10px;
  padding: 12px 14px; margin: 12px 0; font-weight: 600;
}
.btn.danger { color: var(--danger); border-color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; max-width: 90vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20;
}
.toast.show { opacity: 1; }
.podium { display: grid; gap: 10px; margin: 12px 0; }
@media (min-width: 700px) { .podium { grid-template-columns: repeat(3, 1fr); } }
.medal { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.medal .place { font-size: 14px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.medal .who { font: 800 34px/1.15 ui-monospace, Menlo, Consolas, monospace; }
.medal.m1 { border-color: #d4a017; }
.medal.m1 .who { font-size: 44px; }
.medal.m2 { border-color: #9aa5b1; }
.medal.m3 { border-color: #b4713c; }
tr.me td { font-weight: 700; }

.netbar { background: #7a4b00; color: #fff; padding: 8px 16px; font-size: 14px; text-align: center; }
.netbar[hidden] { display: none; }
.warn { color: #b45309; }
@media (prefers-color-scheme: dark) { .warn { color: #fbbf24; } }
.pill.warn { border-color: currentColor; }
[hidden] { display: none !important; }
.banner { background: #fff4d6; border-color: #e2b13c; color: #5a3d00; }
@media (prefers-color-scheme: dark) { .banner { background: #3a2c0a; border-color: #8a6a1c; color: #ffe29a; } }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.banner.info { background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-color: var(--accent); color: var(--text); }
details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.btn:disabled { cursor: default; }
.winner { border-width: 2px; border-color: var(--accent); }
.trophy { font-size: 56px; line-height: 1.1; }
.winname { font: 800 40px/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; margin: 6px 0; }
.podium { display: grid; gap: 8px; margin: 12px 0; }
.medal { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 17px; }
.medal.m1 { border-width: 2px; border-color: var(--accent); font-size: 20px; }
.medal .mc { font: 700 1.1em ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; margin: 0 6px; }
.bigtime { font: 700 28px/1.2 ui-monospace, Menlo, Consolas, monospace; color: var(--accent); }

/* ---------- printing ---------- */
.sheet { text-align: center; padding: 24px 0; }
.sheet h1 { font-size: 56px; margin: 0; }
.sheet h3 { margin: 4px 0 18px; font-weight: 600; }
.sheet .qrbox { max-width: 520px; padding: 0; }
.sheet p { font-size: 20px; }
.sheet p.fnote { font-size: 30px; font-weight: 800; margin: 14px 0 0; }
/* sized QR codes: several per page */
.tiles { display: flex; flex-wrap: wrap; gap: .12in; align-items: flex-start; }
.tile {
  box-sizing: content-box; width: calc(var(--n) * 1in); padding: .08in; text-align: center;
  border: 1px dashed #777; background: #fff; color: #000; break-inside: avoid; page-break-inside: avoid;
}
.tile .qrbox { padding: 0; margin: 3px auto; max-width: 100%; }
.tile .tl { font-weight: 800; line-height: 1.1; }
.tile .th { color: #333; line-height: 1.1; }
.tile .tn { font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.tile.s4 .tl { font-size: 26px; } .tile.s4 .th { font-size: 14px; } .tile.s4 .tn { font-size: 22px; }
.tile.s3 .tl { font-size: 20px; } .tile.s3 .th { font-size: 12px; } .tile.s3 .tn { font-size: 17px; }
.tile.s2 .tl { font-size: 15px; } .tile.s2 .th { font-size: 10px; } .tile.s2 .tn { font-size: 13px; }
.tile.s1 .tl { font-size: 10px; } .tile.s1 .tn { font-size: 8px; }
@media print { .tile .qrbox { max-width: none; } }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
input[type=checkbox] { width: 22px; height: 22px; flex: none; }
@media print {
  .noprint, .topbar { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .sheet { page-break-after: always; break-after: page; min-height: 95vh;
           display: flex; flex-direction: column; justify-content: center; align-items: center; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
}
