/* Визуально — как веб-версия TikTok: чёрный фон, TikTok Sans, красный только для главных действий. */
:root {
  --bg: #000;
  --panel: #121212;
  --fill: rgba(255, 255, 255, .08);
  --fill-hover: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .12);
  --text: rgba(255, 255, 255, .92);
  --muted: rgba(255, 255, 255, .5);
  --red: #fe2c55;
  --red-hover: #ff4569;
  --cyan: #25f4ee;
  --ok: #25f4ee;
  --warn: #ffc53d;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 "TikTok Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

#app { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

h2 { font-size: 18px; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 24px 0 8px; color: var(--muted); }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 20px; border: 0; border-radius: 4px; cursor: pointer;
  background: var(--fill); color: var(--text); font-weight: 600; font-size: 15px;
}
.btn:hover { background: var(--fill-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); }
.btn.text { background: none; height: auto; padding: 6px 4px; color: var(--muted); font-weight: 500; }
.btn.text:hover { color: var(--text); }
.btn.small { font-size: 13px; }
.btn.file { position: relative; overflow: hidden; margin: 4px 0 8px; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

input:not([type]), input[type=text], input[type=number] {
  height: 44px; padding: 0 12px; border: 1px solid transparent; border-radius: 4px;
  background: var(--fill); outline: none; width: 100%;
}
input:focus { border-color: var(--line); background: var(--fill-hover); }
input::placeholder { color: var(--muted); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Главная ---------- */
.home { max-width: 380px; margin: 0 auto; padding-top: 14vh; }
.title { font-size: 40px; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 32px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 8px; }
.field-label { font-weight: 600; }
.at { display: flex; align-items: center; background: var(--fill); border-radius: 4px; border: 1px solid transparent; }
.at:focus-within { border-color: var(--line); background: var(--fill-hover); }
.at > span { padding-left: 12px; color: var(--muted); }
.at input { background: none !important; border: 0 !important; padding-left: 2px; }
.or { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 0; }
.home .row { flex-wrap: nowrap; }
.home .row input { flex: 1; min-width: 0; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.code-input::placeholder { letter-spacing: normal; font-weight: 400; text-transform: none; }

/* ---------- Лобби ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.room { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.room-code {
  border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 28px; font-weight: 800; letter-spacing: .08em;
}
.room-code:hover { color: #fff; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.mode {
  flex: 0 0 200px; height: 44px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 17px; font-weight: 600; position: relative;
}
.mode.on { color: var(--text); }
.mode.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }
.mode:not(.on):not(:disabled):hover { color: var(--text); }
.mode:disabled { cursor: default; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 48px; align-items: start; }

.rows { list-style: none; margin: 0 0 12px; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 0; }
.rows li.offline { opacity: .4; }
.rows li + li { border-top: 1px solid var(--line); }
.who { flex: 1; min-width: 0; display: grid; text-align: left; }
.who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who b a { text-decoration: none; }
.who b a:hover { text-decoration: underline; }
.pill { color: var(--muted); font-size: 13px; white-space: nowrap; }
.pill.ok { color: var(--text); }

.host { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.host .btn.primary { flex: 1; }

.steps { background: var(--panel); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.steps p { margin: 0 0 8px; }
.steps ol { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 8px; }
.steps a:not(.bookmarklet) { color: var(--text); font-weight: 600; }
.bookmarklet {
  display: inline-block; margin-left: 4px; padding: 3px 10px; border-radius: 4px;
  background: var(--red); color: #fff; font-weight: 600; text-decoration: none; cursor: grab;
}

.list-head { display: flex; justify-content: space-between; align-items: center; min-height: 32px; color: var(--muted); font-size: 13px; }
.items { list-style: none; margin: 0 0 12px; padding: 0; max-height: 320px; overflow: auto; }
.items li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; border-top: 1px solid var(--line); font-size: 14px; }
.items li span, .items li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.items li a:hover { text-decoration: underline; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px 8px; font-size: 13px; }
.x:hover { color: var(--text); }

.ava { flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--fill); }

/* ---------- Игра: как страница видео в TikTok ---------- */
.progress { position: sticky; top: 0; z-index: 2; height: 2px; background: var(--line); margin: 0 -16px 24px; }
#timerBar { height: 100%; width: 100%; background: var(--text); }
#timerBar.hurry { background: var(--red); }
#timerBar.reveal { background: var(--muted); }

.stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 32px; align-items: start; }
.media { display: grid; gap: 10px; justify-items: center; width: min(420px, 100%); }
#player { width: 100%; aspect-ratio: 9 / 16; max-height: calc(100vh - 120px); border: 0; border-radius: 8px; background: #000; }
.media.with-comment #player { max-height: 52vh; }

.comment {
  width: 100%; background: var(--panel); border-radius: 8px; padding: 18px 20px;
  font-size: 22px; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere;
}
.comment::before { content: "Комментарий"; display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-bottom: 6px; }

.panel { min-width: 0; }
.panel-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 32px; }
.round-no { font-weight: 700; }
.votes { display: flex; gap: 12px; }
.btn.text.on { color: var(--red); }
.panel h2 { font-size: 24px; font-weight: 800; margin: 4px 0; }
.panel #rule { margin: 0 0 16px; }

.choices { display: grid; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px; margin: 0 -12px;
  border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left;
}
.choice:not(:disabled):hover { background: var(--fill); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.correct):not(.wrong):not(.picked) { opacity: .5; }
.choice::after {
  content: ""; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
}
.choice.picked::after { border-color: var(--text); background: radial-gradient(var(--text) 0 4px, transparent 5px); }
.choice.correct { background: rgba(37, 244, 238, .1); }
.choice.correct::after { content: "✓"; border: 0; background: var(--cyan); color: #000; }
.choice.wrong { background: rgba(254, 44, 85, .12); }
.choice.wrong::after { content: "✕"; border: 0; background: var(--red); color: #fff; }
.voters { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.voter { font-size: 12px; color: var(--muted); }
.voter + .voter::before { content: ", "; }

.send { width: 100%; margin-top: 12px; }
.choices.multi .choice::after { border-radius: 4px; }
.choices.multi .choice.picked::after { content: "✓"; border: 0; background: var(--text); color: #000; }
.status { min-height: 22px; margin: 16px 0 0; font-weight: 600; }

.scoreboard { list-style: none; margin: 0; padding: 0; }
.scoreboard li { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; }
.scoreboard li + li { border-top: 1px solid var(--line); }
.scoreboard .ava { width: 28px; height: 28px; }
.scoreboard li > span:first-of-type { flex: 1; }
.scoreboard b { font-weight: 700; min-width: 40px; text-align: right; }
.tick { color: var(--muted); font-size: 13px; }
.gain { color: var(--cyan); font-weight: 600; font-size: 13px; }
.gain.neg { color: var(--red); }

/* ---------- Сцена со счётом ---------- */
.scene {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.scene-inner { width: min(460px, 100%); }
.scene-inner h2 { font-size: 32px; font-weight: 800; margin: 2px 0 20px; }
.scene-list { list-style: none; margin: 0; padding: 0; position: relative; }
.scene-list li { display: flex; align-items: center; gap: 12px; min-height: 60px; background: var(--bg); }
.scene-list li + li { border-top: 1px solid var(--line); }
.scene-list .rank { width: 22px; color: var(--muted); font-weight: 700; text-align: center; }
.scene-list .name { flex: 1; min-width: 0; display: grid; }
.scene-list .name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-list .note { font-size: 12px; color: var(--muted); opacity: 0; }
.scene-list .chip { font-weight: 700; font-size: 14px; color: var(--cyan); opacity: 0; min-width: 52px; text-align: right; }
.scene-list .chip.neg { color: var(--red); }
.scene-list .chip.zero { color: var(--muted); }
.scene-list .total { font-size: 20px; font-weight: 800; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.scene-list.gains .note, .scene-list.gains .chip { opacity: 1; }
.scene-list li.up .rank { color: var(--cyan); }
.scene-list li.down .rank { color: var(--red); }

/* ---------- Итоги ---------- */
.over { max-width: 480px; margin: 0 auto; padding-top: 10vh; }
.podium { list-style: none; margin: 0 0 24px; padding: 0; }
.podium li { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.podium li + li { border-top: 1px solid var(--line); }
.podium li.winner .who b { font-size: 18px; }
.place { width: 28px; text-align: center; font-size: 20px; color: var(--muted); font-weight: 700; }
.pts { font-size: 20px; font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 10;
  background: #2f2f2f; color: #fff; padding: 12px 16px; border-radius: 8px; font-weight: 500;
}
.toast.bad { background: var(--red); }

/* ---------- Телефон ---------- */
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; gap: 32px; }
  .mode { flex: 1; }
  .hide-sm { display: none; }
  .stage { grid-template-columns: 1fr; gap: 20px; }
  .media { width: 100%; }
  #player { max-height: 52vh; }
  .media.with-comment #player { max-height: 36vh; }
  .title { font-size: 34px; }
  .home { padding-top: 10vh; }
}
@media (prefers-reduced-motion: no-preference) {
  .choice, .btn, .mode { transition: background-color .12s, color .12s; }
  .scene:not([hidden]) { animation: fade .3s ease-out; }
  .scene-list .note, .scene-list .chip { transition: opacity .35s; }
  @keyframes fade { from { opacity: 0; } }
}
