:root {
  --bg: #0b1020; --surface: #151c31; --surface-2: #1e2742; --line: #2c3657;
  --text: #f4f6fb; --muted: #a3adc4; --accent: #7c9cff;
  --real: #3b82f6; --real-bg: #12305e; --ai: #f59e0b; --ai-bg: #5a3a07;
  --ok: #22c55e; --ok-bg: #0f3d22; --ng: #ef4444; --ng-bg: #4a1414;
  --radius: 16px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.badge { display: inline-flex; align-items: center; gap: .4em; padding: .2em .7em; border-radius: 999px; background: var(--surface-2); font-weight: 700; }
.choice-real { --c: var(--real); --cbg: var(--real-bg); }
.choice-ai { --c: var(--ai); --cbg: var(--ai-bg); }
.banner { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); background: var(--ng-bg); color: #fff; border: 1px solid var(--ng);
  padding: 6px 14px; border-radius: 999px; font-size: 14px; z-index: 50; }

/* ---------------- participant (phone first) ---------------- */
.p-wrap { max-width: 520px; margin: 0 auto; padding: 20px 16px 40px; min-height: 100svh; display: flex; flex-direction: column; gap: 16px; }
.p-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.p-title { font-size: 26px; font-weight: 800; margin: 8px 0 0; letter-spacing: .02em; }
.p-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.p-qno { font-size: 20px; font-weight: 800; }
.p-input { width: 100%; font-size: 18px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.btn-primary { width: 100%; font-size: 20px; font-weight: 800; padding: 16px; border-radius: 14px; border: 0; background: var(--accent); color: #0b1020; }
.vote-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.vote-btn { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 96px; font-size: 30px; font-weight: 900;
  border-radius: 18px; border: 3px solid var(--line); background: var(--surface); color: var(--text); transition: transform .08s; }
.vote-btn:active { transform: scale(.98); }
.vote-btn .ico { font-size: 34px; }
.vote-btn.selected { border-color: var(--c); background: var(--cbg); }
.vote-btn.selected::after { content: "✓ 選択中"; font-size: 15px; font-weight: 700; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--c); color: #0b1020; }
.vote-btn:disabled { opacity: .55; cursor: default; }
.vote-btn.selected:disabled { opacity: 1; }
.p-status { text-align: center; font-weight: 700; font-size: 17px; }
.p-result { text-align: center; font-size: 34px; font-weight: 900; padding: 10px; border-radius: 14px; }
.p-result.ok { background: var(--ok-bg); border: 2px solid var(--ok); }
.p-result.ng { background: var(--ng-bg); border: 2px solid var(--ng); }
.p-result.miss { background: var(--surface-2); border: 2px dashed var(--muted); }
.p-score { text-align: center; font-size: 18px; }
.p-score b { font-size: 40px; }
.p-final-score { text-align: center; font-size: 64px; font-weight: 900; line-height: 1.1; }
.p-pass { text-align: center; font-size: 36px; font-weight: 900; padding: 10px; border-radius: 14px; }
.p-pass.ok { background: var(--ok-bg); border: 2px solid var(--ok); }
.p-pass.ng { background: var(--ng-bg); border: 2px solid var(--ng); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.small { font-size: 13px; }
.expl { font-size: 16px; }
.src { font-size: 13px; color: var(--muted); word-break: break-all; }

/* ---------------- screen (16:9 projector) ---------------- */
.s-root { width: 100vw; height: 100vh; overflow: hidden; display: flex; flex-direction: column; padding: 2.2vh 2.6vw; gap: 1.6vh; }
.s-top { display: flex; align-items: center; justify-content: space-between; font-size: 3.4vh; font-weight: 800; min-height: 6vh; }
.s-top .right { display: flex; gap: 2vw; align-items: center; }
.s-main { flex: 1; min-height: 0; display: flex; gap: 2vw; }
.s-video { flex: 1; min-width: 0; background: #000; border-radius: 1.6vh; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
.s-video video, .s-video iframe { width: 100%; height: 100%; object-fit: contain; border: 0; background: #000; }
.s-video .placeholder { color: var(--muted); font-size: 3vh; text-align: center; padding: 2vh; }
.s-side { width: 30vw; display: flex; flex-direction: column; gap: 1.6vh; }
.s-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 1.6vh; padding: 2vh 1.6vw; }
.s-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 2.2vh; color: var(--muted); min-height: 3vh; }
.s-lobby { flex: 1; display: grid; grid-template-columns: 1.25fr 1fr; gap: 4vw; align-items: center; }
.s-hero h1 { font-size: 10vh; line-height: 1.1; margin: 0; letter-spacing: .02em; }
.s-hero h2 { font-size: 4.4vh; margin: 2vh 0 0; color: var(--muted); font-weight: 700; }
.s-qr { background: #fff; border-radius: 2vh; padding: 2vh; width: min(60vh, 34vw); aspect-ratio: 1; margin-left: auto; }
.s-qr svg { width: 100%; height: 100%; display: block; }
.s-join { font-size: 3vh; margin-top: 2vh; word-break: break-all; }
.s-big-count { font-size: 5vh; font-weight: 900; margin-top: 3vh; }
.s-qno { font-size: 4.6vh; font-weight: 900; }
.s-voted { font-size: 3.2vh; }
.s-timer { font-size: 6vh; font-weight: 900; font-variant-numeric: tabular-nums; }
.s-timer.warn { color: var(--ng); }
.tally { display: flex; flex-direction: column; gap: 1.2vh; }
.tally-row { display: grid; grid-template-columns: 9vw 1fr 6vw; align-items: center; gap: 1vw; font-size: 3vh; font-weight: 800; }
.tally-bar { height: 4.2vh; background: var(--surface-2); border-radius: 1vh; overflow: hidden; }
.tally-bar > i { display: block; height: 100%; background: var(--c); border-radius: 1vh; transition: width .4s; }
.tally-row.correct { outline: .4vh solid var(--ok); outline-offset: .6vh; border-radius: 1vh; }
.s-answer { font-size: 7.5vh; font-weight: 900; text-align: center; padding: 1.6vh; border-radius: 1.6vh; background: var(--cbg); border: .5vh solid var(--c); }
.s-expl { font-size: 2.7vh; line-height: 1.55; }
.s-src { font-size: 1.9vh; color: var(--muted); word-break: break-all; }
.s-locked { position: absolute; top: 2vh; right: 2vh; background: var(--ng-bg); border: .3vh solid var(--ng); padding: .6vh 1.6vw; border-radius: 99px; font-size: 3vh; font-weight: 900; }
.s-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 2.5vh 2vw 2vh; background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.s-year { font-size: 8vh; font-weight: 900; line-height: 1; }
.s-cap-title { font-size: 3.4vh; font-weight: 800; }
.s-cap-meta { font-size: 2.1vh; color: #d6dbea; word-break: break-all; }
.s-summary { flex: 1; display: grid; grid-template-columns: 1fr 1.3fr; gap: 3vw; align-items: stretch; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 2vh; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 1.6vh; padding: 2.4vh 1.6vw; }
.kpi .v { font-size: 9vh; font-weight: 900; line-height: 1; }
.kpi .l { font-size: 2.6vh; color: var(--muted); margin-top: 1vh; }
.dist { display: flex; align-items: flex-end; gap: .8vw; height: 32vh; padding-top: 4vh; }
.dist .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .6vh; }
.dist .bar { width: 100%; background: var(--accent); border-radius: .8vh .8vh 0 0; min-height: 2px; }
.dist .bar.fail { background: #5b6b96; }
.dist .lab { font-size: 1.8vh; color: var(--muted); }
.dist .cnt { font-size: 2.2vh; font-weight: 800; }
.s-closing { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 5vh; }
.s-closing p { font-size: 5.4vh; font-weight: 800; line-height: 1.6; max-width: 80vw; margin: 0; }
.s-activate { position: fixed; inset: 0; background: rgba(11,16,32,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; z-index: 100; font-size: 3.2vh; cursor: pointer; text-align: center; }
.s-activate b { font-size: 6vh; }

/* ---------------- host console ---------------- */
.h-wrap { max-width: 1100px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.h-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.h-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.h-card h3 { margin: 0 0 10px; font-size: 16px; }
.hbtn { font-size: 16px; font-weight: 800; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.hbtn.main { background: var(--accent); color: #0b1020; border-color: var(--accent); font-size: 20px; padding: 16px 22px; }
.hbtn.danger { border-color: var(--ng); color: #ffb4b4; }
.hbtn:disabled { opacity: .4; cursor: default; }
.h-phase { font-size: 22px; font-weight: 900; }
.h-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
table.h-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.h-table th, .h-table td { border-bottom: 1px solid var(--line); padding: 6px 6px; text-align: left; vertical-align: top; }
.h-table tr.current { background: var(--surface-2); }
.h-input { font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 90px; }
.h-qr { width: 150px; background: #fff; padding: 8px; border-radius: 10px; }
.h-qr svg { width: 100%; height: auto; display: block; }
.tag-real { color: #9cc3ff; font-weight: 800; } .tag-ai { color: #ffd08a; font-weight: 800; }
.warn-text { color: #ffb4b4; }
@media (max-width: 640px) { .hbtn.main { width: 100%; } }
