/* ==========================================================================
   🎮 ГЛОБАЛЬНЫЙ ПРЕМИУМ-ИНТЕРФЕЙС И ЦИАНОВЫЕ СЕТЕВЫЕ ТЕМЫ
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0b0e11;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
}

.theme-cyber {
    --bg-main: #0b0e11;
    --bg-panel: #151a21;
    --cell-light: #e2e8f0;
    --cell-dark: #475569;
    --cyan-glow: #00f0ff;
    --cyan-dim: rgba(0, 240, 255, 0.15);
    --btn-primary: #00f0ff;
    --btn-text: #000000;
}

.theme-classic {
    --bg-main: #302e2b;
    --bg-panel: #262421;
    --cell-light: #eeeed2;
    --cell-dark: #769656;
    --cyan-glow: #81b64c;
    --cyan-dim: rgba(129, 182, 76, 0.2);
    --btn-primary: #81b64c;
    --btn-text: #ffffff;
}

/* ⚙️ ЭКРАН НАСТРОЙКИ ПРАВИЛ (ПОЛНОЭКРАННОЕ БЛОКИРУЮЩЕЕ ОКНО) */
.setup-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(11, 14, 17, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.setup-modal {
    background-color: #151a21;
    border: 2px solid var(--cyan-glow);
    box-shadow: 0 0 20px var(--cyan-dim);
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setup-title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    color: var(--cyan-glow);
    letter-spacing: 1px;
}

.setup-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setup-label {
    font-size: 12px;
    font-weight: bold;
    color: #94a3b8;
}

/* Стилизация выпадающего списка времени обдумывания */
.setup-select {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 10px;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    outline: none;
    cursor: pointer;
}

.setup-select:focus {
    border-color: var(--cyan-glow);
}

.setup-btn-group {
    display: flex;
    gap: 8px;
}

.btn-setup-choice {
    flex: 1;
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #ffffff;
    padding: 10px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

/* Активное выделение выбранной стороны ИИ */
.btn-setup-choice.active-choice {
    border-color: var(--cyan-glow);
    background-color: var(--cyan-dim);
    color: var(--cyan-glow);
    box-shadow: 0 0 8px var(--cyan-dim);
}

.btn-start-battle {
    background-color: var(--cyan-glow);
    color: #000000;
    font-size: 14px;
    font-weight: bold;
    padding: 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    margin-top: 10px;
    box-shadow: 0 4px 12px var(--cyan-dim);
}

.btn-start-battle:active {
    transform: scale(0.98);
}

/* 📊 РОДНОЙ ДВУХКОЛОНОЧНЫЙ МАКЕТ ПРИЛОЖЕНИЯ */
.chess-layout-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
    padding: 10px;
    gap: 12px;
    position: relative;
}

/* ==========================================================================
   🧩 ИГРОВОЕ ПОЛЕ И ТРЁХСЛОЙНЫЙ ГРАФИЧЕСКИЙ ДВИЖОК ПОД ГЕОМЕТРИЮ 752x752
   ========================================================================== */

.eval-bar-sidebar {
    width: 20px;
    height: 100%;
    background-color: #000000;
    border: 1px solid #334155;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Белые фигуры растут снизу вверх */
}

.eval-bar-fill {
    width: 100%;
    height: 50%; /* Стартовое деление пополам (0.00) */
    background-color: #ffffff;
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.eval-text {
    position: absolute;
    width: 100%;
    text-align: center;
    bottom: 10px;
    font-size: 10px;
    font-weight: bold;
    color: #000000;
    z-index: 5;
    mix-blend-mode: difference;
}

.game-board-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.engine-indicator-bar {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 380px;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.board-wrapper {
    width: 100%;
    max-width: 380px;
    aspect-ratio: 1 / 1;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    background-size: cover;
    background-image: url("empty_chess_board.png"); /* Слой 0: Твоя пустая доска */
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
}

.cell {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Слой 1: Лимонный хайлайт клеток (chess_move_highlight.png) */
.cell.highlight::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url("chess_move_highlight.png");
    background-size: cover;
    z-index: 1;
    pointer-events: none;
}

/* Интерактивная рамка при ручном клике на фигуру */
.cell.selected-glow::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--cyan-dim);
    border: 2px solid var(--cyan-glow);
    z-index: 1;
    pointer-events: none;
}

/* Слой 2: Отрисовка фигур */
.piece {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
    cursor: grab;
    transition: transform 0.1s ease;
}

.piece:active { cursor: grabbing; }

/* Холст векторной Canvas-анимации атак */
.attack-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* ==========================================================================
   💀 ПОЛНОЭКРАННЫЙ СЛОЙ МАТА (UNDERTALE DEATH OVERLAY)
   ========================================================================== */

.mate-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: none;
    transition: background-color 1s ease;
}

