
/* Стили проекта - Dark Mode (Professional) */

:root {
    --sidebar-width: 300px;
    --gap: 25px;
    
    /* Цветовая палитра - Dark Theme */
    --primary: #2196F3;       /* Оставляем синий акцент */
    --danger: #ef5350;        /* Чуть мягче красный */
    --success: #66bb6a;       /* Чуть мягче зеленый */
    
    --bg: #121212;            /* Основной фон (почти черный) */
    --panel-bg: #1e1e1e;      /* Фон панелей (темно-серый) */
    --text: #e0e0e0;          /* Основной текст (светло-серый) */
    --text-muted: #b0bec5;    /* Второстепенный текст */
    
    --border: #333333;        /* Цвет границ */
    --input-bg: #2c2c2c;      /* Фон полей ввода */
    
    --z-status: 1000;
}

* { box-sizing: border-box; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0; 
    background: var(--bg); 
    color: var(--text); 
    min-height: 100vh;
    min-height: 100dvh; /* Mobile browser bar fix */
    display: flex;
    flex-direction: column;
    /* Убираем "резиновость" прокрутки на iOS */
    overscroll-behavior-y: none;
}

/* Стили для главной страницы */
.home-page {
    justify-content: center;
    align-items: center;
    text-align: center;
}
.home-page .buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap; /* Чтобы кнопки переносились на узких экранах */
}
.home-page button {
    font-size: 1.2rem;
    padding: 15px 30px;
}
.home-page .student-btn {
    background-color: var(--success);
}

h1 { 
    text-align: center; 
    margin: 20px 0; 
    color: #eceff1; 
    font-weight: 500;
    font-size: clamp(1.5rem, 4vw, 2rem); /* Адаптивный размер шрифта */
}

/* Сетка страницы */
.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
    gap: var(--gap);
    align-items: start;
}

/* Панели */
.panel {
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.panel h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #90a4ae;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

/* Центральная колонка с доской */
.board-column {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Контейнер доски (Подложка и Рамка) */
.board-wrapper {
    position: relative;
    width: 100%;
    max-width: 700px; 
    margin: 0 auto; 
    background: var(--panel-bg);
    border-radius: 4px; /* Чуть острее углы для рамки */
    padding: 0; /* Убираем паддинг */
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    border: 5px solid #424242; /* Красивая рамка здесь */
    touch-action: none;
    display: flex; 
    flex-direction: column;
    user-select: none;
    align-items: center; 
    transition: all 0.3s ease;
}

/* Сама доска */
#board {
    width: 100%; 
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    /* Убираем z-index hacks, позволяем библиотеке самой управлять слоями */
}

/* --- ВАЖНОЕ ИСПРАВЛЕНИЕ: Убираем custom border с внутренних div'ов chessboard.js --- */
#board div[class^="board-"] {
    box-sizing: content-box; 
    border: none !important; 
}

/* Слой стрелок (Над фигурами) */
/* Мы используем pointer-events: none, чтобы клики проходили сквозь него к доске */
#arrowLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100; /* Поверх фигур */
}

div[class^="spare-pieces-"] {
    padding: 5px; 
    background: #1e1e1e;
}

/* АНИМАЦИЯ МЕРЦАНИЯ СТРЕЛОК */
@keyframes neonPulse {
    0%, 100% {
        opacity: 0.8;
        filter: drop-shadow(0 0 5px rgba(255, 179, 0, 0.5));
    }
    50% {
        opacity: 1;
        filter: drop-shadow(0 0 10px rgba(255, 179, 0, 0.9));
    }
}

/* НЕОНОВАЯ СТРЕЛКА (ARROW) */
.arrow-line {
    stroke: #ffb300; /* Золотой цвет */
    stroke-width: 4px;
    stroke-linecap: round; /* Закругленные концы */
    transition: all 0.2s ease;
    animation: neonPulse 3s infinite ease-in-out;
}

/* АНИМАЦИЯ ПУЛЬСАЦИИ ПОДСВЕТКИ (box-shadow) */
@keyframes highlightPulse {
    0%, 100% {
        /* Слабое свечение */
        box-shadow: inset 0 0 15px rgba(255, 179, 0, 0.5), inset 0 0 0 1000px rgba(255, 179, 0, 0.25);
    }
    50% {
        /* Сильное свечение */
        box-shadow: inset 0 0 30px rgba(255, 179, 0, 0.9), inset 0 0 0 1000px rgba(255, 179, 0, 0.45);
    }
}

/* ПОДСВЕТКА ПОЛЯ */
.highlight-square {
    /* Используем анимацию тени, чтобы создать эффект пульсации под фигурой */
    animation: highlightPulse 2s infinite ease-in-out;
}

