/* Party Jukebox — собственная визуальная система.
   Тема Телеграма используется только для выбора светлой/тёмной схемы. */

:root {
  color-scheme: dark;

  /* нейтраль */
  --ink:        #06060A;
  --surface:    rgba(255,255,255,.055);
  --surface-2:  rgba(255,255,255,.09);
  --stroke:     rgba(255,255,255,.10);
  --text:       #FFFFFF;
  --text-2:     rgba(255,255,255,.64);
  --text-3:     rgba(255,255,255,.52);
  --sheet-bg:   #101016;
  --scrim:      rgba(0,0,0,.62);

  /* акценты */
  --brand:      #8B7BFF;
  --brand-2:    #E06BD9;
  --up:         #5BE49B;
  --down:       #FF6B81;

  /* атмосфера (пишет JS) */
  --glow:       rgba(139,123,255,.35);
  --atmos:      radial-gradient(120% 80% at 50% -10%, rgba(139,123,255,.30), transparent 62%);

  /* ритм */
  --cover: min(62vw, 252px);
  --g: 20px;              /* боковые поля */
  --r: 16px;
  --tap: 44px;
  --app-h: var(--tg-viewport-stable-height, 100dvh);
  --top-pad: max(var(--tg-content-safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --bot-pad: max(var(--tg-safe-area-inset-bottom, 0px), 10px);
}

body.light {
  color-scheme: light;
  --ink:        #F4F1EE;
  --surface:    rgba(16,12,24,.05);
  --surface-2:  rgba(16,12,24,.09);
  --stroke:     rgba(16,12,24,.10);
  --text:       #14111B;
  --text-2:     rgba(20,17,27,.64);
  --text-3:     rgba(20,17,27,.65);
  --sheet-bg:   #FFFFFF;
  --scrim:      rgba(20,17,27,.35);
  --brand:      #6A4CFF;
  --brand-2:    #C0349F;
  --up:         #0A6B45;
  --down:       #AE1130;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  /* .atmos вылезает за края нарочно, слой градиента шире экрана — но тянуть
     за собой горизонтальный скролл он не должен */
  max-width: 100%;
  overflow-x: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body {
  /* свой контекст наложения: иначе непрозрачный фон body закрывает слой атмосферы */
  isolation: isolate;
  height: var(--app-h);
  overflow: hidden;              /* страница не скроллится — скроллится .scroll */
}

/* Настоящий скроллер вместо тела документа.
   В Телеграме вертикальный жест поверх тела страницы забирает себе клиент:
   тянет окно приложения вниз, а страница в это время стоит — отсюда «скролл
   работает через раз». Внутри элемента с собственной прокруткой клиент жест
   не перехватывает, и вместе с disableVerticalSwipes это единственная пара,
   которая держится на всех клиентах. */
.scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-top: var(--top-pad);
  padding-bottom: calc(var(--bot-pad) + 16px);
}

button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2, p { margin: 0; }
.hidden { display: none !important; }

/* ── атмосфера ───────────────────────────────────────────── */
.atmos {
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 120%;
  z-index: -1;
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.atmos.on { opacity: 1; }

/* ── иконки ──────────────────────────────────────────────── */
.icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-xl { width: 34px; height: 34px; stroke-width: 1.4; }
.ic-fill { fill: currentColor; stroke: none; }

/* ── шапка ───────────────────────────────────────────────── */
.top {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  height: 52px; padding: 0 12px 0 var(--g);
}
.live {
  display: flex; align-items: center; gap: 8px;
  flex: none;
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-2);
}
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 0 var(--up);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(1);   opacity: 1; }
  70%  { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}
.icon-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: 50%; color: var(--text-2);
  transition: transform .15s ease, opacity .15s ease;
}
.icon-btn:active { transform: scale(.9); opacity: .6; }
.top-actions { display: flex; align-items: center; margin-left: auto; }
/* пустой, пока связь есть: иначе gap шапки оставляет дыру после пульса */
#live-text:empty { display: none; }

/* Лица тех, кто сейчас на вечеринке. Стопкой внахлёст — так десять человек
   занимают столько же места, сколько четверо, а шапка не разъезжается. */
.faces { display: flex; align-items: center; min-width: 0; }
.faces .av { width: 26px; height: 26px; font-size: 10px; box-shadow: 0 0 0 2px var(--ink); }
.faces .av + .av { margin-left: -9px; }
.faces .more {
  margin-left: 6px; padding: 0 7px; height: 26px;
  display: grid; place-items: center;
  border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  font-size: 11px; font-weight: 700; box-shadow: 0 0 0 2px var(--ink);
}

