/* Экран партии и панель видеозвонка.
   Токены и общие примитивы (.btn, .card, .screen, .modal, #toast) — в
   theme.css; главная и лобби — в hub.css.

   ВНИМАНИЕ: геометрия доски трогается только осознанно. #board и
   #roll-overlay обязаны иметь ОДИНАКОВЫЕ ширину и пропорцию, иначе
   анимация броска кубиков ляжет мимо доски. Размер доски считается от
   --board-w, а её «100%» меряется по #game-left — то есть ширина #side
   тоже влияет на доску.

   Зум и панорама (viewport.js) живут ВЫШЕ досок: трансформируется только
   #board-stage, общий предок обеих досок. Ставить transform на что-либо
   внутри него нельзя — именно так пара «доска + слой броска» и разъедется. */

/* --- игровой экран: ландшафт — доска слева и колонка справа,
       портрет — доска сверху и панель действий снизу --- */

#screen-game {
  height: 100dvh;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  /* --sa-left/right/bottom ставит nardy.js (вырезы и навигация Android) —
     их уважаем, иначе тапы по крайним пунктам попадают в систему. Верхний
     контентный отступ НЕ берём: доска сознательно заходит углом под кнопку
     «Закрыть» — тап-зоны пунктов тянутся на всю высоту колонки, ходам это
     не мешает */
  padding: calc(4px + env(safe-area-inset-top, 0px))
           calc(8px + max(env(safe-area-inset-right, 0px), var(--sa-right, 0px)))
           calc(6px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom, 0px)))
           calc(8px + max(env(safe-area-inset-left, 0px), var(--sa-left, 0px)));
  /* доске и слою анимации — одна и та же ширина. Пропорция зависит от игры:
     нарды 1010/640, остальные доски квадратные. Атрибут ставит драйвер
     (enter()).
     --board-max-h — сколько высоты отдано доске; ровно эта строка и
     отличает портрет от ландшафта */
  --board-ratio: 1.578125;   /* 1010/640 */
  --board-max-h: calc(100dvh - 12px - var(--sa-bottom, 0px));
  --board-w: min(100%, calc(var(--board-max-h) * var(--board-ratio)));
}
body[data-game="checkers"] #screen-game,
body[data-game="tictac"] #screen-game,
body[data-game="sea"] #screen-game,
body[data-game="tactics"] #screen-game,
body[data-game="chess"] #screen-game { --board-ratio: 1; }
/* «Артиллерия»: поле вытянуто вширь; в портрете — почти квадрат, своя камера
   держит танк крупно (board-artillery.js) */
body[data-game="artillery"] #screen-game { --board-ratio: 1.62; }
@media (orientation: portrait) {
  body[data-game="artillery"] #screen-game { --board-ratio: .86; }
}

/* Морской бой: под полем — подпись, чьё оно (полей два, на экране одно).
   Вне #board-viewport, иначе зум уносил бы её за край. В ландшафте доска
   занимает всю высоту — там она уступает подписи её строку; в портрете
   высоту доске задаёт своё правило ниже, и подпись просто встаёт под неё. */
#screen-game { --sea-caption-h: 44px; }
/* Морской бой: под полем — две кнопки полей и 3D (game-sea.js, paintSeg).
   Вне #board-viewport, иначе зум уносил бы их за край. */
#sea-seg {
  box-sizing: border-box;
  height: var(--sea-caption-h);
  padding-top: 6px;
  display: flex;
  gap: 6px;
  /* ровно под полем, а не во всю ширину левой части ландшафта */
  width: var(--board-w);
  max-width: 100%;
  margin: 0 auto;
}
#sea-seg.hidden { display: none; }
.seg {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-1);
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.seg.on { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), .12); font-weight: 600; }
.seg:disabled { opacity: .45; cursor: default; }
.seg-mini { flex: none; width: 52px; font-weight: 700; }
.seg-mini.hidden { display: none; }
/* поле — почти во всю ширину экрана */
@media (orientation: portrait) {
  body[data-game="sea"] #screen-game {
    padding-left: calc(4px + max(env(safe-area-inset-left, 0px), var(--sa-left, 0px)));
    padding-right: calc(4px + max(env(safe-area-inset-right, 0px), var(--sa-right, 0px)));
  }
}
/* Подпись стоит вплотную под рамкой зума, а увеличенная доска по общему
   правилу (#board-viewport.zoomed) вылезает за рамку на запас обрезки —
   и закрывала бы верх букв. Морскому бою этот запас не нужен: у
   приближенного поля края за рамкой всё равно нет. */
body[data-game="sea"] #board-viewport.zoomed { overflow-clip-margin: 0px; }

/* --- морской бой в 3D (sea3d.js) ---
   Коробка поля держит размер; холст 3D лежит в ней под SVG-доской, а та в
   3D прозрачна — это слой тапов, натянутый на сетку через matrix3d. Доска
   приподнята z-index'ом: иначе абсолютный холст рисовался бы поверх неё и
   забирал тапы. */
#sea-box {
  position: relative;
  width: var(--board-w);
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
}
#sea-box #board-sea { width: 100%; display: block; position: relative; z-index: 1; }
#sea-box canvas.sea3d {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  border-radius: 10px; box-shadow: 0 2px 14px rgba(0, 0, 0, .25);
  transition: filter 1.2s ease;
}
body[data-sea-view="2d"] #sea-box canvas.sea3d { display: none; }
body[data-sea-view="3d"] #board-sea { opacity: 0; box-shadow: none; }
/* виньетка над морем — глубже и спокойнее края */
body[data-sea-view="3d"] #sea-box::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 10px;
  background: radial-gradient(120% 95% at 50% 55%, transparent 62%, rgba(2, 8, 16, .5) 100%);
}
body.sea-lost #sea-box canvas.sea3d { filter: saturate(.5) brightness(.72); }