.mate-overlay.active {
    background-color: rgba(0, 0, 0, 0.7);
}

.mate-text-undertale {
    font-family: 'Determination Mono', 'Courier New', Courier, monospace;
    font-size: 72px;
    font-weight: 900;
    color: #ff0000;
    text-shadow: 
        -4px -4px 0 #000,  4px -4px 0 #000,
        -4px  4px 0 #000,  4px  4px 0 #000;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mate-text-undertale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   📊 БЛОК АНАЛИТИКИ, СКРОЛЛ ХОДОВ И СТАТИСТИКА КАТЕГОРИЙ (CHESS.COM STYLE)
   ========================================================================== */

.analytics-sidebar {
    display: flex;
    flex-direction: column;
    flex: 1;
    background-color: var(--bg-panel);
    border-radius: 8px;
    padding: 12px;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    min-width: 200px;
}

.status-widget {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 4px;
}

/* 📖 КОНТЕЙНЕР ТАБЛИЦЫ ХОДОВ И КРАСИВЫЙ СКРОЛЛБАР */
.move-history-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border: 1px solid #1e293b;
    overflow: hidden;
}

.move-history-header {
    background-color: #1e293b;
    padding: 6px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

.move-list-content {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
}

/* Стилизация полосы прокрутки скролла */
.move-list-content::-webkit-scrollbar { width: 4px; }
.move-list-content::-webkit-scrollbar-track { background: transparent; }
.move-list-content::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

/* 🏆 ИТОГОВАЯ ПЛАШКА ОТЧЁТА И МУЛЬТИЯЗЫЧНАЯ СТАТИСТИКА СЧЁТЧИКОВ */
.review-box {
    background: #0f172a;
    border-left: 4px solid var(--btn-primary);
    padding: 10px;
    border-radius: 4px;
    animation: slideIn 0.4s ease-out;
}

.review-title {
    font-size: 11px;
    color: #64748b;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.review-verdict {
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 8px;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    border-top: 1px solid #1e293b;
    padding-top: 6px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.stat-count {
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 3px;
    min-width: 22px;
    text-align: center;
}

/* Цвета плашек точно как на страницах отчетов Chess.com */
.stat-item.brilliant .stat-count { background-color: #1baca6; color: #fff; }
.stat-item.best .stat-count { background-color: #81b64c; color: #fff; }
.stat-item.excellent .stat-count { background-color: #96bc4b; color: #fff; }
.stat-label { color: #94a3b8; }

/* ⚙️ УПРАВЛЯЮЩИЕ КНОПКИ (ВЕРТИКАЛЬНЫЙ СТЕК) */
.button-container-vertical {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.button-group-row {
    display: flex;
    gap: 6px;
    width: 100%;
}

button {
    border: none;
    border-radius: 4px;
    padding: 10px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    text-transform: uppercase;
}

.btn-primary { background-color: var(--btn-primary); color: var(--btn-text); box-shadow: 0 2px 8px var(--cyan-dim); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background-color: #334155; color: #ffffff; }
.btn-secondary:active { background-color: #475569; }
.btn-danger { background-color: #ef4444; color: #ffffff; width: 100%; }

/* Виджет-шестерёнка */
.settings-trigger {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 18px;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.3s ease;
}
.settings-trigger:hover { transform: rotate(45deg); }
.hidden { display: none !important; }

/* 📱 АДАПТИВНОСТЬ ПОД МОБИЛЬНЫЕ ТЕЛЕФОНЫ (ПЕРЕВОД В ВЕРТИКАЛЬНЫЙ СТЕК) */
@media (max-width: 600px) {
    .chess-layout-container {
        flex-direction: column;
        overflow-y: auto;
        padding: 5px;
        gap: 6px;
    }
    .eval-bar-sidebar {
        width: 100%;
        height: 12px;
        flex-direction: row;
        justify-content: flex-start;
    }
    .eval-bar-fill {
        height: 100%;
        width: 50%;
        transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .eval-text {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        bottom: auto;
    }
    .analytics-sidebar {
        width: 100%;
        max-width: 380px;
        min-height: 180px;
    }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}