:root {
  --bg: #f5f7f4;
  --card: #ffffff;
  --ink: #17231f;
  --muted: #5d6b66;
  --line: #dde4e0;
  --accent: #1f8a70;
  --accent-ink: #ffffff;
  --soft: #e7f3ef;
  --warn: #c77700;
  --over: #c8323b;
  --track: #e3ebe7;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 24px rgb(0 0 0 / .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1614; --card: #17211e; --ink: #e8efec; --muted: #9db0a9; --line: #2a3733;
    --accent: #3cc59f; --accent-ink: #062018; --soft: #1d302a; --warn: #f2a541; --over: #ff6b6b; --track: #26332f;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* header / layout */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.brand__logo { width: 32px; height: 32px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; }
@media (min-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr) 300px; } }
main:focus { outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 3vw, 28px); box-shadow: var(--shadow); max-width: 720px; margin: 0 auto; }
.lede { color: var(--muted); margin: 0 0 1.25rem; }

/* buttons */
.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: .55rem .95rem; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: transparent; }
.btn--big { font-size: 1.15rem; padding: .85rem 1.6rem; min-height: 56px; }
.btn--sm { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; }
#startBtn { width: 100%; margin-top: .5rem; }

/* fields */
.field { display: block; border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
.field__label { display: block; font-weight: 600; margin-bottom: .35rem; padding: 0; }
input[type=text] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .75rem; width: 100%; min-height: 44px; }
input[type=text]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.hint { color: var(--muted); font-size: .88rem; margin: .35rem 0 0; }
.error { color: var(--over); font-weight: 600; min-height: 1.5em; margin: 0; }

.names { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 360px; overflow-y: auto; counter-reset: n; }
.names li { display: flex; align-items: center; gap: 6px; counter-increment: n; }
.names li::before { content: counter(n); width: 1.6em; text-align: right; color: var(--muted); font-size: .85rem; flex: none; }
.del { flex: none; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.del:hover { background: var(--soft); color: var(--over); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; width: max-content; max-width: 100%; }
.step { font: inherit; font-size: 1.3rem; width: 44px; height: 44px; border: 0; background: var(--soft); color: var(--ink); cursor: pointer; }
.stepper output { min-width: 5.5ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; padding: 0 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: inline-block; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; min-height: 40px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.toggles { display: grid; gap: 8px; margin-bottom: 1rem; }
.toggle { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

/* run */
.run { max-width: 1000px; margin: 0 auto; }
.run-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.meta strong { color: var(--ink); }
#targetInfo.bad { color: var(--warn); font-weight: 600; }
.run-tools { display: flex; gap: 6px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0 16px; }
.ring { position: relative; width: min(78vw, 340px); aspect-ratio: 1; --c: var(--accent); }
.ring[data-phase=warn] { --c: var(--warn); }
.ring[data-phase=over] { --c: var(--over); }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring__track { stroke: var(--track); }
.ring__bar { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .4s; }
.ring__inner { position: absolute; inset: 14%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; }
.speaker { font-size: clamp(1.3rem, 5vw, 2.1rem); font-weight: 800; max-width: 100%; overflow-wrap: anywhere; line-height: 1.15; }
.countdown { font-size: clamp(2.4rem, 11vw, 4.2rem); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--c); line-height: 1.1; }
.prompt { color: var(--muted); font-size: .9rem; }
.paused-tag { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; background: var(--soft); padding: 2px 10px; border-radius: 999px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.keys { font-size: .85rem; margin: 0; }

.rails { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .rails { grid-template-columns: 1fr 1fr 1.3fr; } }
.rail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.rail h2 { font-size: 1rem; }
.queue { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.queue .empty { color: var(--muted); font-size: .9rem; }
.pick { font: inherit; width: 100%; text-align: left; padding: .45rem .6rem; border-radius: 8px; border: 1px solid transparent; background: var(--soft); color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.pick:hover { border-color: var(--accent); }
.pick small { color: var(--muted); }
.is-baton .pick { border-color: var(--accent); font-weight: 600; }
.queue--done li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: .3rem .2rem; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.queue--done .t { font-variant-numeric: tabular-nums; color: var(--muted); flex: none; }
.queue--done li.over .t { color: var(--over); font-weight: 600; }
.queue--done li.skipped > span:first-child { color: var(--muted); text-decoration: line-through; }
.inline-add { display: flex; gap: 6px; }
.inline-add input { min-height: 36px; padding: .35rem .6rem; }
.parking { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
.parking li { display: flex; justify-content: space-between; gap: 6px; align-items: center; background: var(--soft); border-radius: 8px; padding: .3rem .3rem .3rem .6rem; overflow-wrap: anywhere; }
.parking small { color: var(--muted); }
.parking .del { width: 30px; height: 30px; }

/* summary */
.sum-stats { color: var(--muted); }
.sum-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-variant-numeric: tabular-nums; }
.sum-table th, .sum-table td { text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sum-table td:last-child, .sum-table th:last-child { text-align: right; }
.sum-table tr.over td:last-child { color: var(--over); font-weight: 600; }
.sum-table tr.skipped td { color: var(--muted); }
#summary .parking li { padding: .4rem .6rem; }
.sum-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 20; margin: 0; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ads (reserved size, no layout shift) */
.ad-slot { display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in srgb, var(--line) 50%, transparent) 10px 20px); border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 auto; }
.ad-slot--rect { width: 300px; height: 250px; }
.ad-slot--wide { width: 100%; max-width: 728px; height: 90px; margin: 24px auto; }
.side { display: flex; justify-content: center; align-items: flex-start; }
@media (min-width: 1000px) { .side .ad-slot { position: sticky; top: 16px; } }
body[data-screen=run] .side { display: none; }
body[data-screen=run] .layout { grid-template-columns: minmax(0, 1fr); }

/* seo + footer */
.seo { max-width: 760px; margin: 24px auto; padding: 0 16px; }
.seo h2 { margin-top: 1.6rem; font-size: 1.3rem; }
.seo details { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.seo summary { cursor: pointer; font-weight: 600; }
.site-footer { text-align: center; padding: 24px 16px 40px; border-top: 1px solid var(--line); font-size: .92rem; }

/* embed mode */
.embed-only { display: none; }
body.embed .chrome { display: none !important; }
body.embed .embed-only { display: block; }
body.embed .layout { padding-top: 12px; }
body.embed:not(.edit-open) .setup-body { display: none; }
body.embed #editTeamBtn { margin: 8px auto 0; }
body.embed .made-with { text-align: center; font-size: .85rem; margin-top: 10px; }
.embed-team { text-align: center; font-weight: 600; margin: 0 0 8px; }

/* presentation mode: big, high contrast, no chrome or ads */
body.presenting .chrome { display: none !important; }
body.presenting { --line: #3a4a44; }
body.presenting .ring { width: min(70vh, 86vw, 560px); }
body.presenting .speaker { font-size: clamp(2rem, 6vw, 3.6rem); }
body.presenting .countdown { font-size: clamp(3rem, 12vw, 7rem); }
body.presenting .layout { max-width: none; }

@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
  .controls .btn--big { flex: 1 1 100%; order: -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
