:root {
  --bg: #07080c;
  --bg2: #0e1118;
  --card: #0f1219;
  --card2: #151a24;
  --line: #232a37;
  --line2: #2e3747;
  --text: #eef1f6;
  --muted: #8b95a7;
  --accent: #4f8cff;
  --accent2: #7c5cff;
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, .12);
  --bad: #f43f5e;
  --bad-bg: rgba(244, 63, 94, .12);
  --miss: #64748b;
  --gold: #fbbf24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(79, 140, 255, .12), transparent 60%),
              radial-gradient(900px 500px at -10% 10%, rgba(124, 92, 255, .10), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 500 16px/1.5 Nunito, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip; /* страховка от горизонтальной прокрутки на телефоне */
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; font-weight: 800; }
h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h2 { font-size: 1.2rem; }
small { font-size: .82em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.block { display: block; }
.big-emoji { font-size: 3rem; line-height: 1; margin-bottom: .3em; }

/* ---------- layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 16px 16px 60px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(7, 8, 12, .8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.15rem; }
.brand b { font-weight: 900; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 900; font-size: .9rem;
}
.me {
  display: flex; align-items: center; gap: 8px; max-width: 55vw;
  background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 14px 4px 4px; font: inherit; cursor: pointer;
}
.me span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me:hover { border-color: var(--line2); }

.card {
  background: linear-gradient(180deg, var(--card), #0c0f15);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.pad-xl { padding: 48px 20px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 18px;
  font: 700 1rem Nunito, inherit; cursor: pointer; color: var(--text); background: var(--card2);
  transition: transform .08s, background .2s, border-color .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 6px 20px rgba(79, 140, 255, .3); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line2); }
.btn.ghost:hover { background: var(--card2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(1.1); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn.sm { padding: 7px 12px; font-size: .9rem; }
.btn.lg { padding: 14px 24px; font-size: 1.08rem; }
.btn.block { width: 100%; }
.btn.icon { padding: 10px 12px; }
.link-btn { background: none; border: 1px solid var(--line2); color: var(--muted); border-radius: 8px; padding: 2px 9px; cursor: pointer; font: inherit; }
.link-btn:hover { color: var(--bad); border-color: var(--bad); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: rgba(79, 140, 255, .15); color: #8cb4ff; }
.badge { white-space: nowrap; }
.badge.live { flex: none; background: rgba(34, 197, 94, .15); color: #4ade80; margin-left: auto; padding: 1px 8px; font-size: .72rem; line-height: 1.5; }
.badge.gold { background: rgba(251, 191, 36, .16); color: var(--gold); }
.tag { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: 999px; background: rgba(79, 140, 255, .14); color: #6ea4ff; font-weight: 800; font-size: .9rem; }

/* ---------- avatars ---------- */
.avatar {
  --c: #5c7cfa;
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  color: #fff; font-weight: 900; font-size: .85rem; letter-spacing: -.02em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.avatar.emoji {
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 35%, #fff), color-mix(in srgb, var(--c) 55%, #1b2030));
  font-size: 1.25rem; line-height: 1; letter-spacing: 0;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar.emoji.sm { font-size: 1rem; }
.avatar.emoji.xs { font-size: .8rem; }
.icon-label { margin: -4px 0 6px; font-weight: 700; }
.icon-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-bottom: 16px; }
.icon-grid button {
  aspect-ratio: 1; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card2);
  font-size: 1.3rem; line-height: 1; cursor: pointer; transition: transform .08s, border-color .15s, background .15s;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
.icon-grid button:hover { border-color: var(--line2); transform: scale(1.08); }
.icon-grid button.on { border-color: var(--accent); background: rgba(79, 140, 255, .2); box-shadow: inset 0 0 0 1px var(--accent); }
@media (max-width: 420px) { .icon-grid { grid-template-columns: repeat(5, 1fr); } }
.avatar.xs { width: 22px; height: 22px; font-size: .58rem; margin-left: -6px; border: 2px solid var(--card); }
.avatar.xs:first-child { margin-left: 0; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; align-items: center; padding: 28px 0 36px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 900; letter-spacing: -.02em; }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent2), #f472b6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.1rem; color: #c3cad6; max-width: 60ch; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.stat { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; }
.stat .flag { font-size: 1.8rem; }
.stat small { display: block; color: var(--muted); }
.hero-card { display: flex; justify-content: center; }
.demo-q { width: min(360px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); transform: rotate(2deg); }
.demo-top { display: flex; justify-content: space-between; align-items: center; }
.ring { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--ok); color: var(--ok); font-weight: 900; }
.demo-word { font-size: 2rem; font-weight: 900; text-align: center; margin: 12px 0 14px; }
.demo-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; }
.demo-opt i, .opt i { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--card2); font-style: normal; font-weight: 900; font-size: .8rem; }
.demo-opt span { margin-left: auto; font-weight: 900; }
.demo-opt.ok { border-color: var(--ok); background: var(--ok-bg); }
.demo-opt.ok span { color: var(--ok); }
.demo-opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.demo-opt.bad span { color: var(--bad); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.group-title { margin: 22px 0 10px; font-size: 1.05rem; }
.group-title:first-child { margin-top: 4px; }
.group-title small { font-weight: 600; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.room-card {
  display: flex; align-items: center; gap: 14px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  transition: transform .15s, border-color .15s, background .15s;
}
.room-card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--card2); }
.room-emoji { display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 16px; background: var(--card2); font-size: 1.8rem; }
.room-emoji.sm { width: 46px; height: 46px; font-size: 1.5rem; }
.room-body { flex: 1; min-width: 0; }
.room-name { font-weight: 900; font-size: 1.1rem; }
.room-label { color: var(--muted); font-size: .9rem; }
.room-meta { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin-top: 4px; min-width: 0; }
.room-online { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-go { color: var(--muted); font-size: 1.3rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--miss); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.how { margin-top: 40px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 14px 52px; position: relative; color: #c3cad6; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 14px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 900; font-size: .85rem; }
.steps b { color: var(--text); }

/* ---------- room ---------- */
.room-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; flex-wrap: wrap; }
.back { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line2); color: var(--text); font-size: 1.2rem; }
.back:hover { background: var(--card2); }
.room-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.room-title h1 { margin: 0; }
.room-actions { display: flex; gap: 8px; }

