:root {
  --bg: #f4f2fb; --card: #fff; --ink: #1b1636; --muted: #6b6785; --brand: #5b3df5; --brand-d: #4429d1;
  --ok: #1f9d55; --bad: #d64545; --line: #e3dff3; --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14102b; --card: #1e1940; --ink: #f1eefc; --muted: #a29dc4; --line: #322b5e; --brand: #7c63ff; --brand-d: #6a50f0; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.15; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.narrow { max-width: 480px; }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: 0 2px 0 var(--line), 0 12px 30px -18px rgba(40, 20, 120, .35); }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.brand { font-weight: 800; letter-spacing: -.02em; font-size: 1.1rem; display: flex; gap: 8px; align-items: center; margin-bottom: 20px; }
.brand b { background: var(--brand); color: #fff; border-radius: 10px; padding: 2px 9px; }

label { display: block; font-weight: 700; font-size: .85rem; margin: 14px 0 6px; }
input[type=text], input[type=number], textarea, select {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: transparent; color: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); }
input.code { font-size: 2rem; text-align: center; letter-spacing: .3em; text-transform: uppercase; font-weight: 800; }

button, .btn { font: inherit; font-weight: 800; border: 0; border-radius: 12px; padding: 12px 20px; cursor: pointer; background: var(--brand); color: #fff; box-shadow: 0 4px 0 var(--brand-d); text-decoration: none; display: inline-block; text-align: center; }
button:active, .btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--brand-d); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, .btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--line); }
button.big { font-size: 1.25rem; padding: 16px 28px; }
button.block { width: 100%; margin-top: 16px; }
button.danger { background: var(--bad); box-shadow: 0 4px 0 #a52f2f; }

.err { color: var(--bad); font-weight: 600; font-size: .9rem; margin-top: 10px; white-space: pre-line; }
.ok { color: var(--ok); font-weight: 700; }
.tag { display: inline-block; font-size: .75rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--line); }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-top: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--brand); }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; cursor: pointer; }
.drop:hover { border-color: var(--brand); }
details { margin-top: 14px; } summary { cursor: pointer; font-weight: 700; }
pre { background: rgba(120, 100, 220, .1); padding: 12px; border-radius: 10px; overflow: auto; font-size: .8rem; }
.preview { max-height: 240px; overflow: auto; margin: 10px 0 0; padding-left: 20px; font-size: .9rem; }

/* Status pill */
.status { position: fixed; top: 10px; right: 10px; font-size: .75rem; font-weight: 800; padding: 4px 12px; border-radius: 99px; background: var(--bad); color: #fff; display: none; z-index: 9; }
.status.show { display: block; }

/* Answer options */
.opts { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .opts.two { grid-template-columns: 1fr 1fr; } }
.opt { display: flex; align-items: center; gap: 14px; background: var(--c); color: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.25); border-radius: 12px; padding: 18px 16px; font-size: 1.15rem; text-align: left; position: relative; overflow: hidden; }
.opt .shape { font-size: 1.5rem; width: 1.6rem; text-align: center; flex: none; }
.opt .label { flex: 1; font-weight: 800; }
.opt .n { font-weight: 800; font-size: 1.4rem; position: relative; }
.opt .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.25); transition: width .6s ease; }
.opt > * { position: relative; }
.opt.dim { opacity: .35; }
.opt.pick { outline: 4px solid var(--ink); }
.opt.right::after { content: "✓"; font-size: 1.6rem; font-weight: 900; }
.opt.static { cursor: default; }

/* Timer */
.timer { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.timer i { display: block; height: 100%; background: var(--brand); transition: width .1s linear; }
.timer.low i { background: var(--bad); }
.clock { font-size: 2.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }

/* Lobby chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 340px; overflow: auto; }
.chip { background: var(--line); border-radius: 99px; padding: 6px 14px; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.chip.off { opacity: .45; }
.chip button { all: unset; cursor: pointer; opacity: .5; font-size: 1.1rem; line-height: 1; } .chip button:hover { opacity: 1; }

/* Join screen on host */
.joinbox { display: grid; gap: 20px; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 760px) { .joinbox { grid-template-columns: 260px 1fr; } }
.qr { width: 100%; max-width: 260px; aspect-ratio: 1; background: #fff; padding: 10px; border-radius: 14px; margin: 0 auto; }
.qr svg { width: 100%; height: 100%; display: block; }
.bigcode { font-size: clamp(2.6rem, 9vw, 5rem); font-weight: 900; letter-spacing: .12em; line-height: 1; font-variant-numeric: tabular-nums; }

/* Leaderboard */
.lb { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lb li { display: grid; grid-template-columns: 2.2rem minmax(60px, 12rem) 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; font-weight: 800; }
.lb li.me { border-color: var(--brand); background: rgba(124, 99, 255, .12); }
.lb .rank { color: var(--muted); } .lb .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; } .lb .bar i { display: block; height: 100%; background: var(--brand); transition: width .8s ease; }
.lb .sc { font-variant-numeric: tabular-nums; }

/* Podium */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 20px 0 28px; }
.podium .step { flex: 1; max-width: 200px; text-align: center; }
.podium .block { border-radius: 14px 14px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; font-size: 2rem; font-weight: 900; color: #fff; }
.podium .p1 .block { height: 160px; background: #d89e00; } .podium .p2 .block { height: 120px; background: #8a94a6; } .podium .p3 .block { height: 90px; background: #b0693a; }
.podium .nm { font-weight: 900; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .podium .sc { color: var(--muted); font-weight: 700; margin-bottom: 6px; }

/* Player */
.pscreen { min-height: 100dvh; display: flex; flex-direction: column; padding: 16px; gap: 14px; max-width: 560px; margin: 0 auto; }
.pscreen .grow { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.pbar { display: flex; justify-content: space-between; font-weight: 800; font-size: .9rem; color: var(--muted); }
.pq { font-size: 1.3rem; font-weight: 800; text-align: center; margin: 6px 0; }
.result { font-size: 2.4rem; font-weight: 900; }
.result.good { color: var(--ok); } .result.bad { color: var(--bad); }
.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); } @keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* Host stage */
.stage-q { font-size: clamp(1.5rem, 4vw, 2.6rem); font-weight: 900; text-align: center; margin: 14px 0 20px; }
.hostbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }

.qlist { padding-left: 22px; margin: 12px 0; display: grid; gap: 8px; }
.qlist li::marker { font-weight: 800; color: var(--muted); }
.qlist li { padding-left: 4px; }
.qlist li { display: list-item; }
.qlist .qt { display: inline-block; width: calc(100% - 150px); vertical-align: middle; font-weight: 700; }
.qlist button { margin-left: 4px; }

button.mark { flex: none; background: transparent; color: var(--muted); border: 2px solid var(--line); box-shadow: none; padding: 8px 12px; font-size: .8rem; min-width: 118px; }
button.mark.on { background: var(--ok); border-color: var(--ok); color: #fff; }