/* Заставка конца партии. Победа: золото, буквы падают и переливаются,
   венок раскрывается листок за листком. Поражение: сцена тускнеет, буквы
   тяжело падают, якорь уходит вниз в пузырях. Тапы не ловит — окно
   результата ядра появится следом. */
.sea-splash {
  position: absolute; inset: 0; z-index: 8; pointer-events: none;
  display: grid; place-items: center; text-align: center; padding: 6%;
}
.sea-splash.hidden { display: none; }
.sea-splash.win {
  background: radial-gradient(60% 45% at 50% 46%, rgba(255, 207, 90, .16), rgba(4, 14, 26, .32) 55%, rgba(4, 14, 26, .5));
  animation: sea-fade .5s ease both;
}
.sea-splash.lose {
  background: radial-gradient(70% 60% at 50% 42%, rgba(40, 14, 16, .5), rgba(2, 6, 12, .86) 75%);
  animation: sea-fade .9s ease both;
}
.sea-splash-card { display: grid; gap: 6px; justify-items: center; }
.sea-emblem { width: clamp(64px, 24vmin, 128px); aspect-ratio: 1; }
.sea-emblem svg { width: 100%; height: 100%; overflow: visible; display: block; }
.sea-splash.win .sea-emblem { animation: sea-pop .9s cubic-bezier(.18, 1.6, .4, 1) .15s both; }
.sea-splash .leaf, .sea-splash .star, .sea-splash .bubble { transform-box: fill-box; transform-origin: center; }
.sea-splash.win .leaf { animation: sea-leaf .35s ease-out both; animation-delay: calc(.35s + var(--i) * .05s); }
.sea-splash.win .star { animation: sea-star 1.1s cubic-bezier(.2, 1.4, .4, 1) .3s both; }
.sea-splash.lose .sea-emblem { animation: sea-sink 2.6s cubic-bezier(.45, 0, .6, 1) .2s both; }
.sea-splash.lose .bubble { animation: sea-rise 2.2s ease-in infinite; animation-delay: calc(1s + var(--i) * .4s); opacity: 0; }
.sea-splash-title { font-weight: 800; letter-spacing: .06em; font-size: clamp(28px, 10vmin, 58px); line-height: 1.05; white-space: nowrap; }
.sea-splash-title span { display: inline-block; }
.sea-splash.win .sea-splash-title span {
  color: #ffcf5a; text-shadow: 0 2px 0 #8a5a12, 0 0 24px rgba(255, 207, 90, .55);
  animation: sea-drop .55s cubic-bezier(.2, 1.5, .45, 1) both, sea-glint 2.4s ease-in-out infinite;
  animation-delay: calc(.45s + var(--i) * .07s), calc(1.5s + var(--i) * .09s);
}
.sea-splash.lose .sea-splash-title { font-size: clamp(24px, 8.4vmin, 50px); }
.sea-splash.lose .sea-splash-title span {
  color: #ff8576; text-shadow: 0 2px 0 #5a1610, 0 0 18px rgba(255, 107, 90, .35);
  animation: sea-fall .7s cubic-bezier(.5, 0, .75, 0) both; animation-delay: calc(.3s + var(--i) * .05s);
}
.sea-splash.lose .sea-splash-card { animation: sea-thud .5s ease 1.2s both; }
.sea-splash-sub { font-weight: 600; color: var(--text); animation: sea-up .5s ease 1.1s both; }
.sea-splash-score { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; animation: sea-up .5s ease 1.3s both; }
@keyframes sea-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes sea-pop { from { transform: scale(.2) rotate(-25deg); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes sea-leaf { from { opacity: 0; transform: scale(.2) } to { opacity: 1; transform: none } }
@keyframes sea-star { from { transform: scale(0) rotate(-180deg) } to { transform: none } }
@keyframes sea-drop { from { transform: translateY(-1.2em) scale(1.3); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes sea-glint { 0%, 70%, 100% { filter: none } 80% { filter: brightness(1.55) drop-shadow(0 0 6px #fff3c0) } }
@keyframes sea-fall { from { transform: translateY(-1.6em) rotate(-8deg); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes sea-thud { 0%, 100% { transform: none } 25% { transform: translateY(5px) } 50% { transform: translateY(-3px) } 75% { transform: translateY(1px) } }
@keyframes sea-sink { 0% { transform: translateY(-30%) rotate(-12deg); opacity: 0 } 25% { opacity: 1 } 100% { transform: translateY(6%) rotate(4deg); opacity: 1 } }
@keyframes sea-rise { 0% { transform: translateY(0); opacity: 0 } 15% { opacity: .9 } 100% { transform: translateY(-46px); opacity: 0 } }
@keyframes sea-up { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) {
  .sea-splash, .sea-splash * { animation: none !important; }
  .sea-splash .bubble { opacity: .6; }
}
@media (orientation: landscape) {
  body[data-game="sea"] #screen-game {
    --board-max-h: calc(100dvh - 12px - var(--sea-caption-h)
                        - var(--sa-bottom, 0px));
  }
}

/* На экране — доска ТОЛЬКО той игры, которая идёт: пустая <svg> соседней
   всё равно занимает место (width + aspect-ratio) и выдавливает настоящую
   доску за край экрана. Прячет её JS классом .hidden (ядро, useDriver) —
   не CSS: правило по [data-game-board] пришлось бы делать специфичнее
   #board-wrap, и такую ловушку легко расставить снова, а поймать нечем —
   вёрстку автотесты не считают. */

#game-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#side {
  /* минимум задан рядом кнопок звонка: 4 × 44 px + зазоры + отступы */
  width: clamp(208px, 24vw, 270px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;    /* на низких экранах (звонок + кнопки) — прокрутка */
}

/* --- рамка зума: неподвижный кадр + трансформируемый слой --- */

#board-viewport {
  position: relative;
  width: 100%;
  /* жесты здесь наши: браузерные скроллы, овер-скролл и двойной тап — прочь.
     Синтетический тап по доске делает viewport.js (иначе браузер после
     панорамы прислал бы click — то есть ЛОЖНЫЙ ХОД) */
  touch-action: none;
  overscroll-behavior: none;
}
/* обрезаем только когда доска реально вылезла: при единичном масштабе рамка
   прозрачна и тень доски видна ровно как раньше */
#board-viewport.zoomed { overflow: clip; overflow-clip-margin: 10px; }
@supports not (overflow: clip) {
  #board-viewport.zoomed { overflow: hidden; }
}

#board-stage {
  transform-origin: 0 0;   /* вся математика viewport.js исходит из этого */
  transform: translate(0px, 0px) scale(1);
}
#board-stage.animated {
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}

/* «вписать доску обратно» — появляется только когда масштаб не единичный */
.zbtn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 7;          /* выше #roll-overlay (6): слой броска рисуется поверх доски */
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: transform .12s ease;
}
.zbtn:active { transform: scale(.9); }
.zbtn .ic { width: 22px; height: 22px; }

#board-wrap,
#board-wrap-checkers,
#board-wrap-tictac,
#board-wrap-sea,
#board-wrap-tactics {
  display: flex;
  width: 100%;
  justify-content: center;
  position: relative;
}
#board-checkers,
#board-tictac,
#board-sea,
#board-tactics {
  width: var(--board-w);
  aspect-ratio: 1;
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .25);
  touch-action: manipulation;
}
#board {
  /* доска почти во весь экран: имена рисуются НА доске, строк над/под нет */
  width: var(--board-w);
  aspect-ratio: 1010 / 640;
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .25);
  touch-action: manipulation;
}

