/* Своё оформление: тёплая палитра и буквы А Б В Г в карточках — не фигуры и не цвета Kahoot. */
:root {
  --bg: #f6f1e8; --card: #ffffff; --ink: #1f1a2e; --muted: #6b6480; --line: #e6dfd3;
  --accent: #5b3df5; --ok: #1ea896; --bad: #f2545b;
  --a: #f2545b; --b: #1ea896; --c: #f5a623; --d: #7b61ff;
  --radius: 18px; --shadow: 0 6px 24px rgba(31, 26, 46, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161322; --card: #221d33; --ink: #f4f0ff; --muted: #a79fc0; --line: #342c4d; --shadow: 0 6px 24px rgba(0,0,0,0.4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; cursor: pointer; border: 0; }
input { font: inherit; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; padding: 16px; gap: 14px; max-width: 560px; margin: 0 auto; }
.screen.wide { max-width: 1100px; }
.hidden { display: none !important; }
h1 { font-size: 28px; margin: 8px 0 0; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 0; }
.muted { color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); }
.field input {
  padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 20px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.field input.pin { letter-spacing: 0.35em; font-size: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
/* Поле в ряду с кнопкой: без min-width поле не сжимается уже своей «естественной» ширины и выталкивает кнопку за экран. */
.row > input, .field .row input { min-width: 0; }
.btn {
  padding: 16px 18px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 18px; font-weight: 700;
  transition: transform .08s ease; min-height: 56px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.small { padding: 10px 14px; font-size: 15px; min-height: 0; flex: 0 0 auto; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 520px;
  background: var(--ink); color: var(--bg); padding: 14px 18px; border-radius: 14px; text-align: center; font-weight: 600;
  opacity: 0; transform: translateY(10px); transition: all .2s ease; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: none; }
.timer { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.timer > i { display: block; height: 100%; background: var(--accent); width: 100%; transition: width .25s linear; }
.timer.hot > i { background: var(--bad); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
.options.two { grid-template-columns: 1fr; }
.opt {
  display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 20px; color: #fff; font-size: 20px; font-weight: 700;
  min-height: 96px; text-align: left; box-shadow: var(--shadow); position: relative; min-width: 0;
}
.opt .letter { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,0.25); display: grid; place-items: center; font-size: 22px; flex: 0 0 auto; }
.opt[data-i="0"] { background: var(--a); } .opt[data-i="1"] { background: var(--b); }
.opt[data-i="2"] { background: var(--c); } .opt[data-i="3"] { background: var(--d); }
.opt.dim { opacity: 0.35; } .opt.correct { outline: 4px solid #fff; box-shadow: 0 0 0 4px var(--ok); }
.big { font-size: 56px; font-weight: 800; letter-spacing: 0.08em; text-align: center; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.grow { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.result { text-align: center; padding: 28px 18px; border-radius: var(--radius); color: #fff; }
.result.ok { background: var(--ok); } .result.bad { background: var(--bad); } .result.none { background: var(--muted); }
.result .points { font-size: 44px; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 2px solid var(--line); border-radius: 99px; padding: 8px 14px; font-weight: 600; }
.chip.off { opacity: 0.4; text-decoration: line-through; }
.board { display: flex; flex-direction: column; gap: 8px; }
.board .entry { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.board .rank { width: 32px; font-weight: 800; color: var(--muted); }
.board .nick { flex: 1; font-weight: 700; }
.board .delta { font-size: 13px; color: var(--ok); } .board .delta.down { color: var(--bad); }
.board .score { font-variant-numeric: tabular-nums; font-weight: 700; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin-top: 20px; }
.podium .step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.podium .block { width: 100%; border-radius: 16px 16px 0 0; display: grid; place-items: center; color: #fff; font-size: 32px; font-weight: 800; }
.podium .p1 .block { height: 160px; background: #f5a623; } .podium .p2 .block { height: 120px; background: #9aa5b8; } .podium .p3 .block { height: 90px; background: #c77d4f; }
.podium .name { font-weight: 800; text-align: center; } .podium .pts { color: var(--muted); font-size: 14px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 10px; }
.bar .track { height: 26px; background: var(--line); border-radius: 8px; overflow: hidden; }
.bar .track > i { display: block; height: 100%; }
.explain { border-left: 4px solid var(--accent); padding: 10px 14px; background: var(--card); border-radius: 0 14px 14px 0; }
table.report { width: 100%; border-collapse: collapse; font-size: 15px; }
table.report th, table.report td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.report td.num, table.report th.num { text-align: right; font-variant-numeric: tabular-nums; }
.qr { width: 220px; height: 220px; background: #fff; padding: 10px; border-radius: 16px; }
.host-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.host-q { font-size: 34px; font-weight: 800; line-height: 1.2; }
@media (min-width: 900px) { .host-q { font-size: 44px; } .options.host .opt { min-height: 130px; font-size: 28px; } }
.ring { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 800; background: conic-gradient(var(--accent) var(--p, 100%), var(--line) 0); }
.ring > span { width: 68px; height: 68px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }
textarea { width: 100%; min-height: 160px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); padding: 12px; font: 14px/1.4 ui-monospace, monospace; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 2px; animation: fall 3.2s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0.8; } }
.host-link { margin-top: auto; font-size: 15px; }
.host-link a { color: var(--muted); text-decoration: none; border-bottom: 1px dashed var(--line); }
.host-link a:hover { color: var(--accent); }
.install { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--card); border: 2px dashed var(--line); font-size: 15px; line-height: 1.35; }
.install-icon { font-size: 26px; }
.install-text { flex: 1; }
.install-text b { white-space: nowrap; }
.install-close { background: none; color: var(--muted); font-size: 24px; line-height: 1; padding: 4px 6px; }
.q-text { font-size: 22px; line-height: 1.3; margin: 4px 0 0; }
.q-image { max-width: 100%; max-height: 32vh; border-radius: 14px; align-self: center; }
.opt .txt { font-size: 18px; font-weight: 700; line-height: 1.25; min-width: 0; overflow-wrap: normal; }
.opt .txt.squeeze { overflow-wrap: anywhere; }
.options.list { grid-template-columns: 1fr; }
.options.list .opt { min-height: 64px; }
.opt:disabled { opacity: 0.6; }
.r-question { margin: 0; font-size: 15px; }
.board .entry.me { outline: 3px solid var(--accent); outline-offset: -3px; }
.board .gap { text-align: center; color: var(--muted); letter-spacing: 0.3em; }
.board-me { font-size: 18px; font-weight: 700; margin: 4px 0 6px; }
/* Таймер у игрока: крупные секунды и толстая полоса, последние 5 секунд — красные и пульсируют. */
#s-question .timer { height: 14px; }
.countdown { flex: 0 0 auto !important; min-width: 64px; text-align: center; font-size: 22px; font-weight: 800;
  font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: 99px; background: var(--card); color: var(--ink); }
.countdown.hot { background: var(--bad); color: #fff; animation: pulse 1s ease-in-out infinite; }
#q-timer.hot > i { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
/* Вопрос может быть из нескольких строк (эмодзи-загадка, затем вопрос) — переносы сохраняем. */
.host-q, .q-text, .r-question { white-space: pre-line; }
/* Крупнее первая строка — только у вопросов, написанных в две строки (эмодзи-загадка, затем вопрос). */
.host-q.multi::first-line, .q-text.multi::first-line { font-size: 1.35em; }
/* Эмодзи-загадка — крупно своей строкой («🧙‍♂️💍🌋» над «Какой это фильм?»). */
.q-emoji { display: block; font-size: 2.4em; line-height: 1.15; margin: 4px 0 6px; letter-spacing: 4px; }
.q-line { display: block; }
.order-list { margin: 8px 0 12px; padding-left: 28px; font-size: 22px; font-weight: 700; line-height: 1.6; }
.cloud { text-align: center; line-height: 1.2; padding: 28px; font-weight: 800; }
.cloud span { display: inline-block; margin: 6px 12px; }
.order-pick { display: flex; flex-direction: column; gap: 10px; }
.order-pick .opt { min-height: 64px; }
.order-pick .opt.picked .letter, .order-pick .opt.picked .txt { opacity: 0.5; }
.order-pick .opt.picked { filter: saturate(0.6); }
.order-pick .opt .num { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #1f1a2e;
  display: grid; place-items: center; font-size: 22px; font-weight: 800; flex: 0 0 auto; }
.slider-value { text-align: center; font-size: 48px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 6px 0 10px; }
.slider { width: 100%; height: 44px; accent-color: var(--accent); }
.slider-ends { font-size: 15px; }
.r-list { margin: 6px 0 0; padding-left: 24px; line-height: 1.5; }
.my-list { display: flex; flex-direction: column; gap: 8px; }
.my-row { display: flex; gap: 8px; align-items: center; }
.my-title { flex: 1; text-align: left; padding: 12px 16px; border-radius: 14px; background: var(--bg); color: var(--ink);
  border: 2px solid var(--line); font-weight: 700; font-size: 16px; }
.my-title:hover { border-color: var(--accent); }
.ed-list { display: flex; flex-direction: column; gap: 10px; }
.ed-q { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.ed-q-head { display: flex; gap: 10px; align-items: center; }
.ed-q-head .t { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.ed-q-head .k { font-size: 22px; }
.ed-q-head button { background: none; color: var(--muted); font-size: 18px; padding: 6px 8px; border-radius: 8px; }
.ed-q-head button:hover { background: var(--bg); color: var(--ink); }
.ed-form { display: grid; gap: 10px; }
.ed-form textarea, .ed-form input, .ed-form select { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--bg); color: var(--ink); width: 100%; min-height: 0; }
.ed-form textarea { min-height: 70px; font-family: inherit; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.ed-opt { display: flex; gap: 8px; align-items: center; }
.ed-opt .letter { width: 34px; height: 34px; border-radius: 9px; color: #fff; display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.ed-opt input[type=radio] { width: 22px; height: 22px; accent-color: var(--ok); flex: 0 0 auto; }
.ed-problem { color: var(--bad); font-weight: 600; font-size: 14px; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.kind-card { text-align: left; padding: 14px; border-radius: 16px; background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.kind-card:hover { border-color: var(--accent); }
.kind-card .i { font-size: 30px; }
.kind-card b { display: block; margin: 4px 0 2px; }
.kind-card span { color: var(--muted); font-size: 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tpl { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 16px 16px 40px; border-radius: 18px;
  background: var(--bg); color: var(--ink); border: 2px solid var(--line); border-top: 8px solid var(--tc); }
.tpl:hover { border-color: var(--tc); }
.tpl-emoji { font-size: 34px; }
.tpl .muted { font-size: 14px; line-height: 1.35; }
.tpl-count { position: absolute; left: 16px; bottom: 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.tpl-group { margin: 6px 0 8px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#tpl-list .tpl-grid + .tpl-group { margin-top: 18px; }
#slider-send, #order-send, #order-reset { width: 100%; }
/* Дорожка викторины (updateProgress в common.js). */
.qprog { --qp: 0; --ball: 18px; display: flex; align-items: center; gap: 14px; flex: 1 1 auto; min-width: 0; }
.qprog.small { --ball: 14px; gap: 10px; }
.qprog-track { position: relative; flex: 1; height: calc(var(--ball) + 12px); min-width: 80px; }
.qprog-track::before { content: ""; position: absolute; left: 0; right: 22px; top: 50%; height: 2px; margin-top: -1px;
  background: var(--line); border-radius: 2px; }
.qprog-fill { position: absolute; left: 0; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 3px;
  width: calc((100% - 22px - var(--ball)) * var(--qp) + var(--ball) / 2);
  background: linear-gradient(90deg, var(--c), var(--a)); transition: width .6s cubic-bezier(.34, 1.4, .64, 1); }
.qprog-ball { position: absolute; top: 50%; width: var(--ball); height: var(--ball); margin-top: calc(var(--ball) / -2);
  left: calc((100% - 22px - var(--ball)) * var(--qp)); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd89a, var(--c) 45%, var(--a)); box-shadow: 0 2px 6px rgba(242, 84, 91, .45);
  transition: left .6s cubic-bezier(.34, 1.4, .64, 1); }
.qprog-ball.hop { animation: qp-hop .6s ease-out; }
@keyframes qp-hop { 0% { transform: translateY(0) scale(1, 1); } 15% { transform: translateY(0) scale(1.15, .8); }
  45% { transform: translateY(calc(var(--ball) * -1.1)) scale(.95, 1.08); } 80% { transform: translateY(0) scale(1.1, .9); } 100% { transform: none; } }
.qprog-flag { position: absolute; right: 0; top: 50%; transform: translateY(-55%); font-size: 16px; line-height: 1; }
.qprog.small .qprog-flag { font-size: 13px; }
.qprog-num { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; }
.qprog-num b { color: var(--ink); font-size: 20px; }
.qprog.small .qprog-num b { font-size: 17px; }
@media (prefers-reduced-motion: reduce) { .qprog-ball, .qprog-fill { transition: none; } .qprog-ball.hop { animation: none; } }

/* Картинка вопроса в конструкторе и поиск фото */
.ed-img { display: flex; flex-direction: column; gap: 10px; }
.ed-img img { max-width: 100%; max-height: 220px; align-self: flex-start; border-radius: 14px; box-shadow: var(--shadow); }
.ed-img .row { flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
.ed-img label.btn { cursor: pointer; }
.ed-img input[type=file] { display: none; }
.photo-dlg { width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: none; border-radius: 22px; padding: 18px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.photo-dlg[open] { display: flex; flex-direction: column; gap: 12px; }
.photo-dlg::backdrop { background: rgba(10, 8, 20, 0.55); }
.photo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.photo-head h3 { margin: 0; }
#photo-form input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-content: start; gap: 10px;
  overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.photo-grid button { position: relative; display: block; padding: 0; border: none; border-radius: 14px; overflow: hidden; background: var(--bg); cursor: pointer; }
/* Высота — от самой картинки (4:3): иначе в узком окне строки сетки сжимались и наезжали друг на друга. */
.photo-grid img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
#photo-status:empty { display: none; }
.photo-grid span { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 12px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); }
.photo-grid button:disabled { opacity: 0.5; cursor: progress; }
.photo-credit { font-size: 13px; margin: 0; }
.photo-credit a { color: inherit; }

/* Счётчик ответов у ведущего: крупное число, заливка по доле ответивших, «все ответили» — зелёный */
.answer-count { display: flex; align-items: center; gap: 12px; min-height: 84px; padding: 6px 20px 6px 18px; border-radius: 24px; border: 2px solid var(--line);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 24%, var(--card)) var(--share, 0%), var(--card) 0);
  transition: background 0.4s, border-color 0.3s; }
.answer-count b { font-size: 52px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; min-width: 1ch; text-align: center; }
.answer-count > span { font-size: 16px; font-weight: 600; line-height: 1.25; color: var(--muted); }
.answer-count.all { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 26%, var(--card)); }
.answer-count.all > span { color: var(--ink); }
.answer-count.bump b { animation: count-bump 0.35s ease-out; }
@keyframes count-bump { 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .answer-count.bump b { animation: none; } }

/* Отсчёт «3, 2, 1» перед вопросом: цифра растёт за свою секунду, у каждой цифры свой цвет */
#s-countdown { justify-content: center; }
.getready { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 70vh; text-align: center; }
.getready-title { margin: 0; font-size: clamp(20px, 3vw, 32px); font-weight: 800; }
.getready-hint { margin: 0; font-size: clamp(16px, 2vw, 22px); }
.getready-num { --digit: var(--accent); width: min(46vw, 46vh, 320px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font-size: min(30vw, 30vh, 210px); font-weight: 900; line-height: 1; color: #fff; background: var(--digit);
  box-shadow: 0 18px 50px color-mix(in srgb, var(--digit) 45%, transparent); font-variant-numeric: tabular-nums; }
.getready-num[data-n="3"] { --digit: var(--a); }
.getready-num[data-n="2"] { --digit: var(--c); }
.getready-num[data-n="1"] { --digit: var(--b); }
.getready-num.go { animation: grow-digit 1s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
@keyframes grow-digit { 0% { transform: scale(0.45); opacity: 0; } 18% { opacity: 1; } 100% { transform: scale(1.12); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .getready-num.go { animation: none; } }
.answered-line { margin: -4px 0 0; font-size: 14px; font-weight: 600; text-align: right; }
.answered-line:empty { display: none; }
label.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Игрок, телефон лёжа: высоты мало — шапка и таймер на всю ширину, слева вопрос с картинкой, справа варианты.
   Раньше всё шло одной колонкой, и до вариантов приходилось листать. */
@media (orientation: landscape) and (max-height: 520px) {
  #s-question:not(.hidden) {
    display: grid; max-width: none; gap: 8px 18px; align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto auto auto 1fr;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }
  #s-question > .row:first-child, #q-timer { grid-column: 1 / -1; }
  #q-count { grid-column: 2; grid-row: 3; margin: 0; }
  #q-text { grid-column: 1; grid-row: 3; font-size: 18px; margin: 0; }
  #q-image { grid-column: 1; grid-row: 4; max-height: calc(100dvh - 150px); justify-self: start; }
  #q-options, #q-short, #q-order, #q-slider, #q-wait { grid-column: 2; grid-row: 4; align-self: stretch; }
  /* Текст без картинки — тоже слева, во всю высоту. */
  #q-text:has(+ #q-image.hidden) { grid-row: 3 / span 2; }
  #s-question .options { grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
  #s-question .options.list { grid-template-columns: 1fr; }
  #s-question .opt { min-height: 64px; padding: 10px 12px; }
  #s-question .opt .letter { width: 36px; height: 36px; font-size: 18px; }
  #s-question .opt .txt { font-size: 16px; }
  #q-options, #q-order { max-height: calc(100dvh - 120px); overflow-y: auto; }
  /* Подиум и итог лёжа — ниже, чтобы помещались без прокрутки. */
  #s-podium h2, #s-result h2 { margin: 4px 0; }
  .podium { margin-top: 8px; gap: 10px; }
  .podium .p1 .block { height: 21vh; } .podium .p2 .block { height: 15vh; } .podium .p3 .block { height: 10vh; }
  .podium .block { font-size: 24px; }
  #s-result .result { padding: 14px; }
  #s-result #r-emoji { font-size: 32px !important; }
}

/* Узкий телефон, варианты сеткой 2×2: меньше отступы и квадрат с буквой — иначе «Юпитер» рвался на «Юпите / р».
   Если слово всё равно не влезает — шрифт этой кнопки меньше (fitWords в common.js), а не перенос «Поеха-ли». */
@media (max-width: 420px) {
  .options:not(.list):not(.two) .opt { padding: 12px; gap: 10px; }
  .options:not(.list):not(.two) .opt .letter { width: 36px; height: 36px; font-size: 18px; }
}

/* Ведущий, широкий экран (ноутбук, проектор, телевизор 16:9), вопрос с картинкой: фото по центру занимает
   всё свободное место, варианты 2×2 компактно снизу. Раньше картинка была фиксированной высоты, и на 1280×720
   нижний ряд вариантов обрезался. */
@media (min-width: 900px) {
  #s-question.wide.with-image:not(.hidden) {
    display: grid; height: 100dvh; gap: 12px; grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  }
  #s-question.with-image > #q-image {
    width: 100%; height: 100%; max-height: none !important; min-height: 0; object-fit: contain; justify-self: center;
  }
  #s-question.with-image .options.host .opt { min-height: 84px; padding: 12px 18px; }
}

/* Экран «Провести»: папки, карточки с пометками, свои папки */
.cat-home { display: flex; flex-direction: column; gap: 22px; }
.cat-section { display: flex; flex-direction: column; gap: 12px; }
.cat-section h2 { margin: 0; }
.cat-search { flex: 1 1 260px; max-width: 420px; padding: 12px 16px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 16px; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.ftile { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 16px 16px 16px;
  border-radius: 18px; background: var(--card); color: var(--ink); border: 2px solid var(--line); border-top: 8px solid var(--tc);
  box-shadow: var(--shadow); min-height: 120px; cursor: pointer; }
.ftile:hover { border-color: var(--tc); }
.ftile-emoji { font-size: 32px; }
.ftile .muted { font-size: 13px; line-height: 1.3; }
.ftile-count { position: absolute; top: 12px; right: 14px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.qcard { position: relative; display: flex; flex-direction: column; border-radius: 18px; background: var(--card);
  border: 2px solid var(--line); border-left: 8px solid var(--tc, var(--accent)); box-shadow: var(--shadow); }
.qcard:hover { border-color: var(--tc, var(--accent)); }
.qcard.mine { --tc: var(--accent); }
.qcard-main { flex: 1; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 14px 16px; background: none;
  color: var(--ink); border: none; cursor: pointer; border-radius: 16px; }
.qcard-main b { padding-right: 34px; }
.qcard-emoji { font-size: 30px; }
.qcard-main .muted { font-size: 14px; line-height: 1.35; }
.qcard-meta { display: flex; gap: 10px; align-items: center; margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.badge { padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 800; color: #fff; }
.badge.quiz { background: var(--accent); } .badge.template { background: var(--c); } .badge.poll { background: var(--b); } .badge.generator { background: var(--a); }
.qcard-edit { position: absolute; top: 10px; right: 10px; background: var(--bg); border-radius: 10px; padding: 6px 8px; font-size: 16px; }
.qcard-tools { display: flex; gap: 6px; align-items: center; padding: 0 12px 12px; }
.qcard-tools button { background: var(--bg); border-radius: 10px; padding: 6px 9px; font-size: 16px; color: var(--ink); }
.qcard-tools select { flex: 1; min-width: 0; padding: 7px 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font-size: 14px; }
/* Папка с обложкой-фото: картинка 16:9 сверху, название и число — под ней. */
.qcard.with-cover { overflow: hidden; }
.qcard-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: color-mix(in srgb, var(--tc) 25%, var(--card)); }
.ftile.with-cover { padding: 0; overflow: hidden; border-top-width: 2px; min-height: 0; gap: 0; }
.ftile-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: color-mix(in srgb, var(--tc) 25%, var(--card)); }
.ftile-body { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 14px 12px; }
.ftile-body b { line-height: 1.25; }
.ftile-n { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips:empty { display: none; }
.chips .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 520px) {
  .folder-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ftile:not(.with-cover) { min-height: 104px; padding: 12px; }
  .ftile-body { padding: 8px 10px 10px; font-size: 15px; }
  .ftile .muted { display: none; }
}

/* Общая викторина /q/<код> */
.brand-link { font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; }
.share-card h1 { margin: 4px 0; }
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.share-actions .btn { flex: 1 1 200px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.share-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.small-print { font-size: 14px; }
.share-chip { display: inline-block; padding: 6px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; cursor: pointer; padding: 8px; }
.share-box { display: flex; flex-direction: column; gap: 12px; }
.share-box .share-url { font-family: ui-monospace, monospace; font-size: 15px; word-break: break-all; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.share-box img.share-qr { width: 180px; height: 180px; align-self: center; background: #fff; border-radius: 12px; padding: 8px; }
.share-box .row { display: flex; flex-wrap: wrap; gap: 8px; }
.warn { color: var(--bad); font-weight: 600; }
.qcard-tools button.on { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }

/* Командная игра */
.team-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 10px; }
.team-bar p { margin: 0; }
.team-select select { margin-left: 6px; padding: 6px 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font-size: 15px; }
.team-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.team-col { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; padding: 10px; border-radius: 14px; border: 2px solid var(--tc); background: color-mix(in srgb, var(--tc) 10%, var(--card)); }
.team-col > b { width: 100%; }
.team-col .chip { cursor: pointer; font: inherit; color: var(--ink); }
.team-board { display: flex; flex-direction: column; gap: 8px; }
.team-row { display: grid; grid-template-columns: 32px minmax(120px, 1.2fr) 2fr auto auto; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: 14px; background: var(--card); box-shadow: var(--shadow); border-left: 6px solid var(--tc); }
.team-row .team-name { font-weight: 800; }
.team-bar-fill { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--tc) 18%, transparent); overflow: hidden; }
.team-bar-fill i { display: block; height: 100%; background: var(--tc); border-radius: 99px; transition: width .6s ease; }
.team-pick { margin-top: 18px; }
.team-pick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: 16px; font: inherit; font-weight: 700;
  color: var(--ink); background: color-mix(in srgb, var(--tc) 12%, var(--card)); border: 2px solid color-mix(in srgb, var(--tc) 50%, transparent); }
.team-btn.mine { border: 4px solid var(--tc); background: color-mix(in srgb, var(--tc) 28%, var(--card)); }
.team-btn .team-emoji { font-size: 32px; }
@media (max-width: 560px) { .team-row { grid-template-columns: 28px 1fr auto; } .team-row .team-bar-fill, .team-row .muted { display: none; } }
/* Окно «Поделиться»: как окно поиска фото — видно только открытым. */
.share-dlg[open] { gap: 12px; }
.report td.num { white-space: nowrap; }
.assign-list { display: flex; flex-direction: column; gap: 8px; }
.assign-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.share-box .btn.small { display: inline-flex; align-items: center; text-decoration: none; }
.qcard-assign { right: 54px; }
#ai-audience, #ai-text { width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; resize: vertical; }
/* ИИ: уровень и класс — как остальные поля окна, крупно: это главный выбор после темы. */
#ai-level, #ai-class { padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
#ai-class { min-width: 120px; }

.team-rename { border: 0; background: none; cursor: pointer; font-size: 15px; padding: 2px 4px; margin-left: 2px; border-radius: 8px; }
.team-rename:hover, .team-rename:focus-visible { background: color-mix(in srgb, var(--tc) 20%, transparent); }

/* Звук на экране ведущего: кнопка 🔊/🔇 в углу, не мешает игре. */
.sound-toggle { position: fixed; left: 14px; bottom: 14px; z-index: 50; width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow); font-size: 20px; line-height: 44px; text-align: center; }
.sound-toggle.inline { position: static; align-self: center; margin-top: 4px; box-shadow: none; }

/* Сохранённый отчёт /r/<id> */
.rep { max-width: 860px; margin: 0 auto; gap: 14px; }
.rep h2 { margin: 18px 0 6px; }
.rep-head h1 { margin: 2px 0; }
.rep-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.rep-sum { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.rep-sum > div:first-child { display: flex; flex-direction: column; }
.rep-big { font-size: 40px; font-weight: 800; line-height: 1; }
@media (max-width: 560px) { .rep-sum { grid-template-columns: 1fr; } }
.rep-q { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.rep-q h3 { margin: 0; font-size: 18px; line-height: 1.3; }
.rep-q-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.rep-share { font-weight: 700; color: var(--ok); }
.rep-share.bad { color: var(--bad); }
.rep-bars { display: flex; flex-direction: column; gap: 6px; }
.rep-bar { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--bg); overflow: hidden; }
.rep-bar-fill { position: absolute; inset: 0 auto 0 0; opacity: 0.28; }
.rep-bar[data-i="0"] .rep-bar-fill { background: var(--a); } .rep-bar[data-i="1"] .rep-bar-fill { background: var(--b); }
.rep-bar[data-i="2"] .rep-bar-fill { background: var(--c); } .rep-bar[data-i="3"] .rep-bar-fill { background: var(--d); }
.rep-bar.right { outline: 2px solid var(--ok); }
.rep-bar-label, .rep-bar-num { position: relative; }
.rep-bar-num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.rep-cloud { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-weight: 700; }
.rep-cloud sup { font-size: 11px; color: var(--muted); margin-left: 2px; }
.rep-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; }
.rep-table th, .rep-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.rep-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.saved-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; margin: 8px 0 12px;
  border-radius: 14px; background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.saved-box a { font-weight: 700; word-break: break-all; }

.rep-table th:first-child, .rep-table td:first-child { width: 48px; }

/* ---------- Темы игры (фон у ведущего, на большом экране и у игроков) ----------
   Фон — слой под страницей; поверх — тёмная палитра с полупрозрачными карточками, вопрос — на белой плашке,
   чтобы читался из конца зала и на проекторе. «plain» — без класса themed, как раньше. */
body.themed { --bg: transparent; --card: rgba(22, 18, 40, 0.78); --ink: #f6f2ff; --muted: rgba(255, 255, 255, 0.8);
  --line: rgba(255, 255, 255, 0.2); --shadow: 0 8px 28px rgba(0, 0, 0, 0.35); color: var(--ink); background: #2a1d6e; }
body.themed::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
body.themed .host-q, body.themed .q-text, body.themed #r-text {
  background: #fff; color: #1f1a2e; padding: 14px 20px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); }
body.themed input, body.themed textarea, body.themed select { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
body.themed .qprog-track { background: rgba(255, 255, 255, 0.28); }
body.themed .big, body.themed h1, body.themed h2 { text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35); }

body[data-theme="batut"] { background: #4b2fd6; }
body[data-theme="batut"]::before { background: url('/themes/batut.svg'); }
body[data-theme="jump"] { background: linear-gradient(135deg, #3a22b8 0%, #6a3df0 100%); }
body[data-theme="jump"]::before { background: url('/themes/jump.png') no-repeat right -2vw bottom -6vh / auto 92vh; opacity: 0.28; }
body[data-theme="photo"] { background: #120e1f; }
body[data-theme="photo"]::before { background: linear-gradient(rgba(12, 9, 24, 0.5), rgba(12, 9, 24, 0.62)), var(--theme-img) center / cover;
  filter: blur(3px); transform: scale(1.03); }
body[data-theme="newyear"] { background: linear-gradient(160deg, #0d3b2a 0%, #14532d 55%, #5a1420 100%) fixed; }
body[data-theme="newyear"]::before { background: url('/themes/newyear.svg'); }
body[data-theme="winter"] { background: radial-gradient(ellipse at top, #1d3b73 0%, #0b1530 70%) fixed; }
body[data-theme="winter"]::before { background: url('/themes/winter.svg'); }
body[data-theme="spring"] { background: linear-gradient(135deg, #c93a6e 0%, #e9774f 100%) fixed; }
body[data-theme="spring"]::before { background: url('/themes/spring.svg'); }
body[data-theme="halloween"] { background: linear-gradient(160deg, #2b1240 0%, #4a1f3f 100%) fixed; }
body[data-theme="halloween"]::before { background: url('/themes/halloween.svg'); }
body[data-theme="summer"] { background: linear-gradient(160deg, #0a7f99 0%, #129e8a 100%) fixed; }
body[data-theme="summer"]::before { background: url('/themes/summer.svg'); }

.theme-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.theme-pick select { width: auto; padding: 8px 12px; border-radius: 12px; }

body.themed .toast { background: #fff; color: #1f1a2e; }
