/* Participant app. Large targets (≥ 48 px), follows the phone's dark mode; the question page itself stays white (SPEC P6). */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --ink: #111827; --muted: #5b6474; --line: #d9dee7;
  --primary: #1e3a8a; --primary-ink: #ffffff; --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2; --grey-bg: #e5e7eb; --focus: #2563eb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c; --surface: #19202b; --ink: #e8ecf3; --muted: #9aa4b5; --line: #2c3544;
    --primary: #3b5cc4; --primary-ink: #ffffff; --ok: #4ade80; --ok-bg: #12351f; --warn: #fbbf24; --warn-bg: #3a2c0b;
    --bad: #f87171; --bad-bg: #3b1616; --grey-bg: #262e3b; --focus: #60a5fa;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 520px; margin: 0 auto; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }
.muted, .hint { color: var(--muted); font-size: .92rem; }
.btn { display: block; width: 100%; min-height: 48px; border: 0; border-radius: 10px; padding: 12px 16px; background: var(--primary); color: var(--primary-ink); font-weight: 600; cursor: pointer; }
.btn.secondary { background: var(--grey-bg); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn + .btn { margin-top: 10px; }
.link { background: none; border: 0; color: var(--focus); padding: 8px 0; cursor: pointer; text-decoration: underline; min-height: 44px; }
.field { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
label.lbl { display: block; font-weight: 600; margin: 12px 0 6px; }
.code-input { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .3em; text-align: center; text-transform: uppercase; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px; margin: 12px 0; }
.error b { font-family: ui-monospace, monospace; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 12px; margin: 12px 0; }
.ok-line { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 12px; margin: 12px 0; font-weight: 600; }
.helpline { font-size: .85rem; color: var(--muted); text-align: center; margin: 16px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.countdown { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Quiz screen */
.quiz { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .team { font-weight: 700; font-family: ui-monospace, monospace; }
.topbar .qno { color: var(--muted); }
.topbar .timer { margin-left: auto; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.amber { color: var(--warn); }
.timer.red { color: var(--bad); }
@media (prefers-reduced-motion: no-preference) { .timer.red { animation: pulse 1s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .55; } }
.strip { padding: 8px 12px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.question { background: #fff; padding: 0; }
.question img { display: block; width: 100%; height: auto; background: #fff; user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; pointer-events: none; }
.page-marker { position: sticky; top: 52px; z-index: 2; display: inline-block; margin: 6px; padding: 2px 8px; border-radius: 6px; background: rgba(17,24,39,.8); color: #fff; font-size: .8rem; }
.more-below { position: sticky; bottom: 0; text-align: center; padding: 6px; background: rgba(17,24,39,.85); color: #fff; font-size: .9rem; }
.watermark-note { font-size: .8rem; color: var(--muted); padding: 6px 12px; }
.panel { padding: 12px; background: var(--surface); border-top: 1px solid var(--line); }
.panel.submitted { background: var(--ok-bg); color: var(--ok); }
.panel.timeup { background: var(--grey-bg); color: var(--muted); }
.role { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--grey-bg); margin-bottom: 8px; }
.role.captain { background: var(--primary); color: var(--primary-ink); }
.statusbar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }
.statusbar .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--ok); }
.statusbar .dot.off { background: var(--bad); }
.center-screen { display: grid; place-items: center; min-height: 60dvh; text-align: center; padding: 24px; }
.big { font-size: 1.2rem; font-weight: 700; margin: 4px 0; }
.center-screen .big { font-size: 1.4rem; }

/* Answer controls */
.answer .choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 10px; }
.answer .choices.two { grid-template-columns: 1fr 1fr; }
.choice { min-height: 56px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 1.15rem; font-weight: 700; cursor: pointer; }
.choice.on { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.choice:disabled { cursor: not-allowed; opacity: .75; }
.answer .rows { display: grid; gap: 8px; }
.answer .row { display: grid; grid-template-columns: 2rem 1fr 1fr; gap: 8px; align-items: center; }
.answer-match .row { grid-template-columns: 2rem 1fr; }
.order-line { font-family: ui-monospace, monospace; font-size: 1.1rem; min-height: 1.5em; }
.confirm { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--warn-bg); color: var(--ink); }

@media (min-width: 900px) {
  .quiz-body { display: grid; grid-template-columns: minmax(0, 1fr) 380px; flex: 1; }
  .quiz-body .panel { border-top: 0; border-left: 1px solid var(--line); }
}

/* ---- Phase 2: installed app, device setup, lobby, quiz room ---- */
.btn.small { width: auto; min-height: 40px; padding: 8px 14px; display: inline-block; }
.lead { font-weight: 600; }
.fix { font-size: .9rem; margin-top: 6px; color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; }
.update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 60; background: var(--warn-bg); color: var(--warn); padding: 10px 16px; text-align: center; font-weight: 600; }
.progress { height: 8px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress .bar { height: 100%; background: var(--primary); }
.checks { list-style: none; padding: 0; margin: 8px 0; }
.checks li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.checks li.ok { color: var(--ok); }
.checks li.wait, .checks li.warn { color: var(--warn); }
.preview { width: 100%; max-height: 50dvh; background: #000; border-radius: 10px; transform: scaleX(-1); }
.frame-guide { position: relative; }
.guide-box { position: absolute; inset: 8% 15% 4% 15%; border: 3px dashed rgba(255,255,255,.85); border-radius: 40% 40% 12px 12px; pointer-events: none; }
.level { height: 16px; background: var(--grey-bg); border-radius: 8px; overflow: hidden; }
.level-fill { height: 100%; width: 0; background: var(--ok); transition: width .08s; }
.sentence { font-size: 1.1rem; font-weight: 600; }
.ticklist { display: grid; gap: 10px; }
.tick { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; }
.tick input { width: 24px; height: 24px; flex: none; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.row-btns .btn + .btn { margin-top: 0; }
.shots { display: flex; gap: 8px; margin: 8px 0; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-radius: 999px; padding: 2px 10px; font-weight: 600; }
.ok { color: var(--ok); }
.step-actions { margin-top: 12px; }

/* Top bar self view (P6): the camera sits in the bar, never over the question. */
.self-tile { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: #000; transform: scaleX(-1); flex: none; }
.qwrap { position: relative; min-width: 0; }
.question.hidden-q { visibility: hidden; }
.gate { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; gap: 8px; padding: 24px; text-align: center; background: var(--surface); }
.gate[hidden] { display: none; }
.upright { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--surface); text-align: center; padding: 24px; }
.upright[hidden] { display: none; }
.page { position: relative; overflow: hidden; }
.wm { position: absolute; inset: 0; pointer-events: none; display: grid; align-content: space-around; justify-items: center; }
.wm span { transform: rotate(-30deg); color: rgba(17, 24, 39, .07); font-weight: 700; font-size: clamp(12px, 3vw, 22px); white-space: nowrap; user-select: none; }
.question.zoomed img { width: 180%; max-width: none; }
.question.zoomed { overflow: auto; }
.statusbar .session { margin-left: auto; font-family: ui-monospace, monospace; }
.chat-btn { position: relative; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; margin-left: auto; }
.statusbar .session + .chat-btn { margin-left: 8px; }
.chat-btn .unread { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.chat-btn .unread[hidden] { display: none; }
.panel-wrap { position: relative; }
.chat-panel { padding: 12px; background: var(--surface); border-top: 1px solid var(--line); }
.chat-panel[hidden], .panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; }
.chat-list { max-height: 34dvh; overflow: auto; display: grid; gap: 6px; margin: 8px 0; }
.msg { max-width: 85%; padding: 6px 10px; border-radius: 10px; background: var(--grey-bg); }
.msg.mine { justify-self: end; background: var(--primary); color: var(--primary-ink); }
.msg .from { font-size: .75rem; opacity: .8; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.chat-form { display: flex; gap: 8px; }
.strip div + div { margin-top: 4px; }
/* The question area stays white for PDF pages only; lobby / waiting / messages follow the theme. */
.question .center-screen { background: var(--bg); color: var(--ink); margin: 0; min-height: 50dvh; }
.speaking { color: var(--ok); font-weight: 700; }
.speaking::before { content: "● "; }