#roll-overlay {
  /* отдельный слой броска кубиков: его не затирает НИКАКАЯ перерисовка доски */
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: var(--board-w);
  aspect-ratio: 1010 / 640;
  pointer-events: none;
  z-index: 6;
}

/* --- правая колонка: действия и управление --- */

#actionbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
#actionbar .btn { width: 100%; }
#hint { text-align: center; min-height: 16px; line-height: 1.35; }

/* ряд «Ничья / Сдаться» живёт в меню «⋯»; видимость ставят драйверы */
#controls { display: flex; gap: 8px; }
#controls .btn { flex: 1; }

/* круглые кнопки управления партией */
.gbtn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease;
}
.gbtn:active { transform: scale(.92); }
.gbtn.accent { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.gbtn.danger { color: var(--danger); }
.gbtn.off { color: var(--text-3); }
.gbtn:disabled { opacity: .4; }

#banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}
#banner-text { flex: 1; min-width: 100%; }
#banner-buttons { display: flex; gap: 6px; width: 100%; }
#banner-buttons .btn { flex: 1; }

/* --- плашки игроков: имена, счёт, чей ход ---
   Список игр позитивный, а не «все, кроме шашек»: у нард имена рисуются на
   самой доске, у остальных — здесь, и четвёртая игра иначе молча осталась бы
   без плашек. Ничья по договорённости есть в шашках и на больших досках
   крестиков (там нужный для ничьей «полный ящик» недостижим) — у нард и
   морского боя её нет, их правило ниже и прячет. Внутри крестиков кнопку
   прячет драйвер по полю can_draw: на 3×3 договариваться не о чем, а CSS
   про вид партии не знает. */

#players { display: none; flex-direction: column; gap: 6px; }
body[data-game="checkers"] #players,
body[data-game="tictac"] #players,
body[data-game="sea"] #players,
body[data-game="tactics"] #players,
body[data-game="artillery"] #players,
body[data-game="chess"] #players { display: flex; }
body:not([data-game="checkers"]):not([data-game="tictac"]):not([data-game="chess"]) #btn-draw {
  display: none;
}
body:not([data-game="chess"]) #btn-takeback { display: none; }

