/* Сброс стилей */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    color: #333;
    font-size: 1.8em;
    font-weight: 300;
    margin: 15px 0;
}

/* ИСПРАВЛЕНО: Основной контейнер разделен на две равные части */
.main-area {
    display: flex;
    width: 100%;
    height: 100%;
}

/* ИСПРАВЛЕНО: Левая часть - контейнер для доски и кнопок */
.left-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: 60px;
}

/* ИСПРАВЛЕНО: Правая часть - контейнер для PGN */
.right-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    padding-top: 60px;
}

/* ИСПРАВЛЕНО: Секция доски отцентрована в левом контейнере */
.board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chessboard {
    width: 70vh;
    height: 70vh;
    border: 2px solid #8B4513;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Дополнительные стили для различных тем досок */
.chessboard.blue {
    border-color: #2E86AB;
}

.chessboard.green {
    border-color: #2D5016;
}

.chessboard.brown {
    border-color: #8B4513;
}

.chessboard.gray {
    border-color: #6C757D;
}

.chessboard.wood {
    border-color: #A0522D;
    box-shadow: 0 4px 15px rgba(160, 82, 45, 0.3);
}

.chessboard.marble {
    border-color: #E5E5E5;
    box-shadow: 0 4px 15px rgba(229, 229, 229, 0.4);
}

.chessboard.red {
    border-color: #DC3545;
}

.chessboard.purple {
    border-color: #6F42C1;
}

.chessboard.black {
    border-color: #212529;
}

/* Дополнительные CSS переменные для цветовых схем */
.chessboard.blue {
    --board-primary: #2E86AB;
    --board-secondary: #A23B72;
}

.chessboard.green {
    --board-primary: #2D5016;
    --board-secondary: #7CB342;
}

.chessboard.brown {
    --board-primary: #8B4513;
    --board-secondary: #DEB887;
}

.chessboard.gray {
    --board-primary: #6C757D;
    --board-secondary: #ADB5BD;
}

.chessboard.wood {
    --board-primary: #A0522D;
    --board-secondary: #DEB887;
}

.chessboard.marble {
    --board-primary: #E5E5E5;
    --board-secondary: #F8F9FA;
}

.chessboard.red {
    --board-primary: #DC3545;
    --board-secondary: #F8D7DA;
}

.chessboard.purple {
    --board-primary: #6F42C1;
    --board-secondary: #E2D9F3;
}

.chessboard.black {
    --board-primary: #212529;
    --board-secondary: #6C757D;
}

/* ИСПРАВЛЕНО: Кнопки навигации отцентрированы под доской */
.navigation-section {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Индикация текущего хода */
.move-info-section {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.move-info {
    background: #f8f9fa;
    border: 2px solid #8B4513;
    border-radius: 6px;
    padding: 8px 16px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    min-width: 160px;
    text-align: center;
    transition: background-color 0.3s ease;
}

/* Зеленый фон для индикатора активности */
.move-info.active {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.move-counter {
    background: #e9ecef;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    padding: 4px 12px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #6c757d;
    min-width: 100px;
    text-align: center;
}

.nav-btn {
    padding: 12px 16px;
    border: 2px solid #8B4513;
    background: #fff;
    color: #8B4513;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    min-width: 45px;
}

.nav-btn:hover:not(:disabled) {
    background: #8B4513;
    color: white;
    transform: translateY(-1px);
}

.nav-btn:disabled {
    background: #e9ecef;
    border-color: #dee2e6;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.play-btn {
    background: #28a745;
    border-color: #28a745;
    color: white;
    padding: 12px 20px;
}

.play-btn:hover:not(:disabled) {
    background: #218838;
    border-color: #218838;
}

.play-btn.playing {
    background: #dc3545;
    border-color: #dc3545;
}

.play-btn.playing:hover {
    background: #c82333;
    border-color: #c82333;
}

/* ИСПРАВЛЕНО: PGN секция в правом контейнере */
.pgn-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pgn-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.pgn-section label {
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
}

.settings-btn {
    padding: 8px 12px;
    border: 2px solid #8B4513;
    background: #fff;
    color: #8B4513;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.settings-btn:hover {
    background: #8B4513;
    color: white;
}

#pgn-input {
    width: 100%;
    flex: 1;
    padding: 20px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    transition: border-color 0.3s ease;
    background: #fff;
}

#pgn-input:focus {
    outline: none;
    border-color: #8B4513;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.load-btn {
    margin-top: 15px;
    padding: 12px 25px;
    background: #8B4513;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-btn:hover {
    background: #654321;
    transform: translateY(-1px);
}

/* Модальное окно настроек */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 700px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
    color: #333;
    font-size: 1.5em;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.settings-group {
    margin-bottom: 15px;
}

.settings-group h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1.2em;
}

.piece-delay-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 0;
}

.piece-delay-row:last-child {
    border-bottom: none;
}

.piece-label {
    font-weight: 500;
    color: #555;
    flex: 0 0 120px;
    text-align: left;
}

.delay-inputs {
    display: flex;
    gap: 15px;
    flex: 1;
    justify-content: flex-end;
}

.delay-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.delay-input-group label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.delay-input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

.delay-input:focus {
    outline: none;
    border-color: #8B4513;
    box-shadow: 0 0 0 2px rgba(139, 69, 19, 0.1);
}

.default-delay-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.default-delay-row .piece-label {
    flex: 0 0 200px;
}

.modal-buttons {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn {
    background: #28a745;
    color: white;
}

.save-btn:hover {
    background: #218838;
}

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

.cancel-btn:hover {
    background: #5a6268;
}

/* Селектор пресетов */
.preset-selector {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.preset-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.preset-select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.preset-select:focus {
    outline: none;
    border-color: #8B4513;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.preset-select:hover {
    border-color: #adb5bd;
}