/* Маленькая метка в строке очереди: «Вперёд?» на своём треке или «ждёт админа».
   Живёт в подписи, а не в блоке голосов, — там на узком экране уже тесно. */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  font-size: 11px; font-weight: 700; vertical-align: middle;
}
.chip .ic { width: 12px; height: 12px; }
.chip-btn { color: var(--brand-2); }
.chip-btn:active { opacity: .6; }

/* Оценка играющего: стоит над действиями и крупнее очереди — это главный
   трек в комнате, и реакция на него должна быть в один тап.
   z-index обязателен: у героя завеса на слое 2, и всё, что не поднято выше,
   просто не видно (список поднятых — рядом с .hero-veil). */
.hero-votes {
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.hero-votes .vote { width: 50px; height: 50px; position: relative; flex: none; }
/* Счёт — бейджем на кнопке лайка, а не отдельной колонкой: строка и так
   занята именем, а ещё одна цифра посередине её разрывает. */
.hero-votes .score {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; padding: 0 5px; height: 18px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--surface-2); font-size: 11px; font-weight: 800;
}
.hero-votes .score:empty { display: none; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: stretch; }

/* Тумблер «анонимно» под строкой поиска: выключенный — обычная бледная
   таблетка, включённый горит, потому что он липкий и человек должен видеть,
   что всё ещё ставит втихую. */
.anon-toggle { margin: 10px 0 0; }
.anon-toggle.on { background: var(--brand); border-color: transparent; color: #fff; }

/* Блок «На экран»: эмодзи и строка — это одно и то же действие, крикнуть в зал.
   Стоит сразу под главной кнопкой, до очереди: пока человек смотрит на экран,
   он и реагирует, а листать до конца списка ради этого никто не будет. */
/* Пока слово не названо, гость всё видит, но ничего не может: объясняем это
   один раз сверху, а не отказом на каждое нажатие. */
.gate {
  margin: 0 var(--g) 6px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--stroke);
  font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--text-2);
}

.stage-box { padding: 18px var(--g) 0; }
.reacts {
  display: flex; gap: 6px; align-items: center;
  margin: 10px 0 8px;
}
.reacts button, .reacts input {
  flex: 1; min-width: 0; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px; border: 1px solid var(--stroke);
  background: var(--surface);
  font-size: 19px; line-height: 1; text-align: center;
  transition: transform .14s ease, background .14s ease;
}
.reacts button:active { transform: scale(.86); background: var(--surface-2); }
.reacts input {
  flex: 0 0 46px; color: var(--text-2); font-size: 17px; font-weight: 700;
  caret-color: var(--brand);
}

/* Строка крика: тот же .field, что у поиска, плюс кнопка отправки. */
.shout-field { gap: 8px; }
.shout-field input {
  flex: 1; min-width: 0; height: 100%;
  background: none; border: 0; color: var(--text); font: inherit; font-size: 15px;
}
.shout-field input::placeholder { color: var(--text-3); }
.send {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--surface-2); color: var(--brand-2);
  transition: transform .15s ease, opacity .15s ease;
}
.send:active { transform: scale(.88); }
.send:disabled { opacity: .4; }
.reacts input::placeholder { color: var(--text-3); }

/* Летящие эмодзи. Слой поверх всего, кликам не мешает. */
.fx { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.fx span {
  position: absolute; bottom: 12vh;
  font-size: 30px; line-height: 1;
  animation: fly var(--life, 3.4s) cubic-bezier(.3,.1,.5,1) forwards;
}
@keyframes fly {
  0%   { opacity: 0; transform: translateY(0)     scale(.5)  rotate(0deg); }
  14%  { opacity: 1; transform: translateY(-8vh)  scale(1.05) rotate(var(--tilt, 8deg)); }
  100% { opacity: 0; transform: translateY(-62vh) scale(.9)  rotate(calc(var(--tilt, 8deg) * -1.5)); }
}
.ghost-icon { flex: none; padding-left: 14px; padding-right: 14px; }
.ctl-wide { width: 100%; }

/* Текст песни приходит с переносами как есть — их и уважаем, но переполнять
   экран по горизонтали длинной строке не даём. */
.lyrics {
  margin: 0; font: inherit; font-size: 15px; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}

/* Караоке. Текущая строка наливается слева направо ровно за свою длительность
   (она приходит вместе с таймингом), спетое гаснет, будущее ждёт приглушённым и
   чуть размытым — взгляд сам держится за одну строку, а не ищет её в простыне.
   Налив — это анимация, а не таймер: браузер двигает её сам по кадрам, и на
   паузе она замирает вместе с музыкой. */
.karaoke { padding: 8vh 0 26vh; display: grid; gap: 2px; text-align: left; }
.karaoke .ln {
  margin: 0; padding: 8px 0;
  font-size: clamp(21px, 5.8vw, 27px);
  font-weight: 800; letter-spacing: -.022em; line-height: 1.22;
  overflow-wrap: anywhere;
  color: var(--text-3); opacity: .34;
  filter: blur(.7px);
  transform: scale(.975); transform-origin: left center;
  transition: opacity .38s ease, transform .38s ease, color .38s ease, filter .38s ease;
}
.karaoke .ln.past { opacity: .26; filter: none; }
.karaoke .ln.on {
  opacity: 1; filter: drop-shadow(0 0 22px var(--glow));
  transform: scale(1); color: var(--text);
}

/* Налив: одна картинка в две полосы шириной в два экрана — двигаем её, и
   граница между спетым и неспетым едет по строке. */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .karaoke .ln.on:not(.inst) {
    background-image: linear-gradient(90deg, var(--text) 0 50%, var(--text-3) 50%);
    background-size: 200% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text; background-clip: text;
    color: transparent; -webkit-text-fill-color: transparent;
    animation: kar-fill var(--dur, 3s) linear forwards;
  }
}
@keyframes kar-fill { to { background-position: 0 0; } }