.prow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
}
.prow.turn { border-color: var(--accent); }
.prow .pdot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
}
.prow.online .pdot { background: var(--ok, #5dc46e); }
.prow .pname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prow .peaten { color: var(--text-2); }
/* морской бой, расстановка: «флот готов» должно бросаться в глаза, а не
   теряться серым рядом с именем */
.prow.ready { border-color: var(--ok); }
.prow.ready .peaten { color: var(--ok); font-weight: 600; }
/* Морской бой: в плашке имя со счётом побед и подпись справа («кораблей:
   10», «флот готов ✓»). В узкой колонке ландшафта им бывает тесно в одну
   строку — тогда подпись уходит второй строкой, а не съедает имя
   многоточием. Имя не сжимается, пока не займёт всю строку; пустая подпись
   второй строки не заводит. Если имя длиннее целой строки, многоточием
   режется только оно (.ptext), а счёт (.pscore) остаётся — game-sea.js
   кладёт их в ячейку имени двумя кусками. */
body[data-game="sea"] .prow { flex-wrap: wrap; row-gap: 2px; }
body[data-game="sea"] .prow .pname {
  display: flex;
  flex: 1 0 auto;
  max-width: calc(100% - 16px);
}
body[data-game="sea"] .prow .ptext {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
body[data-game="sea"] .prow .pscore { flex: none; margin-left: .3em; }
body[data-game="sea"] .prow .peaten { margin-left: auto; }
body[data-game="sea"] .prow .peaten:empty { display: none; }

/* --- портрет: доска сверху, управление снизу ---

   Раньше здесь висела заглушка «Поверните телефон»: доска нард широкая, и
   целиком в портрете она мелковата. Теперь мелковата — не приговор: пункт
   приближается щипком (viewport.js), зато партия открывается сразу, без
   разворота телефона.

   Блок стоит НИЖЕ базовых правил намеренно: селекторы одинаковой
   специфичности, и побеждает последний. Подняв его к --board-w, легко
   получить «портрет не применился» (ровно так и было: #game-left { flex: 1 }
   перебивал flex: none, и доска висела посреди пустого экрана).

   ВАЖНО: верхний safe-inset здесь берём, в отличие от ландшафта. В ландшафте
   доска сознательно заходит углом под «✕ Закрыть» (тап-зоны колонок тянутся
   на всю высоту, ходу это не мешает), а в портрете доска встаёт к самому
   верху во всю ширину — и «✕» села бы ровно на верхний пункт. */

@media (orientation: portrait) {
  #screen-game {
    flex-direction: column;
    --board-max-h: 52dvh;
    padding-top: calc(4px + max(env(safe-area-inset-top, 0px), var(--sa-top, 0px)));
  }
  #game-left { flex: none; justify-content: flex-start; }
  #side {
    width: 100%;
    flex: 1;
    min-height: 0;
    gap: 10px;
    padding-top: 6px;
    /* видео и подсказки — сразу под доской, круглые кнопки — у нижнего края,
       куда достаёт большой палец. space-between, а не flex-end: при
       переполнении flex-end срезает верх прокручиваемого содержимого */
    justify-content: space-between;
  }
  /* кнопки хода — в ряд: колонка из широких кнопок съела бы полэкрана */
  #actionbar { flex-direction: row; flex-wrap: wrap; }
  #actionbar .btn { width: auto; flex: 1 1 46%; }
  /* у морского боя подсказка длинная и меняется на каждый тап: своей
     строкой по центру, а не прижатой к краю за кнопками */
  body[data-game="sea"] #hint { flex-basis: 100%; }
  /* в портрете камера телефона даёт вертикальный кадр */
  #pip-local { aspect-ratio: 3 / 4; }
}

/* --- окно результата партии ---

   Высота телефона в ландшафте — 360–430 px, а столбик «эмодзи — заголовок —
   причина — счёт — три кнопки» требует около 430: окно центрировалось и
   уходило за край и сверху, и снизу. В ландшафте оно раскладывается в две
   колонки — итог слева, кнопки справа — и занимает около 200 px. Отступы —
   с запасом на вырезы и на кнопки Telegram поверх webview (--sa-*, их ставит
   nardy.js); если не хватит и этого, окно прокручивается внутри, а не
   обрезается. Вне низкого ландшафта (портрет, планшет, десктоп) обёртки
   колонок прозрачны (display: contents), и окно ровно прежнее — у всех игр
   сразу: окно общее, его рисует ядро. */
.result-head,
.result-actions { display: contents; }

@media (orientation: landscape) and (max-height: 520px) {
  #modal-result {
    padding:
      calc(8px + max(env(safe-area-inset-top, 0px), var(--sa-top, 0px)))
      calc(12px + max(env(safe-area-inset-right, 0px), var(--sa-right, 0px)))
      calc(8px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom, 0px)))
      calc(12px + max(env(safe-area-inset-left, 0px), var(--sa-left, 0px)));
  }
  #modal-result .modal-box {
    flex-direction: row;
    gap: 20px;
    max-width: 620px;
    max-height: 100%;
    overflow-y: auto;
    padding: 16px 20px;
  }
  #modal-result .result-head,
  #modal-result .result-actions {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
  }
  #modal-result .result-head { align-items: center; gap: 6px; }
  #modal-result .result-head p { margin: 0; }
  #modal-result .result-head p:empty { display: none; }
  #modal-result .big-icon { font-size: 40px; }
  /* кнопкам места побольше: «Перейти к новой партии» — самая длинная
     надпись окна, и в половине его ширины она переносилась бы */
  #modal-result .result-actions { flex-grow: 1.3; gap: 8px; }
  #modal-result .result-actions .btn { min-height: 44px; padding: 4px 14px; }
}

/* --- видеозвонок: панель в правой колонке игрового экрана --- */

.cbtn {
  width: 44px;
  height: 44px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: transform .12s ease, background .12s ease;
}
.cbtn:active { transform: scale(.9); }
.cbtn.danger { background: var(--danger); }
.cbtn.ok { background: var(--ok); }
/* выключенные микрофон и камера — приглушены, а не тревожно-красные:
   тревожный только сброс звонка */
.cbtn.off { background: rgba(255, 255, 255, .06); color: var(--text-3); }

