/* Contrast (WCAG): fg 13.4:1, --mut 5.06:1 on card, --line 3.3:1 vs card (non-text >= 3:1), --acc 11.25:1. */
:root {
  color-scheme: dark;
  --bg: #14151a; --card: #1e2028; --field: #101116; --hover: #2a2d38;
  --line: #6b7083;      /* borders of interactive controls: >= 3:1 */
  --divider: #2e313c;   /* decorative separators only */
  --fg: #e8e9ee; --mut: #8b8fa0; --acc: #ffd23f; --on-acc: #111;
  --ok: #4ade80; --bad: #f87171;
  --r: 8px; --t: 150ms;
}
* { 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; }
a { color: var(--acc); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; margin-top: 1rem; }
figure { margin: 0; }
img { max-width: 100%; }

/* ---------- accessibility helpers ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 10; background: var(--acc); color: var(--on-acc); padding: 10px 14px; border-radius: var(--r); font-weight: 700; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
#app:focus { outline: none; }

/* ---------- layout ---------- */
.nav { max-width: 1280px; margin: 0 auto; padding: 10px 16px 0; display: flex; gap: 12px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 6px 0; }
.page { max-width: 1280px; margin: 0 auto; padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--divider); border-radius: 10px; padding: 16px; min-width: 0; }
.card.gap { margin-top: 16px; }
.narrow { max-width: 440px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pagehead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.pagehead h1 { margin: 0; }
.pagehead .timer, .pagehead .big { margin-left: auto; }
.pagehead .big + .timer { margin-left: 16px; }
.mut { color: var(--mut); }
.hint { color: var(--mut); font-size: 14px; margin: 4px 0 8px; }
.err { color: var(--bad); min-height: 1.5em; margin: 8px 0; }
.err:empty { min-height: 0; margin: 0; }
.loading { color: var(--mut); }
.big { font-size: 2.4rem; font-weight: 800; letter-spacing: .2em; color: var(--acc); margin: 0; }

/* ---------- forms ---------- */
label { display: block; margin: .75rem 0 .25rem; color: var(--mut); font-size: 14px; }
label.inline { display: inline; margin: 0; }
input, textarea, select { width: 100%; background: var(--field); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; font: inherit; min-height: 40px; }
input[type=range] { padding: 0; border: 0; background: none; min-height: 0; }
input[type=file] { padding: 7px; }
input:hover, textarea:hover, select:hover { border-color: var(--mut); }
input:user-invalid { border-color: var(--bad); }
.upper { text-transform: uppercase; }
textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 14px; resize: vertical; }