/* Проигрыш YT Music отдаёт строкой «♪» — показываем его тремя точками, как
   это делают все плееры: видно, что караоке живо, а петь пока нечего. */
.karaoke .ln.inst { font-size: 0; padding: 14px 0; }
.karaoke .ln.inst i {
  display: inline-block; width: 9px; height: 9px; margin-right: 8px;
  border-radius: 50%; background: currentColor;
}
.karaoke .ln.inst.on i { animation: kar-dot 1.2s ease-in-out infinite; }
.karaoke .ln.inst.on i:nth-child(2) { animation-delay: .16s; }
.karaoke .ln.inst.on i:nth-child(3) { animation-delay: .32s; }
@keyframes kar-dot {
  0%, 100% { transform: translateY(0);    opacity: .45; }
  50%      { transform: translateY(-5px); opacity: 1; }
}

body.paused .karaoke .ln.on { animation-play-state: paused; }
body.paused .karaoke .ln.inst.on i { animation-play-state: paused; }

/* связь пропала: пульс замирает и краснеет — «эфир» без этого врёт */
.top.offline .pulse { background: var(--down); animation: none; opacity: .8; }
.top.offline .live { color: var(--down); }

/* ── герой ───────────────────────────────────────────────── */
.hero { padding: 4px var(--g) 24px; text-align: center; }
/* обложка, разлитая по фону: крупная цветная плоскость, текста на ней нет */
.stack { position: relative; isolation: isolate; }
.hero-art {
  position: absolute; left: -30%; right: -30%; top: -22px; z-index: 1;
  width: 160%; height: calc(var(--cover) + 130px);
  object-fit: cover;
  filter: blur(46px) saturate(1.7);
  opacity: .62;
  transform: scale(1.05);
  -webkit-mask-image: radial-gradient(60% 52% at 50% 40%, #000 38%, transparent 100%);
  mask-image: radial-gradient(60% 52% at 50% 40%, #000 38%, transparent 100%);
  pointer-events: none;
}
/* подложка под текстом: что бы ни светилось выше, под буквами — ровный фон,
   поэтому контраст текста здесь константа, а не лотерея */
.hero-veil {
  position: absolute; left: -50vw; right: -50vw; top: 0; bottom: -26px; z-index: 2;
  background: linear-gradient(to bottom,
    transparent calc(var(--cover) - 44px), var(--ink) calc(var(--cover) + 22px));
  pointer-events: none;
}
.hero-title, .hero-sub, .hero-by, .bar, .times, .ghost, .hero-votes,
.whose { position: relative; z-index: 3; }
body.light .hero-art { opacity: .5; }
.stack { display: flex; flex-direction: column; align-items: center; }

.cover {
  position: relative; z-index: 1;
  width: var(--cover);
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--text-3);
  box-shadow: 0 30px 80px -24px var(--glow), 0 0 120px -30px var(--glow), 0 2px 10px rgba(0,0,0,.4);
  will-change: transform;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* «Живая» обложка вместо спотифаевского Canvas: медленный наезд на саму
   картинку и встречный дрейф размытого фона. Периоды разные и взаимно
   непростые, поэтому рисунок не повторяется за вечер и не выглядит петлёй.
   Бита тут нет и быть не может — звук играет на хосте, а не в телефоне гостя.
   ponytail: дыхание вместо такта; настоящий бит потребовал бы слать уровень
   громкости в состояние и городить анализ на сервере. */
@keyframes cover-breathe {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to   { transform: scale(1.09) translate3d(-1.5%, -1.5%, 0); }
}
@keyframes drift {
  from { transform: scale(1.05) translate3d(-2%, 0, 0); }
  to   { transform: scale(1.22) translate3d(2%, -3%, 0); }
}
.cover img { animation: cover-breathe 19s ease-in-out infinite alternate; }
.hero-art  { animation: drift 31s ease-in-out infinite alternate; }
/* на паузе картинка замирает — иначе экран врёт, что всё идёт своим чередом */
body.paused .cover img, body.paused .hero-art { animation-play-state: paused; }

.hero-title {
  margin: 22px 0 0;
  font-size: clamp(25px, 7.4vw, 34px);
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.12;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-sub {
  margin: 8px 0 0;
  font-size: 16px; font-weight: 500;
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

.hero-by {
  display: inline-flex; align-items: center; gap: 9px;
  margin: 14px 0 0;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  max-width: 100%;
}
.hero-by-text { display: flex; flex-direction: column; text-align: left; min-width: 0; }
.hero-by-text b { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-by-text i { font-size: 11px; font-style: normal; color: var(--text-2); letter-spacing: .02em; }

.bar {
  width: 100%; height: 4px; margin: 18px 0 0;
  border-radius: 999px; overflow: hidden;
  background: var(--surface-2);
}
.bar span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transform: scaleX(0); transform-origin: left center;
  transition: transform .3s linear;
}
.times {
  display: flex; justify-content: space-between; width: 100%;
  margin-top: 7px;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.ghost {
  display: inline-flex; align-items: center; gap: 8px;
  height: var(--tap); margin-top: 16px; padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  font-size: 14px; font-weight: 700;
  transition: transform .15s ease, opacity .15s ease;
}
.ghost:active { transform: scale(.96); }
.ghost.voted { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.ghost:disabled { opacity: .5; }

/* ── «Дальше» ────────────────────────────────────────────── */
.next { position: relative; z-index: 4; padding: 0 var(--g); }
.rail {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 2px 12px;
}
.rail h2 {
  font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-2);
}
.rail .count { font-size: 13px; font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }

.list { display: flex; flex-direction: column; gap: 4px; }

.row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 8px 7px 7px;
  border-radius: 14px;
  background: var(--surface);
  will-change: transform;
}
.row-plain { background: none; padding-left: 0; padding-right: 0; }

.media { position: relative; width: 46px; height: 46px; flex: none; }
.media img, .media .ph {
  width: 46px; height: 46px; border-radius: 11px; object-fit: cover; display: block;
  background: var(--surface-2);
}
.media .ph { display: grid; place-items: center; color: var(--text-3); }
.av {
  /* инициалы — подложка под фото, а не строка над ним: в grid они встали бы
     двумя рядами (буквы сверху, аватарка снизу) */
  position: relative;
  display: grid; place-items: center; overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, #6A4CFF, #B3309A);   /* белые инициалы проходят 4.5:1 */
  color: #fff; font-weight: 800; font-size: 11px;
  flex: none;
  /* размер задаёт носитель (.av-lg, .av-badge, родительское правило), а круглым
     лицо остаётся само: без этого аватарка в новом месте схлопывается по
     инициалам и расплющивается по ширине ячейки */
  aspect-ratio: 1;
}
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.av-badge {
  position: absolute; right: -4px; bottom: -4px;
  width: 21px; height: 21px;
  box-shadow: 0 0 0 2.5px var(--ink);
}
.av-lg { width: 32px; height: 32px; font-size: 13px; }

.meta { min-width: 0; }
.meta .t {
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Подпись строки: артист и автор ужимаются многоточием, а «через ~12 мин»
   не должно исчезать — это главный вопрос гостя, ради него список и открывают. */
.meta .s {
  margin-top: 2px;
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.meta .s .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .s .eta { flex: none; color: var(--text-3); }
/* Свой трек: до него и хочется знать, сколько ждать */
.meta .s .eta.mine { color: var(--brand); font-weight: 700; }
.meta .acts { display: flex; gap: 6px; margin-top: 5px; }

/* голоса: палец вверх / вниз, счёт только когда он не ноль */
.votes { display: flex; align-items: center; gap: 0; }
.vote {
  width: 40px; height: var(--tap);
  display: grid; place-items: center;
  color: var(--text-3);
  transition: transform .15s ease, color .15s ease;
}
.vote:active { transform: scale(.85); }
.vote.on[data-v="1"]  { color: var(--up); }
.vote.on[data-v="-1"] { color: var(--down); }
.vote.on .ic { fill: currentColor; stroke: currentColor; }
.score {
  min-width: 18px; text-align: center;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.score.pos { color: var(--up); }
.score.neg { color: var(--down); }
.score:empty { min-width: 10px; }   /* ноля нет — нечего показывать */

/* ── главная кнопка: в потоке, чтобы ничего не перекрывать ── */
.cta {
  width: calc(100% - 2 * var(--g));
  margin: 0 var(--g) 10px;
  height: 54px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: 18px;
  font-size: 16px; font-weight: 800; letter-spacing: -.01em;
  color: #fff;
  /* цвета зафиксированы тёмными: белый текст на них проходит 4.5:1 в обеих темах */
  background: linear-gradient(120deg, #6A4CFF, #B3309A);
  box-shadow: 0 14px 36px -12px rgba(106,76,255,.8), 0 1px 0 rgba(255,255,255,.18) inset;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), opacity .18s ease;
}
.cta:active { transform: scale(.975); }


/* ── шторки ──────────────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 40; visibility: hidden; }
.sheet.open { visibility: visible; }
.sheet .scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  opacity: 0; transition: opacity .3s ease;
}
.sheet.open .scrim { opacity: 1; }

.sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  /* меряем от .sheet (position: fixed; inset: 0), то есть от реально видимой
     области, а не от --tg-viewport-stable-height: тот бывает больше экрана,
     и тогда верх шторки уезжает за границу */
  max-height: calc(100% - 40px);
  height: calc(100% - 40px);
  background: var(--sheet-bg);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,.5);
  transform: translateY(100%);
  transition: transform .36s cubic-bezier(.22,.9,.24,1);
  will-change: transform;
}
.sheet.open .sheet-card { transform: none; }
.sheet.dragging .sheet-card { transition: none; }
#sheet-admin .sheet-card { height: auto; max-height: calc(100% - 40px); }

.grabber { height: 22px; display: grid; place-items: center; flex: none; touch-action: none; }
.grabber::before {
  content: ''; width: 38px; height: 4px; border-radius: 999px;
  background: var(--surface-2);
}
.sheet-head { padding: 4px var(--g) 12px; flex: none; touch-action: none; }
.sheet-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.sheet-body {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 var(--g) calc(var(--bot-pad) + 16px);
}

.field {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 12px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-3);
}
.field input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: none; outline: none;
  font-size: 16px; font-weight: 600; color: var(--text);
}
.field input::placeholder { color: var(--text-3); font-weight: 500; }
.field .clear { width: 32px; height: 32px; display: grid; place-items: center; color: var(--text-3); }

.add {
  width: 40px; height: var(--tap);
  display: grid; place-items: center;
  color: var(--brand);
  transition: transform .15s ease;
}
.add:active { transform: scale(.85); }
.add.done { color: var(--up); }
.add:disabled { opacity: .45; }

/* ── пульт ───────────────────────────────────────────────── */
.admin-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.where { display: grid; gap: 8px; margin: 10px 0 4px; }
.ctl {
  height: 66px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border-radius: 16px; background: var(--surface);
  font-size: 12px; font-weight: 700;
  transition: transform .15s ease;
}
.ctl:active { transform: scale(.95); }
.ctl.on { background: linear-gradient(120deg, #6A4CFF, #B3309A); color: #fff; }

.vol { display: block; margin-top: 18px; }
.rail-label {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  margin-bottom: 8px;
}
.rail-label b { color: var(--text); font-variant-numeric: tabular-nums; }
#vol {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: var(--tap); background: none;
}
#vol::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--surface-2); }
#vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.danger-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 50px; margin-top: 22px;
  border-radius: 16px;
  color: var(--down);
  background: color-mix(in srgb, var(--down) 12%, transparent);
  font-size: 15px; font-weight: 700;
}
.danger-btn:active { transform: scale(.98); }
.note { margin-top: 10px; font-size: 12.5px; color: var(--text-3); text-align: center; }

/* ── состояния ───────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 38px var(--g);
  color: var(--text-3); text-align: center;
  font-size: 14px; font-weight: 500;
}
.cover-empty { box-shadow: none; }

.skel {
  height: 60px; border-radius: 14px; background: var(--surface);
  animation: breathe 1.3s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity: .55 } 50% { opacity: 1 } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--bot-pad) + 72px); z-index: 60;
  padding: 11px 18px; border-radius: 999px;
  background: var(--sheet-bg);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  font-size: 14px; font-weight: 700;
  opacity: 0; transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none; max-width: calc(100% - 2 * var(--g));
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

#fatal {
  position: fixed; inset: 0; z-index: 70;
  justify-content: center;
  background: var(--ink);
}

@media (max-width: 374px) {
  :root { --g: 16px; }
  .hero-title { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.av-row { width: 46px; height: 46px; font-size: 15px; }
#search-state:empty { display: none; }

.field input::-webkit-search-cancel-button,
.field input::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* ── чей это трек ─────────────────────────────────────────── */
/* Пока играет анонимный трек, комната ставит на человека. Лента горизонтальная:
   людей на вечеринке десятки, а вертикальный список съел бы всю карточку. */
.whose {
  margin-top: 14px; padding: 12px 0 4px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.whose-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.whose-head b { font-size: 14px; font-weight: 800; }
.whose-head span { font-size: 12px; color: var(--dim); }
.whose-list {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.whose-list::-webkit-scrollbar { display: none; }
.whose-one {
  flex: none; display: grid; justify-items: center; gap: 6px;
  width: 72px; padding: 10px 4px; border: 0; border-radius: 14px;
  background: rgba(255,255,255,.05); color: inherit; cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
/* .av сам по себе без размеров — его задаёт носитель. Здесь лицо главное,
   по нему и целятся пальцем, поэтому оно крупное. */
.whose-one .av { width: 46px; height: 46px; font-size: 16px; }
.whose-one .nm {
  max-width: 100%; font-size: 11px; font-weight: 600; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.whose-one.on {
  background: rgba(180,140,255,.22); transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px rgba(180,140,255,.6);
}
.whose-one.on .nm { color: #fff; }
.whose-none { font-size: 12px; color: var(--dim); padding: 6px 2px; }

/* ── «Угадай мелодию» ────────────────────────────────────────
   Цвета вариантов те же, что на экране: «жми жёлтый» должно
   совпадать в руке и на телевизоре. Текст на них тёмный — белый
   на жёлтом и салатовом не читается. */
body.gaming #hero, body.gaming #open-search { display: none; }

.gm {
  --a: #FF5E7E; --b: #3DB9FF; --cc: #FFC43D; --d: #6FE39A;
  position: relative;
  margin: 4px var(--g) 22px; padding: 20px 16px 18px;
  border-radius: 26px; overflow: hidden;
  background:
    radial-gradient(90% 60% at 10% 0%, rgba(139,123,255,.38), transparent 70%),
    radial-gradient(80% 60% at 100% 100%, rgba(224,107,217,.30), transparent 70%),
    var(--surface);
  border: 1px solid var(--stroke);
}
.gm-hello { text-align: center; }
.gm-kicker {
  font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--text-3);
}
.gm-title {
  margin: 6px 0 0; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05;
  background: linear-gradient(100deg, var(--text) 20%, var(--brand) 60%, var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gm-sub { margin: 8px 0 0; font-size: 13.5px; color: var(--text-2); }

.gm-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.gm-round { font-size: 13px; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }

.gm-timer { height: 6px; margin: 14px 0; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.gm-timer i {
  display: block; height: 100%; transform-origin: left; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), #FFC43D);
}
.gm-timer i.hurry { background: var(--down); animation: gm-hurry .45s ease-in-out infinite alternate; }
@keyframes gm-hurry { to { opacity: .5; } }

/* голосование */
.gm-lists { display: grid; gap: 8px; }
.gm-list {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border-radius: 18px; text-align: left;
  background: var(--surface); border: 1.5px solid transparent;
  transition: transform .15s ease, border-color .2s ease, background .2s ease;
}
.gm-list:active { transform: scale(.98); }
.gm-list.on {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  box-shadow: 0 10px 30px -14px var(--brand);
}
.gm-emoji { font-size: 28px; line-height: 1; flex: none; }
.gm-list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gm-list-text b { font-size: 15px; font-weight: 800; }
.gm-list-text i { font-style: normal; font-size: 12px; color: var(--text-3); }
.gm-votes {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 99px; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--surface-2); font-variant-numeric: tabular-nums;
}
.gm-votes:empty { visibility: hidden; }

/* ожидание */
.gm-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 0 10px; color: var(--text-2); font-weight: 700; }
.gm-wait p { margin: 0; }
.gm-eq { display: flex; align-items: flex-end; gap: 5px; height: 40px; }
.gm-eq i {
  width: 8px; height: 100%; border-radius: 99px; transform-origin: bottom;
  background: linear-gradient(0deg, var(--brand), var(--brand-2));
  animation: gm-eq .8s ease-in-out infinite alternate;
}
.gm-eq i:nth-child(2n) { animation-duration: .55s; }
.gm-eq i:nth-child(3n) { animation-duration: 1.1s; animation-delay: -.3s; }
@keyframes gm-eq { from { transform: scaleY(.2); } to { transform: scaleY(1); } }

/* раунд: четыре крупные кнопки, палец попадает не глядя */
.gm-ask { margin: 0 0 12px; text-align: center; font-size: 17px; font-weight: 800; }
.gm-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gm-opt {
  --c: var(--a);
  position: relative; min-height: 104px; width: 100%;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 12px; border-radius: 20px; text-align: left;
  background: var(--c); color: #0B0A14;
  box-shadow: 0 -4px 0 rgba(0,0,0,.18) inset, 0 12px 28px -16px var(--c);
  transition: transform .15s ease, opacity .3s ease, filter .3s ease;
}
.gm-opt[data-letter="B"] { --c: var(--b); }
.gm-opt[data-letter="C"] { --c: var(--cc); }
.gm-opt[data-letter="D"] { --c: var(--d); }
.gm-opt:active:not(:disabled) { transform: scale(.95) translateY(2px); }
.gm-opt:disabled { cursor: default; }
.gm-letter {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px;
  background: rgba(11,10,20,.16); font-size: 15px; font-weight: 900;
}
.gm-opt-text { display: flex; flex-direction: column; min-width: 0; width: 100%; }
.gm-opt-text b {
  font-size: 14.5px; font-weight: 800; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gm-opt-text i { font-style: normal; font-size: 12px; font-weight: 600; opacity: .72;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-opt.dim { opacity: .28; filter: saturate(.4); }
.gm-opt.picked { transform: scale(1.02); box-shadow: 0 0 0 3px var(--text), 0 14px 34px -12px var(--c); }
.gm-opt.picked::after { content: "✓"; position: absolute; top: 10px; right: 12px; font-weight: 900; font-size: 18px; }

.gm-options-small .gm-opt { min-height: 0; flex-direction: row; align-items: center; padding: 8px 10px; border-radius: 14px; }
.gm-options-small .gm-letter { width: 24px; height: 24px; font-size: 12px; border-radius: 8px; flex: none; }
.gm-options-small .gm-opt-text b { font-size: 12.5px; -webkit-line-clamp: 1; }
.gm-opt.right { box-shadow: 0 0 0 3px var(--up), 0 0 26px -4px var(--up); }
.gm-opt.right::after { content: "✓"; margin-left: auto; font-weight: 900; }
.gm-opt.wrong { opacity: .55; }
.gm-opt.wrong::after { content: "✕"; margin-left: auto; font-weight: 900; }

/* вскрытие */
.gm-verdict {
  margin: 10px 0 14px; text-align: center; font-size: 44px; font-weight: 800; letter-spacing: -.03em;
  animation: gm-pop .6s cubic-bezier(.2,1.6,.4,1) backwards;
}
.gm-verdict.hit { color: var(--up); text-shadow: 0 0 30px color-mix(in srgb, var(--up) 60%, transparent); }
.gm-verdict.miss { color: var(--down); font-size: 30px; }
.gm-verdict.skip { color: var(--text-2); font-size: 26px; }
@keyframes gm-pop { from { transform: scale(.3); opacity: 0; } }
.gm-answer { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gm-answer img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; flex: none; }
.gm-answer div { display: flex; flex-direction: column; min-width: 0; }
.gm-answer i { font-style: normal; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.gm-answer b { font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-answer span { font-size: 13px; color: var(--text-2); }

.gm-mine { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--text-2); }
.gm-mine b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }

/* финал */
.gm-board { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.gm-board li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px;
  background: var(--surface); font-weight: 700;
}
.gm-board li.me { background: color-mix(in srgb, var(--brand) 22%, transparent); box-shadow: inset 0 0 0 1.5px var(--brand); }
.gm-board li em { font-style: normal; width: 18px; text-align: center; color: var(--text-3); font-weight: 800; }
.gm-board li:nth-child(1) em { color: #E0A93A; }
.gm-board li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-board li b { font-variant-numeric: tabular-nums; }
.gm-board .empty-row { justify-content: center; color: var(--text-3); }

/* игры не про музыку: гости, карточка, места */
.gm-people { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gm-person {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0;
  padding: 10px 6px; border-radius: 18px; background: var(--surface); border: 1.5px solid transparent;
  font-size: 12.5px; font-weight: 700; transition: transform .15s ease, border-color .2s ease, background .2s ease;
}
.gm-person:active { transform: scale(.95); }
.gm-person span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-person em { font-style: normal; font-size: 10.5px; color: var(--down); }
.gm-person.on {
  border-color: var(--brand); background: color-mix(in srgb, var(--brand) 20%, transparent);
  box-shadow: 0 10px 26px -14px var(--brand);
}
.gm-card {
  position: relative; display: grid; width: 100%; min-height: 150px; margin: 4px 0 0;
  border-radius: 22px; background: var(--surface-2); border: 1.5px dashed var(--stroke); text-align: center;
}
.gm-card > span { grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 16px; transition: opacity .25s ease, transform .35s cubic-bezier(.2,1.4,.4,1); }
.gm-card-back { color: var(--text-2); font-weight: 700; }
.gm-card-face { opacity: 0; transform: scale(.9); }
.gm-card.open { border-style: solid; border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--surface)); }
.gm-card.open .gm-card-back { opacity: 0; }
.gm-card.open .gm-card-face { opacity: 1; transform: none; }
.gm-card-emoji { font-size: 44px; line-height: 1; }
.gm-card-face b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.gm-card-face i { font-style: normal; font-size: 13px; color: var(--text-2); }
.gm-places { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-place { padding: 8px 12px; border-radius: 99px; background: var(--surface); font-size: 13px; font-weight: 700; }
.gm-place:active { transform: scale(.95); }
.gm-winners { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin: 6px 0 10px; }
.gm-winners span { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gm-winners b { font-size: 15px; }
.gm-winners i { font-style: normal; font-size: 12px; color: var(--text-3); }
.gm-say { margin: 12px 0; text-align: center; font-size: 19px; font-weight: 800; line-height: 1.3; }
.gm-sleep { padding: 30px 0 20px; text-align: center; font-size: 54px; }
.gm-sleep p { margin: 10px 0 0; font-size: 16px; font-weight: 700; color: var(--text-2); }
.gm-board li.dead { opacity: .5; }
.gm-board li.dead .nm { text-decoration: line-through; }

/* пульт: переключатель режимов */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#mode-music { grid-column: 1 / -1; min-height: 84px; }
.mode-tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 14px; min-height: 118px; border-radius: 20px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--stroke);
  transition: transform .15s ease, border-color .25s ease, box-shadow .25s ease;
}
.mode-tile:active { transform: scale(.97); }
.mode-emoji { font-size: 30px; line-height: 1; margin-bottom: auto; transition: transform .4s cubic-bezier(.2,1.6,.4,1); }
.mode-tile b { font-size: 15px; font-weight: 800; line-height: 1.15; }
.mode-tile i { font-style: normal; font-size: 11.5px; color: var(--text-3); line-height: 1.25; }
.mode-tile.on {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #6A4CFF, #B3309A);
  box-shadow: 0 16px 36px -16px rgba(106,76,255,.9);
}
.mode-tile.on i { color: rgba(255,255,255,.78); }
.mode-tile.on .mode-emoji { transform: scale(1.18) rotate(-8deg); }
.mode-tile.on::after {
  content: "сейчас"; position: absolute; top: 12px; right: 12px;
  padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.2);
  font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.game-next {
  margin-top: 8px; height: 50px; flex-direction: row; font-size: 14px;
  background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand);
}

/* «Найди песню»: полоска отрывков и поиск с подсказками */
.gm-stages { display: flex; gap: 4px; margin-bottom: 12px; }
.gm-stages i {
  display: grid; place-items: center; height: 30px; min-width: 34px; border-radius: 10px;
  font-style: normal; font-size: 11.5px; font-weight: 800; color: var(--text-3);
  background: var(--surface); transition: background .3s ease, color .3s ease;
}
.gm-stages i.done { background: var(--surface-2); color: var(--text-2); }
.gm-stages i.now { color: #fff; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.gm-q {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 16px; box-sizing: border-box;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--stroke); outline: none;
}
.gm-q:focus { border-color: var(--brand); }
.gm-hits { display: grid; gap: 6px; margin-top: 8px; }
.gm-hit {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%;
  padding: 10px 14px; border-radius: 14px; text-align: left; background: var(--surface);
  transition: transform .15s ease;
}
.gm-hit:active:not(:disabled) { transform: scale(.98); }
.gm-hit b { font-size: 14.5px; font-weight: 800; }
.gm-hit i { font-style: normal; font-size: 12px; color: var(--text-3); }
.gm-hits .gm-none { padding: 10px 4px; font-size: 13px; color: var(--text-3); }
.gm-src {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; vertical-align: 2px;
  font-style: normal; font-size: .72em; font-weight: 800; background: rgba(11,10,20,.14);
}

@media (prefers-reduced-motion: reduce) {
  .gm-eq i, .gm-timer i.hurry, .gm-verdict { animation: none; }
}

/* режим сменился — карточка игры или плеер проявляются, а не выскакивают
   (display:none → block перезапускает анимацию сама) */
#hero, .gm { animation: gm-in .45s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes gm-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { #hero, .gm { animation: none; } }