#call-wrap {
  width: 100%;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #0b0d11;
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
  display: flex;
  flex-direction: column;
  position: relative;
  flex: none;
  transition: opacity .12s ease;
}
#pip-stage { position: relative; display: block; }
#pip-remote {
  width: 100%;
  aspect-ratio: 4 / 3;      /* в ландшафте камеры дают горизонтальный кадр */
  object-fit: cover;
  background: #0b0d11;
  display: block;
}
#pip-local {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 32%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: #191c24;
}
#pip-status, #pip-badges {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent);
  text-align: center;
}
#pip-controls {
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 6px;
  background: rgba(0, 0, 0, .5);
}
#pip-controls .cbtn { width: 44px; height: 44px; }
#pip-controls .cbtn .ic { width: 20px; height: 20px; }
#call-wrap.waiting #pip-local { display: none; }

/* свернуть видео: доска остаётся главной, связь не рвётся */
.pip-collapse {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.pip-collapse .ic { width: 16px; height: 16px; transform: rotate(-90deg); }
/* видимый кружок маленький (кадр важнее), а попасть в него надо пальцем */
.pip-collapse::after { content: ""; position: absolute; inset: -7px; }

/* «вернуть в колонку» — только у оторванного окна и только в партии */
.pip-dock { right: 42px; }

/* --- оторванное окно: его таскают пальцем по экрану ---

   Высота задана явно (а не по содержимому) намеренно: только так
   переход «пилюля ↔ окно» можно анимировать — в auto CSS не едет.
   --pip-ar — пропорция кадра: в ландшафте камера даёт 4:3, в портрете 3:4. */
#call-wrap.float {
  position: fixed;
  z-index: 45;
  --pip-w: 204px;
  --pip-ar: .75;
  width: var(--pip-w);
  height: calc(var(--pip-w) * var(--pip-ar) + 58px);
  touch-action: none;        /* окно двигаем мы, а не браузер */
  cursor: grab;
  transition: width .24s cubic-bezier(.2, .8, .2, 1),
              height .24s cubic-bezier(.2, .8, .2, 1),
              border-radius .24s ease,
              opacity .12s ease;
}
@media (orientation: portrait) { #call-wrap.float { --pip-ar: 1.3333; } }

/* три размера по двойному тапу: щипок по окошку в 200 px неудобен — палец
   закрывает ровно то, что масштабируешь, а угловая ручка съела бы четверть
   кадра. Размеры подобраны так, чтобы кнопки 44 px везде влезли в один ряд */
#call-wrap.float[data-size="0"] { --pip-w: 152px; }
#call-wrap.float[data-size="2"] { --pip-w: 256px; }
#call-wrap.float[data-size="0"] #pip-controls { gap: 2px; padding: 4px; }
#call-wrap.float[data-size="0"] #pip-flip { display: none; }

#call-wrap.dragging { transition: none; cursor: grabbing; }

/* --- свёрнуто: круглая пилюля «Видеосвязь» у края экрана --- */

#call-wrap.collapsed {
  --pip-w: 64px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border-color: var(--line-strong);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
#call-wrap.collapsed #pip-stage { flex: 1; height: 100%; }
#call-wrap.collapsed #pip-remote {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}
#call-wrap.collapsed #pip-local,
#call-wrap.collapsed #pip-controls,
#call-wrap.collapsed #pip-status,
#call-wrap.collapsed #pip-badges,
#call-wrap.collapsed .pip-collapse,
#call-wrap.collapsed .pip-dock { display: none; }

/* значок поверх кадра: без него свёрнутое видео читается как случайный
   кружок, а это ГЛАВНАЯ подсказка «здесь видеосвязь, потяни меня» */
.pip-badge { display: none; }
#call-wrap.collapsed .pip-badge {
  display: flex;
  position: absolute;
  inset: 0;
  /* без z-index значок прячется ЗА #pip-stage: тот тоже позиционирован
     (position: relative) и стоит в разметке ниже — значит рисуется поверх */
  z-index: 4;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, .34);
  pointer-events: none;
}
/* пока картинки собеседника нет, кружок — просто заметная кнопка «Видеосвязь» */
#call-wrap.collapsed.waiting .pip-badge { background: var(--accent); }
.pip-badge .ic { width: 26px; height: 26px; }

/* жест по доске — видео уходит с дороги и не ловит пальцы */
#call-wrap.ghost { opacity: .3; pointer-events: none; }

#tap-play {
  position: fixed;
  left: 50%;
  bottom: calc(70px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 56;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 11px 16px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--sh-2);
}

#call-banner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  animation: pulse 1.6s ease-in-out infinite;
}
.call-banner-btns { display: flex; gap: 6px; }
.call-banner-btns .btn { flex: 1; min-height: 44px; }
.call-banner-btns .btn.primary { background: #fff; color: #12141a; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  #call-banner { animation: none; }
  .gbtn:active, .cbtn:active, .zbtn:active { transform: none; }
  #board-stage.animated, #call-wrap, #call-wrap.float { transition: none; }
}

/* --- чат партии, нижняя полоса и меню «⋯» (chat-nardy.js) ---

   Колонка #side сверху вниз: видео, плашки, баннер, кнопки хода — и ниже
   всё свободное место отдано ленте сообщений (#chat-feed, flex: 1). Где
   места нет, лента сжимается в ноль, а сообщение соперника всплывает
   облачком над полем. Быстрые реакции и полоса «⋯ / чат / видео» — у
   нижнего края, под большим пальцем. */