.lobby, .play { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.side { position: sticky; top: 80px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  flex: 1 1 auto; min-width: 56px; padding: 9px 12px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  font: 700 .95rem Nunito, inherit; cursor: pointer; transition: border-color .15s, background .15s;
}
.seg button small { display: block; font-size: .7rem; color: var(--muted); font-weight: 600; }
.seg button:hover:not(:disabled) { border-color: var(--line2); }
.seg button.on { border-color: var(--accent); background: rgba(79, 140, 255, .14); color: #fff; box-shadow: inset 0 0 0 1px var(--accent); }
.seg button.on small { color: #a9c6ff; }
.seg.disabled button { cursor: default; }
.seg button.off { opacity: .3; cursor: not-allowed; text-decoration: line-through; }
.seg.disabled button:not(.on) { opacity: .55; }
.note { padding: 10px 14px; border-radius: 12px; background: rgba(251, 191, 36, .1); color: #fcd34d; border: 1px solid rgba(251, 191, 36, .25); font-size: .92rem; }
.note.ok { background: var(--ok-bg); color: #86efac; border-color: rgba(34, 197, 94, .25); }
.note.bad { background: var(--bad-bg); color: #fda4af; border-color: rgba(244, 63, 94, .3); }

.players { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: var(--card2); border: 1px solid transparent; }
.players li.me { border-color: rgba(79, 140, 255, .4); }
.players li.off { opacity: .5; }
.pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.pname small { color: var(--muted); font-weight: 600; }
.pscore { font-weight: 900; color: #a9c6ff; }
.pmark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .75rem; font-weight: 900; }
.pmark.ok { background: var(--ok-bg); color: var(--ok); }
.pmark.wait { color: var(--muted); }
.side-foot { margin-top: 16px; }
.waiting { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 10px; border-radius: 12px; background: var(--card2); }

/* ---------- question ---------- */
.q-top { display: flex; align-items: center; gap: 10px; }
.q-count { margin-left: auto; color: #c3cad6; }
.q-progress { height: 4px; border-radius: 4px; background: var(--card2); margin: 12px 0 0; overflow: hidden; }
.q-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; }
.q-main { text-align: center; padding: 18px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.q-main.compact { padding-bottom: 12px; margin-bottom: 12px; }
.q-word { font-size: clamp(2rem, 6vw, 3rem); font-weight: 900; letter-spacing: -.01em; line-height: 1.15; word-break: break-word; }
.q-word.long { font-size: clamp(1.4rem, 4vw, 2rem); }
.q-sub { color: var(--muted); margin-top: 4px; }
.say {
  display: inline-grid; place-items: center; vertical-align: middle; flex: none;
  width: 34px; height: 34px; margin: 0 8px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line2); background: var(--card2); color: var(--text);
  font-size: 1rem; line-height: 1; cursor: pointer; transition: background .15s, border-color .15s, transform .08s;
}
.say:hover { border-color: var(--accent); background: rgba(79, 140, 255, .15); }
.say:active { transform: scale(.92); }
.q-word .say { width: 40px; height: 40px; font-size: 1.15rem; margin-left: 12px; position: relative; top: -4px; }
.qitem-head .say { width: 26px; height: 26px; font-size: .8rem; margin: 0; }
.note.muted-note { margin-top: 8px; background: var(--card2); color: var(--muted); border-color: var(--line); }
.btn.muted-btn { color: var(--muted); }
.timer-ring { --p: 1; position: relative; width: 74px; height: 74px; margin: 14px auto 2px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke: var(--card2); stroke-width: 4; }
.timer-ring circle.fg { stroke: var(--ok); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--p)); transition: stroke .3s; }
.timer-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; font-weight: 900; color: var(--ok); }
.timer-ring.warn circle.fg { stroke: var(--bad); }
.timer-ring.warn b { color: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }
.q-instr { font-size: 1.1rem; }
.options { display: grid; gap: 10px; }
.opt {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line2); background: transparent; color: var(--text);
  font: 700 1.12rem Nunito, inherit; cursor: pointer; transition: border-color .15s, background .15s, transform .08s;
}
.opt span { flex: 1; min-width: 0; word-break: break-word; }
button.opt:hover:not(:disabled) { border-color: var(--accent); background: rgba(79, 140, 255, .07); }
button.opt:active:not(:disabled) { transform: scale(.99); }
.opt.picked { border-color: var(--accent); background: rgba(79, 140, 255, .16); box-shadow: inset 0 0 0 1px var(--accent); }
.opt.picked i { background: var(--accent); color: #fff; }
.options.locked .opt:not(.picked) { opacity: .45; cursor: default; }
.opt:disabled { cursor: default; }
.q-status { margin-top: 14px; text-align: center; font-weight: 700; color: #86efac; min-height: 1.5em; }

.options.revealed .opt { cursor: default; padding: 12px 16px; }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.correct i { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong i { background: var(--bad); color: #fff; }
.opt .who { flex: none; display: flex; }
.opt .mark { flex: none; font-weight: 900; font-size: 1.2rem; }
.opt.correct .mark { color: var(--ok); }
.opt.wrong .mark { color: var(--bad); }
.verdict { display: inline-block; margin-top: 10px; padding: 6px 16px; border-radius: 999px; font-weight: 900; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict.miss { background: rgba(100, 116, 139, .18); color: #cbd5e1; }
.pair { text-align: center; margin: 0 0 12px; font-size: 1.05rem; }

.table-wrap { overflow-x: auto; margin-top: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; color: var(--muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.me td { background: rgba(79, 140, 255, .07); }
.pcell { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.ans { font-weight: 700; }
.ans.ok { color: var(--ok); }
.ans.bad { color: var(--bad); }
.ans.miss { color: var(--muted); }
td.plus { color: var(--ok); font-weight: 900; }

.next-row { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; }
.auto-bar { width: 100%; height: 4px; background: var(--card2); border-radius: 4px; overflow: hidden; }
.auto-bar i { display: block; height: 100%; width: 100%; background: var(--accent); }
.next-row .btn { min-width: 220px; }

.mini-rank { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.mini-rank li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px; background: var(--card2); }
.mini-rank li.me { box-shadow: inset 0 0 0 1px rgba(79, 140, 255, .5); }
.mini-rank .pl { width: 20px; color: var(--muted); font-weight: 900; }
.mini-rank .avatar.xs { margin-left: 0; }

.countdown-card { max-width: 560px; margin: 30px auto; }
.countdown b { display: block; font-size: 7rem; font-weight: 900; line-height: 1.1; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop 1s infinite; }
@keyframes pop { 0% { transform: scale(.6); opacity: .2; } 30% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- final ---------- */
.final { max-width: 980px; margin: 0 auto; }
.summary { display: flex; align-items: center; gap: 0; background: #fff; border-radius: 12px; padding: 6px; margin-bottom: 24px; position: relative; }
.sum-bar { flex: 1; display: flex; align-items: center; height: 40px; border-radius: 8px; overflow: hidden; }
.sum-bar i { display: block; height: 100%; }
.sum-bar span { padding: 4px 10px; margin: 0 6px; border-radius: 6px; font-weight: 900; color: #fff; }
.sum-bar.ok i { background: linear-gradient(90deg, #34d399, #6ee7b7); }
.sum-bar.ok span { background: rgba(0, 0, 0, .2); position: absolute; left: 14px; }
.sum-bar.bad { justify-content: flex-end; }
.sum-bar.bad i { background: #f43f5e; }
.sum-bar.bad span { background: rgba(0, 0, 0, .2); position: absolute; right: 14px; }
.acc-circle {
  --p: .5; flex: none; width: 92px; height: 92px; margin: -16px 10px; border-radius: 50%;
  display: grid; place-content: center; text-align: center; color: #111; z-index: 1;
  background: radial-gradient(closest-side, #fff 80%, transparent 81% 100%), conic-gradient(#22c55e calc(var(--p) * 100%), #f43f5e 0);
  box-shadow: 0 0 0 8px rgba(34, 197, 94, .15);
}
.acc-circle b { font-size: 1.5rem; font-weight: 900; line-height: 1; }
.acc-circle small { font-size: .7rem; color: #555; }
.final-head { text-align: center; margin-bottom: 18px; }
.tabs { display: flex; justify-content: center; gap: 4px; margin-bottom: 14px; }
.tabs button { background: transparent; border: 0; color: var(--muted); font: 800 1rem Nunito, inherit; padding: 10px 18px; border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.lb { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 36px 36px minmax(0, 1.2fr) minmax(80px, 1fr) 46px 64px; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--card2); }
.lb-row.first { background: linear-gradient(90deg, rgba(251, 191, 36, .14), var(--card2)); }
.lb-row.me { box-shadow: inset 0 0 0 1px var(--ok); background: rgba(34, 197, 94, .1); }
.lb-row .pl { font-weight: 900; font-size: 1.1rem; text-align: center; }
.lb-name { min-width: 0; }
.lb-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { display: block; }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #e5e7eb33; }
.stack i { display: block; height: 100%; }
.stack .ok { background: #34d399; }
.stack .bad { background: #f43f5e; }
.stack .miss { background: #e5e7eb; }
.lb-acc { color: var(--muted); text-align: right; font-weight: 700; }
.lb-score { text-align: right; font-size: 1.15rem; }
.qlist { display: flex; flex-direction: column; gap: 8px; }
.qitem { background: var(--card2); border-radius: 12px; padding: 10px 14px; }
.qitem-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qn { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--line); font-size: .78rem; font-weight: 900; }
.arrow { color: var(--muted); }
.ok-text { color: var(--ok); font-weight: 800; }
.qitem-res { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; border: 1px solid var(--line2); }
.chip.ok { color: #86efac; border-color: rgba(34, 197, 94, .4); background: var(--ok-bg); }
.chip.bad { color: #fda4af; border-color: rgba(244, 63, 94, .4); background: var(--bad-bg); }
.chip.miss { color: var(--muted); }
.chip small { opacity: .75; }
.final-actions { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

/* ---------- records ---------- */
.records-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.records-grid .span-2 { grid-column: span 2; }
.records-grid .card { overflow-x: auto; }
.r-icon { margin-right: 6px; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }

/* ---------- misc ---------- */
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 10px; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; margin: 0; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50;
  background: var(--card2); border: 1px solid var(--line2); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast.error { border-color: var(--bad); color: #fda4af; }
body.offline::after {
  content: 'Нет соединения… переподключаемся'; position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--bad); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: .9rem;
}

.dialog { border: 1px solid var(--line2); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 24px; width: min(420px, calc(100% - 32px)); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(4px); }
.name-row { display: flex; gap: 8px; margin: 14px 0; }
.name-row input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text); font: 700 1.05rem Nunito, inherit; }
.name-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* появление экранов */
#app > * { animation: rise .25s ease-out; }
#app.no-anim > * { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 10px; }
  .hero-card { display: none; }
  /* minmax(0,1fr): колонка не растягивается шире экрана из-за таблиц/длинных слов */
  .lobby, .play { grid-template-columns: minmax(0, 1fr); }
  .card, .side, .qcard { min-width: 0; }
  .side { position: static; }
  .play .side { order: 2; }
  .records-grid { grid-template-columns: 1fr; }
  .records-grid .span-2 { grid-column: auto; }
}
@media (max-width: 600px) {
  .container { padding: 12px 12px 40px; }
  .card { padding: 16px; border-radius: 16px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .seg button { padding: 8px 10px; font-size: .9rem; min-width: 44px; }
  .opt { padding: 14px; font-size: 1.02rem; }
  .room-actions { width: 100%; }
  .room-actions .btn { flex: 1; }
  .lb-row { grid-template-columns: 28px 30px minmax(0, 1fr) 56px; gap: 8px; padding: 10px; }
  .lb-row .avatar { width: 30px; height: 30px; }
  .lb-row .stack { grid-column: 3 / 5; grid-row: 2; }
  .lb-acc { display: none; }
  .table { font-size: .88rem; }
  .table td, .table th { padding: 7px 6px; }
  .hide-sm { display: none; }

  /* шапка кабинета */
  .room-head { gap: 10px; margin-bottom: 12px; }
  .room-title h1 { font-size: 1.3rem; }
  .room-actions { gap: 6px; }
  .room-actions .btn { padding: 7px 8px; font-size: .82rem; }

  /* вопрос */
  .q-top { flex-wrap: wrap; gap: 6px; }
  .q-top .tag { font-size: .78rem; padding: 3px 10px; max-width: 100%; }
  .q-count { font-size: .9rem; }
  .q-main { padding: 12px 0; margin-bottom: 12px; }
  .q-word { font-size: clamp(1.7rem, 9vw, 2.4rem); }
  .q-word .say { width: 34px; height: 34px; font-size: 1rem; margin-left: 8px; }
  .timer-ring { width: 62px; height: 62px; margin-top: 10px; }
  .timer-ring b { font-size: 1.35rem; }
  .q-instr { font-size: 1rem; margin-bottom: 10px; }
  .options { gap: 8px; }
  .opt { padding: 12px; gap: 10px; }
  .options.revealed .opt { padding: 10px 12px; }
  .verdict { margin-top: 8px; padding: 4px 14px; }
  .pair { font-size: .98rem; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; }
  .pair .say { margin: 0 6px 0 0; }

  /* результаты вопроса — компактные строки вместо широкой таблицы */
  .results thead { display: none; }
  .results tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "p t pts" "a a tot"; align-items: center; column-gap: 10px; row-gap: 2px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
  .results tr:last-child { border-bottom: 0; }
  .results td { border: 0; padding: 0; }
  .results td:nth-child(1) { grid-area: p; min-width: 0; }
  .results td:nth-child(2) { grid-area: a; padding-left: 36px; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .results td:nth-child(3) { grid-area: t; color: var(--muted); font-size: .85rem; }
  .results td:nth-child(4) { grid-area: pts; }
  .results td:nth-child(5) { grid-area: tot; font-size: .85rem; color: var(--muted); }
  .results td:nth-child(5)::before { content: 'всего '; }
  .results tr.me { background: rgba(79, 140, 255, .07); border-radius: 10px; }
  .results tr.me td { background: none; }
  .pcell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-wrap { margin-top: 10px; }

  .next-row { margin-top: 12px; }
  .next-row .btn { width: 100%; min-width: 0; }

  /* лобби */
  .card-head { flex-wrap: wrap; }
  .seg { gap: 6px; }
  .seg button small { font-size: .62rem; }
  .players li, .mini-rank li { padding: 6px 8px; }

  /* итоги */
  .summary { margin-bottom: 16px; }
  .sum-bar { height: 32px; }
  .final-head h2 { font-size: 1.15rem; }
  .final-head .lead { font-size: .95rem; }
  .tabs button { padding: 8px 12px; }
  .final-actions .btn { width: 100%; }
  .qitem { padding: 8px 10px; }
  .acc-circle { width: 76px; height: 76px; }
  .acc-circle b { font-size: 1.2rem; }
  .brand > span:last-child { display: none; }
}
