@charset "UTF-8";

/* public/style.css */

/* ===== ЛИЦО НА КОЛОБКЕ В ПРОФИЛЕ И ПРЕВЬЮ ИНВЕНТАРЯ — ПОДБИРАТЬ ЗДЕСЬ =====
   Только лица из конструктора (класс .face-built).
   --ball-face-scale — размер лица: 1 = как сейчас, 0.8 = на 20% меньше.
   --ball-face-x     — сдвиг вбок в % колобка: + вправо, − влево.
   --ball-face-y     — сдвиг вверх-вниз в % колобка: + вниз, − вверх.
   Профиль и инвентарь — раздельно. */
:root {
    --ball-face-scale: 0.65;
    --ball-face-x: 5%;
    --ball-face-y: 0%;

    --inv-face-scale: 0.65;
    --inv-face-x: 5%;
    --inv-face-y: 0%;

    /* колобок в главном меню (рядом с «Введите ваше имя») */
    --menu-face-scale: 0.65;
    --menu-face-x: 5%;
    --menu-face-y: 0%;

    /* колобки игроков в лобби комнаты */
    --lobby-face-scale: 0.65;
    --lobby-face-x: 5%;
    --lobby-face-y: 0%;
}

/* CSS-переменные для системы сеттингов */
:root {
    --setting-day-bg: linear-gradient(180deg, #f7ebe6 0%, #eedacc 100%);
    --setting-night-bg: linear-gradient(180deg, #76483c 0%, #6b4234 100%);
    --setting-day-text: #3a2b20;
    --setting-night-text: #f7efe6;
    /* Фоновая картинка сеттинга: по умолчанию — прозрачный 1px, чтобы не перебивать градиент */
    --setting-day-bg-image: linear-gradient(transparent, transparent);
    --setting-night-bg-image: linear-gradient(transparent, transparent);
    /* Утро (фаза «смерть жертвы»): прозрачно, пока сеттинг не дал background_morning.png */
    --setting-morning-bg-image: linear-gradient(transparent, transparent);
}

/* ОСНОВНЫЕ СТИЛИ СТРАНИЦЫ */
html, body {
    height: 100%;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    transition: all 2s ease;
}

/* Дневной фон — ПОСТОЯННАЯ канва в обоих режимах: ночью его накрывает
   плавно проявляющийся слой body::before (см. ниже). Если оставить фон только
   на .day-mode, при смене класса канва мгновенно белела бы под fade-слоем. */
body.day-mode,
body.night-mode {
    background: var(--setting-day-bg-image), var(--setting-day-bg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* Дневной режим (по умолчанию) */
body.day-mode {
    color: var(--setting-day-text);
}

/* Ночной режим.
   ВАЖНО: фон канвы здесь НЕ меняем — CSS-градиенты не анимируются, и смена
   background давала резкий скачок. Канва всегда дневная, а ночь приносит
   фиксированный слой body::before, плавно проявляющийся по opacity. */
body.night-mode {
    color: var(--setting-night-text);
}

/* Слой ночного фона поверх дневной канвы: плавный переход день/ночь */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--setting-night-bg-image), var(--setting-night-bg);
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 2s ease;
    pointer-events: none;
}

body.night-mode::before {
    opacity: 1;
}

/* Слой утреннего фона (фаза «смерть жертвы»): рисуется ПОВЕРХ ночного слоя
   (::after идёт после ::before при одинаковом z-index). Если у сеттинга нет
   background_morning.png, переменная остаётся прозрачной и виден ночной фон. */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--setting-morning-bg-image);
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 2s ease;
    pointer-events: none;
}

body.morning-mode::after {
    opacity: 1;
}

/* Панели и крупные поверхности перекрашиваются в ночь плавно
   (фоновые цвета/текст/рамки — в отличие от градиентов, они анимируются) */
#chat-panel,
#chat-panel .chat-title,
#chat-panel .chat-input-area,
#chat-panel #chatInput,
#phase-display,
#phase-timer,
#gesture-panel {
    transition: background-color 1.6s ease, color 1.6s ease, border-color 1.6s ease, box-shadow 1.6s ease;
}

/* ГЛАВНЫЙ ЗАГОЛОВОК */
#site-title-wrapper {
    position: relative;
    display: inline-block;
    max-width: 400px;
    width: 60%;
    margin: 10px auto 0;
    z-index: 1;
}

#site-title {
    display: block;
    width: 100%;
    height: auto;
}

#site-symbol {
    position: absolute;
    top: -10%;
    right: -8%;
    width: 28%;
    height: auto;
    pointer-events: none;
}

#site-slogan {
    text-align: center;
    font-size: 15px;
    color: #dcbea0;
    margin: 4px auto 0;
    position: relative;
    z-index: 1;
    font-style: italic;
    opacity: 0.85;
}

/* НАЧАЛЬНЫЙ ИНТЕРФЕЙС */
#setup-ui {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

/* ============================================
   ИКОНКА-ПАСХАЛКА (левый верхний угол)
   ============================================ */
#easter-egg-corner {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
}

#easter-egg-corner-den {
    position: fixed;
    top: 16px;
    left: 78px;
    z-index: 100;
}

#easter-egg-corner.active,
#easter-egg-corner-den.active {
    z-index: 140;
}

/* ============================================
   КНОПКА ОБРАТНОЙ СВЯЗИ (правый нижний угол)
   ============================================ */
#feedback-corner {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.feedback-trigger-btn {
    font-size: 12px;
    font-weight: 700;
    color: #5a3a1a;
    background: rgba(255,255,255,0.92);
    border: 2px solid #c8a070;
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    white-space: nowrap;
}

.feedback-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(0,0,0,0.18);
}

.feedback-bubble {
    margin-top: 6px;
    font-size: 12px;
    color: #3a2b20;
    background: rgba(255,255,255,0.95);
    border: 2px solid #c8a070;
    border-radius: 12px;
    padding: 6px 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    white-space: nowrap;
}

.feedback-bubble a {
    color: #b06020;
    font-weight: 700;
    text-decoration: none;
}

.feedback-bubble a:hover {
    text-decoration: underline;
}

/* ============================================
   СИСТЕМА ОПЛАТЫ ЧЕРЕЗ БАЛАНС
   ============================================ */
#botPriceTag {
    transition: opacity 0.2s;
}

#botPaymentMode .gender-label {
    font-size: 12px;
}

#promoResult.promo-success {
    color: #2e7d32;
    background: #e8f5e9;
    border-radius: 6px;
    padding: 8px 12px;
}

#promoResult.promo-error {
    color: #c62828;
    background: #ffebee;
    border-radius: 6px;
    padding: 8px 12px;
}

#promoCodeInput {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

#promoBalanceBadge:not(:empty)::before {
    content: '| ';
}

/* ============================================
   БАННЕР БЕТА-ВЕРСИИ (старые стили заменены на новые ниже)
   ============================================ */

#easter-egg-icon,
#easter-egg-icon-den {
    width: 52px;
    height: 52px;
    cursor: pointer;
    border-radius: 12px;
    border: 3px solid #000;
    background: rgba(255,255,255,0.95);
    padding: 4px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    object-fit: contain;
}

#easter-egg-icon:hover,
#easter-egg-icon-den:hover {
    transform: rotate(-8deg) scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.easter-egg-bubble {
    position: absolute;
    bottom: -500%;
    left: 0;
    margin-bottom: 8px;
    width: 260px;
    background: rgba(255,255,255,0.97);
    border: 3px solid #000;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    animation: fadeSlideUp 0.3s ease-out;
}

#easter-egg-text-den {
    bottom: -320%;
}

.easter-egg-bubble p {
    margin: 0 0 8px;
    font-size: 13px;
    color: #3a2b20;
    line-height: 1.5;
}

.easter-egg-bubble p:last-of-type {
    margin-bottom: 0;
}

.easter-egg-close {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: pointer;
    font-size: 16px;
    color: #999;
    transition: color 0.2s;
}

.easter-egg-close:hover {
    color: #333;
}

/* ============================================
   СЧЁТЧИК ОНЛАЙНА (правый верхний угол)
   ============================================ */
#online-counter {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: rgba(255,255,255,0.95);
    border: 3px solid #000;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    color: #3a2b20;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

#online-counter .online-dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

/* ============================================
   ГЛОБАЛЬНАЯ СТАТИСТИКА (v2.0)
   Вкладка «📊 Сервер» в карточке лидеров + модалка подробной статистики.

   Карточка лидеров узкая (~300px внутри), поэтому строками «подпись — число»
   тут не обойтись: длинные подписи («За мирных», «Сыграно ведущим») уезжали в
   многоточие, а список не влезал по высоте. Вместо строк — плитки с цифрой
   сверху и подписью снизу и компактные строки ролей с полоской винрейта;
   всё остальное вынесено в широкое окно.
   ============================================ */
#global-stats-content {
    display: block;
    padding: 4px 0 2px;
    text-align: left;
}

.gs-summary { display: flex; flex-direction: column; gap: 10px; }

.gs-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}
.gs-tiles-wide { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }

.gs-tile {
    background: rgba(138, 88, 54, 0.08);
    border-radius: 10px;
    padding: 8px 6px;
    text-align: center;
    min-width: 0;
}
.gs-tile-value {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.15;
    color: #6b4a30;
    font-variant-numeric: tabular-nums;
}
.gs-tile-label {
    margin-top: 2px;
    font-size: 11px;
    color: #8a7565;
    line-height: 1.25;
}

.gs-section-title,
.gs-block-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8a5836;
    margin-bottom: 6px;
}

.gs-roles { display: flex; flex-direction: column; gap: 8px; }
.gs-role-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 12.5px;
}
.gs-role-name { color: #5a4a3a; font-weight: 600; white-space: nowrap; }
.gs-role-val {
    color: #8a7565;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.gs-role-bar {
    margin-top: 3px;
    height: 5px;
    border-radius: 3px;
    background: rgba(138, 88, 54, 0.12);
    overflow: hidden;
}
.gs-role-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #c8a550, #8a5836);
}

.gs-more-btn {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: #8a5836;
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.gs-more-btn:hover { background: #6b4a30; }

/* Строки «сколько из скольких» в модалке */
.gs-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(138, 88, 54, 0.1);
}
.gs-line:last-of-type { border-bottom: none; }
.gs-line-label { color: #5a4a3a; }
.gs-line-value {
    color: #6b4a30;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.gs-line-sub { color: #8a7565; font-weight: 500; font-size: 12px; }

.gs-note {
    margin-top: 8px;
    font-size: 11.5px;
    line-height: 1.4;
    color: #8a7565;
}
.gs-note-big {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(200, 165, 80, 0.14);
    font-size: 12.5px;
    color: #6b4a30;
}

/* График ежедневного онлайна */
.gs-chart {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 5px;
    height: 120px;
    padding: 4px 2px 0;
}
.gs-bar-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    flex: 1;
    min-width: 14px;
    height: 100%;
}
.gs-bar {
    width: 100%;
    max-width: 26px;
    background: linear-gradient(to top, #8a5836, #c8a550);
    border-radius: 3px 3px 0 0;
}
.gs-bar-count { font-size: 9px; color: #8a5836; margin-top: 2px; }
.gs-bar-date { font-size: 8px; color: #8a7565; }
.gs-empty { color: #8a7565; font-size: 13px; padding: 12px 0; }

/* Модалка подробной статистики */
.global-stats-modal-content {
    width: min(760px, 94vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}
.global-stats-modal-body {
    overflow-y: auto;
    padding-right: 4px;
}
.gs-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.gs-block {
    background: rgba(138, 88, 54, 0.05);
    border-radius: 12px;
    padding: 12px 14px;
    min-width: 0;
}
.gs-block-wide { grid-column: 1 / -1; }

/* Управление звуком в меню/лобби — левый верхний угол, ПОД иконками-пасхалками
   (#easter-egg-corner стоит на top:16px; left:16px, поэтому здесь смещено ниже). */
#menu-audio-controls {
    position: fixed;
    top: 80px;
    left: 16px;
    z-index: 100;
    display: flex;
    gap: 8px;
}
.menu-audio-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 3px solid #000;
    background: rgba(255,255,255,0.95);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.menu-audio-btn:hover { transform: scale(1.08); }
.menu-audio-btn.audio-off {
    background: rgba(210,210,210,0.85);
    opacity: 0.55;
}
@media (max-width: 480px) {
    .menu-audio-btn { width: 38px; height: 38px; font-size: 17px; }
    #menu-audio-controls { top: 64px; left: 12px; gap: 6px; }
}

/* ============================================
   3-КОЛОНОЧНЫЙ LAYOUT МЕНЮ
   ============================================ */
/* Фоновый SVG-арт на весь экран */
#menu-bg-art {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

#menu-bg-art .menu-scene-art {
    width: 100%;
    height: 100%;
    display: block;
}

.menu-layout {
    display: grid;
    grid-template-columns: 270px 1fr 270px;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    align-items: start;
    margin: 0 auto;
    padding: 0 12px;
    box-sizing: border-box;
}

.menu-center {
    display: flex;
    justify-content: center;
}

.menu-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
}

.menu-left {
    justify-self: start;
    width: 100%;
}

.menu-right {
    justify-self: end;
    width: 100%;
}

.about-game-card .side-card-body p,
.from-author-card .side-card-body p {
    font-size: 13px;
    margin: 6px 0;
    color: #5a4a3a;
    line-height: 1.5;
}

.about-game-card .side-card-body ul {
    margin: 6px 0 6px 4px;
    padding-left: 4px;
    list-style: none;
}

.about-game-card .side-card-body li {
    font-size: 12px;
    color: #5a4a3a;
    line-height: 1.5;
    margin-bottom: 5px;
    padding-left: 2px;
}

.about-game-card.expanded .side-card-body {
    max-height: 500px;
}

.from-author-card.expanded .side-card-body {
    max-height: 380px;
}

/* ============================================
   КАРТОЧКА ОБНОВЛЕНИЙ
   ============================================ */
.changelog-card {
    background: linear-gradient(145deg, #1a0830, #2d1060, #1a0828);
    border-color: #261f32;
    box-shadow: 0 4px 24px rgba(124, 58, 237, 0.4), inset 0 0 0 1px rgba(196, 150, 255, 0.12);
}

.changelog-card .side-card-title {
    color: #e9d5ff;
    background: linear-gradient(90deg, #3b0d7a, #5b21b6);
    text-shadow: 0 0 14px rgba(231, 189, 255, 0.547);
}

.changelog-card .side-card-title:hover {
    background: linear-gradient(90deg, #4c1896, #6d28d9);
}

.changelog-card .side-card-title::after {
    color: #231630;
}

.changelog-card.expanded .side-card-title {
    border-bottom: 2px solid rgba(79, 47, 121, 0.3);
}

.changelog-card.expanded .side-card-body {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.changelog-card .side-card-body ul {
    margin: 8px 0 4px 0;
    padding-left: 4px;
    list-style: none;
}

.changelog-card .side-card-body li {
    font-size: 12px;
    color: #331a4b;
    line-height: 1.55;
    margin-bottom: 6px;
    padding-left: 2px;
    padding-top: 3px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(196, 150, 255, 0.1);
}

.changelog-card .side-card-body li:last-child {
    border-bottom: none;
}

.changelog-version-label {
    font-size: 11px;
    color: rgba(83, 37, 123, 0.642);
    margin-top: 10px;
    text-align: right;
}

.changelog-history-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(91, 33, 182, 0.4);
    border-radius: 8px;
    background: rgba(91, 33, 182, 0.12);
    color: #4d2a78;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.changelog-history-btn:hover {
    background: rgba(91, 33, 182, 0.2);
    border-color: rgba(91, 33, 182, 0.6);
}

.changelog-history-modal-content {
    max-width: 560px;
    width: calc(100vw - 24px);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.changelog-history-modal-body {
    overflow-y: auto;
    padding-right: 4px;
}

.changelog-history-version-block {
    border: 1px solid rgba(91, 33, 182, 0.18);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(91, 33, 182, 0.05);
}

.changelog-history-title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: #4d2a78;
}
/* Дата выхода версии (2.5) — первый коммит, где карточка сменилась на неё */
.changelog-history-date {
    margin-left: 6px;
    font-size: 12px;
    font-weight: 600;
    opacity: 0.6;
}

.support-author-btn {
    display: block;
    margin: 12px auto 4px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #c0813a, #a06020);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border-radius: 20px;
    border: 2px solid #7a4a10;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 3px 10px rgba(120,70,10,0.25);
}

.support-author-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(120,70,10,0.35);
}
/* Две кнопки доната рядом: DonationAlerts и Boosty (2.5) */
.support-author-lead { margin: 12px 0 0; text-align: center; font-weight: 600; }
.support-author-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.support-author-row .support-author-btn { margin: 8px 0 4px; }

/* ============================================
   БОКОВЫЕ КАРТОЧКИ (новости, профиль, лидерборд)
   ============================================ */
.side-card {
    background: rgba(255,255,255,0.95);
    border: 3px solid #000;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    animation: fadeSlideUp 0.5s ease-out both;
    overflow: hidden;
}

.side-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #3a2b20;
    margin: 0;
    padding: 12px 16px;
    border-bottom: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.side-card-title:hover {
    background: rgba(0,0,0,0.04);
}

.side-card-title::after {
    content: '▼';
    font-size: 11px;
    color: #a08060;
    transition: transform 0.3s;
}

.side-card.expanded .side-card-title::after {
    transform: rotate(180deg);
}

.side-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 16px;
}

.side-card.expanded .side-card-body {
    max-height: 600px;
    padding: 0 16px 14px;
}

.leaderboard-card.expanded .side-card-body {
    max-height: 420px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.side-card.expanded .side-card-title {
    border-bottom: 2px solid #f0e0d0;
}



/* Карточка профиля (правая сторона) */
.profile-side-card .profile-stats-header {
    margin-bottom: 14px;
    padding-bottom: 0;
    border-bottom: none;
}

.profile-side-card .profile-stats-grid {
    margin-top: 0;
}

/* Заглушка лидерборда */
.leaderboard-card {
    animation-delay: 0.15s;
}

.leaderboard-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    text-align: center;
}

.leaderboard-lock {
    font-size: 32px;
    opacity: 0.5;
}

.leaderboard-placeholder p {
    margin: 0;
    font-size: 13px;
    color: #8a7565;
    line-height: 1.4;
}

/* ============================================
   АДАПТИВНОСТЬ: мобильные/планшеты
   ============================================ */
@media (max-width: 1000px) {
    .menu-layout {
        grid-template-columns: 1fr;
        max-width: 500px;
        padding: 0 8px;
    }
    
    .menu-left {
        order: 3;
    }
    
    .menu-side {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 100% !important;
        justify-self: center !important;
        padding-top: 0;
    }
    
    .menu-center {
        order: 1;
    }
    
    .menu-right {
        order: 2;
    }
    
    .side-card {
        flex: 1;
        min-width: 200px;
    }
    
    #easter-egg-corner {
        position: absolute;
    }
    #easter-egg-corner-den {
        position: absolute;
        left: 78px;
    }
    
    #online-counter {
        position: absolute;
    }
}

@media (max-width: 480px) {
    .menu-side {
        flex-direction: column;
    }
    
    #online-counter {
        font-size: 12px;
        padding: 8px 14px;
    }
    
    #easter-egg-icon,
    #easter-egg-icon-den {
        width: 40px;
        height: 40px;
    }
}

/* ПАНЕЛЬ ВВОДА ИМЕНИ */
#name-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 34px;
    border-radius: 20px;
    border: 4px solid #000;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-width: 300px;
    max-width: 420px;
    box-sizing: border-box;
    margin: 40px auto;
}

#name-panel label {
    font-size: 20px;
    font-weight: bold;
}

#name-panel input {
    padding: 12px 16px;
    width: 280px;
    font-size: 16px;
    border-radius: 8px;
    border: 2px solid #8a5836;
}

/* ВЫБОР АВАТАРА */
#avatar-selector label {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
}

.avatar-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 300px;
}

.avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.avatar-option:hover {
    background-color: rgba(138, 88, 54, 0.1);
    border-color: #8a5836;
}

.avatar-option.selected {
    border-color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.1);
}

.avatar-preview {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #ddd;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    position: relative; /* якорь для второго слоя аватара (.avatar-overlay) */
}

/* Цвета аватаров */
.avatar-option[data-color="orange"] .avatar-preview { background-color: #FF8C00; }
.avatar-option[data-color="green"]  .avatar-preview { background-color: #2ECC40; }
.avatar-option[data-color="blue"]   .avatar-preview { background-color: #4DA6FF; }
.avatar-option[data-color="red"]    .avatar-preview { background-color: #FF4D4D; }
.avatar-option[data-color="yellow"] .avatar-preview { background-color: #FFDD57; }
.avatar-option[data-color="pink"]   .avatar-preview { background-color: #FF66CC; }
.avatar-option[data-color="cyan"]   .avatar-preview { background-color: #20E5D9; }
.avatar-option[data-color="violet"] .avatar-preview { background-color: #A66CFF; }
.avatar-option[data-color="violet"] .avatar-preview { background-color: #A66CFF; }
.avatar-option[data-color="black"] .avatar-preview { background-color: #121212; }
.avatar-option[data-color="white"] .avatar-preview { background-color: #f3eeee; }
.avatar-option[data-color="grey"] .avatar-preview { background-color: #626162; }

/* ============================================
   РЕДАКТОР АВАТАРА - МОДАЛЬНОЕ ОКНО
   ============================================ */

#avatar-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 8px 0 4px;
}

.avatar-large-preview {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background-color: #FF8C00;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
}

/* Слой для узора поверх аватара */
.avatar-large-preview.has-pattern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    pointer-events: none;
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    mix-blend-mode: overlay;
}

#openAvatarEditorBtn {
    padding: 9px 18px;
    font-size: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#openAvatarEditorBtn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Переключатель пола */
.gender-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 4px 0;
    order: 6;
}

.gender-selector-compact {
    margin: 5px 0;
}

.gender-option {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.gender-option input[type="radio"] {
    display: none;
}

.gender-label {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    color: #5d5a5a;
    font-size: 14px;
    transition: all 0.2s ease;
    user-select: none;
}

.gender-option input[type="radio"]:checked + .gender-label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: #e7e4e4;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.gender-label:hover {
    border-color: rgba(135, 134, 134, 0.4);
    color: #444343;
}

/* Модальное окно редактора */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal.hidden {
    display: none;
}

/* Редактор аватара открывается ПОВЕРХ другого окна: из инвентаря (вкладка
   «Колобки») и из профиля. z-index у всех .modal одинаковый, а при равном
   z-index выигрывает тот, кто НИЖЕ в DOM, — #avatar-editor-modal же лежит в
   index.html раньше и инвентаря, и профиля, поэтому открывался под ними.
   Своего окна поверх редактора нет, так что ему можно быть выше всех modal. */
#avatar-editor-modal {
    z-index: 10010;
}

.avatar-editor-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.avatar-editor-content .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.avatar-editor-content .modal-header > span {
    font-size: 20px;
    font-weight: bold;
}

.avatar-editor-tabs {
    display: flex;
    gap: 5px;
}

.tab-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: none;
    box-shadow: none;
}

.tab-btn.active {
    background: white;
    color: #764ba2;
    font-weight: bold;
}

.avatar-editor-body {
    padding: 20px;
}

/* Превью ЗАКРЕПЛЕНО при прокрутке. Иначе, домотав до нижних плашек, не видно,
   как выбранный цвет садится на колобка, — а это единственное, ради чего в это
   окно и заходят (жалоба Светы 14.08.2026). Прокручивается `.avatar-editor-body`,
   он и есть контейнер прилипания. Фон обязателен и обязан быть непрозрачным:
   без него плашки едут СКВОЗЬ колобка. */
.avatar-editor-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: white;
    padding: 6px 0 10px;
    box-shadow: 0 6px 10px -8px rgba(0, 0, 0, 0.45);
}

#editor-avatar-preview {
    width: 120px;
    height: 120px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    text-align: center;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.color-option {
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.color-option.selected {
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(calc(-50% + 10px), calc(-50% - 10px));
    font-size: 24px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Опция "без градиента" */
.color-option.no-gradient {
    background: repeating-linear-gradient(
        45deg,
        #ddd,
        #ddd 5px,
        #eee 5px,
        #eee 10px
    );
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #888;
}

/* Сетка узоров */
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.pattern-option {
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
}

.pattern-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.pattern-option.selected {
    border-color: #764ba2;
    background-color: rgba(118, 75, 162, 0.1);
}

.pattern-preview {
    width: 40px;
    height: 40px;
    background-size: 15px 15px;
    border-radius: 8px;
}

.pattern-option span {
    font-size: 11px;
    color: #666;
}

.avatar-editor-content .modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Цвета для color-option */
.color-option.color-orange { background-color: #FF8C00; }
.color-option.color-green { background-color: #2ECC40; }
.color-option.color-blue { background-color: #4DA6FF; }
.color-option.color-red { background-color: #FF4D4D; }
.color-option.color-yellow { background-color: #FFDD57; }
.color-option.color-pink { background-color: #FF66CC; }
.color-option.color-cyan { background-color: #20E5D9; }
.color-option.color-violet { background-color: #A66CFF; }
.color-option.color-black { background-color: #121212; }
.color-option.color-white { background-color: #f3eeee; }
.color-option.color-grey { background-color: #626162; }

/* КНОПКИ */
button {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #8a5836;
    color: white;
}

/* Кнопки комнаты (список 17.10.2026, п.5): сверху главные — начать, настройки,
   удалить; снизу меньше — сесть/встать и выйти. */
.lobby-actions-main,
.lobby-actions-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.lobby-actions-main { margin-top: 20px; }
.lobby-actions-secondary { margin-top: 10px; gap: 8px; }
/* Не владелец: верхняя строка пустая — её отступ забирает нижняя. */
.lobby-actions-main:not(:has(> button:not([style*="display: none"]))) { margin-top: 0; }
.lobby-actions-main:not(:has(> button:not([style*="display: none"]))) + .lobby-actions-secondary {
    margin-top: 20px;
}
.lobby-actions-secondary button {
    padding: 7px 14px;
    font-size: 13px;
}
/* «Вернуться в афтепати» — длинная узкая полоса над списком игроков. */
.lobby-rejoin-bar {
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 10px;
    padding: 5px 12px;
    font-size: 13px;
    background-color: #6a5acd;
}
.lobby-rejoin-bar:hover { background-color: #7b6be0; }

button:hover {
    background-color: #9a6b4a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#enterNameBtn {
    padding: 9px 10px;
    font-size: 13px;
    font-weight: bold;
}

/* ========== СИСТЕМА УВЕДОМЛЕНИЙ ========== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.notification {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.notification:hover {
    transform: scale(1.02);
}

/* ПАНЕЛЬ КОМНАТ */
#rooms-panel {
    display: none;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 2;
}

.rooms-grid {
    display: flex;
    gap: 40px;
    width: 100%;
}

.rooms-left, .rooms-right {
    flex: 1;
    /* Без min-width: 0 длинная строка без пробелов (ник, название, сообщение
       «ааааа…») распирала колонку и выталкивала соседнюю вправо (16.10.2026, п.17). */
    min-width: 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.rooms-left {
    display: flex;
    flex-direction: column;
}

.divider {
    width: 2px;
    background: #8a5836;
    opacity: 0.3;
}

.rooms-subtitle {
    font-size: 24px;
    margin: 0 0 20px 0;
    color: #3a2b20;
}

.rooms-info {
    font-style: italic;
    color: #666;
    margin-bottom: 20px;
}

.join-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.join-row input {
    flex: 1;
    padding: 10px;
    border: 2px solid #8a5836;
    border-radius: 6px;
    font-size: 16px;
}

#rooms-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    flex-shrink: 1;
    min-height: 60px;
}

/* Когда чат лобби виден — уменьшаем список комнат */
#rooms-list.with-lobby-chat {
    max-height: 180px;
}

/* ============================================
   ЧАТ ЛОББИ (в левой колонке)
   ============================================ */
#lobby-chat {
    margin-top: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.lobby-chat-title {
    padding: 10px 14px;
    font-weight: bold;
    font-size: 15px;
    color: #3a2b20;
    border-bottom: 1px solid #e0e0e0;
    background: rgba(138, 88, 54, 0.08);
    border-radius: 8px 8px 0 0;
}

#lobby-chat-messages {
    height: 200px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Ленту можно растянуть за нижний правый угол (v2.0, п.46): 200px хватало
       на пять строк, и переписка комнаты читалась в щёлочку. Высоту запоминаем
       в localStorage — см. initLobbyChatResize. */
    resize: vertical;
    min-height: 100px;
    max-height: 70vh;
}

#lobby-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#lobby-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(138, 88, 54, 0.3);
    border-radius: 3px;
}

.lobby-msg {
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    animation: fadeIn 0.2s ease;
}

.lobby-msg-sender {
    font-weight: bold;
    color: #8a5836;
    margin-right: 6px;
}

.lobby-msg-text {
    color: #3a2b20;
    overflow-wrap: anywhere;
}

.lobby-msg-system {
    color: #999;
    font-style: italic;
    font-size: 12px;
    text-align: center;
    padding: 2px 0;
}

.lobby-msg-time {
    font-size: 11px;
    color: #bbb;
    /* 6px минус пробел перед временем (он нужен, чтобы двойной клик по
       последнему слову не цеплял цифры времени). Время не выделяется и не
       копируется вместе с текстом. */
    margin-left: 2px;
    user-select: none;
    -webkit-user-select: none;
}

.lobby-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    background: white;
    border-radius: 0 0 8px 8px;
}

.lobby-chat-input-area { align-items: flex-end; position: relative; }
.lobby-chat-input-area input,
.lobby-chat-input-area textarea {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
/* Растягивается вверх за уголок (2.5, п.26) */
.lobby-chat-input-area textarea {
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    min-height: 38px;
    max-height: 200px;
    resize: vertical;
    line-height: 1.35;
}

.lobby-chat-input-area input:focus,
.lobby-chat-input-area textarea:focus {
    border-color: #8a5836;
}

/* Остаток символов у поля ввода лобби-чата (v2.0, п.46). Появляется только
   на подходе к лимиту — иначе мозолил бы глаза при каждом «привет». */
.lobby-chat-counter {
    align-self: center;
    font-size: 12px;
    color: #8a7a68;
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    text-align: right;
}
.lobby-chat-counter.over {
    color: #b54c4c;
    font-weight: bold;
}

.lobby-chat-input-area button {
    padding: 8px 14px;
    background: #8a5836;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    min-width: 40px;
}

.lobby-chat-input-area button:hover {
    background: #6d4529;
}

/* ===== ОТВЕТЫ В ЛОББИ-ЧАТЕ ===== */
/* Строка сообщения: текст слева, кнопка «ответить» справа.
   Обычный поток, а не flex: во flex текст был отдельной колонкой, и перенос
   строки начинался под концом ника — у длинного ника сообщение уезжало
   узкой полосой вправо (баги Апреля, п.37). Теперь перенос — от левого края. */
.lobby-msg-line {
    display: block;
    position: relative;
    padding-right: 28px;
}
.lobby-msg-reply-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #8a5836;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 50%;
    opacity: 0.45;
    transition: opacity 0.15s, background 0.15s;
}
.lobby-msg-line:hover .lobby-msg-reply-btn { opacity: 0.9; }
/* 🗑 удалить сообщение (список 24.11.2026, п.5) — левее стрелки ответа.
   Видна при наведении, как ↩; взведённая («Удалить?») — всегда и красная. */
.lobby-msg-line.has-del { padding-right: 52px; }
.lobby-msg-del-btn {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 6px;
    opacity: 0.45;
    transition: opacity 0.15s, background 0.15s;
}
.lobby-msg-del-btn[hidden] { display: none; }
.lobby-msg-line:hover .lobby-msg-del-btn { opacity: 0.9; }
.lobby-msg-del-btn:hover { opacity: 1; background: rgba(181, 76, 76, 0.12); transform: translateY(-50%); box-shadow: none; }
.lobby-msg-del-btn.armed {
    opacity: 1;
    color: #fff;
    background: #b54c4c;
    font-weight: bold;
    white-space: nowrap;
}
.lobby-msg-del-btn.armed:hover { background: #9c3c3c; }
@media (hover: hover) {
    .lobby-msg-del-btn { opacity: 0; }
    .lobby-msg-line:hover .lobby-msg-del-btn { opacity: 0.9; }
    .lobby-msg-del-btn.armed { opacity: 1; }
}
/* Апрель, п.52: общее button:hover ставит transform: translateY(-2px) — он
   затирал центровку translateY(-50%), и стрелка уезжала вниз при наведении. */
.lobby-msg-reply-btn:hover { opacity: 1; background: rgba(138, 88, 54, 0.12); transform: translateY(-50%); box-shadow: none; }

/* Цитата над сообщением-ответом */
.lobby-msg-quote {
    font-size: 11px;
    color: #999;
    font-style: italic;
    border-left: 2px solid #ccc;
    padding-left: 6px;
    margin-bottom: 2px;
    word-break: break-word;
}
.lobby-msg-quote b { color: #8a5836; font-style: normal; }

/* Превью ответа над полем ввода */
.lobby-reply-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 10px;
    padding: 6px 10px;
    background: rgba(138, 88, 54, 0.08);
    border-left: 3px solid #8a5836;
    border-radius: 6px;
    font-size: 12px;
    color: #6b5a4a;
}
.lobby-reply-preview-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lobby-reply-preview-text b { color: #8a5836; }
.lobby-reply-cancel {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
}
.lobby-reply-cancel:hover { color: #c0392b; }

/* КНОПКА СОЗДАНИЯ КОМНАТЫ */
.create-btn {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: bold;
}

/* МОДАЛЬНОЕ ОКНО СОЗДАНИЯ КОМНАТЫ */
#bot-config-modal .modal-content {
    max-width: 420px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#bot-config-modal {
    align-items: flex-start;
    overflow-y: auto;
    padding: 10px 0;
}

#bot-config-modal .modal-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
    padding-top: 2px;
}

#bot-config-modal .modal-footer {
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 3;
}

.modal-content {
    padding: 24px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    color: #3a2b20;
}

.modal-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #3a2b20;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.form-field input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}

.form-field input:focus {
    border-color: #8a5836;
    outline: none;
}

.checkbox-field {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
    align-items: start;
}
.checkbox-field input[type="checkbox"] {
    margin-top: 3px; /* выровнять визуально с первой строкой текста */
}
.checkbox-field label {
    white-space: normal; /* разрешаем переносы */
    display: block;
    word-break: break-word;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* ЛОББИ */
#lobby {
    margin-top: 30px;
    padding: 20px;
    background: #f8f4f0;
    border-radius: 12px;
}

.player-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 10px;
}

.player-sprite {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 8px;
    background-color: #ddd;
    -webkit-mask-image: url('kolobok.png');
    mask-image: url('kolobok.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    position: relative;
    transform: scaleX(-1);
}

/* Слой узора для маленького спрайта */
.player-sprite.has-pattern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    -webkit-mask-image: url('kolobok.png');
    mask-image: url('kolobok.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* Overlay лица для маленького спрайта */
.player-sprite .avatar-face {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 100;
}

/* Шапка из профиля на колобке в лобби (13.09.2026). Лежит рядом со спрайтом,
   а не внутри: спрайт обрезан маской kolobok.png. Коробка = размер колобка,
   сама посадка (сдвиг/масштаб) — applyContainHatPosition, как на баннере. */
.lobby-hat-layer {
    position: absolute;
    top: 0;
    left: 50%;
    width: 60px;
    height: 60px;
    margin-left: -30px;
    object-fit: contain;
    pointer-events: none;
}
.lobby-hat { z-index: 3; }
/* Слой лица над шапкой (13.11.2026, сердечки «влюблённости», applyLobbyFaceTop).
   Колобок в лобби отзеркален — слой тоже; посадка внутри — как у лица в спрайте. */
.lobby-face-top { z-index: 4; transform: scaleX(-1); }
.lobby-face-top > div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-60%, -55%);
    width: 50%;
    height: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.lobby-hat-back { z-index: 0; }

/* ИГРОВОЙ ИНТЕРФЕЙС */
#game-ui {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 100;
}

/* ПАНЕЛЬ ЧАТА */
#chat-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 320px;
    height: 350px;
    min-width: 240px;
    min-height: 220px;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    z-index: 999;
    backdrop-filter: blur(10px);
    overflow: hidden;
    resize: both;            /* пользователь может увеличить чат перетаскиванием угла */
    display: flex;
    flex-direction: column;
    /* size/position НЕ анимируем — иначе перетаскивание угла лагает */
    transition: background 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

/* День - светлый стиль чата */
body.day-mode #chat-panel {
    background: rgba(255, 248, 240, 0.95);
    color: #5a4030;
    border: 2px solid #d4a574;
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.3);
}

body.day-mode #chat-panel .chat-title {
    background: rgba(212, 165, 116, 0.3);
    border-bottom: 1px solid #d4a574;
    color: #5a4030;
}

body.day-mode #chat-panel .chat-input-area {
    background: rgba(212, 165, 116, 0.2);
    border-top: 1px solid #d4a574;
}

body.day-mode #chat-panel #chatInput {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #d4a574;
    color: #5a4030;
}

body.day-mode #chat-panel #chatInput::placeholder {
    color: #8b7355;
}

body.day-mode #chat-panel #sendChatBtn {
    background: #d4a574;
    color: #fff;
}

body.day-mode #chat-panel .chat-message .sender {
    color: #8b5a3c;
}

body.day-mode #chat-panel .chat-message.system {
    color: #8b7355;
}

/* Ночь - тёмный стиль чата */
body.night-mode #chat-panel {
    background: rgba(40, 25, 20, 0.95);
    color: #e8d5c4;
    border: 2px solid #8b5a3c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

body.night-mode #chat-panel .chat-title {
    background: rgba(139, 90, 60, 0.3);
    border-bottom: 1px solid #8b5a3c;
    color: #e8d5c4;
}

body.night-mode #chat-panel .chat-input-area {
    background: rgba(139, 90, 60, 0.2);
    border-top: 1px solid #8b5a3c;
}

body.night-mode #chat-panel #chatInput {
    background: rgba(60, 40, 30, 0.8);
    border: 1px solid #8b5a3c;
    color: #e8d5c4;
}

body.night-mode #chat-panel #chatInput::placeholder {
    color: #a08070;
}

body.night-mode #chat-panel #sendChatBtn {
    background: #8b5a3c;
    color: #fff;
}

body.night-mode #chat-panel .chat-message .sender {
    color: #ffcc88;
}

body.night-mode #chat-panel .chat-message.system {
    color: #a08070;
}

body.night-mode #speaker-status {
    display: none !important;
}

.chat-title {
    font-size: 14px;
    font-weight: bold;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.5s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.chat-close-mobile {
    display: none;
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1;
}
.chat-close-mobile:hover { background: rgba(255,255,255,0.15); }
@media (max-width: 1100px) {
    .chat-close-mobile { display: inline-block; }
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-message .sender {
    font-weight: bold;
    color: #ffeb3b;
    margin-right: 5px;
}

.chat-message.system {
    color: #aaa;
    font-style: italic;
    text-align: center;
    font-size: 12px;
}

body.bubbles-active .chat-message:not(.system) {
    display: block;
}

/* ===== Вкладки чата: «Чат» / «Связь с богом» (в строке заголовка) ===== */
.chat-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.chat-tab {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(127, 127, 127, 0.18);
    color: inherit;
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s, opacity 0.2s;
}
.chat-tab.active { opacity: 1; background: rgba(156, 39, 176, 0.28); font-weight: 700; }
.chat-tab:hover { opacity: 1; }
.chat-tab.chat-tab-unread::after { content: ' ●'; color: #ff5252; }

/* Личка с богом — отдельный список сообщений (показывается вместо #chat-messages) */
#god-dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    flex-direction: column;
    gap: 6px;
}
.god-dm-message {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    padding: 4px 9px;
    border-radius: 9px;
    max-width: 92%;
}
.god-dm-message.dm-out { align-self: flex-end; background: rgba(76, 175, 80, 0.18); }
.god-dm-message.dm-in { align-self: flex-start; background: rgba(156, 39, 176, 0.20); }
.god-dm-message .sender { font-weight: bold; color: #ce93d8; margin-right: 4px; }

#godDmRecipient {
    flex: 1 1 100%;          /* занимает всю первую строку — поле и кнопка переносятся вниз */
    max-width: none;
    font-size: 12px;
    border-radius: 6px;
    padding: 5px;
}

/* Выбор адресата обычного чата у бога: игрокам / только зрителям */
#godChatTargetSelect {
    flex: 1 1 100%;
    max-width: none;
    font-size: 12px;
    border-radius: 6px;
    padding: 5px;
    background: rgba(156, 39, 176, 0.15);
    border: 1px solid rgba(156, 39, 176, 0.4);
    color: inherit;
}

/* Адаптив под телефон: вкладки крупнее для пальца */
@media (max-width: 1100px) {
    .chat-tab { font-size: 13px; padding: 9px 6px; }
    #godDmRecipient { font-size: 13px; }
    #godChatTargetSelect { font-size: 13px; }
}

/* ============================================
   ПОДСКАЗКИ ДЛЯ НОВИЧКОВ (онбординг)
   Адаптивные: баннер снизу + приветственная карточка.
   ============================================ */
.hint-banner {
    position: fixed;
    top: 50px;
    right: 16px;
    left: auto;
    bottom: auto;
    transform: translateY(-160%);
    z-index: 100050;
    max-width: min(360px, 88vw);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(30, 18, 45, 0.97);
    color: #f3ecff;
    border: 1px solid #9c6dd6;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.45);
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.hint-banner.visible { transform: translateY(0); opacity: 1; }
.hint-banner-body { flex: 1; }
.hint-banner-body b { color: #d8b4ff; }
.hint-banner-close {
    flex-shrink: 0;
    background: #7e57c2;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.hint-banner-close:hover { background: #9575cd; }

.hint-welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 100060;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.hint-welcome-card {
    max-width: min(460px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
    background: linear-gradient(160deg, #2a1840, #1c1230);
    color: #f3ecff;
    border: 1px solid #9c6dd6;
    border-radius: 16px;
    padding: 22px 22px 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}
.hint-welcome-title { font-size: 20px; font-weight: 800; margin-bottom: 14px; text-align: center; }
.hint-welcome-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.hint-welcome-list li { font-size: 14px; line-height: 1.45; }
.hint-welcome-btn {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 700;
    background: #7e57c2;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.hint-welcome-btn:hover { background: #9575cd; }

@media (max-width: 600px) {
    .hint-banner { font-size: 13px; padding: 10px 12px; gap: 8px; flex-direction: column; align-items: stretch; top: 10px; right: 8px; left: 8px; max-width: none; }
    .hint-banner-close { width: 100%; padding: 9px; }
    .hint-welcome-title { font-size: 18px; }
    .hint-welcome-list li { font-size: 13px; }
}

.chat-input-area {
    display: flex;
    flex-wrap: wrap;          /* селект адресата — на 1-й строке, поле+кнопка — на 2-й */
    align-items: flex-end;    /* при увеличенном поле ввода кнопки прижаты к его низу */
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border-top: 1px solid rgba(255,255,255,0.1);
    gap: 8px;
}

#chatInput {
    flex: 1 1 auto;
    min-width: 0;            /* без этого поле не сжимается и кнопка «слезает» вниз */
    min-height: 38px;        /* одинаковая высота с кнопками микрофона/отправки */
    max-height: 220px;       /* не даём разрастись на весь чат */
    height: 38px;            /* стартовая высота = одна строка */
    box-sizing: border-box;
    resize: vertical;        /* пользователь может увеличить поле ввода по высоте */
    overflow-y: auto;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: white;
    padding: 6px 10px;
    font-family: inherit;    /* textarea иначе берёт моноширинный шрифт */
    font-size: 13px;
    line-height: 1.4;
}

#chatInput:focus {
    outline: none;
    border-color: #ffeb3b;
}

/* «Мои провайдеры» над полями своего провайдера (окно бота и «Сменить модель»). */
.saved-provider-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}
.saved-provider-row select { flex: 1 1 auto; min-width: 0; margin: 0; }
.saved-provider-row button {
    flex: 0 0 auto;
    padding: 6px 9px;
    font-size: 14px;
    line-height: 1;
    margin: 0;
}

/* Сколько символов ещё можно написать — число уменьшается с каждым символом. */
.chat-char-counter {
    align-self: center;
    flex: 0 0 auto;
    min-width: 30px;
    font-size: 11px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
    user-select: none;
}
.chat-char-counter.low { color: #e0913a; opacity: 1; font-weight: bold; }
.chat-char-counter.over { color: #d64545; opacity: 1; font-weight: bold; }

#sendChatBtn {
    background: #ffeb3b;
    border: none;
    border-radius: 6px;
    color: #333;
    font-weight: bold;
    width: 40px;
    height: 38px;             /* одинаковая высота с полем и микрофоном */
    box-sizing: border-box;
    flex-shrink: 0;          /* кнопка не сжимается и не переносится на новую строку */
    align-self: center;
    cursor: pointer;
    transition: transform 0.1s;
}

#sendChatBtn:active {
    transform: scale(0.9);
}

/* Кнопка голосового ввода (диктовка через STT) */
#dictation-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: white;
    /* Апрель, п.32 (Света: «кнопку поменьше»): было 40×38 — вровень с полем.
       padding: 0 — иначе общее button { padding: 12px 24px } мешает ужаться. */
    font-size: 13px;
    width: 28px;
    height: 28px;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: center;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}
#dictation-btn:hover {
    background: rgba(255,255,255,0.2);
}
#dictation-btn:active {
    transform: scale(0.9);
}
/* Идёт распознавание — красная пульсация */
#dictation-btn.listening {
    background: #e53935;
    border-color: #e53935;
    color: #fff;
    animation: dictation-pulse 1.2s ease-in-out infinite;
}
@keyframes dictation-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.6); }
    50% { box-shadow: 0 0 0 6px rgba(229,57,53,0); }
}

/* ИСТОРИЯ ГОЛОСОВАНИЙ */
/* Апрель, п.36: перетаскивается за заголовок и растягивается за правый нижний
   угол (initVotingHistoryPanel в script.js; на телефоне — своя раскладка из
   mobile-ui.css). По умолчанию — на прежнем месте, сверху справа от чата
   (12.11.2026, в): «справа внизу» не прижилось. */
#voting-history {
    position: fixed;
    top: 20px;
    left: 360px;
    width: 220px;
    min-width: 180px;
    min-height: 44px;
    max-width: calc(100vw - 16px);
    max-height: 400px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    border-radius: 12px;
    z-index: 999;
    backdrop-filter: blur(10px);
    overflow: hidden;
    resize: both;
    display: none; /* Скрыто по умолчанию */
    flex-direction: column;
}

#voting-history.visible {
    display: flex;
}

/* Во время перетаскивания — без размытия фона под панелью (п.16 списка
   24.11.2026): его пересчёт на каждом сдвиге давал рывки. Фон чуть плотнее,
   чтобы без размытия текст читался так же. */
#voting-history.dragging {
    backdrop-filter: none;
    background: rgba(0, 0, 0, 0.92);
}

#voting-history.collapsed {
    height: auto !important;
    min-height: 0;
    resize: none;
}

.voting-history-title {
    font-size: 14px;
    font-weight: bold;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: move;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
}

.voting-history-collapse-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    line-height: 22px;
    padding: 0; /* общий padding кнопок 12px 24px съедал стрелку целиком */
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, background 0.15s ease;
}

.voting-history-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none; /* общий button:hover сдвигает вверх и затирает поворот */
}

#voting-history.collapsed .voting-history-collapse-btn,
#voting-history.collapsed .voting-history-collapse-btn:hover {
    transform: rotate(-90deg);
}

#voting-history.collapsed #voting-history-content {
    display: none;
}

#voting-history-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    /* Firefox; толщину и цвет для Chrome — ниже */
    scrollbar-color: rgba(255, 210, 120, 0.75) rgba(255, 255, 255, 0.12);
}

/* Скроллбар был почти невидим (6px, белый 30%) — п.36 */
#voting-history-content::-webkit-scrollbar {
    width: 10px;
}

#voting-history-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 5px;
}

#voting-history-content::-webkit-scrollbar-thumb {
    background: rgba(255, 210, 120, 0.75);
    border-radius: 5px;
}

#voting-history-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 220, 140, 0.95);
}

.voting-day-block {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.voting-day-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.voting-day-header {
    font-size: 13px;
    font-weight: bold;
    color: #ffeb3b;
    margin-bottom: 8px;
}

/* Сетка, а не flex-wrap. Раньше строка была flex с переносом, и на 12+ игроках
   длинный список голосовавших переносился ЦЕЛИКОМ на следующую строку, отрываясь
   от своего кандидата. Аватарка кандидата и аватарки голосовавших — один и тот же
   кружок .mini-avatar, поэтому перенесённая строка читалась как ещё один кандидат:
   «съезжают голосовавшие и словно дублируются те, в кого голосовали» (п.16
   April_master). В сетке кандидат закреплён в своей колонке, а голосовавшие
   переносятся внутри СВОЕЙ и никуда не уезжают. */
.voting-candidate-row {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: start;   /* кандидат остаётся на первой строке, когда список перенёсся */
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

/* «Воздержались»: подпись + список, без кандидата, стрелки и итога.
   Не сетка, а поток: в сетке «auto 1fr» подпись («Воздержались (перевесили):»)
   растягивала свою колонку на всю ширину узкой панели, и список ужимался до
   одной аватарки в строке — воздержавшиеся шли столбиком (баги Апреля, п.35). */
.voting-candidate-row.voting-skip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.voting-candidate {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
    color: #ff9800;
    white-space: nowrap;   /* номер места не должен отрываться от аватарки */
}

.voting-candidate.executed {
    color: #ff4444;
    text-decoration: line-through;
}

.voting-arrow {
    color: #888;
    font-size: 14px;
}

.voting-voters {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
}

.voting-voters-hidden {
    color: #d7c8a9;
    font-weight: 700;
    padding: 2px 8px;
    border: 1px solid rgba(215, 200, 169, 0.24);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.voting-voter {
    display: flex;
    align-items: center;
    gap: 2px;
    color: #aaa;
    white-space: nowrap;   /* номер места не должен отрываться от аватарки */
}

.voting-total {
    color: #4caf50;
    font-weight: bold;
    justify-self: end;   /* своя колонка сетки; margin-left:auto тут больше не нужен */
}

.mini-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    transform: scaleX(-1);
}

.mini-avatar.color-orange { background-color: #ff9800; }
.mini-avatar.color-green { background-color: #4caf50; }
.mini-avatar.color-blue { background-color: #2196f3; }
.mini-avatar.color-red { background-color: #f44336; }
.mini-avatar.color-yellow { background-color: #ffeb3b; }
.mini-avatar.color-pink { background-color: #e91e63; }
.mini-avatar.color-cyan { background-color: #00bcd4; }
.mini-avatar.color-violet { background-color: #9c27b0; }
.mini-avatar.color-black { background-color: #121212; }
.mini-avatar.color-white { background-color: #f3eeee; }
.mini-avatar.color-grey { background-color: #626162; }

/* ========== OVERLAY ЛИЦ ДЛЯ АВАТАРОВ ========== */
/* Overlay лица для маленького спрайта (lobby/room) */
.player-sprite .avatar-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-60%, -55%);
    width: 50%;
    height: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 100;
}

/* Нагатроник вне стола (24.11.2026): +20% к размеру лица в лобби комнаты.
   scale стоит после translate — лицо растёт вокруг своего центра и не съезжает. */
.player-sprite .avatar-face[data-face-pack="nagatronfaces"] {
    transform: translate(-60%, -55%) scale(1.21);
}

/* Лицо внутри спрайта за столом — не используется (face вынесено на уровень seat) */
.player-sprite-table .avatar-face {
    display: none;
}

/* Overlay лица для мини-аватара */
.mini-avatar .avatar-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-65%, -55%);
    width: 80%;
    height: 80%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 50;
}

/* КНОПКА ВОЗДЕРЖАТЬСЯ */
.abstain-btn {
    position: fixed;
    right: 30px;
    bottom: 50%;
    padding: 15px 30px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1100;
    transition: all 0.2s ease;
    display: none;
}

.abstain-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.abstain-btn:active {
    transform: translateY(0);
}

.abstain-btn.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Баннер объявлений диктора (v2.0) */
@keyframes subphaseAnnounceIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes subphaseAnnounceOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ФИНАЛЬНОЕ ГОЛОСОВАНИЕ (казнить / помиловать) */
.final-vote-ui {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 20, 10, 0.95);
    border: 2px solid #ff9800;
    border-radius: 16px;
    padding: 24px 32px;
    z-index: 1200;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.4s ease;
    min-width: 320px;
}

.final-vote-title {
    color: #ff9800;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 8px;
}

.final-vote-subtitle {
    color: #ddd;
    font-size: 15px;
    margin-bottom: 20px;
}

.final-vote-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 16px;
}

.final-vote-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.final-vote-btn.execute-btn {
    background: linear-gradient(135deg, #e53935, #b71c1c);
    color: white;
}

.final-vote-btn.execute-btn:hover {
    background: linear-gradient(135deg, #f44336, #c62828);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.4);
}

.final-vote-btn.spare-btn {
    background: linear-gradient(135deg, #43a047, #2e7d32);
    color: white;
}

.final-vote-btn.spare-btn:hover {
    background: linear-gradient(135deg, #4caf50, #388e3c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(67, 160, 71, 0.4);
}

.final-vote-btn.selected {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    outline: 3px solid #fff;
}

.final-vote-btn.dimmed {
    opacity: 0.4;
    pointer-events: none;
    transform: scale(0.95);
}

.final-vote-counter {
    color: #aaa;
    font-size: 14px;
    margin-top: 4px;
}

#phase-display {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 1000;
    padding: 12px 30px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    transition: all 0.5s ease;
}

/* День - светлый стиль */
body.day-mode #phase-display {
    background: rgba(255, 248, 240, 0.9);
    color: #5a4030;
    border: 2px solid #d4a574;
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.3);
}

/* Ночь - тёмный стиль */
body.night-mode #phase-display {
    background: rgba(40, 25, 20, 0.9);
    color: #e8d5c4;
    border: 2px solid #8b5a3c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#phase-title {
    margin: 0;
    font-size: 24px;
}

#phase-number {
    font-size: 24px;
    font-weight: bold;
    margin-left: 10px;
}

/* КАРТОЧКА РОЛИ */
.role-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #8a5836;
    border-radius: 15px;
    padding: 30px 50px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.role-card.visible {
    opacity: 1;
    pointer-events: auto;
}

.role-card h1,
.role-card .role-display-title {
    margin: 20px 0 0 0;
    font-size: 36px;
    font-weight: bold;
    color: #8a5836;
}

/* Видно только поисковикам и экранным читалкам (#site-h1) */
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ИГРОВОЙ СТОЛ */
#game-table-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* dvh учитывает текущую видимую высоту вьюпорта (без адресной строки на мобиле).
       vh — фолбек для старых браузеров. */
    height: 70vh;
    height: 70dvh;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 50;
}

/* ИГРОВОЙ СТОЛ */
.game-table-wrapper {
    position: relative;
    /* Фиксированный natural-размер (design-size). На узких экранах
       уменьшается через transform: scale(...) — см. fitGameTable() в script.js */
    width: 1280px;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    transform-origin: bottom center;
    will-change: transform;
    /* Важно: wrapper не должен иметь z-index, создающего изоляцию, если table имеет */
    z-index: auto;
}

.game-table {
    width: 1200px; 
    height: 600px; 
    position: absolute;
    bottom: -200px; 
    /* Стол выше колобков/шапок/лиц, но ниже имён и табличек.
       Верх стека мест — 103 (см. baseZ в script.js, 20 игроков), поэтому 120.
       Всё, что должно быть НАД столом, живёт в 130–150; выше уже .player-tags (200). */
    z-index: 120;
    background: url('table.png') center / contain no-repeat;
    pointer-events: none; /* Чтобы клики проходили к спрайтам, если они под ним, но тут спрайты под столом визуально */
}

/* ЗАДНИЙ СЛОЙ СТОЛА (tableLayers в settingsConfig.js).
   Нужен там, где игроки сидят НА самом столе, а не за ним: в «Пчелином улье»
   стол — цветок, места приходятся на дальние лепестки, и цельная картинка
   поверх мест прятала бы игроков под столом.

   Стол (.game-table) при этом остаётся тем же, чем он был всегда, — верхним
   слоем поверх колобков; в таком сеттинге от него остаётся только ближний
   ободок (своим спрайтом или маской). А дальняя половина уезжает СЮДА, под
   места. Картинка заднего слоя — table_down.png из папки сеттинга, а если его
   нет — копия table.png целиком.

   Геометрия обязана совпадать со столом до пикселя, иначе слои разъедутся:
   те же 1200×600, тот же bottom, то же center/contain. */
.game-table-back {
    width: 1200px;
    height: 600px;
    position: absolute;
    bottom: -200px;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    /* Ниже всего стека мест (минимум — задний слой шапки, 4). */
    z-index: 1;
    pointer-events: none;
}

/* Контейнер для игроков вокруг стола */
.players-around-table {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: auto; /* НЕ СОЗДАЕМ КОНТЕКСТ */
    top: 0;
    left: 0;
    pointer-events: none;
}

/* ИГРОК ЗА СТОЛОМ - ЯКОРЬ */
.player-at-table {
    position: absolute;
    display: flex; 
    width: 0;
    height: 0;
    transform: none;
    z-index: auto;
    
    justify-content: center;
    align-items: center;
    
    pointer-events: auto; /* Включаем события для контейнера */
}

/* Общие правила для частей игрока */
.player-at-table > * {
    position: absolute;
    left: 50%;
    /* transform переносим на детей */
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

/* Выноска позиционируется отдельно, без общего centering-трансформа */
.player-at-table > .speech-bubble {
    left: auto;
    transform: none;
}

/* НОМЕР ИГРОКА */
.player-number {
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: bold;
    color: #333;
    pointer-events: none;
    white-space: nowrap;
    
    /* Позиция - ставим на ту же высоту, что и имя */
    top: 25px;
    margin-left: -50px; /* Сдвиг влево относительно центра, чтобы быть слева от имени */
    z-index: 130; /* ВЫШЕ СТОЛА (стол — 120) */
}

/* СПРАЙТ ИГРОКА ЗА СТОЛОМ */
.player-sprite-table {
    width: 170px;
    height: 170px;
    min-width: 170px;
    min-height: 170px;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: #FF8C00; /* Дефолтный цвет */
    background-size: cover;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -135px; /* Центрируем по вертикали относительно якоря */
    z-index: var(--seat-sprite-z, 34); /* Слой колобка задаётся симметрично от краёв к центру */
    /* Крайние места стоят на дробных координатах (calc(50% + float px)) — браузер
       рисует тонкий вертикальный шов по центру при субпиксельном композитинге.
       Выносим колобок на собственный слой → шов исчезает. */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
}

/* Слой узора для спрайта за столом.

   РАЗМЕР СЛОЯ СЧИТАЕТСЯ, А НЕ ПОДБИРАЕТСЯ. Все ручные PNG узоров нарисованы в
   форме колобка: сам рисунок занимает 65,4% холста (замерено по альфе — bbox
   172..841 из 1024, ровно как у kolobok.png). В масочных контекстах (лобби,
   профиль, превью) и шар, и узор режутся одной и той же маской kolobok.png,
   поэтому там рисунок совпадает с шаром пиксель в пиксель. За столом маски нет
   — шар занимает весь бокс 170px, и слой обязан быть во столько же раз больше:
   170 / 0,654 ≈ 260px. Стояло 250px, то есть узор выходил на 4% МЕНЬШЕ шара, и
   по краю колобка оставалось пустое кольцо ~3px (жалоба Светы 01.09.2026
   «узоры меньше самих колобков, белые круги не достают края»). Плюс 6px запаса
   на то, что художник у самого края рисует не всегда: лишнее всё равно срежет
   маска ниже, а пустого кольца больше не остаётся.

   Размер задан ОДНОЙ переменной, top/left и центр маски считаются от неё через
   calc/at center — раньше числа (250 / -38 / -39 / 124px 123px) дублировали
   друг друга, и правка размера требовала пересчёта маски руками. */
.player-sprite-table.has-pattern::after {
    --table-pattern-layer: 260px;
    content: '';
    position: absolute;
    top: calc((170px - var(--table-pattern-layer)) / 2);
    left: calc((170px - var(--table-pattern-layer)) / 2);
    width: var(--table-pattern-layer);
    height: var(--table-pattern-layer);
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    pointer-events: none;
    mix-blend-mode: overlay;
    /* ОБРЕЗКА ПО ШАРУ. Слой больше спрайта, поэтому всё, что художник нарисовал
       за пределами колобка, торчало наружу: при opacity .5 без контраста это
       было почти незаметно, а после подъёма контраста полезли белые куски
       вокруг шара (жалоба Светы 14.08.2026). Слой центрирован по спрайту, так
       что круг шара — это ровно центр слоя при радиусе 85 (половина 170px). */
    -webkit-mask-image: radial-gradient(circle 85px at center, #000 99%, transparent 100%);
    mask-image: radial-gradient(circle 85px at center, #000 99%, transparent 100%);
}

/* ТАЙЛОВЫЕ узоры заливают весь квадрат холста: за столом обрезаем слой по кругу
   аватара (border-radius клипует фон), иначе узор вылезает за спрайт.
   Остальным — рисункам В ФОРМЕ КОЛОБКА (все ручные PNG и мои нетайловые SVG) —
   оставляем большой слой --table-pattern-layer: он ровно навёрстывает то, что в других местах
   съедает маска колобка (видимая часть там 65% бокса), и рисунок садится на шар
   целиком. Раньше признаком служило `data:` в URL, но это НЕ то свойство: «Комикс»
   тоже вектор, а нарисован по форме колобка — и за столом выходил заметно меньше
   шара (жалоба Светы 14.08.2026). Признак теперь объявляется явно, см.
   AVATAR_PATTERNS_TILED в script.js. */
.player-sprite-table.pattern-vector::after {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    /* Слой уже ровно по спрайту и обрезан border-radius — радиальная маска из
       правила выше здесь не нужна и была бы смещена (у неё координаты слоя 250×250). */
    -webkit-mask-image: none;
    mask-image: none;
}

/* Overlay лица для спрайта за столом — ВЫНЕСЕНО на уровень seat */
.player-at-table > .avatar-face-table {
    position: absolute;
    left: 50%;
    top: -135px; /* Совпадает с top спрайта */
    width: 170px;  /* Совпадает с размером спрайта */
    height: 170px;
    transform: translateX(-50%) translateX(-10px);
    z-index: var(--seat-face-z, 44); /* Лицо всегда выше шапки, но ниже стола */
    pointer-events: none;
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: 43% 45%;
}

/* Собранное конструктором лицо (13.11.2026): холст с полями по 25% с каждой
   стороны (TABLE_PAD в faceConstructor.js), поэтому коробка в 1,5 раза больше
   и выше на столько же — лицо на месте, а сердечки «влюблённости» и прочее,
   что крупнее колобка, не срезаются краем. */
.player-at-table > .avatar-face-table.face-built {
    width: 255px;
    height: 255px;
    top: -177.5px;
}

/* Зеркалирование лица для flipped игроков */
.player-at-table.flipped > .avatar-face-table {
    transform: translateX(-50%) translateX(10px) scaleX(-1);
}

/* Для игроков справа (flipped) — зеркалим весь спрайт */
.player-at-table.flipped .player-sprite-table {
    transform: translateX(-50%) scaleX(-1);
}

/* Имя игрока */
.player-name-table {
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: bold;
    color: #333;
    pointer-events: none;
    white-space: nowrap;
    
    /* Позиция */
    top: 25px; /* Та же высота, что и у номера */
    margin-left: 20px; /* Сдвиг вправо, чтобы не накладывался на номер, а был рядом */
    z-index: 130; /* ВЫШЕ СТОЛА (стол — 120) */
}


/* ТАЙМЕР */
#phase-timer {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 10px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    opacity: 0;
    /* Невидимый таймер не должен ловить клики: в меню он лежит прямо поверх
       счётчика «Онлайн», и тот нажимался только на зелёную точку. */
    pointer-events: none;
    transition: all 0.5s ease;
}

#phase-timer.visible-timer {
    opacity: 1;
    pointer-events: auto;
}

/* Предупреждение о конце фазы — оранжевая пульсация (за 10 сек до конца) */
#phase-timer.timer-warn {
    animation: phase-timer-warn 1s ease-in-out infinite;
    border-color: #ff9800 !important;
    color: #ff9800 !important;
}
@keyframes phase-timer-warn {
    0%, 100% { box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4); transform: scale(1); }
    50%      { box-shadow: 0 4px 22px rgba(255, 152, 0, 0.85); transform: scale(1.06); }
}

/* Опасность — красная быстрая пульсация (за 5 сек до конца) */
#phase-timer.timer-danger {
    animation: phase-timer-danger 0.55s ease-in-out infinite;
    border-color: #f44336 !important;
    color: #f44336 !important;
    font-weight: 700;
}
@keyframes phase-timer-danger {
    0%, 100% { box-shadow: 0 4px 16px rgba(244, 67, 54, 0.5); transform: scale(1); }
    50%      { box-shadow: 0 4px 28px rgba(244, 67, 54, 1); transform: scale(1.1); }
}

/* День - светлый стиль таймера */
body.day-mode #phase-timer {
    background: rgba(255, 248, 240, 0.9);
    color: #5a4030;
    border: 2px solid #d4a574;
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.3);
}

/* Ночь - тёмный стиль таймера */
body.night-mode #phase-timer {
    background: rgba(40, 25, 20, 0.9);
    color: #e8d5c4;
    border: 2px solid #8b5a3c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#phase-label {
    font-size: 14px;
    opacity: 0.9;
    /* v2.0: таймер не должен расползаться влево и наезжать на кнопки —
       длинные названия фаз обрезаются с многоточием */
    max-width: 150px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* Когда на экране счётчик зрителей (он стоит слева от таймера, right: 236px),
   таймеру остаётся меньше места: режем подпись сильнее, иначе «Речь: Имя»
   вырастает на 260px и накрывает плашку. Класс ставит updateSpectatorsButton(). */
body.has-spectators #phase-label {
    max-width: 96px;
}

#phase-time {
    font-size: 20px;
    font-weight: bold;
    font-family: monospace;
}

/* ЦВЕТА ДЛЯ СПРАЙТОВ */
.player-sprite.color-orange, .player-sprite-table.color-orange { background-color: #FF8C00; }
.player-sprite.color-green,  .player-sprite-table.color-green  { background-color: #2ECC40; }
.player-sprite.color-blue,   .player-sprite-table.color-blue   { background-color: #4DA6FF; }
.player-sprite.color-red,    .player-sprite-table.color-red    { background-color: #FF4D4D; }
.player-sprite.color-yellow, .player-sprite-table.color-yellow { background-color: #FFDD57; }
.player-sprite.color-pink,   .player-sprite-table.color-pink   { background-color: #FF66CC; }
.player-sprite.color-cyan,   .player-sprite-table.color-cyan   { background-color: #20E5D9; }
.player-sprite.color-violet, .player-sprite-table.color-violet { background-color: #A66CFF; }
.player-sprite.color-black,  .player-sprite-table.color-black  { background-color: #121212; }
.player-sprite.color-white,  .player-sprite-table.color-white  { background-color: #f3eeee; }
.player-sprite.color-grey,   .player-sprite-table.color-grey   { background-color: #626162; }

/* МЕРТВЫЙ ИГРОК */
.player-at-table.dead .player-sprite-table {
    filter: grayscale(50%) brightness(0.5) contrast(1.2);
}

/* Пасхалочный аватар-картинка: убираем обрезку по кругу */
.easter-egg-avatar {
    background-color: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    /* Рамку и outline снимаем: у .profile-banner-avatar есть border 3px, и без
       маски-колобка + с border-radius:0 он рисовался ЗАМЕТНЫМ КВАДРАТОМ вокруг
       картинки (в профилях людей и ботов). Картиночному аватару рамка не нужна —
       у него своя форма. */
    border: none !important;
    outline: none !important;
}

/* Маска и размер картиночных аватаров правятся ВСЮДУ, КРОМЕ СТОЛА.
   За столом (.player-sprite-table) маски-колобка нет и картинка всегда заливала весь
   бокс 170×170 через cover — там всё отображалось верно, а общая ужимка до 72% делала
   уникальные аватары заметно мельче цветных. Стол не трогаем.
     - маска-колобок обрезала цельные PNG (шар с шапкой, основанием) по силуэту колобка,
       и в комнате/профиле был виден только центр → снимаем;
     - без маски цветной колобок занимает ~66% бокса, а картинка залила бы 100% →
       ужимаем картинку до близкой доли. Крутить размер ЗДЕСЬ. */
.easter-egg-avatar:not(.player-sprite-table) {
    -webkit-mask-image: none !important;
    mask-image: none !important;
    /* 66%, а не 72%: измерено по картинкам. Непрозрачная часть kolobok.png (маска
       цветного колобка) занимает 65% ширины бокса, а уникальные спрайты залиты почти
       под края своего холста (~98.5%), поэтому 65 / 0.985 ≈ 66. На 72% уникальные
       колобки были заметно крупнее обычных — это и правил. */
    background-size: 66% !important;
    background-position: center !important;
}

/* Мини-аватар (список «кто как проголосовал», история голосований) — исключение:
   маски-колобка у него нет вовсе, это просто кружок 16px, и ЦВЕТНОЙ аватар занимает
   все 100% бокса. С общей ужимкой до 66% картиночные колобки выходили заметно мельче
   соседей-обычных, поэтому здесь картинка растягивается на весь бокс. */
.mini-avatar.easter-egg-avatar:not(.player-sprite-table) {
    background-size: contain !important;
}

/* Для пасхалочных аватаров: убираем outline (прямоугольный), оставляем только drop-shadow по контуру изображения */
.player-at-table.mafia-target:hover .player-sprite-table.easter-egg-avatar {
    outline: none;
    filter: drop-shadow(0 0 8px red) drop-shadow(0 0 15px rgba(255, 0, 0, 0.6));
}
.player-at-table.voting-target:hover .player-sprite-table.easter-egg-avatar {
    outline: none;
    filter: drop-shadow(0 0 8px #ff9800) drop-shadow(0 0 15px rgba(255, 152, 0, 0.6));
}
.player-at-table.nomination-target:hover .player-sprite-table.easter-egg-avatar {
    outline: none;
    filter: drop-shadow(0 0 8px #2196f3) drop-shadow(0 0 15px rgba(33, 150, 243, 0.6));
}

/* ========== СИСТЕМА ТАБЛИЧЕК ========== */

/* Контейнер для всех табличек под игроком */
.player-tags {
    position: absolute;
    top: 40px; /* Под номером и именем — поднято на 10px */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 200; /* Выше стола */
    pointer-events: none;
}
/* Контейнер для табличек НАД игроком */
.player-top-tags {
    position: absolute;
    bottom: 190px; /* Над спрайтом и шапкой — не перекрывает колобка */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column; /* Голоса снизу, индикатор "Я" сверху */
    align-items: center;
    gap: 10px;
    z-index: 200; /* Выше стола */
    pointer-events: none;
}
/* Базовый стиль для всех табличек */
.player-tag {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    /* Видимость НЕ зависит от анимации (23.10.2026): раньше база была opacity: 0,
       а видимой табличку делала только tagAppear с forwards. Любое правило со
       своей animation (пульс «Выставлен», animation: none на телефоне) оставляло
       табличку прозрачной — она занимала строку, и «УБИТ» съезжал вниз.
       Теперь появление — backwards-анимация от прозрачной к обычной. */
    animation: tagAppear 0.3s ease backwards;
}

.player-tag::before {
    font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "Android Emoji", sans-serif;
    font-size: 1.1em;
    display: inline-block;
    vertical-align: middle;
}

.player-tag.my-role::before,
.player-tag.mafia-teammate::before,
.player-tag.mafia-ally::before,
.player-tag.killed::before,
.player-tag.executed::before,
.player-tag.dead-status::before,
.player-tag.final-role::before {
    content: none;
}

@keyframes tagAppear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Строка 1: Моя роль (только для себя) */
.player-tag.my-role {
    background: linear-gradient(135deg, #6a1b9a, #9c27b0);
    color: white;
    border: 2px solid #ce93d8;
}

/* Моя роль: мирный/мафия/союзник мафии */
.player-tag.my-role.role-peaceful {
    background: linear-gradient(135deg, #ef9a9a, #e57373);
    border: 2px solid #ffcdd2;
}
body.night-mode .player-tag.my-role.role-peaceful {
    background: linear-gradient(135deg, #b71c1c, #c62828);
    border-color: #ef5350;
}

.player-tag.my-role.role-mafia {
    background: linear-gradient(135deg, #ce93d8, #ba68c8);
    border: 2px solid #e1bee7;
}
body.night-mode .player-tag.my-role.role-mafia {
    background: linear-gradient(135deg, #4a148c, #6a1b9a);
    border-color: #ab47bc;
}

.player-tag.my-role.role-mafia-ally {
    background: linear-gradient(135deg, #9e9e9e, #8d8d8d);
    border: 2px solid #d0d0d0;
}
body.night-mode .player-tag.my-role.role-mafia-ally {
    background: linear-gradient(135deg, #4a148c, #7b1fa2);
    border-color: #ba68c8;
}

/* Маньяк (v2.0) — третья сторона, поэтому и цвет третий: ЖЁЛТЫЙ. Днём светлый,
 * ночью насыщенный — как у мирных/мафии выше. Текст тёмный: белым по жёлтому
 * не читается. Одно правило на все три таблички (своя роль, режим бога, финал):
 * рисуются они в разных местах, а цвет роли обязан быть один. */
.player-tag.my-role.role-maniac,
.player-tag.god-role.role-maniac,
.player-tag.final-role.role-maniac {
    /* Дневной жёлтый был почти белым (#fff59d → #ffe082) и на светлых фонах —
       «Пчёлы» с их пыльцой и цветами хуже всего — табличка читалась как
       ПРОЗРАЧНАЯ: светлая заливка, светлая рамка, светлый фон под ней.
       Берём насыщенный янтарь: он такой же «дневной светлый», как розовый у
       мирных (#e57373), но не растворяется ни на светлом, ни на тёмном. */
    background: linear-gradient(135deg, #ffc107, #ffa000);
    border: 2px solid #fff3c4;
    color: #3a2704;
}
body.night-mode .player-tag.my-role.role-maniac,
body.night-mode .player-tag.god-role.role-maniac,
body.night-mode .player-tag.final-role.role-maniac {
    background: linear-gradient(135deg, #fbc02d, #f9a825);
    border-color: #ffe082;
    color: #3b2a05;
}

.player-tag.my-role::before {
    content: none;
}

.player-tag.mafia-teammate {
    background: linear-gradient(135deg, #000000, #333333);
    color: white;
    border: 2px solid #555555;
}

body.day-mode .player-tag.mafia-teammate {
    background: linear-gradient(135deg, #9e9e9e, #8d8d8d);
    border-color: #d0d0d0;
}

.player-tag.mafia-teammate::before {
    content: none;
}

.player-tag.mafia-ally {
    background: linear-gradient(135deg, #4a148c, #7b1fa2);
    color: white;
    border: 2px solid #ba68c8;
}

.player-tag.mafia-ally::before {
    content: none;
}

.player-tag.mafia-suggestion {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    font-size: 10px;
    border: 1px solid #e65100;
    animation: pulse 1s infinite alternate;
}

.player-tag.mafia-suggestion::before {
    content: "🎯";
}

@keyframes pulse {
    from { opacity: 0.7; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1.05); }
}

@keyframes botThinkPulse {
    0%, 100% { opacity: 0.4; transform: translateX(-50%) scale(0.8); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.2); }
}

/* Строка 2: Информация от шерифа */
.player-tag.sheriff-check {
    background: linear-gradient(135deg, #b71c1c, #d32f2f);
    color: white;
    border: 2px solid #ff5252;
}

.player-tag.sheriff-check::before {
    content: "🔍";
}

/* Проверка шерифа: "ЭТО МАФИЯ" (Черный с красной рамкой для акцента) */
.player-tag.sheriff-check.is-mafia {
    background: linear-gradient(135deg, #000000, #1a1a1a);
    border: 2px solid #ff0000; /* Яркая красная рамка - "ОПАСНОСТЬ" */
}

.player-tag.sheriff-check.is-mafia::before {
    content: "💀";
}

/* Информация от дона: ищет шерифа */
.player-tag.don-check {
    background: linear-gradient(135deg, #4a148c, #6a1b9a);
    color: white;
    border: 2px solid #ba68c8;
}

.player-tag.don-check::before {
    content: "🎩";
}

/* Проверка дона: "ЭТО ШЕРИФ" (синий акцент — цель найдена) */
.player-tag.don-check.is-sheriff {
    background: linear-gradient(135deg, #0d47a1, #1565c0);
    border: 2px solid #42a5f5;
}

.player-tag.don-check.is-sheriff::before {
    content: "⭐";
}

/* Кого доктор лечит ЭТОЙ ночью (п.7). Видит только сам доктор — как метка
   маньяка, это выбор текущей ночи, а не накопленное знание. Зелёный: он
   единственный за столом, кто спасает. */
.player-tag.heal-mark {
    background: linear-gradient(135deg, #1b5e20, #2e7d32);
    color: white;
    border: 2px solid #66bb6a;
}

.player-tag.heal-mark::before {
    content: "💉";
}

/* Цели убийц этой ночи (27.10.2026). Раньше у black-mark и maniac-mark не было
   своих правил вовсе: табличка без заливки и рамки — у жертвы мафии от неё
   оставался голый флажок, а «ЖЕРТВА МАНЬЯКА» выглядела полупрозрачной.
   Эмодзи уже в тексте, поэтому ::before пустой. */
.player-tag.black-mark {
    background: linear-gradient(135deg, #1c1c1c, #333333);
    color: white;
    border: 2px solid #ef5350;
}

.player-tag.maniac-mark {
    background: linear-gradient(135deg, #3a2704, #5d4037);
    color: #ffe082;
    border: 2px solid #ffc107;
}

.player-tag.black-mark::before,
.player-tag.maniac-mark::before {
    content: none;
}

/* Строка 3: Убит (v1.8, п.21 — без указания, кто именно убил: мафия, бог, маньяк).
   Класс раньше назывался killed-by-mafia. */
.player-tag.killed {
    background: linear-gradient(135deg, #b71c1c, #c62828);
    color: white;
    border: 2px solid #ef5350;
}

body.day-mode .player-tag.killed {
    background: linear-gradient(135deg, #ef9a9a, #e57373);
    border-color: #ffcdd2;
}

.player-tag.killed::before {
    content: none;
}

/* Строка 3: Казнён голосованием */
.player-tag.executed {
    background: linear-gradient(135deg, #37474f, #455a64);
    color: white;
    border: 2px solid #90a4ae;
}

body.day-mode .player-tag.executed {
    background: linear-gradient(135deg, #90a4ae, #78909c);
    border-color: #cfd8dc;
}

.player-tag.executed::before {
    content: none;
}

/* Статус мертвеца (общий) */
.player-tag.dead-status::before {
    content: none;
}

.player-tag.final-role::before {
    content: none;
}

/* Значок мирного жителя (Домик или щит) */
.role-description.town::before,
.role-description.civilian::before {
    content: "🏠";
    margin-right: 5px;
}

/* Базовая табличка для мёртвого (когда неизвестно как умер) */
.player-tag.dead-status {
    background: linear-gradient(135deg, #424242, #616161);
    color: #bdbdbd;
    border: 2px solid #757575;
}

/* Табличка с голосами (днём) */
.player-tag.votes {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 98px;
    max-width: 170px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    color: #3d2415;
    background: rgba(255, 248, 235, 0.96);
    border: 1px solid rgba(155, 105, 63, 0.35);
    border-radius: 12px;
    box-shadow:
        0 6px 14px rgba(87, 53, 24, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    overflow: hidden;
}

.player-tag.votes::after {
    content: none;
}

.player-tag.votes .vote-count {
    width: 100%;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    color: #8f5e37;
}

.player-tag.votes .vote-names {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    color: #4e2f1d;
    white-space: normal;
}

body.day-mode .player-tag.votes {
    color: #3d2415;
    border-color: rgba(155, 105, 63, 0.35);
}

body.day-mode .player-tag.votes .vote-names {
    color: #4e2f1d;
}

/* Строка финала: Роль (при окончании игры) */
.player-tag.final-role {
    background: linear-gradient(135deg, #1976d2, #2196f3);
    color: white;
    border: 2px solid #64b5f6;
}

.player-tag.final-role.role-peaceful {
    background: linear-gradient(135deg, #ef9a9a, #e57373);
    border: 2px solid #ffcdd2;
}
body.night-mode .player-tag.final-role.role-peaceful {
    background: linear-gradient(135deg, #b71c1c, #c62828);
    border-color: #ef5350;
}

.player-tag.final-role.role-mafia {
    background: linear-gradient(135deg, #ce93d8, #ba68c8);
    border: 2px solid #e1bee7;
}
body.night-mode .player-tag.final-role.role-mafia {
    background: linear-gradient(135deg, #4a148c, #6a1b9a);
    border-color: #ab47bc;
}

.player-tag.final-role.role-mafia-ally {
    background: linear-gradient(135deg, #9e9e9e, #8d8d8d);
    border: 2px solid #d0d0d0;
}
body.night-mode .player-tag.final-role.role-mafia-ally {
    background: linear-gradient(135deg, #4a148c, #7b1fa2);
    border-color: #ba68c8;
}

/* ОБЩИЕ СТИЛИ */
* {
    box-sizing: border-box;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

.hidden {
    display: none !important;
}

.modal-open #setup-ui > *:not(#game-ui) {
    filter: blur(2px);
    pointer-events: none;
}

/* ИНДИКАТОР ИГРОКА (Я) */
.me-indicator {
    color: #ffeb3b; /* Ярко-желтый */
    font-size: 40px;
    font-weight: bold;
    text-shadow: 0 0 10px #ff9800, 0 4px 4px rgba(0,0,0,0.5);
    z-index: 140; /* Выше стола (120) и подписей (130) */
    pointer-events: none;
    animation: bounce 1.5s infinite ease-in-out;
    order: -1; /* Быть выше других элементов в контейнере (голосов) */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.me-indicator::after {
    content: 'ВЫ';
    display: block;
    font-size: 14px;
    text-align: center;
    color: white;
    margin-top: 0px;
    text-shadow: 0 2px 4px black;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* Индикатор бота на игровом столе */
.bot-badge-table {
    position: absolute;
    top: -140px;
    right: -10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 140; /* Выше стола (120) и подписей (130) */
    pointer-events: none;
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
}

/* Личный цветной маркер на игроке (п.3): 🔴 подозреваю / 🟢 поддерживаю /
   ⚪ под вопросом. Ставится долгим нажатием или правой кнопкой по колобку,
   видна только тому, кто поставил (на сервер не уходит).
   Зеркалит бейдж бота по другую сторону головы, чтобы они не налезали. */
.player-mark {
    position: absolute;
    top: -140px;
    left: -10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 140; /* Выше стола (120) и подписей (130) — как бейдж бота */
    pointer-events: none;
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
    animation: player-mark-pop 180ms ease-out;
}

@keyframes player-mark-pop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* Счётчик фолов (п.4). Видят ВСЕ за столом — это публичное правило, а не чья-то
   тайна. Стоит под бейджем бота, чтобы они не налезали друг на друга. */
.player-foul-badge {
    position: absolute;
    top: -122px;               /* п.1 списка 30.09: чуть выше, чтобы не наезжал */
    right: -12px;
    min-width: 26px;
    height: 20px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;       /* узкий бейдж переносил значок над цифрой */
    width: max-content;
    z-index: 141;              /* чуть выше бейджа бота (140) */
    pointer-events: none;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #3a2b20;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Лишён речи третьим фолом — отдельный вид, иначе пропуск его хода выглядит
   как сбой очереди. */
.player-foul-badge.foul-muted {
    background: rgba(90, 32, 32, 0.95);
    color: #ffd9d9;
}

/* Имена и названия с декоративными символами (2.4): новые сервер не пропускает,
   а уже заведённые не должны вылезать за карточку — переносим где угодно и
   срезаем то, что выросло вверх-вниз. */
#lobby-room-name,
.lobby-player-name,
.room-item .room-info-left,
.chat-message .sender {
    overflow-wrap: anywhere;
    overflow: hidden;
}
.room-item .room-info-left { min-width: 0; }
.lobby-player-name {
    max-width: 220px;
    max-height: 3.6em;
    text-align: center;
}
#lobby-room-name { max-height: 3em; }

.lobby-player-summary {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 0 6px 0 0;
    color: #6f5848;
    border-bottom: none;
}

.lobby-player-summary__label {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: #6f5848;
}

.lobby-player-summary__count {
    min-width: 54px;
    padding: 6px 12px;
    text-align: center;
    color: #fff7ef;
    font-size: 16px;
    font-weight: 700;
    background: #8a5836;
    border-radius: 999px;
    box-shadow: none;
}

.lobby-bot-badge {
    position: absolute;
    top: -12px;
    right: -8px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
    z-index: 10;
}

/* Подсветка для мафии ночью - только спрайт */
.player-at-table.mafia-target:hover .player-sprite-table {
    outline: 3px solid #ff4d4d;
    filter: drop-shadow(0 0 10px red);
    transition: all 0.2s ease;
}

/* Выбор цели ночной проверки (шериф/дон) — клик по колобку. Синяя подсветка,
   чтобы не путать с красным прицелом убийства: у дона это два разных действия. */
.player-at-table.investigate-target:hover .player-sprite-table {
    outline: 3px solid #64b5f6;
    filter: drop-shadow(0 0 10px #2196f3);
    transition: all 0.2s ease;
}

.player-at-table.investigate-target:hover .player-sprite-table.easter-egg-avatar {
    outline: none;
    filter: drop-shadow(0 0 8px #64b5f6) drop-shadow(0 0 15px rgba(33, 150, 243, 0.6));
}

/* Ход МАНЬЯКА (v2.0) едет по той же машинерии выбора цели, но это убийство,
   а не проверка — подсветка красная, как у прицела мафии. Правила ниже идут
   ПОСЛЕ синих, поэтому при обоих классах побеждает красный. */
.player-at-table.investigate-target.kill-target-mode:hover .player-sprite-table {
    outline: 3px solid #ff5252;
    filter: drop-shadow(0 0 10px #d50000);
}

.player-at-table.investigate-target.kill-target-mode:hover .player-sprite-table.easter-egg-avatar {
    outline: none;
    filter: drop-shadow(0 0 8px #ff5252) drop-shadow(0 0 15px rgba(213, 0, 0, 0.6));
}

/* Если цель уже выбрана */
.player-at-table.mafia-target.selected .player-sprite-table {
    border: 4px solid red;
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Анимация появления баннера победы */
@keyframes bannerAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Анимация текста перехода фазы */
@keyframes fadeInText {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Пульсирующая анимация для важных элементов */
@keyframes gentlePulse {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(255, 152, 0, 0.3);
    }
    50% { 
        box-shadow: 0 0 15px rgba(255, 152, 0, 0.6);
    }
}

/* Анимация появления спрайта */
@keyframes spriteAppear {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

@keyframes spriteAppearFlipped {
    0% {
        opacity: 0;
        transform: translateX(-50%) scaleX(-1) scaleY(0.5);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scaleX(-1) scaleY(1);
    }
}

/* Применяем анимацию к спрайтам */
.player-sprite-table {
    animation: spriteAppear 0.5s ease-out;
}

.player-at-table.flipped .player-sprite-table {
    animation: spriteAppearFlipped 0.5s ease-out;
}

/* Улучшенный hover эффект для игроков за столом */
.player-at-table:not(.dead) .player-sprite-table {
    transition: transform 0.3s ease, filter 0.3s ease;
}
/* Задний слой шапки ездит на hover ровно так же, как передняя: они рисуются на
   одном холсте, и любое расхождение сразу видно как разъехавшаяся шапка. */
.player-at-table:not(.dead) .avatar-hat,
.player-at-table:not(.dead) .avatar-hat-back {
    transition: transform 0.3s ease, filter 0.3s ease;
}

.player-at-table:not(.dead):not(.flipped):hover .player-sprite-table {
    transform: translateX(-50%) scale(1.05);
}
/* Поворот шапки (--hat-rotate) на hover СОХРАНЯЕМ, и порядок функций тот же,
   что у покоя, + scale в конце: иначе шапка с наклоном (у маньяка он большой)
   на наведении выпрямлялась — выглядело как резкий наклон (п.9 списка 30.09). */
.player-at-table:not(.dead):not(.flipped):hover .avatar-hat,
.player-at-table:not(.dead):not(.flipped):hover .avatar-hat-back {
    transform: translateX(-50%) rotate(var(--hat-rotate, 0deg)) scale(1.05);
}

.player-at-table.flipped:not(.dead):hover .player-sprite-table {
    transform: translateX(-50%) scaleX(-1.05) scaleY(1.05);
}
.player-at-table.flipped:not(.dead):hover .avatar-hat,
.player-at-table.flipped:not(.dead):hover .avatar-hat-back {
    transform: translateX(-50%) scaleX(-1) rotate(var(--hat-rotate, 0deg)) scale(1.05);
}

/* Подсветка для днёвного режима голосования */
.player-at-table.voting-target:hover .player-sprite-table {
    outline: 3px solid #ff9800;
    filter: drop-shadow(0 0 10px #ff9800);
    transition: all 0.2s ease;
}

.player-at-table.voting-target {
    cursor: pointer;
}

/* Подсветка для номинации */
.player-at-table.nomination-target:hover .player-sprite-table {
    outline: 3px solid #2196f3;
    filter: drop-shadow(0 0 10px #2196f3);
    transition: all 0.2s ease;
}

/* Если цель уже выбрана */
.player-at-table.day-target.selected .player-sprite-table {
    border: 4px solid red;
    animation: blink 1s infinite;
}

/* ==================== РАСШИРЕННЫЕ НАСТРОЙКИ КОМНАТЫ ==================== */

/* Широкое модальное окно */
.modal-wide {
    max-width: 880px;
    width: 95vw; /* Viewport units — не зависит от родителя */
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 0; /* Переопределяем padding от .modal-content — дети сами добавят */
}

/* Заголовок внутри modal-wide */
.modal-wide .modal-header {
    padding: 24px 24px 0;
    margin-bottom: 16px;
    flex-shrink: 0;
}

/* Скроллируемая часть настроек внутри modal-wide */
.modal-wide .modal-settings {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding: 0 24px;
}

/* Footer внутри modal-wide всегда видимый */
.modal-wide .modal-footer {
    flex-shrink: 0;
    background: white;
    margin-top: 0;
    border-top: 1px solid #eee;
    padding: 16px 24px;
    border-radius: 0 0 18px 18px;
}

/* Секции настроек */
.settings-section {
    margin-bottom: 20px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #e5e5e5;
}

.settings-section-title {
    font-size: 16px;
    font-weight: bold;
    color: #3a2b20;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Кнопка показать/скрыть */
.btn-toggle {
    padding: 4px 12px;
    font-size: 12px;
    background: #8a5836;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle:hover {
    background: #6b4227;
}

/* Настройки игры */
.advanced-settings {
    margin-top: 16px;
}

/* Группы настроек */
.settings-group {
    margin-bottom: 20px;
    padding: 14px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.settings-group-title {
    font-size: 14px;
    font-weight: bold;
    color: #555;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* ============================================
   ПРАВКА ШАПОК ЗА СТОЛОМ (v2.0, п.40)

   Позицию шапки на столе можно подобрать только глядя НА СТОЛ, но окно
   инвентаря — обычная модалка: затемняет фон и занимает почти весь экран.
   Получалось «правлю вслепую»: ползунки видно, результат — нет.

   В режиме «🪑 Стол» окно ужимается в узкую колонку у левого края, затемнение
   снимается, а мимо окна клики проходят на стол (сама панель кликабельна).
   ============================================ */
body.hat-table-editing #inventory-modal {
    background: transparent;
    justify-content: flex-start;
    align-items: flex-start;
    pointer-events: none;
}
body.hat-table-editing #inventory-modal .modal-content {
    pointer-events: auto;
    margin: 12px 0 0 12px;
    width: 340px;
    max-width: 42vw;
    max-height: 92vh;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    opacity: 0.97;
}
/* Сетка предметов в узкой колонке не нужна: предмет уже выбран, а место
   съедает — оставляем детали и сам редактор. */
body.hat-table-editing #inventory-grid-wrap {
    max-height: 130px;
}
body.hat-table-editing .inventory-details-preview {
    transform: scale(0.75);
    transform-origin: top center;
}

/* Пояснение под группой полей (например, допустимый разброс таймеров) */
.settings-hint {
    font-size: 12px;
    color: #8a7a68;
    margin-top: -4px;
    margin-bottom: 10px;
}

/* Селекты */
.form-field select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    box-sizing: border-box;
    background: white;
    cursor: pointer;
}

.form-field select:focus {
    border-color: #8a5836;
    outline: none;
}

/* Чекбоксы ролей */
.roles-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.role-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.role-checkbox input {
    width: auto;
    margin: 0;
}

.role-checkbox input:disabled + .role-badge {
    opacity: 0.7;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

/* Мафиозные роли: светло-чёрные (серые), выбранные — чёрные */
.role-badge.mafia {
    background: #d9d9d9;
    color: #333;
    border: 1px solid #a6a6a6;
}

/* Мирные роли: светло-красные, выбранные — красные */
.role-badge.town,
.role-badge.civilian {
    background: #ffd6d6;
    color: #b00000;
    border: 1px solid #f0a0a0;
}

/* Иные роли: светло-оранжевые, выбранные — оранжевые */
.role-badge.neutral {
    background: #ffe6bf;
    color: #a15c00;
    border: 1px solid #f0c080;
}

.role-checkbox input:checked + .role-badge.mafia {
    background: #1a1a1a;
    color: white;
    border-color: #1a1a1a;
}

.role-checkbox input:checked + .role-badge.town,
.role-checkbox input:checked + .role-badge.civilian {
    background: #e02020;
    color: white;
    border-color: #e02020;
}

.role-checkbox input:checked + .role-badge.neutral {
    background: #f08c00;
    color: white;
    border-color: #f08c00;
}

/* Адаптивность для настроек */
@media (max-width: 600px) {
    .modal-wide {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .settings-group {
        padding: 10px;
    }
    
    .roles-checkboxes {
        gap: 6px;
    }
    
    .role-badge {
        font-size: 12px;
        padding: 3px 8px;
    }
}

/* ==================== РЕЖИМ ВЫСТУПЛЕНИЙ ПО ОЧЕРЕДИ ==================== */

/* Индикатор текущего спикера */
.speaker-indicator {
    position: absolute;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 36px;
    animation: speakerPulse 1s infinite ease-in-out;
    z-index: 150; /* Выше стола (120), подписей (130) и индикаторов (140) */
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}


/* ЕДИНСТВЕННАЯ галочка на колобке (п.12) — «игрок ОТГОВОРИЛ»: свой ход в круге
   речей закончил (дневной круг и оправдания). Раньше этой же зелёной галочкой
   отмечали подавших голос, из-за чего выставление посреди хода читалось как «уже
   отговорил»; по решению Светы (19.08.2026) значка «голос подан» у мест больше
   нет, а галочка означает только законченную речь.

   ВАЖНО про координаты: место за столом (`.player-at-table`) — это ТОЧКА 0×0, а
   не коробка колобка, и всем детям места правило `.player-at-table > *` задаёт
   `left: 50%` + `translate(-50%, -50%)`. Поэтому «left/right: -20px» не прижимают
   значок к краю колобка, а сажают его почти в ту же точку, что и соседний, —
   именно так две галочки и налезли друг на друга. Считаем от `calc(50% ± N)` и
   гасим общий центрирующий transform (тот же приём, что у `.voice-indicator`).
   z-index 140 — тот же ярус, что у остальных индикаторов места (см. раскладку
   слоёв за столом: стол 120, подписи 130, индикаторы 140, микрофон 150). */
.has-spoken-indicator {
    position: absolute;
    top: -35px;
    left: calc(50% - 15px);
    transform: none !important;
    width: 30px;
    height: 30px;
    background: #4CAF50;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: bold;
    z-index: 140;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@keyframes speakerPulse {
    0%, 100% { 
        transform: translateX(-50%) scale(1); 
        opacity: 1;
    }
    50% { 
        transform: translateX(-50%) scale(1.2); 
        opacity: 0.8;
    }
}

/* Подсветка текущего спикера */
.player-at-table.current-speaker .player-sprite {
    filter: drop-shadow(0 0 20px #4CAF50) drop-shadow(0 0 40px #4CAF50);
}

.player-at-table.current-speaker .player-name {
    color: #4CAF50;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

/* Статус спикера в чате */
#speaker-status {
    padding: 10px 15px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    border: 1px solid #a5d6a7;
}

#speaker-status .speaker-label {
    color: #2e7d32;
}

#speaker-status .queue-info {
    color: #666;
    font-size: 12px;
    margin-left: auto;
}

#speaker-status .speaker-timer-text {
    color: #d32f2f;
    font-weight: bold;
    font-family: monospace;
    font-size: 15px;
    margin-left: 8px;
}

/* Кнопка передачи слова. #finish-check-turn-btn — «Закончить ход» шерифа/дона:
   живёт в той же панели чата, поэтому выглядит так же (раньше ход проверяющего
   вообще нечем было закрыть). */
#pass-word-btn,
#mafia-skip-kill-btn,
#finish-check-turn-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
    margin-left: 10px;
    white-space: nowrap;
}

#pass-word-btn:hover:not(:disabled),
#finish-check-turn-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(76, 175, 80, 0.3);
}

#pass-word-btn:disabled,
#mafia-skip-kill-btn:disabled,
#finish-check-turn-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Режимы очереди речей (13.09.2026). «✋ Хочу говорить» — тёплая жёлтая, чтобы
   отличаться от зелёной «Закончить речь»; панель эстафеты — над полем ввода. */
#raise-hand-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #f5b301 0%, #e09e00 100%);
    color: #2b2100;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    margin-left: 10px;
    white-space: nowrap;
    transition: all 0.2s;
}
#raise-hand-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #e09e00 0%, #c98b00 100%);
    transform: translateY(-1px);
}
#raise-hand-btn:disabled {
    background: #cfc7a8;
    color: #5a5340;
    cursor: default;
}
.relay-pick-panel {
    padding: 8px 10px;
    margin: 4px 8px;
    border: 1px dashed rgba(255, 215, 0, 0.6);
    border-radius: 8px;
    background: rgba(40, 32, 60, 0.85);
    font-size: 13px;
}
.relay-pick-label {
    color: #ffd86b;
    font-weight: bold;
    margin-bottom: 6px;
}
.relay-pick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.relay-pick-btn {
    padding: 5px 10px;
    border: 1px solid #8a6a3c;
    border-radius: 6px;
    background: #3b2f4d;
    color: #f1e6ff;
    cursor: pointer;
    font-size: 13px;
}
.relay-pick-btn:hover { background: #4d3d66; }
.relay-pick-btn.selected {
    background: #4CAF50;
    border-color: #2e7d32;
    color: #fff;
}

/* «Никого не убивать» (v2.0, п.48) — не зелёная «дальше», а спокойная серо-синяя:
   это не продолжение хода, а отказ от действия. */
#mafia-skip-kill-btn {
    background: linear-gradient(135deg, #5c6b7a 0%, #47555f 100%);
}
#mafia-skip-kill-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #47555f 0%, #37434c 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(71, 85, 95, 0.35);
}

/* Адаптация чат-инпут для кнопки */
.chat-input-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;    /* при увеличенном поле ввода кнопки прижаты к его низу */
}

/* Кнопки хода — своей строкой под полем ввода (12.11.2026, о). В одной строке
   с полем, микрофоном и «Отправить» кнопка «Закончить речь» (nowrap + отступ)
   сжимала поле почти до нуля — как раз в свою очередь, когда надо писать, а
   растянуть его вбок нельзя (resize: vertical). Так же сделано в Бункере. */
.chat-input-area > #pass-word-btn,
.chat-input-area > #mafia-skip-kill-btn,
.chat-input-area > #finish-check-turn-btn,
.chat-input-area > #raise-hand-btn {
    flex: 1 1 100%;
    margin-left: 0;
}

@media (max-width: 500px) {
    #pass-word-btn,
    #mafia-skip-kill-btn,
    #finish-check-turn-btn {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
    }
}

/* ==================== СИСТЕМА НОМИНАЦИИ ==================== */

/* Цель номинации */
.player-at-table.nomination-target:hover .player-sprite-table {
    outline: 3px solid #ff9800;
    filter: drop-shadow(0 0 10px #ff9800);
    transition: all 0.2s ease;
}

/* Подсветка номинированного при голосовании */
.player-at-table.voting-target.nominated-candidate {
    cursor: pointer;
}

.player-at-table.voting-target.nominated-candidate .player-sprite-table {
    outline: 3px solid #f44336;
    filter: drop-shadow(0 0 10px #f44336);
}

/* Кнопка "Закончить речь" */
#finish-defense-btn {
    position: fixed;
    right: 30px;
    bottom: calc(50% - 60px);
    padding: 15px 30px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    z-index: 1100;
    transition: all 0.2s ease;
    display: none;
}

#finish-defense-btn:hover {
    background: linear-gradient(135deg, #45a049, #388e3c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

#finish-defense-btn.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Кнопка "Воздержаться от выставления" */
#skip-nomination-btn {
    position: fixed;
    right: 30px;
    bottom: 50%;
    padding: 15px 30px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4);
    z-index: 1100;
    transition: all 0.2s ease;
    display: none;
}

#skip-nomination-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.5);
}

#skip-nomination-btn.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Стиль для сообщений защиты в чате */
.chat-message.defense {
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid #ff9800;
    padding-left: 8px;
    margin-left: -8px;
}

.chat-message.defense .sender {
    color: #ff9800;
}

/* Стиль для приватных размышлений ботов о голосовании (видит только бог) */
.chat-type-vote-reasoning {
    background: rgba(124, 77, 255, 0.1);
    border-left: 3px solid #7c4dff;
    padding-left: 8px;
    margin-left: -8px;
    font-style: italic;
}

.chat-type-vote-reasoning .sender {
    color: #b388ff;
}

/* Стиль для мыслей ботов в реальном времени (видит только бог) */
.chat-type-bot-thinking {
    background: rgba(0, 200, 83, 0.1);
    border-left: 3px solid #00c853;
    padding-left: 8px;
    margin-left: -8px;
    font-style: italic;
    font-size: 0.9em;
}

.chat-type-bot-thinking .sender {
    color: #69f0ae;
}

/* Стиль для ночного чата мафии */
.chat-type-mafia {
    background: rgba(244, 67, 54, 0.1);
    border-left: 3px solid #f44336;
    padding-left: 8px;
    margin-left: -8px;
}

.chat-type-mafia .sender {
    color: #ef5350;
}

/* Свой неяркий цвет у сообщений каждого (2.5, п.32): ники-двойники различимы.
   --sender-hue ставит decorateChatSender. Сообщения со своим фоном (ведущий,
   зрители, мафия, защита…) не перекрашиваем — у них цвет канала важнее. */
.chat-message.sender-tinted:not([class*="chat-type-"]):not(.chat-afterparty-human),
.chat-message.sender-tinted.chat-type-last-words,
.lobby-msg.sender-tinted {
    /* Последние слова — тоже цветом игрока (список 24.11.2026, п.10): своего
       фона канала у них нет, и прощальная речь терялась среди системных строк.
       Вдвое тусклее (04.11.2026, Света): подсветка спорила с текстом. У ведущего,
       зрителей и призраков свой фон канала — их это не касается (:not выше). */
    background: hsla(var(--sender-hue), 70%, 50%, 0.04);
    box-shadow: inset 3px 0 0 hsla(var(--sender-hue), 60%, 50%, 0.25);
    border-radius: 4px;
}
.chat-message.sender-tinted:not([class*="chat-type-"]):not(.chat-afterparty-human),
.chat-message.sender-tinted.chat-type-last-words {
    padding-left: 8px;
    margin-left: -8px;
}
.lobby-msg.sender-tinted { padding-left: 6px; }
html.dark-theme .chat-message.sender-tinted:not([class*="chat-type-"]):not(.chat-afterparty-human),
html.dark-theme .chat-message.sender-tinted.chat-type-last-words,
html.dark-theme .lobby-msg.sender-tinted {
    background: hsla(var(--sender-hue), 60%, 60%, 0.05);
}
.sender-clickable { cursor: pointer; }
.sender-clickable:hover { text-decoration: underline; }

/* Стиль ночного content мафии для бога */
.chat-type-mafia-night {
    background: rgba(183, 28, 28, 0.15);
    border-left: 3px solid #b71c1c;
    padding-left: 8px;
    margin-left: -8px;
    font-style: italic;
}

.chat-type-mafia-night .sender {
    color: #ef5350;
}

/* Сообщение зрителя — видно только призракам и богу (отдельный «загробный» канал) */
.chat-type-spectator {
    background: rgba(96, 125, 139, 0.12);
    border-left: 3px solid #607d8b;
    padding-left: 8px;
    margin-left: -8px;
    font-style: italic;
}
.chat-type-spectator .sender {
    color: #607d8b;
}

/* Сообщение бога, адресованное только зрителям — не видят живые игроки */
.chat-type-god-spectator {
    background: rgba(156, 39, 176, 0.12);
    border-left: 3px solid #9c27b0;
    padding-left: 8px;
    margin-left: -8px;
    font-style: italic;
}
.chat-type-god-spectator .sender {
    color: #ba68c8;
}

/* Афтепати: реплики людей (игроков и зрителей) — чтобы не тонули среди ботов. */
.chat-message.chat-afterparty-human {
    background: rgba(33, 150, 243, 0.12);
    border-left: 3px solid #2196f3;
    padding-left: 8px;
    margin-left: -8px;
    border-radius: 4px;
}
.chat-message.chat-afterparty-human .sender {
    color: #1976d2;
}
html.dark-theme .chat-message.chat-afterparty-human .sender {
    color: #64b5f6;
}

/* Ответ на сообщение в игровом чате (ведущий, зрители, призраки) */
.chat-msg-quote {
    font-size: 11px;
    opacity: 0.75;
    font-style: italic;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-msg-quote b { font-style: normal; }
/* Клик по цитате — к исходному сообщению (12.11.2026, н) */
.quote-jump { cursor: pointer; }
.quote-jump:hover { opacity: 1; text-decoration: underline; }
.quote-flash { animation: quoteFlash 1.6s ease-out; }
@keyframes quoteFlash {
    0%, 35% { background-color: rgba(255, 200, 60, 0.55); }
    100% { background-color: transparent; }
}
.chat-reply-btn {
    display: none;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.45;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}
.chat-reply-btn:hover { opacity: 1; transform: none; background: none; box-shadow: none; }
#chat-panel.can-reply .chat-message:not(.system) .chat-reply-btn { display: inline-block; }
/* В личке ведущего отвечать можно всегда (2.5, п.28) */
.god-dm-message .dm-reply-btn { display: inline-block; }
/* Стрелка ↩ — только при наведении на сообщение (16.10.2026, п.9). Место под
   неё остаётся (opacity, не display), чтобы строка не прыгала. На телефоне
   наведения нет — там стрелка видна всегда, как раньше. */
@media (hover: hover) {
    .chat-reply-btn,
    .lobby-msg-reply-btn { opacity: 0; }
    .chat-message:hover .chat-reply-btn,
    .lobby-msg-line:hover .lobby-msg-reply-btn { opacity: 0.9; }
    .chat-reply-btn:hover,
    .lobby-msg-reply-btn:hover { opacity: 1; }
}
.game-reply-preview { margin: 4px 10px 0; }

/* Сообщение бога всем (и игрокам) */
.chat-type-god {
    background: rgba(255, 179, 0, 0.14);
    border-left: 3px solid #ffb300;
    padding-left: 8px;
    margin-left: -8px;
}
.chat-type-god .sender {
    color: #ffb300;
}

/* Сообщение призрака (мёртвого игрока) — видят мёртвые, зрители и бог */
.chat-type-ghost {
    background: rgba(0, 188, 212, 0.12);
    border-left: 3px solid #26c6da;
    padding-left: 8px;
    margin-left: -8px;
    font-style: italic;
}
.chat-type-ghost .sender {
    color: #4dd0e1;
}

/* ===== Модальное окно помощи ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal-overlay.hidden {
    display: none;
}

.help-content {
    color: #333;
}

.help-section {
    margin-bottom: 24px;
}

.help-section h3 {
    color: #2196F3;
    border-bottom: 2px solid #2196F3;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.help-section ul {
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.role-description {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
    border-left: 4px solid #888;
}

.role-description h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.role-description p {
    margin: 4px 0;
    font-size: 14px;
}

.role-description.civilian {
    border-left-color: #f44336; /* Красный мирный */
    background: rgba(244, 67, 54, 0.1);
}

.role-description.mafia {
    border-left-color: #000000; /* Черная мафия */
    background: rgba(0, 0, 0, 0.05);
}

.role-description.town {
    border-left-color: #2196F3;
    background: rgba(33, 150, 243, 0.1);
}

/* Кнопка помощи и настроек в игре */
#help-btn:hover,
#game-settings-btn:hover {
    background: rgba(0,0,0,0.9) !important;
    transform: scale(1.1);
}

/* ========== ИНДИКАТОР СОЕДИНЕНИЯ ========== */
#connection-indicator {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== УЛУЧШЕНИЯ ДОСТУПНОСТИ ========== */

/* Фокус для интерактивных элементов */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #8a5836;
    outline-offset: 2px;
}

/* Улучшенный контраст для ночного режима */
body.night-mode input,
body.night-mode select {
    background: rgba(60, 40, 30, 0.8);
    border-color: #8b5a3c;
    color: #e8d5c4;
}

body.night-mode input::placeholder {
    color: #a08070;
}

/* Анимация загрузки */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ========== УЛУЧШЕННЫЕ ХОВЕР ЭФФЕКТЫ ========== */

/* Комната в списке */
.room-item {
    transition: all 0.2s ease !important;
}

.room-item:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

/* Игрок в лобби */
.player-wrapper {
    transition: transform 0.2s ease;
}

.player-wrapper:hover {
    transform: scale(1.05);
}

/* ========== МОБИЛЬНАЯ АДАПТАЦИЯ ========== */
@media (max-width: 768px) {
    #chat-panel {
        width: 280px;
        height: 300px;
    }
    
    #voting-history {
        left: 20px;
        max-width: calc(100vw - 40px);
    }
    
    .abstain-btn {
        right: 10px;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    #phase-display {
        padding: 8px 20px;
    }
    
    #phase-title {
        font-size: 18px;
    }
    
    #notification-container {
        right: 10px;
        left: 10px;
    }
    
    .notification {
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    #chat-panel {
        width: calc(100vw - 40px);
        left: 10px;
    }
    /* Стол и спрайты теперь масштабируются через transform:scale на wrapper
       (см. fitGameTable() в script.js) — отдельные размеры тут не нужны */
}

/* ========== СИСТЕМА СЕТТИНГОВ (ТЕМ ОФОРМЛЕНИЯ) ========== */

/* Сетка выбора сеттинга в модалке создания комнаты */
.setting-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.setting-selector-grid::-webkit-scrollbar {
    width: 6px;
}

.setting-selector-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.setting-selector-grid::-webkit-scrollbar-thumb {
    background: rgba(138, 88, 54, 0.4);
    border-radius: 3px;
}

/* Карточка сеттинга */
.setting-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.setting-card:hover {
    border-color: #c89b6e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(138, 88, 54, 0.2);
}

.setting-card.selected {
    border-color: #8a5836;
    background: linear-gradient(135deg, #fdf3e7 0%, #f5e6d3 100%);
    box-shadow: 0 2px 8px rgba(138, 88, 54, 0.3);
}

.setting-card.selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 12px;
    color: #8a5836;
    font-weight: bold;
}

.setting-card-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 6px;
}

.setting-card-icon img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.setting-card-emoji,
.setting-card-emoji-fallback {
    font-size: 32px;
    line-height: 1;
}

.setting-card-name {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

.setting-card.selected .setting-card-name {
    color: #8a5836;
}

/* Задний слой шапки (за колобком) */
.avatar-hat-back {
    position: absolute;
    width: 230px;
    height: 230px;
    top: -165px;
    left: 5px;
    transform: translateX(-50%) rotate(var(--hat-rotate, 0deg));
    margin-left: var(--hat-offset-x, 0px);
    z-index: var(--seat-hat-back-z, 33); /* Ниже колобка (--seat-sprite-z ~34) */
    pointer-events: none;
    object-fit: contain;
    image-rendering: auto;
    animation: hatBackAppear 0.4s ease-out;
}

/* Зеркалирование заднего слоя для flipped игроков */
.player-at-table.flipped .avatar-hat-back {
    transform: translateX(-50%) scaleX(-1) rotate(var(--hat-rotate, 0deg));
    left: -5px;
    margin-left: calc(-1 * var(--hat-offset-x, 0px));
    animation: hatBackAppearFlipped 0.4s ease-out;
}

.player-at-table:not(.flipped) .avatar-hat-back {
    transform: translateX(-50%) rotate(var(--hat-rotate, 0deg));
}

/* Серый фильтр для заднего слоя шапки мертвых игроков */
.player-at-table.dead .avatar-hat-back {
    filter: grayscale(50%) brightness(0.5) contrast(1.2);
}

@keyframes hatBackAppear {
    from { opacity: 0; transform: translateX(-50%) translateY(-15px) rotate(-10deg); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) rotate(0deg); }
}

@keyframes hatBackAppearFlipped {
    from { opacity: 0; transform: translateX(-50%) scaleX(-1) translateY(-15px) rotate(10deg); }
    to   { opacity: 1; transform: translateX(-50%) scaleX(-1) translateY(0) rotate(0deg); }
}

/* Шляпы на аватарах */
.avatar-hat {
    position: absolute;
    width: 230px;  /* Размер шапки: ширина */
    height: 230px; /* Размер шапки: высота */
    top: -165px;   /* На голове колобка (спрайт top=-135px, высота 170px, центр=-50px) */
    left: 5px;
    transform: translateX(-50%) rotate(var(--hat-rotate, 0deg));
    margin-left: var(--hat-offset-x, 0px);
    z-index: var(--seat-hat-z, 39); /* Слой шапки задаётся отдельно и симметрично от краёв к центру */
    pointer-events: none;
    object-fit: contain;
    image-rendering: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: hatAppear 0.4s ease-out;
}

/* Зеркалирование шапки для flipped игроков */
.player-at-table.flipped .avatar-hat {
    transform: translateX(-50%) scaleX(-1) rotate(var(--hat-rotate, 0deg));
    animation: hatAppearFlipped 0.4s ease-out;
    left: -5px;
    margin-left: calc(-1 * var(--hat-offset-x, 0px));
}

/* Не-flipped игроки: шапку не зеркалим (совпадает с направлением лица) */
.player-at-table:not(.flipped) .avatar-hat {
    transform: translateX(-50%) rotate(var(--hat-rotate, 0deg));
}

/* Серый фильтр для шапки мертвых игроков */
.player-at-table.dead .avatar-hat {
    filter: grayscale(50%) brightness(0.5) contrast(1.2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.avatar-hat-dead {
    opacity: 0.5;
    filter: grayscale(0.8) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes hatAppear {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-15px) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) rotate(0deg);
    }
}

@keyframes hatAppearFlipped {
    from {
        opacity: 0;
        transform: translateX(-50%) scaleX(-1) translateY(-15px) rotate(10deg);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scaleX(-1) translateY(0) rotate(0deg);
    }
}

/* Декор на столе */
.table-decor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 5;
    opacity: 0.9;
}

/* Индикатор сеттинга в списке комнат */
.room-setting-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(138, 88, 54, 0.1);
    font-size: 12px;
    color: #8a5836;
    font-weight: 500;
}

.room-setting-badge .setting-emoji {
    font-size: 14px;
}

/* «С богом / без бога» в списке комнат: жёлтый — ведущий-человек, серый — без него */
.room-god-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    margin-left: 4px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.room-god-badge.with-god { background: #f7edd0; color: #7a5a10; }
.room-god-badge.no-god { background: #e8e8e8; color: #5a5a5a; }

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .setting-selector-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 6px;
        max-height: 200px;
    }
    
    .setting-card {
        padding: 8px 4px;
        min-height: 65px;
    }
    
    .setting-card-icon {
        font-size: 26px;
    }
    
    .setting-card-name {
        font-size: 10px;
    }
    /* ВНИМАНИЕ: не задавать здесь размер .avatar-hat!
       Шапка масштабируется вместе со столом (.game-table-wrapper имеет
       transform: scale). Отдельный мобильный размер рассинхронизировал её
       с головой — шапки «съезжали». Геометрия шапки одна для всех экранов. */
}

@media (max-width: 480px) {
    .setting-selector-grid {
        grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
        max-height: 180px;
    }
}

/* ============================================
   СИСТЕМА ПРОФИЛЯ И СТАТИСТИКИ
   ============================================ */

/* Плавающие декоративные элементы */
.floating-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.float-icon {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-size: 24px;
    opacity: 0.15;
    animation: floatIcon 4s ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.15; }
    50% { transform: translateY(-12px) rotate(10deg); opacity: 0.3; }
}

/* name-panel — позиционирование для декораций */
#name-panel {
    position: relative;
    overflow: hidden;
}

#name-panel > *:not(.floating-decorations) {
    position: relative;
    z-index: 1;
}

/* Карточка статистики в меню входа */
.profile-stats-card {
    width: 100%;
    background: linear-gradient(135deg, #fef9f4 0%, #f5e6d3 100%);
    border-radius: 14px;
    padding: 16px;
    border: 2px solid #e0c9b3;
    box-shadow: 0 2px 12px rgba(138, 88, 54, 0.12);
    animation: fadeSlideUp 0.4s ease-out;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-stats-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0c9b3;
}

.profile-rank-icon {
    font-size: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.profile-rank-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-rank-title {
    font-size: 15px;
    font-weight: 700;
    color: #5c3d2e;
}

.profile-xp-bar {
    width: 100%;
    height: 8px;
    background: #e0d4c8;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.profile-xp-bar.large {
    height: 12px;
    border-radius: 6px;
}

.profile-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.profile-xp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.35), transparent);
    border-radius: 4px 4px 0 0;
}

.profile-xp-text {
    font-size: 11px;
    color: #8a7565;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    transition: transform 0.2s ease;
}

.profile-stat:hover {
    transform: scale(1.05);
}

.profile-stat-value {
    font-size: 22px;
    font-weight: 800;
    color: #3a2b20;
    line-height: 1;
}

.profile-stat-wins {
    color: #16a34a;
}

.profile-stat-label {
    font-size: 11px;
    color: #8a7565;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   ROOMS HEADER С МИНИ-ПРОФИЛЕМ
   ============================================ */

.rooms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.rooms-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 40px;
    border: 2px solid #e0c9b3;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    cursor: default;
    transition: box-shadow 0.2s ease;
}

.mini-profile:hover {
    box-shadow: 0 4px 16px rgba(138, 88, 54, 0.2);
}

.mini-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #FF8C00;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    flex-shrink: 0;
    position: relative; /* якорь для второго слоя аватара (.avatar-overlay) */
}

.mini-profile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mini-profile-name {
    font-size: 14px;
    font-weight: 700;
    color: #3a2b20;
    line-height: 1;
}

.mini-profile-rank {
    font-size: 11px;
    color: #8a7565;
    line-height: 1;
}

.profile-details-btn {
    width: 34px;
    height: 34px;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: #f5e6d3 !important;
    color: #5c3d2e !important;
    border: 1px solid #d4b896 !important;
    transition: all 0.2s ease !important;
}

.profile-details-btn:hover {
    background: #e6d0b8 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

/* ============================================
   МОДАЛКА ПОДРОБНОГО ПРОФИЛЯ
   ============================================ */

.profile-modal-content {
    max-width: 440px !important;
    width: 90vw;
}

.profile-modal-body {
    padding: 24px;
}

.profile-modal-top {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0e0d0;
}

.profile-modal-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #FF8C00;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.profile-modal-rank-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-modal-name {
    font-size: 20px;
    font-weight: 800;
    color: #3a2b20;
}

.profile-modal-rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #fef9f4, #f5e6d3);
    border-radius: 20px;
    border: 1px solid #e0c9b3;
    font-size: 13px;
    font-weight: 600;
    color: #5c3d2e;
    width: fit-content;
}

.profile-modal-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-modal-stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    transition: background 0.15s ease;
}

.profile-modal-stat-row:hover {
    background: rgba(138, 88, 54, 0.06);
}

.profile-modal-stat-row:nth-child(odd) {
    background: rgba(138, 88, 54, 0.03);
}

.profile-modal-stat-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
}

.profile-modal-stat-label {
    flex: 1;
    font-size: 14px;
    color: #5c3d2e;
}

.profile-modal-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #3a2b20;
}

.btn-danger {
    background-color: #dc3545 !important;
    color: white !important;
}

.btn-danger:hover {
    background-color: #c82333 !important;
}

.btn-primary {
    background-color: #8a5836 !important;
    color: white !important;
}

/* ============================================
   PROFILE — НОВЫЙ ДИЗАЙН (БАННЕР + ДРУЗЬЯ + СТАТУС)
   ============================================ */

.profile-modal-content {
    max-width: 480px !important;
    width: 92vw;
    padding: 0 !important;
    overflow: hidden;
    position: relative;
}
.profile-modal-body {
    padding: 0 !important;
    max-height: calc(85vh - 70px);
    max-height: calc(85dvh - 70px);
    overflow-y: auto;
}

/* Footer профиль-модалки — добавляем горизонтальный padding
   (по умолчанию у .modal-footer есть только padding-top, кнопка хлоплась к краю) */
.profile-modal-content .modal-footer {
    padding: 12px 18px;
    margin-top: 0;
    background: white;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
}

/* Индикатор "друзья в сети" в счётчике онлайна */
.online-friends-extra {
    color: #1e7a3a;
    font-weight: 600;
    font-size: 13px;
}

/* Бейдж "друг в комнате" в карточке комнаты */
.room-friends-badge {
    margin-top: 4px;
    font-size: 13px;
    color: #166534;
    font-weight: 600;
    background: rgba(74, 222, 128, 0.12);
    padding: 2px 8px;
    border-radius: 8px;
    width: fit-content;
}

/* === БАННЕР === */
.profile-banner {
    position: relative;
    width: 100%;
    min-height: 160px;
    background: linear-gradient(135deg, #4a3322 0%, #2b1d12 100%); /* fallback */
    overflow: hidden;
}
.profile-banner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-repeat: repeat;
    background-size: 40px 40px;
    opacity: 0.25;
}
.profile-banner-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 18px;
}

.profile-banner-avatar-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    /* Зеркалим спрайты в профиле (как flipped-сторона за столом) */
    transform: scaleX(-1);
}
/* Слои поверх аватара: лицо и шляпа из профиля.
   Лицо уменьшено в 3 раза — иначе занимает весь круг и выглядит огромным. */
.profile-banner-face,
.profile-banner-hat {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}
/* Лицо: уменьшено + сдвинуто к правому (визуально) краю колобка.
   wrap имеет scaleX(-1), поэтому translateX отрицательный → визуально сдвиг вправо. */
.profile-banner-face { z-index: 2; transform: scale(0.45) translateX(-15%); }
/* Нагатроник вне стола (24.11.2026): лица набора на 20% крупнее обычных.
   translateX уменьшен по формуле t × 0.45 / 0.54 — иначе сдвиг к правому краю
   колобка вырос бы вместе с масштабом. */
.profile-banner-face[data-face-pack="nagatronfaces"] {
    transform: scale(0.54) translateX(-12.5%);
}
/* Собранное лицо (13.11.2026) — как за столом: холст = коробка колобка с полями
   по 25% (отсюда 150% и -25%), сдвиг лица на 10px из 170 (5,9% колобка =
   3,92% этой коробки) к визуально правому краю — обёртка отзеркалена. */
.profile-banner-face.face-top-img,
.inventory-preview-overlay.face.face-top-img { z-index: 4; }   /* сердечки — над шапкой (z 3) */
.profile-banner-face.face-built {
    top: -25%;
    left: -25%;
    width: 150%;
    height: 150%;
    /* обёртка отзеркалена: минус у x — чтобы «+» в переменной значил «вправо» */
    transform: translate(calc(var(--ball-face-x) / -1.5), calc(var(--ball-face-y) / 1.5)) scale(var(--ball-face-scale));
}
/* Задний слой шапки в профиле (под колобком) */
.profile-banner-hat-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 0;
    transform: translateY(-20%);
}
/* Шляпа: уменьшена в 2 раза от прежнего размера + чуть приподнята */
.profile-banner-hat { z-index: 3; transform: translateY(-20%);}
.profile-banner-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: relative;
    z-index: 1; /* Колобок выше заднего слоя шапки (z-index:0), ниже лица (2) и самой шляпы (3) */
    background-color: #FF8C00;
    background-size: cover;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.15);
    box-sizing: border-box;
}
/* Слой узора поверх профильного аватара (профиль игрока/бота, превью MAE).
   Раньше узор задавался в --pattern-url, но правила ::after не было → не отображался. */
.profile-banner-avatar.has-pattern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    pointer-events: none;
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    mix-blend-mode: overlay;
}

.profile-banner-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.profile-banner-name {
    font-size: 22px;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    word-break: break-word;
    line-height: 1.2;
}
/* Титул-награда: выдаётся только админом, поэтому выглядит как знак отличия,
   а не как подпись — золотая рамка вместо обычного текста. */
.profile-banner-title {
    display: inline-block;
    align-self: flex-start;
    margin: 2px 0 3px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #ffe9a8;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(230, 190, 90, 0.75);
    border-radius: 11px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    word-break: break-word;
}
.profile-banner-caption {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    word-break: break-word;
    line-height: 1.35;
    min-height: 1.35em;
}
.profile-banner-caption:empty::before {
    content: 'Без подписи';
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}
.profile-banner-status {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    font-size: 12px;
    color: white;
    align-self: flex-start;
}
.profile-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888; /* default offline */
}
.profile-banner-status.online .profile-status-dot { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.profile-banner-status.offline .profile-status-dot { background: #888; }
.profile-banner-status.invisible .profile-status-dot { background: #c084fc; }

.profile-edit-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    transition: background 0.2s;
}
.profile-edit-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* === ACTIONS === */
.profile-actions {
    display: flex;
    gap: 8px;
    padding: 14px 18px 8px;
}
.profile-action-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1.5px solid #d4a574;
    background: #fef9f4;
    color: #5c3d2e;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.profile-action-btn:hover:not(:disabled) {
    background: #f5e6d3;
    transform: translateY(-1px);
}
.profile-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.profile-friend-btn.is-friend {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
    color: #166534;
}

/* === СЕКЦИИ === */
.profile-section {
    padding: 12px 18px;
    border-top: 1px solid #f0e0d0;
}
.profile-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #5c3d2e;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.profile-section-count {
    font-size: 12px;
    font-weight: 600;
    color: #8a7565;
    background: rgba(138, 88, 54, 0.1);
    padding: 1px 8px;
    border-radius: 10px;
}

/* === СПИСОК ДРУЗЕЙ === */
.profile-friends-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.profile-friends-group-title {
    flex-basis: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 2px 0;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    color: #8a5836;
    cursor: pointer;
}
.profile-friends-group-title:hover { opacity: 0.8; }
.profile-friends-group-body {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.profile-friends-group-body[hidden] { display: none; }
.profile-friends-empty {
    font-size: 13px;
    color: #8a7565;
    font-style: italic;
}
.profile-friend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    background: rgba(138, 88, 54, 0.06);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}
.profile-friend-item:hover {
    background: rgba(138, 88, 54, 0.15);
    border-color: #d4a574;
}
/* Поиск игрока «в друзья» (16.10.2026) */
.friend-search { margin-top: 10px; }
.friend-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid #d8c8b8;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #3a2b20;
}
.friend-search-results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.friend-search-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; background: rgba(138, 88, 54, 0.06); }
.friend-search-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: #3a2b20; }
.friend-search-name:hover { text-decoration: underline; }
.friend-search-add { flex-shrink: 0; margin: 0; padding: 4px 10px; font-size: 12px; }
.friend-search-empty { color: #999; font-size: 13px; padding: 4px 6px; }
html.dark-theme .friend-search input { background: var(--dk-surface); color: var(--dk-text); border-color: var(--dk-border); }
html.dark-theme .friend-search-row { background: rgba(255, 255, 255, 0.05); }
html.dark-theme .friend-search-name { color: var(--dk-text); }

.profile-friend-item-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #FF8C00;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-size: contain;
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-image: url('kolobok.png');
    mask-size: contain;
    mask-position: center;
    mask-repeat: no-repeat;
    flex-shrink: 0;
    position: relative;
}
.profile-friend-item-name {
    font-size: 13px;
    color: #3a2b20;
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-friend-item-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    flex-shrink: 0;
}
.profile-friend-item.online .profile-friend-item-status {
    background: #4ade80;
    box-shadow: 0 0 5px #4ade80;
}

/* Стороны в профиле (16.10.2026): мирные / мафия / нейтралы, раскрываются по клику */
.stat-sides { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.stat-side { border-radius: 10px; background: rgba(138, 88, 54, 0.06); border-left: 4px solid #999; padding: 0 10px; }
.stat-side--town { border-left-color: #3b82f6; }
.stat-side--mafia { border-left-color: #e53935; }
.stat-side--neutral { border-left-color: #8e24aa; }
.stat-side summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; cursor: pointer; list-style: none; }
.stat-side summary::-webkit-details-marker { display: none; }
.stat-side summary::after { content: '▾'; color: #999; transition: transform 0.15s; }
.stat-side[open] summary::after { transform: rotate(180deg); }
.stat-side-title { font-weight: 700; color: #3a2b20; white-space: nowrap; }
.stat-side-line { flex: 1; text-align: right; font-size: 13px; color: #6b5444; }
.stat-side-role { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0 5px 12px; border-top: 1px dashed rgba(138, 88, 54, 0.2); font-size: 13px; color: #3a2b20; }
.stat-side-role span:last-child { color: #6b5444; text-align: right; }
html.dark-theme .stat-side { background: rgba(255, 255, 255, 0.05); }
html.dark-theme .stat-side-title,
html.dark-theme .stat-side-role { color: var(--dk-text); }
html.dark-theme .stat-side-line,
html.dark-theme .stat-side-role span:last-child { color: var(--dk-text-2); }

/* === СТАТИСТИКА (сетка) === */
.profile-stats-grid-modal {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.profile-stat-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    background: rgba(138, 88, 54, 0.05);
    border-radius: 10px;
    text-align: center;
    gap: 2px;
}
.profile-stat-cell-icon {
    font-size: 18px;
}
.profile-stat-cell-value {
    font-size: 15px;
    font-weight: 700;
    color: #3a2b20;
}
.profile-stat-cell-label {
    font-size: 11px;
    color: #8a7565;
}

/* ============================================
   РЕДАКТОР ПРОФИЛЯ (Phase C)
   ============================================ */
.profile-editor-content {
    max-width: 460px !important;
    width: 92vw;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden;
}
.profile-editor-content .modal-header {
    flex-shrink: 0;
    padding: 14px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 16px;
    font-weight: 700;
    border-radius: 18px 18px 0 0;
}
.profile-editor-content .modal-footer {
    flex-shrink: 0;
    padding: 12px 18px;
    margin-top: 0;
    background: white;
    border-radius: 0 0 18px 18px;
    border-top: 1px solid #eee;
}
.profile-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 18px;
}

/* Превью баннера в редакторе */
.profile-editor-banner-preview {
    position: relative;
    width: 100%;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(135deg, #4a3322 0%, #2b1d12 100%);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.profile-editor-banner-overlay {
    position: absolute;
    inset: 0;
    background-repeat: repeat;
    background-size: 40px 40px;
    opacity: 0.25;
    pointer-events: none;
}
.profile-editor-banner-label {
    position: relative;
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* Секции */
.profile-editor-section {
    margin-bottom: 16px;
}
.profile-editor-section:last-child { margin-bottom: 0; }
.profile-editor-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #3a2b20;
    margin-bottom: 8px;
}

/* Табы баннера */
.profile-editor-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    background: #f5e6d3;
    padding: 3px;
    border-radius: 8px;
}
.profile-editor-tab-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #6b5a4a;
    cursor: pointer;
    transition: all 0.15s;
}
.profile-editor-tab-btn.active {
    background: white;
    color: #5c3d2e;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.profile-editor-tab-content { display: none; }
.profile-editor-tab-content.active { display: block; }

/* Подпись textarea */
#profile-editor-caption {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1.5px solid #d4a574;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    background: #fef9f4;
    color: #3a2b20;
}
#profile-editor-caption:focus {
    outline: none;
    border-color: #8a5836;
}
.profile-editor-char-counter {
    text-align: right;
    font-size: 11px;
    color: #8a7565;
    margin-top: 3px;
}

/* Тогл невидимки */
.profile-editor-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.profile-editor-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.profile-editor-toggle-label {
    font-size: 14px;
    color: #3a2b20;
    font-weight: 600;
}
.profile-editor-hint {
    font-size: 12px;
    color: #8a7565;
    margin-top: 4px;
    margin-left: 26px;
}

/* ============================================
   ИНВЕНТАРЬ (модалка с лицами/шляпами)
   ============================================ */
.inventory-content {
    max-width: 640px !important;
    width: 92vw;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden;
}
.inventory-content .modal-header {
    flex-shrink: 0;
    padding: 14px 18px;
    background: linear-gradient(135deg, #8a5836 0%, #5c3d2e 100%);
    color: white;
    font-size: 16px;
    font-weight: 700;
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.inventory-content .modal-footer {
    flex-shrink: 0;
    padding: 12px 18px;
    margin-top: 0;
    background: white;
    border-radius: 0 0 18px 18px;
    border-top: 1px solid #eee;
}

.inventory-tabs {
    display: flex;
    gap: 5px;
}
.inventory-tab-btn {
    flex: 1;
    padding: 7px 12px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.inventory-tab-btn:hover { background: rgba(255, 255, 255, 0.3); }
.inventory-tab-btn.active {
    background: white;
    color: #5c3d2e;
}

.inventory-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 0;
}

/* ===== ВКЛАДКА «ДОСТИЖЕНИЯ» =====
   Список карточек, а не сетка предметов: у достижения кроме иконки есть условие
   и прогресс-бар, в ячейку 72px это не влезает. Полученные — сверху. */
.inventory-ach-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fef9f4;
}
.inventory-ach-head {
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid #f0e0d0;
}
.inventory-ach-count {
    font-size: 14px;
    font-weight: 700;
    color: #8a5836;
}
.inventory-ach-hint {
    font-size: 11px;
    color: #a89880;
}
.inventory-ach-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px 14px;
    font-size: 12px;
    color: #a89880;
}
.inventory-ach-group {
    font-size: 12px;
    font-weight: 700;
    color: #8a5836;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 14px 4px 6px;
}
.inventory-ach-group:first-child { margin-top: 2px; }
.inventory-ach-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #f0e0d0;
    margin-bottom: 7px;
}
.inventory-ach-row.unlocked {
    background: #fff8ec;
    border-color: #e0bc8a;
}
.inventory-ach-row.locked .inventory-ach-icon { filter: grayscale(1); opacity: 0.45; }
.inventory-ach-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0e0d0 center/contain no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #b9a68f;
}
.inventory-ach-meta { flex: 1 1 auto; min-width: 0; }
.inventory-ach-name {
    font-size: 14px;
    font-weight: 600;
    color: #3a2b20;
}
.inventory-ach-row.locked .inventory-ach-name { color: #6b5a4a; }
.inventory-ach-desc {
    font-size: 11.5px;
    color: #8a7565;
    margin-top: 1px;
}
/* Ссылки в описании («#фанарт» → посты в Телеграме и на Бусти). */
.inventory-ach-link {
    color: #b5651d;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
}
.inventory-ach-link:hover { color: #8a4510; border-bottom-style: solid; }
.inventory-ach-reward {
    font-size: 11px;
    color: #b87333;
    margin-top: 2px;
}

/* Редкость достижения (27.08.2026): «есть у 5% игроков и 9% ботов».
   Приглушённая строка — это справка, а не часть условия. */
.inventory-ach-rarity {
    font-size: 11px;
    color: #9a8878;
    margin-top: 2px;
}

/* «Чьи достижения»: свои, другого игрока или модели. */
.inventory-ach-who {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #f0e0d0;
}
.inventory-ach-who input {
    flex: 1 1 180px;
    min-width: 120px;
    padding: 6px 10px;
    border: 1px solid #d8c0a4;
    border-radius: 8px;
    font-size: 13px;
}
.inventory-ach-who-btn {
    padding: 6px 10px;
    border: 1px solid #d8c0a4;
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: #5c3d2e;
    cursor: pointer;
    white-space: nowrap;
}
.inventory-ach-who-btn:hover { background: #f5e6d3; }
.inventory-ach-subject {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    color: #8a5836;
    background: #fdf6ee;
    border-bottom: 1px solid #f0e0d0;
}
.inventory-ach-bar {
    position: relative;
    height: 6px;
    margin-top: 5px;
    border-radius: 3px;
    background: #f0e0d0;
    overflow: hidden;
}
.inventory-ach-bar > i {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(to right, #d4a574, #b87333);
}
.inventory-ach-progress {
    flex: 0 0 auto;
    font-size: 11px;
    color: #a89880;
    white-space: nowrap;
}
.inventory-ach-date { color: #b87333; }

/* Тост «получено достижение» — поверх всего, справа снизу.
   Три части (эскиз Светы 22.08.2026): значок достижения свисает с левого нижнего
   угла таблички, рядом колобок-награда, справа текст. Значок — отдельная картинка
   (public/extra/achievements/), её может ещё не быть: тогда элемент удаляется по
   onerror и остальное не съезжает, потому что он лежит абсолютом. */
.achievement-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 350px;
    padding: 14px 16px 14px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff6e6, #ffe9c7);
    border: 1px solid #e0bc8a;
    box-shadow: 0 10px 28px rgba(90, 60, 30, 0.28);
    animation: achToastIn 0.35s ease;
}
@keyframes achToastIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.achievement-toast.hiding { opacity: 0; transition: opacity 0.4s ease; }
.achievement-toast-badge {
    position: absolute;
    left: -18px;
    bottom: -16px;
    width: 62px;
    height: 62px;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(90, 60, 30, 0.35));
    pointer-events: none;
}
.achievement-toast-avatar {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fff center/contain no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.achievement-toast-text { flex: 1 1 auto; min-width: 0; }
.achievement-toast-title {
    font-size: 11px;
    font-weight: 700;
    color: #b87333;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.achievement-toast-name {
    font-size: 15px;
    font-weight: 700;
    color: #3a2b20;
}
.achievement-toast-desc {
    font-size: 11.5px;
    color: #8a7565;
    margin-top: 2px;
}

/* ===== ВКЛАДКА «МУЗЫКА» ===== */
.inventory-music-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fef9f4;
}
.inventory-music-hint {
    flex-shrink: 0;
    padding: 12px 16px;
    font-size: 12px;
    color: #8a7565;
    border-bottom: 1px solid #f0e0d0;
}
.inventory-music-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 12px 14px;
}
.music-group-title {
    font-size: 12px;
    font-weight: 700;
    color: #8a5836;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 12px 4px 6px;
    display: block;
    width: calc(100% - 8px);
    text-align: left;
    background: none;
    border: none;
    padding: 2px 0;
    cursor: pointer;
    font-family: inherit;
}
.music-group-title:hover { opacity: 0.8; }
.music-group-title:first-child { margin-top: 4px; }
.music-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}
.music-row:hover { background: #f5e6d3; }
.music-row.playing { background: #efe0cc; }
.music-play-btn {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    min-width: 28px;          /* без этого глобальный стиль кнопки растягивал в овал */
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    border: none;
    background: #8a5836;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.music-play-btn:hover { background: #6d4529; }
.music-play-btn:active { transform: scale(0.92); }
.music-row-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.music-row-name {
    font-size: 14px;
    color: #3a2b20;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.music-row-author {
    font-size: 11px;
    color: #a89880;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.music-dl-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #efe6da;
    color: #8a5836;
    font-size: 15px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.music-dl-btn:hover { background: #e0cdb6; }

/* Кнопка добавления трека в личный плейлист (★) */
.music-pl-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #efe6da;
    color: #b0a08c;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.music-pl-btn:hover { background: #e0cdb6; }
.music-pl-btn.in-playlist { color: #e6a817; background: #fbf0d0; }

/* Панель состояния личного плейлиста */
.inventory-music-playlist-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 12px;
    color: #6b5a4a;
    border-bottom: 1px solid #f0e0d0;
    background: #fffaf2;
}
.music-pl-empty { color: #a89880; }
.music-pl-count { flex: 1 1 auto; font-weight: 600; color: #8a5836; }
.music-pl-clear {
    flex-shrink: 0;
    border: 1px solid #d9c4a8;
    background: #fff;
    color: #8a5836;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}
.music-pl-clear:hover { background: #f3e7d6; }

.inventory-grid-wrap {
    overflow-y: auto;
    padding: 14px 16px;
    border-right: 1px solid #f0e0d0;
}
.inventory-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #8a7565;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
}
.inventory-section-title.unique { color: #b87333; }
.inventory-section-title.unavailable { color: #9e9e9e; }
.inventory-section-hint {
    font-size: 11px;
    color: #a89880;
    margin: -4px 0 8px;
}
.inventory-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #d4a574, transparent);
    margin: 14px 0;
}
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}
.inventory-cell {
    aspect-ratio: 1;
    border-radius: 10px;
    background: #f5e6d3;
    border: 2.5px solid transparent;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    overflow: hidden;
}
.inventory-cell:hover {
    transform: scale(1.05);
    background: #ebd6b9;
}
.inventory-cell.selected {
    border-color: #8a5836;
    background: white;
}
.inventory-cell.active-now {
    border-color: #4ade80;
}
.inventory-cell.active-now::after {
    content: '✓';
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 11px;
    background: #4ade80;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.inventory-cell.default-cell {
    font-size: 26px;
    color: #8a7565;
}
.inventory-cell img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    /* Flipped (как у игрока на левой стороне стола — сцена баннера/превью) */
    transform: scaleX(-1);
}
.inventory-cell.face-cell img {
    max-width: 44.6%;
    max-height: 44.6%;
}
/* Нагатроник (24.11.2026): картинки лиц набора в сетке на 20% крупнее.
   44.6 × 1.2 ≈ 53.5. */
.inventory-cell.face-cell[data-face-pack="nagatronfaces"] img {
    max-width: 53.52%;
    max-height: 53.52%;
}
/* Колобок — цельный спрайт, он и есть содержимое ячейки. Не зеркалим:
   персональные колобки рисованы уже в нужную сторону. */
.inventory-cell.avatar-cell img {
    max-width: 84%;
    max-height: 84%;
    transform: none;
}
/* Ячейка «обычный колобок» — свой цветной, а не крестик «снять». */
.inventory-own-avatar {
    width: 84%;
    height: 84%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
}

/* Недоступная ячейка: затемнена, с замком. Кликабельна (для примерки). */
.inventory-cell.locked img { filter: grayscale(0.7) brightness(0.92); opacity: 0.75; }
.inventory-cell.locked { background: #ece4da; }
.inventory-cell.locked.selected { background: #fff; }
.inventory-lock-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 11px;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
    pointer-events: none;
}

/* Карточка уникального НАБОРА лиц: одна ячейка на весь набор, по клику под ней
   раскрываются все эмоции набора. Отличается от обычной ячейки рамкой-«стопкой»
   и уголком ▸/▾. */
.inventory-cell.face-pack-cell {
    background: linear-gradient(160deg, #f7e9d0 0%, #efd9b4 100%);
    box-shadow: 2px 2px 0 0 rgba(138, 88, 54, 0.18), 4px 4px 0 0 rgba(138, 88, 54, 0.1);
}
.inventory-cell.face-pack-cell.expanded {
    background: #fff;
    border-color: #b87333;
}
.inventory-pack-badge {
    position: absolute;
    bottom: 1px;
    left: 4px;
    font-size: 11px;
    line-height: 1;
    color: #8a5836;
    pointer-events: none;
}
/* Заголовок раскрытого набора — мельче обычной секции, с отступом сверху. */
.inventory-section-title.pack-title {
    color: #b87333;
    text-transform: none;
    letter-spacing: 0;
    margin: 10px 0 6px;
}

.inventory-details {
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #fef9f4;
    min-height: 0;
    overflow-y: hidden;
}
.inventory-details-preview {
    flex-shrink: 0;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: #fff;
    margin-bottom: 14px;
    position: relative;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.inventory-preview-base {
    position: relative;
    z-index: 1; /* Колобок выше заднего слоя шапки (z-index:0), ниже оверлеев лица (2) и шапки (3) */
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #FF8C00;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}
/* УЗОР В ИНВЕНТАРЕ. Слой узора рисуется псевдоэлементом, и правило для него надо
   заводить в КАЖДОМ контексте отдельно — у вкладки «Колобки» его просто не было,
   поэтому узор там не показывался вовсе, хотя в конфиге стоял (жалоба Светы
   14.08.2026). Тело правила повторяет масочные контексты (лобби, профиль). */
.inventory-preview-base.has-pattern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    pointer-events: none;
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    mix-blend-mode: overlay;
}

/* Плитка «мой колобок» в сетке — это ГОЛЫЙ КРУГ без маски колобка, как стол.
   Значит рисунок в форме колобка надо растянуть на весь круг (иначе он занял бы
   65% и выглядел мелким), а тайловый оставить как есть. */
.inventory-own-avatar {
    position: relative;
}
.inventory-own-avatar.has-pattern::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: 154%;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    mix-blend-mode: overlay;
}
.inventory-own-avatar.pattern-vector::after {
    background-size: cover;
}

.inventory-preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}
/* Превью инвентаря — как в баннере профиля: flipped-сторона (как у игрока,
   сидящего слева за столом), лицо сдвинуто к визуально правому краю колобка,
   шляпа приподнята к макушке. Сам колобок и оверлеи зеркалятся отдельно
   (а не контейнером), чтобы белый фон и тень превью не отражались. */
.inventory-preview-base { transform: scaleX(-1); }
.inventory-preview-overlay.face { z-index: 2; transform: scaleX(-1) scale(0.446) translateX(-11.2%); }
/* Нагатроник вне стола (24.11.2026): +20% к обычному размеру в превью. */
.inventory-preview-overlay.face[data-face-pack="nagatronfaces"] {
    transform: scaleX(-1) scale(0.5352) translateX(-9.33%);
}
/* Собранное лицо — в геометрии стола (см. .profile-banner-face.face-built) */
.inventory-preview-overlay.face.face-built {
    inset: -25%;
    background-size: 100% 100%;
    transform: scaleX(-1) translate(calc(var(--inv-face-x) / -1.5), calc(var(--inv-face-y) / 1.5)) scale(var(--inv-face-scale));
}
.inventory-preview-overlay.hat  { z-index: 3; transform: scaleX(-1) translateY(-20%); }
/* Задний слой шапки в превью инвентаря (под колобком) */
.inventory-preview-overlay.hat-back { z-index: 0; transform: scaleX(-1) translateY(-20%); }

/* ===== ВТОРОЙ СЛОЙ АВАТАРА (части поверх колобка, под шапкой) =====
   Каждая часть — это ВНЕШНЯЯ КОРОБКА, равная коробке колобка, и картинка
   внутри неё. Смысл разделения: проценты смещения (--ov-x/--ov-y) считаются
   от размера внешней коробки, то есть от размера колобка, а не от размера
   самой части. Поэтому одни и те же x/y/size из AVATAR_OVERLAYS дают
   одинаковую картинку и за столом (170px), и в баннере профиля (~53px).

   Колобок-картинка занимает не весь бокс аватара: за столом это cover на все
   170px, а везде остальное — 66% бокса (см. .easter-egg-avatar выше).
   Отсюда --ov-base: доля бокса, которую реально занимает колобок. */
.avatar-overlay {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--ov-base, 66%);
    height: var(--ov-base, 66%);
    pointer-events: none;
    transform: translate(-50%, -50%) translate(var(--ov-x, 0%), var(--ov-y, 0%));
    z-index: 1; /* Выше колобка (z:1, но раньше по DOM), ниже лица (2) и шапки (3) */
}

.avatar-overlay > .avatar-overlay-part {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(var(--ov-rotate, 0deg));
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* За столом коробка колобка — это .player-sprite-table: 170×170 при top:-135px.
   Проценты тут не годятся (само место 0×0), поэтому размеры в px. */
.player-at-table > .avatar-overlay {
    top: -135px;
    left: 50%;
    width: 170px;
    height: 170px;
    pointer-events: none; /* .player-at-table > * включает события — тут не надо */
    transform: translateX(-50%) translate(var(--ov-x, 0%), var(--ov-y, 0%));
    /* Запасное значение — между дефолтами колобка (34) и шапки (39): его берёт
       превью dev-редактора, у которого нет посчитанных переменных места. */
    z-index: var(--seat-overlay-z, 36);
}

/* Правая половина стола зеркалится — вместе со смещением частей, иначе
   причёска, сдвинутая вправо, осталась бы справа и на зеркальном колобке. */
.player-at-table.flipped > .avatar-overlay {
    transform: translateX(-50%) scaleX(-1) translate(var(--ov-x, 0%), var(--ov-y, 0%));
}

/* Мертвецов гасим целиком — как колобок и шапку */
.player-at-table.dead > .avatar-overlay {
    filter: grayscale(50%) brightness(0.5) contrast(1.2);
}

/* Превью инвентаря зеркалит сам колобок (.inventory-preview-base), а не свою
   коробку, — поэтому второй слой зеркалим отдельно, как лицо и шапку. */
.inventory-details-preview > .avatar-overlay {
    transform: translate(-50%, -50%) scaleX(-1) translate(var(--ov-x, 0%), var(--ov-y, 0%));
}

/* Мини-аватар (16px в списках голосования) — единственное место, где картинка
   аватара растянута на весь бокс, а не на 66% (см. .mini-avatar.easter-egg-avatar). */
.mini-avatar > .avatar-overlay {
    --ov-base: 100%;
}
.inventory-details-name {
    flex-shrink: 0;
    font-size: 17px;
    font-weight: 700;
    color: #3a2b20;
    margin-bottom: 6px;
}
.inventory-details-desc {
    flex-shrink: 0;
    font-size: 13px;
    color: #6b5a4a;
    line-height: 1.4;
    margin-bottom: 14px;
    min-height: 40px;
}
.inventory-use-btn {
    flex-shrink: 0;
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    background: #8a5836;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.inventory-use-btn:hover:not(:disabled) { background: #6e4528; }
/* Подпись к колобку — та, что ставится в рантайме (adminSetAvatarCaption).
   Отдельной строкой и заметнее служебного текста: она про самого колобка. */
.inventory-avatar-caption {
    display: block;
    margin-bottom: 6px;
    color: #8a5836;
    font-style: italic;
    font-weight: 600;
}

/* «Как получить» — вторая строка под описанием колобка: путей два (достижение
   и опыт), и без неё замок на карточке ничего не объясняет. */
.inventory-avatar-unlock {
    display: block;
    margin-top: 6px;
    color: #a07a4e;
    font-size: 11.5px;
    line-height: 1.35;
}

/* Вторичная кнопка под «Использовать» (сейчас — «Редактор аватара»).
   Не соревнуется с основной: контурная, не заливная. */
.inventory-secondary-btn {
    flex-shrink: 0;
    width: 100%;
    margin-top: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid #d9c4a8;
    background: #fff;
    color: #8a5836;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.inventory-secondary-btn:hover { background: #f7ede0; }
.inventory-use-btn:disabled {
    background: #4ade80;
    cursor: default;
    opacity: 1;
}
.inventory-unlock-hint {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-top: 12px;
    padding: 10px 12px;
    background: #fff8ec;
    border: 1px solid #e8d4b8;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: #6b5a4a;
    text-align: left;
    width: 100%;
}
.inventory-unlock-hint ol { margin: 6px 0; padding-left: 18px; }
.inventory-unlock-hint a { color: #b87333; text-decoration: underline; }

/* МОБИЛЬНАЯ адаптация — колонки в столбик */
@media (max-width: 700px) {
    .inventory-content {
        max-width: 360px !important;
        width: 94vw;
    }
    .inventory-content .modal-header { padding: 10px 14px; font-size: 14px; }
    /* Пять вкладок в 360px не помещаются подписями — разрешаем перенос строки. */
    .inventory-tabs { flex-wrap: wrap; }
    .inventory-tab-btn { font-size: 12px; padding: 6px 8px; flex: 1 1 30%; }
    .inventory-ach-row { padding: 8px; gap: 9px; }
    .inventory-ach-icon { width: 34px; height: 34px; font-size: 15px; }
    .inventory-ach-name { font-size: 13px; }
    /* Значок свисает влево — на телефоне отодвигаем тост от края, чтобы не срезало. */
    .achievement-toast { right: 10px; bottom: 14px; max-width: calc(100vw - 34px); margin-left: 22px; }
    .achievement-toast-badge { width: 50px; height: 50px; left: -14px; bottom: -12px; }
    .achievement-toast-avatar { width: 44px; height: 44px; }
    .inventory-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .inventory-grid-wrap {
        border-right: none;
        border-bottom: 1px solid #f0e0d0;
        padding: 10px 12px;
        max-height: 40vh;
    }
    .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
    .inventory-cell.default-cell { font-size: 20px; }
    .inventory-details { padding: 12px; }
    .inventory-details-preview { width: 80px; height: 80px; margin-bottom: 8px; }
    .inventory-details-name { font-size: 14px; }
    .inventory-details-desc { font-size: 12px; min-height: 30px; margin-bottom: 10px; }
    .inventory-use-btn { font-size: 13px; padding: 8px 14px; }
    .inventory-content .modal-footer { padding: 10px 14px; }
    .inventory-content .modal-footer button { font-size: 13px; padding: 8px 14px; }
    /* Музыка — компактнее на телефоне */
    .inventory-music-hint { padding: 8px 12px; font-size: 11px; }
    .inventory-music-list { padding: 6px 8px 10px; }
    .music-row { gap: 8px; padding: 6px 6px; }
    .music-play-btn { width: 30px; height: 30px; font-size: 13px; }
    .music-dl-btn { width: 28px; height: 28px; font-size: 13px; }
    .music-row-name { font-size: 13px; }
    .music-pl-btn { width: 28px; height: 28px; font-size: 13px; }
}

/* Телефон в ЛАНДШАФТЕ (а играют только так — портрет перекрыт заглушкой):
   экран широкий, но низкий. Возвращаем колонки бок-о-бок и используем всю
   ширину/высоту — иначе при стопке (грид сверху, детали снизу) ничего не влезает.

   ВАЖНО про условие: раньше тут стояло `max-width: 900px`, и на телефонах,
   которые в альбомной дают 900–1000px ширины, правило не срабатывало вообще —
   инвентарь оставался в десктопной раскладке и не влезал в экран (жалоба
   «окно не влезает, прокрутить нельзя»). Признак телефона в альбомной — не
   ширина, а НИЗКАЯ высота, по ней и гейтим. */
@media (orientation: landscape) and (max-height: 560px) {
    .inventory-content {
        max-width: 94vw !important;
        width: 94vw;
        height: 94dvh;
    }
    .inventory-body {
        grid-template-columns: 1.4fr 1fr;
        grid-template-rows: none;
    }
    .inventory-grid-wrap {
        max-height: none;
        border-right: 1px solid #f0e0d0;
        border-bottom: none;
    }
    /* Правая колонка (превью + описание + кнопка) своего скролла не имела:
       при нехватке высоты её содержимое просто обрезалось родительским
       overflow: hidden — отсюда «прокрутить нельзя». */
    .inventory-details {
        overflow-y: auto;
        min-height: 0;
    }
    .inventory-details-preview { width: 76px; height: 76px; margin-bottom: 6px; }
    .inventory-details-desc { min-height: 0; }
    .inventory-content .modal-header { padding: 8px 12px; font-size: 14px; }
    .inventory-tab-btn { font-size: 12px; padding: 5px 8px; }
    .inventory-content .modal-footer { padding: 8px 12px; }
}

/* === МОБИЛЬНЫЕ ПРАВКИ — компактнее === */
@media (max-width: 700px) {
    .profile-editor-content {
        max-width: 340px !important;
        width: 94vw;
    }
    .profile-editor-content .modal-header { padding: 10px 14px; font-size: 14px; }
    .profile-editor-body { padding: 10px 14px; }
    .profile-editor-banner-preview { height: 60px; margin-bottom: 12px; }
    .profile-editor-banner-label { font-size: 11px; }
    .profile-editor-section { margin-bottom: 12px; }
    .profile-editor-label { font-size: 12px; margin-bottom: 6px; }
    .profile-editor-tab-btn { font-size: 11px; padding: 5px 8px; }
    #profile-editor-caption { font-size: 12px; padding: 6px 8px; }
    .profile-editor-toggle-label { font-size: 13px; }
    .profile-editor-hint { font-size: 11px; margin-left: 24px; }
    .profile-editor-content .modal-footer { padding: 10px 14px; }
    .profile-editor-content .modal-footer button { font-size: 13px; padding: 8px 14px; }

    .profile-modal-content {
        max-width: 360px !important;
        width: 94vw;
    }
    .profile-banner-content { padding: 14px 12px; gap: 10px; }
    .profile-banner-avatar,
    .profile-banner-avatar-wrap { width: 56px; height: 56px; }
    .profile-banner-name { font-size: 17px; }
    .profile-banner-caption { font-size: 12px; }
    .profile-banner-title { font-size: 11px; padding: 1px 7px; }
    .profile-banner-status { font-size: 11px; padding: 2px 8px; }
    .profile-edit-btn { width: 30px; height: 30px; font-size: 14px; }
    .profile-actions { padding: 10px 12px 6px; gap: 6px; }
    .profile-action-btn { padding: 8px 10px; font-size: 12px; }
    .profile-section { padding: 10px 12px; }
    .profile-section-title { font-size: 13px; margin-bottom: 8px; }
    .profile-stats-grid-modal { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .profile-stat-cell { padding: 6px 4px; }
    .profile-stat-cell-icon { font-size: 16px; }
    .profile-stat-cell-value { font-size: 13px; }
    .profile-stat-cell-label { font-size: 10px; }
    .profile-friend-item-avatar { width: 24px; height: 24px; }
    .profile-friend-item-name { font-size: 12px; max-width: 90px; }
}

/* ============================================
   ОНЛАЙН-СЧЁТЧИК НА ЭКРАНЕ ВХОДА
   ============================================ */
#name-panel .online-count {
    font-size: 13px;
    color: #8a7565;
    text-align: center;
    margin-top: -10px;
}

#name-panel .online-count .online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

/* ============================================
   СИСТЕМА ЖЕСТОВ
   ============================================ */

/* Кнопка управления звуком */
#audio-toggle-btn {
    position: fixed;
    top: 20px;
    right: 290px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 17px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

#audio-toggle-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

#tts-toggle-btn {
    position: fixed;
    top: 20px;
    right: 344px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 17px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

#tts-toggle-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

/* ===== Дневной/ночной стиль верхних кнопок (кроме голубой активной) ===== */
body.day-mode #tts-toggle-btn:not(.active),
body.day-mode #audio-toggle-btn:not(.active),
body.day-mode #volume-mixer-btn:not(.active),
body.day-mode #my-context-btn:not(.active),
body.day-mode #help-floating-btn:not(.active),
body.day-mode #room-settings-floating-btn:not(.active),
body.day-mode #profile-floating-btn:not(.active),
body.day-mode #speech-bubble-btn:not(.active) {
    background: rgba(255, 236, 210, 0.9);
    color: #5a4030;
    border-color: rgba(160, 115, 76, 0.7);
}

body.day-mode #tts-toggle-btn:not(.active):hover,
body.day-mode #audio-toggle-btn:not(.active):hover,
body.day-mode #volume-mixer-btn:not(.active):hover,
body.day-mode #my-context-btn:not(.active):hover,
body.day-mode #help-floating-btn:not(.active):hover,
body.day-mode #room-settings-floating-btn:not(.active):hover,
body.day-mode #profile-floating-btn:not(.active):hover,
body.day-mode #speech-bubble-btn:not(.active):hover {
    background: rgba(255, 244, 225, 0.97);
}

body.night-mode #tts-toggle-btn:not(.active),
body.night-mode #audio-toggle-btn:not(.active),
body.night-mode #volume-mixer-btn:not(.active),
body.night-mode #my-context-btn:not(.active),
body.night-mode #help-floating-btn:not(.active),
body.night-mode #room-settings-floating-btn:not(.active),
body.night-mode #profile-floating-btn:not(.active),
body.night-mode #speech-bubble-btn:not(.active) {
    background: rgba(24, 22, 40, 0.85);
    color: #ebe7ff;
    border-color: rgba(132, 121, 182, 0.7);
}

body.night-mode #tts-toggle-btn:not(.active):hover,
body.night-mode #audio-toggle-btn:not(.active):hover,
body.night-mode #volume-mixer-btn:not(.active):hover,
body.night-mode #my-context-btn:not(.active):hover,
body.night-mode #help-floating-btn:not(.active):hover,
body.night-mode #room-settings-floating-btn:not(.active):hover,
body.night-mode #profile-floating-btn:not(.active):hover,
body.night-mode #speech-bubble-btn:not(.active):hover {
    background: rgba(36, 32, 59, 0.93);
}

/* Кнопка микшера громкости */
#volume-mixer-btn {
    position: fixed;
    top: 20px;
    right: 398px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 17px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#volume-mixer-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

/* Панель микшера */
.volume-mixer-panel {
    position: fixed;
    top: 68px;
    right: 398px;
    background: rgba(20, 20, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 16px;
    z-index: 10000;
    min-width: 220px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}
.volume-mixer-panel.hidden { display: none; }
.volume-mixer-title {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: center;
}
.volume-mixer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.volume-mixer-row:last-child { margin-bottom: 0; }
.volume-mixer-label {
    color: #ccc;
    font-size: 12px;
    min-width: 72px;
    white-space: nowrap;
}
.volume-mixer-value {
    color: #aaa;
    font-size: 11px;
    min-width: 32px;
    text-align: right;
}
.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #6c63ff;
    cursor: pointer;
    border: 2px solid #fff;
}
.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #6c63ff;
    cursor: pointer;
    border: 2px solid #fff;
}

/* ===== Кнопка выносок ===== */
#speech-bubble-btn {
    position: fixed;
    top: 20px;
    right: 360px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 20px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#speech-bubble-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); }
#speech-bubble-btn.active { background: rgba(100, 99, 255, 0.5); border-color: #6c63ff; }

/* Кнопка просмотра своего контекста */
#my-context-btn {
    position: fixed;
    top: 20px;
    right: 506px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 16px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.chat-message.local-draft {
    opacity: 0.7;
    color: #b8b8b8;
    font-style: italic;
}

.chat-message.local-draft .sender {
    color: #9e9e9e;
}
#my-context-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); }

/* ===== Счётчик зрителей (v2.0, п.10) =====
   Крайняя ПРАВАЯ в верхнем ряду: между кнопкой музыки (290) и таймером фазы (20).
   Показывается ТОЛЬКО когда зрители есть — в обычной партии ряд остаётся прежним.
   Пока кнопка на экране, таймер сильнее режет свою подпись (см. body.has-spectators
   #phase-label), иначе длинная «Речь: Имя» расползлась бы влево прямо на неё. */
#spectators-btn {
    position: fixed;
    top: 20px;
    right: 236px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: transform 0.2s, background 0.2s;
}
#spectators-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); }
#spectators-btn.active { background: rgba(100, 99, 255, 0.5); border-color: #6c63ff; }
.spectators-eye { font-size: 14px; }
/* Цифра — под глазом, как просили: не бейджем в углу, а вторым этажом кнопки */
.spectators-count {
    font-size: 10px;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

.spectators-panel {
    position: fixed;
    top: 62px;
    right: 236px;
    min-width: 190px;
    max-width: 260px;
    max-height: 320px;
    overflow-y: auto;
    background: rgba(20, 20, 35, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 10px 12px;
    /* 10000 — как у микшера и меню ☰: выпадашки верхнего ряда обязаны быть ВЫШЕ
       мини-панели бога (#god-controls-bar, 9999), она висит прямо под ними. */
    z-index: 10000;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.spectators-panel.hidden { display: none; }
.spectators-title {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.75;
    color: #fff;
    margin-bottom: 8px;
}
.spectators-list { display: flex; flex-direction: column; gap: 6px; }
.spectators-row { display: flex; align-items: center; gap: 8px; }
.spectators-row .mini-avatar { flex: 0 0 auto; }
.spectators-name {
    font-size: 13px;
    color: #f0eefc;
    min-width: 0;           /* без этого длинное имя распирает строку вместо многоточия */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.spectators-empty { font-size: 12px; opacity: 0.7; color: #f0eefc; }
.spectators-name { flex: 1 1 auto; }
/* Выгнать/забанить зрителя — кнопки справа в строке (18.09.2026) */
.spectators-mod-btn {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    min-width: 22px; min-height: 22px;
    padding: 0; margin: 0;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: #f0eefc;
    font-size: 12px; line-height: 1;
    cursor: pointer;
}
.spectators-mod-btn:hover { background: rgba(255,255,255,0.28); }
/* Доверенное лицо (Апрель, п.29): роли открыты — замок подсвечен */
.spectators-mod-btn.is-on { background: rgba(255, 200, 80, 0.45); }

/* «🙈 Слепой зритель» рядом с подписью «Наблюдатель» (24.11.2026) — как выпадашка «глазами …» */
#blind-spectator-btn {
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
    cursor: pointer;
}
#blind-spectator-btn.is-on { background: rgba(255, 200, 80, 0.45); border-color: rgba(255, 200, 80, 0.8); }
#blind-spectator-btn:hover { transform: none; box-shadow: none; filter: brightness(1.1); }

/* «Глазами …» у зрителя с открытыми картами (п.29): ночные метки, проверки и
   совет мафии видны только своей стороне. Роли и шапки фильтрует script.js. */
#spectator-view-select {
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 12px;
}
body[data-spec-view="town"] :is(.player-tag.black-mark, .player-tag.maniac-mark, .player-tag.heal-mark, .player-tag.sheriff-check, .player-tag.don-check),
body[data-spec-view="mafia"] :is(.player-tag.maniac-mark, .player-tag.heal-mark, .player-tag.sheriff-check),
body[data-spec-view="sheriff"] :is(.player-tag.black-mark, .player-tag.maniac-mark, .player-tag.heal-mark, .player-tag.don-check),
body[data-spec-view="maniac"] :is(.player-tag.black-mark, .player-tag.heal-mark, .player-tag.sheriff-check, .player-tag.don-check),
body[data-spec-view]:not([data-spec-view="all"]):not([data-spec-view="mafia"]) .chat-message.chat-mafia-only {
    display: none !important;
}

/* День/ночь — как у остальных кнопок верхнего ряда */
body.day-mode #spectators-btn:not(.active) {
    background: rgba(255, 236, 210, 0.9);
    color: #5a4030;
    border-color: rgba(160, 115, 76, 0.7);
}
body.day-mode #spectators-btn:not(.active):hover { background: rgba(255, 244, 225, 0.97); }
body.night-mode #spectators-btn:not(.active) {
    background: rgba(24, 22, 40, 0.85);
    color: #ebe7ff;
    border-color: rgba(132, 121, 182, 0.7);
}
body.night-mode #spectators-btn:not(.active):hover { background: rgba(36, 32, 59, 0.93); }

/* Плавающая кнопка помощи */
#help-floating-btn {
    position: fixed;
    top: 20px;
    right: 410px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#help-floating-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); }

/* Плавающая кнопка настроек комнаты */
#room-settings-floating-btn {
    position: fixed;
    top: 20px;
    right: 460px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 20px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#room-settings-floating-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); }

/* Плавающая кнопка профиля */
#profile-floating-btn {
    position: fixed;
    top: 20px;
    right: 510px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 20px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#profile-floating-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); }

/* ==== Кнопка меню игры (v2.0 — объединяет профиль/помощь/настройки/выноски) ==== */
#game-menu-btn {
    position: fixed;
    top: 20px;
    right: 452px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 18px;
    border: 2px solid #d4a574;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
#game-menu-btn:hover { transform: scale(1.1); background: rgba(0, 0, 0, 0.9); border-color: #f5d89a; }
#game-menu-btn.active { background: rgba(100, 99, 255, 0.5); border-color: #6c63ff; }
body.day-mode #game-menu-btn:not(.active) {
    background: rgba(255, 236, 210, 0.9);
    color: #5a4030;
    border-color: #b8865a;
}
body.day-mode #game-menu-btn:not(.active):hover {
    background: rgba(255, 244, 225, 0.97);
    border-color: #d4a574;
}
body.night-mode #game-menu-btn.active {
    background: rgba(100, 99, 255, 0.5);
    border-color: #6c63ff;
}

.game-menu-dropdown {
    position: fixed;
    top: 62px;
    right: 452px;
    background: rgba(20, 20, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 6px 0;
    z-index: 10000;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}
.game-menu-dropdown.hidden { display: none; }

.game-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: #ddd;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.game-menu-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.game-menu-icon {
    width: 22px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

/* ============================================
   PHASE 2.1 — МОБИЛЬНОЕ МЕНЮ + АДАПТИВНЫЙ ЧАТ
   На узких экранах все вспомогательные кнопки прячутся в выпадающее меню.
   ============================================ */

#mobile-menu-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 22px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1003;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
#mobile-menu-btn:hover { transform: scale(1.05); background: rgba(0, 0, 0, 0.9); }

.mobile-menu-dropdown {
    position: fixed;
    top: 76px;
    right: 20px;
    width: 260px;
    background: rgba(20, 14, 8, 0.96);
    border-radius: 12px;
    z-index: 1004;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
}
.mobile-menu-dropdown.hidden { display: none; }

.mobile-menu-item {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #f0e4d4;
    padding: 11px 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 15px;
    text-align: left;
    transition: background 0.15s;
    font-family: inherit;
}
.mobile-menu-item:hover { background: rgba(255, 255, 255, 0.18); }
.mobile-menu-item:active { background: rgba(255, 255, 255, 0.25); }
.mobile-menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.mobile-menu-item-danger { color: #ff9292; }
.mobile-menu-item-danger:hover { background: rgba(255, 80, 80, 0.25); }
.mobile-menu-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin: 4px 0;
}

/* Чат — открытое (mobile-shown) состояние: фуллскрин-оверлей */
#chat-panel.mobile-shown {
    width: 92vw;
    max-width: 380px;
    height: 60vh;
    height: 60dvh;
    left: 4vw;
    top: 76px;
    resize: none;    /* в мобильном оверлее размер меняет mobile-ui.js (свой угловой хват) */
    min-width: 0;    /* десктопные ограничения размера не должны влиять на мобильный оверлей */
    min-height: 0;
}

/* === Компактный режим (узкие/мобильные экраны) === */
@media (max-width: 1100px) {
    /* Прячем индивидуальные плавающие кнопки — они теперь в меню */
    #audio-toggle-btn,
    #tts-toggle-btn,
    #volume-mixer-btn,
    #speech-bubble-btn,
    #help-floating-btn,
    #room-settings-floating-btn,
    #profile-floating-btn,
    #my-context-btn,
    #spectators-btn,
    #balance-game-btn,
    #voice-btn,
    #mic-toggle-btn,
    #afterparty-menu-btn,
    #leave-game-btn {
        display: none !important;
    }
    /* Чат по умолчанию скрыт; открывается через меню (класс .mobile-shown) */
    #chat-panel:not(.mobile-shown) {
        display: none !important;
    }
    /* Меню игры ☰ на телефоне не нужно: ВСЕ его пункты (выноски, помощь,
       настройки комнаты, профиль) уже лежат в мобильном меню ☰. Две одинаковые
       кнопки ☰ на одном экране — это п.12 April_master (25.08.2026). */
    #game-menu-btn,
    #game-menu-dropdown {
        display: none !important;
    }
}

/* То же для телефона в АЛЬБОМНОЙ: там ширина бывает 1100+px, и гейт по
   max-width выше не срабатывает (см. html.phone-ui, mobile-ui.js). */
html.phone-ui #game-menu-btn,
html.phone-ui #game-menu-dropdown {
    display: none !important;
}

/* На широких экранах кнопка-меню всегда скрыта.
   html:not(.phone-ui) — потому что у крупных телефонов в альбомной ширина
   бывает и 1100+px: там гейт по ширине соврал бы и спрятал ☰ на телефоне
   (класс phone-ui ставит mobile-ui.js по короткой стороне экрана). */
@media (min-width: 1101px) {
    html:not(.phone-ui) #mobile-menu-btn,
    html:not(.phone-ui) #mobile-menu-dropdown {
        display: none !important;
    }
}

/* ============================================
   PHASE 2.1.1 — КОМПАКТНЫЙ UI ДЛЯ МОБИЛЫ
   Уменьшаем «День N», таймер, "Воздержаться", уведомления.
   Делаем чат и модалки читаемыми. Фиксируем позицию микшера.
   ============================================ */
@media (max-width: 1100px) {
    /* "День 1" — компактнее */
    #phase-display {
        padding: 6px 14px !important;
    }
    #phase-title {
        font-size: 14px !important;
    }
    #phase-number {
        font-size: 12px !important;
    }

    /* Таймер фазы */
    #phase-timer {
        padding: 6px 10px !important;
        font-size: 13px !important;
        right: 76px !important; /* слева от кнопки-меню */
        top: 20px !important;
    }

    /* Кнопка "Воздержаться" / "Закончить речь" / "Пропустить номинацию" */
    .abstain-btn,
    #finish-defense-btn,
    #skip-nomination-btn {
        padding: 8px 14px !important;
        font-size: 13px !important;
        right: 10px !important;
    }

    /* Уведомления — компактные */
    #notification-container {
        right: 10px !important;
        left: 10px !important;
        top: 70px !important;
    }
    .notification {
        max-width: 100% !important;
        font-size: 13px !important;
        padding: 10px 14px !important;
    }

    /* === ЧАТ В МОБИЛЬНОМ ОВЕРЛЕЕ — крупнее текст === */
    #chat-panel.mobile-shown .chat-message,
    #chat-panel.mobile-shown #chat-messages {
        font-size: 15px !important;
        line-height: 1.4;
    }
    #chat-panel.mobile-shown .chat-message {
        font-size: 15px !important;
    }
    #chat-panel.mobile-shown #chatInput {
        font-size: 15px !important;
        padding: 8px 12px !important;
    }
    #chat-panel.mobile-shown #sendChatBtn {
        font-size: 18px !important;
        padding: 8px 14px !important;
    }
    #chat-panel.mobile-shown .chat-title {
        font-size: 15px !important;
        padding: 12px 14px !important;
    }

    /* === МОДАЛКИ — fit в маленький экран ===
       .modal-content — обычная модалка (с padding-ом сама)
       .modal-wide    — широкая модалка (settings/create-room), padding на детях */
    .modal-content:not(.modal-wide):not(.avatar-editor-content) {
        max-width: 95vw !important;
        width: auto !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        overflow-y: auto !important;
        padding: 16px !important;
        font-size: 14px !important;
    }
    .modal-content:not(.modal-wide):not(.avatar-editor-content) .modal-header {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }

    /* Широкая модалка (создание комнаты, расширенные настройки) — фуллскрин на мобиле */
    .modal-wide {
        max-width: 100vw !important;
        width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
    }
    .modal-wide .modal-header {
        font-size: 16px !important;
        padding: 12px 16px !important;
    }
    .modal-wide .modal-settings {
        padding: 0 14px !important;
    }
    .settings-section {
        padding: 10px 12px !important;
        margin-bottom: 12px !important;
    }
    .settings-section-title {
        font-size: 14px !important;
    }
    .settings-group {
        padding: 10px !important;
        margin-bottom: 10px !important;
    }
    .settings-group-title {
        font-size: 13px !important;
    }
    .form-field {
        margin-bottom: 10px !important;
    }
    .form-field label {
        font-size: 13px !important;
    }
    .form-field input[type="text"],
    .form-field input[type="number"],
    .form-field select,
    .form-field textarea {
        font-size: 14px !important;
        padding: 8px 10px !important;
        min-height: 36px !important;
    }
    .form-actions,
    .modal-footer {
        padding: 12px 14px !important;
        gap: 8px !important;
    }
    .form-actions button,
    .modal-footer button {
        font-size: 14px !important;
        padding: 10px 16px !important;
    }
    /* Подсказки/help-tooltip — компактнее */
    .help-tooltip {
        font-size: 12px !important;
        width: 18px !important;
        height: 18px !important;
        line-height: 18px !important;
    }
    .help-tip-box {
        font-size: 12px !important;
        padding: 10px !important;
    }

    /* === РЕДАКТОР АВАТАРА — компактные размеры (без zoom) ===
       Цель: на телефоне в портрете 360×800 чтобы видно было одновременно:
       header + tabs + превью + текст + 2-3 ряда цветов + footer без скролла. */
    .avatar-editor-content {
        max-width: 340px !important;
        width: 90vw !important;
        max-height: 88dvh !important;
        border-radius: 12px !important;
    }
    /* Header — title и табы в одну строку, чтобы экономить вертикаль */
    .avatar-editor-content .modal-header {
        padding: 8px 12px !important;
        gap: 8px !important;
        flex-direction: row !important;
        align-items: center !important;
    }
    .avatar-editor-content .modal-header > span {
        font-size: 13px !important;
        white-space: nowrap !important;
    }
    .avatar-editor-tabs {
        flex: 1 !important;
        gap: 4px !important;
    }
    .avatar-editor-tabs .tab-btn {
        padding: 5px 6px !important;
        font-size: 11px !important;
        border-radius: 6px !important;
    }
    /* Body — компактные отступы */
    .avatar-editor-body {
        padding: 10px 12px !important;
    }
    .avatar-editor-preview {
        margin-bottom: 6px !important;
    }
    #editor-avatar-preview {
        width: 56px !important;
        height: 56px !important;
    }
    .tab-description {
        font-size: 11px !important;
        margin-bottom: 6px !important;
    }
    /* Цвета — 6 в ряд, компактные квадратики */
    .color-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 5px !important;
    }
    .color-option {
        border-radius: 6px !important;
        border-width: 2px !important;
    }
    /* Узоры — 5 в ряд */
    .pattern-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 5px !important;
    }
    /* Footer — компактные кнопки */
    .avatar-editor-content .modal-footer {
        padding: 8px 12px !important;
        gap: 6px !important;
    }
    .avatar-editor-content .modal-footer button {
        padding: 6px 14px !important;
        font-size: 13px !important;
    }

    /* === МИКШЕР ГРОМКОСТИ — позиция фикс (был off-screen на узких экранах) === */
    .volume-mixer-panel {
        top: 76px !important;
        right: 10px !important;
        left: auto !important;
        max-width: calc(100vw - 20px);
        min-width: 0 !important;
        width: 280px;
    }
}

/* ============================================
   ФИКС СТРУКТУРЫ РЕДАКТОРА АВАТАРА
   Чтобы header + footer были фиксированы, а body скроллился — flex-column.
   Применяется на ВСЕХ экранах (не только мобиле) — это структурный фикс.
   ============================================ */
.avatar-editor-content {
    display: flex !important;
    flex-direction: column !important;
}
.avatar-editor-content .modal-header { flex-shrink: 0; }
.avatar-editor-content .modal-footer { flex-shrink: 0; }
.avatar-editor-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* ============================================
   КЛАВИАТУРА ОТКРЫТА — поднимаем модалки к верху видимой области.
   .modal обычно центрирует контент по вертикали; при открытой клавиатуре
   это значит что модалка может оказаться частично под ней. Прижимаем сверху.
   ============================================ */
body.keyboard-open .modal {
    align-items: flex-start !important;
    padding-top: 12px !important;
}
/* .modal-wide (фуллскрин на мобиле) — уже занимает всё, ничего не сдвигаем */
body.keyboard-open .modal-wide {
    padding-top: 0 !important;
}

/* ============================================
   СОСУЩЕСТВОВАНИЕ С САМОПИСНОЙ КЛАВИАТУРОЙ
   keyboard.js при показе ставит body.custom-kb-open и --kb-height.
   Ограничиваем высоту панелей, чтобы активный инпут не уходил под клавиатуру.
   ============================================ */
body.custom-kb-open .modal-content,
body.custom-kb-open .avatar-editor-content,
body.custom-kb-open .changelog-history-modal-content {
    max-height: calc(100vh - var(--kb-height) - 24px) !important;
    max-height: calc(100dvh - var(--kb-height) - 24px) !important;
    overflow-y: auto;
}
/* Чат-оверлей: ужимаем, чтобы поле ввода осталось над клавиатурой */
body.custom-kb-open #chat-panel.mobile-shown {
    max-height: calc(100vh - 84px - var(--kb-height));
    max-height: calc(100dvh - 84px - var(--kb-height));
}

/* ============================================
   ПЛАШКА «ПОСЛЕДНИЕ СЛОВА» НА ТЕЛЕФОНЕ
   #last-words-container создаётся инлайн-стилями в script.js, поэтому
   переопределяем через !important. Делаем компактным flex-столбцом
   с явными отступами — чтобы имя/таймер не наезжали на кнопку «Закончить речь».
   ============================================ */
@media (max-width: 1100px) {
    #last-words-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 6px !important;
        top: 70px !important;
        padding: 12px 18px !important;
        min-width: 0 !important;
        max-width: min(92vw, 360px) !important;
        font-size: 15px !important;
    }
    #last-words-container > div { margin: 0 !important; }
    #last-words-speaker { font-size: 18px !important; }
    #last-words-timer { font-size: 26px !important; }
    #finish-last-words-btn { margin-top: 4px !important; padding: 10px 20px !important; font-size: 15px !important; }
}

/* Низкая альбомная высота телефона — ещё компактнее */
@media (orientation: landscape) and (max-height: 500px) {
    #last-words-container {
        top: 54px !important;
        padding: 8px 16px !important;
        gap: 4px !important;
    }
    #last-words-speaker { font-size: 16px !important; }
    #last-words-timer { font-size: 22px !important; }
    #finish-last-words-btn { margin-top: 2px !important; padding: 7px 16px !important; font-size: 14px !important; }
}

/* Поиск по моделям в модалках */
#botModelSearch,
#upgradeModelSearch {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid rgba(220, 220, 220, 0.);
    border-radius: 8px;
    background: rgba(245, 245, 245, 0.08);
    color: #C0C0C0;
}

/* Лейаут провайдеров TTS: browser + elevenlabs сверху, AI Studio ниже */
.tts-provider-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
}

.tts-provider-wide-row {
    grid-column: 1 / -1;
}

/* ===== Выноски (speech bubbles) ===== */
.speech-bubble {
    position: absolute;
    background:
        radial-gradient(circle at top left, rgba(167, 205, 255, 0.2), transparent 34%),
        linear-gradient(165deg, rgba(14, 25, 51, 0.97) 0%, rgba(27, 33, 68, 0.97) 100%);
    color: #f3f7ff;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    padding: 13px 17px 14px;
    border-radius: 16px;
    width: 360px;
    word-break: break-word;
    z-index: 2147483647 !important;
    pointer-events: none;
    box-shadow:
        0 14px 30px rgba(3, 10, 26, 0.46),
        0 0 0 1px rgba(169, 201, 255, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(169, 201, 255, 0.38);
    animation: bubbleFadeIn 0.25s ease-out;
    transition: opacity 0.5s ease;
    overflow: visible;
}
.speech-bubble.fade-out { opacity: 0; }

.speech-bubble::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    pointer-events: none;
    opacity: 0.9;
}

/* Говорящий игрок не должен подниматься над столом/UI только из-за состояния речи. */
.player-at-table.is-speaking { z-index: auto !important; }

/* Хвостик выноски — угловой клин: выходит из ближнего НИЖНЕГО УГЛА и смотрит
   вниз-В-СТОРОНУ автора (выноска стоит сбоку от колобка, BUBBLE_SIDE_GAP_PX в
   script.js). Рисуем clip-path, а не бордерами: у клина три опорные точки —
   вверх по ближнему борту (--tail-up), вдоль низа (--tail-base) и кончик,
   вынесенный наружу на --tail-out и вниз на --tail-down.

   Две тонкости, из-за которых старый бордерный хвостик выглядел отвалившимся:
   1) клин заходит на 2px ВНУТРЬ выноски (--tail-ovl) и закрывает её собственную
      1px рамку в месте стыка — иначе поперёк основания шла тёмная черта;
   2) ближний нижний угол выноски выпрямляем (border-radius 0) — скруглённый
      угол оставлял между телом и клином прозрачную зазубрину.
   Цвет — сплошной, подобран под угол градиента фона; дневной режим свой. */
.speech-bubble::after {
    --tail-out: 5px;
    --tail-base: 26px;
    --tail-up: 25px;
    --tail-down: 5px;
    --tail-ovl: 2px;
    content: '';
    position: absolute;
    bottom: calc(-1 * var(--tail-down));
    width: calc(var(--tail-out) + var(--tail-base));
    height: calc(var(--tail-up) + var(--tail-down));
    background: rgba(24, 31, 64, 0.97);
}
/* flipped-игрок — выноска справа от спрайта, значит хвостик у левого нижнего угла */
.speech-bubble.bubble-left {
    border-bottom-left-radius: 0;
}
.speech-bubble.bubble-left::before { border-bottom-left-radius: 0; }
.speech-bubble.bubble-left::after {
    left: calc(-1 * var(--tail-out));
    /* борт → кончик → низ → сам угол */
    clip-path: polygon(
        calc(var(--tail-out) + var(--tail-ovl)) 0,
        0 100%,
        100% calc(var(--tail-up) - var(--tail-ovl)),
        calc(var(--tail-out) + var(--tail-ovl)) calc(var(--tail-up) - var(--tail-ovl))
    );
}
/* обычный игрок — выноска слева от спрайта, хвостик у правого нижнего угла */
.speech-bubble.bubble-right {
    border-bottom-right-radius: 0;
}
.speech-bubble.bubble-right::before { border-bottom-right-radius: 0; }
.speech-bubble.bubble-right::after {
    right: calc(-1 * var(--tail-out));
    clip-path: polygon(
        calc(100% - var(--tail-out) - var(--tail-ovl)) 0,
        100% 100%,
        0 calc(var(--tail-up) - var(--tail-ovl)),
        calc(100% - var(--tail-out) - var(--tail-ovl)) calc(var(--tail-up) - var(--tail-ovl))
    );
}

/* === Выноска: дневной (светлый) режим === */
body.day-mode .speech-bubble {
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 36%),
        linear-gradient(160deg, rgba(255, 252, 245, 0.98) 0%, rgba(255, 243, 219, 0.98) 100%);
    color: #2b2018;
    box-shadow:
        0 12px 28px rgba(100, 60, 20, 0.24),
        0 0 0 1px rgba(184, 140, 92, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(184, 140, 92, 0.52);
}
body.day-mode .speech-bubble::before {
    border-color: rgba(120, 82, 43, 0.12);
}
body.day-mode .speech-bubble::after {
    background: rgba(255, 245, 227, 0.98);
}
body.day-mode .speech-bubble .bubble-sender { color: #6b4030; }
body.day-mode .speech-bubble .bubble-sender.mafia-sender { color: #cc2200; }
body.day-mode .speech-bubble .bubble-sender.defense-sender { color: #aa7700; }

.speech-bubble .bubble-sender {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.03em;
    color: #d6e7ff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 7px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.speech-bubble .bubble-sender.mafia-sender {
    color: #ffd3d3;
    background: rgba(173, 38, 38, 0.26);
    border-color: rgba(255, 110, 110, 0.2);
}
.speech-bubble .bubble-sender.defense-sender {
    color: #fff0b3;
    background: rgba(172, 128, 16, 0.24);
    border-color: rgba(255, 217, 61, 0.18);
}
body.day-mode .speech-bubble .bubble-sender {
    color: #6b4030;
    background: rgba(146, 96, 44, 0.08);
    border-color: rgba(146, 96, 44, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
body.day-mode .speech-bubble .bubble-sender.mafia-sender {
    color: #a82a14;
    background: rgba(194, 62, 32, 0.12);
    border-color: rgba(194, 62, 32, 0.18);
}
body.day-mode .speech-bubble .bubble-sender.defense-sender {
    color: #8a6400;
    background: rgba(214, 170, 49, 0.14);
    border-color: rgba(214, 170, 49, 0.2);
}

@keyframes bubbleFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Кнопка открытия панели жестов */
#gesture-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 28px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#gesture-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

#gesture-btn.active {
    background: #8a5836;
    border-color: #fff;
}

/* Панель жестов */
#gesture-panel {
    position: fixed;
    bottom: 86px;
    right: 20px;
    width: 320px;
    max-height: 480px;
    max-height: min(480px, 80dvh);
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.97);
    border: 2px solid #8a5836;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    padding: 12px;
    animation: gestureSlideUp 0.2s ease-out;
}

#gesture-panel.hidden {
    display: none;
}

@keyframes gestureSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gesture-panel-title {
    font-weight: bold;
    font-size: 15px;
    color: #3a2b20;
    margin-bottom: 10px;
    text-align: center;
}

.gesture-section {
    margin-bottom: 10px;
}

.gesture-section-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-left: 2px;
}

.gesture-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gesture-item {
    width: 44px;
    height: 44px;
    border: 2px solid #e0d6cc;
    border-radius: 10px;
    background: #faf6f2;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}

.gesture-item:hover {
    border-color: #8a5836;
    background: #f0e6dc;
    transform: scale(1.12);
}

.gesture-item:active {
    transform: scale(0.95);
}

.gesture-item.gesture-number {
    font-size: 16px;
    font-weight: bold;
    color: #3a2b20;
}

/* Номера всегда на виду (12.11.2026, к): блок прилипает к низу прокручиваемой
   панели. Фон — как у самой панели (inherit), иначе под ним просвечивали бы
   эмодзи; в ночном режиме и тёмной теме фон панели свой — inherit его и берёт. */
.gesture-numbers-section {
    position: sticky;
    bottom: -12px;            /* = padding панели: прилипает к самому краю */
    z-index: 1;
    margin: 0 -12px -12px;
    padding: 8px 12px 12px;
    background: inherit;
    border-top: 1px solid rgba(138, 88, 54, 0.25);
    border-radius: 0 0 14px 14px;
}

/* Всплывающий жест над аватаром */
.gesture-bubble {
    position: absolute;
    top: -210px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 48px;
    z-index: 100;
    pointer-events: none;
    animation: gesturePop 0.3s ease-out;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.gesture-bubble.gesture-bubble-number {
    font-size: 32px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #8a5836;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #3a2b20;
}

/* Жест ПРИЗРАКА (п.23 списка 2.0): реакции мёртвых видны всей комнате, как
   реакции зрителей. Место за столом у призрака остаётся, поэтому пузырь висит
   над ним — но выглядеть должен «из-за кромки», иначе его не отличить от
   реакции живого игрока: приглушённый, с холодным свечением вместо тени.
   Ночной вариант цифры прописан явно — иначе его перекрывает
   `body.night-mode .gesture-bubble.gesture-bubble-number` ниже по файлу. */
.gesture-bubble.gesture-bubble-ghost {
    opacity: 0.72;
    filter: drop-shadow(0 0 9px rgba(150, 200, 255, 0.85)) grayscale(0.3);
}

.gesture-bubble.gesture-bubble-ghost.gesture-bubble-number,
body.night-mode .gesture-bubble.gesture-bubble-ghost.gesture-bubble-number {
    background: rgba(226, 238, 255, 0.9);
    border-color: #7a90b8;
    color: #2b3550;
}

.gesture-bubble.fade-out {
    animation: gestureFade 0.4s ease-in forwards;
}

@keyframes gesturePop {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    60% { transform: translateX(-50%) scale(1.2); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes gestureFade {
    0% { opacity: 1; transform: translateX(-50%) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) scale(0.5) translateY(-20px); }
}

/* Жесты бога/зрителей — у них нет места за столом, поэтому вместо пузыря над
   сиденьем показываем эмодзи (того же размера, что и жесты игроков) сбоку справа,
   с именем отправителя под ним. Без окошка/рамки — просто эмодзи и подпись. */
#offtable-gesture-layer {
    position: fixed;
    top: 130px;
    right: 16px;
    z-index: 1400;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    pointer-events: none;
}

.offtable-gesture-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: offtableGesturePop 0.3s ease-out;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.offtable-gesture-item .offtable-gesture-emoji {
    font-size: 48px;
    line-height: 1;
}

/* Числовой жест — голая цифра без собственного цвета; даём подложку-бублик
   (как у жестов-цифр над столом), чтобы читалось на любом фоне. */
.offtable-gesture-item .offtable-gesture-emoji.offtable-gesture-number {
    font-size: 32px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #8a5836;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #3a2b20;
}

body.night-mode .offtable-gesture-item .offtable-gesture-emoji.offtable-gesture-number {
    background: rgba(50, 35, 25, 0.95);
    border-color: #8a5836;
    color: #e8d5c4;
}

.offtable-gesture-item .offtable-gesture-name {
    font-size: 11px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    white-space: nowrap;
}

.offtable-gesture-item.fade-out {
    animation: offtableGestureFade 0.4s ease-in forwards;
}

@keyframes offtableGesturePop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes offtableGestureFade {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.7) translateY(-14px); }
}

/* Кнопка «Жесты» приглушена, когда игрок лично скрыл у себя чужие жесты (ПКМ) */
#gesture-btn.gestures-hidden {
    opacity: 0.45;
    filter: grayscale(0.6);
}

/* Ночной стиль панели жестов */
body.night-mode #gesture-panel {
    background: rgba(50, 35, 25, 0.97);
    border-color: #6d4529;
}

body.night-mode .gesture-panel-title {
    color: #e8d5c4;
}

body.night-mode .gesture-section-label {
    color: #8a7565;
}

body.night-mode .gesture-item {
    border-color: #5a4030;
    background: #3a2b20;
}

body.night-mode .gesture-item:hover {
    border-color: #8a5836;
    background: #4a3828;
}

body.night-mode .gesture-item.gesture-number {
    color: #e8d5c4;
}

body.night-mode .gesture-bubble.gesture-bubble-number {
    background: rgba(50, 35, 25, 0.95);
    border-color: #8a5836;
    color: #e8d5c4;
}

/* ============================================
   ГОЛОСОВОЙ ЧАТ
   ============================================ */

/* Кнопка входа в голосовой чат — левый верхний угол, под чатом */
#voice-btn {
    position: fixed;
    top: 380px;
    left: 20px;
    /* Апрель, п.32: 36px вместо 46. padding: 0 обязателен — общее
       button { padding: 12px 24px } иначе держит ширину не меньше 52px. */
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#voice-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.9);
}

body.day-mode #voice-btn:not(.active) {
    background: rgba(255, 236, 210, 0.9);
    color: #5a4030;
    border-color: rgba(160, 115, 76, 0.7);
}

body.day-mode #voice-btn:not(.active):hover {
    background: rgba(255, 244, 225, 0.97);
}

body.night-mode #voice-btn:not(.active) {
    background: rgba(24, 22, 40, 0.85);
    color: #ebe7ff;
    border-color: rgba(132, 121, 182, 0.7);
}

body.night-mode #voice-btn:not(.active):hover {
    background: rgba(36, 32, 59, 0.93);
}

#voice-btn.active {
    background: #2e7d32;
    border-color: #81c784;
    box-shadow: 0 0 16px rgba(76, 175, 80, 0.4);
}

/* === АВАТАР БОТА (компактный пикер) === */
.bot-avatar-preview {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #666;
    flex-shrink: 0;
    position: relative;
    /* Маска-колобок как у игровых аватаров — иначе превью было простым кругом
       и узор (::after ниже) не совпадал с тем, как бот выглядит в игре. */
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}
/* Слой узора для превью аватара бота (раньше правила не было → узор не показывался) */
.bot-avatar-preview.has-pattern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-mask-image: url('kolobok.png');
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-image: url('kolobok.png');
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    pointer-events: none;
    background-image: var(--pattern-url);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: var(--pattern-opacity);
    filter: contrast(var(--pattern-contrast));
    mix-blend-mode: overlay;
}
.color-grid-compact {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.color-grid-compact .color-option {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.color-grid-compact .color-option:hover { transform: scale(1.15); }
.color-grid-compact .color-option.selected { border-color: #fff; box-shadow: 0 0 0 2px #4a90d9; }
.color-grid-compact .color-option.no-gradient {
    background: repeating-conic-gradient(#555 0% 25%, #333 0% 50%) 50% / 12px 12px;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
}
.pattern-grid-compact {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.pattern-grid-compact .pattern-option-mini {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    background-size: cover;
    background-position: center;
    transition: transform 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #ccc;
    background-color: #444;
}
.pattern-grid-compact .pattern-option-mini:hover { transform: scale(1.1); }
.pattern-grid-compact .pattern-option-mini.selected { border-color: #4a90d9; }

/* === МЫСЛИ БОТОВ (после игры) === */
.bot-thoughts-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1e1e2e;
    border: 1px solid #444;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.bot-thoughts-header {
    padding: 16px 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    color: #e0e0e0;
}
.bot-thoughts-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid #333;
    flex-wrap: wrap;
}
.bot-thoughts-tab {
    padding: 6px 14px;
    background: #2a2a3e;
    border: 1px solid #444;
    border-radius: 8px;
    color: #aaa;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.bot-thoughts-tab:hover { background: #3a3a4e; color: #fff; }
.bot-thoughts-tab.active { background: #4a90d9; border-color: #4a90d9; color: #fff; }
.bot-thoughts-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.thought-entry {
    margin-bottom: 16px;
    padding: 12px;
    background: #252538;
    border-radius: 10px;
    border-left: 3px solid #4a90d9;
}
.thought-entry .thought-phase {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
}
.thought-entry .thought-text {
    font-size: 13px;
    color: #ccc;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* === GOD MODE ИНТЕРВЬЮ === */
.interview-panel {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    max-height: 500px;
    background: #1e1e2e;
    border: 1px solid #555;
    border-radius: 14px;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.interview-header {
    padding: 12px 16px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: bold;
    color: #e0e0e0;
}
.interview-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 150px;
    max-height: 320px;
}
.interview-msg {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 85%;
}
.interview-msg.user { background: #3a3a5e; color: #ddd; margin-left: auto; }
.interview-msg.bot { background: #252538; color: #ccc; margin-right: auto; }
.interview-input-area {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #444;
}
.interview-input-area input {
    flex: 1;
    background: #2a2a3e;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 8px 12px;
    color: #ddd;
    font-size: 13px;
}
.interview-input-area button {
    padding: 8px 14px;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

/* Кнопка микрофона */
#mic-toggle-btn {
    position: fixed;
    top: 380px;
    left: 60px;   /* 🎧: 20 + 36, зазор 4px — как был между прежними кнопками (п.32) */
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #2e7d32;
    color: white;
    font-size: 18px;
    border: 2px solid #81c784;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#mic-toggle-btn:hover {
    transform: scale(1.1);
}

#mic-toggle-btn.muted {
    background: #c62828;
    border-color: #e57373;
    box-shadow: 0 0 16px rgba(198, 40, 40, 0.4);
}

#mic-toggle-btn.no-speak {
    background: #555;
    border-color: #888;
    opacity: 0.7;
}

/* Индикатор голосового чата на аватаре — виден ВСЕМ */
.voice-indicator {
    position: absolute;
    top: -70px;
    left: calc(50% + 55px);
    transform: none !important;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #546e7a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 140; /* Выше стола (120) и подписей (130) */
    pointer-events: none;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: background 0.3s;
}

.voice-indicator::after {
    content: '🎤';
    font-size: 13px;
}

/* В голосе, но молчит */
.voice-indicator.muted {
    background: #546e7a;
}

.voice-indicator.muted::after {
    content: '🎤';
}

/* Активно говорит */
.voice-indicator.speaking {
    background: #4CAF50;
    animation: voicePulse 1.2s infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
}

/* Статус голоса — подпись рядом с кнопкой */
#voice-status {
    position: fixed;
    top: 432px;
    left: 20px;
    z-index: 1000;
    color: white;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 10px;
    border-radius: 12px;
    pointer-events: none;
    text-align: center;
    white-space: nowrap;
}

/* ========== GOD MODE CONTROLS ========== */

.god-next-phase-btn {
    margin: 10px 12px 12px;
    padding: 12px;
    background: linear-gradient(135deg, #7b1fa2, #9c27b0);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.god-next-phase-btn:hover {
    background: linear-gradient(135deg, #9c27b0, #ba68c8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.5);
}

.god-next-phase-btn:active {
    transform: translateY(0);
}

/* Мини-панель управления бога (вместо полной боковой панели) */
#god-controls-bar {
    position: fixed;
    top: 70px;
    right: 70px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(20, 10, 30, 0.95);
    border: 2px solid #9c27b0;
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: 0 0 10px rgba(156, 39, 176, 0.3), 0 4px 12px rgba(0,0,0,0.4);
}

#god-controls-bar .god-next-phase-btn {
    margin: 0;
    padding: 5px 10px;
    font-size: 12px;
}

/* Запросы «хочу обратиться к моделям» в афтепати (16.10.2026) */
#afterparty-permit-requests {
    position: fixed;
    left: 50%;
    top: 70px;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(460px, calc(100vw - 32px));
}
.afterparty-permit-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(20, 10, 30, 0.95);
    border: 2px solid #9c27b0;
    border-radius: 8px;
    padding: 6px 10px;
    color: #eee;
    font-size: 13px;
}
.afterparty-permit-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.afterparty-permit-item button { flex-shrink: 0; padding: 4px 8px; font-size: 12px; margin: 0; }

/* Расклад ведущего «📋 Роли» (16.10.2026) — под пультом, в его стиле */
#god-roles-panel {
    position: fixed;
    top: 118px;
    right: 70px;
    z-index: 9999;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 32px));
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(20, 10, 30, 0.95);
    border: 2px solid #9c27b0;
    border-radius: 8px;
    padding: 8px 10px;
    color: #eee;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
#god-roles-panel .god-roles-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#god-roles-panel .god-roles-close { background: none; border: none; color: #bbb; cursor: pointer; font-size: 14px; }
#god-roles-panel .god-roles-row { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; }
#god-roles-panel .god-roles-row.dead { opacity: 0.5; }
#god-roles-panel .god-roles-num { color: #999; min-width: 22px; text-align: right; }
#god-roles-panel .god-roles-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#god-roles-panel .god-roles-role { font-weight: 600; white-space: nowrap; }
#god-roles-panel .god-roles-empty { color: #999; padding: 6px 0; }

#god-controls-bar .god-next-phase-btn.god-waiting {
    animation: god-pulse 1s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.7);
    border-color: #ffc107;
}

@keyframes god-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#god-controls-bar .god-auto-btn {
    margin: 0;
    padding: 5px 10px;
    font-size: 11px;
    background: rgba(100, 100, 100, 0.5);
    color: #aaa;
    border: 1px solid #666;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

#god-controls-bar .god-auto-btn:hover {
    background: rgba(156, 39, 176, 0.3);
    color: #ce93d8;
    border-color: #9c27b0;
}

#god-controls-bar .god-auto-btn.active {
    background: rgba(76, 175, 80, 0.3);
    color: #81c784;
    border-color: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

/* На мобиле god-бар (top/right) перекрывал открытый чат-оверлей (он стартует с
   top:76px и занимает почти всю ширину). Переносим бар вниз по центру — вне
   зоны чата — и делаем компактнее. */
@media (max-width: 1100px) {
    #god-controls-bar {
        top: auto;
        right: auto;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        padding: 5px 10px;
        gap: 4px;
        max-width: 92vw;
        flex-wrap: wrap;
        justify-content: center;
    }
    #god-controls-bar .god-next-phase-btn,
    #god-controls-bar .god-auto-btn {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* Табличка роли для режима бога */
.player-tag.god-role {
    background: linear-gradient(135deg, #6a1b9a, #9c27b0);
    color: white;
    border: 2px solid #ce93d8;
}

.player-tag.god-role::before {
    content: none;
}

.player-tag.god-role.role-mafia {
    background: linear-gradient(135deg, #ce93d8, #ba68c8);
    border: 2px solid #e1bee7;
}

.player-tag.god-role.role-peaceful {
    background: linear-gradient(135deg, #ef9a9a, #e57373);
    border: 2px solid #ffcdd2;
}

.player-tag.god-role.role-neutral {
    background: linear-gradient(135deg, #9e9e9e, #8d8d8d);
    border: 2px solid #d0d0d0;
}

/* ===== ЕДИНЫЕ ЦВЕТА ТАБЛИЧЕК РОЛЕЙ (решение Светы 23.10.2026) =====
   Цвет — по СТОРОНЕ, одинаковый у всех типов табличек роли: своя (my-role),
   у бога и зрячего зрителя (god-role), союзник мафии (mafia-teammate), роль,
   раскрытая при смерти или в конце игры (final-role).
     мирные, шериф, доктор — светло-красные днём, красные ночью;
     мафия, дон            — серые днём, чёрные ночью;
     маньяк                — светло-жёлтые днём, жёлтые ночью.
   Стоит ПОСЛЕ всех старых правил ролей и перекрывает их: раньше у каждого типа
   был свой набор, и шериф выходил то фиолетовым, то серым. */
body .player-tag.role-peaceful:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #ef9a9a, #e57373);
    border: 2px solid #ffcdd2;
    color: #fff;
}
body.night-mode .player-tag.role-peaceful:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #b71c1c, #c62828);
    border-color: #ef5350;
}
body .player-tag.role-mafia:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #9e9e9e, #757575);
    border: 2px solid #d0d0d0;
    color: #fff;
}
body.night-mode .player-tag.role-mafia:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #1c1c1c, #333333);
    border-color: #616161;
}
/* Светло-жёлтый днём — с ТЁМНОЙ рамкой: совсем бледный (#fff59d со светлой
   рамкой) на светлых фонах вроде «Пчёл» читался как прозрачный. */
body .player-tag.role-maniac:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #ffe57f, #ffd740);
    border: 2px solid #c79100;
    color: #3a2704;
}
body.night-mode .player-tag.role-maniac:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #fbc02d, #f9a825);
    border-color: #fff3c4;
    color: #3a2704;
}
/* Шериф и доктор (27.10.2026) — мирные, но выделены своим цветом:
   шериф синий, доктор зелёный. Днём светлее, ночью насыщеннее. */
body .player-tag.role-sheriff:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #64b5f6, #1e88e5);
    border: 2px solid #bbdefb;
    color: #fff;
}
body.night-mode .player-tag.role-sheriff:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #0d47a1, #1565c0);
    border-color: #42a5f5;
}
body .player-tag.role-doctor:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #81c784, #43a047);
    border: 2px solid #c8e6c9;
    color: #fff;
}
body.night-mode .player-tag.role-doctor:is(.my-role, .god-role, .final-role, .mafia-teammate) {
    background: linear-gradient(135deg, #1b5e20, #2e7d32);
    border-color: #66bb6a;
}

.god-mode-group {
    border: 1px solid rgba(156, 39, 176, 0.4) !important;
    background: rgba(156, 39, 176, 0.08) !important;
}

/* God Context Modal */
.god-context-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.god-context-modal-content {
    background: #1e1e2e;
    border: 1px solid rgba(156, 39, 176, 0.5);
    border-radius: 12px;
    /* п.4 списка 30.09: промпт и ситуация — длинные тексты, в 700px их тяжело
       читать. Окно шире и по высоте постоянное, прокрутка одна — у тела окна. */
    width: 94%;
    max-width: 1100px;
    height: 85vh;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(156, 39, 176, 0.3);
}

.god-context-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(156, 39, 176, 0.3);
    font-size: 16px;
    font-weight: bold;
    color: #ce93d8;
}

.god-context-close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}

.god-context-close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.god-context-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 0 12px;
}

.god-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.god-tab:hover {
    color: #ccc;
}

.god-tab.active {
    color: #ce93d8;
    border-bottom-color: #9c27b0;
}

.god-context-body {
    padding: 14px 18px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;             /* иначе flex-ребёнок растёт под текст и прокрутка не включается */
    font-size: 13px;
    color: #ccc;
    line-height: 1.5;
}

.god-context-body pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.45;
}

/* «✍️ Вживую» — ответ бота по мере прихода (08.10.2026). */
.god-tab.god-tab-live-active::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 5px;
    border-radius: 50%;
    background: #66bb6a;
    vertical-align: middle;
    animation: god-live-pulse 1s ease-in-out infinite;
}
.god-live-empty { text-align: center; color: #888; padding: 30px 10px; }
.thinking-label .thinking-model { color: #9aa0a6; font-size: 11px; font-family: monospace; }
.god-live-status { margin-bottom: 10px; color: #bbb; font-size: 12px; }
.god-live-action { background: #444; padding: 1px 6px; border-radius: 3px; font-size: 11px; margin-left: 4px; }
.god-live-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: #66bb6a; animation: god-live-pulse 1s ease-in-out infinite;
}
.god-live-block {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.2);
    border-left: 3px solid #9c27b0;
    border-radius: 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.god-live-reasoning { border-left-color: #607d8b; color: #b0bec5; font-style: italic; }
.god-live-raw { font-family: monospace; font-size: 12px; }
.god-live-cursor { display: inline-block; color: #ce93d8; animation: god-live-pulse 0.8s steps(2) infinite; }
@keyframes god-live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

.god-thinking-entry {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border-left: 3px solid #9c27b0;
}

.god-thinking-entry .thinking-label {
    font-size: 11px;
    color: #ce93d8;
    font-weight: bold;
    margin-bottom: 4px;
}

.god-thinking-entry .thinking-text {
    color: #b0bec5;
    font-size: 12px;
}

.god-memory-entry {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.god-memory-sender {
    font-weight: bold;
    color: #ce93d8;
    font-size: 12px;
}

.god-memory-content {
    color: #b0bec5;
    font-size: 12px;
    margin-top: 2px;
}

.god-memory-type {
    font-size: 10px;
    color: #666;
    margin-left: 8px;
}

/* ==================== КНОПКА ВЫХОДА ИЗ ИГРЫ ==================== */
#leave-game-btn {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(80, 20, 20, 0.85);
    border: 2px solid #c0392b;
    color: white;
    font-size: 22px;
    cursor: pointer;
    z-index: 1001;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(192, 57, 43, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

#leave-game-btn:hover {
    background: rgba(120, 30, 30, 0.95);
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(192, 57, 43, 0.6);
}

#leave-game-btn:active {
    transform: scale(0.95);
}

/* ==================== ДИАЛОГ ПОДТВЕРЖДЕНИЯ ВЫХОДА ==================== */
#leave-game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.leave-dialog {
    background: #2a1a0a;
    border: 2px solid #8a5836;
    border-radius: 16px;
    padding: 30px 36px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.leave-dialog h3 {
    color: #e74c3c;
    margin: 0 0 12px;
    font-size: 20px;
}

.leave-dialog p {
    color: #bbb;
    margin: 0 0 24px;
    font-size: 14px;
    line-height: 1.5;
}

.leave-dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.leave-btn-confirm {
    padding: 10px 28px;
    background: #c0392b;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.leave-btn-confirm:hover {
    background: #e74c3c;
}

.leave-btn-cancel {
    padding: 10px 28px;
    background: #555;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.leave-btn-cancel:hover {
    background: #777;
}

/* ============================================
   ЗАБЛОКИРОВАННЫЕ СЕТТИНГИ
   ============================================ */
.setting-card.setting-locked {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
    filter: grayscale(0.6);
}

.setting-card.setting-locked:hover {
    border-color: #999;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.setting-locked-badge {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: #c0392b;
    font-weight: 700;
    white-space: nowrap;
    background: rgba(255,255,255,0.9);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ============================================
   ПОДСКАЗКИ (HELP TOOLTIPS)
   ============================================ */
.help-tooltip {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 11px;
    border-radius: 50%;
    background: #c62828;
    color: white;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 4px;
    user-select: none;
    transition: background 0.2s;
}

.help-tooltip:hover {
    background: #357abd;
}

/* Скрытый исходник для подсказки (содержимое копируется в popup) */
.help-tip-box {
    display: none !important;
}

/* Плавающий popup подсказки */
#help-popup-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s;
}

.help-popup-box {
    background: #1e1e2e;
    color: #e8e8f0;
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 380px;
    width: 90%;
    position: relative;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.help-popup-box a {
    color: #ffcc00;
    font-weight: 600;
}

.help-popup-box b {
    color: #fff;
}

.help-popup-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
    padding: 0;
    line-height: 1;
}

.help-popup-close:hover {
    color: #fff;
}

/* ============================================
   МОБИЛЬНАЯ ЗАГЛУШКА
   ============================================ */
#mobile-landing {
    /* Заглушка "Игра только под ПК" отключена — телефонам разрешён вход
       (в портретной ориентации показывается rotate-overlay).
       Элемент остаётся в DOM на случай если понадобится снова. */
    display: none !important;
}

.mobile-landing-bg {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #1c1510 0%, #2e2118 40%, #503a28 100%);
    z-index: -1;
}

.mobile-landing-stars span {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #f7ebe6;
    border-radius: 50%;
    animation: mobileStar 3s ease-in-out infinite;
}
.mobile-landing-stars span:nth-child(1) { top: 8%; left: 15%; animation-delay: 0s; }
.mobile-landing-stars span:nth-child(2) { top: 5%; left: 55%; animation-delay: 1.2s; }
.mobile-landing-stars span:nth-child(3) { top: 12%; left: 80%; animation-delay: 0.6s; }
.mobile-landing-stars span:nth-child(4) { top: 3%; left: 35%; animation-delay: 2s; }
.mobile-landing-stars span:nth-child(5) { top: 15%; left: 92%; animation-delay: 1.5s; }

@keyframes mobileStar {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

.mobile-landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px 30px;
    min-height: 100vh;
    color: #f0e4d4;
}

.mobile-landing-logo {
    width: 70%;
    max-width: 280px;
    height: auto;
    margin-bottom: 32px;
    filter: drop-shadow(0 4px 20px rgba(0,0,0,0.5));
}

/* Блок предупреждения */
.mobile-landing-warning {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 340px;
    gap: 12px;
    flex: 1;
}

.mobile-warning-icon {
    font-size: 52px;
    line-height: 1;
}

.mobile-warning-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #f5d89a;
    line-height: 1.3;
}

.mobile-warning-text {
    margin: 0;
    font-size: 15px;
    color: #c0a88a;
    line-height: 1.6;
}

.mobile-warning-action {
    color: #f0e4d4;
    font-weight: 600;
}

.mobile-warning-url {
    margin-top: 4px;
    padding: 10px 20px;
    background: rgba(245, 216, 154, 0.1);
    border: 1px solid rgba(245, 216, 154, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-family: monospace;
    color: #f5d89a;
    word-break: break-all;
}

/* Футер */
.mobile-landing-footer {
    text-align: center;
    margin-top: auto;
    padding-top: 24px;
}

/* Блок «Почему нет адаптации» */
.mobile-why-block {
    width: 100%;
    max-width: 340px;
    margin-top: 20px;
    border: 1px solid rgba(245, 216, 154, 0.25);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    overflow: hidden;
}

.mobile-why-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #f5d89a;
    -webkit-tap-highlight-color: transparent;
}

.mobile-why-arrow {
    font-size: 12px;
    transition: transform 0.3s;
    color: #c0a88a;
}

.mobile-why-block.open .mobile-why-arrow {
    transform: rotate(180deg);
}

.mobile-why-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    padding: 0 16px;
}

.mobile-why-block.open .mobile-why-body {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0 16px 16px;
}

.mobile-why-body p {
    margin: 0 0 10px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #c0a88a;
}

.mobile-why-body b {
    color: #e0cdb8;
}

.mobile-landing-footer p {
    margin: 0;
    font-size: 11px;
    color: #6b5a4a;
}

/* ============================================
   BETA BANNER (перенесён в feedback-corner)
   ============================================ */
#beta-banner {
    position: relative;
    bottom: auto;
    left: auto;
    z-index: 90;
    max-width: 280px;
    padding: 7px 14px;
    font-size: 11px;
    color: #7a5c00;
    background: rgba(255, 248, 225, 0.93);
    border: 1px solid #f0d88a;
    border-radius: 10px;
    line-height: 1.45;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 6px;
}

/* ============================================
   ПОДРОБНАЯ СТАТИСТИКА В БОКОВОЙ КАРТОЧКЕ
   ============================================ */
.profile-stats-detailed {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(138, 88, 54, 0.2);
}

.profile-stat-row-mini {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
    color: #8a7565;
}

.profile-stat-row-mini span:last-child {
    font-weight: 700;
    color: #5a3a1a;
}

.profile-stats-open-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #8a5836 0%, #6b3f25 100%);
    color: #fff8ec;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(74, 48, 24, 0.25);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.profile-stats-open-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(74, 48, 24, 0.32);
}

.profile-stats-open-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(74, 48, 24, 0.25);
}

/* ============================================
   ЗАПИСИ ПАРТИЙ (v2.0, п.14)
   ============================================ */
/* Список своих партий: строка-кнопка «когда, где» + «чем кончилось, кем играл».
   Оформление намеренно повторяет карточки профиля — это соседнее окно. */
.recordings-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 40vh;
    overflow-y: auto;
}

/* Окно записей шире и выше остальных профильных модалок (18.09.2026): в 480px
   при 40vh влезало 2,5 записи и всё остальное — скроллбар. Список — до 62vh,
   само окно — до 760px; на телефоне ширина всё равно упрётся в 92vw. */
#recordings-modal .profile-modal-content {
    max-width: 760px !important;
}
#recordings-modal .profile-modal-body {
    max-height: calc(92vh - 70px);
    max-height: calc(92dvh - 70px);
}
#recordings-modal .recordings-list {
    max-height: 62vh;
    max-height: 62dvh;
}
#recordings-modal .recordings-protocol {
    max-height: 60vh;
}

.recordings-empty {
    margin: 0;
    padding: 12px 4px;
    font-size: 13px;
    color: #8a7565;
    text-align: center;
}

.recordings-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #f0e0d0;
    border-radius: 10px;
    background: #fffaf3;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.12s ease;
}

.recordings-row:hover {
    background: #f5e6d3;
    transform: translateY(-1px);
}

.recordings-row-title {
    font-size: 13px;
    font-weight: 700;
    color: #5c3d2e;
}

.recordings-row-meta {
    font-size: 12px;
    color: #8a7565;
}

/* Срок хранения звука. Подсказка вверху списка и пометка у каждой записи:
   текст партии остаётся навсегда, а клипы озвучки уберут (v2.0, п.14). */
.recordings-retention-hint {
    margin: 0 0 4px;
    padding: 8px 10px;
    border: 1px dashed #d8c0a4;
    border-radius: 8px;
    background: rgba(245, 230, 211, 0.5);
    font-size: 12px;
    line-height: 1.4;
    color: #7a6352;
}

.recordings-row-audio {
    font-size: 11px;
    color: #9a8574;
}

/* Комментарии под публичной записью (24.11.2026, п.12): блок «Сообщества». */
.recordings-comments {
    margin: -2px 0 8px;
    padding: 8px 10px;
    border: 1px solid rgba(138, 88, 54, 0.18);
    border-top: none;
    border-radius: 0 0 10px 10px;
    background: rgba(255, 250, 244, 0.7);
}
html.dark-theme .recordings-comments { background: rgba(255, 255, 255, 0.03); border-color: var(--dk-border); }

/* Исход публичной записи спрятан (список 24.11.2026, п.10): «скрыто» — клик
   показывает победителя. */
.recordings-spoiler {
    display: inline-block;
    padding: 0 6px;
    border-radius: 4px;
    background: #8a7565;
    color: #f5e6d3;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.recordings-spoiler:hover { background: #6d5a4b; }
.recordings-spoiler.revealed {
    padding: 0;
    background: none;
    color: inherit;
    cursor: inherit;
    user-select: auto;
}
html.dark-theme .recordings-spoiler:not(.revealed) { background: #5b4b40; color: #e9dccd; }

/* Состав стола в карточке записи (19.09.2026). */
.recordings-row-players {
    font-size: 12px;
    color: #7a6553;
    word-break: break-word;
}

.recordings-row-audio.expiring {
    color: #b0521f;
    font-weight: 700;
}

.recordings-watch-btn {
    align-self: flex-start;
    margin-top: 4px;
    padding: 4px 10px;
    border: 1px solid #d8c0a4;
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: #5c3d2e;
    cursor: pointer;
}

.recordings-watch-btn:hover {
    background: #f5e6d3;
}

.recordings-watch-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Удаление — необратимое действие, поэтому красное и визуально отдельно от
   «смотреть/скачать» (п.20). */
.recordings-delete-btn {
    border-color: #e0b4b4;
    color: #a03a2e;
}

.recordings-delete-btn:hover {
    background: #fbe9e7;
}

/* Кнопки строки в ряд: «смотреть» и «скачать» — действия одного веса. */
.recordings-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Открыть скачанный файл — под списком: это вход мимо сервера, и путать его
   со своими записями не надо. */
.recordings-open-file {
    margin-top: 8px;
    text-align: center;
}

.recordings-open-file .btn-secondary {
    font-size: 12px;
    padding: 5px 12px;
}

/* Панель плеера записи. Фиксирована снизу и поверх стола: реплей смотрят
   на весь экран, в том числе чтобы снять видео записью экрана. */
.replay-bar {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 94vw;
    padding: 8px 12px;
    border: 1px solid rgba(216, 192, 164, 0.5);
    border-radius: 12px;
    background: rgba(28, 20, 14, 0.88);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    flex-wrap: wrap;
}

.replay-btn {
    padding: 5px 10px;
    border: 1px solid rgba(216, 192, 164, 0.35);
    border-radius: 8px;
    background: rgba(255, 248, 236, 0.1);
    color: #f5e6d3;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.replay-btn:hover {
    background: rgba(255, 248, 236, 0.22);
}

.replay-scrub {
    width: min(320px, 40vw);
    accent-color: #c8a06a;
    cursor: pointer;
}

.replay-time {
    font-size: 12px;
    color: #e3c6b2;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.replay-select {
    padding: 4px 6px;
    border: 1px solid rgba(216, 192, 164, 0.35);
    border-radius: 8px;
    background: rgba(255, 248, 236, 0.1);
    color: #f5e6d3;
    font-size: 12px;
    cursor: pointer;
}

.replay-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #e3c6b2;
    cursor: pointer;
    white-space: nowrap;
}

/* Микшер записи (15.09.2026): панель с двумя ползунками над полосой плеера.
   Лежит внутри .replay-bar (она fixed — значит absolute считается от неё),
   поэтому сворачивается и исчезает вместе с полосой. */
.replay-mixer {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    min-width: 260px;
    padding: 10px 14px;
    border: 1px solid rgba(216, 192, 164, 0.5);
    border-radius: 12px;
    background: rgba(28, 20, 14, 0.94);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
}

.replay-mixer.hidden { display: none; }

.replay-mixer-title {
    font-size: 12px;
    font-weight: 700;
    color: #f5e6d3;
    margin-bottom: 8px;
}

.replay-mixer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #e3c6b2;
    cursor: pointer;
}

.replay-mixer-row:last-child { margin-bottom: 0; }

.replay-mixer-label {
    min-width: 84px;
    white-space: nowrap;
}

.replay-mixer-slider {
    flex: 1;
    min-width: 110px;
    accent-color: #c8a06a;
    cursor: pointer;
}

.replay-mixer-value {
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Убранство главного меню на время реплея. Прячем классом на body, а не
   перебором id из JS: боковых карточек полтора десятка, лежат они в .menu-layout,
   у которой id нет вовсе, — и возвращать их по одной значило бы рано или поздно
   что-нибудь потерять. Снять класс при выходе достаточно, чтобы всё вернулось. */
body.replay-active #site-title-wrapper,
body.replay-active #site-slogan,
body.replay-active #site-announcements,
body.replay-active .menu-layout,
body.replay-active #menu-audio-controls,
body.replay-active #menu-bg-art,
body.replay-active #online-counter,
body.replay-active #easter-egg-corner,
body.replay-active #easter-egg-corner-den,
body.replay-active #feedback-corner {
    display: none !important;
}
/* Список зрителей в записи ПОКАЗЫВАЕМ (п.6.4, 10.09.2026): раньше его прятали,
   потому что состав в записи не хранился и в панель попадали случайные люди из
   прошлой живой партии. Теперь состав едет событием `spectators`. */

/* Свёрнутая панель: остаётся один язычок, чтобы её можно было вернуть.
   Полупрозрачна, пока на неё не навели, — реплей снимают записью экрана, и
   на готовом ролике панель поперёк стола не нужна. */
.replay-bar.collapsed {
    gap: 0;
    padding: 4px 6px;
    opacity: 0.35;
}

.replay-bar.collapsed:hover {
    opacity: 1;
}

.replay-bar.collapsed > *:not(#replay-collapse) {
    display: none;
}

.recordings-protocol-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.recordings-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #5c3d2e;
    cursor: pointer;
}

/* Полка «Избранное» (12.09.2026): фильтр над списком и золотая кайма у
   помеченных строк — звёздочка в подписи есть, но кайма ловится взглядом
   при прокрутке. */
.recordings-favorites-filter {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

/* Фильтры записей (2.4) — одной строкой над списком, на узком экране переносятся. */
.recordings-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin: 0 0 10px;
}
.recordings-filter-bar input[type="search"],
.recordings-filter-bar select {
    font-size: 13px;
    padding: 4px 6px;
    border: 1px solid #c9b29a;
    border-radius: 6px;
    background: #fffaf3;
    color: #3a2b20;
    min-width: 0;
    max-width: 100%;
}
.recordings-filter-bar input[type="search"] { width: 130px; }
/* Пока грузится новая выборка, прежний список виден, но бледнее (17.10.2026). */
#recordings-list.recordings-list--loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.15s;
}
html.dark-theme .recordings-filter-bar input[type="search"],
html.dark-theme .recordings-filter-bar select {
    background: var(--dk-surface);
    color: var(--dk-text);
    border-color: var(--dk-border);
}

.recordings-row.recordings-row-favorite {
    border-color: #e0b64a;
    background: #fff7e0;
}

/* Протокол — моноширинный текст с сохранением переносов: он выравнен пробелами
   (состав по местам, отбивки фаз), и пропорциональный шрифт эту разметку сломал бы.
   pre-wrap, а не pre: длинная реплика должна переноситься, а не уезжать вбок. */
.recordings-protocol {
    margin: 0;
    padding: 10px 12px;
    max-height: 45vh;
    overflow-y: auto;
    border: 1px solid #f0e0d0;
    border-radius: 10px;
    background: #fffaf3;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #4a3018;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ============================================
   ТАБЛИЦА ЛИДЕРОВ
   ============================================ */
/* Вкладки лидерборда (Люди / Модели) — v1.6 */
.leaderboard-tabs {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    margin-bottom: 8px;
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(255, 255, 255, 0.95);
}
.leaderboard-tab-btn {
    flex: 1;
    padding: 5px 8px;
    line-height: 1.5;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(138, 88, 54, 0.08);
    color: #6b4a30;
    transition: background 0.15s ease, color 0.15s ease;
}
.leaderboard-tab-btn:hover {
    background: rgba(138, 88, 54, 0.18);
}
.leaderboard-tab-btn.active {
    background: #8a5836;
    color: #fff;
}

/* Переключатель «За всё время / Сезон» (v2.1). Стоит под вкладками и общий на
   все три: сезон — это взгляд на те же цифры за сезон, а не отдельный раздел. */
.leaderboard-season {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
}
.leaderboard-season-btn {
    flex: 1;
    padding: 3px 6px;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(138, 88, 54, 0.06);
    color: #6b4a30;
    transition: background 0.15s ease, color 0.15s ease;
}
.leaderboard-season-btn:hover {
    background: rgba(138, 88, 54, 0.14);
}
.leaderboard-season-btn.active {
    background: rgba(138, 88, 54, 0.45);
    color: #fff;
}
.leaderboard-season-select {
    flex: 1;
    min-width: 0;
    padding: 3px 4px;
    border: 1px solid rgba(138, 88, 54, 0.3);
    border-radius: 5px;
    font-size: 11px;
    color: #3a2b20;
    background: #fff;
}
.leaderboard-season-note {
    margin-bottom: 6px;
    font-size: 10px;
    line-height: 1.4;
    color: #8a6a50;
}
/* Тройка призёров над цифрами вкладки «Сервер». */
.gs-season {
    margin-bottom: 8px;
}
/* Строка «в этом сезоне» в профиле игрока. */
.profile-season-row {
    margin-top: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #6b4a30;
    background: rgba(138, 88, 54, 0.07);
}

/* «Что боты о вас запомнили» — своё досье в своём профиле (п.4, 07.09.2026).
   Отделено от строки сезона рамкой: это не цифра, а текст про человека, и
   читается он иначе. Высоту ограничиваем — заметка до 700 знаков, а профиль
   не должен из-за неё вытягиваться на два экрана. */
.profile-dossier-row {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(138, 88, 54, 0.28);
    border-radius: 8px;
    background: rgba(138, 88, 54, 0.05);
}
.profile-dossier-title {
    font-size: 12px;
    font-weight: bold;
    color: #3a2b20;
    margin-bottom: 4px;
}
.profile-dossier-text {
    font-size: 12px;
    line-height: 1.45;
    color: #6b4a30;
    max-height: 160px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.profile-dossier-text.empty {
    font-style: italic;
    color: #8a5836;
}
.profile-dossier-note {
    margin-top: 6px;
    font-size: 11px;
    color: #8a5836;
}

/* Список версий модели в профиле — v1.6 */
.mp-versions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mp-version-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
    background: rgba(138, 88, 54, 0.06);
}
.mp-version-id {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #3a2b20;
}
.mp-version-stat {
    font-size: 11px;
    color: #8a5836;
    font-weight: 600;
    min-width: 46px;
    text-align: right;
}

/* Поля админ-редактора вида модели — v1.6 */
.mae-field {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.mae-field > label {
    flex: 0 0 110px;
    margin: 0;
}
.mae-field > input,
.mae-field > select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid rgba(138, 88, 54, 0.4);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #3a2b20;
}

/* Строки предложения «добавить игру в память» — v1.6 (фича 3) */
.bot-memory-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(138, 88, 54, 0.15);
}
.bot-memory-name {
    color: #3a2b20;
    font-size: 14px;
    font-weight: 600;
}
.bot-memory-save-btn {
    padding: 5px 14px;
    font-size: 13px;
}

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

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
    background: rgba(138, 88, 54, 0.05);
}

.leaderboard-row.leaderboard-clickable {
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.leaderboard-row.leaderboard-clickable:hover {
    background: rgba(138, 88, 54, 0.18);
    transform: translateX(2px);
}

.leaderboard-row.leaderboard-me {
    background: rgba(138, 88, 54, 0.15);
    font-weight: 700;
}

.leaderboard-pos {
    min-width: 22px;
    text-align: center;
    font-weight: 700;
}

.leaderboard-name {
    flex: 1;
    /* min-width: 0 — иначе flex не даёт ячейке ужаться, и широкий ник выталкивает
       XP и винрейт вбок. Высота зажата: клинопись (𒈙 𒐫) выше строки в разы и
       налезала на соседние строки (список 16.10.2026, п.17–18). */
    min-width: 0;
    line-height: 1.4;
    max-height: 1.4em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #3a2b20;
}

.leaderboard-xp {
    font-size: 11px;
    color: #8a5836;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.leaderboard-wr {
    font-size: 11px;
    color: #666;
    min-width: 30px;
    text-align: right;
}

/* ============================================
   УВЕДОМЛЕНИЕ О ДОСТИЖЕНИИ
   ============================================ */
#achievement-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    animation: achFadeIn 0.5s ease-out;
    pointer-events: none;
}

#achievement-notification.achievement-fade-out {
    animation: achFadeOut 0.5s ease-out forwards;
}

.achievement-content {
    text-align: center;
    z-index: 2;
}

.achievement-icon {
    font-size: 80px;
    animation: achBounce 0.6s ease-out;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
}

.achievement-title {
    font-size: 28px;
    color: #ffd700;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 12px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 2px 4px rgba(0,0,0,0.5);
    animation: achSlideUp 0.6s ease-out 0.2s both;
}

.achievement-name {
    font-size: 42px;
    font-weight: 900;
    margin-top: 8px;
    text-shadow: 0 0 30px currentColor, 0 2px 4px rgba(0,0,0,0.5);
    animation: achSlideUp 0.6s ease-out 0.4s both;
}

.achievement-subtitle {
    font-size: 16px;
    color: #ccc;
    margin-top: 8px;
    animation: achSlideUp 0.6s ease-out 0.6s both;
}

.achievement-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 70%);
    animation: achPulse 1.5s ease-in-out infinite;
}

.achievement-particles {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
}

.achievement-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color, #ffd700);
    animation: achParticle 1.5s ease-out var(--delay, 0s) both;
}

@keyframes achFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes achFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes achBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes achSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes achPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.2; }
}

@keyframes achParticle {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--x), var(--y)) scale(0); opacity: 0; }
}
.auth-panel {
    display: grid;
    gap: 8px;
    width: 100%;
    margin: 10px 0;
}

.auth-panel input {
    width: 100%;
    box-sizing: border-box;
}

.auth-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.auth-actions button {
    min-height: 34px;
    border-radius: 8px;
}

.auth-status {
    font-size: 12px;
    line-height: 1.35;
    color: #7a5a47;
    text-align: center;
    max-width: 340px;
    order: 8;
}

.special-name-hint {
    min-height: 20px;
    width: 100%;
    max-width: 340px;
    font-size: 12px;
    line-height: 16px;
    color: #b88312;
    text-align: center;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.special-name-hint.visible {
    visibility: visible;
}

.special-name-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.special-name-actions button {
    border: 1px solid rgba(184, 131, 18, 0.35);
    border-radius: 999px;
    background: rgba(255, 248, 226, 0.85);
    color: #8a5d0f;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
}

.special-name-actions button.active {
    background: #b88312;
    color: #fff8e2;
}

.name-panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: min(100%, 340px);
    order: 7;
}

.name-panel-actions button,
#openAuthModalBtn {
    min-height: 44px;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.auth-modal-content {
    max-width: 420px;
}

.auth-modal-body {
    display: grid;
    gap: 12px;
    padding: 20px 24px;
}

.auth-modal-body input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 2px solid #8a5836;
    border-radius: 8px;
    font-size: 16px;
}

.auth-modal-note {
    margin: 0 0 4px;
    color: #5d4638;
    line-height: 1.4;
}

/* «Забыли пароль?» (2.5) */
.forgot-password-row { text-align: right; font-size: 12px; margin-top: -2px; }
.forgot-password-row a,
.forgot-password-info a { color: #b06020; font-weight: 700; text-decoration: none; }
.forgot-password-row a:hover,
.forgot-password-info a:hover { text-decoration: underline; }
.forgot-password-info {
    font-size: 12px;
    line-height: 1.4;
    color: #5d4638;
    background: rgba(200, 160, 112, 0.15);
    border-radius: 10px;
    padding: 6px 10px;
}
html.dark-theme .forgot-password-info { color: var(--dk-text); }
.auth-create-offer { font-size: 14px; padding: 10px 12px; }
.auth-create-offer button { display: block; width: 100%; margin-top: 8px; }

.auth-modal-actions {
    gap: 8px;
    flex-wrap: wrap;
}


/* ========== MOBILE: PORTRAIT-MODE OVERLAY ========== */
#rotate-device-overlay {
    display: none;
}

/* Показываем оверлей только когда УЗКИЙ экран в портрете — т.е. телефон.
   Планшеты в портрете (768-1024px) и десктопы не получают эту заглушку,
   потому что у них достаточно места чтобы играть как есть. */
@media (orientation: portrait) and (max-width: 600px) {
    #rotate-device-overlay {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 999999;
        background: linear-gradient(135deg, #2b1d12 0%, #4a3322 100%);
        align-items: center;
        justify-content: center;
        padding: 24px;
        text-align: center;
        color: #e3c6b2;
    }
    /* При показанном оверлее прячем всё остальное содержимое body */
    body > *:not(#rotate-device-overlay) {
        display: none !important;
    }

    /* Набор текста на телефоне идёт через самописную клавиатуру (keyboard.js),
       которая не перекрывает экран как родная. Поэтому прежний костыль с
       раскрытием портрета во время набора и подсказка «поверните для набора»
       больше не нужны и удалены. */
}

.rotate-device-overlay__inner {
    max-width: 320px;
}
.rotate-device-overlay__icon {
    font-size: 80px;
    margin-bottom: 16px;
    animation: rotateDeviceHint 2s ease-in-out infinite;
}
@keyframes rotateDeviceHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}
.rotate-device-overlay__title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}
.rotate-device-overlay__hint {
    font-size: 14px;
    opacity: 0.85;
    line-height: 1.4;
}

/* ============================================
   ОБЪЯВЛЕНИЯ АДМИНИСТРАЦИИ И ОПРОСЫ СООБЩЕСТВА
   (см. siteNotices.js)
   ============================================ */

/* --- Полоса объявлений сверху ---
   Ниже тостов (9999) и модалок (10000), но выше игрового слоя (100). */
:root { --announce-h: 0px; }

/* --- СИЛА УЗОРА АВАТАРА (обе ручки здесь, в пяти правилах ниже только var) ---
   Узор кладётся слоем с mix-blend-mode: overlay. У overlay мёртвая зона ровно на
   средне-сером: пиксель яркостью ~128 не двигает картинку ВООБЩЕ, чем бы ни был
   фон. Ручные PNG рисуются как раз полутонами (кружево 146, спираль 153, зигзаг
   167 по замеру) — отсюда жалоба «много узоров плохо видно», а прежняя opacity
   0.5 делила и без того слабый эффект пополам.
   contrast() растаскивает яркость ОТ середины к краям — то есть бьёт ровно в
   причину, а уже контрастные рисунки (звёзды, волны — чистый чёрный) не портит:
   им расти некуда, они упираются в границу.
   Мерялка: scratchpad/smoke/analyze-patterns.mjs, сравнение вариантов:
   scratchpad/smoke/compare-visibility.mjs. hard-light даёт ещё ярче, но выбеливает
   сам шар и убивает его цвет — поэтому overlay. */
:root {
    --pattern-opacity: 0.8;
    --pattern-contrast: 2.2;
}

#site-announcements {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9800;
    display: none;
    flex-direction: column;
    pointer-events: none;
}
#site-announcements.has-items {
    display: flex;
}
.site-announcement {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 48px 10px 18px;
    position: relative;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 600;
    color: #1b1206;
    border-bottom: 2px solid rgba(0, 0, 0, 0.45);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}
.site-announcement.kind-info {
    background: linear-gradient(180deg, #cfe6ff, #a8cdf5);
}
.site-announcement.kind-warning {
    background: linear-gradient(180deg, #ffe2a8, #f5c56a);
}
.site-announcement.kind-critical {
    background: linear-gradient(180deg, #ffb3ae, #f2726a);
    color: #2a0806;
}
/* Критичное объявление слегка пульсирует — его нельзя закрыть, но можно проглядеть */
.site-announcement.kind-critical .sa-icon {
    animation: saPulse 1.6s ease-in-out infinite;
}
@keyframes saPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.22); }
}
.sa-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1.3;
}
.sa-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}
.sa-close {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.14);
    color: #1b1206;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.sa-close:hover {
    background: rgba(0, 0, 0, 0.28);
}

/* Меню/лобби: полоса раздвигает контент, чтобы ничего не перекрывать */
body.has-site-announcement #setup-ui {
    padding-top: calc(10px + var(--announce-h));
}
body.has-site-announcement #online-counter {
    top: calc(16px + var(--announce-h));
}
body.has-site-announcement #menu-audio-controls {
    top: calc(80px + var(--announce-h));
}
body.has-site-announcement #easter-egg-corner,
body.has-site-announcement #easter-egg-corner-den {
    top: calc(16px + var(--announce-h));
}

/* За игровым столом полоса сжимается в узкую плашку по центру и не двигает вёрстку.
   Клик по ней разворачивает полный текст. */
#site-announcements.compact {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(720px, 62vw);
    cursor: pointer;
}
#site-announcements.compact .site-announcement {
    padding: 5px 34px 5px 12px;
    font-size: 12px;
    border-radius: 0 0 12px 12px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.4);
    opacity: 0.94;
}
#site-announcements.compact:not(.expanded) .sa-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#site-announcements.compact .sa-close {
    top: 3px;
    width: 20px;
    height: 20px;
    font-size: 11px;
}

/* --- Кнопка админ-панели (левый верх, под управлением звуком) --- */
#admin-panel-btn {
    position: fixed;
    top: calc(134px + var(--announce-h));
    left: 16px;
    z-index: 120;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 3px solid #000;
    background: rgba(255, 255, 255, 0.95);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
}
#admin-panel-btn:hover {
    background: #ffe2a8;
}

/* --- Карточка опроса в меню --- */
/* Опросов может идти несколько — карточка листается, а не растёт бесконечно */
.poll-side-card.expanded .side-card-body {
    max-height: 460px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}
.poll-card-block + .poll-card-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed rgba(138, 88, 54, 0.4);
}
.poll-card-question {
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.35;
}
.poll-card-empty {
    font-size: 12px;
    opacity: 0.75;
    margin-bottom: 8px;
}
.poll-card-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 8px;
}
.poll-card-bar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 74px 34px;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.poll-card-bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.poll-card-bar {
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.18);
    overflow: hidden;
}
.poll-card-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #d99a3f, #b3651f);
    border-radius: 4px;
    transition: width 0.35s ease;
}
.poll-card-bar-pct {
    text-align: right;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}
.poll-card-more,
.poll-card-meta {
    font-size: 11px;
    opacity: 0.75;
    margin-bottom: 6px;
}
.poll-card-btn {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #b3651f, #8a4a12);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.poll-card-btn:hover {
    filter: brightness(1.12);
}

/* --- Модалка голосования --- */
.poll-modal-content {
    width: 92%;
    max-width: 620px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.poll-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}
.poll-question {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 4px;
}
.poll-status-line {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 14px;
}
.poll-empty {
    font-size: 13px;
    opacity: 0.8;
}
.poll-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.poll-option {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid rgba(138, 88, 54, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.poll-option:hover {
    background: rgba(217, 154, 63, 0.09);
}
.poll-option.chosen {
    border-color: #b3651f;
    background: rgba(217, 154, 63, 0.16);
}
.poll-option.locked {
    cursor: default;
}
.poll-option-main {
    min-width: 0;
}
.poll-option-text {
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
}
.poll-your-mark {
    font-size: 11px;
    color: #2f7d32;
    font-weight: 700;
    white-space: nowrap;
}
.poll-suggested-by {
    display: block;
    font-size: 11px;
    opacity: 0.6;
    font-style: italic;
}
.poll-option-bar {
    height: 6px;
    margin-top: 6px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.13);
    overflow: hidden;
}
.poll-option-fill {
    height: 100%;
    background: linear-gradient(90deg, #d99a3f, #b3651f);
    border-radius: 3px;
    transition: width 0.35s ease;
}
.poll-option-counts {
    text-align: right;
    white-space: nowrap;
}
.poll-pct {
    display: block;
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.poll-split {
    display: block;
    font-size: 11px;
    opacity: 0.65;
}
.poll-totals {
    margin-top: 14px;
    font-size: 12px;
    opacity: 0.8;
}
.poll-totals-note {
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.65;
    line-height: 1.4;
}
.poll-guest-note {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(33, 150, 243, 0.12);
    border-left: 3px solid #2196F3;
    font-size: 12px;
    line-height: 1.4;
}
.poll-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.poll-suggest-block {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(138, 88, 54, 0.4);
}
.poll-suggest-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}
.poll-suggest-row {
    display: flex;
    gap: 8px;
}
.poll-suggest-row input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid rgba(138, 88, 54, 0.45);
    border-radius: 8px;
    font-size: 13px;
}
.poll-suggest-hint {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.7;
    line-height: 1.4;
}

/* --- Админ-панель объявлений и опросов --- */
.admin-notices-content {
    width: 94%;
    max-width: 780px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.admin-notices-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px 0;
    border-bottom: 2px solid rgba(138, 88, 54, 0.25);
}
.admin-tab-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px 8px 0 0;
    background: rgba(138, 88, 54, 0.12);
    color: #3a2b20;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.admin-tab-btn.active {
    background: #b3651f;
    color: #fff;
}
.admin-pending-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    margin-left: 4px;
    border-radius: 10px;
    background: #d93a3a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
}
.admin-notices-body {
    padding: 14px 16px;
    overflow-y: auto;
    flex: 1;
}
.admin-form-block {
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid rgba(138, 88, 54, 0.3);
    border-radius: 10px;
    background: rgba(217, 154, 63, 0.07);
}
.admin-block-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}
.admin-block-subtitle {
    font-size: 12px;
    font-weight: 700;
    opacity: 0.8;
    margin: 10px 0 6px;
}
.admin-notices-body textarea,
.admin-notices-body input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid rgba(138, 88, 54, 0.45);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}
.admin-char-count {
    font-size: 11px;
    opacity: 0.6;
    text-align: right;
    margin-top: 2px;
}
.admin-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-top: 10px;
    font-size: 12px;
}
.admin-form-row label {
    display: flex;
    align-items: center;
    gap: 6px;
}
.admin-form-row select,
.admin-form-row input[type="datetime-local"] {
    padding: 5px 8px;
    border: 1px solid rgba(138, 88, 54, 0.45);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
}
.admin-check {
    cursor: pointer;
}
.admin-hint {
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.75;
    line-height: 1.5;
}
.admin-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.admin-mini-btn {
    padding: 4px 10px;
    border: 1px solid rgba(138, 88, 54, 0.5);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.85);
    color: #3a2b20;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}
.admin-mini-btn:hover {
    background: #ffe2a8;
}
.admin-mini-btn.danger {
    border-color: rgba(190, 60, 50, 0.55);
    color: #a32e26;
}
.admin-mini-btn.danger:hover {
    background: #ffd9d5;
}
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.admin-empty {
    font-size: 13px;
    opacity: 0.7;
    padding: 10px 0;
}
.admin-item {
    padding: 10px 12px;
    border: 1px solid rgba(138, 88, 54, 0.3);
    border-left: 4px solid rgba(138, 88, 54, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
}
/* Зелёная кромка — объявление/опрос прямо сейчас на сайте */
.admin-item.live {
    border-left-color: #2f9838;
    background: rgba(47, 152, 56, 0.07);
}
.admin-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    margin-bottom: 6px;
}
.admin-badge {
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(138, 88, 54, 0.16);
    font-weight: 700;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-item-state,
.admin-item-until {
    opacity: 0.7;
}
/* Вкладка «Онлайн» (31.10.2026): одна строка — одно соединение */
.admin-online-summary {
    margin-bottom: 10px;
}
.admin-online-row {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) minmax(0, 1fr) auto;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
    border-top: 1px dashed rgba(127, 127, 127, 0.25);
}
.admin-online-row > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-online-lobby {
    opacity: 0.6;
}
@media (max-width: 600px) {
    .admin-online-row { grid-template-columns: 1fr 1fr; }
}
.admin-item-text {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
    word-break: break-word;
}
.admin-item-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.admin-option-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
/* Строки отсортированы по убыванию голосов — лидер сверху и с короной */
.admin-option-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px auto auto;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 3px 0;
}
.admin-option-row.leader .admin-option-text {
    font-weight: 700;
}
.admin-option-row.leader .admin-option-fill {
    background: linear-gradient(90deg, #f0b429, #b3651f);
}
.admin-option-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-option-bar {
    display: block;
    height: 7px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.14);
    overflow: hidden;
}
.admin-option-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #d99a3f, #b3651f);
    transition: width 0.35s ease;
}
.admin-option-count {
    opacity: 0.75;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.admin-add-option-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.admin-add-option-row input {
    flex: 1;
    min-width: 0;
}

/* ============================================
   СВОЙ ЦВЕТ УЗОРА (.pattern-tinted)

   ⚠️ ЭТОТ БЛОК ДОЛЖЕН ОСТАВАТЬСЯ В КОНЦЕ ФАЙЛА. Слой узора описан в КАЖДОМ
   контексте своим правилом вида `.что-то.has-pattern::after` — таких пять с
   лишним, и раскиданы они по всему файлу. Специфичность у них ровно такая же,
   как у правила ниже, поэтому решает ПОРЯДОК: стоя выше, этот блок затирался
   всеми контекстами, объявленными ниже, и цвет узора «ничего не менял» у бота,
   в лобби, в профиле и в инвентаре — а в превью редактора работал, потому что
   его правило объявлено выше. Класс продублирован (.pattern-tinted дважды) —
   это поднимает специфичность на запас, если кто-то допишет контекст ниже.

   Что здесь происходит: обычный режим красит узор самим шаром (картинка +
   overlay). Чтобы узор стал ЗАДАННОГО цвета, рисунок меняет роль — он больше не
   картинка, а МАСКА, сквозь которую видно сплошную заливку --pattern-color.
   Отсюда background-image: none и снятые blend/contrast: цвет должен быть ровно
   выбранным, без подмешивания шара.

   ЛОВУШКА: в масочных контекстах слой УЖЕ обрезан маской kolobok.png. Просто
   подменить mask-image нельзя — потеряется форма колобка и узор вылезет
   квадратом. Поэтому маски складываются в стопку (узор + колобок) и
   пересекаются: mask-composite: intersect, для старого вебкита source-in.
   ============================================ */
.has-pattern.pattern-tinted.pattern-tinted::after {
    background-image: none;
    background-color: var(--pattern-color, #fff);
    mix-blend-mode: normal;
    filter: none;
    opacity: 0.95;
    -webkit-mask-image: var(--pattern-url), url('kolobok.png');
    mask-image: var(--pattern-url), url('kolobok.png');
    -webkit-mask-repeat: no-repeat, no-repeat;
    mask-repeat: no-repeat, no-repeat;
    -webkit-mask-position: center, center;
    mask-position: center, center;
    -webkit-mask-size: contain, contain;
    mask-size: contain, contain;
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
}

/* Плитка «мой колобок» в инвентаре — голый круг без маски колобка, и рисунок в
   ней растянут (background-size: 154%). Маска обязана повторять тот же размер,
   иначе крашеный узор сядет мельче обычного. */
.inventory-own-avatar.has-pattern.pattern-tinted.pattern-tinted::after {
    -webkit-mask-image: var(--pattern-url);
    mask-image: var(--pattern-url);
    -webkit-mask-size: 154%;
    mask-size: 154%;
    -webkit-mask-composite: source-over;
    mask-composite: add;
}
.inventory-own-avatar.pattern-vector.pattern-tinted.pattern-tinted::after {
    -webkit-mask-size: cover;
    mask-size: cover;
}

/* За столом маски колобка нет — шар занимает весь бокс. Но слой БОЛЬШЕ спрайта
   (--table-pattern-layer против 170), поэтому маски всё равно две: сам узор и
   круг шара — иначе крашеный узор торчал бы наружу так же, как обычный до фикса.
   Слой центрирован по спрайту, поэтому круг шара = центр слоя, радиус 85. */
.player-sprite-table.has-pattern.pattern-tinted.pattern-tinted::after {
    -webkit-mask-image: var(--pattern-url), radial-gradient(circle 85px at center, #000 99%, transparent 100%);
    mask-image: var(--pattern-url), radial-gradient(circle 85px at center, #000 99%, transparent 100%);
    -webkit-mask-size: cover, auto;
    mask-size: cover, auto;
    -webkit-mask-position: center, center;
    mask-position: center, center;
    -webkit-mask-repeat: no-repeat, no-repeat;
    mask-repeat: no-repeat, no-repeat;
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
}

/* Тайловые за столом: слой ровно по спрайту, круг шара не нужен. */
.player-sprite-table.has-pattern.pattern-tinted.pattern-tinted.pattern-vector::after {
    -webkit-mask-image: var(--pattern-url);
    mask-image: var(--pattern-url);
    -webkit-mask-size: cover;
    mask-size: cover;
    -webkit-mask-composite: source-over;
    mask-composite: add;
}

/* ============================================
   ОКОШКО ВЕДУЩЕГО «ЖЕСТЫ ЗА СТОЛОМ» (v2.1)
   Открывается ПКМ по кнопке жестов, position: fixed — координаты ставит JS
   рядом с самой кнопкой.
   ============================================ */
.god-gesture-settings {
    position: fixed;
    z-index: 6100;
    min-width: 250px;
    /* На узком экране (телефон в портрете) 320px не влезают вовсе — окошко тогда
       не поместить никаким позиционированием, см. openGodGestureSettings. */
    max-width: min(320px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(28, 24, 34, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    color: #efe6d8;
    font-size: 13px;
}

.god-gesture-settings.hidden { display: none; }

.god-gesture-settings-title {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 14px;
}

.god-gesture-settings-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    cursor: pointer;
    line-height: 1.35;
}

.god-gesture-settings-row input { margin-top: 2px; cursor: pointer; }

.god-gesture-settings-note {
    margin: 6px 0 2px;
    font-size: 11px;
    color: #9c9184;
    line-height: 1.35;
}

.god-gesture-settings-personal {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    color: #c9bfb2;
}

/* ============================================
   ГЛАЗ У ПОЛЯ ПАРОЛЯ (v2.1)
   Кнопка кладётся в обёртку вокруг input — см. initPasswordEyes в script.js.
   ============================================ */
.password-field-wrap {
    position: relative;
    display: block;
}

.password-eye-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Апрель, п.52: та же ловушка общего button:hover — глазок съезжал вниз */
.password-eye-btn:hover,
.password-eye-btn:active { opacity: 1; transform: translateY(-50%); background: transparent; box-shadow: none; }

/* Место под кнопку, чтобы текст пароля не уезжал под глаз. */
.password-field-wrap > input { padding-right: 38px !important; }


/* ============================================
   ТЁМНАЯ ТЕМА (13.09.2026)
   Класс html.dark-theme ставит toggleDarkTheme() (script.js), выбор живёт в
   localStorage (mafia_dark_theme). Красит меню, лобби, модалки и игровые
   ПАНЕЛИ (чат, фаза, таймер, кнопки). Фон партии, колобки, выноски и всё
   день/ночь за столом НЕ трогает — там своя смена суток.
   Правила ниже разделены на две части: сгенерированные (scratchpad-скрипт
   прошёл по style.css и перевёл белые поверхности / тёмный текст / светлые
   рамки в переменные --dk-*) и ручные (инлайновые стили, игровые панели).
   ============================================ */
html.dark-theme {
    color-scheme: dark;
    --dk-surface: #241b16;      /* белые карточки/панели */
    --dk-surface-2: #2e231c;    /* светло-серые/кремовые подложки */
    --dk-surface-3: #3a2d24;    /* ещё темнее в оригинале (#ddd-#eee) */
    --dk-border: #4a3a30;
    --dk-text: #ece0d2;         /* был #3a2b20 / #333 */
    --dk-text-2: #c9b8a6;       /* был #555 / #666 / #6b5a4a */
    --dk-muted: #9a8878;        /* был #888 / #999 / #8a7565 */
    --dk-accent-text: #d9a677;  /* был #8a5836 как цвет текста */
}

/* Текст меню и лобби наследует цвет body (день = тёмно-коричневый).
   #game-ui тоже лежит внутри #setup-ui, поэтому красим только экраны меню. */
html.dark-theme .menu-layout,
html.dark-theme #rooms-panel { color: var(--dk-text); }

/* Фон страницы вне партии: у экрана комнат нет ночного арта, там светит
   дневной градиент сеттинга. За столом (#game-ui показан) фон не трогаем —
   это уже день/ночь самой игры. В комнате (#lobby показан) тоже не трогаем:
   там уже виден фон выбранного сеттинга, и тёмная тема его прятала. */
html.dark-theme body:not(:has(#game-ui[style*="display: block"])):not(:has(#lobby[style*="display: block"])) {
    background: linear-gradient(180deg, #120d0a 0%, #1e1610 100%);
}

/* ── Плавное переливание светлая ↔ тёмная (п.6) ──────────────────────────
   Постоянный transition на «*» сделал бы вялым каждый ховер, поэтому класс
   html.theme-switching живёт ровно время переключения (THEME_FADE_MS в
   script.js) и на это время заставляет ВСЁ переливаться по цвету.
   Размеры/трансформации не трогаем — перечислены только красящие свойства. */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition-property: background-color, background-image, color, border-color,
        outline-color, box-shadow, fill, stroke !important;
    transition-duration: 380ms !important;
    transition-timing-function: ease !important;
    transition-delay: 0s !important;
}

/* Канва страницы — градиент, а градиенты не интерполируются: браузер щёлкнул бы
   фоном посреди плавной картинки. Поэтому JS снимает СТАРЫЙ фон в эту накладку
   и гасит её. Слой той же природы, что body::before у ночи: z-index -1 держит
   его над канвой, но под всем содержимым страницы. */
#theme-fade-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-size: cover;
    background-position: center;
    /* Сам слой живёт прозрачностью — иначе правило выше (оно не перечисляет
       opacity) отобрало бы у него единственный нужный transition. */
    transition-property: opacity !important;
}

@media (prefers-reduced-motion: reduce) {
    html.theme-switching,
    html.theme-switching *,
    html.theme-switching *::before,
    html.theme-switching *::after { transition-duration: 0s !important; }
}

/* ===== DARK THEME (generated) ===== */
html.dark-theme #easter-egg-icon,
html.dark-theme #easter-egg-icon-den { background: rgba(36, 27, 22, 0.95); }
html.dark-theme .easter-egg-bubble { background: rgba(36, 27, 22, 0.97); }
html.dark-theme .easter-egg-bubble p { color: var(--dk-text); }
html.dark-theme .easter-egg-close { color: var(--dk-muted); }
html.dark-theme .easter-egg-close:hover { color: var(--dk-text); }
html.dark-theme .gs-tile-value { color: var(--dk-accent-text); }
html.dark-theme .gs-tile-label { color: var(--dk-text-2); }
html.dark-theme .gs-section-title,
html.dark-theme .gs-block-title { color: var(--dk-accent-text); }
html.dark-theme .gs-line-label { color: var(--dk-text); }
html.dark-theme .gs-line-value { color: var(--dk-accent-text); }
html.dark-theme .gs-line-sub { color: var(--dk-text-2); }
html.dark-theme .gs-note { color: var(--dk-text-2); }
html.dark-theme .gs-note-big { color: var(--dk-accent-text); }
html.dark-theme .gs-bar-count { color: var(--dk-accent-text); }
html.dark-theme .gs-bar-date { color: var(--dk-text-2); }
html.dark-theme .gs-empty { color: var(--dk-text-2); }
html.dark-theme .about-game-card .side-card-body p,
html.dark-theme .from-author-card .side-card-body p { color: var(--dk-text); }
html.dark-theme .about-game-card .side-card-body li { color: var(--dk-text); }
html.dark-theme .side-card { background: rgba(36, 27, 22, 0.95); }
html.dark-theme .side-card-title { color: var(--dk-text); }
html.dark-theme .side-card-title::after { color: var(--dk-muted); }
html.dark-theme .side-card.expanded .side-card-title { border-bottom-color: var(--dk-border); }
html.dark-theme .leaderboard-placeholder p { color: var(--dk-text-2); }
html.dark-theme #name-panel { background: rgba(36, 27, 22, 0.95); }
html.dark-theme .gender-label { color: var(--dk-text-2); }
html.dark-theme .gender-label:hover { color: var(--dk-text); }
html.dark-theme .tab-btn.active { background: var(--dk-surface); }
html.dark-theme .tab-description { color: var(--dk-text-2); }
html.dark-theme .rooms-left,
html.dark-theme .rooms-right { background: rgba(36, 27, 22, 0.95); }
html.dark-theme .rooms-subtitle { color: var(--dk-text); }
html.dark-theme .rooms-info { color: var(--dk-text-2); }
html.dark-theme #rooms-list { border-color: var(--dk-border); background: var(--dk-surface); }
html.dark-theme #lobby-chat { border-color: var(--dk-border); background: var(--dk-surface); }
html.dark-theme .lobby-chat-title { color: var(--dk-text); border-bottom-color: var(--dk-border); }
html.dark-theme .lobby-msg-sender { color: var(--dk-accent-text); }
html.dark-theme .lobby-msg-text { color: var(--dk-text); }
html.dark-theme .lobby-msg-system { color: var(--dk-muted); }
html.dark-theme .lobby-chat-input-area { border-top-color: var(--dk-border); background: var(--dk-surface); }
html.dark-theme .lobby-chat-input-area input,
html.dark-theme .lobby-chat-input-area textarea { border-color: var(--dk-border); background: var(--dk-surface-2); color: var(--dk-text); }
html.dark-theme .lobby-chat-counter { color: var(--dk-text-2); }
html.dark-theme .lobby-msg-reply-btn { color: var(--dk-accent-text); }
html.dark-theme .lobby-msg-quote { color: var(--dk-muted); border-left-color: var(--dk-border); }
html.dark-theme .lobby-msg-quote b { color: var(--dk-accent-text); }
html.dark-theme .lobby-reply-preview { color: var(--dk-text-2); }
html.dark-theme .lobby-reply-preview-text b { color: var(--dk-accent-text); }
html.dark-theme .lobby-reply-cancel { color: var(--dk-muted); }
html.dark-theme #bot-config-modal .modal-header { background: var(--dk-surface); }
html.dark-theme #bot-config-modal .modal-footer { background: var(--dk-surface); }
html.dark-theme .modal-content { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .modal-header { color: var(--dk-text); }
html.dark-theme .form-field label { color: var(--dk-text-2); }
html.dark-theme .form-field input { border-color: var(--dk-border); }
html.dark-theme .modal-footer { border-top-color: var(--dk-border); }
html.dark-theme #lobby { background: var(--dk-surface-2); }
html.dark-theme .chat-message.system { color: var(--dk-muted); }
html.dark-theme .lobby-player-summary { color: var(--dk-text-2); }
html.dark-theme .lobby-player-summary__label { color: var(--dk-text-2); }
html.dark-theme .modal-wide .modal-footer { background: var(--dk-surface); border-top-color: var(--dk-border); }
html.dark-theme .settings-section { background: var(--dk-surface); border-color: var(--dk-border); }
html.dark-theme .settings-section-title { color: var(--dk-text); }
html.dark-theme .settings-group { background: var(--dk-surface); border-color: var(--dk-border); }
html.dark-theme .settings-group-title { color: var(--dk-text-2); border-bottom-color: var(--dk-border); }
html.dark-theme .settings-hint { color: var(--dk-text-2); }
html.dark-theme .form-field select { border-color: var(--dk-border); background: var(--dk-surface); }
html.dark-theme .chat-message.defense .sender { color: var(--dk-accent-text); }
html.dark-theme .chat-type-spectator .sender { color: var(--dk-text-2); }
html.dark-theme .help-content { color: var(--dk-text); }
html.dark-theme .setting-selector-grid { border-color: var(--dk-border); }
html.dark-theme .setting-card { background: var(--dk-surface); }
html.dark-theme .setting-card.selected::after { color: var(--dk-accent-text); }
html.dark-theme .setting-card-name { color: var(--dk-text-2); }
html.dark-theme .setting-card.selected .setting-card-name { color: var(--dk-accent-text); }
html.dark-theme .room-setting-badge { color: var(--dk-accent-text); }
html.dark-theme .room-god-badge.with-god { background: var(--dk-surface-3); color: var(--dk-text); }
html.dark-theme .room-god-badge.no-god { background: var(--dk-surface-2); color: var(--dk-text-2); }
html.dark-theme .profile-stats-card { border-color: var(--dk-border); }
html.dark-theme .profile-stats-header { border-bottom-color: var(--dk-border); }
html.dark-theme .profile-rank-title { color: var(--dk-text); }
html.dark-theme .profile-xp-bar { background: var(--dk-surface-3); }
html.dark-theme .profile-xp-text { color: var(--dk-text-2); }
html.dark-theme .profile-stat { background: rgba(36, 27, 22, 0.7); }
html.dark-theme .profile-stat-value { color: var(--dk-text); }
html.dark-theme .profile-stat-label { color: var(--dk-text-2); }
html.dark-theme .mini-profile { background: rgba(36, 27, 22, 0.95); border-color: var(--dk-border); }
html.dark-theme .mini-profile-name { color: var(--dk-text); }
html.dark-theme .mini-profile-rank { color: var(--dk-text-2); }
html.dark-theme .profile-details-btn { background: var(--dk-surface-3) !important; color: var(--dk-text) !important; }
html.dark-theme .profile-modal-top { border-bottom-color: var(--dk-border); }
html.dark-theme .profile-modal-name { color: var(--dk-text); }
html.dark-theme .profile-modal-rank-badge { border-color: var(--dk-border); color: var(--dk-text); }
html.dark-theme .profile-modal-stat-label { color: var(--dk-text); }
html.dark-theme .profile-modal-stat-value { color: var(--dk-text); }
html.dark-theme .profile-modal-content .modal-footer { background: var(--dk-surface); }
html.dark-theme .profile-action-btn { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .profile-action-btn:hover:not(:disabled) { background: var(--dk-surface-3); }
html.dark-theme .profile-section { border-top-color: var(--dk-border); }
html.dark-theme .profile-section-title { color: var(--dk-text); }
html.dark-theme .profile-section-count { color: var(--dk-text-2); }
html.dark-theme .profile-friends-empty { color: var(--dk-text-2); }
html.dark-theme .profile-friend-item-name { color: var(--dk-text); }
html.dark-theme .profile-stat-cell-value { color: var(--dk-text); }
html.dark-theme .profile-stat-cell-label { color: var(--dk-text-2); }
html.dark-theme .profile-editor-content .modal-footer { background: var(--dk-surface); border-top-color: var(--dk-border); }
html.dark-theme .profile-editor-label { color: var(--dk-text); }
html.dark-theme .profile-editor-tabs { background: var(--dk-surface-3); }
html.dark-theme .profile-editor-tab-btn { color: var(--dk-text-2); }
html.dark-theme .profile-editor-tab-btn.active { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme #profile-editor-caption { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .profile-editor-char-counter { color: var(--dk-text-2); }
html.dark-theme .profile-editor-toggle-label { color: var(--dk-text); }
html.dark-theme .profile-editor-hint { color: var(--dk-text-2); }
html.dark-theme .inventory-content .modal-footer { background: var(--dk-surface); border-top-color: var(--dk-border); }
html.dark-theme .inventory-tab-btn.active { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .inventory-ach-panel { background: var(--dk-surface); }
html.dark-theme .inventory-ach-head { border-bottom-color: var(--dk-border); }
html.dark-theme .inventory-ach-count { color: var(--dk-accent-text); }
html.dark-theme .inventory-ach-hint { color: var(--dk-muted); }
html.dark-theme .inventory-ach-list { color: var(--dk-muted); }
html.dark-theme .inventory-ach-group { color: var(--dk-accent-text); }
html.dark-theme .inventory-ach-row { background: var(--dk-surface); border-color: var(--dk-border); }
html.dark-theme .inventory-ach-row.unlocked { background: var(--dk-surface-2); }
html.dark-theme .inventory-ach-icon { color: var(--dk-muted); }
html.dark-theme .inventory-ach-name { color: var(--dk-text); }
html.dark-theme .inventory-ach-row.locked .inventory-ach-name { color: var(--dk-text-2); }
html.dark-theme .inventory-ach-desc { color: var(--dk-text-2); }
html.dark-theme .inventory-ach-link,
html.dark-theme .inventory-ach-link:hover { color: var(--dk-accent-text); }
html.dark-theme .inventory-ach-reward { color: var(--dk-accent-text); }
html.dark-theme .inventory-ach-rarity { color: var(--dk-muted); }
html.dark-theme .inventory-ach-who { border-bottom-color: var(--dk-border); }
html.dark-theme .inventory-ach-who-btn { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .inventory-ach-who-btn:hover { background: var(--dk-surface-3); }
html.dark-theme .inventory-ach-subject { color: var(--dk-accent-text); background: var(--dk-surface-2); border-bottom-color: var(--dk-border); }
html.dark-theme .inventory-ach-bar { background: var(--dk-surface-3); }
html.dark-theme .inventory-ach-date { color: var(--dk-accent-text); }
html.dark-theme .inventory-music-panel { background: var(--dk-surface); }
html.dark-theme .inventory-music-hint { color: var(--dk-text-2); border-bottom-color: var(--dk-border); }
html.dark-theme .music-group-title { color: var(--dk-accent-text); }
html.dark-theme .profile-friends-group-title { color: var(--dk-accent-text); }
html.dark-theme .music-row:hover { background: var(--dk-surface-3); }
html.dark-theme .music-row.playing { background: var(--dk-surface-3); }
html.dark-theme .music-row-name { color: var(--dk-text); }
html.dark-theme .music-row-author { color: var(--dk-muted); }
html.dark-theme .music-dl-btn { background: var(--dk-surface-3); color: var(--dk-accent-text); }
html.dark-theme .music-pl-btn { background: var(--dk-surface-3); color: var(--dk-muted); }
html.dark-theme .music-pl-btn.in-playlist { color: var(--dk-accent-text); background: var(--dk-surface-3); }
html.dark-theme .inventory-music-playlist-bar { color: var(--dk-text-2); border-bottom-color: var(--dk-border); background: var(--dk-surface); }
html.dark-theme .music-pl-empty { color: var(--dk-muted); }
html.dark-theme .music-pl-count { color: var(--dk-accent-text); }
html.dark-theme .music-pl-clear { border-color: var(--dk-border); background: var(--dk-surface); color: var(--dk-accent-text); }
html.dark-theme .music-pl-clear:hover { background: var(--dk-surface-3); }
html.dark-theme .inventory-grid-wrap { border-right-color: var(--dk-border); }
html.dark-theme .inventory-section-title { color: var(--dk-text-2); }
html.dark-theme .inventory-section-title.unique { color: var(--dk-accent-text); }
html.dark-theme .inventory-section-title.unavailable { color: var(--dk-muted); }
html.dark-theme .inventory-section-hint { color: var(--dk-muted); }
html.dark-theme .inventory-cell { background: var(--dk-surface-3); }
html.dark-theme .inventory-cell.selected { background: var(--dk-surface); }
html.dark-theme .inventory-cell.default-cell { color: var(--dk-text-2); }
html.dark-theme .inventory-cell.locked { background: var(--dk-surface-3); }
html.dark-theme .inventory-cell.locked.selected { background: var(--dk-surface); }
html.dark-theme .inventory-pack-badge { color: var(--dk-accent-text); }
html.dark-theme .inventory-section-title.pack-title { color: var(--dk-accent-text); }
html.dark-theme .inventory-details { background: var(--dk-surface); }
html.dark-theme .inventory-details-preview { background: var(--dk-surface); }
html.dark-theme .inventory-details-name { color: var(--dk-text); }
html.dark-theme .inventory-details-desc { color: var(--dk-text-2); }
html.dark-theme .inventory-secondary-btn { border-color: var(--dk-border); background: var(--dk-surface); color: var(--dk-accent-text); }
html.dark-theme .inventory-secondary-btn:hover { background: var(--dk-surface-2); }
html.dark-theme .inventory-unlock-hint { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text-2); }
html.dark-theme .inventory-unlock-hint a { color: var(--dk-accent-text); }
@media (max-width: 700px) {
    html.dark-theme .inventory-grid-wrap { border-bottom-color: var(--dk-border); }
}
@media (orientation: landscape) and (max-height: 560px) {
    html.dark-theme .inventory-grid-wrap { border-right-color: var(--dk-border); }
}
html.dark-theme #name-panel .online-count { color: var(--dk-text-2); }
html.dark-theme .volume-mixer-value { color: var(--dk-muted); }
html.dark-theme .chat-message.local-draft .sender { color: var(--dk-muted); }
html.dark-theme .god-memory-type { color: var(--dk-text-2); }
html.dark-theme .setting-locked-badge { background: rgba(36, 27, 22, 0.9); }
html.dark-theme .help-popup-box a { color: var(--dk-accent-text); }
html.dark-theme .help-popup-close { color: var(--dk-muted); }
html.dark-theme .mobile-warning-text { color: var(--dk-muted); }
html.dark-theme .mobile-why-arrow { color: var(--dk-muted); }
html.dark-theme .mobile-why-body p { color: var(--dk-muted); }
html.dark-theme .profile-stat-row-mini { color: var(--dk-text-2); }
html.dark-theme .profile-stat-row-mini span:last-child { color: var(--dk-text); }
html.dark-theme .recordings-empty { color: var(--dk-text-2); }
html.dark-theme .recordings-row { border-color: var(--dk-border); background: var(--dk-surface); }
html.dark-theme .recordings-row:hover { background: var(--dk-surface-3); }
html.dark-theme .recordings-row-title { color: var(--dk-text); }
html.dark-theme .recordings-row-meta { color: var(--dk-text-2); }
html.dark-theme .recordings-retention-hint { color: var(--dk-text-2); }
html.dark-theme .recordings-row-audio { color: var(--dk-muted); }
html.dark-theme .recordings-row-players { color: var(--dk-muted); }
html.dark-theme .recordings-row-audio.expiring { color: var(--dk-accent-text); }
html.dark-theme .recordings-watch-btn { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .recordings-watch-btn:hover { background: var(--dk-surface-3); }
html.dark-theme .recordings-delete-btn { border-color: var(--dk-border); }
html.dark-theme .recordings-delete-btn:hover { background: var(--dk-surface-2); }
html.dark-theme .recordings-toggle { color: var(--dk-text); }
html.dark-theme .recordings-row.recordings-row-favorite { background: var(--dk-surface-2); }
html.dark-theme .recordings-protocol { border-color: var(--dk-border); background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .leaderboard-tabs { background: rgba(36, 27, 22, 0.95); }
html.dark-theme .leaderboard-tab-btn { color: var(--dk-accent-text); }
html.dark-theme .leaderboard-season-btn { color: var(--dk-accent-text); }
html.dark-theme .leaderboard-season-select { color: var(--dk-text); background: var(--dk-surface); }
html.dark-theme .leaderboard-season-note { color: var(--dk-text-2); }
html.dark-theme .profile-season-row { color: var(--dk-accent-text); }
html.dark-theme .profile-dossier-title { color: var(--dk-text); }
html.dark-theme .profile-dossier-text { color: var(--dk-accent-text); }
html.dark-theme .profile-dossier-text.empty { color: var(--dk-accent-text); }
html.dark-theme .profile-dossier-note { color: var(--dk-accent-text); }
html.dark-theme .mp-version-id { color: var(--dk-text); }
html.dark-theme .mp-version-stat { color: var(--dk-accent-text); }
html.dark-theme .bot-memory-name { color: var(--dk-text); }
html.dark-theme .leaderboard-name { color: var(--dk-text); }
html.dark-theme .leaderboard-xp { color: var(--dk-accent-text); }
html.dark-theme .leaderboard-wr { color: var(--dk-text-2); }
html.dark-theme .auth-status { color: var(--dk-text-2); }
html.dark-theme .special-name-hint { color: var(--dk-accent-text); }
html.dark-theme .special-name-actions button { background: rgba(46, 35, 28, 0.85); color: var(--dk-accent-text); }
html.dark-theme .auth-modal-note { color: var(--dk-text); }
html.dark-theme .sa-close { color: var(--dk-text); }
html.dark-theme #admin-panel-btn { background: rgba(36, 27, 22, 0.95); }
html.dark-theme .admin-tab-btn { color: var(--dk-text); }
html.dark-theme .admin-mini-btn { background: rgba(36, 27, 22, 0.85); color: var(--dk-text); }
html.dark-theme .admin-mini-btn.danger:hover { background: var(--dk-surface-2); }
html.dark-theme .admin-item { background: rgba(36, 27, 22, 0.6); }
html.dark-theme .god-gesture-settings-note { color: var(--dk-muted); }

/* ===== DARK THEME (manual) ===== */

/* Карточка обновлений сама фиолетовая — генератор её общими правилами
   .side-card не должен перекрашивать */
html.dark-theme .changelog-card { background: linear-gradient(145deg, #1a0830, #2d1060, #1a0828); }
html.dark-theme .changelog-card .side-card-title { color: #e9d5ff; }
html.dark-theme .changelog-card.expanded .side-card-title { border-bottom-color: rgba(79, 47, 121, 0.3); }
/* В светлой теме карточка на деле белая (.side-card идёт позже и перебивает
   градиент), и тёмно-фиолетовый текст пунктов читался. В тёмной градиент
   виден — и тот же текст сливался с ним. Всё содержимое — светло-сиреневым. */
html.dark-theme .changelog-card .side-card-body li { color: #ddd0f2; border-bottom-color: rgba(196, 150, 255, 0.18); }
html.dark-theme .changelog-card .side-card-body li b { color: #f1e8ff; }
html.dark-theme .changelog-version-label { color: rgba(221, 208, 242, 0.6); }
html.dark-theme .changelog-history-btn { background: rgba(196, 150, 255, 0.14); border-color: rgba(196, 150, 255, 0.4); color: #e9d5ff; }
html.dark-theme .changelog-history-btn:hover { background: rgba(196, 150, 255, 0.24); border-color: rgba(196, 150, 255, 0.6); }
html.dark-theme .changelog-history-version-block { background: rgba(196, 150, 255, 0.06); border-color: rgba(196, 150, 255, 0.2); }
html.dark-theme .changelog-history-title { color: #e9d5ff; }
html.dark-theme .changelog-history-modal-body li { color: var(--dk-text); }

/* Вкладка «📊 Сервер» в таблице лидеров: подписи ролей и «игр / побед» */
html.dark-theme .gs-role-name { color: var(--dk-text); }
html.dark-theme .gs-role-val { color: var(--dk-text-2); }
html.dark-theme .gs-tile { background: rgba(217, 166, 119, 0.1); }
html.dark-theme .gs-block { background: rgba(217, 166, 119, 0.07); }
html.dark-theme .gs-line { border-bottom-color: var(--dk-border); }
html.dark-theme .gs-role-bar { background: rgba(217, 166, 119, 0.16); }
html.dark-theme .leaderboard-tab-btn { background: rgba(217, 166, 119, 0.1); }
html.dark-theme .leaderboard-tab-btn:hover { background: rgba(217, 166, 119, 0.2); }
html.dark-theme .leaderboard-tab-btn.active { background: #8a5836; color: #fff; }
html.dark-theme .leaderboard-season-btn { background: rgba(217, 166, 119, 0.08); }
html.dark-theme .leaderboard-season-btn.active { background: rgba(138, 88, 54, 0.75); color: #fff; }

/* Строка «🎤 Голос: …» в профиле игрока и модели: инлайновый цвет после
   voiceRow.style.display = '' сериализуется в rgb() — ловим по классу. */
html.dark-theme .profile-voice-row { color: var(--dk-text) !important; background: rgba(255, 255, 255, 0.06) !important; }

/* Поля ввода в меню/лобби/модалках */
html.dark-theme #setup-ui > :not(#game-ui) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.dark-theme #setup-ui > :not(#game-ui) select,
html.dark-theme #setup-ui > :not(#game-ui) textarea,
html.dark-theme .modal-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.dark-theme .modal-content select,
html.dark-theme .modal-content textarea {
    background: var(--dk-surface-2);
    color: var(--dk-text);
    border-color: var(--dk-border);
}
html.dark-theme #setup-ui > :not(#game-ui) ::placeholder,
html.dark-theme .modal-content ::placeholder { color: var(--dk-muted); }
html.dark-theme #setup-ui > :not(#game-ui) option,
html.dark-theme .modal-content option { background: var(--dk-surface-2); color: var(--dk-text); }

/* Инлайновые цвета текста из index.html / script.js (лобби, список комнат).
   Матчим и hex из разметки, и rgb(), в который браузер сериализует cssText.
   Префикс «; » / «^=» — чтобы не зацепить background-color: #8a5836. */
html.dark-theme #setup-ui > :not(#game-ui) [style^="color: #3a2b20"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: #3a2b20"],
html.dark-theme #setup-ui > :not(#game-ui) [style^="color: rgb(58, 43, 32)"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: rgb(58, 43, 32)"],
html.dark-theme #setup-ui > :not(#game-ui) [style^="color: #333"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: #333"],
html.dark-theme .modal-content [style^="color: #3a2b20"],
html.dark-theme .modal-content [style*="; color: #3a2b20"],
html.dark-theme .modal-content [style^="color: rgb(58, 43, 32)"],
html.dark-theme .modal-content [style*="; color: rgb(58, 43, 32)"],
html.dark-theme .modal-content [style^="color: #333"],
html.dark-theme .modal-content [style*="; color: #333"],
html.dark-theme .modal-content [style^="color: rgb(51, 51, 51)"],
html.dark-theme .modal-content [style*="; color: rgb(51, 51, 51)"] { color: var(--dk-text) !important; }

html.dark-theme #setup-ui > :not(#game-ui) [style^="color: #666"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: #666"],
html.dark-theme #setup-ui > :not(#game-ui) [style^="color: rgb(102, 102, 102)"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: rgb(102, 102, 102)"],
html.dark-theme #setup-ui > :not(#game-ui) [style^="color: #555"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: #555"],
html.dark-theme .modal-content [style^="color: #666"],
html.dark-theme .modal-content [style*="; color: #666"],
html.dark-theme .modal-content [style^="color: rgb(102, 102, 102)"],
html.dark-theme .modal-content [style*="; color: rgb(102, 102, 102)"],
html.dark-theme .modal-content [style^="color: #555"],
html.dark-theme .modal-content [style*="; color: #555"],
html.dark-theme .modal-content [style^="color: rgb(85, 85, 85)"],
html.dark-theme .modal-content [style*="; color: rgb(85, 85, 85)"] { color: var(--dk-text-2) !important; }

html.dark-theme #setup-ui > :not(#game-ui) [style^="color: #8a5836"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: #8a5836"],
html.dark-theme #setup-ui > :not(#game-ui) [style^="color: rgb(138, 88, 54)"],
html.dark-theme #setup-ui > :not(#game-ui) [style*="; color: rgb(138, 88, 54)"] { color: var(--dk-accent-text) !important; }

/* Список комнат: карточки рисуются с инлайновым белым фоном (script.js) */
html.dark-theme .room-item {
    background: var(--dk-surface-2) !important;
    border-color: var(--dk-border) !important;
    color: var(--dk-text);
}
html.dark-theme .room-item:hover { border-color: var(--dk-accent-text) !important; }

/* Всплывашка «Передать владельца» и модалки с инлайновым белым фоном */
html.dark-theme #owner-transfer-popup {
    background: var(--dk-surface-2) !important;
    border-color: var(--dk-border) !important;
    color: var(--dk-text);
}
html.dark-theme .modal-content[style*="background: white"] { background: var(--dk-surface) !important; }
/* Строки сводки настроек комнаты: инлайновая светлая линия-разделитель */
html.dark-theme .modal-content [style*="border-bottom: 1px solid #eee"],
html.dark-theme .modal-content [style*="border-bottom: 1px solid #e0e0e0"],
html.dark-theme .modal-content [style*="border-bottom: 1px solid #ddd"] { border-bottom-color: var(--dk-border) !important; }

/* Кнопки левого верхнего угла (музыка/звуки/тема) */
html.dark-theme .menu-audio-btn { background: rgba(46, 35, 28, 0.95); border-color: var(--dk-border); }
html.dark-theme .menu-audio-btn.audio-off { background: rgba(46, 35, 28, 0.7); }
html.dark-theme #theme-toggle-btn { border-color: #6c5a8a; }

/* Обратная связь и счётчик онлайна */
html.dark-theme .feedback-trigger-btn,
html.dark-theme .feedback-bubble,
html.dark-theme #online-counter { background: rgba(36, 27, 22, 0.95); color: var(--dk-text); border-color: var(--dk-border); }
html.dark-theme .online-friends-extra { color: #6fd38c; }
html.dark-theme .room-friends-badge { color: #8be3a5; background: rgba(74, 222, 128, 0.14); }

/* Статус говорящего в чате (день): зелёная плашка становится тёмно-зелёной */
html.dark-theme #speaker-status {
    background: linear-gradient(135deg, #1e3a22 0%, #16301a 100%);
    border-color: #2e5a34;
}
html.dark-theme #speaker-status .speaker-label { color: #9be0a0; }
html.dark-theme #speaker-status .queue-info { color: var(--dk-text-2); }

/* ---------- ИГРОВЫЕ ПАНЕЛИ ДНЁМ: берут ночную раскраску ----------
   Ночью они и так тёмные (body.night-mode …). Значения скопированы из ночных
   правил выше по файлу — фон/колобки/выноски не трогаем. */
html.dark-theme body.day-mode #chat-panel {
    background: rgba(40, 25, 20, 0.95);
    color: #e8d5c4;
    border: 2px solid #8b5a3c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
html.dark-theme body.day-mode #chat-panel .chat-title {
    background: rgba(139, 90, 60, 0.3);
    border-bottom: 1px solid #8b5a3c;
    color: #e8d5c4;
}
html.dark-theme body.day-mode #chat-panel .chat-input-area {
    background: rgba(139, 90, 60, 0.2);
    border-top: 1px solid #8b5a3c;
}
html.dark-theme body.day-mode #chat-panel #chatInput {
    background: rgba(60, 40, 30, 0.8);
    border: 1px solid #8b5a3c;
    color: #e8d5c4;
}
html.dark-theme body.day-mode #chat-panel #chatInput::placeholder { color: #a08070; }
html.dark-theme body.day-mode #chat-panel #sendChatBtn { background: #8b5a3c; color: #fff; }
html.dark-theme body.day-mode #chat-panel .chat-message .sender { color: #ffcc88; }
html.dark-theme body.day-mode #chat-panel .chat-message.system { color: #a08070; }

html.dark-theme body.day-mode #phase-display,
html.dark-theme body.day-mode #phase-timer {
    background: rgba(40, 25, 20, 0.9);
    color: #e8d5c4;
    border: 2px solid #8b5a3c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

html.dark-theme body.day-mode #tts-toggle-btn:not(.active),
html.dark-theme body.day-mode #audio-toggle-btn:not(.active),
html.dark-theme body.day-mode #volume-mixer-btn:not(.active),
html.dark-theme body.day-mode #my-context-btn:not(.active),
html.dark-theme body.day-mode #help-floating-btn:not(.active),
html.dark-theme body.day-mode #room-settings-floating-btn:not(.active),
html.dark-theme body.day-mode #profile-floating-btn:not(.active),
html.dark-theme body.day-mode #speech-bubble-btn:not(.active),
html.dark-theme body.day-mode #spectators-btn:not(.active),
html.dark-theme body.day-mode #voice-btn:not(.active) {
    background: rgba(24, 22, 40, 0.85);
    color: #ebe7ff;
    border-color: rgba(132, 121, 182, 0.7);
}
html.dark-theme body.day-mode #tts-toggle-btn:not(.active):hover,
html.dark-theme body.day-mode #audio-toggle-btn:not(.active):hover,
html.dark-theme body.day-mode #volume-mixer-btn:not(.active):hover,
html.dark-theme body.day-mode #my-context-btn:not(.active):hover,
html.dark-theme body.day-mode #help-floating-btn:not(.active):hover,
html.dark-theme body.day-mode #room-settings-floating-btn:not(.active):hover,
html.dark-theme body.day-mode #profile-floating-btn:not(.active):hover,
html.dark-theme body.day-mode #speech-bubble-btn:not(.active):hover,
html.dark-theme body.day-mode #spectators-btn:not(.active):hover,
html.dark-theme body.day-mode #voice-btn:not(.active):hover {
    background: rgba(36, 32, 59, 0.93);
}
html.dark-theme body.day-mode #game-menu-btn:not(.active) {
    background: rgba(24, 22, 40, 0.85);
    color: #ebe7ff;
    border-color: rgba(132, 121, 182, 0.7);
}
html.dark-theme body.day-mode #game-menu-btn:not(.active):hover {
    background: rgba(36, 32, 59, 0.93);
    border-color: #6c63ff;
}

html.dark-theme body.day-mode #gesture-panel { background: rgba(50, 35, 25, 0.97); border-color: #6d4529; }
html.dark-theme body.day-mode .gesture-panel-title { color: #e8d5c4; }
html.dark-theme body.day-mode .gesture-section-label { color: #8a7565; }
html.dark-theme body.day-mode .gesture-item { border-color: #5a4030; background: #3a2b20; }
html.dark-theme body.day-mode .gesture-item:hover { border-color: #8a5836; background: #4a3828; }
html.dark-theme body.day-mode .gesture-item.gesture-number { color: #e8d5c4; }

/* Профиль модели: «в сети» = бот этого семейства сидит в комнате (17.10.2026) */
.mp-online-row {
    margin: 2px 0 10px;
    font-size: 13px;
    color: #5a4634;
    text-align: center;
}
html.dark-theme .mp-online-row { color: #d8c8b4; }

/* ============================================
   РЕДИЗАЙН 2.5: КАРТОЧКА ВХОДА (макет «Меню: гость», 25–27.10.2026)
   Раскладка из макета: имя, ниже персонаж — колобок слева, пол и
   редактор/профиль справа; «Войти в игру» во всю ширину; под ней вход в
   аккаунт или плашка аккаунта. Цвета и кнопки — СТАРЫЕ, игровые (Света,
   27.10.2026): коричневые кнопки без обводки, фиолетовый акцент у пола и
   редактора, никаких тёмных рамок у кнопок и бежевых подложек.
   Стоит в конце и с `body` в селекторе: старые правила карточки разбросаны
   по файлу (#name-panel, .name-panel-actions, order у кнопок).
   ============================================ */
body #name-panel {
    width: 380px;
    max-width: calc(100vw - 32px);
    min-width: 0;
    padding: 22px 26px;
    gap: 12px;
    align-items: stretch;
}
body #name-panel label[for="nameInput"] {
    text-align: center;
    font-size: 20px;
}
body #name-panel #nameInput {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.np-character {
    display: flex;
    align-items: center;
    gap: 12px;
}
body #avatar-preview-container {
    flex: none;
    width: 116px;
    height: 116px;
    margin: -6px 0;
    display: grid;
    place-items: center;
    cursor: pointer;
}
body #avatar-preview-container .avatar-large-preview {
    width: 124px;
    height: 124px;
    /* Колобок больше ячейки 116px: без отрицательного поля он вылезал вправо-вниз
       на 4px, а шапка (по центру ячейки) сидела левее и выше (Апрель, п.26) */
    margin: -4px;
}
.np-character-side {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
body #name-panel .gender-selector {
    order: 0;
    margin: 0;
    gap: 6px;
    justify-content: flex-start;
}
body #name-panel .gender-option { flex: 1 1 50%; }
body #name-panel .gender-label {
    flex: 1 1 auto;
    text-align: center;
    padding: 6px 8px;
    font-size: 13px;
    white-space: nowrap;
}
/* Редактор, профиль и записи — фиолетовые, как была кнопка редактора */
body #openAvatarEditorBtn,
body #openMyProfileBtn {
    padding: 8px 10px;
    font-size: 13px;
    white-space: nowrap;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
body #openAvatarEditorBtn:hover,
body #openMyProfileBtn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

body #name-panel .name-panel-actions {
    order: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* Главная кнопка — крупнее и с тенью; «Войти в аккаунт» второстепенная,
   другого цвета, чтобы их не путали (Света, 27.10.2026) */
body #name-panel #enterNameBtn {
    min-height: 52px;
    font-size: 19px;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 14px rgba(138, 88, 54, 0.45);
}
body #name-panel #enterNameBtn:hover { filter: brightness(1.08); }
body #name-panel #openAuthModalBtn {
    min-height: 40px;
    font-size: 14px;
    font-weight: 600;
    background: rgba(102, 126, 234, 0.12);
    color: #4c51bf;
    box-shadow: none;
}
body #name-panel #openAuthModalBtn:hover { background: rgba(102, 126, 234, 0.22); }
html.dark-theme body #name-panel #openAuthModalBtn { background: rgba(102, 126, 234, 0.2); color: #b4bdf8; }

.np-perks-link {
    align-self: center;
    margin-top: -4px;
    padding: 2px 6px;
    border: 0;
    background: transparent;
    color: #667eea;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.np-perks-link:hover { background: transparent; color: #764ba2; transform: none; box-shadow: none; }
/* Текст про регистрацию теперь в окне «Что даёт аккаунт» */
body #name-panel #auth-status { display: none; }

.account-plate {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 12px;
    border-radius: 8px;
    background: rgba(102, 126, 234, 0.1);
}
.account-plate-email {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #3a2b20;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-plate-email:hover { background: transparent; color: #764ba2; transform: none; box-shadow: none; }
#accountPlateLogoutBtn {
    padding: 5px 12px;
    font-size: 12px;
    background: #6c757d;
}
#accountPlateLogoutBtn:hover { background: #5a6268; }

/* Что даёт аккаунт */
.perks-modal-content { max-width: 540px; }
.perks-lead { margin: 4px 24px 12px; color: #6b5b4d; font-size: 14px; }
.perks-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 24px 8px;
}
.perk {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.07);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}
.perk span { font-size: 20px; line-height: 1; }
@media (max-width: 480px) {
    .perks-grid { grid-template-columns: 1fr; }
}

/* ===== Низ меню (редизайн 2.5): отдельные кнопки по углам, без заливки
   полосы — тёмная полоса визуально уменьшала экран (Света, 27.10.2026). ===== */
@media (min-width: 1001px) {
    body #feedback-corner.menu-bottom-bar {
        left: 16px;
        right: 16px;
        bottom: 16px;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        pointer-events: none;
    }
    body #feedback-corner.menu-bottom-bar > * { pointer-events: auto; }
    .menu-bar-spacer { flex: 1 1 auto; }
    body .menu-bottom-bar #beta-banner {
        max-width: none;
        margin: 0;
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 12px;
        white-space: nowrap;
    }
    body .menu-bottom-bar .menu-bar-install {
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 700;
        background: linear-gradient(135deg, #667eea, #764ba2);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    }
    body .menu-bottom-bar .feedback-bubble {
        position: absolute;
        right: 0;
        bottom: 40px;
        margin: 0;
    }
}
/* Значки Telegram и Boosty в левом нижнем углу, правее — «Установить» (2.5).
   z-index выше колонок меню: иначе край левой колонки перекрывал значок. */
.menu-bar-social {
    position: relative;
    z-index: 2;
    display: inline-flex;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}
.menu-bar-social svg { width: 100%; height: 100%; display: block; }
.menu-bar-social:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.22);
}
/* Телефон: полоса снова колонкой в углу, установка — отдельной кнопкой */
@media (max-width: 1000px) {
    .menu-bar-spacer { display: none; }
    body .menu-bottom-bar .menu-bar-install {
        order: -1;
        margin-bottom: 6px;
        padding: 6px 14px;
        font-size: 12px;
        border-radius: 20px;
        background: linear-gradient(135deg, #667eea, #764ba2);
    }
}

/* Тёмная тема для новых элементов */
html.dark-theme .account-plate { background: rgba(102, 126, 234, 0.16); }
html.dark-theme .account-plate-email { color: var(--dk-text); }
html.dark-theme .perk { background: rgba(102, 126, 234, 0.14); color: var(--dk-text); }
html.dark-theme .perks-lead { color: var(--dk-text-2); }
html.dark-theme .np-perks-link { color: #9aa8f5; }
/* Подсказка пасхалки раньше держала место всегда (visibility: hidden) —
   в новой карточке это дыра между именем и колобком. */
body #name-panel .special-name-hint:not(.visible) { display: none; }

/* ===== Левая колонка меню (редизайн 2.5) ===== */
/* Опрос и обновление больше не сворачиваются — это то, ради чего колонка */
.static-card .side-card-title { cursor: default; }
.static-card:not(.changelog-card) .side-card-title:hover { background: transparent; }
/* У обновления шапка фиолетовая — при наведении остаётся своей */
.changelog-card.static-card .side-card-title:hover { background: linear-gradient(90deg, #3b0d7a, #5b21b6); }
.static-card .side-card-title::after { content: none; }
.static-card .side-card-body {
    max-height: none;
    padding: 10px 16px 14px;
}

/* Опрос */
.poll-side-card .side-card-title { gap: 8px; }
.poll-side-title { flex: 1 1 auto; }
.poll-side-pager {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #8a7565;
}
.poll-side-pager:empty { display: none; }
.poll-pager-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(102, 126, 234, 0.12);
    color: #4c51bf;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.poll-pager-btn:hover { background: rgba(102, 126, 234, 0.24); }
.poll-card-options {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 6px;
}
.poll-card-options.expanded {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 2px;
}
.poll-card-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 30px;
    padding: 4px 10px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #3a2b20;
    font-size: 12px;
    text-align: left;
    overflow: hidden;
    cursor: pointer;
}
.poll-card-option:hover:not(:disabled) { border-color: rgba(102, 126, 234, 0.45); }
.poll-card-option:disabled { cursor: default; }
.poll-card-option.mine { border-color: #667eea; }
.poll-card-option-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.2);
    transition: width 0.35s ease;
}
.poll-card-option.mine .poll-card-option-fill { background: rgba(102, 126, 234, 0.32); }
.poll-card-option-label {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.poll-card-option-pct {
    position: relative;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.poll-card-more-btn {
    width: 100%;
    margin-bottom: 6px;
    padding: 4px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #667eea;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.poll-card-more-btn:hover { background: rgba(102, 126, 234, 0.08); }

/* Обновление */
.changelog-card .side-card-title { gap: 8px; }
.changelog-date {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
}
.changelog-card.static-card .side-card-body { padding-top: 4px; }
.changelog-card .side-card-body ul {
    max-height: 110px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
    mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.changelog-history-link {
    padding: 0;
    border: none;
    background: transparent;
    color: #667eea;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.changelog-history-link:hover { text-decoration: underline; }
/* Окно «Обновления»: текущая версия крупно и удобно для чтения,
   прошлые — свёрнутыми строками ниже */
.changelog-current { margin-bottom: 14px; }
.changelog-current-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
    color: #4d2a78;
}
.changelog-current-title span { font-size: 13px; font-weight: 600; opacity: 0.7; }
.changelog-current-list {
    margin: 0;
    padding-left: 28px;
    font-size: 14px;
    line-height: 1.55;
    color: #3a2b20;
}
.changelog-current-list li { padding: 3px 0; }
.changelog-current-list li::marker { color: #764ba2; font-weight: 700; }
.changelog-history-past {
    margin: 4px 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #8a7565;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.changelog-history-version-block + .changelog-history-version-block { margin-top: 6px; }
.changelog-history-version-block .changelog-history-title { cursor: pointer; }
.changelog-history-version-block .changelog-history-title::before { content: '▾ '; }
.changelog-history-version-block.collapsed .changelog-history-title { margin: 0; }
.changelog-history-version-block.collapsed .changelog-history-title::before { content: '▸ '; }
.changelog-history-version-block.collapsed > :not(.changelog-history-title) { display: none; }
html.dark-theme .changelog-current-title { color: #e9d5ff; }
html.dark-theme .changelog-current-list { color: var(--dk-text); }
html.dark-theme .changelog-history-past { color: var(--dk-muted); }

/* Об игре / От автора: карточка — просто кнопка, открывает окно */
button.about-game-card {
    width: 100%;
    font: inherit;
    text-align: left;
    color: inherit;
    cursor: pointer;
}
.about-game-card .side-card-title::after {
    content: '→';
    font-size: 14px;
    transform: none;
}
.about-tabs {
    display: flex;
    gap: 4px;
    margin: 10px 0 8px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
}
.about-tab {
    flex: 1 1 0;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #5a4a3a;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.about-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.about-modal-content { max-width: 620px; }
.about-tabs-big { margin: 18px 24px 4px; }
.about-tabs-big .about-tab { font-size: 15px; padding: 8px 10px; }
.about-pane {
    padding: 8px 24px;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.55;
    color: #3a2b20;
}
.about-pane ul { margin: 0; padding-left: 0; list-style: none; }
.about-pane li { margin-bottom: 8px; }
.about-pane p { margin: 0 0 10px; }

html.dark-theme .poll-card-option { background: rgba(255, 255, 255, 0.06); color: var(--dk-text); }
html.dark-theme .poll-pager-btn,
html.dark-theme .poll-card-more-btn,
html.dark-theme .changelog-history-link { color: #9aa8f5; }
html.dark-theme .poll-side-pager { color: var(--dk-muted); }
html.dark-theme .about-tabs { background: rgba(255, 255, 255, 0.06); }
html.dark-theme .about-tab:not(.active) { color: var(--dk-text); }
html.dark-theme .about-pane { color: var(--dk-text); }
/* Колонки шире (как в макете), заголовки карточек в одну строку */
@media (min-width: 1001px) {
    .menu-layout { grid-template-columns: 300px 1fr 300px; }
}
.static-card .side-card-title { font-size: 14px; white-space: nowrap; }
.poll-side-title,
.changelog-card-name { overflow: hidden; text-overflow: ellipsis; }
.poll-side-pager { white-space: nowrap; flex: none; }

/* ===== Правая колонка меню (редизайн 2.5) ===== */
/* Профиль открывается из карточки входа — боковая карточка больше не нужна */
#profile-stats-card { display: none; }

/* Таблица лидеров: в карточке первые пять строк, сезоны — только в окне */
.leaderboard-card #leaderboard-card-body .leaderboard-season,
.leaderboard-card #leaderboard-card-body .leaderboard-season-note { display: none; }
/* Три строки, а не пять: место под посты «Сообщества» (2.5) — с картинкой
   текст поста иначе не помещался. Полная таблица — в окне «Все →». */
.leaderboard-card #leaderboard-card-body .leaderboard-row:nth-child(n+4) { display: none; }
.leaderboard-card #leaderboard-card-body #global-stats-content {
    max-height: 150px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
    mask-image: linear-gradient(to bottom, #000 75%, transparent);
}
.leaderboard-card .changelog-history-link { margin-top: 8px; }
.leaderboard-modal-content { width: min(520px, calc(100vw - 24px)); max-width: none; }
.leaderboard-modal-slot .leaderboard-row { font-size: 14px; padding: 8px 12px; }
.leaderboard-modal-slot .leaderboard-xp,
.leaderboard-modal-slot .leaderboard-wr { font-size: 13px; }
.leaderboard-modal-slot {
    padding: 4px 24px 8px;
    max-height: 65vh;
    overflow-y: auto;
}

/* Сообщество */
.community-card .side-card-title { gap: 8px; }
.community-card-name { flex: 1 1 auto; }
.community-compose-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.community-mini {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 340px;
    overflow-y: auto;
    margin-bottom: 8px;
}
/* Длинный пост в «Сообществе» выталкивал таблицу лидеров за экран (2.5).
   Правая колонка не задаёт высоту ряда (height: 0), а растягивается до
   соседних колонок (min-height: 100% — в гриде считается от области ячейки).
   Лента сжимается и крутится внутри, таблица лидеров всегда целиком. */
@media (min-width: 1001px) {
    .menu-layout > .menu-right {
        align-self: stretch;
        height: 0;
        /* Нижний предел: когда левая колонка короткая (опросов нет), лента
           сжималась до фото и даты, а то и пропадала совсем. */
        min-height: max(100%, min(540px, 100vh - 260px));
        box-sizing: border-box;
    }
    .menu-right > .community-card {
        flex: 0 1 auto;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .menu-right > .community-card > .side-card-body {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .menu-right > .community-card .community-mini { flex: 1 1 auto; min-height: 0; max-height: none; }
    .menu-right > .community-card .changelog-history-link { flex: none; }
    .menu-right > .leaderboard-card { flex: none; }

    /* Апрель, п.21: при 100% на 1366×768 левая колонка (опрос + обновление +
       «Об игре») уходила под край экрана — «Об игре» прятался под плашкой
       онлайна, а низ таблицы лидеров (правая колонка тянется до левой) — под
       «Игра в разработке». Колонки не ниже экрана минус шапка (~180px) и нижние
       кнопки (~60px); опрос и обновление сжимаются и крутятся внутри. */
    .menu-layout > .menu-left {
        max-height: max(420px, 100vh - 245px);
        box-sizing: border-box;
    }
    .menu-layout > .menu-right {
        max-height: max(420px, 100vh - 245px);
    }
    .menu-left > .poll-side-card,
    .menu-left > .changelog-card {
        flex: 0 1 auto;
        min-height: 110px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .menu-left > .poll-side-card > .side-card-body,
    .menu-left > .changelog-card > .side-card-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
    .menu-left > .poll-side-card > .side-card-title,
    .menu-left > .changelog-card > .side-card-title,
    .menu-left > .about-game-card { flex: none; }
}
.community-empty {
    padding: 14px 6px;
    text-align: center;
    font-size: 13px;
    color: #8a7565;
}
.community-mini-post {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.04);
    color: #3a2b20;
    text-align: left;
    overflow: hidden;
    cursor: pointer;
    flex: none;
}
.community-mini-post:hover { background: rgba(102, 126, 234, 0.1); }
.community-mini-post.big { padding: 0 0 8px; }
.community-mini-post.big > span { padding: 0 10px; }
.community-mini-post.big .community-mini-meta { padding-top: 8px; }
.community-mini-photo {
    width: 100%;
    height: 96px;
    object-fit: cover;
    display: block;
}
.community-mini-meta { font-size: 11px; color: #8a7565; font-weight: 600; }
.community-pin { margin-right: 4px; }
.community-mini-title { font-size: 13px; font-weight: 700; line-height: 1.3; }
.community-mini-text {
    font-size: 12px;
    line-height: 1.4;
    color: #5a4a3a;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.community-mini-text.short,
.community-mini.several .community-mini-text { -webkit-line-clamp: 2; line-clamp: 2; }
.community-mini.several .community-mini-photo { height: 64px; }
/* Запись не сжимается: не хватает места — лента крутится, а не сплющивает записи */
.community-mini-post { flex-shrink: 0; }

/* Окно ленты */
.community-modal-content { max-width: 640px; width: calc(100vw - 24px); }
.community-modal-content.with-editor { max-width: 960px; }
.community-modal-main {
    display: flex;
    gap: 16px;
    padding: 0 24px;
    max-height: 70vh;
}
.community-list {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 4px 8px 0;
}
.community-post {
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.05);
}
.community-post-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.community-post-date { font-size: 12px; color: #8a7565; font-weight: 600; }
.community-post-tools { display: flex; gap: 4px; }
.community-post-tools button {
    padding: 3px 8px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.06);
    color: #3a2b20;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.community-post-tools button:hover { background: rgba(0, 0, 0, 0.12); }
.community-post-tools button.armed { background: #dc3545; color: #fff; }
.community-post-title { margin: 6px 0 4px; font-size: 17px; color: #3a2b20; }
.community-post-text {
    font-size: 14px;
    line-height: 1.55;
    color: #3a2b20;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.community-post-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 10px;
}
.community-post-photos img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}
.community-text-link { color: #5a67d8; text-decoration: underline; overflow-wrap: anywhere; }
html.dark-theme .community-text-link { color: #a3b1ff; }
.community-post-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.community-post-links a {
    padding: 4px 12px;
    border-radius: 99px;
    background: rgba(102, 126, 234, 0.14);
    color: #4c51bf;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}
.community-post-links a:hover { background: rgba(102, 126, 234, 0.24); }

/* Редактор записи */
.community-editor {
    flex: none;
    width: 290px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.03);
}
.community-editor-title { font-size: 15px; font-weight: 700; color: #3a2b20; }
.community-editor label,
.community-editor-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #6b5b4d;
}
.community-editor input[type="text"],
.community-editor textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 400;
    color: #3a2b20;
    resize: vertical;
}
.community-editor input[type="text"]:focus,
.community-editor textarea:focus { border-color: #667eea; outline: none; }
.community-photos-edit { display: flex; gap: 6px; flex-wrap: wrap; }
.community-photo-thumb,
.community-photo-add {
    position: relative;
    width: 64px;
    height: 48px;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}
.community-photo-thumb { border: none; }
.community-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.community-photo-thumb span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    opacity: 0;
}
.community-photo-thumb:hover span { opacity: 1; }
.community-photo-add {
    border: 2px dashed #667eea;
    background: transparent;
    color: #667eea;
    font-size: 20px;
}
.community-link-row { display: flex; gap: 4px; }
.community-link-row input { min-width: 0; }
.community-link-row button { flex: none; padding: 4px 10px; }
.community-link-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-weight: 600;
    color: #4c51bf;
}
.community-link-chip span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-link-chip button { border: none; background: transparent; cursor: pointer; color: #8a7565; }
.community-editor .community-pin-row { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: #3a2b20; cursor: pointer; }
.community-editor-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 760px) {
    .community-modal-main { flex-direction: column; overflow-y: auto; }
    .community-list { overflow: visible; }
    .community-editor { width: auto; overflow: visible; }
}

html.dark-theme .community-mini-post { background: rgba(255, 255, 255, 0.05); color: var(--dk-text); }
html.dark-theme .community-mini-text,
html.dark-theme .community-post-text,
html.dark-theme .community-post-title,
html.dark-theme .community-editor-title { color: var(--dk-text); }
html.dark-theme .community-post { background: rgba(102, 126, 234, 0.1); }
html.dark-theme .community-editor { background: rgba(255, 255, 255, 0.04); }
html.dark-theme .community-post-tools button { background: rgba(255, 255, 255, 0.08); color: var(--dk-text); }
html.dark-theme .community-post-links a,
html.dark-theme .community-link-chip { color: #b4bdf8; }

/* ===== 2.6 п.21: комментарии к записям «Сообщества» ===== */
.community-comments-toggle {
    margin-top: 10px;
    padding: 4px 10px;
    border: none;
    border-radius: 99px;
    background: rgba(0, 0, 0, 0.05);
    color: #6b5848;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.community-comments-toggle:hover,
.community-comments-toggle.open { background: rgba(102, 126, 234, 0.16); color: #4c51bf; }
.community-comments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.community-comments[hidden] { display: none; }
.community-comments-empty,
.community-comments-guest { font-size: 12px; color: #8a7565; text-align: center; padding: 4px 0; }
.community-comment {
    padding: 8px 10px;
    border-radius: 10px;
    background: #fff;
}
.community-comment-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: #3a2b20; }
.community-comment-time { font-size: 11px; color: #8a7565; }
.community-comment-del {
    margin-left: auto;
    padding: 1px 6px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 11px;
    cursor: pointer;
    opacity: 0.6;
}
.community-comment-del:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
.community-comment-del.armed { opacity: 1; background: #dc3545; color: #fff; }
.community-comment-text {
    margin-top: 3px;
    font-size: 13px;
    line-height: 1.45;
    color: #3a2b20;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.community-comment-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.community-comment-photos img {
    max-width: 160px;
    max-height: 120px;
    border-radius: 8px;
    display: block;
}
.community-comment-form { display: flex; flex-direction: column; gap: 6px; }
.community-comment-form textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
}
.community-comment-tray { display: flex; gap: 6px; flex-wrap: wrap; }
.community-comment-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.community-comment-attach {
    padding: 0 4px;
    border: none;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.7;
}
.community-comment-attach:hover { opacity: 1; }
.community-comment-send {
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
html.dark-theme .community-comments-toggle { background: rgba(255, 255, 255, 0.06); color: var(--dk-text); }
html.dark-theme .community-comment { background: rgba(255, 255, 255, 0.05); }
html.dark-theme .community-comment-head,
html.dark-theme .community-comment-text { color: var(--dk-text); }
html.dark-theme .community-comment-form textarea { background: rgba(255, 255, 255, 0.05); color: var(--dk-text); border-color: rgba(255, 255, 255, 0.12); }

/* ===== Таблица лидеров (редизайн 2.5): вкладки и сезоны единым переключателем
   в фиолетовом акценте, топ-3 подсвечены, «Сервер» — только в окне ===== */
body .leaderboard-tabs,
body .leaderboard-season {
    gap: 3px;
    margin: 0 0 8px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
}
body .leaderboard-tab-btn,
body .leaderboard-season-btn {
    padding: 5px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    color: #5a4a3a;
    font-size: 12px;
    font-weight: 600;
}
body .leaderboard-tab-btn:hover,
body .leaderboard-season-btn:hover { background: rgba(102, 126, 234, 0.1); }
body .leaderboard-tab-btn.active,
body .leaderboard-season-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.leaderboard-card #leaderboard-card-body .leaderboard-tab-btn[data-lb-tab="server"] { display: none; }

.leaderboard-list { gap: 3px; }
body .leaderboard-row {
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.03);
}
body .leaderboard-row.leaderboard-clickable:hover {
    background: rgba(102, 126, 234, 0.12);
    transform: none;
}
body .leaderboard-row.lb-top1 { background: linear-gradient(90deg, rgba(255, 196, 0, 0.28), rgba(255, 196, 0, 0.06)); }
body .leaderboard-row.lb-top2 { background: linear-gradient(90deg, rgba(160, 170, 185, 0.32), rgba(160, 170, 185, 0.06)); }
body .leaderboard-row.lb-top3 { background: linear-gradient(90deg, rgba(205, 127, 50, 0.26), rgba(205, 127, 50, 0.05)); }
body .leaderboard-row.lb-top1 .leaderboard-name,
body .leaderboard-row.lb-top2 .leaderboard-name,
body .leaderboard-row.lb-top3 .leaderboard-name { font-weight: 700; }
body .leaderboard-row.leaderboard-me { box-shadow: inset 0 0 0 2px #667eea; }
body .leaderboard-xp { color: #5a67d8; }
.leaderboard-gap {
    text-align: center;
    line-height: 1;
    color: #a08060;
    margin: 2px 0;
}
.leaderboard-modal-slot .leaderboard-my-place { display: none; }

/* Сами контейнеры вкладок тоже носят класс .leaderboard-placeholder (это их
   «Загрузка…») — список в них должен тянуться на всю ширину */
body #leaderboard-content,
body #model-leaderboard-content {
    align-items: stretch;
    padding: 0;
    text-align: left;
}
/* Пустая таблица в карточке — одной строкой, без огромного кубка */
.leaderboard-card #leaderboard-card-body .leaderboard-placeholder .leaderboard-placeholder {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    padding: 10px 4px;
    text-align: left;
}
.leaderboard-card #leaderboard-card-body .leaderboard-placeholder .leaderboard-lock { font-size: 20px; }
.leaderboard-card #leaderboard-card-body .leaderboard-placeholder .leaderboard-placeholder p { font-size: 12px; }

html.dark-theme body .leaderboard-tabs,
html.dark-theme body .leaderboard-season { background: rgba(255, 255, 255, 0.06); }
html.dark-theme body .leaderboard-tab-btn,
html.dark-theme body .leaderboard-season-btn { background: transparent; color: var(--dk-text); }
html.dark-theme body .leaderboard-tab-btn.active,
html.dark-theme body .leaderboard-season-btn.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
html.dark-theme body .leaderboard-row { background: rgba(255, 255, 255, 0.04); }
html.dark-theme body .leaderboard-xp { color: #9aa8f5; }

/* ===== Экран комнат (редизайн 2.5) ===== */
/* Комната в списке: две строки слева, роли и два значка справа */
#rooms-list .room-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin: 0 0 8px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
}
#rooms-list .room-item:hover { border-color: #8a5836; }
#rooms-list .room-info-left {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.room-line-1,
.room-line-2 {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
}
.room-title {
    font-weight: 700;
    font-size: 15px;
    color: #3a2b20;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.room-line-1 .room-setting-badge { flex: none; }
.room-playing {
    flex: none;
    padding: 1px 8px;
    border-radius: 10px;
    background: #fde8e8;
    color: #a02828;
    font-size: 11px;
    font-weight: 600;
}
.room-line-2 { font-size: 12px; color: #666; }
.room-count { font-weight: 600; color: #2f9838; }
.room-count.full { color: #c0392b; }
.room-roles {
    flex: none;
    font-size: 18px;
    letter-spacing: 2px;
}
#rooms-list .room-spectate-btn,
#rooms-list .room-settings-btn {
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
#rooms-list .room-spectate-btn { background: #4a4a6b; }
#rooms-list .room-settings-btn { background: #8a5836; }
#rooms-list .room-spectate-btn:hover { background: #5c5c82; }
#rooms-list .room-settings-btn:hover { background: #9a6b4a; }

/* Лобби: в комнате оно занимает всю правую панель */
.rooms-right:has(> #lobby:not([style*="none"])) {
    display: flex;
    flex-direction: column;
}
body #lobby {
    margin-top: 0;
    padding: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
/* JS показывает лобби через style="display: block" — flex нужен поверх него */
body #lobby:not([style*="none"]) { display: flex !important; flex: 1 1 auto; }
body #lobby #lobby-room-name { margin: 0; font-size: 20px; }
body #lobby #room-flags-badges { margin: -4px 0 0 !important; }
body #lobby .lobby-rejoin-bar { margin: 0; }
body #lobby #lobby-players {
    flex: 1 1 auto;
    min-height: 260px;
    padding: 12px 16px;
    background: #f8f4f0;
    border-radius: 12px;
}

/* Значки-кнопки */
.lobby-ico-btn {
    flex: none;
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}
.lobby-ico-blue { background: #4a90d9; }
.lobby-ico-red { background: #d94a4a; }
.lobby-ico-gold { background: #e6a817; }
.lobby-ico-violet { background: #7b5ea7; }
.lobby-ico-grey { background: #6c757d; }
.lobby-ico-ink { background: #4a4a6b; }
.lobby-ico-btn:hover { filter: brightness(1.1); }
.lobby-ico-blue:hover { background: #4a90d9; }
.lobby-ico-red:hover { background: #d94a4a; }
.lobby-ico-gold:hover { background: #e6a817; }
.lobby-ico-violet:hover { background: #7b5ea7; }
.lobby-ico-grey:hover { background: #6c757d; }
.lobby-ico-ink:hover { background: #4a4a6b; }
#promoBalanceBadge { font-size: 12px; font-weight: 700; margin-left: 4px; }
#promoBalanceBadge:empty { display: none; }

/* Строка владельца */
body #bot-controls {
    margin: 0 !important;
    align-items: center;
    gap: 6px;
}
.lobby-ico-spacer { flex: 1 1 auto; }
/* Переключатели партии значками: включён — фиолетовая рамка, выключен — блёкло */
.lobby-switch {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    font-size: 18px;
    cursor: pointer;
    box-shadow: inset 0 0 0 2px transparent;
    transition: background 0.15s, box-shadow 0.15s;
}
.lobby-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.lobby-switch span { filter: grayscale(1); opacity: 0.45; transition: filter 0.15s, opacity 0.15s; }
.lobby-switch:has(input:checked) {
    background: rgba(102, 126, 234, 0.14);
    box-shadow: inset 0 0 0 2px #667eea;
}
.lobby-switch:has(input:checked) span { filter: none; opacity: 1; }
.lobby-switch:has(input:focus-visible) { outline: 2px solid #667eea; outline-offset: 2px; }

/* Низ: «Начать игру» широкая, остальное значками */
.lobby-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.lobby-actions #startGameBtn {
    flex: 1 1 auto;
    height: 46px;
    padding: 0 16px;
    background: #2f9838;
    font-size: 17px;
    font-weight: 600;
}
.lobby-actions #startGameBtn:hover { background: #38a842; }
.lobby-actions .lobby-ico-btn { height: 46px; min-width: 46px; font-size: 20px; }
.lobby-actions #leaveRoomBtn { height: 46px; padding: 0 18px; font-size: 14px; }
.lobby-wait-note {
    flex: 1 1 auto;
    font-size: 14px;
    color: #8a7565;
}
.lobby-actions:has(> #startGameBtn:not([style*="none"])) .lobby-wait-note { display: none; }

html.dark-theme #rooms-list .room-item { background: rgba(255, 255, 255, 0.05); border-color: var(--dk-border); }
html.dark-theme .room-title { color: var(--dk-text); }
html.dark-theme .room-line-2 { color: var(--dk-muted); }
html.dark-theme body #lobby #lobby-players { background: rgba(255, 255, 255, 0.04); }
html.dark-theme .lobby-switch { background: rgba(255, 255, 255, 0.06); }
html.dark-theme .lobby-wait-note { color: var(--dk-muted); }
/* Название комнаты не обрезаем — переносим, бейджи уходят на следующую строку */
.room-line-1 { flex-wrap: wrap; white-space: normal; row-gap: 4px; }
.room-title { white-space: normal; overflow-wrap: anywhere; text-overflow: clip; }
.room-roles { font-size: 13px; letter-spacing: 1px; }

/* ===== Окно «Создание комнаты» (редизайн 2.5) ===== */
#create-room-modal .modal-content.crm {
    width: min(980px, calc(100vw - 24px));
    max-width: none;
    height: min(700px, calc(100vh - 24px));
    max-height: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.crm-head {
    flex: none;
    padding: 18px 26px 14px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.crm-title-row { display: flex; align-items: center; }
.crm-title { flex: 1 1 auto; font-size: 22px; font-weight: 700; color: #3a2b20; }
.crm-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #f1ebe2;
    color: #3a2b20;
    font-size: 15px;
}
.crm-close:hover { background: #e6dccf; }
.crm-name-row { display: flex; align-items: center; gap: 14px; }
.crm-name-row #newRoomName { flex: 1 1 auto; min-width: 0; font-size: 16px; }
.crm-code { position: relative; flex: none; width: 190px; }
.crm-code.hidden { display: none; }
.crm-code input { width: 100%; box-sizing: border-box; padding-right: 40px; }
.crm-eye {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #f1ebe2;
    font-size: 14px;
}
.crm-eye:hover { background: #e6dccf; }

.crm-body { flex: 1 1 auto; min-height: 0; display: flex; }
.crm-nav {
    flex: none;
    width: 214px;
    padding: 12px 10px;
    background: #faf7f3;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.crm-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #3a2b20;
    text-align: left;
}
.crm-tab:hover { background: rgba(102, 126, 234, 0.08); }
.crm-tab.active { background: #fff; box-shadow: inset 3px 0 0 #667eea, 0 1px 4px rgba(0, 0, 0, 0.06); }
.crm-tab-ico { width: 26px; font-size: 20px; text-align: center; flex: none; }
.crm-tab-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.crm-tab-text > span { font-size: 15px; font-weight: 600; }
.crm-tab-text small {
    font-size: 12px;
    color: #8a7565;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-panes { flex: 1 1 auto; min-width: 0; padding: 22px 28px; overflow-y: auto; }
.crm-pane { display: flex; flex-direction: column; gap: 18px; }
.crm-pane[hidden] { display: none; }
.crm-pane-fill { height: 100%; }
.crm-lbl { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: #6b5b4d; }
.crm-hint { font-size: 12px; color: #8a7a68; line-height: 1.4; }
.crm-muted { color: #8a7a68; font-weight: 400; }
.crm-indent { margin-left: 25px; }
.crm-sep { border-top: 1px solid #eee; }
.crm-chk { display: flex; align-items: center; gap: 8px; font-size: 15px; color: #3a2b20; cursor: pointer; }
.crm-chk input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: #8a5836; flex: none; }
.crm-strong { font-weight: 600; }
.crm-small { font-size: 13px; }
.crm-align-end { align-self: end; padding-bottom: 10px; }
.crm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; align-items: start; }
.crm-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.crm-contents { display: contents; }
.crm-contents.hidden { display: none; }
.crm-grid3 .form-field { margin: 0; }
.crm-panes select,
.crm-panes input[type="number"] { width: 100%; box-sizing: border-box; }
.crm-checks { gap: 12px 20px; }
.crm-inline { display: flex; gap: 8px; }
.crm-inline select { flex: 1 1 auto; }
.crm-inline #maxRevotesField { flex: none; width: 64px; margin: 0; }
.crm-inline #maxRevotesField.hidden { display: none; }
.crm-num { width: 64px !important; padding: 5px 8px; }

/* Число игроков */
.crm-steppers { display: flex; flex-wrap: wrap; gap: 22px; }
.crm-stepper { display: flex; align-items: center; gap: 8px; }
.crm-stepper label { width: 72px; font-size: 14px; color: #777; }
.crm-stepper button {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #f1ebe2;
    color: #3a2b20;
    font-size: 18px;
}
.crm-stepper button:hover { background: #e6dccf; }
.crm-stepper input {
    width: 52px !important;
    padding: 6px 4px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    -moz-appearance: textfield;
}
.crm-stepper input::-webkit-inner-spin-button,
.crm-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.crm-god-card {
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(156, 39, 176, 0.05);
    border: 1px solid rgba(156, 39, 176, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Сеттинг */
.crm-setting-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: #555; }
#setting-selector.crm-settings-grid {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    grid-template-columns: repeat(5, 1fr);
    align-content: start;
}
#setting-selector.crm-settings-grid:not(.show-dev) .setting-locked,
#rs-setting-selector.crm-settings-grid:not(.show-dev) .setting-locked { display: none; }

/* Роли */
.crm-roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.crm-role-card {
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid #eee;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.crm-role-card[hidden] { display: none; }
.crm-role-card:has(input:checked) { border-color: rgba(102, 126, 234, 0.55); background: rgba(102, 126, 234, 0.04); }
.crm-role-card .role-checkbox { margin: 0; }
.crm-role-extra { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #666; }
.crm-role-extra label { flex: 1 1 auto; }
.crm-role-extra select { width: 100px !important; padding: 5px 8px; font-size: 13px; }
/* «Сколько» и самолечение имеют смысл, только когда роль включена */
.crm-role-card:not(:has(.role-checkbox input:checked)) .crm-role-extra,
.crm-role-card:not(:has(.role-checkbox input:checked)) > .crm-chk { opacity: 0.4; pointer-events: none; }

@media (max-width: 760px) {
    .crm-body { flex-direction: column; }
    .crm-nav { width: auto; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid #eee; }
    .crm-tab { width: auto; flex: none; }
    .crm-tab-text small { display: none; }
    .crm-name-row { flex-wrap: wrap; }
    .crm-roles, .crm-grid3 { grid-template-columns: 1fr 1fr; }
    .crm-grid2 { grid-template-columns: 1fr; }
    #setting-selector.crm-settings-grid { grid-template-columns: repeat(3, 1fr); }
}

html.dark-theme .crm-head,
html.dark-theme .crm-nav { border-color: var(--dk-border); }
html.dark-theme .crm-nav { background: rgba(255, 255, 255, 0.03); }
html.dark-theme .crm-title,
html.dark-theme .crm-tab,
html.dark-theme .crm-chk { color: var(--dk-text); }
html.dark-theme .crm-tab.active { background: rgba(255, 255, 255, 0.06); }
html.dark-theme .crm-role-card { background: rgba(255, 255, 255, 0.03); border-color: var(--dk-border); }
html.dark-theme .crm-close,
html.dark-theme .crm-eye,
html.dark-theme .crm-stepper button { background: rgba(255, 255, 255, 0.08); color: var(--dk-text); }
/* Поля окна создания — в стиле остальных форм игры */
.crm input[type="text"],
.crm input[type="password"],
.crm input[type="number"],
.crm select {
    padding: 9px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #3a2b20;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.crm input:focus,
.crm select:focus { border-color: #8a5836; outline: none; }
.crm .crm-name-row #newRoomName { padding: 10px 14px; font-size: 16px; }
#create-room-modal .crm .modal-footer {
    flex: none;
    margin: 0;
    padding: 14px 26px;
    border-top: 1px solid #eee;
}
#create-room-modal .crm .modal-footer button { padding: 11px 26px; font-size: 16px; }
html.dark-theme .crm input,
html.dark-theme .crm select { background: rgba(255, 255, 255, 0.06); border-color: var(--dk-border); color: var(--dk-text); }

/* ===== Окно настроек уже созданной комнаты — та же раскладка (редизайн 2.5) ===== */
#room-settings-modal .modal-content.crm {
    width: min(980px, calc(100vw - 24px));
    max-width: none;
    height: min(700px, calc(100vh - 24px));
    max-height: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#room-settings-modal .modal-content.crm-view { width: min(820px, calc(100vw - 24px)); height: min(560px, calc(100vh - 24px)); }
#room-settings-modal .crm .modal-footer {
    flex: none;
    margin: 0;
    padding: 14px 26px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
#room-settings-modal .crm .modal-footer button { padding: 11px 26px; font-size: 16px; }
.crm-revotes { flex: none; width: 64px; }
.crm-revotes.hidden { display: none; }
.crm-view-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 9px 0;
    border-bottom: 1px solid #f0ebe4;
    font-size: 14px;
    color: #6b5b4d;
}
.crm-view-row b { color: #3a2b20; font-weight: 600; text-align: right; }
.crm-pane:has(> .crm-view-row) { gap: 0; }
.crm-view-setting { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.crm-view-setting span { font-size: 40px; }
html.dark-theme .crm-view-row { border-color: var(--dk-border); color: var(--dk-muted); }
html.dark-theme .crm-view-row b { color: var(--dk-text); }
.crm .crm-name-row > input[type="text"] { flex: 1 1 auto; min-width: 0; padding: 10px 14px; font-size: 16px; }

/* Шапка лобби: название, 🔒, справа код и роли (редизайн 2.5) */
.lobby-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
body #lobby .lobby-head #lobby-room-name { flex: 0 1 auto; min-width: 0; margin: 0; }
.lobby-room-lock { flex: none; font-size: 18px; }
.lobby-head-spacer { flex: 1 1 auto; }
.lobby-room-code {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border-radius: 8px;
    background: #f8f4f0;
    font-size: 13px;
    color: #6f5848;
}
.lobby-room-code[hidden] { display: none; }
.lobby-room-code b { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; color: #3a2b20; }
.lobby-room-code button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #ece3d8;
    font-size: 14px;
}
.lobby-room-code button:hover { background: #e0d4c5; }
.lobby-room-roles { flex: none; font-size: 20px; letter-spacing: 3px; }
html.dark-theme .lobby-room-code { background: rgba(255, 255, 255, 0.06); color: var(--dk-muted); }
html.dark-theme .lobby-room-code b { color: var(--dk-text); }
html.dark-theme .lobby-room-code button { background: rgba(255, 255, 255, 0.1); }
/* Шапка в две строки: название отдельно, ниже флаги слева, код и роли справа */
.lobby-head { align-items: flex-start; }
body #lobby .lobby-head #lobby-room-name { flex: 0 1 auto; overflow-wrap: anywhere; max-height: none; line-height: 1.25; }
.lobby-room-lock { line-height: 1.4; }
.lobby-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: -6px; }
.lobby-meta:not(:has(#room-flags-badges[style*="flex"])):not(:has(.lobby-room-code:not([hidden]))):has(.lobby-room-roles:empty) { display: none; }
.lobby-room-roles { font-size: 14px; letter-spacing: 1px; white-space: nowrap; }
.lobby-room-roles:empty { display: none; }
.lobby-room-code { padding: 2px 3px 2px 8px; font-size: 12px; }
.lobby-room-code button { width: 22px; height: 22px; font-size: 12px; }

/* ===== Окно «Добавить бота» — две колонки (редизайн 2.5) ===== */
#bot-config-modal { align-items: center; }
#bot-config-modal .modal-content.bcm {
    width: min(920px, calc(100vw - 24px));
    max-width: none;
    height: min(680px, calc(100vh - 24px));
    max-height: none;
    margin: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.bcm-head {
    flex: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 16px 24px;
    border-bottom: 1px solid #eee;
}
#bot-config-modal .bcm-head .bcm-title {
    position: static;
    flex: 1 1 auto;
    margin: 0;
    padding: 0;
    font-size: 21px;
    background: none;
}
.bcm-presets { display: flex; align-items: center; gap: 8px; margin: 0; }
.bcm-presets label { margin: 0; font-size: 13px; color: #777; font-weight: normal; }
.bcm-presets select { width: 230px; padding: 7px 10px; }
.bcm-preset-hint { flex-basis: 100%; font-size: 12px; color: #999; text-align: right; }
.bcm-preset-hint:empty { display: none; }
.bcm-ico {
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #f1ebe2;
    color: #3a2b20;
    font-size: 15px;
    cursor: pointer;
}
.bcm-ico:hover { background: #e6dccf; }
.bcm-ico-brown { background: #8a5836; }
.bcm-ico-brown:hover { background: #9a6b4a; }
.bcm-ico-blue { background: #4a90d9; color: #fff; }
.bcm-ico-blue:hover { background: #3f7fc2; }
.bcm-ico:disabled { opacity: 0.5; cursor: default; }

.bcm-body { flex: 1 1 auto; min-height: 0; display: flex; }
.bcm-left {
    flex: none;
    width: 400px;
    position: relative;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #eee;
}
.bcm-scroll, .bcm-right { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 24px; }
.bcm-right { min-width: 0; }
.bcm .form-field { margin-bottom: 16px; }
.bcm .form-field > label { font-size: 13px; color: #555; margin-bottom: 6px; }
.bcm-hint { font-size: 12px; color: #8a7a68; margin-top: 5px; line-height: 1.35; }
.bcm-sub { display: block; font-size: 12px; color: #777; margin-bottom: 4px; }

/* Поля — как в окне создания комнаты */
.bcm input[type="text"],
.bcm input[type="password"],
.bcm select {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #3a2b20;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.bcm input:focus, .bcm select:focus { border-color: #8a5836; outline: none; }

/* Кто бот: аватар, имя, случайный/выбрать */
.bcm-who { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.bcm .bot-avatar-preview { width: 84px; height: 84px; }
.bcm-who-fields { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

/* Сегменты вместо круглых «таблеток» — те же радио, тот же фиолетовый выбор */
.bcm .bcm-seg {
    display: flex;
    gap: 0;
    margin: 0;
    justify-content: flex-start;
    border: 2px solid #ddd;
    border-radius: 9px;
    overflow: hidden;
    width: max-content;
    max-width: 100%;
}
.bcm .bcm-seg-fill { width: auto; }
.bcm .bcm-seg-fill > * { flex: 1 1 0; }
.bcm .bcm-seg .gender-option { flex: 1 1 auto; }
.bcm .bcm-seg .gender-label,
.bcm .bcm-prov {
    flex: 1 1 auto;
    display: block;
    width: 100%;
    padding: 7px 12px;
    border: none;
    border-radius: 0;
    background: #fff;
    color: #3a2b20;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
}
.bcm .bcm-seg .gender-option + .gender-option .gender-label,
.bcm .bcm-prov + .bcm-prov { border-left: 1px solid #eee; }
.bcm .bcm-seg .gender-label:hover, .bcm .bcm-prov:hover { background: #f8f4f0; color: #3a2b20; }
.bcm .bcm-seg input:checked + .gender-label,
.bcm:not(:has(#botCustomProviderToggle:checked)):has(input[name="botPayment"][value="apikey"]:checked) .bcm-prov[data-custom="0"],
.bcm:has(#botCustomProviderToggle:checked) .bcm-prov[data-custom="1"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}
.bcm:not(:has(#botCustomProviderToggle:checked)):has(input[name="botPayment"][value="balance"]:checked) .bcm-prov[data-custom="flowers"] {
    background: linear-gradient(135deg, #f7c948 0%, #e0a800 100%);
    color: #3d2c00;
}
.bcm .bcm-seg input:disabled + .gender-label { opacity: 0.45; cursor: default; }

/* Озвучка: четыре карточки 2×2 с подписью цены */
.bcm .bcm-voices { gap: 6px; margin: 0; }
.bcm .bcm-voices .gender-option { display: block; }
.bcm .bcm-voices .gender-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 7px 12px;
    border: 2px solid #ddd;
    border-radius: 9px;
    background: #fff;
    color: #3a2b20;
    font-size: 14px;
    box-shadow: none;
}
.bcm .bcm-voices .gender-label small { font-size: 11px; opacity: 0.75; }
.bcm .bcm-voices input:checked + .gender-label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: #fff;
}
.bcm-chk { display: flex !important; align-items: center; gap: 8px; cursor: pointer; font-size: 13px !important; }
.bcm-chk input { width: 16px; height: 16px; margin: 0; }

/* Панель выбора аватара поверх левой колонки */
.bcm-picker {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow-y: auto;
    padding: 16px 24px;
    background: #fff;
}
.bcm-picker-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; font-weight: 600; }
.bcm-picker-head span { flex: 1 1 auto; }
.bcm-picker-head button { padding: 8px 16px; font-size: 14px; }
.bcm-picker-label { margin: 12px 0 6px; font-size: 13px; color: #555; }
.bcm-picker .color-grid-compact { gap: 7px; }
.bcm-picker .color-grid-compact .color-option.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #764ba2; }
.bcm-picker .pattern-grid-compact .pattern-option-mini { width: 40px; height: 40px; }
.bcm-picker .pattern-grid-compact .pattern-option-mini.selected { border-color: #764ba2; }

/* Модель: список сразу раскрыт */
.bcm #botModelSearch { margin-bottom: 8px; }
.bcm select.bcm-models { height: 150px; padding: 4px; }
.bcm select.bcm-models option { padding: 5px 8px; border-radius: 5px; }
/* Выбранная модель видна и без фокуса на списке (баги 18.11.2026, п.15–16):
   у неактивного listbox Chrome красит её бледно-серым — почти не отличить. */
.bcm select.bcm-models option:checked {
    background: #5a67d8 linear-gradient(0deg, #5a67d8 0%, #5a67d8 100%);
    color: #fff; font-weight: 600;
}
.bcm-picked {
    margin-top: 5px; padding: 4px 8px; border-radius: 6px;
    background: rgba(90, 103, 216, 0.1); color: #3c47a8;
    font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html.dark-theme .bcm-picked { background: rgba(163, 177, 255, 0.14); color: #c3cbff; }

.bcm-pay-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.bcm .bcm-promo {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #6f42c1;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}
.bcm-key { position: relative; }
.bcm-key input { padding-right: 44px !important; }
.bcm-eye {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #f1ebe2;
    font-size: 14px;
    cursor: pointer;
}
#botCustomProviderInputs .saved-provider-row { margin-bottom: 10px; }

/* Свой провайдер заменяет блок OpenRouter целиком */
.bcm:has(#botCustomProviderToggle:checked) #botModelField,
.bcm:has(#botCustomProviderToggle:checked) #botProviderField,
.bcm:has(#botCustomProviderToggle:checked) #botPaymentMode,
.bcm:has(#botCustomProviderToggle:checked) #botPriceTag { display: none !important; }

/* Низ: цена за партию слева, кнопки справа */
#bot-config-modal .bcm .bcm-foot {
    position: static;
    flex: none;
    align-items: center;
    margin: 0;
    padding: 14px 24px;
    border-top: 1px solid #eee;
}
#bot-config-modal .bcm .bcm-foot button { padding: 11px 26px; font-size: 16px; }
.bcm-spacer { flex: 1 1 auto; }
.bcm-price {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    background: #fff8e1;
    color: #8c6d1f;
    border: 1px solid #f0d88a;
}
.bcm-free { display: none; background: #e9f6ec; color: #24703a; border-color: #bfe3c8; }
.bcm #botPriceTag[style*="none"] ~ .bcm-free { display: inline-block; }
.bcm:has(#botCustomProviderToggle:checked) .bcm-free { display: none; }

@media (max-width: 760px) {
    #bot-config-modal .modal-content.bcm { height: calc(100vh - 24px); }
    .bcm-head { padding: 12px 14px; }
    .bcm-presets { order: 3; flex-basis: 100%; }
    .bcm-presets select { flex: 1 1 auto; width: auto; min-width: 0; }
    .bcm-body { flex-direction: column; overflow-y: auto; }
    .bcm-left { width: auto; border-right: none; border-bottom: 1px solid #eee; }
    .bcm-scroll, .bcm-right { flex: none; overflow: visible; padding: 14px; }
    .bcm .bcm-seg .gender-label, .bcm .bcm-prov { padding: 7px 8px; font-size: 13px; white-space: normal; }
    #bot-config-modal .bcm .bcm-foot { flex-wrap: wrap; padding: 10px 14px; }
    #bot-config-modal .bcm .bcm-foot button { padding: 10px 18px; font-size: 15px; }
}

html.dark-theme .bcm-head,
html.dark-theme .bcm-left,
html.dark-theme #bot-config-modal .bcm .bcm-foot { border-color: var(--dk-border); }
html.dark-theme .bcm-picker { background: var(--dk-surface); }
html.dark-theme .bcm input,
html.dark-theme .bcm select { background: rgba(255, 255, 255, 0.06); border-color: var(--dk-border); color: var(--dk-text); }
html.dark-theme .bcm .bcm-seg { border-color: var(--dk-border); }
html.dark-theme .bcm .bcm-seg .gender-label,
html.dark-theme .bcm .bcm-prov,
html.dark-theme .bcm .bcm-voices .gender-label { background: transparent; border-color: var(--dk-border); color: var(--dk-text); }
html.dark-theme .bcm-ico, html.dark-theme .bcm-eye { background: rgba(255, 255, 255, 0.08); color: var(--dk-text); }
html.dark-theme .bcm .bcm-seg input:checked + .gender-label,
html.dark-theme .bcm .bcm-voices input:checked + .gender-label,
html.dark-theme .bcm:not(:has(#botCustomProviderToggle:checked)):has(input[name="botPayment"][value="apikey"]:checked) .bcm-prov[data-custom="0"],
html.dark-theme .bcm:has(#botCustomProviderToggle:checked) .bcm-prov[data-custom="1"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}
.bcm .gender-selector { order: 0; }
/* Аватар с именем остаются видны над панелью — выбор сразу видно на колобке */
.bcm-picker { top: 120px; border-top: 1px solid #eee; padding-top: 12px; }
.bcm:has(#botCustomProviderToggle:checked) #botApiKeyField .bcm-hint { display: none; }

/* Форма «своего провайдера» — сетка в две колонки, как в макете */
#botCustomProviderInputs:not([style*="none"]) { display: grid !important; }
.bcm-conn { grid-template-columns: 1fr 1fr; gap: 12px 10px; align-items: start; }
.bcm-conn-full { grid-column: 1 / -1; }
.bcm-conn #botConnKeySlot:empty { display: none; }
.bcm-conn #botApiKeyField { margin: 0; }
.bcm-conn #botApiKeyField > label { font-size: 12px; color: #777; margin-bottom: 4px; }
.bcm-conn-pick { display: flex; gap: 6px; }
.bcm-conn-pick select { flex: 1 1 auto; min-width: 0; }
.bcm-conn-pick .bcm-ico { height: auto; }
.bcm-conn-model { display: flex; gap: 6px; align-items: flex-start; }
.bcm-conn-model > input, .bcm-conn-model > select { flex: 1 1 auto; min-width: 0; }
#botConnModelRow:not(.is-manual) #botCustomModelInput,
#botConnModelRow.is-manual #botConnModelSelect,
#botConnModelRow.is-manual #botConnModelSearch { display: none; }
#botConnModelSearch { width: 100%; box-sizing: border-box; margin-bottom: 6px; }
.bcm .bcm-conn-load {
    flex: none;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: #4a90d9;
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
}
.bcm .bcm-conn-load:hover { background: #3f7fc2; }
.bcm-conn-manual { margin-top: 8px; color: #555; }
.bcm-conn-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bcm .bcm-conn-actions button {
    padding: 9px 14px;
    border: none;
    border-radius: 8px;
    background: #f1ebe2;
    color: #3a2b20;
    font-size: 14px;
    cursor: pointer;
}
.bcm .bcm-conn-actions button:hover { background: #e6dccf; }
.bcm .bcm-conn-actions button:disabled, .bcm .bcm-conn-load:disabled { opacity: 0.6; cursor: default; }
.bcm-conn-result { padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.bcm-conn-result[data-kind="ok"] { background: #e9f6ec; color: #24703a; }
.bcm-conn-result[data-kind="error"] { background: #fdecea; color: #b3261e; }
.bcm-conn .bcm-hint { margin-top: -4px; }

/* Что показывать у каждого сервиса */
/* data-kind ставит JS: generic (свой адрес или популярный сервис), yandexgpt, gigachat */
.bcm-conn:not([data-kind="generic"]) #botConnModelRow,
.bcm-conn:not([data-kind="generic"]) #botConnTestBtn,
.bcm-conn:not([data-kind="generic"]) #botCustomProviderHint,
.bcm-conn:not([data-kind="yandexgpt"]) #botYandexModelRow,
.bcm-conn:not([data-kind="yandexgpt"]) #botYandexHint,
.bcm-conn:not([data-kind="gigachat"]) #botGigachatHint { display: none; }

/* Выбор аватара — две вкладки */
.bcm-picker-tabs { display: flex; border-bottom: 2px solid #eee; margin-bottom: 4px; }
.bcm .bcm-picker-tabs button {
    flex: 1 1 auto;
    margin-bottom: -2px;
    padding: 8px 6px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: #777;
    font-size: 13px;
    cursor: pointer;
}
.bcm-picker[data-tab="bg"] [data-pick-tab="bg"],
.bcm-picker[data-tab="pattern"] [data-pick-tab="pattern"] { border-bottom-color: #764ba2; color: #764ba2; }
.bcm-picker[data-tab="bg"] [data-pane="pattern"],
.bcm-picker[data-tab="pattern"] [data-pane="bg"] { display: none; }

@media (max-width: 760px) {
    .bcm-conn { grid-template-columns: 1fr; }
}
html.dark-theme .bcm .bcm-conn-actions button { background: rgba(255, 255, 255, 0.08); color: var(--dk-text); }
html.dark-theme .bcm-picker-tabs { border-color: var(--dk-border); }

/* Оплата OpenRouter компактнее: ключ сразу под переключателем, одна подсказка */
#botPaymentMode #botApiKeyField { margin: 8px 0 0; }
#botPaymentMode #botApiKeyField > label,
#botPaymentMode #botApiKeyField .bcm-hint { display: none; }
.bcm .bcm-promo { padding: 6px 10px; font-size: 12px; }
/* Глазик: общий hover кнопок двигает их transform'ом — центрируем без transform */
.bcm .bcm-eye,
.bcm .bcm-eye:hover {
    top: 0;
    bottom: 0;
    margin: auto 0;
    transform: none;
    box-shadow: none;
}
.bcm .bcm-eye:hover { background: #e6dccf; }
html.dark-theme .bcm .bcm-eye:hover { background: rgba(255, 255, 255, 0.14); }

/* ============================================
   ПРОФИЛЬ — РЕДИЗАЙН 2.5 (:is(#profile-modal, #model-profile-modal) .pfm)
   Баннер с рангом, под ним вкладки. Окно одной высоты:
   прокручивается только содержимое вкладки.
   ============================================ */
:is(#profile-modal, #model-profile-modal) .pfm {
    max-width: 980px !important;
    width: 96vw;
    height: min(640px, 92vh);
    height: min(640px, 92dvh);
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    border-radius: 14px;
    overflow: hidden;
}
:is(#profile-modal, #model-profile-modal) .profile-banner {
    flex: none;
    height: 196px;
    min-height: 0;
}
:is(#profile-modal, #model-profile-modal) .pfm-banner-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0) 65%);
}
:is(#profile-modal, #model-profile-modal) .profile-banner-content {
    height: 100%;
    box-sizing: border-box;
    padding: 26px 330px 26px 32px;
    gap: 24px;
}
:is(#profile-modal, #model-profile-modal) .profile-banner-avatar-wrap,
:is(#profile-modal, #model-profile-modal) .profile-banner-avatar {
    width: 128px;
    height: 128px;
}
:is(#profile-modal, #model-profile-modal) .profile-banner-info { gap: 6px; }
:is(#profile-modal, #model-profile-modal) .pfm-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
:is(#profile-modal, #model-profile-modal) .profile-banner-name { font-size: 30px; font-weight: 600; }
:is(#profile-modal, #model-profile-modal) .profile-banner-title { margin: 0; align-self: center; font-weight: 600; }
:is(#profile-modal, #model-profile-modal) .profile-banner-caption { font-size: 15px; }
:is(#profile-modal, #model-profile-modal) .pfm-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
:is(#profile-modal, #model-profile-modal) .profile-banner-status { margin: 0; font-size: 13px; padding: 4px 11px; border-radius: 14px; }

:is(#profile-modal, #model-profile-modal) .pfm-top-btns {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    display: flex;
    gap: 8px;
}
:is(#profile-modal, #model-profile-modal) .pfm-pill {
    height: 36px;
    margin: 0;
    padding: 0 14px;
    border: none;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    color: #3a2b20;
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-pill:hover { background: #fff; transform: none; }
:is(#profile-modal, #model-profile-modal) .pfm-close { width: 36px; padding: 0; }
:is(#profile-modal, #model-profile-modal) .profile-friend-btn:not(.is-friend) { background: #8a5836; color: #fff; }
:is(#profile-modal, #model-profile-modal) .profile-friend-btn:not(.is-friend):hover { background: #9a6b4a; }
:is(#profile-modal, #model-profile-modal) .profile-friend-btn.is-friend { background: #e9f6ec; color: #166534; border: none; }

:is(#profile-modal, #model-profile-modal) .pfm-rank {
    position: absolute;
    right: 28px;
    bottom: 22px;
    z-index: 2;
    width: 280px;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    color: #3a2b20;
}
.pfm-rank-head { display: flex; align-items: center; gap: 8px; }
.pfm-rank-icon { font-size: 24px; }
.pfm-rank-name { flex: 1 1 auto; font-size: 16px; font-weight: 600; }
.pfm-rank-xp { font-weight: 600; }
.pfm-rank-bar { margin-top: 8px; height: 8px; border-radius: 4px; background: #eadfd2; overflow: hidden; }
.pfm-rank-bar i { display: block; height: 100%; width: 0; }
.pfm-rank-next { margin-top: 5px; font-size: 12px; color: #8a7a68; }

/* Строка вкладок */
:is(#profile-modal, #model-profile-modal) .pfm-tabs {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 24px;
    border-bottom: 2px solid #eee;
    background: #fff;
    overflow-x: auto;
    scrollbar-width: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-tab {
    margin: 0 0 -2px;
    padding: 14px 10px;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: none;
    color: #6b5b4c;
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-tab:hover { color: #3a2b20; transform: none; }
:is(#profile-modal, #model-profile-modal) .pfm-tab.active { color: #3a2b20; border-image: linear-gradient(135deg, #667eea, #764ba2) 1; border-bottom-width: 3px; border-bottom-style: solid; }
.pfm-cnt { margin-left: 6px; padding: 1px 7px; border-radius: 10px; background: #f1ebe2; color: #8a5836; font-size: 12px; }
.pfm-cnt:empty { display: none; }
.pfm-tabs-gap { flex: 1 1 auto; }
:is(#profile-modal, #model-profile-modal) .pfm-act {
    margin: 0 0 0 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: #8a5836;
    color: #fff;
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-act:hover { background: #9a6b4a; transform: none; }

/* Содержимое вкладок */
:is(#profile-modal, #model-profile-modal) .pfm-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 20px 24px !important;
    background: #fff;
    color: #3a2b20;
}
.pfm-pane { display: none; }
.pfm[data-tab="overview"] .pfm-pane[data-pane="overview"],
.pfm[data-tab="ach"] .pfm-pane[data-pane="ach"],
.pfm[data-tab="roles"] .pfm-pane[data-pane="roles"],
.pfm[data-tab="play"] .pfm-pane[data-pane="play"],
.pfm[data-tab="friends"] .pfm-pane[data-pane="friends"],
.pfm[data-tab="memory"] .pfm-pane[data-pane="memory"],
.pfm[data-tab="versions"] .pfm-pane[data-pane="versions"] { display: block; }
.pfm-muted { color: #8a7a68; }
.pfm-empty { padding: 24px 0; text-align: center; color: #8a7a68; font-size: 14px; }
.pfm-ttl { font-size: 13px; font-weight: 600; color: #8a5836; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; }
.pfm-foot-note { font-size: 12px; margin-top: 10px; }

.pfm-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.pfm-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pfm-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pfm-big-cell { padding: 14px 16px; border-radius: 12px; background: #f8f4f0; }
.pfm-big-cell span { display: block; font-size: 13px; color: #6b5b4c; }
.pfm-big-cell b { display: block; margin-top: 4px; font-size: 30px; font-weight: 600; }
.pfm-small { display: flex; flex-wrap: wrap; gap: 8px; }
.pfm-chip { padding: 6px 11px; border-radius: 16px; background: #f8f4f0; font-size: 13px; color: #6b5b4c; }
.pfm-chip b { color: #3a2b20; font-weight: 600; }
.pfm-flowers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pfm-flowers .pfm-flowers-code { cursor: pointer; border: none; font: inherit; font-size: 13px; }
.pfm-flowers code { font-weight: 700; letter-spacing: 0.5px; }
.pfm-season { padding: 10px 14px; border-radius: 10px; background: #fff8e1; border: 1px solid #f0d88a; color: #6f5618; font-size: 14px; }

.pfm-sides { display: flex; flex-direction: column; gap: 8px; }
:is(#profile-modal, #model-profile-modal) .pfm-side {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 11px 14px;
    border: none;
    border-left: 4px solid var(--side, #999);
    border-radius: 10px;
    background: #f8f4f0;
    color: #3a2b20;
    font-size: 14px;
    font-weight: normal;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-side:hover { filter: brightness(0.97); transform: none; }
.pfm-side--town { --side: #3b82f6; }
.pfm-side--mafia { --side: #e11d48; }
.pfm-side--neutral { --side: #8b5cf6; }
.pfm-side-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--side); }
.pfm-side-t { flex: none; width: 84px; font-weight: 600; }
.pfm-side-bar { flex: 1 1 auto; height: 8px; border-radius: 4px; background: #eadfd2; overflow: hidden; }
.pfm-side-bar i { display: block; height: 100%; background: var(--side); }
.pfm-side-pct { flex: none; width: 40px; text-align: right; font-weight: 600; }
.pfm-side-sub { flex: none; width: 150px; text-align: right; font-size: 13px; color: #8a7a68; white-space: nowrap; }

:is(#profile-modal, #model-profile-modal) .pfm-ach-sum {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 4px 0 0;
    padding: 12px 14px;
    border: none;
    border-radius: 10px;
    background: #f8f4f0;
    color: #3a2b20;
    font-size: 14px;
    font-weight: normal;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-ach-sum:hover { filter: brightness(0.97); transform: none; }
:is(#profile-modal, #model-profile-modal) .pfm-ach-sum b { font-weight: 600; }
.pfm-ach-recent { display: flex; gap: 6px; }
.pfm-ach-mini {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f7edd0 center/contain no-repeat;
    display: grid;
    place-items: center;
    font-size: 17px;
}

/* Достижения */
.pfm-filter-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; font-size: 13px; }
.pfm-seg { flex: none; display: flex; border: 1px solid #ddd; border-radius: 9px; overflow: hidden; }
:is(#profile-modal, #model-profile-modal) .pfm-seg button {
    margin: 0;
    padding: 7px 14px;
    border: none;
    border-radius: 0;
    background: #fff;
    color: #3a2b20;
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-seg button:hover { background: #f5efe8; transform: none; }
:is(#profile-modal, #model-profile-modal) .pfm-seg button.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.pfm-ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pfm-ach-grid .inventory-ach-row { margin: 0; align-items: flex-start; }
.pfm-ach-grid .pfm-empty { grid-column: 1 / -1; }

/* Стороны и роли */
.pfm-role-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pfm-role-col { background: #f8f4f0; border-radius: 12px; padding: 14px 16px; border-top: 4px solid var(--side); }
.pfm-role-head { display: flex; align-items: baseline; gap: 8px; }
.pfm-role-head b { flex: 1 1 auto; font-size: 17px; font-weight: 600; }
.pfm-role-head span { font-weight: 600; }
.pfm-role-sub { font-size: 13px; margin: 2px 0 8px; }
.pfm-role-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #ece4da; font-size: 14px; }
.pfm-role-row:last-child { border-bottom: none; }
.pfm-role-row b { font-weight: 600; }

/* Как играет */
:is(#profile-modal, #model-profile-modal) .gs-modal-grid { grid-template-columns: 1fr 1fr; }
:is(#profile-modal, #model-profile-modal) .gs-block { background: #f8f4f0; }

/* Друзья */
:is(#profile-modal, #model-profile-modal) .friend-search { margin: 0 0 14px; }
:is(#profile-modal, #model-profile-modal) .friend-search input { padding: 9px 12px; border: 2px solid #ddd; }
:is(#profile-modal, #model-profile-modal) .friend-search input:focus { border-color: #8a5836; outline: none; }
:is(#profile-modal, #model-profile-modal) .profile-friends-group-body {
    display: grid;
    /* Апрель, п.12: четыре колонки во всю ширину окна давали карточки по ~230px —
       «квадратики слишком большие». Теперь колонок столько, сколько влезет по
       ~160px, и они делят строку поровну — без пустой полосы справа. */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
:is(#profile-modal, #model-profile-modal) .profile-friend-item { border-radius: 10px; padding: 5px 10px 5px 6px; background: #f8f4f0; min-width: 0; }
:is(#profile-modal, #model-profile-modal) .profile-friend-item-name { max-width: none; }

/* Профиль модели: список версий */
#model-profile-modal .mp-versions-list { gap: 8px; }
#model-profile-modal .mp-version-row { gap: 12px; padding: 10px 14px; border-radius: 10px; background: #f8f4f0; font-size: 14px; }
#model-profile-modal .mp-version-stat { font-size: 13px; min-width: 64px; }
#model-profile-modal .mp-version-sub { flex: none; font-size: 13px; color: #8a7a68; white-space: nowrap; }
html.dark-theme #model-profile-modal .mp-version-row { background: rgba(255, 255, 255, 0.05); }
html.dark-theme #model-profile-modal .mp-version-sub { color: var(--dk-text-2); }
@media (max-width: 760px) { #model-profile-modal .mp-version-sub { display: none; } }

/* Что помнят боты */
:is(#profile-modal, #model-profile-modal) .profile-dossier-row { margin: 0; padding: 14px 16px; border: none; border-radius: 12px; background: #f8f4f0; max-width: none; /* п.54: на всю ширину окна */ }
/* п.54: досье занимает всю вкладку и по высоте — поле растёт до низа окна */
.pfm[data-tab="memory"] .pfm-pane[data-pane="memory"] { display: flex; flex-direction: column; height: 100%; }
#profile-modal .profile-dossier-row:not([style*="none"]) { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; box-sizing: border-box; }
#profile-modal .profile-dossier-row .profile-dossier-input { flex: 1 1 auto; min-height: 140px; resize: none; }
:is(#profile-modal, #model-profile-modal) .profile-dossier-title { font-size: 13px; font-weight: 600; color: #8a5836; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; }
:is(#profile-modal, #model-profile-modal) .profile-dossier-text { font-size: 15px; line-height: 1.55; color: #3a2b20; max-height: none; }
:is(#profile-modal, #model-profile-modal) .profile-dossier-note { font-size: 13px; color: #8a7a68; margin-top: 10px; }
/* Досье о себе (2.5): поле ввода + счётчик + «Сохранить» */
.profile-dossier-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(138, 88, 54, 0.3);
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    resize: vertical;
    background: #fff;
    color: #3a2b20;
}
.profile-dossier-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.profile-dossier-count { font-size: 12px; color: #8a7a68; }
.profile-dossier-count.over { color: #c0392b; font-weight: 700; }
.profile-dossier-save {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.profile-dossier-save:disabled { opacity: 0.45; cursor: default; }
html.dark-theme .profile-dossier-input { background: var(--dk-surface); color: var(--dk-text); border-color: var(--dk-border); }

/* Узко: баннер растёт по содержимому, плашка ранга уходит под имя */
@media (max-width: 760px) {
    :is(#profile-modal, #model-profile-modal) .pfm { height: 92vh; height: 92dvh; border-radius: 12px; }
    :is(#profile-modal, #model-profile-modal) .profile-banner { height: auto; }
    :is(#profile-modal, #model-profile-modal) .profile-banner-content { height: auto; padding: 56px 14px 10px; gap: 14px; }
    :is(#profile-modal, #model-profile-modal) .profile-banner-avatar-wrap,
    :is(#profile-modal, #model-profile-modal) .profile-banner-avatar { width: 72px; height: 72px; }
    :is(#profile-modal, #model-profile-modal) .profile-banner-name { font-size: 20px; }
    :is(#profile-modal, #model-profile-modal) .profile-banner-caption { font-size: 13px; }
    :is(#profile-modal, #model-profile-modal) .pfm-top-btns { top: 10px; right: 10px; left: 10px; justify-content: flex-end; }
    :is(#profile-modal, #model-profile-modal) .pfm-pill { height: 32px; font-size: 13px; padding: 0 12px; }
    :is(#profile-modal, #model-profile-modal) .pfm-close { width: 32px; }
    :is(#profile-modal, #model-profile-modal) .pfm-rank { position: relative; right: auto; bottom: auto; width: auto; margin: 0 14px 12px; padding: 9px 12px; }
    :is(#profile-modal, #model-profile-modal) .pfm-tabs { padding: 0 10px; }
    :is(#profile-modal, #model-profile-modal) .pfm-body { padding: 14px !important; }
    .pfm-overview, .pfm-role-cols, .pfm-ach-grid, :is(#profile-modal, #model-profile-modal) .gs-modal-grid { grid-template-columns: 1fr; }
    .pfm-big-cell { padding: 10px 12px; }
    .pfm-big-cell b { font-size: 22px; }
    .pfm-side-sub { display: none; }
    :is(#profile-modal, #model-profile-modal) .profile-friends-group-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Тёмная тема */
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-tabs,
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-body { background: var(--dk-surface); color: var(--dk-text); border-bottom-color: var(--dk-border); }
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-tab { color: var(--dk-text-2); }
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-tab.active,
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-tab:hover { color: var(--dk-text); }
html.dark-theme .pfm-cnt { background: rgba(255, 255, 255, 0.08); color: var(--dk-text-2); }
html.dark-theme .pfm-big-cell,
html.dark-theme .pfm-chip,
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-side,
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-ach-sum,
html.dark-theme .pfm-role-col,
html.dark-theme :is(#profile-modal, #model-profile-modal) .gs-block,
html.dark-theme :is(#profile-modal, #model-profile-modal) .profile-friend-item,
html.dark-theme :is(#profile-modal, #model-profile-modal) .profile-dossier-row { background: rgba(255, 255, 255, 0.05); color: var(--dk-text); }
html.dark-theme .pfm-big-cell span,
html.dark-theme .pfm-chip,
html.dark-theme .pfm-muted,
html.dark-theme .pfm-side-sub,
html.dark-theme .pfm-empty { color: var(--dk-text-2); }
html.dark-theme .pfm-chip b,
html.dark-theme :is(#profile-modal, #model-profile-modal) .profile-dossier-text { color: var(--dk-text); }
html.dark-theme .pfm-side-bar,
html.dark-theme .pfm-rank-bar { background: rgba(255, 255, 255, 0.1); }
html.dark-theme .pfm-role-row { border-bottom-color: var(--dk-border); }
html.dark-theme .pfm-season { background: rgba(240, 216, 138, 0.1); border-color: rgba(240, 216, 138, 0.35); color: #f0d88a; }
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-seg { border-color: var(--dk-border); }
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-seg button:not(.active) { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-rank { background: rgba(36, 27, 22, 0.92); color: var(--dk-text); }

/* Профиль 2.5: сворачивание групп друзей — display:grid выше перебивал [hidden] */
:is(#profile-modal, #model-profile-modal) .profile-friends-group-body[hidden] { display: none; }

/* Подсказка «Как получать опыт» под плашкой ранга */
:is(#profile-modal, #model-profile-modal) .pfm-rank-help {
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #8a5836;
    color: #fff;
    font-size: 13px;
    font-weight: normal;
    line-height: 22px;
    cursor: pointer;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-rank-help:hover { background: #9a6b4a; transform: none; }
:is(#profile-modal, #model-profile-modal) .pfm { position: relative; }
.pfm-xp-help {
    position: absolute;
    top: 184px;
    right: 28px;
    z-index: 6;
    width: 320px;
    box-sizing: border-box;
    padding: 14px 16px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    color: #3a2b20;
    font-size: 13px;
    line-height: 1.6;
}
.pfm-xp-help[hidden] { display: none; }
.pfm-xp-help b { font-weight: 600; }
:is(#profile-modal, #model-profile-modal) .pfm-xp-help-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #f1ebe2;
    color: #3a2b20;
    cursor: pointer;
    box-shadow: none;
}
:is(#profile-modal, #model-profile-modal) .pfm-xp-help-close:hover { transform: none; }
.pfm-xp-help-ranks { margin-top: 10px; }
.pfm-xp-ranks div { display: flex; justify-content: space-between; padding: 1px 6px; border-radius: 6px; }
.pfm-xp-ranks span { color: #8a7a68; }
.pfm-xp-ranks .is-current { background: #f1ebe2; }

/* Титул от админа: поле прямо в баннере */
.pfm-title-edit { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.pfm-title-edit[hidden] { display: none; }
.pfm-title-edit input {
    width: 220px;
    height: 32px;
    box-sizing: border-box;
    padding: 0 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #3a2b20;
}
.pfm-title-edit input:focus { border-color: #8a5836; outline: none; }
:is(#profile-modal, #model-profile-modal) .pfm-title-edit .pfm-pill { height: 32px; }

@media (max-width: 760px) {
    .pfm-xp-help { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: 70%; overflow-y: auto; }
    .pfm-title-edit input { width: 140px; }
}
html.dark-theme .pfm-xp-help { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme :is(#profile-modal, #model-profile-modal) .pfm-xp-help-close,
html.dark-theme .pfm-xp-ranks .is-current { background: rgba(255, 255, 255, 0.08); color: var(--dk-text); }
html.dark-theme .pfm-xp-ranks span { color: var(--dk-text-2); }

/* Шапка из профиля на колобке главного экрана: слои рядом с превью, как в лобби */
body #avatar-preview-container { position: relative; }
/* Колобок отзеркален, как .player-sprite в лобби: лицо смотрит вправо, а посадка
   шапок (mirror: true) подобрана именно под такого колобка. */
body #avatar-preview-container .avatar-large-preview { transform: scaleX(-1); }
#avatar-preview-container .lobby-hat-layer { left: 50%; }
/* Лицо на колобке главного экрана: своего правила не было, слой был нулевой высоты */
/* Собранное лицо на колобке главного меню — геометрия стола (applyMenuBuiltFace).
   Колобок отзеркален, поэтому у x минус: «+» в переменной = вправо. */
.avatar-large-preview .avatar-face.face-built,
.lobby-face-top.face-built > div {
    top: -25%;
    left: -25%;
    width: 150%;
    height: 150%;
    background-size: 100% 100%;
    transform: translate(calc(var(--menu-face-x) / -1.5), calc(var(--menu-face-y) / 1.5)) scale(var(--menu-face-scale));
}

/* Собранное лицо на колобках лобби комнаты — та же геометрия, свои ручки */
.player-sprite .avatar-face.face-built,
.lobby-face-top.face-built.lobby-ball > div {
    top: -25%;
    left: -25%;
    width: 150%;
    height: 150%;
    background-size: 100% 100%;
    transform: translate(calc(var(--lobby-face-x) / -1.5), calc(var(--lobby-face-y) / 1.5)) scale(var(--lobby-face-scale));
}

.avatar-large-preview .avatar-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-60%, -55%);
    width: 50%;
    height: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 2;
}

/* ===== Эмодзи и стикеры в чате (2.5, п.16–20). Логика — stickers.js ===== */
.chat-input-area { position: relative; }
/* Поле ввода + внутри него справа: кнопка стикеров сверху, счётчик снизу */
/* flex-basis 0: с auto обёртка брала ширину поля по содержимому, и кнопка
   отправки в узком чате уезжала на вторую строку */
.chat-input-wrap { position: relative; flex: 1 1 0; min-width: 0; display: flex; }
.chat-input-wrap #chatInput { flex: 1 1 auto; width: 100%; padding-right: 40px; }
.chat-input-wrap .sticker-btn,
.lobby-chat-input-area .chat-input-wrap .sticker-btn {
    position: absolute;
    top: 2px;
    right: 6px;
    width: 26px;
    min-width: 0;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 17px;
    cursor: pointer;
    line-height: 22px;
    opacity: 0.75;
    z-index: 2;
}
.chat-input-wrap .sticker-btn:hover, .chat-input-wrap .sticker-btn.active,
.lobby-chat-input-area .chat-input-wrap .sticker-btn:hover { opacity: 1; background: transparent; }
.lobby-chat-input-area .chat-input-wrap textarea { padding-right: 40px; }
/* Кнопки лобби коричневые (.lobby-chat-input-area button) — в панели стикеров свой вид */
.lobby-chat-input-area .sticker-picker .sticker-cell { background: transparent; padding: 0; min-width: 0; }
.lobby-chat-input-area .sticker-picker .sticker-cell:hover:not(:disabled) { background: rgba(102, 126, 234, 0.12); }
.lobby-chat-input-area .sticker-picker .sticker-tab { min-width: 0; padding: 4px 10px; font-size: 12px; background: rgba(138, 88, 54, 0.08); color: #5a3a24; }
.lobby-chat-input-area .sticker-picker .sticker-tab.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
/* Счётчик символов — бледная цифра в правом нижнем углу поля, под 😊 (выбор
   Светы, 2.5). Виден, только пока в поле есть текст: :placeholder-shown ловит
   и очистку поля кодом после отправки, без всяких событий. */
.chat-input-wrap .chat-char-counter,
.chat-input-wrap .lobby-chat-counter {
    display: block !important;
    position: absolute;
    right: 10px;
    bottom: 3px;
    min-width: 0;
    font-size: 10px;
    line-height: 1;
    opacity: 0.55;
    pointer-events: none;
    z-index: 2;
}
.chat-input-wrap textarea:placeholder-shown ~ .chat-char-counter,
.chat-input-wrap textarea:placeholder-shown ~ .lobby-chat-counter { display: none !important; }
.chat-input-wrap .chat-char-counter.low,
.chat-input-wrap .lobby-chat-counter.low { opacity: 0.9; }
.chat-input-wrap .chat-char-counter.over,
.chat-input-wrap .lobby-chat-counter.over { opacity: 1; }
.sticker-picker {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: calc(100% + 6px);
    max-height: 300px;
    display: flex;
    flex-direction: column;
    background: #fffaf4;
    border: 1px solid rgba(138, 88, 54, 0.3);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 500;
    overflow: hidden;
}
.sticker-picker.hidden { display: none; }
.sticker-tabs { flex: 0 0 auto; display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid rgba(138, 88, 54, 0.15); overflow-x: auto; }
.sticker-tab {
    padding: 4px 10px;
    border: none;
    border-radius: 14px;
    background: rgba(138, 88, 54, 0.08);
    font-size: 12px;
    font-weight: 700;
    color: #5a3a24;
    cursor: pointer;
    white-space: nowrap;
}
.sticker-tab.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.sticker-tab.locked { opacity: 0.6; }
.sticker-locked-note { padding: 6px 10px 0; font-size: 12px; color: #8a5836; }
/* overflow-x: hidden + место под полосу заранее: иначе полосы прокрутки
   появлялись по очереди (вертикальная сужала сетку → вылезала горизонтальная →
   росла высота → вертикальная пропадала) и окно дёргалось. */
/* Не меньше 6 столбцов (список 24.11.2026, п.14: «меньше мотать»): в чате партии
   (панель 320px) влезало 5. Ячейка ужимается до доли ширины, при которой встаёт
   шесть, на широкой панели столбцов больше, как раньше. 21px — пять зазоров по 4px
   плюс запас на округление. */
.sticker-grid { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(56px, calc((100% - 21px) / 6)), 1fr)); gap: 4px; padding: 6px; }
.sticker-grid .sticker-cell .sticker-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sticker-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 64px;
    min-width: 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    overflow: hidden;   /* колобок со шапкой крупнее ячейки — не даём ему распирать сетку */
}
.sticker-cell:hover:not(:disabled) { background: rgba(102, 126, 234, 0.12); }
.sticker-cell:disabled { cursor: default; filter: grayscale(1); opacity: 0.45; }
/* Мини-колобок: шар обрезан маской, шапка — соседние слои (applyLobbyProfileHat) */
.sticker-kolobok { position: relative; display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.sticker-kolobok .sticker-kolobok-stage { position: absolute; display: block; }
/* Шапка на стикере сидит сама (applyLobbyProfileHat), сдвигов не нужно.
   В сетке инвентаря её сжимало общее .inventory-cell img { max-width: 90% } —
   шапка уезжала; снимаем ограничение (сдвиг translate чинил сетку, но ломал
   панель стикеров и чат). */
.sticker-kolobok .lobby-hat-layer { max-width: none; max-height: none; }
.sticker-kolobok .sticker-kolobok-sprite { margin: 0; position: absolute; transform: scaleX(-1); }
.sticker-img { display: inline-block; vertical-align: middle; object-fit: contain; }
.chat-message .chat-sticker { margin: 0 2px; }
html.dark-theme .sticker-picker { background: var(--dk-surface); border-color: var(--dk-border); }
html.dark-theme .sticker-tab:not(.active) { background: rgba(255, 255, 255, 0.08); color: var(--dk-text); }
html.dark-theme .sticker-locked-note { color: var(--dk-accent-text); }

.inventory-stickers-panel {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    overflow-y: auto;
    background: #fef9f4;
}
/* Вкладка устроена как остальные (Апрель, п.7): сетка слева, карточка справа */
.inventory-stickers-panel:has(> .inv-stickers-body) { padding: 0; overflow: hidden; }
.inv-stickers-body { flex: 1 1 auto; height: 100%; }
.inv-sticker-cell { overflow: hidden; }
.inv-sticker-cell.locked .chat-sticker,
.inv-sticker-cell.locked .sticker-kolobok,
.inv-sticker-cell.locked .sticker-img { filter: grayscale(0.7) brightness(0.92); opacity: 0.75; }
.inv-sticker-preview {
    flex-shrink: 0;
    width: 130px;
    height: 130px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: #f5e6d3;
}
.inv-sticker-preview.locked > * { filter: grayscale(0.7); opacity: 0.8; }
.inv-sticker-unlock-more { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(138, 88, 54, 0.25); }
html.dark-theme .inventory-stickers-panel { background: var(--dk-surface); }
html.dark-theme .inv-sticker-preview { background: var(--dk-surface-2); }
@media (max-width: 700px) {
    .inv-sticker-preview { width: 80px; height: 80px; margin-bottom: 8px; }
    .inv-sticker-preview > * { transform: scale(0.65); }
}
/* Панель жестов (2.5): вкладки «Обычные / Свой колобок / Дипсик…», под ними
   либо эмодзи-жесты, либо сетка пака. Прокручивается вся панель, а не сетка. */
.gesture-tabs { padding: 0 0 8px; border-bottom: none; flex-wrap: wrap; overflow: visible; }
.gesture-stickers .sticker-grid { padding: 2px 0; overflow: visible; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.gesture-stickers .sticker-locked-note { padding: 2px 0 6px; }
/* Жест-стикер над колобком: без подложки-кружка обычного эмодзи */
.gesture-bubble.gesture-bubble-sticker { background: transparent; box-shadow: none; padding: 0; font-size: 0; }

/* Поля API-ключей (13.11.2026, жалоба Камня): НЕ type="password". Телефон
   принимал такое поле за пароль — подставлял туда сохранённый пароль от сайта
   (стираешь — возвращается) и открывал «защищённую» клавиатуру без вставки.
   Теперь это обычное текстовое поле, а точки рисует CSS. */
.api-key-input { -webkit-text-security: disc; text-security: disc; }
.api-key-input:focus { -webkit-text-security: none; text-security: none; }

/* ===== 🌼 Таблица «сколько тратят модели» (15.11.2026) ===== */
.flowers-price-table { width: calc(100% - 40px); margin: 4px 20px 10px; border-collapse: collapse; font-size: 14px; }
.flowers-price-table td { padding: 5px 4px; border-bottom: 1px solid #eee; }
.flowers-price-table .flowers-price-num { text-align: right; font-weight: 700; color: #b8860b; white-space: nowrap; }
.flowers-price-table .flowers-price-model { font-size: 11px; color: #999; }
.flowers-fact-note { font-size: 11px; opacity: 0.75; }
html.dark-theme .flowers-price-table td { border-color: var(--dk-border, #333); }
html.dark-theme .flowers-price-table .flowers-price-num { color: #f7d774; }

/* ===== «🌼 За цветочки» в окне бота (15.11.2026) ===== */
html.dark-theme .bcm:not(:has(#botCustomProviderToggle:checked)):has(input[name="botPayment"][value="balance"]:checked) .bcm-prov[data-custom="flowers"] {
    background: linear-gradient(135deg, #f7c948 0%, #e0a800 100%);
    color: #3d2c00;
}
.bcm-flowers-bar { display: none; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 0 6px; }
/* Плашка цветочков вплотную к подсказке под списком моделей, без пустой полосы */
.bcm:has(input[name="botPayment"][value="balance"]:checked) #botPaymentMode { margin-top: 0; padding-top: 0; }
.bcm-flowers-bar .bcm-fl-boosty-note { font-size: 11px; color: #8a7a3a; max-width: 340px; line-height: 1.4; }
html.dark-theme .bcm-flowers-bar .bcm-fl-boosty-note { color: #c9b66a; }
.bcm:has(input[name="botPayment"][value="balance"]:checked) .bcm-flowers-bar { display: flex; }
.bcm-flowers-bar .bcm-fl-balance { font-size: 16px; }
.bcm-flowers-bar .bcm-fl-balance b { font-size: 22px; color: #c99a06; }
.bcm-flowers-bar .bcm-fl-why { font-size: 13px; color: #777; line-height: 1.4; }
.bcm-flowers-bar .bcm-fl-box {
    width: 100%; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px; border-radius: 12px; background: #fff8dc; border: 1px solid #f0d77a;
}
.bcm-flowers-bar .bcm-fl-code { font-size: 15px; display: flex; align-items: center; gap: 6px; }
.bcm-flowers-bar .bcm-fl-code code {
    font-size: 16px; font-weight: 700; letter-spacing: 1px; padding: 2px 8px;
    border-radius: 6px; background: #fff; border: 1px dashed #c99a06; user-select: all;
}
.bcm-flowers-bar .bcm-fl-copy { padding: 2px 8px; font-size: 13px; }
.bcm-flowers-bar .bcm-fl-hint { font-size: 12px; color: #7a6a2a; }
.bcm-flowers-bar .bcm-fl-donate {
    display: block; width: 100%; box-sizing: border-box; margin-top: 2px; padding: 10px 14px; border-radius: 10px;
    text-decoration: none; font-weight: 700; font-size: 15px;
    background: linear-gradient(135deg, #f7c948, #e0a800); color: #3d2c00;
}
.bcm-flowers-bar .bcm-fl-boosty { font-size: 12px; color: #8a6d00; }
.bcm-flowers-bar .bcm-fl-spend { font-size: 12px; color: #777; line-height: 1.45; }
.bcm-flowers-bar .bcm-fl-prices {
    background: none; border: none; box-shadow: none; padding: 0; font-size: 13px;
    color: #7b6aa8; text-decoration: underline; cursor: pointer;
}
html.dark-theme .bcm-flowers-bar .bcm-fl-why, html.dark-theme .bcm-flowers-bar .bcm-fl-spend { color: #aaa; }
html.dark-theme .bcm-flowers-bar .bcm-fl-box { background: #2e2a18; border-color: #6b5a1e; }
html.dark-theme .bcm-flowers-bar .bcm-fl-code code { background: #1e1c12; color: #f7d774; }
html.dark-theme .bcm-flowers-bar .bcm-fl-hint, html.dark-theme .bcm-flowers-bar .bcm-fl-boosty { color: #c9b66a; }
html.dark-theme .bcm-flowers-bar .bcm-fl-prices { color: #b8a8e8; }
/* Цена «≈ N 🌼» внизу окна и подсказка об оплате нужны только в режиме цветочков:
   со своим ключом игрок платит OpenRouter сам, ему наши 🌼 ни к чему. */
.bcm:has(input[name="botPayment"][value="apikey"]:checked) #botPriceTag,
.bcm #botPaymentHint { display: none !important; }
.bcm:has(input[name="botPayment"][value="balance"]:checked) #botApiKeyField { display: none !important; }
.bcm:has(input[name="botPayment"][value="balance"]:checked) #botModelField { margin-bottom: 6px; }
.bcm-flowers-bar .bcm-fl-balance { line-height: 1.1; margin-top: -2px; }

/* ===== 2.6 п.15: гостю — пилюля «Вы гость · Зарегистрироваться» в шапке комнат.
   17.11.2026: вместо широкой плашки над комнатами — в стиле мини-профиля рядом. ===== */
.guest-pill {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 6px 5px 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #e0c9b3; border-radius: 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    font-size: 13px; color: #6b5848; white-space: nowrap;
}
.guest-pill .guest-pill-main,
.guest-pill .guest-pill-main:hover {
    padding: 5px 12px; border: none; border-radius: 20px; font-size: 13px; font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff;
    box-shadow: none; transform: none; cursor: pointer;
}
.guest-pill .guest-pill-info,
.guest-pill .guest-pill-info:hover {
    width: 22px; height: 22px; min-width: 0; padding: 0; border: none; border-radius: 50%;
    background: rgba(102, 126, 234, 0.14); color: #4c51bf; font-size: 12px; font-weight: 700;
    box-shadow: none; transform: none; cursor: pointer;
}
html.dark-theme .guest-pill { background: rgba(36, 27, 22, 0.95); border-color: var(--dk-border); color: var(--dk-text-2); }
html.dark-theme .guest-pill .guest-pill-info { background: rgba(255,255,255,0.08); color: #b4bdf8; }
@media (max-width: 700px) {
    .guest-pill .guest-pill-text { display: none; }
}

/* ===== 2.6 п.6: кнопка озвучки чата лобби (15.11.2026) ===== */
.lobby-chat-title { display: flex; align-items: center; gap: 8px; }
.lobby-tts-toggle {
    margin-left: auto; padding: 2px 10px; font-size: 12px; border-radius: 12px;
    background: rgba(0,0,0,0.25); color: inherit; box-shadow: none; border: 1px solid rgba(255,255,255,0.25);
}
.lobby-tts-toggle.on { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-color: transparent; }

/* ===== Лицо «Влюблённость» 🥰 на стикерах (2.6 п.16; пересчитано 24.11.2026) =====
   Стикер вписывает лицо по его рисунку целиком (кадр 'tight'), а у «влюблённости»
   в рисунок входят сердечки: кадр в 1,49 раза шире самого лица (замер: 400 px
   против 269, у «сна» 264). ×1.2 возмещало это лишь отчасти — лицо оставалось
   на ~20% мельче соседних стикеров («пухлое маленькое»). Коробка ×1.49
   (50% → 74.5%), сдвиг — чтобы центр ЛИЦА, а не сердечек, встал туда же, куда
   у остальных эмоций (translate(-60%, -55%) от коробки 50%). */
.sticker-kolobok[data-emotion="love"] .player-sprite .avatar-face:not(.face-built),
.sticker-kolobok[data-emotion="love"] .lobby-face-top:not(.face-built) > div {
    width: 74.5%;
    height: 74.5%;
    transform: translate(-57.3%, -50.3%);
}
/* Сердечки — отдельным слоем над шаром и шапкой (stickers.js → applyLobbyFaceTop) */
.sticker-kolobok .lobby-face-top { z-index: 4; }

/* ===== 2.6 п.3: фото и гиф в чате лобби (15.11.2026) ===== */
.lobby-chat-input-area .lobby-media-btn,
.lobby-chat-input-area .lobby-media-btn:hover {
    background: transparent; box-shadow: none; transform: none; color: inherit;
    padding: 0 2px; min-width: 0; font-size: 16px; align-self: center;
}
.lobby-media-btn {
    padding: 0 2px; min-width: 0; width: auto; background: transparent; box-shadow: none; border: none;
    font-size: 14px; line-height: 1; cursor: pointer; flex: 0 0 auto; opacity: 0.8;
}
.lobby-media-btn:hover { opacity: 1; }
.lobby-msg-media { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; }
.lobby-msg-media img {
    max-width: 120px; max-height: 100px; border-radius: 6px; cursor: zoom-in; display: block;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.lobby-media-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 4px; }
.lobby-media-chip { position: relative; width: 48px; height: 48px; }
.lobby-media-chip img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
.lobby-media-chip.loading img { opacity: 0.45; }
.lobby-media-chip button {
    position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; min-width: 0; padding: 0;
    border-radius: 50%; font-size: 10px; line-height: 18px; background: #333; color: #fff; border: none; box-shadow: none; cursor: pointer;
}
.lobby-media-gone { font-size: 12px; opacity: 0.7; }
#lobby-chat.lobby-drop { outline: 2px dashed #8a7cd8; outline-offset: -4px; }
.lobby-media-viewer {
    position: fixed; inset: 0; z-index: 2147483000; background: rgba(0,0,0,0.85);
    touch-action: none;
    display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
/* Просмотр — на весь экран: и маленькую картинку растягиваем, а не оставляем крохой */
.lobby-media-viewer img { width: 94vw; height: 92vh; object-fit: contain; border-radius: 6px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lobby-media-viewer-close {
    position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px;
    width: 40px; height: 40px; padding: 0; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.18); color: #fff; font-size: 20px; line-height: 40px; cursor: pointer;
}
@media (max-width: 480px) { .lobby-msg-media img { max-width: 35vw; } }

/* ===== 2.6 п.5: «Выкрикнуть» — маленький 📢, режим в два шага (15.11.2026) ===== */
#shoutToggle {
    width: 22px; height: 22px; padding: 0; min-width: 0; flex-shrink: 0; align-self: center;
    font-size: 11px; line-height: 1; border-radius: 50%; box-sizing: border-box;
    background: transparent; border: 1px solid rgba(255,255,255,0.18); box-shadow: none;
    opacity: 0.55; cursor: pointer; transition: opacity 0.15s, background 0.15s;
}
#shoutToggle:hover { opacity: 0.9; }
#shoutToggle.armed { opacity: 1; background: #f0a030; border-color: #f0a030; }
#chatInput.shout-armed { outline: 2px solid #f0a030; outline-offset: -1px; }

/* ===== 2.6 п.20: вкладки «Мои / Публичные» в окне записей ===== */
.recordings-tabs { display: flex; gap: 4px; margin: 0 0 10px; }
.recordings-tabs button {
    flex: 1 1 0;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #6b5848;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.recordings-tabs button.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.recordings-watch-btn.recordings-public-on { background: rgba(102, 126, 234, 0.18); color: #4c51bf; }
html.dark-theme .recordings-tabs button:not(.active) { background: rgba(255, 255, 255, 0.06); color: var(--dk-text); }
html.dark-theme .recordings-watch-btn.recordings-public-on { color: #b4bdf8; }

/* 2.6 п.20: описание публичной записи */
.recordings-row-desc {
    display: block;
    margin: 3px 0 2px;
    font-size: 13px;
    line-height: 1.4;
    color: #3a2b20;
    font-style: italic;
    white-space: pre-line;
}
.recordings-desc-editor {
    margin: -4px 0 8px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(102, 126, 234, 0.07);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.recordings-desc-editor textarea,
.crm-public-desc {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    padding: 7px 9px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
}
.crm-public-desc { grid-column: 1 / -1; }
.recordings-desc-hint { font-size: 12px; color: #8a7565; }
.recordings-desc-bar { display: flex; justify-content: flex-end; gap: 6px; }
.recordings-desc-ok {
    padding: 5px 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
html.dark-theme .recordings-row-desc { color: var(--dk-text); }
html.dark-theme .recordings-desc-editor textarea,
html.dark-theme .crm-public-desc { background: rgba(255, 255, 255, 0.05); color: var(--dk-text); border-color: rgba(255, 255, 255, 0.12); }
/* «?» у галочки «🌍 Публичная запись» и окно-пояснение (баги 18.11.2026) */
.public-rec-help {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; padding: 0; margin-left: 4px;
    border-radius: 50%; border: 1px solid #9aa3c7; background: transparent;
    color: #5a67d8; font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer;
}
.public-rec-help:hover { background: rgba(90, 103, 216, 0.12); }
.public-rec-help-content { max-width: 420px; }
.public-rec-help-body { padding: 4px 20px 8px; font-size: 14px; line-height: 1.45; }
.public-rec-help-body p { margin: 0 0 10px; }
.public-rec-help-body a { color: #5a67d8; text-decoration: underline; overflow-wrap: anywhere; }
.public-rec-help-muted { color: #888; font-size: 12px; }
html.dark-theme .public-rec-help { color: #a3b1ff; border-color: #5c6491; }
html.dark-theme .public-rec-help-body a { color: #a3b1ff; }

/* 17.11.2026: ответы и стикеры в комментариях «Сообщества» */
.community-comment-reply {
    padding: 1px 6px; border: none; border-radius: 6px; background: transparent;
    color: #8a7565; font-size: 11px; cursor: pointer;
}
.community-comment-reply:hover { background: rgba(102, 126, 234, 0.12); color: #4c51bf; }
.community-comment-head .community-comment-reply + .community-comment-del,
.community-comment-head .community-comment-reply { margin-left: auto; }
.community-comment-head .community-comment-reply + .community-comment-del { margin-left: 0; }
.community-comment-quote {
    display: block; width: 100%; text-align: left; margin: 4px 0 2px;
    padding: 4px 8px; border: none; border-left: 3px solid #667eea; border-radius: 4px 8px 8px 4px;
    background: rgba(102, 126, 234, 0.08); color: #6b5848; font-size: 12px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.community-comment.flash { animation: community-comment-flash 1.2s ease; }
@keyframes community-comment-flash { 0%, 40% { box-shadow: 0 0 0 2px #667eea; } 100% { box-shadow: 0 0 0 0 transparent; } }
.community-reply-chip {
    display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px;
    background: rgba(102, 126, 234, 0.1); color: #6b5848; font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.community-reply-chip button { margin-left: auto; border: none; background: none; cursor: pointer; color: #8a7565; }
.community-comment-form { position: relative; }
.community-sticker-picker { position: static; max-height: 240px; overflow-y: auto; }
.community-comment-attach.active { opacity: 1; }
html.dark-theme .community-comment-quote,
html.dark-theme .community-reply-chip { color: var(--dk-text-2); }

/* ===== 2.6 п.25: «Кто в сети» по клику на счётчик ===== */
#online-counter.clickable { cursor: pointer; }
#online-counter.clickable:hover { box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25); }
.online-peek {
    z-index: 1200;
    width: 300px; max-width: calc(100vw - 16px); max-height: 60vh; overflow-y: auto;
    padding: 12px 14px;
    background: #fff; border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    color: #3a2b20; font-size: 13px;
}
.online-peek-head { font-size: 14px; margin-bottom: 8px; }
.online-peek-room { padding: 8px 0; border-top: 1px solid rgba(0, 0, 0, 0.07); }
.online-peek-room-title { display: flex; align-items: baseline; gap: 6px; font-weight: 600; margin-bottom: 5px; overflow-wrap: anywhere; }
.online-peek-state { margin-left: auto; font-size: 11px; font-weight: 500; color: #8a7565; white-space: nowrap; }
.online-peek-people { display: flex; flex-wrap: wrap; gap: 4px; }
.online-peek-person {
    padding: 2px 9px; border-radius: 99px;
    background: rgba(102, 126, 234, 0.12); color: #4c51bf; font-size: 12px;
}
button.online-peek-person { border: 0; font: inherit; font-size: 12px; cursor: pointer; }
button.online-peek-person:hover { filter: brightness(0.92); text-decoration: underline; }
.online-peek-person.guest { background: rgba(0, 0, 0, 0.05); color: #6b5848; }
.online-peek-rest, .online-peek-empty { padding-top: 8px; border-top: 1px solid rgba(0, 0, 0, 0.07); font-size: 12px; color: #8a7565; }
html.dark-theme .online-peek { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .online-peek-person { color: #b4bdf8; }
html.dark-theme .online-peek-person.guest { background: rgba(255, 255, 255, 0.06); color: var(--dk-text-2); }
html.dark-theme .online-peek-room, html.dark-theme .online-peek-rest { border-top-color: var(--dk-border); }

/* ===== 2.6 п.21.5: приватные комнаты — заявки и приглашения ===== */
.invite-cards {
    position: fixed; right: 16px; bottom: 80px; z-index: 1300;
    display: flex; flex-direction: column; gap: 8px; width: 300px; max-width: calc(100vw - 32px);
}
.invite-card {
    padding: 12px 14px; border-radius: 14px; background: #fff; color: #3a2b20;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25); font-size: 13px; line-height: 1.4;
}
.invite-card-bar { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.invite-card-primary, .invite-card-secondary {
    padding: 5px 14px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: none;
}
.invite-card-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.invite-card-secondary { background: rgba(0, 0, 0, 0.06); color: #6b5848; }
.invite-card-muted { color: #8a7565; font-size: 12px; }
.private-join-content { position: relative; max-width: 360px; padding: 22px 22px 18px; text-align: center; }
.private-join-title { font-size: 18px; font-weight: 700; color: #3a2b20; overflow-wrap: anywhere; }
.private-join-sub { margin: 6px 0 14px; font-size: 13px; color: #8a7565; }
.private-join-row { display: flex; gap: 6px; }
.private-join-row input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.15); font: inherit; }
.private-join-enter { padding: 8px 16px; }
.private-join-or { margin: 12px 0 8px; font-size: 12px; color: #8a7565; }
.private-join-ask {
    width: 100%; padding: 9px 14px; border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; font-weight: 600;
}
.private-join-ask:disabled { opacity: 0.6; cursor: default; }
.private-join-status { margin-top: 10px; font-size: 13px; color: #6b5848; min-height: 1em; }
.private-join-close {
    position: absolute; top: 8px; right: 10px; padding: 2px 6px; border: none; background: none;
    box-shadow: none; color: #8a7565; font-size: 15px; cursor: pointer;
}
.lobby-invite-btn, .lobby-invite-btn:hover {
    padding: 3px 10px; border: none; border-radius: 99px; font-size: 12px; font-weight: 600;
    background: rgba(102, 126, 234, 0.14); color: #4c51bf; box-shadow: none; transform: none; cursor: pointer;
}
.invite-friends-panel {
    position: fixed; z-index: 1300; width: 280px; max-height: 50vh; overflow-y: auto;
    padding: 10px 12px; border-radius: 14px; background: #fff; color: #3a2b20;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25); font-size: 13px;
}
.invite-friend-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.invite-friend-row span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.invite-friend-row button {
    padding: 3px 10px; border: none; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
    background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; box-shadow: none;
}
.invite-friend-row button:disabled { background: rgba(0,0,0,0.08); color: #6b5848; }
html.dark-theme .invite-card, html.dark-theme .invite-friends-panel { background: var(--dk-surface); color: var(--dk-text); }
html.dark-theme .private-join-title { color: var(--dk-text); }

/* 🌼 Расход за партию у плательщика (баги 18.11.2026, п.2) */
.game-flowers-spend {
    position: fixed; left: 10px; bottom: 10px; z-index: 9000;
    max-width: min(320px, calc(100vw - 20px)); padding: 6px 12px; border-radius: 14px;
    border: 1px solid rgba(184, 134, 11, 0.35); background: rgba(255, 248, 225, 0.95); color: #6b4f0a;
    font-size: 12px; text-align: left; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.game-flowers-spend .gfs-list { display: none; margin-top: 6px; }
.game-flowers-spend.open .gfs-list { display: block; }
.game-flowers-spend .gfs-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.game-flowers-spend .gfs-model { color: #a08850; font-size: 11px; }
html.dark-theme .game-flowers-spend { background: rgba(40, 34, 20, 0.95); color: #f7d774; border-color: rgba(247, 215, 116, 0.3); }
html.dark-theme .game-flowers-spend .gfs-model { color: #c9b071; }

/* Меню у крестика игрока в лобби: выгнать / в зрители (18.11.2026) */
.lobby-kick-menu { position: fixed; z-index: 10050; display: flex; flex-direction: column; min-width: 190px; padding: 4px; border-radius: 10px; background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.lobby-kick-menu button { padding: 8px 12px; border: none; border-radius: 7px; background: transparent; color: #3a2b20; font-size: 14px; text-align: left; cursor: pointer; }
.lobby-kick-menu button:hover { background: #f3ece4; }
.lobby-kick-menu button:last-child { color: #c0392b; }
html.dark-theme .lobby-kick-menu { background: #2a2a3a; }
html.dark-theme .lobby-kick-menu button { color: #e8e8f0; }
html.dark-theme .lobby-kick-menu button:hover { background: rgba(255,255,255,0.08); }
html.dark-theme .lobby-kick-menu button:last-child { color: #ff8a80; }