#chat-feed {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  /* снизу вверх: при переполнении режется верх (старое), а новое всегда
     у нижнего края — сообщения кладутся в обратном порядке */
  flex-direction: column-reverse;
  gap: 5px;
  cursor: pointer;
  /* старые сообщения тают у верхнего края, а не обрезаются ножом */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 28px);
}
#chat-feed.tiny { visibility: hidden; }
.cmsg {
  max-width: 82%;
  padding: 7px 11px;
  border-radius: 16px 16px 16px 6px;
  background: var(--surface-2);
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}
.cmsg.small { font-size: 14px; padding: 6px 10px; }
.cmsg.theirs { align-self: flex-start; }
.cmsg.mine {
  align-self: flex-end;
  border-radius: 16px 16px 6px 16px;
  background: #5b4423;   /* латунь в тени: своё отличается от чужого не только стороной */
}
.cmsg.react { background: none; padding: 0 4px; font-size: 34px; line-height: 1.1; }
.cmsg.react.small { font-size: 28px; }
.cempty { margin: auto; color: var(--text-3); font-size: 13px; text-align: center; padding: 0 20px; }

#dock { display: flex; align-items: center; gap: 8px; margin-top: auto; }
#chat-feed:not(.hidden) ~ #dock { margin-top: 0; }
.dock-gap { flex: 1; }
.chat-entry:not(.hidden) ~ .dock-gap { display: none; }
.chat-entry {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.chat-entry .ic { width: 20px; height: 20px; flex: none; }
.chat-entry-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; }
.chat-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* облачко сообщения над полем и летящие реакции — поверх всего экрана */
#chat-pop {
  position: fixed;
  z-index: 40;
  box-sizing: border-box;
  padding: 9px 13px;
  border-radius: 14px;
  background: rgba(39, 44, 55, .97);
  box-shadow: var(--sh-2);
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  max-height: 30vh;
  overflow: hidden;
  cursor: pointer;
  animation: chat-pop-in .22s ease both;
}
@keyframes chat-pop-in { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) {
  #chat-pop { animation: none; }
}

/* --- панель чата ---
   Портрет: от низа доски (top ставит chat-nardy.js) до низа экрана, доска
   при этом сжимается (правило body.chat-open ниже). Ландшафт: колонкой
   справа вместо #side. */
#chat-panel {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .45);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--sa-bottom, 0px));
}
#chat-panel.hidden { display: none; }
#chat-catcher { position: fixed; z-index: 29; }
#chat-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 6px 16px;
  touch-action: none;   /* смахивание вниз — наше */
}
#chat-head .sheet-grip { position: absolute; top: 6px; left: 50%; margin-left: -18px; }
#chat-title { flex: 1; font-weight: 600; font-size: 15px; }
.cclose {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--surface-3); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.cclose .ic { width: 16px; height: 16px; transform: rotate(90deg); }
#chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 14px 10px;
}
#chat-list > :first-child { margin-top: auto; }
#chat-form { display: flex; align-items: center; gap: 8px; padding: 0 10px 8px; }
.chat-inputbox {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: 44px;
  border-radius: 22px;
  background: var(--surface-2);
  padding: 0 4px 0 16px;
}
#chat-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;      /* меньше 16 — iOS приближает страницу при фокусе */
  user-select: text;
  -webkit-user-select: text;
}
.cicon {
  width: 40px; height: 40px; border: 0; background: none; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.cicon .ic { width: 24px; height: 24px; }
.csend {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.csend .ic { width: 20px; height: 20px; }
#chat-emoji {
  background: var(--surface-1);
  padding: 6px 8px 8px;
  height: min(250px, 34dvh);
  display: flex;
  flex-direction: column;
}
#chat-emoji.hidden { display: none; }
#chat-emoji-tabs { display: flex; gap: 4px; padding-bottom: 6px; }
.etab {
  flex: 1; height: 34px; border: 0; border-radius: 10px; background: none;
  font-size: 18px; font-family: inherit; cursor: pointer; padding: 0;
}
.etab.on { background: var(--surface-3); }
#chat-emoji-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  grid-auto-rows: 42px;
}
.ebtn {
  border: 0; background: none; font-size: 28px; font-family: inherit;
  padding: 0; cursor: pointer; border-radius: 10px;
}
.ebtn:active { background: var(--surface-3); }

@media (orientation: portrait) {
  /* чат открыт — доска уступает ему место, но остаётся видна целиком */
  body.chat-open #screen-game { --board-max-h: 32dvh; }
}
@media (orientation: landscape) {
  /* Владелец (23.10, снимки с телефона): «в горизонтальном положении
     функционал оказывается слишком высоко и за часами». Колонка теперь во
     всю высоту (лента забирает свободное место), и её верх уходил под
     строку состояния и кнопки Telegram «⌄ ⋮» в правом верхнем углу. Доске
     заходить под них можно (см. блок «портрет»), колонке с кнопками — нет. */
  #side {
    justify-content: flex-start;
    padding-top: max(env(safe-area-inset-top, 0px), var(--sa-top, 0px));
  }
  /* высоты под колонкой стало меньше — кнопки хода по две в ряд */
  #actionbar { flex-direction: row; flex-wrap: wrap; }
  #actionbar .btn { width: auto; flex: 1 1 40%; min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
  #hint { flex-basis: 100%; }
  #chat-panel {
    left: auto;
    top: 0;
    width: min(360px, 46vw);
    border-radius: 20px 0 0 20px;
    padding-right: max(env(safe-area-inset-right, 0px), var(--sa-right, 0px));
  }
  #chat-head .sheet-grip { display: none; }
  #chat-head { padding-top: calc(10px + var(--sa-top, 0px)); }
  .cclose .ic { transform: none; }
  #chat-emoji { height: 40dvh; }
  /* поле — во всю оставшуюся ширину, колонка уходит за панель */
  body.chat-open #side { display: none; }
  body.chat-open #screen-game { padding-right: calc(min(360px, 46vw) + 8px); }
  /* узкая колонка: строка «Сообщение» сжимается до значка */
  .chat-entry { flex: none; width: 44px; padding: 0; justify-content: center; }
  .chat-entry-text { display: none; }
  .chat-entry .chat-badge { position: absolute; top: -4px; right: -4px; }
  /* четыре круглые кнопки на всю ширину узкой колонки */
  #dock { justify-content: space-between; gap: 4px; }
  .dock-gap, .chat-entry:not(.hidden) ~ .dock-gap { display: none; }
  #rec-bar { right: 100px; font-size: 14px; gap: 6px; }
  .rec-hint { font-size: 12px; }
}