/* Кнопки под доской */
.controls-row {
    margin-top: 20px;
    margin-bottom: 20px; /* Отступ снизу, т.к. паддинга нет */
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    position: relative;
    z-index: 101; /* Кнопки поверх стрелок */
}

button {
    padding: 12px 20px; /* Увеличенная зона клика для пальцев */
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s;
    touch-action: manipulation; /* Убирает задержку 300мс на мобильных */
    min-height: 44px; /* Стандарт iOS для тач-таргетов */
}

/* Hover только для устройств с мышью (фикс залипания на мобильных) */
@media (hover: hover) {
    button:hover { 
        filter: brightness(1.1); 
        box-shadow: 0 4px 8px rgba(0,0,0,0.4); 
    }
}

button:active { transform: translateY(0); }
button:disabled { 
    background: #424242; 
    color: #757575;
    cursor: default; 
    transform: none; 
    box-shadow: none; 
}

button.danger { background: var(--danger); }
button.success { background: var(--success); }
button.secondary { background: #546e7a; }
button.orange { background: #fb8c00; }

/* Анимация кнопки записи */
button.recording-active {
    background: var(--danger);
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 83, 80, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 83, 80, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 83, 80, 0); }
}

/* Кнопки выбора цвета (новые) */
.turn-btn {
    width: 44px; 
    padding: 0; 
    display: flex; 
    justify-content: center; 
    align-items: center;
    border: 2px solid transparent;
}
.turn-btn.white {
    background: #eeeeee;
    color: #000;
}
.turn-btn.black {
    background: #212121;
    color: #fff;
    border: 1px solid #444;
}
.turn-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.6);
    transform: scale(1.05);
}

/* Индикатор хода */
.turn-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-radius: 8px;
    font-size: 1.4rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.turn-indicator.white {
    background: #eeeeee;
    color: #111;
    border-color: #fff;
}
.turn-indicator.black {
    background: #212121;
    color: #fff;
    border-color: #424242;
}


/* Элементы форм */
.form-group { margin-bottom: 15px; }
label { 
    display: block; 
    margin-bottom: 6px; 
    font-weight: 500; 
    font-size: 0.9rem; 
    color: var(--text-muted); 
}

/* UPDATED: Added input[type="password"] to the selector list */
input[type="text"], input[type="number"], input[type="password"] {
    width: 100%; 
    padding: 12px; /* Больше отступ для пальцев */
    background: var(--input-bg);
    border: 1px solid var(--border); 
    color: #fff;
    border-radius: 6px;
    font-size: 16px; /* Фикс зума на iPhone (меньше 16px вызывает зум) */
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none; /* Убираем стандартные тени iOS */
}

/* Убираем стрелочки (spinners) у input number */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

/* UPDATED: Added input[type="password"]:focus to the selector list */
input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus { 
    border-color: var(--primary); 
    background: #333;
}

/* Списки (история, ученики) */
.list-container {
    max-height: 400px;
    overflow-y: auto;
    background: #141414;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px;
    /* Инерционная прокрутка на iOS */
    -webkit-overflow-scrolling: touch;
}
.list-item {
    background: #262626;
    padding: 10px 12px;
    margin-bottom: 5px;
    border: 1px solid #333;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    color: #ccc;
}
.placeholder { padding: 20px; text-align: center; color: #666; }

/* Таймер */
.timer-display {
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    margin: 10px 0;
    color: #fff;
    font-family: monospace;
    padding: 10px;
    background: #262626;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.timer-display.ended {
    color: #ffcdd2;
    border-color: var(--danger);
    background: #b71c1c;
}
/* Зеленый стиль для успешного решения */
.timer-display.success {
    color: #a5d6a7;
    border-color: var(--success);
    background: #1b5e20;
}

/* Статус бар */
.status-bar {
    position: fixed; 
    bottom: 20px; 
    left: 50%;
    transform: translateX(-50%);
    background: #212121; 
    color: #fff;
    padding: 12px 24px; 
    border-radius: 30px;
    border: 1px solid #444;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    opacity: 0; 
    transition: opacity 0.3s;
    pointer-events: none; 
    z-index: var(--z-status);
    font-weight: 500;
    white-space: nowrap; /* Чтобы текст не ехал на телефоне */
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.status-bar.show { opacity: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1e1e1e; }
::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #616161; }

/* Адаптивность */
@media (max-width: 1100px) {
    .container {
        grid-template-columns: 1fr; /* Одна колонка */
        max-width: 700px;
        padding: 0 10px 20px 10px; /* Меньше отступы по краям */
        gap: 15px;
    }
    .board-column {
        order: -1; /* Доска всегда сверху */
    }
    .side-panel {
        width: 100%;
    }
    .board-wrapper {
        padding: 0;
        border-width: 3px; 
    }
    .controls-row button {
        flex: 1 1 auto;
    }
}