:root {
  --bg: #0d0e11;
  --panel: #16181d;
  --panel2: #1e2127;
  --border: #2a2d35;
  --text: #eceef2;
  --muted: #8b93a7;
  --accent: #ffd60a;         /* жёлтый акцент */
  --accent-hover: #ffe14d;
  --accent-ink: #201800;     /* тёмный текст на жёлтом */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen { max-width: 1200px; margin: 0 auto; padding: 20px; }
.hidden { display: none !important; }

h1 { text-align: center; margin: 32px 0 4px; font-size: 34px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 28px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
h2 .ic { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; color: var(--accent); }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- главный экран: профиль → действия → комнаты ---------- */

.home { max-width: 640px; }
.hero h1 { display: flex; align-items: center; justify-content: center; gap: 12px; }
.hero .sub { margin-bottom: 22px; }

.profile-card { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.profile-card h2 { margin-bottom: 6px; }
.profile-main { flex: 1; min-width: 0; }

/* две компактные карточки в одну линию */
.actions-row { display: flex; gap: 12px; margin-bottom: 14px; }
.actions-row .card {
  margin-bottom: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
}
.actions-row .card h2 { font-size: 13px; margin-bottom: 6px; }
.actions-row .hint { flex: 1; font-size: 12.5px; margin: 0 0 8px; color: var(--muted); }
@media (max-width: 519px) {
  .actions-row .hint { display: none; } /* на узких экранах — только суть */
}
.actions-row .row { gap: 8px; }
.actions-row .row input { min-width: 0; letter-spacing: .25em; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

input, button { font: inherit; }
input {
  width: 100%;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus { border-color: var(--accent); }
#joinCode { text-transform: uppercase; letter-spacing: .3em; text-align: center; }

button {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel2);
}
button:hover { background: #262c39; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover { background: var(--accent-hover); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { color: var(--text); background: var(--panel2); }
.big { font-size: 18px; padding: 12px 24px; }

.row { display: flex; gap: 10px; }
.row input { flex: 1; }

.rooms-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  cursor: pointer;
}
.room-item:hover { border-color: var(--accent); }
.room-item .code { font-weight: 700; letter-spacing: .15em; color: var(--accent); }
.room-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .cnt { color: var(--muted); font-size: 13px; }

/* ---------- комната ---------- */

.room-screen { max-width: 1400px; }
.room-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 14px;
}
.code-chip {
  font-weight: 700;
  letter-spacing: .2em;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--accent);
}
.video-name {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}
.spacer { flex: 1; }
.viewers { color: var(--muted); white-space: nowrap; }

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  height: calc(100vh - 84px);
  min-height: 0;
}

.player { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.video-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
video { max-width: 100%; max-height: 100%; width: 100%; }

.ic {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -.14em;
  flex-shrink: 0;
}
.crown { margin-left: 5px; color: var(--accent); }
.crown .ic { width: 11px; height: 11px; vertical-align: -1px; }

/* ---------- тап-зоны и оверлеи видео ---------- */

.video-wrap { touch-action: manipulation; }

.tapzone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
}
.tapzone.left { left: 0; width: 33%; }
.tapzone.center { left: 33%; width: 34%; }
.tapzone.right { right: 0; width: 33%; }

.seek-flash {
  position: absolute;
  top: 50%;
  z-index: 4;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  border-radius: 24px;
  background: rgba(10, 12, 16, .65);
  font-size: 15px;
  pointer-events: none;
  opacity: 0;
}
.seek-flash.show { animation: flashPulse .85s ease; }
@keyframes flashPulse {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.85); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* столбик сообщений в полном экране */
.fs-chat {
  position: absolute;
  left: 14px;
  top: 56px;
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  max-width: 72%;
  pointer-events: none;
}
body.is-fs .fs-chat { display: flex; }
.fs-msg {
  background: rgba(10, 12, 16, .55);
  backdrop-filter: blur(4px);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 5px;
  animation: fsMsgLive .5s ease;
  gap: 6px;
}
.fs-msg .msg-nick { display: inline; font-size: 12px; margin: 0; }
.fs-msg .bubble { background: transparent; padding: 0; border-radius: 0; max-width: none; }
.fs-msg .chat-img { max-height: 96px; margin: 0; }
.fs-msg.shrink .bubble { background: transparent; }
.fs-msg.sys { justify-content: center; text-align: center; }
.fs-msg .text { display: inline; }
@keyframes fsMsgLive {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: none; }
}
/* плавное схлопывание перед удалением */
.fs-msg.leave {
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: height .45s ease, opacity .45s ease, padding .45s ease, margin .45s ease;
}

.gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 16, .75);
  z-index: 7;
}

/* ---------- панель управления в стиле youtube ---------- */

/* крупный центральный кластер: пауза/перемотка в середине плеера */
.center-cluster {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 6;
  pointer-events: none; /* пустые зоны кластера пропускают тапы к видео */
  transition: opacity .25s ease;
}
.cbtn {
  pointer-events: auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  padding: 0;
  background: rgba(12, 14, 20, .62);
  border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, background .15s ease;
}
.cbtn:hover { background: rgba(30, 34, 44, .8); }
.cbtn:active { transform: scale(.92); }
.cbtn .ic { width: 25px; height: 25px; }
.cbtn-main { width: 72px; height: 72px; background: rgba(12, 14, 20, .8); }
.cbtn-main .ic { width: 34px; height: 34px; color: var(--accent); }
.cbtn:disabled { opacity: .35; }

.ytc {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 30px 10px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  transition: opacity .25s ease;
}
.yicon {
  background: transparent;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  padding: 8px 10px;
  flex-shrink: 0;
}
.yicon:hover { background: rgba(255, 255, 255, .14); }
.yicon:disabled { opacity: .4; }

.pbar {
  position: relative;
  flex: 1;
  height: 16px;
  cursor: pointer;
  touch-action: none;
  min-width: 40px;
}
.pbar.ro { pointer-events: none; cursor: default; }
.pbar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3.5px;
  margin-top: -1.75px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .22);
}
.pbuff, .pfill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 3.5px;
  margin-top: -1.75px;
  border-radius: 2px;
  width: 0;
}
.pbuff { background: rgba(255, 255, 255, .35); }
.pfill { background: var(--accent); }
.pknob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .15s ease;
}
.pbar:hover .pknob, .pbar:active .pknob { transform: scale(1); }

.ptime {
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 0 6px;
  flex-shrink: 0;
}

.buf-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 12, 16, .6);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  pointer-events: none;
}