/* --- меню «⋯»: лист снизу --- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-wrap.hidden { display: none; }
.sheet {
  width: min(100%, 520px);
  max-height: 90dvh;
  overflow-y: auto;
  box-sizing: border-box;
  background: var(--surface-1);
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + max(env(safe-area-inset-bottom, 0px), var(--sa-bottom, 0px)));
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, .6);
  animation: sheet-up .2s ease both;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-3); align-self: center; }
.sheet-title { text-align: center; font-size: 13px; color: var(--text-2); }
.mtiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mtile {
  height: 72px;
  border: 0;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.mtile .ic { width: 24px; height: 24px; }
.mtile.off { color: var(--text-3); }
.mtoggles { background: var(--surface-2); border-radius: 16px; display: flex; flex-direction: column; }
.mtoggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 14px;
  font-size: 15px;
  cursor: pointer;
}
.mtoggle + .mtoggle { border-top: 1px solid var(--line); }
.mtoggle span { flex: 1; }
.mtoggle input { width: 22px; height: 22px; accent-color: var(--accent); }
@media (orientation: landscape) and (max-height: 520px) {
  /* низкий ландшафт: плитки и переключатели в две колонки */
  .sheet { width: min(100%, 640px); }
  .mtiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* --- полоса соперника: аватар, имя, счёт в этой игре (chat-nardy.js) --- */
#opp-bar { display: flex; align-items: center; gap: 10px; flex: none; min-height: 48px; }
#opp-bar.hidden { display: none; }
.ava {
  width: 44px; height: 44px; flex: none; border-radius: 50%; overflow: hidden;
  background: linear-gradient(160deg, #6a7ba0, #2b3140);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #e8ecf4;
}
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava.bot { background: var(--surface-3); font-size: 22px; }
#opp-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#opp-score {
  display: grid; grid-template-columns: auto auto; column-gap: 8px; row-gap: 1px;
  align-items: baseline; padding: 5px 10px; border-radius: 12px; background: var(--surface-1);
}
#opp-score.hidden { display: none; }
#opp-score .sl { font-size: 11px; color: var(--text-2); }
#opp-score b { font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
#opp-score b.acc { color: var(--accent); }
@media (orientation: landscape) {
  /* в колонке — одной строкой и мельче: высоты в ландшафте мало */
  #opp-bar { min-height: 0; gap: 8px; }
  #opp-bar .ava { width: 32px; height: 32px; font-size: 14px; }
  #opp-name { font-size: 14px; }
  #opp-score { padding: 3px 8px; }
  #opp-score b { font-size: 13px; }
}

/* --- кнопка записи: держите — голос, коснитесь — станет камерой --- */
.recbtn {
  width: 52px; height: 52px; flex: none; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  /* долгое нажатие — наше: без меню «скопировать» и без прокрутки */
  touch-action: none; -webkit-touch-callout: none; user-select: none;
  transition: transform .12s ease, background .12s ease;
}
.recbtn.hidden { display: none; }
.recbtn .ic { width: 24px; height: 24px; pointer-events: none; }
body.recording .recbtn { background: #e5484d; color: #fff; transform: scale(1.25);
  box-shadow: 0 0 0 10px rgba(229, 72, 77, .2); }
body.in-call .recbtn { display: none; }
/* нижняя полоса всегда на экране, даже если колонка прокручивается
   (видео в колонке, расстановка морского боя, полоса соперника сверху) */
#dock { position: sticky; bottom: 0; z-index: 3; background: var(--bg); padding-top: 4px; }
#rec-bar {
  /* закрывает «⋯» и «Сообщение», кнопки записи и связи остаются видны */
  position: absolute; left: 0; right: 112px; top: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px; padding-left: 8px;
  background: var(--bg); font-size: 16px; font-variant-numeric: tabular-nums;
}
#rec-bar.hidden { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d;
  animation: rec-blink 1s ease-in-out infinite; }
.rec-hint { flex: 1; text-align: center; font-size: 14px; color: var(--text-2);
  transform: translateX(var(--dx, 0px)); }
@keyframes rec-blink { 50% { opacity: .25 } }
#rec-circle {
  position: fixed; z-index: 36; width: 132px; height: 132px; pointer-events: none;
}
#rec-circle.hidden { display: none; }
#rec-circle svg, .vcirc svg { position: absolute; inset: 0; width: 100%; height: 100%;
  transform: rotate(-90deg); }
#rec-circle video { position: absolute; inset: 7px; width: calc(100% - 14px); height: calc(100% - 14px);
  border-radius: 50%; object-fit: cover; transform: scaleX(-1); background: #111; }
.rbg { fill: none; stroke: rgba(255, 255, 255, .15); stroke-width: 4; }
.rfg { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100; }
#rec-circle .rfg { stroke: #e5484d; animation: rec-ring 10s linear forwards; }
@keyframes rec-ring { from { stroke-dashoffset: 100 } to { stroke-dashoffset: 0 } }

