:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef2f5; --text: #15212b; --muted: #5b6b78;
  --line: #d9e0e6; --brand: #0f5c6e; --brand-2: #138a8a; --brand-ink: #ffffff;
  --ok: #1d7a46; --ok-bg: #e3f4ea; --bad: #b3261e; --bad-bg: #fbe7e5; --warn: #9a5b00; --warn-bg: #fff3dc;
  --easy: #2f7d5b; --moderate: #b07a12; --distinguished: #7a3e9d;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,32,48,.06), 0 6px 24px rgba(16,32,48,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1418; --surface: #162026; --surface-2: #1d2a31; --text: #e6edf1; --muted: #93a4b0;
    --line: #2a3a43; --brand: #3fb3c4; --brand-2: #4fc7b8; --brand-ink: #062027;
    --ok: #5fd08f; --ok-bg: #143323; --bad: #ff8a80; --bad-bg: #3a1a18; --warn: #f2b74d; --warn-bg: #3a2b10;
    --easy: #6fd3a5; --moderate: #f0c05a; --distinguished: #c99ae6;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 64px; }
.wide { max-width: 1180px; }
header.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: var(--brand-ink); font-weight: 800; flex: none; }
header.top h1 { font-size: 17px; margin: 0; line-height: 1.25; }
header.top p { margin: 0; color: var(--muted); font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; }
input, select { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
input:focus, select:focus, button:focus-visible, .opt:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px; border-color: var(--brand); }
button { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 18px; cursor: pointer; background: var(--brand); color: var(--brand-ink); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #fff; }
button.block { width: 100%; padding: 14px; font-size: 17px; margin-top: 20px; }
.err { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 10px; margin-top: 14px; font-size: 14px; }
.err:empty { display: none; }
.rules { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.rules b { display: block; }
.rules .ic { font-size: 20px; line-height: 1.2; }

/* test screen */
.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 12px; }
.bar-row { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; }
.timer { font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.timer.low { background: var(--warn-bg); color: var(--warn); }
.timer.crit { background: var(--bad-bg); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .35s ease; }
.stem { font-size: 19px; font-weight: 600; line-height: 1.45; margin: 4px 0 14px; }
.statements { margin: 0 0 14px; padding-left: 22px; color: var(--text); }
.statements li { margin: 4px 0; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: var(--surface); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 14px; font-weight: 500; }
.opt .k { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 14px; }
.opt[aria-checked="true"] { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.opt[aria-checked="true"] .k { background: var(--brand); color: var(--brand-ink); }
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* result */
.result { text-align: center; }
.ring { width: 190px; height: 190px; margin: 8px auto 12px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring .num small { font-size: 18px; color: var(--muted); font-weight: 600; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.lvl { background: var(--surface-2); border-radius: 12px; padding: 12px 8px; }
.lvl b { display: block; font-size: 22px; }
.lvl span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lvl.easy b { color: var(--easy); } .lvl.moderate b { color: var(--moderate); } .lvl.distinguished b { color: var(--distinguished); }
.review-item { text-align: left; border-top: 1px solid var(--line); padding: 14px 0; }
.review-item .o { padding: 6px 10px; border-radius: 8px; margin: 4px 0; font-size: 15px; }
.o.right { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.o.wrong { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; }

/* admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; cursor: pointer; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.easy { color: var(--easy); } .pill.moderate { color: var(--moderate); } .pill.distinguished { color: var(--distinguished); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: none; }
.grow { flex: 1 1 200px !important; }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
.toggle input { width: auto; }
.qr { display: grid; place-items: center; text-align: center; }
.qr img { width: min(360px, 80vw); height: auto; background: #fff; padding: 12px; border-radius: 12px; }
.join-url { font-size: clamp(18px, 3vw, 30px); font-weight: 700; word-break: break-all; margin: 12px 0 4px; }
.bigcount { font-size: clamp(48px, 10vw, 96px); font-weight: 800; line-height: 1; color: var(--brand); }
.hbar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.hbar > i { display: block; height: 100%; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(860px, calc(100vw - 32px)); max-height: 88vh; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .dhead { position: sticky; top: 0; background: var(--surface); padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
dialog .dbody { padding: 8px 20px 20px; }
.hidden { display: none !important; }
@media (max-width: 520px) { .card { padding: 18px; } .stem { font-size: 17px; } }
