/* ══════════════════════════════════════════════════════════════════
   Шахматы — Telegram Mini App
   Премиальный тёмный дизайн + Чат + Зрители
   ══════════════════════════════════════════════════════════════════ */

:root {
    /* ── Основная палитра ── */
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-card: #22222e;
    --bg-elevated: #2a2a38;
    --bg-glass: rgba(30, 30, 45, 0.85);

    /* ── Акценты ── */
    --accent: #7c6ff7;
    --accent-glow: rgba(124, 111, 247, 0.3);
    --accent-light: #a499ff;
    --gold: #f5c842;
    --green: #4caf82;
    --red: #e05555;
    --cyan: #42c9f5;

    /* ── Текст ── */
    --text-primary: #eaeaf0;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    /* ── Доска ── */
    --board-light: #e8dcc8;
    --board-dark: #7d945d;
    --board-highlight: rgba(255, 255, 100, 0.45);
    --board-selected: rgba(124, 111, 247, 0.5);
    --board-legal: rgba(124, 111, 247, 0.3);
    --board-check: rgba(224, 85, 85, 0.6);
    --board-last-move: rgba(255, 255, 100, 0.25);

    /* ── Размеры ── */
    --board-size: min(100vw - 16px, 480px);
    --cell-size: calc(var(--board-size) / 8);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ── Сброс и база ── */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ── Экраны ── */

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 auto;
    padding: 8px;
}

/* ── Экран ожидания ── */

.waiting-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    padding: 32px;
}

.waiting-icon {
    font-size: 64px;
    animation: pulse 2s ease-in-out infinite;
}

.waiting-container h2 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.waiting-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.loader {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.loader-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.loader-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

/* ══════════════════════════════════════════════════════════════
   Лейаут: доска + чат
   ══════════════════════════════════════════════════════════════ */

.game-layout {
    display: flex;
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    gap: 12px;
    min-height: 0;
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 520px;
    margin: 0 auto;
}

/* ── Панель игрока ── */

.player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    min-height: 48px;
}

.bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.opponent-avatar {
    background: linear-gradient(135deg, #444, #666);
}

.my-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

/* Аватарка — фото из Telegram */
.player-avatar .avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Аватарка — fallback с инициалами */
.player-avatar.avatar-initials {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.player-avatar {
    overflow: hidden;
    position: relative;
}

.player-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.player-name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
}

.player-elo {
    font-size: 11px;
    opacity: 0.7;
}

.bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    min-width: 50px;
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.timer.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.timer.low-time {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.15);
    border-color: rgba(255, 77, 77, 0.3);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.captured-pieces {
    display: flex;
    gap: 2px;
    height: 16px;
    font-size: 14px;
    max-width: 120px;
    justify-content: flex-end;
    opacity: 0.8;
}

/* ── Бейдж зрителей ── */

.spectator-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(66, 201, 245, 0.12);
    border: 1px solid rgba(66, 201, 245, 0.2);
    border-radius: 20px;
    font-size: 12px;
    color: var(--cyan);
    animation: fadeIn 0.3s ease;
}

.spectator-icon {
    font-size: 13px;
}

.spectator-count {
    font-weight: 600;
}

/* ── Баннер зрителя ── */

.spectator-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(66, 201, 245, 0.1), rgba(124, 111, 247, 0.1));
    border: 1px solid rgba(66, 201, 245, 0.15);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--cyan);
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ── Шахматная доска ── */

.board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0;
    flex-shrink: 0;
}

