:root {
  --bg: #f6f7fb; --surface: #ffffff; --text: #15192b; --muted: #6b7280; --border: #e3e6ee;
  --primary: #4f46e5; --primary-dark: #4338ca; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --radius: 12px;
  --c1: #4f46e5; --c2: #0ea5e9; --c3: #10b981; --c4: #f59e0b; --c5: #ef4444; --c6: #8b5cf6; --c7: #ec4899; --c8: #14b8a6;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.narrow { max-width: 460px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: -0.02em; text-decoration: none; color: var(--text); font-size: 1.2rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f3f4f8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-lg { padding: 14px 20px; font-size: 1.1rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; background: #eef0f6; color: var(--muted); }
.badge-open { background: #dcfce7; color: #166534; }
.badge-closed { background: #fee2e2; color: #991b1b; }
.badge-draft { background: #eef0f6; color: #4b5563; }
.badge-screen { background: #e0e7ff; color: #3730a3; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }
.code-pill { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; background: #eef0f6; padding: 4px 10px; border-radius: 8px; letter-spacing: 0.08em; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.qlist { display: flex; flex-direction: column; gap: 8px; }
.qitem { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.qitem.active { border-color: var(--primary); box-shadow: 0 0 0 2px #e0e7ff; }
.qitem-main { flex: 1; min-width: 0; }
.qitem-prompt { font-weight: 600; overflow-wrap: anywhere; }
.qitem-side { display: flex; flex-direction: column; gap: 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
dialog { border: 0; border-radius: 14px; padding: 24px; max-width: 560px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #15192b; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.toast.error { background: var(--danger); }

/* ---------- results ---------- */
.result { display: flex; flex-direction: column; gap: 16px; }
.result-prompt { font-size: 1.4rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.result-meta { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1fr) 3fr auto; gap: 12px; align-items: center; }
.bar-label { font-weight: 600; overflow-wrap: anywhere; }
.bar-label.correct::before { content: "✓ "; color: var(--ok); }
.bar-track { height: 28px; background: #eef0f6; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; transition: width 0.4s ease; min-width: 2px; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.bar-row.correct .bar-fill { outline: 3px solid var(--ok); outline-offset: -3px; }
.bar-row.dim .bar-fill { opacity: 0.35; }
.c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); }
.c5 { background: var(--c5); } .c6 { background: var(--c6); } .c7 { background: var(--c7); } .c8 { background: var(--c8); }
.tc1 { color: var(--c1); } .tc2 { color: var(--c2); } .tc3 { color: var(--c3); } .tc4 { color: var(--c4); }
.tc5 { color: var(--c5); } .tc6 { color: var(--c6); } .tc7 { color: var(--c7); } .tc8 { color: var(--c8); }
.rating-avg { font-size: 3rem; font-weight: 800; line-height: 1; }
.rating-avg small { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.cloud { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: center; padding: 12px; line-height: 1.1; }
.cloud-word { font-weight: 700; }
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.entry { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow-wrap: anywhere; }
.entry-meta { color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
.ranked { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.ranked li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.rank-num { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; display: inline-grid; place-items: center; }
.pending { padding: 24px; text-align: center; color: var(--muted); font-size: 1.1rem; background: #fff; border: 1px dashed var(--border); border-radius: 10px; }
.verdict { padding: 12px 16px; border-radius: 10px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.verdict-match { background: #dcfce7; color: #166534; }
.verdict-differ { background: #fef3c7; color: #92400e; }
.verdict-none { background: #eef0f6; color: var(--muted); }
.teams-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.team-card { border: 2px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; }
.team-card.agree { border-color: var(--ok); }
.team-card.differ { border-color: var(--warn); }
.team-name { font-weight: 800; }
.team-top { font-size: 1.1rem; margin: 6px 0; overflow-wrap: anywhere; }
.team-count { color: var(--muted); font-size: 0.85rem; }
.mini-bars .bar-track { height: 10px; }
.mini-bars .bar-row { grid-template-columns: minmax(0, auto) 1fr auto; gap: 6px; font-size: 0.85rem; }
.mini-bars .bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; overflow-wrap: normal; }
.lb { display: grid; grid-template-columns: 1fr; gap: 20px; }
.lb.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .lb.two { grid-template-columns: 1fr; } }
.lb-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.lb-row.top-1 .rank-num { background: #f59e0b; }
.lb-row.top-2 .rank-num { background: #9ca3af; }
.lb-row.top-3 .rank-num { background: #b45309; }
.lb-points { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-sub { color: var(--muted); font-size: 0.8rem; }

/* ---------- big mode (present + results pages) ---------- */
.result--big .result-prompt { font-size: 2.4rem; }
.result--big .result-meta { font-size: 1.1rem; }
.result--big .bar-track { height: 44px; }
.result--big .bar-label, .result--big .bar-value { font-size: 1.4rem; }
.result--big .rating-avg { font-size: 5rem; }
.result--big .entry { font-size: 1.25rem; }
.result--big .ranked li { font-size: 1.4rem; }
.result--big .verdict { font-size: 1.3rem; }
.result--big .team-name { font-size: 1.2rem; }
.result--big .team-top { font-size: 1.5rem; }
.result--big .lb-row { font-size: 1.3rem; padding: 14px 16px; }
.result--big .pending { font-size: 1.6rem; padding: 40px; }
.result--big .mini-bars .bar-track { height: 10px; }
.result--big .mini-bars .bar-row { font-size: 0.85rem; }
.result--big .mini-bars .bar-label { font-size: 0.85rem; }

/* ---------- present layout ---------- */
.present { display: grid; grid-template-columns: 1fr 280px; min-height: 100vh; }
.present-main { padding: 40px; display: flex; flex-direction: column; justify-content: center; }
.present-side { background: var(--surface); border-left: 1px solid var(--border); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.present-side img { width: 100%; max-width: 230px; }
.present-join { font-weight: 700; overflow-wrap: anywhere; }
.present-code { font-size: 1.6rem; }
@media (max-width: 800px) { .present { grid-template-columns: 1fr; } .present-side { border-left: 0; border-top: 1px solid var(--border); } }
.splash { text-align: center; }
.splash h1 { font-size: 3rem; margin: 0 0 12px; }
.splash .present-join { font-size: 2rem; }

/* ---------- results page ---------- */
.results-page { padding: 32px; min-height: 100vh; display: flex; flex-direction: column; }
.results-page .result { flex: 1; justify-content: center; }
.results-foot { color: var(--muted); font-size: 0.85rem; margin-top: 16px; text-align: right; }

/* ---------- participant ---------- */
.choice { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border: 2px solid var(--border); border-radius: 12px; background: #fff; font: inherit; font-size: 1.05rem; cursor: pointer; }
.choice.selected { border-color: var(--primary); background: #eef2ff; }
.choice.correct { border-color: var(--ok); background: #dcfce7; }
.choice.wrong { border-color: var(--danger); background: #fee2e2; }
.rating-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.rating-buttons .btn { min-width: 48px; font-size: 1.2rem; }
.rating-buttons .btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.rank-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rank-list li { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.rank-list li .rank-text { flex: 1; }
.timer { font-size: 2rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--danger); }
.qa-item { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; align-items: flex-start; }
.qa-text { flex: 1; overflow-wrap: anywhere; }
.qa-vote { min-width: 56px; }
.qa-vote.voted { background: var(--primary); color: #fff; border-color: var(--primary); }
.score-card { text-align: center; padding: 20px; }
.score-card .big { font-size: 2.4rem; font-weight: 800; }
