/* ==========================================================================
   🎮 КИБЕР-СПОРТИВНОЕ НЕОНОВОЕ ОФОРМЛЕНИЕ И ГЕОМЕТРИЯ СЕТИ (ЧАСТЬ 1)
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background-color: #070a12;
    color: #ffffff;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Принудительное подключение жирного шрифта Chess.com */
.setup-title, #mate-text, .report-header, .stat-badge, #eval-text {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 900 !important;
}

/* ГЛАВНЫЙ СЕТОЧНЫЙ КОНТЕЙНЕР ПРИЛОЖЕНИЯ */
.app-container {
    display: flex;
    flex-direction: row;
    width: 95vw;
    height: 90vh;
    max-width: 1200px;
    background: rgba(20, 27, 45, 0.7);
    border: 2px solid #00f0ff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.2);
    position: relative;
    z-index: 10;
}

/* 📊 ВЕРТИКАЛЬНАЯ ШКАЛА ОЦЕНКИ (EVALUATION BAR) */
#eval-bar-container {
    width: 35px;
    height: 100%;
    background-color: #262421; /* Черные пешки (Chess.com) */
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #403d39;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-right: 20px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

#eval-bar-fill {
    width: 100%;
    height: 50%;
    background-color: #ffffff; /* Белые пешки */
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#eval-text {
    position: absolute;
    width: 100%;
    text-align: center;
    left: 0;
    font-size: 11px;
    color: #000000;
    mix-blend-mode: difference; /* Эпичная формула: белый текст на черном, черный на белом! */
    z-index: 12;
    bottom: 50%;
    transform: translateY(50%);
    letter-spacing: -0.5px;
}

/* ДОСКА И КОНТРОЛЛЕРЫ БЛОКА */
.board-wrapper {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.engine-status-bar {
    width: 100%;
    max-width: 520px;
    background: #111726;
    border: 1px solid #00f0ff;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: #00f0ff;
    margin-bottom: 15px;
    letter-spacing: 1px;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

.chess-container {
    position: relative;
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1;
}

#chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    border: 4px solid #1e293b;
    border-radius: 8px;
    overflow: hidden;
    background: #111726;
}

#attack-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* 🎨 ШАХМАТНЫЕ ТЕМЫ КЛЕТОК (CYBER И CLASSIC) */
.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    height: 100%;
}