/* --- голосовое в ленте: ▶, волна, время --- */
.cmsg.voice { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  cursor: pointer; user-select: none; -webkit-user-select: none; }
.vplay { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--text);
  position: relative; }
.vplay::after { content: ""; position: absolute; left: 12px; top: 9px;
  border-left: 11px solid var(--surface-2); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.cmsg.mine .vplay { background: var(--accent); }
.cmsg.mine .vplay::after { border-left-color: #5b4423; }
.cmsg.voice.playing .vplay::after { left: 10px; top: 10px; width: 4px; height: 12px; border: 0;
  border-left: 4px solid var(--surface-2); border-right: 4px solid var(--surface-2); box-sizing: content-box; }
.cmsg.mine.voice.playing .vplay::after { border-color: #5b4423; }
.cmsg.voice { max-width: 100%; box-sizing: border-box; }
.vwave { display: flex; align-items: center; gap: 2px; height: 22px; min-width: 0; overflow: hidden; }
.vwave i { flex: none; }
.vwave i { width: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.vwave i.on { background: #fff; }
.vtime { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: none; }
.cmsg.small.voice .vplay { width: 28px; height: 28px; }
.cmsg.small.voice .vplay::after { left: 10px; top: 7px; }

/* --- кружок в ленте: маленький, сбоку, поле не закрывает --- */
.cmsg.vmsg { background: none; padding: 0; cursor: pointer; }
.vcirc { position: relative; width: 140px; height: 140px; }
.cmsg.small .vcirc { width: 100px; height: 100px; }
.vcirc video { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px);
  border-radius: 50%; object-fit: cover; background: radial-gradient(circle at 50% 40%, #3a3f4c, #1a1d24); }
.vface { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.vface.hidden { display: none; }

/* --- видеосвязь в партии: в свободном месте колонки, доска не меняется ---
   Владелец (23.10): «видеосвязь надо сделать не в ущерб игровому полю, а
   расположить так, чтобы занять оставшееся пространство». Окно встаёт в
   #side вместо ленты (call-nardy.js кладёт его перед #chat-feed) и
   забирает всю свободную высоту; кнопки — маленькие, поверх видео. */
#side > #call-wrap:not(.float) { flex: 1 1 0; min-height: 150px; }
#side > #call-wrap:not(.float) #pip-stage { flex: 1; min-height: 0; }
#side > #call-wrap:not(.float) #pip-remote {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto;
}
#side > #call-wrap:not(.float) #pip-local {
  left: auto; right: 8px; top: 8px; width: 26%; max-width: 120px; z-index: 1;
}
#side > #call-wrap:not(.float) #pip-controls {
  position: absolute; left: 0; right: 0; bottom: 8px; z-index: 2;
  background: none; justify-content: center; gap: 10px; padding: 0;
}
#side > #call-wrap:not(.float) #pip-controls .cbtn { width: 40px; height: 40px; }
#side > #call-wrap:not(.float) #pip-controls .cbtn .ic { width: 18px; height: 18px; }
#side > #call-wrap:not(.float) #pip-status,
#side > #call-wrap:not(.float) #pip-badges { bottom: 56px; background: none; }
#side > #call-wrap:not(.float) .pip-collapse { right: auto; left: 8px; }
body.in-call #chat-feed { display: none; }

/* правила и анимации Tactical Frontier в меню «⋯» — только в этой игре */
body:not([data-game="tactics"]) #game-menu .tf-tools { display: none; }
#game-menu .tf-tools { display: flex; gap: 8px; }
#game-menu .tf-tools .btn { flex: 1; min-height: 44px; }
/* прокрутка колонки к кнопке не прячет её под липкой нижней полосой */
#side { scroll-padding-bottom: 72px; }

/* Плашки игроков снизу дублировали полосу соперника сверху — владелец
   (23.10): «вверху надо подписывать участников, а снизу убрать». Есть
   полоса — плашек нет: их счётчики она показывает у себя (mirrorPlayers),
   чей ход — по кольцу у аватара соперника. Зрителю полосы нет, плашки
   остаются */
body.has-opp #players { display: none !important; }
.ava.turn { box-shadow: 0 0 0 3px var(--accent); }

.opp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.opp-text #opp-name { flex: none; }
#opp-sub { font-size: 13px; color: var(--text-2); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#opp-sub:empty { display: none; }
#opp-sub.ready { color: var(--ok); }
@media (orientation: landscape) { #opp-sub { font-size: 12px; } }

/* Видеосвязь в партии: владелец (23.10) — «надо убирать чат сообщений,
   чтобы было больше места под окно видеосвязи». Лента уже спрятана, теперь
   и нижняя полоса: видео забирает всё место под доской, а чат и меню —
   маленькие кнопки в левом верхнем углу окна (рядом со «свернуть»). */
body.in-call #dock { display: none; }
.pip-corner { display: none; }
#side > #call-wrap:not(.float):not(.collapsed) .pip-corner {
  position: absolute; top: 8px; z-index: 3;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
#side > #call-wrap:not(.float) #pip-chat { left: 46px; }
#side > #call-wrap:not(.float) #pip-menu { left: 86px; }
.pip-corner .ic { width: 17px; height: 17px; }
.pip-corner .chat-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; font-size: 11px; }
#side > #call-wrap:not(.float) .pip-collapse { top: 10px; }

/* ползунок «Громкость игры» в меню «⋯» */
.mvolume { display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 16px; background: var(--surface-2); font-size: 15px; }
.mvolume span { flex: none; }
.mvolume input { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); }
.mvolume b { flex: none; width: 44px; text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--text-2); }
