/* Shout Timer — phone-first, readable from 3 m during a round. */
:root {
  --bg: #111; --fg: #f4f4f4; --muted: #9a9a9a; --accent: #ffd166; --line: #333;
  --set-bg: #111; --set-fg: #f4f4f4;          /* working: light on dark */
  --rest-bg: #f2efe6; --rest-fg: #111;        /* waiting: dark on light */
  --danger: #e04b4b; --ok: #46b36b;
  --tap: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
/* pull-to-refresh stays available on the sub-pages; only a running round blocks it */
body[data-view="run"] { overscroll-behavior: none; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button { font: inherit; color: inherit; background: none; border: 0; }
h1 { font-size: 22px; font-weight: 600; margin: 8px 0 16px; }
h2 { font-size: 20px; font-weight: 600; margin: 4px 0 12px; }
.muted { color: var(--muted); }
output { font-variant-numeric: tabular-nums; }

/* views */
.view { display: none; padding: 16px; max-width: 520px; margin: 0 auto; }
body[data-view="setup"] #view-setup, body[data-view="mic"] #view-mic, body[data-view="record"] #view-record { display: block; }
body[data-view="run"] #view-run { display: block; padding: 0; max-width: none; }

/* setup */
.field { margin: 0 0 22px; }
.label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stepper { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; gap: 8px; }
.stepper output { font-size: 44px; text-align: center; font-weight: 600; }
.step { height: var(--tap); border: 1px solid var(--line); border-radius: 12px; font-size: 30px; }
.chips { display: flex; gap: 8px; margin-top: 10px; }
.chips.wrap { flex-wrap: wrap; }
.chips.wrap .chip { flex: 0 1 auto; padding: 0 14px; }
.chip { flex: 1; height: 44px; border: 1px solid var(--line); border-radius: 22px; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--fg); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segbtn { flex: 1; height: 48px; color: var(--muted); }
.segbtn[aria-checked="true"] { background: #2a2a2a; color: var(--fg); }
.segbtn:disabled { opacity: .4; }
.primary { display: block; width: 100%; height: 72px; border-radius: 16px; background: var(--accent); color: #111;
  font-size: 26px; font-weight: 700; margin: 8px 0 22px; }
.status { width: 100%; border-collapse: collapse; font-size: 15px; }
.status th { text-align: left; color: var(--muted); font-weight: 500; padding: 7px 0; width: 38%; }
.status td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.status tr:last-child td { border-bottom: 0; }
.links { display: flex; gap: 18px; margin-top: 20px; flex-wrap: wrap; }
.link { color: var(--accent); text-decoration: underline; padding: 8px 0; }

/* running view — fixed, never scrolls */
.live { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto auto auto auto auto auto; gap: 6px;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); overflow: hidden; touch-action: none; user-select: none; }
body[data-phase="set"] .live { background: var(--set-bg); color: var(--set-fg); }
body[data-phase="rest"] .live, body[data-phase="ready"] .live { background: var(--rest-bg); color: var(--rest-fg); }
.phase-label { font-size: 44px; font-weight: 700; letter-spacing: .04em; text-align: center; }
.big { font-size: min(42vw, 44vh); line-height: 1; font-weight: 700; text-align: center; align-self: center;
  font-variant-numeric: tabular-nums; }
.drain { height: 22px; border-radius: 11px; background: rgba(0,0,0,.12); overflow: hidden; visibility: hidden; }
body[data-phase="rest"] .drain, body[data-phase="ready"] .drain { visibility: visible; }
.drain-fill { height: 100%; width: 100%; background: currentColor; opacity: .75; }
.row2 { display: flex; justify-content: space-between; align-items: baseline; }
.position { font-size: 84px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.last { font-size: 60px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; opacity: .85; }
.strip { display: flex; gap: 4px; height: 44px; align-items: flex-end; }
.strip .blk { flex: 1; min-height: 10px; border: 2px solid currentColor; border-radius: 4px; opacity: .55; }
.strip .blk.done { background: currentColor; opacity: .9; }
.strip .blk.cur { opacity: 1; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.band { height: 40px; border-radius: 8px; background: rgba(127,127,127,.18); position: relative; overflow: hidden; }
.band-fill { height: 100%; width: 0; background: var(--ok); transition: width 40ms linear; }
.band.nomatch .band-fill { background: var(--danger); }
.band-gate { position: absolute; top: 0; bottom: 0; width: 3px; background: currentColor; left: 60%; }
.big-band { height: 60px; margin: 16px 0 8px; }
.hint { text-align: center; font-size: 15px; opacity: .6; }
.undo { height: 72px; border-radius: 16px; background: var(--danger); color: #fff; font-size: 24px; font-weight: 700; }
.resume-audio { height: 72px; border-radius: 16px; background: var(--accent); color: #111; font-size: 24px; font-weight: 700; }
.end { height: 44px; font-size: 15px; opacity: .55; border-radius: 22px; border: 1px solid currentColor; position: relative; overflow: hidden; }
.end .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: currentColor; opacity: .25; }

/* [hidden] must beat the display rules above */
[hidden] { display: none !important; }

/* done state */
.done { padding: 16px; max-width: 520px; margin: 0 auto; }
.history { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.history th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.history td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.history td.re::after { content: " ↺"; color: var(--accent); }
.totals { display: flex; justify-content: space-between; font-size: 22px; font-weight: 600; margin: 14px 0 6px; }
.done-counts { color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 18px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.actions .primary { width: auto; flex: 1; margin: 0; height: 60px; }
.event-log { font: 12px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: var(--muted); max-height: 40vh; overflow: auto; }

@media (prefers-color-scheme: light) {
  :root { --bg: #fafafa; --fg: #111; --muted: #666; --line: #ddd; }
  .segbtn[aria-checked="true"] { background: #e8e8e8; }
}

/* record / test view */
.takes { margin: 10px 0; }
.take { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.take span { flex: 1; }
.marks { display: flex; gap: 8px; margin: 10px 0; min-height: 34px; }
.mark { padding: 6px 10px; border-radius: 8px; font-variant-numeric: tabular-nums; font-weight: 600; border: 1px solid var(--line); }
.mark.ok { border-color: var(--ok); color: var(--ok); }
.mark.no { border-color: var(--danger); color: var(--danger); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.stepper output.small { font-size: 20px; }

.build-footer { position: fixed; right: 10px; bottom: 6px; font-size: 11px; color: var(--muted); opacity: .8; pointer-events: none; }
body[data-view="run"] .build-footer { display: none; }
.summary { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.primary.stage { height: 60px; font-size: 22px; margin: 6px 0 10px; }
.trials div { padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* ── your-word page: one flow, real buttons ── */
.stage { margin: 0 0 26px; }
.stage h2 { margin: 0 0 8px; }
.btn { display: block; width: 100%; height: 56px; border-radius: 14px; border: 2px solid var(--line); font-size: 18px; font-weight: 600; margin: 8px 0; color: var(--fg); background: transparent; }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.btn.ghost { border-color: transparent; color: var(--muted); height: 44px; font-weight: 500; }
.btn:disabled { opacity: .4; }
.banner { position: sticky; top: 0; z-index: 5; background: var(--accent); color: #111; border-radius: 14px; padding: 14px 16px; margin: 0 0 14px; text-align: center; }
.banner-text { font-size: 26px; font-weight: 800; line-height: 1.15; }
.banner-sub { font-size: 15px; margin-top: 4px; opacity: .85; }
.banner .btn.ghost { color: #111; margin: 6px 0 0; }
.list { margin: 6px 0 4px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item-main { flex: 1; min-width: 0; }
.item-actions { display: flex; gap: 6px; }
.mini { font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.small { font-size: 13px; }
.slider { display: grid; grid-template-columns: 1fr 64px; gap: 12px; align-items: center; }
.slider output { font-size: 20px; text-align: right; }