.board-container {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.cell.light {
    background-color: var(--board-light);
}

.cell.dark {
    background-color: var(--board-dark);
}

.cell.selected {
    background-color: var(--board-selected) !important;
}

.cell.last-move {
    background-color: var(--board-last-move) !important;
}

.cell.check {
    background: radial-gradient(circle, var(--board-check), transparent 70%) !important;
}

/* Точки допустимых ходов */
.cell.legal::after {
    content: '';
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: var(--board-legal);
    pointer-events: none;
}

/* Для ходов со взятием — кольцо вместо точки */
.cell.legal.has-piece::after {
    width: 85%;
    height: 85%;
    background: transparent;
    border: 3px solid var(--board-legal);
}

/* Координаты */
.cell .coord {
    position: absolute;
    font-size: 9px;
    font-weight: 700;
    pointer-events: none;
    opacity: 0.6;
}

.cell .coord-file {
    bottom: 2px;
    right: 4px;
}

.cell .coord-rank {
    top: 2px;
    left: 4px;
}

.cell.light .coord {
    color: var(--board-dark);
}

.cell.dark .coord {
    color: var(--board-light);
}

/* ── Шахматные фигуры ── */
.piece {
    font-size: calc(var(--cell-size) * 0.78);
    line-height: 1;
    cursor: grab;
    transition: transform 0.08s ease;
    filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.3));
    z-index: 1;
    /* Убираем глобальный цвет */
    color: var(--text-primary);
}

/* Белые фигуры: чисто белый цвет + тёмная обводка */
.piece.white {
    color: #ffffff;
    text-shadow:
        0 0 2px #000000,
        1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Чёрные фигуры: чисто чёрный цвет + светлая обводка */
.piece.black {
    color: #000000;
    text-shadow:
        0 0 1px #ffffff,
        0 0 2px #ffffff;
    /* Дополнительная коррекция для Unicode-фигур */
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.5));
}

.piece:active {
    cursor: grabbing;
    transform: scale(1.15);
}

.piece.dragging {
    position: fixed;
    z-index: 1000;
    transform: scale(1.25);
    pointer-events: none;
    filter: drop-shadow(2px 4px 8px rgba(0, 0, 0, 0.5));
}

/* ── Статус партии ── */

.game-status-bar {
    text-align: center;
    padding: 6px 12px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.status-text.your-turn {
    color: var(--green);
}

.status-text.opponent-turn {
    color: var(--text-secondary);
}

.status-text.game-over-status {
    color: var(--gold);
}

.status-text.check-status {
    color: var(--red);
    animation: pulseColor 1s ease-in-out infinite;
}

.status-text.spectator-status {
    color: var(--cyan);
}

@keyframes pulseColor {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ── Кнопки управления ── */

.controls-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 4px 0;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    position: relative;
}

.control-btn:hover,
.control-btn:active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    transform: scale(0.97);
}

.control-icon {
    font-size: 18px;
}

.control-label {
    font-size: 10px;
    font-weight: 500;
}

/* Непрочитанные сообщения чата */
.chat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--red);
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.25s ease;
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ── Список ходов ── */

.moves-panel {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    min-height: 40px;
    max-height: 120px;
}

.moves-list {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.move-number {
    color: var(--text-muted);
    margin-right: 2px;
    min-width: 20px;
}

.move-item {
    color: var(--text-secondary);
    padding: 2px 4px;
    border-radius: 3px;
    cursor: default;
}

.move-item:last-child {
    color: var(--accent-light);
    background: rgba(124, 111, 247, 0.1);
}

/* ══════════════════════════════════════════════════════════════
   ЧАТ
   ══════════════════════════════════════════════════════════════ */

.chat-panel {
    display: none;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s ease;
}

.chat-panel.open {
    display: flex;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.chat-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-online {
    font-size: 11px;
    color: var(--cyan);
}

.chat-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-system-msg {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px 0;
    font-style: italic;
}

/* Сообщения чата */
.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    background: var(--bg-elevated);
    border-radius: 10px;
    border-top-left-radius: 4px;
    animation: fadeIn 0.2s ease;
    max-width: 90%;
}

.chat-msg.own {
    align-self: flex-end;
    background: rgba(124, 111, 247, 0.15);
    border-top-left-radius: 10px;
    border-top-right-radius: 4px;
}

.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-msg-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.chat-msg-name.role-white {
    color: var(--gold);
}

.chat-msg-name.role-black {
    color: var(--accent-light);
}

.chat-msg-name.role-spectator {
    color: var(--cyan);
}

.chat-msg-role {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-msg-role.role-white {
    background: rgba(245, 200, 66, 0.15);
    color: var(--gold);
}

.chat-msg-role.role-black {
    background: rgba(164, 153, 255, 0.15);
    color: var(--accent-light);
}

.chat-msg-role.role-spectator {
    background: rgba(66, 201, 245, 0.12);
    color: var(--cyan);
}

.chat-msg-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg-time {
    font-size: 9px;
    color: var(--text-muted);
    align-self: flex-end;
}

/* Ввод чата */
.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-send {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px var(--accent-glow);
}

.chat-send:active {
    transform: scale(0.95);
}


/* ── Сообщения чата ── */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-system-msg {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin: 8px 0;
    font-style: italic;
}

.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--bg-elevated);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    animation: popIn 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-msg.own {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 8px rgba(124, 111, 247, 0.25);
}

.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin-bottom: 2px;
    opacity: 0.8;
}