/* диагностический экран: долгое нажатие на код комнаты / Alt+D */
.dbg {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 30;
  max-width: calc(100% - 16px);
  background: rgba(0, 0, 0, .72);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #9fe8b8;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
  white-space: pre-wrap;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.unmute-pill {
  position: absolute;
  left: 12px;
  bottom: 58px;
  z-index: 6;
  background: rgba(10, 12, 16, .72);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  padding: 8px 15px;
  border-radius: 22px;
  font-size: 13px;
  cursor: pointer;
}
.unmute-pill:hover { background: rgba(30, 34, 44, .85); }

/* автоскрытие панели при воспроизведении */
body.ui-hidden .ytc,
body.ui-hidden .center-cluster { opacity: 0; pointer-events: none; }
body.ui-hidden .video-wrap { cursor: none; }

.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.side-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.side-block.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h3 { margin-bottom: 8px; }
#btnDrawerClose, #btnRoster { display: none; }
#drawerBackdrop { display: none; }

#roster { list-style: none; margin: 0; padding: 0; max-height: 130px; overflow-y: auto; }
#roster li { padding: 3px 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
#roster li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#roster li.is-host .who { color: var(--accent); font-weight: 600; }
#roster .crown { display: inline-flex; align-items: center; }
#roster .crown .ic { width: 11px; height: 11px; }

#chat { flex: 1; overflow-y: auto; min-height: 0; padding-right: 4px; }

/* кнопка «вниз» в чате, когда ушли листать историю */
.chat-jump {
  position: absolute;
  right: 12px;
  bottom: 66px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
  z-index: 2;
}
.chat-jump:hover { background: #262c39; }
.chat-jump .ic { width: 18px; height: 18px; }

/* сообщение: [аватар] [ник + пузырь]; подряд от одного автора — без аватара */
.msg { display: flex; gap: 8px; padding: 4px 0; font-size: 14px; line-height: 1.45; word-break: break-word; }
.msg .ava-slot { flex: 0 0 30px; display: flex; align-items: flex-end; padding-bottom: 2px; }
.msg .msg-main { flex: 1; min-width: 0; }
.msg .msg-nick { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.msg .bubble {
  display: inline-block;
  background: var(--panel2);
  border-radius: 10px;
  padding: 6px 10px;
  max-width: 100%;
}
.msg.no-ava { margin-top: -2px; }
.msg.no-ava::before { content: ''; flex: 0 0 30px; }                    /* отступ под аватар */
.msg.has-ava::before { content: none; }
.msg.cont .msg-nick { display: none; } /* ник — только на верхнем ряду серии */
/* одиночный эмодзи — крупно и без подложки, как в телеграме; размер в em,
   поэтому масштабируются и анимированные, и шрифтовые варианты */
.bubble.big { background: transparent; padding: 0 2px; }
.bubble.big .text { font-size: 80px; line-height: 1.2; }
.msg.sys {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  justify-content: center;   /* системные центрируются */
  text-align: center;
  padding: 5px 0;
}
.chat-img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  cursor: zoom-in;
  margin: 2px 0;
}
.bubble.with-img { padding: 4px; background: transparent; }
.bubble.with-img .text { display: block; padding: 4px 6px; font-size: 13px; }

/* цвет выделения задаём явно и для букв, и для псевдо-бокса эмодзи —
   значение снято с нативной подсветки Chromium в тёмной схеме */
::selection { background: #063ba6; color: #fff; }

/* анимированные эмодзи (lottie/tgs) в тексте сообщений */
.aemoji {
  position: relative;
  display: inline-block;
  width: 1.45em;
  height: 1.45em;
  vertical-align: -0.3em;
  line-height: 1;
  overflow: hidden;
  user-select: all;       /* клик по эмодзи выделяет его целиком — удобно копировать */
}
/* оригинальный символ (то, что уходит в буфер при копировании) невидим:
   opacity гасит ВСЮ отрисовку элемента — включая принудительно проявляемый
   Chromium'ом статичный глиф на выделении и нативную подсветку. Поэтому при
   выделении не появляется «текстура» статичного эмодзи под анимацией,
   а синий прямоугольник рисуем сами (.aemoji.selected). Копированию и
   выделению opacity не мешает: они работают по DOM-дереву, а не по экрану. */
.aemoji-char {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15em;
  opacity: 0;
}
.aemoji svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;   /* выделение по клику идёт в символ, а не в svg */
}
/* псевдо-выделение: синий прямоугольник как у букв; анимация остаётся видимой */
.aemoji.selected { background: #063ba6; }
/* анимации нет (нет lottie/файла) — эмодзи выглядит как обычный текст */
.aemoji.fallback { display: inline; vertical-align: baseline; overflow: visible; user-select: text; }
.aemoji.fallback .aemoji-char { position: static; opacity: 1; font-size: inherit; }

/* аватарки */
.ava {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: rgba(10, 12, 16, .8);
  font-weight: 700;
  flex: none;
  user-select: none;
  padding: 0;              /* кнопка-аватар без подкладок: строго круг */
  overflow: hidden;
  box-sizing: border-box;
}
/* без своей картинки — нейтральный кружок со знаком вопроса */
.ava.empty {
  background-color: #343b48;
  background-image: url('data:image/svg+xml;utf8,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Ctext x=%2212%22 y=%2217%22 font-family=%22system-ui,sans-serif%22 font-weight=%22700%22 font-size=%2213%22 text-anchor=%22middle%22 fill=%22%23a8b0c2%22%3E%3F%3C/text%3E%3C/svg%3E');
  background-size: 58%;
  background-position: center;
  background-repeat: no-repeat;
}
.ava-xs { width: 22px; height: 22px; font-size: 13px; }
.ava-sm { width: 30px; height: 30px; font-size: 16px; }
.ava-md { width: 34px; height: 34px; font-size: 18px; }
.ava-lg { width: 62px; height: 62px; font-size: 34px; cursor: zoom-in; }
#avaPreview { width: 96px; height: 96px; font-size: 52px; margin: 6px auto 14px; }
/* аватар на главном экране: кнопка, круг внутри неё заполняет весь квадрат */
#avaBtn { padding: 0; }
#avaBtn .ava { width: 100%; height: 100%; }
#avaBtn:hover { background-color: #343b48; }
button.ava:not(.empty):hover, #avaBtn:not(.empty):hover { background: transparent; }

#chatForm { display: flex; gap: 8px; padding-top: 10px; align-items: center; }
#chatForm input { flex: 1; }
#btnAttach { width: 38px; height: 38px; padding: 0; display: flex; align-items: center; justify-content: center; }
#btnAttach.busy { opacity: .4; pointer-events: none; }
#btnAttach .ic { width: 22px; height: 22px; }

/* ---------- модалка ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-panel {
  width: min(640px, 92vw);
  height: min(560px, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
/* панель выбора аватара — компактная, по содержимому */
.ava-panel {
  width: min(420px, 92vw);
  height: auto;
  max-height: 88vh;
  overflow-y: auto;
}
.ava-row { display: flex; justify-content: center; }
.ava img, .ava img + * { border-radius: 50%; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava-row #avaPreview img { width: 96px; height: 96px; }
.ava-upload { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }

.browser-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.path { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.browser-list { flex: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.browser-item {
  display: flex;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.browser-item:hover { background: var(--panel2); }
.browser-item.selected { background: var(--accent); color: #fff; }
.browser-item .icon { width: 20px; text-align: center; }

.modal-foot { display: flex; justify-content: flex-end; padding-top: 12px; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- оверлей состояния соединения ---------- */

.conn-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  backdrop-filter: blur(3px);
}
.conn-panel {
  text-align: center;
  padding: 28px;
}
.conn-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.conn-sub { color: var(--muted); margin-bottom: 18px; }
.conn-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- мобильная версия ---------- */

@media (max-width: 900px) {
  .screen { padding: 10px; }
  .home { max-width: 100%; }
  h1 { margin-top: 18px; font-size: 28px; }

  /* комната фиксируется на весь экран, чат прижат к низу */
  .room-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    max-width: none;
  }
  .room-bar { padding: 2px 0 10px; gap: 8px; }
  .room-bar .video-name { display: none; }
  #viewersD { display: none; }
  #btnRoster { display: inline-flex; align-items: center; gap: 4px; }
  #btnNick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }

  .layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 10px;
    height: auto;
  }
  .player { flex: 0 0 auto; min-height: 0; }
  .video-wrap { height: min(56.25vw, 46vh); }
  .ytc { gap: 0; padding: 22px 6px 4px; }
  .yicon { font-size: 16px; padding: 7px 8px; }
  .ptime { font-size: 11px; padding: 0 2px; }
  .unmute-pill { bottom: 52px; }

  .side { flex: 1; min-height: 0; gap: 10px; }
  .side-block.chat { flex: 1; min-height: 0; }
  #chat { flex: 1; }

  /* клавиатура открыта: видео скрываем (оно играет дальше со звуком и
     синхронизацией), чат занимает весь экран */
  body.kb-open .player { display: none; }

  /* участники — выдвижная шторка справа */
  .side-block.roster {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(80vw, 320px);
    display: flex;
    flex-direction: column;
    border-radius: 14px 0 0 14px;
    transform: translateX(106%);
    transition: transform .28s ease;
    margin: 0;
  }
  body.drawer-open .side-block.roster { transform: translateX(0); box-shadow: -12px 0 40px rgba(0,0,0,.5); }
  .side-block.roster ul { flex: 1; max-height: none; overflow-y: auto; }
  #btnDrawerClose { display: block; }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
}

/* iPad / планшеты: оставляем две колонки */
@media (min-width: 901px) and (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 260px; }
}