/* ---------- buttons ---------- */
button, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 6px; border: 1px solid transparent;
  background: var(--acc); color: var(--on-acc); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color var(--t), filter var(--t), transform var(--t);
}
button:hover:not(:disabled), a.btn:hover { filter: brightness(1.08); }
button:active:not(:disabled), a.btn:active { transform: translateY(1px); }
button.ghost, a.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
button.ghost:hover:not(:disabled), a.btn.ghost:hover { background: var(--hover); filter: none; }
button.ghost.on, button[aria-pressed=true] { background: var(--acc); color: var(--on-acc); border-color: var(--acc); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.danger:hover:not(:disabled) { background: rgba(248, 113, 113, .12); filter: none; }
button.armed { background: var(--bad); color: var(--on-acc); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
@media (pointer: coarse) { button, a.btn, input, select { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- play ---------- */
.stages { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0; }
.stage { position: relative; width: 400px; height: 300px; background: #fff; overflow: hidden; border: 1px solid var(--line); }
.stage iframe, .stage img { position: absolute; inset: 0; width: 400px; height: 300px; border: 0; background: #fff; display: block; max-width: none; }
.stage img { image-rendering: pixelated; }
@media (max-width: 460px) { .stage { zoom: .8; } }
@media (max-width: 370px) { .stage { zoom: .7; } }
.m-result img { display: none; }
.m-overlay img { opacity: var(--o, .5); }
.m-diff img { mix-blend-mode: difference; }
.lbl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 6px; color: var(--mut); font-size: 14px; }
.modes { display: inline-flex; gap: 4px; }
.modes button { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.lbl input[type=range] { width: 100px; }
.sw { display: flex; gap: 6px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.sw span { width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; }
.sw code { font-size: 13px; margin-right: 6px; }
#ed { height: 240px; }
.bar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; gap: 8px; }
.tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.timer { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.res { padding: 10px 12px; border-radius: 6px; background: var(--field); margin-top: 6px; border-left: 4px solid var(--line); }
.res.ok { border-left-color: var(--ok); }
.res.bad { border-left-color: var(--bad); color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 6px; text-align: left; border-bottom: 1px solid var(--divider); }
th { color: var(--mut); font-weight: 600; }
td small { color: var(--mut); display: block; font-size: 12px; white-space: nowrap; }
tr.me { background: #2a2a1a; }
td.n, th.n { text-align: right; }

/* ---------- misc ---------- */
details { background: var(--field); border: 1px solid var(--divider); border-radius: 6px; margin: 8px 0; padding: 8px 12px; }
summary { cursor: pointer; color: var(--mut); min-height: 28px; }
pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 13px; }
.thumb { width: 120px; height: 90px; border: 1px solid var(--line); background: #fff; display: block; }
.chs { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.banner { border-color: var(--acc); }
.item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--divider); flex-wrap: wrap; }
.item:last-child { border-bottom: 0; }
.tag { font-size: 12px; background: var(--acc); color: var(--on-acc); border-radius: 4px; padding: 0 6px; vertical-align: middle; font-weight: 700; white-space: nowrap; }
.tag-me { background: var(--fg); }
.live { margin-left: auto; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.live.on { color: var(--ok); }
.live.off { color: var(--acc); }

/* host: presets + monitor */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.pre { flex-direction: column; align-items: flex-start; padding: 8px; text-align: left; font-weight: 400; font-size: 13px; }
.pre span { display: block; margin-top: 4px; }
.pthumb { width: 120px; height: 90px; overflow: hidden; background: #fff; position: relative; flex: none; }
.pthumb iframe { width: 400px; height: 300px; border: 0; transform: scale(.3); transform-origin: 0 0; pointer-events: none; position: absolute; }
.mons { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mon { background: var(--field); border: 1px solid var(--divider); border-radius: 6px; padding: 8px; font-size: 13px; }
.mon .meta { margin-top: 4px; }
.mon details { padding: 4px 8px; margin: 6px 0 0; }
.mon pre { max-height: 160px; overflow: auto; font-size: 12px; }

/* projector board */
.board .big { font-size: 1.6rem; }
.board table { font-size: 20px; }
.board td small { font-size: 14px; }

/* ---- event extras: first 100%, diff, board live, podium, voting ---- */
.first-toast { position: fixed; left: 50%; top: 24px; transform: translateX(-50%); z-index: 1000; background: linear-gradient(135deg,#f59e0b,#ef4444); color: #fff; padding: 18px 32px; border-radius: 14px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.35); animation: ftIn .5s cubic-bezier(.2,1.6,.4,1); }
.first-toast.out { opacity: 0; transition: opacity .6s; }
.first-toast .ft-k { font-weight: 800; letter-spacing: .2em; font-size: 14px; }
.first-toast .ft-n { font-size: 34px; font-weight: 800; line-height: 1.2; }
.first-toast .ft-s { font-size: 14px; opacity: .9; }
@keyframes ftIn { from { transform: translateX(-50%) scale(.4); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.diff { margin-top: 8px; }
.diff img { display: block; max-width: 100%; height: auto; margin-top: 4px; border: 1px solid var(--line); }
.big-mons { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.board .big-mons .pthumb { width: 160px; height: 120px; }
.board .big-mons .pthumb iframe { transform: scale(.4); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; min-height: 260px; padding-top: 10px; }
.pod { width: 150px; text-align: center; opacity: 0; animation: podUp .8s ease-out forwards; }
.pod-m { font-size: 40px; } .pod-n { font-weight: 800; font-size: 20px; word-break: break-word; } .pod-s { opacity: .8; }
.pod-b { margin-top: 6px; border-radius: 8px 8px 0 0; color: #fff; font-size: 34px; font-weight: 800; display: grid; place-items: center; }
.p1 .pod-b { height: 150px; background: #f59e0b; } .p2 .pod-b { height: 110px; background: #94a3b8; } .p3 .pod-b { height: 80px; background: #b45309; }
@keyframes podUp { from { opacity: 0; transform: translateY(60px); } to { opacity: 1; transform: none; } }
.award { text-align: center; font-size: 18px; margin-top: 12px; }
.votes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.vote-box { background: var(--field); border-radius: 6px; padding: 10px 14px; }
.vote-row { gap: 10px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.vote-row label { min-width: 140px; }
@media (prefers-reduced-motion: reduce) { .pod, .first-toast { animation: none; opacity: 1; } }