.theme-cyber .cell.w { background-color: #1e293b; }
.theme-cyber .cell.b { background-color: #0f172a; }
.theme-classic .cell.w { background-color: #eeeed2; }
.theme-classic .cell.b { background-color: #769656; }

.piece {
    width: 88%;
    height: 88%;
    object-fit: contain;
    z-index: 5;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ХАЙЛАЙТЫ ХОДОВ И ВЫДЕЛЕНИЯ */
.highlight { box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.6); background-color: rgba(0, 240, 255, 0.15) !important; }
.selected-glow { box-shadow: inset 0 0 20px #ff007f; background-color: rgba(255, 0, 127, 0.2) !important; }

/* ==========================================================================
   🎮 КИБЕР-СПОРТИВНОЕ НЕОНОВОЕ ОФОРМЛЕНИЕ И ГЕОМЕТРИЯ СЕТИ (ЧАСТЬ 2)
   ========================================================================== */

/* 📖 ИНТЕРАКТИВНАЯ ПАНЕЛЬ ИСТОРИИ ХОДОВ */
.side-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 20px;
    gap: 20px;
    height: 100%;
}

.panel-section {
    background: #111726;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.panel-section:first-child {
    flex: 1;
    height: calc(100% - 140px);
}

.panel-header {
    font-size: 14px;
    color: #64748b;
    letter-spacing: 1px;
    margin-bottom: 12px;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 6px;
    text-transform: uppercase;
}

.moves-box {
    flex: 1;
    overflow-y: auto;
    font-size: 15px;
    line-height: 28px;
    color: #94a3b8;
    padding-right: 5px;
}

/* Кликабельные спаны отдельных ходов (Chess.com Style) */
.clickable-move-node {
    color: #38bdf8;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.1s ease;
    display: inline-block;
}
.clickable-move-node:hover { background: rgba(56, 189, 248, 0.15); color: #ffffff; }
.clickable-move-node.active-history-node { background: #0284c7 !important; color: #ffffff !important; font-weight: bold; box-shadow: 0 0 8px rgba(2, 132, 199, 0.5); }

/* ДИСПЛЕЙ ОТЛАДКИ И СЕРВЕРА */
.debug-box {
    height: 110px;
    gap: 8px;
}
.debug-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #94a3b8;
}
.debug-row strong { color: #00f0ff; letter-spacing: 0.5px; }

/* КНОПКИ НАВИГАЦИИ СТРЕЛОК ВЗАМЕН ОТКАТА */
.action-controls-row {
    display: flex;
    width: 100%;
    max-width: 520px;
    justify-content: space-between;
    margin-top: 15px;
    gap: 12px;
}

.nav-control-btn {
    flex: 1;
    background: #1e293b;
    border: 1px solid #334155;
    color: #ffffff;
    padding: 14px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}
.nav-control-btn:hover:not(:disabled) { background: #00f0ff; color: #000000; box-shadow: 0 0 15px #00f0ff; border-color: #00f0ff; }
.nav-control-btn:disabled { opacity: 0.2; cursor: not-allowed; box-shadow: none !important; }
#settings-trigger { font-size: 14px; }

/* ОБЩИЕ ЭКРАНЫ НАСТРОЕК И ОВЕРЛЕЕВ */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(7, 10, 18, 0.96);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.overlay.active { opacity: 1; pointer-events: auto; }

/* СТАРТОВАЯ КОРОБКА ПРАВИЛ */
.setup-box {
    background: #111726;
    border: 2px solid #00f0ff;
    border-radius: 12px;
    width: 90vw;
    max-width: 420px;
    padding: 30px;
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.25);
    text-align: center;
}
.setup-title { font-size: 36px; color: #00f0ff; letter-spacing: 2px; text-shadow: 0 0 15px #00f0ff; margin-bottom: 2px; }
.setup-subtitle { font-size: 12px; color: #64748b; letter-spacing: 4px; margin-bottom: 30px; }

.setup-section {
    text-align: left;
    margin-bottom: 25px;
}
.section-label { font-size: 11px; color: #64748b; letter-spacing: 1px; display: block; margin-bottom: 10px; font-weight: bold; }

.side-selector { display: flex; gap: 10px; }
.side-btn {
    flex: 1; background: #1e293b; border: 1px solid #334155; color: #ffffff; padding: 12px; border-radius: 6px; font-weight: bold; cursor: pointer; transition: all 0.15s; font-size: 13px;
}
.side-btn.active { background: #00f0ff; color: #000000; box-shadow: 0 0 15px #00f0ff; border-color: #00f0ff; }

/* СЛАЙДЕРЫ */
.cyber-slider {
    -webkit-appearance: none;
    appearance: none; /* 🔥 Стандартное свойство, чтобы VS Code перестал ругаться! */
    width: 100%;
    height: 6px;
    background: #1e293b;
    border-radius: 3px;
    outline: none;
}
.cyber-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none; /* 🔥 Железобетонный стандарт для ползунка */
    width: 18px;
    height: 18px;
    background: #00f0ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px #00f0ff;
    transition: transform 0.1s;
}
.cyber-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.btn-neon-trigger {
    width: 100%; background: transparent; border: 2px solid #00f0ff; color: #00f0ff; padding: 15px; font-size: 16px; font-weight: bold; border-radius: 6px; cursor: pointer; letter-spacing: 1px; transition: all 0.2s; margin-top: 10px; box-shadow: 0 0 10px rgba(0,240,255,0.1);
}
.btn-neon-trigger:hover { background: #00f0ff; color: #000000; box-shadow: 0 0 25px #00f0ff; }

/* 💀 КАТ-СЦЕНА МАТА И АНИМАЦИЯ КОРОЛЯ (UNDERTALE TIMELINE) */
#mate-overlay {
    background: rgba(0, 0, 0, 0.98);
}

#mate-text {
    color: #ff0000;
    font-size: 82px;
    letter-spacing: 6px;
    text-shadow: 0 0 35px #ff0000;
    opacity: 0;
    z-index: 1005;
    position: absolute;
}

#animation-king-holder {
    position: absolute;
    width: 65px;
    height: 65px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    pointer-events: none;
    transform-origin: center center;
}
#animation-king-holder img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 📊 ПЛАШКА ОТЧЁТА О ПАРТИИ (CHESS.COM STYLE) */
.report-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.report-box {
    width: 92vw;
    max-width: 460px;
    background: #262421;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
}

.report-box.animate-appearance {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s cubic-bezier(0.34, 1.3, 0.64, 1), transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.report-header {
    font-size: 20px;
    letter-spacing: 1px;
    color: #ffffff;
    margin-bottom: 22px;
    border-bottom: 1px solid #3d3b38;
    padding-bottom: 12px;
}

.loader-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px 0;
}

.shimmer-icon-slot {
    font-size: 32px;
    display: inline-block;
    animation: pulseIconShimmer 0.25s infinite alternate;
}

#loader-text-status {
    font-size: 14px;
    color: #c3c1be;
    font-style: italic;
}

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 22px;
    text-align: left;
    width: 100%;
}

.stat-line {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    opacity: 0;
}

.stat-line.fade-in-badge {
    opacity: 1;
    transition: opacity 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

.stat-badge {
    padding: 5px 12px;
    border-radius: 4px;
    color: #ffffff;
    font-size: 11px;
    min-width: 140px;
    text-align: center;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Цвета плашек оценок Chess.com */
.badge-brilliant { background-color: #1baca6; }
.badge-great { background-color: #5c8bb0; }
.badge-best { background-color: #81b64c; }
.badge-excellent { background-color: #81b64c; }
.badge-good { background-color: #5c8bb0; }
.badge-book { background-color: #a45a3a; }
.badge-forced { background-color: #b1b0ad; }
.badge-inaccuracy { background-color: #f7c04a; color: #000 !important; }
.badge-mistake { background-color: #e57f35; }
.badge-miss { background-color: #ff3b30; }
.badge-blunder { background-color: #b43d3b; }

.stat-count {
    font-size: 15px;
    color: #ffffff;
    opacity: 0;
}
.stat-count.fade-in-text {
    opacity: 1;
    transition: opacity 0.2s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

.btn-green-report {
    width: 100%;
    background: #81b64c;
    border: none;
    color: #ffffff;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 0 #5f8936;
    opacity: 0;
    transition: background 0.1s, opacity 0.2s ease;
}
.btn-green-report:hover { background: #91c951; }
.btn-green-report.visible { opacity: 1; }

.analysis-badge-floating {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 28px;
    z-index: 150;
    opacity: 0;
}
.analysis-badge-floating.show-node-badge {
    opacity: 1;
    transition: opacity 0.5s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

@keyframes pulseIconShimmer {
    0% { transform: scale(0.8) rotate(-10deg); opacity: 0.5; }
    100% { transform: scale(1.2) rotate(10deg); opacity: 1; }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; height: auto; width: 98vw; padding: 10px; gap: 10px; }
    #eval-bar-container { width: 100%; height: 25px; flex-direction: row; justify-content: flex-start; margin-right: 0; margin-bottom: 10px; }
    #eval-bar-fill { height: 100%; width: 50%; transition: width 0.4s ease; }
    #eval-text { bottom: 0; top: 0; transform: none; display: flex; justify-content: center; align-items: center; }
    .side-panel { margin-left: 0; width: 100%; }
    .panel-section:first-child { height: 200px; }
}

/* ==========================================================================
   🤖 ДОПОЛНИТЕЛЬНЫЕ ЭЛЕМЕНТЫ И НЕОНОВЫЙ КИБЕР-ГЛОВ (РАСШИРЕНИЕ ДО 540 СТРОК)
   ========================================================================== */

/* Кастомный неоновый скроллбар для Chess.com истории ходов */
.moves-box::-webkit-scrollbar {
    width: 6px;
}
.moves-box::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 4px;
}
.moves-box::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
    border: 1px solid #334155;
}
.moves-box::-webkit-scrollbar-thumb:hover {
    background: #00f0ff;
    box-shadow: 0 0 10px #00f0ff;
}

/* Фикс позиционирования картинок фигур на доске */
.cell img {
    pointer-events: none;
    transition: all 0.15s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Ограничитель высоты для предотвращения прыжков интерфейса */
.board-wrapper, .side-panel {
    max-height: 100%;
}

/* Кастомный триггер для плавной Ease-In-Out прогрузки плашек */
.stats-container, .loader-zone {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Стилизация текста ошибок и критических уведомлений */
.critical-alert-popup {
    color: #ff3b30;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 59, 48, 0.4);
}

/* Плавная подсветка активных окон в теме Cyber */
@keyframes cyberGlow {
    0% { border-color: #1e293b; box-shadow: none; }
    100% { border-color: #00f0ff; box-shadow: 0 0 15px rgba(0, 240, 255, 0.2); }
}

.panel-section:hover {
    animation: cyberGlow 0.5s forwards;
}

.hidden { display: none !important; }