.chat-msg.own .chat-msg-header {
    justify-content: flex-end;
    /* Имя справа для своих */
    flex-direction: row-reverse;
}

.chat-msg-name {
    font-weight: 600;
}

.chat-msg-role {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-msg-text {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg-time {
    display: block;
    font-size: 9px;
    text-align: right;
    margin-top: 2px;
    opacity: 0.6;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE: Мобилки vs ПК
   ══════════════════════════════════════════════════════════════ */

/* === МОБИЛКИ (по умолчанию) === */

.game-layout {
    flex-direction: column;
}

.game-main {
    max-width: 520px;
}

/* Чат на мобилках: выезжает снизу как нижний лист */
.chat-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55vh;
    z-index: 1500;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.open {
    display: flex;
    transform: translateY(0);
}

/* Затемнение фона при открытом чате на мобилке */
.chat-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1499;
    animation: fadeIn 0.25s ease;
}

.chat-backdrop.visible {
    display: block;
}

/* === ПК / Планшет (> 768px) === */
@media (min-width: 768px) {
    .game-layout {
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
        padding-top: 8px;
    }

    .game-main {
        max-width: 520px;
        flex-shrink: 0;
    }

    /* Чат на ПК — справа от доски */
    .chat-panel {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        width: 300px;
        height: calc(100vh - 32px);
        max-height: 680px;
        transform: none;
        border-radius: var(--radius);
        box-shadow: none;
        border: 1px solid rgba(255, 255, 255, 0.06);
        flex-shrink: 0;
    }

    .chat-panel.open {
        transform: none;
    }

    .chat-close {
        display: none;
    }

    .chat-backdrop {
        display: none !important;
    }

    /* На ПК кнопка «Чат» не нужна — чат всегда виден */
    #btn-chat-toggle {
        display: none;
    }

    /* Чат всегда открыт на ПК */
    .chat-panel {
        display: flex;
    }
}

/* ── Модальные окна ── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 24px;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 32px 28px;
    text-align: center;
    max-width: 340px;
    width: 100%;
    animation: slideUp 0.3s ease;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.result-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.modal-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.result-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.result-elo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 16px;
}

.elo-label {
    color: var(--text-secondary);
}

.elo-change {
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
}

.elo-change.positive {
    color: var(--green);
    background: rgba(76, 175, 130, 0.15);
}

.elo-change.negative {
    color: var(--red);
    background: rgba(224, 85, 85, 0.15);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.btn-primary:hover,
.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ── Превращение пешки ── */

.promotion-card {
    padding: 24px;
}

.promotion-pieces {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
}

.promotion-piece {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    background: var(--bg-elevated);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.promotion-piece:hover,
.promotion-piece:active {
    border-color: var(--accent);
    background: var(--bg-glass);
    transform: scale(1.08);
}

/* ── Адаптивность ── */

@media (max-height: 700px) {
    .player-bar {
        padding: 5px 10px;
        min-height: 40px;
    }

    .player-avatar {
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .player-name {
        font-size: 13px;
    }

    .game-status-bar {
        padding: 4px;
        min-height: 24px;
    }

    .controls-bar {
        padding: 2px 0;
    }

    .control-btn {
        padding: 6px 12px;
    }

    .moves-panel {
        max-height: 60px;
    }
}

@media (max-height: 600px) {
    .screen {
        padding: 4px;
    }

    .moves-panel {
        display: none;
    }
}

/* ── Анимация хода ── */

.cell-animate {
    animation: moveFlash 0.4s ease;
}

@keyframes moveFlash {
    0% {
        transform: scale(0.85);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ── Скроллбар ── */

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 2px;
}