:root {
  --bg: #0d0f1a;
  --bg2: #151829;
  --card: #1b1f35;
  --line: #2a2f4d;
  --text: #eef0ff;
  --muted: #8d93b8;
  --accent: #ffcc33;
  --accent2: #7c5cff;
  --good: #2fd47a;
  --bad: #ff5470;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #2a1f66 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #3b1240 0%, transparent 55%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 96px;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: #1a1300; font-size: 18px; box-shadow: 0 6px 20px #ffcc3340;
}
.brand-name { font-size: 20px; }
.top-right { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line); font-size: 14px; color: var(--muted);
}
.pill-btn:hover { color: var(--text); border-color: var(--accent2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 #2fd47a80; animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px #2fd47a00; } 100% { box-shadow: 0 0 0 0 #2fd47a00; } }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px;
  max-width: 1180px; margin: 0 auto; padding: 8px 24px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.stage {
  background: linear-gradient(180deg, #1d2140, #161a30);
  border: 1px solid var(--line); border-radius: 24px; padding: 28px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  box-shadow: 0 20px 60px #0008;
}
.round-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.round-n { font-weight: 800; color: var(--accent); margin-right: 4px; }
.chip { padding: 4px 10px; border-radius: 999px; background: #ffffff10; color: var(--muted); font-size: 13px; }
.chip:empty { display: none; }
.chip-diff[data-d="easy"] { color: var(--good); }
.chip-diff[data-d="medium"] { color: var(--accent); }
.chip-diff[data-d="hard"] { color: var(--bad); }

.timer-wrap { position: relative; width: 120px; height: 120px; margin: 18px 0 8px; }
.timer { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 10; }
.timer-track { stroke: #ffffff12; }
.timer-bar {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .3s;
}
.timer-wrap.low .timer-bar { stroke: var(--bad); }
.timer-wrap.reveal .timer-bar { stroke: var(--accent2); }
.timer-num { position: absolute; inset: 0; display: grid; place-content: center; line-height: 1; }
#timer-num { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; }
#timer-label { color: var(--muted); font-size: 12px; margin-top: 4px; }

.question { font-size: clamp(22px, 3vw, 32px); line-height: 1.25; margin: 12px 0 22px; max-width: 760px; text-wrap: balance; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 760px; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } }
.choice {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 16px 18px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--line);
  font-size: 17px; font-weight: 600; min-height: 64px; transition: transform .08s, border-color .15s, background .15s;
}
.choice:hover:not(:disabled) { border-color: var(--accent2); transform: translateY(-2px); }
.choice:active:not(:disabled) { transform: translateY(0); }
.choice:disabled { cursor: default; }
.choice .key {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: #ffffff12; font-size: 14px; font-weight: 800; color: var(--muted);
}
.choice .label { position: relative; z-index: 1; flex: 1; }
.choice .count { position: relative; z-index: 1; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.choice .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: #ffffff0d; transition: width .6s ease-out; }
.choice.picked { border-color: var(--accent); background: #2a2a3f; }
.choice.picked .key { background: var(--accent); color: #1a1300; }
.choice.dim { opacity: .55; }
.choice.correct { border-color: var(--good); background: #143326; opacity: 1; }
.choice.correct .key { background: var(--good); color: #002210; }
.choice.correct .bar { background: #2fd47a26; }
.choice.wrong { border-color: var(--bad); background: #3a1622; opacity: 1; }
.choice.wrong .key { background: var(--bad); color: #2a0008; }

.status { min-height: 1.5em; margin: 18px 0 6px; color: var(--muted); font-size: 16px; }
.status.good { color: var(--good); font-weight: 700; }
.status.bad { color: var(--bad); font-weight: 700; }

.answered-strip { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
#answered-n { color: var(--text); font-weight: 700; }
.answered-names { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.answered-names span {
  padding: 2px 8px; border-radius: 999px; background: #7c5cff22; color: #c9bdff; font-size: 12px;
  animation: pop .3s ease-out;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.side { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; }
.card h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card h2 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats div { background: #ffffff08; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.stats b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 12px; }
.last-result { margin: 12px 0 0; color: var(--muted); font-size: 14px; min-height: 1.2em; }

.board-list { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.board-list li {
  counter-increment: r; display: grid; grid-template-columns: 28px 1fr auto auto; gap: 8px; align-items: center;
  padding: 8px 6px; border-radius: 10px; font-variant-numeric: tabular-nums; transition: background .3s;
}
.board-list li::before { content: counter(r); color: var(--muted); font-weight: 700; text-align: center; }
.board-list li:nth-child(1)::before { content: "🥇"; }
.board-list li:nth-child(2)::before { content: "🥈"; }
.board-list li:nth-child(3)::before { content: "🥉"; }
.board-list li.me { background: #ffcc3318; outline: 1px solid #ffcc3355; }
.board-list li.empty { display: block; color: var(--muted); font-size: 14px; }
.board-list li.empty::before { content: none; }
.board-list .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board-list .gain { font-size: 12px; color: var(--good); }
.board-list .gain.zero { color: var(--muted); }
.board-list .total { font-weight: 800; }
.board-list li.bump { animation: bump .8s ease-out; }
@keyframes bump { 0% { background: #2fd47a40; } 100% { background: transparent; } }
.fine { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.reactions {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 8px; border-radius: 999px;
  background: #151829e6; border: 1px solid var(--line); backdrop-filter: blur(8px); z-index: 5;
}
.reactions button {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: transparent; font-size: 24px;
  transition: transform .1s, background .1s;
}
.reactions button:hover { background: #ffffff12; transform: scale(1.15); }
.reactions button:active { transform: scale(.9); }
.reactions button.cool { opacity: .4; }

.floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.floater {
  position: absolute; bottom: 70px; font-size: 34px; animation: rise 2.6s ease-out forwards;
  display: flex; flex-direction: column; align-items: center;
}
.floater small { font-size: 11px; color: var(--muted); background: #0008; padding: 1px 6px; border-radius: 6px; }
@keyframes rise {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  10% { opacity: 1; transform: translateY(-20px) scale(1.1); }
  100% { transform: translateY(-60vh) translateX(var(--drift)) scale(1); opacity: 0; }
}

.nick-dialog {
  border: 1px solid var(--line); border-radius: 24px; background: var(--bg2); color: var(--text);
  padding: 28px; width: min(420px, 92vw);
}
.nick-dialog::backdrop { background: #05060dcc; backdrop-filter: blur(4px); }
.nick-dialog h2 { margin: 0 0 8px; }
.nick-dialog p { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.nick-dialog input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg);
  color: var(--text); font: inherit; font-size: 18px; margin-bottom: 14px; outline: none;
}
.nick-dialog input:focus { border-color: var(--accent2); }
.btn-primary {
  width: 100%; padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: #1a1300;
  font-weight: 800; font-size: 17px;
}
.btn-primary:hover { filter: brightness(1.08); }
