/* ======== ОСНОВНЫЕ СТИЛИ СЕКЦИЙ ======== */
#sec-course {
    padding-top: 0px;
}

#sec-board {
    padding-top: 5px;
    padding-bottom: 5px;
}

#sec-board .u-sheet {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ======== ШАПКА КУРСА И НАВИГАЦИЯ ======== */
.course-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px 0;
}

.course-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
    padding: 0;
}

.theme-name {
    font-size: 1.2rem;
    margin: 0;
    padding: 0;
    color: #666;
}

.theme-progress {
    font-size: 1rem;
    margin-top: 10px;
}

/* Стили для информации о задаче */
.puzzle-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 5px;
    margin-bottom: 5px;
}

.puzzle-info .solved-icon {
    width: 20px;
    height: 20px;
}

.solved-icon.visible {
    visibility: visible;
}

.solved-icon.hidden {
    visibility: hidden;
}

.puzzle-info .puzzle-number {
    font-size: 1rem;
    color: #555;
}

/* Стили для решенных задач */
.puzzle-solved {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    color: #2ecc71;
}

.solved-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
}

.solved-text {
    font-weight: bold;
    font-size: 1.1em;
}

/* ======== ШАХМАТНАЯ ДОСКА И ДОПОЛНИТЕЛЬНЫЕ ЭЛЕМЕНТЫ ======== */
.board-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

#board {
    width: min(60vh, 90vw, 800px);
    height: min(60vh, 90vw, 800px);
    margin: 0 auto;
    position: relative;
}

/* Инициализация шахматной доски для правильного отображения сообщений */
.cm-chessboard {
    position: relative;
}

/* Общий контейнер для доски и лишних фигур */
.chess-board-container {
    position: relative;
    width: 100%;
    max-width: 800px; /* Соответствует максимальной ширине доски */
    margin: 0 auto;
}

/* Стили для секций с лишними фигурами */
#top-extra-pieces, #bottom-extra-pieces {
    position: absolute;
    width: auto;
    right: -120px; /* Смещение вправо от доски */
    padding: 5px;
    margin: 0;
    box-sizing: border-box;
    z-index: 10;
}

/* Верхние фигуры размещаем вверху справа */
#top-extra-pieces {
    top: 0;
}

/* Нижние фигуры размещаем внизу справа */
#bottom-extra-pieces {
    bottom: 0;
}

/* Сбрасываем стилевые переопределения секций */
#top-extra-pieces .u-sheet,
#bottom-extra-pieces .u-sheet,
#sec-board .u-sheet {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Контейнеры для лишних фигур */
.extra-pieces {
    display: flex;
    flex-direction: column; /* Фигуры в столбик */
    align-items: flex-start;
}

/* Обновленные стили для лишних фигур и индикатора хода */
.extra-pieces-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 5px 0;
}

/* Стили для отдельных фигур */
.extra-piece-span {
    display: block;
    margin: 3px 0;
    cursor: help;
    transition: transform 0.2s ease;
}

.extra-piece-span:hover {
    transform: scale(1.2);
}

.extra-pieces img.extra-piece-svg,
.extra-pieces svg {
    width: 24px;
    height: 24px;
    margin: 0 3px;
    cursor: help;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

.extra-pieces img.extra-piece-svg:hover,
.extra-pieces svg:hover {
    transform: scale(1.2);
}

/* Стиль для отображения очередности хода */
.turn-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
    padding: 5px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.turn-indicator img {
    width: 24px;
    height: 24px;
    margin-right: 10px;
}

.turn-indicator span {
    font-weight: bold;
    font-size: 16px;
}

/* Индикаторы хода - также располагаем справа */
#top-turn-indicator, #bottom-turn-indicator {
    position: absolute;
    right: -200px; /* Дальше, чем фигуры */
    padding: 5px;
    background-color: rgba(255,255,255,0.8);
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
}

#top-turn-indicator {
    top: 10px;
}

#bottom-turn-indicator {
    bottom: 10px;
}

/* Стиль для отображения счетчика ходов */
.moves-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    padding: 8px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    transition: all 0.3s ease;
}

.moves-counter.thinking {
    background-color: rgba(255, 235, 59, 0.3);
}

.moves-counter img {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

/* ======== КНОПКИ УПРАВЛЕНИЯ ======== */
.control-buttons {
    display: flex;
    justify-content: space-between; /* Изменено с center на space-between */
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin: 10px auto;
    padding: 0 10px;
    box-sizing: border-box;
}

.control-buttons .u-btn {
    padding: 5px 15px;
    font-size: 0.9rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.control-buttons .u-btn img {
    width: 16px;
    height: 16px;
}

.control-buttons .disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.rotate-button {
    display: flex;
    justify-content: flex-start; /* Выравнивание по левому краю */
    margin: 0;
}

.rotate-button .u-btn {
    padding: 5px 15px;
    font-size: 0.9rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.rotate-button .u-btn img {
    width: 16px;
    height: 16px;
}

/* Кнопка справки */
.help-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background-color: #2979c7;
    border-radius: 5px;
    margin-left: auto; /* Смещение кнопки вправо */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.help-button:hover {
    background-color: #1e5b8d;
    transform: translateY(-2px);
}

.help-button img {
    width: 24px;
    height: 24px;
}

/* Контейнер кнопок с выравниванием элементов */
.buttons-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px; /* Согласуется с шириной доски */
    margin: 10px auto;
    padding: 0;
    box-sizing: border-box;
}

/* ======== ТЕКСТ ЗАДАНИЯ И ИСТОРИЯ ХОДОВ ======== */
#TaskPuzzle {
    padding: 10px 20px;
    min-height: 20px;
    height: auto;
    margin: 0;
    line-height: 1.5;
}

.moves-history {
    min-height: 50px;
    height: auto;
    padding: 10px;
    margin: 10px 0;
}

/* ======== УВЕДОМЛЕНИЯ И СООБЩЕНИЯ ======== */
#theme-notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4CAF50;
    color: white;
    padding: 15px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: top 0.5s ease;
    text-align: center;
    min-width: 300px;
    max-width: 80%;
}

#theme-notification.show {
    top: 20px;
}

/* Стили для сообщений о победе/поражении/ничьей */
.win-message { color: #2ecc71; font-size: 24px; font-weight: bold; }
.draw-message { color: #3498db; font-size: 24px; font-weight: bold; }
.lose-message { color: #e74c3c; font-size: 24px; font-weight: bold; }

/* Стили для слоя с сообщением */
.message-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
}

.message-layer div {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 15px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 200px;
}

.message-layer img {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
}

/* ======== ПАНЕЛЬ ЗАВЕРШЕНИЯ ЗАДАЧИ ======== */
.completion-panel {
    position: fixed;
    bottom: -100px;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
    padding: 20px;
    text-align: center;
    z-index: 1000;
    transition: bottom 0.5s ease-in-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.completion-panel.visible {
    bottom: 0;
}

.completion-panel img {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
}

.completion-panel .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #555;
}

/* Стили для overlay фона */
.message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

.message-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ======== КНОПКИ НА ПАНЕЛИ ======== */
.next-puzzle-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.next-puzzle-btn:hover {
    background-color: #388E3C;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.retry-puzzle-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #2196F3;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.retry-puzzle-btn:hover {
    background-color: #0b7dda;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.panel-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}

/* ======== СТИЛИ ДЛЯ ПРЕДУПРЕЖДЕНИЙ ======== */
.auth-warning {
    color: #e67e22;
    margin-top: 10px;
    font-size: 14px;
    text-align: center;
    padding: 5px 10px;
    background-color: rgba(230, 126, 34, 0.1);
    border-radius: 5px;
    font-weight: bold;
}

/* ======== БАЗОВЫЕ СТИЛИ РАЗДЕЛОВ U-SECTION ======== */
.u-section-1 .u-sheet-1 {
  min-height: 44px;
}

.u-section-1 .u-text-1 {
  margin: 1px auto;
}

.u-section-2 {
  min-height: 47px;
}

.u-section-2 .u-btn-1 {
  --radius: 50px;
  border-style: solid;
  align-self: center;
  margin: 5px 0 0 auto;
  padding: 0 8px;
}

.u-section-2 .u-icon-1 {
  font-size: 1.5em;
}

.u-section-2 .u-text-1 {
  font-weight: 400;
  margin: -31px 53px 13px;
}

.u-section-3 .u-sheet-1 {
  min-height: 10px;
}

.u-section-4 {
  min-height: 53px;
}

.u-section-4 .u-btn-1 {
  --radius: 50px;
  border-style: solid;
  margin: 5px 0 0 auto;
  padding: 0 8px;
}

.u-section-4 .u-icon-1 {
  font-size: 1.5em;
}

.u-section-4 .u-text-1 {
  font-weight: 700;
  margin: -31px calc(((100% - 1140px) / 2) + 5px) 20px calc(((100% - 1140px) / 2));
}

.u-section-5 .u-sheet-1 {
  min-height: 10px;
}

.u-section-6 .u-sheet-1 {
  min-height: 44px;
}

.u-section-6 .u-btn-1 {
  --radius: 50px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 1px;
  background-image: none;
  margin: 1px auto 0 0;
  padding: 10px 25px 11px;
}

.u-section-6 .u-btn-2 {
  --radius: 50px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 1px;
  background-image: none;
  margin: -42px auto 0;
  padding: 5px 49px 6px;
}

.u-section-6 .u-icon-1 {
  margin-right: 13px;
  vertical-align: 0px;
  font-size: 1.4286em;
}

.u-section-6 .u-btn-3 {
  --radius: 50px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 1px;
  background-image: none;
  margin: -44px 0 0 auto;
  padding: 10px 30px 11px 29px;
}

.u-section-7 .u-sheet-1 {
  min-height: 43px;
}

.u-section-7 .u-icon-1, .u-section-7 .u-icon-2, .u-section-7 .u-icon-3 {
  width: 43px;
  background-image: none;
  height: 43px;
  padding: 6px;
}

.u-section-7 .u-icon-1 {
  margin: 0 auto;
}

.u-section-7 .u-icon-2 {
  margin: -43px auto 0 0;
}

.u-section-7 .u-icon-3 {
  margin: -43px 0 0 auto;
}

.u-section-8 .u-sheet-1, .u-section-10 .u-sheet-1, .u-section-13 .u-sheet-1 {
  min-height: 10px;
}

.u-section-9 .u-sheet-1 {
  min-height: 354px;
}

.u-section-9 .u-image-1 {
  width: 380px;
  height: 354px;
  margin: 0 auto;
}

.u-section-11 .u-sheet-1 {
  min-height: 48px;
}

.u-section-11 .u-text-1 {
  margin: 0 0 0 auto;
}

.u-section-11 .u-icon-1 {
  font-size: 2.2223em;
}

.u-section-11 .u-text-2 {
  margin: -48px auto 0;
}

.u-section-11 .u-text-3 {
  margin: -48px 904px 0 0;
}

.u-section-12 .u-sheet-1 {
  min-height: 0;
}

.u-section-12 .u-text-1 {
  width: auto;
  margin: 0 auto 0 -50px;
}

.u-section-12 .u-icon-1 {
  font-size: 1.125rem;
}

.u-section-12 .u-text-2 {
  margin: 0 0 0 auto;
}

.u-section-12 .u-text-3 {
  margin: 0 auto 0 0;
}

.u-section-14 .u-sheet-1 {
  min-height: 72px;
}

.u-section-14 .u-text-1 {
  margin: 0 auto 43px 0;
}

/* ======== МЕДИА-ЗАПРОСЫ ======== */
@media (max-width: 1200px) {
    #top-extra-pieces, #bottom-extra-pieces,
    #top-turn-indicator, #bottom-turn-indicator {
        position: static;
        width: 100%;
        margin: 5px 0;
    }

    .extra-pieces {
        flex-direction: row;
        justify-content: center;
    }

    .extra-piece-span {
        margin: 0 3px;
    }

    .u-section-2 {
        min-height: 38px;
    }

    .u-section-2 .u-text-1 {
        margin-right: 50px;
        margin-left: calc(((100% - 940px) / 2));
    }

    .u-section-4 {
        min-height: 38px;
    }

    .u-section-4 .u-text-1 {
        margin-top: -38px;
        margin-right: 50px;
        margin-left: calc(((100% - 940px) / 2));
    }

    .u-section-6 .u-btn-2 {
        margin-top: -43px;
    }

    .u-section-6 .u-btn-3 {
        margin-top: -43px;
        margin-bottom: 1px;
    }

    .u-section-9 .u-image-1 {
        inset: auto;
    }

    .u-section-11 .u-text-3 {
        margin-right: 704px;
    }

    .u-section-12 .u-text-1 {
        margin-left: 0;
    }
}

@media (max-width: 991px) {
    .u-section-2 .u-text-1 {
        width: auto;
        margin-left: 50px;
    }

    .u-section-4 .u-text-1 {
        width: auto;
        margin-left: 50px;
    }

    .u-section-11 .u-text-3 {
        margin-top: 20px;
        margin-right: 484px;
    }
}

@media (max-width: 767px) {
    .turn-indicator {
        font-size: 14px;
        padding: 3px 5px;
    }

    .turn-indicator img {
        width: 18px;
        height: 18px;
        margin-right: 5px;
    }

    .moves-counter {
        font-size: 14px;
        padding: 5px;
    }

    .u-section-2 .u-text-1 {
        margin-left: calc(((100% - 540px) / 2));
    }

    .u-section-4 .u-text-1 {
        margin-left: calc(((100% - 540px) / 2));
    }

    .u-section-6 .u-sheet-1 {
        min-height: 0;
    }

    .u-section-6 .u-btn-1 {
        font-size: 0.75rem;
        padding-left: 15px;
        padding-right: 15px;
    }

    .u-section-6 .u-btn-2 {
        font-size: 0.75rem;
        padding-left: 36px;
        padding-right: 36px;
    }

    .u-section-6 .u-btn-3 {
        font-size: 0.75rem;
        padding-left: 19px;
        padding-right: 19px;
    }

    .u-section-11 .u-sheet-1 {
        min-height: 0;
    }

    .u-section-11 .u-text-1 {
        margin-top: 60px;
    }

    .u-section-11 .u-text-3 {
        margin-right: 304px;
        margin-bottom: 60px;
    }

    .u-section-12 .u-sheet-1 {
        min-height: 48px;
    }

    .u-section-12 .u-text-1 {
        margin-right: 490px;
    }

    .u-section-12 .u-icon-1 {
        font-size: 2.2223em;
        margin-right: 9px;
    }

    .u-section-12 .u-text-2 {
        width: auto;
        margin-top: -48px;
        margin-left: 490px;
    }

    .u-section-12 .u-text-3 {
        width: auto;
        margin-top: -48px;
        margin-left: auto;
    }

    .u-section-14 .u-text-1 {
        margin-bottom: 60px;
    }

    .control-buttons .u-btn-text {
        display: none;
    }

    .control-buttons {
        gap: 10px;
    }

    .control-buttons .u-btn {
        padding: 8px;
    }

    .control-buttons .u-btn img {
        width: 14px;
        height: 14px;
    }

    #TaskPuzzle {
        padding: 5px 10px;
        font-size: 0.9rem;
    }

    .modal-content {
        margin: 5% auto;
        padding: 15px;
        width: 90%;
    }

    .extra-pieces span {
        font-size: 16px;
        margin: 0 3px;
    }

    .help-button {
        width: 32px;
        height: 32px;
        margin-left: 10px;
    }

    .help-button img {
        width: 18px;
        height: 18px;
    }

    .buttons-container {
        flex-wrap: wrap;
    }
}

@media (max-width: 575px) {
    .u-section-2 {
        min-height: 51px;
    }

    .u-section-2 .u-text-1 {
        width: 340px;
        margin: -38px auto 0;
    }

    .u-section-4 {
        min-height: 45px;
    }

    .u-section-4 .u-text-1 {
        width: 340px;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 0;
    }

    .u-section-6 .u-btn-1, .u-section-6 .u-btn-2 {
        font-size: 0.5625rem;
    }

    .u-section-9 .u-sheet-1 {
        min-height: 317px;
    }

    .u-section-9 .u-image-1 {
        width: 340px;
        height: 317px;
    }

    .u-section-11 .u-text-3 {
        margin-top: -48px;
        margin-right: 104px;
    }

    .u-section-12 .u-text-1 {
        margin-right: 290px;
    }

    .u-section-12 .u-text-2 {
        margin-left: 290px;
    }
}

/* Выравнивание элементов шахматной доски по центру */
#sec-controls-top .u-sheet,
#sec-board .u-sheet,
#sec-MovesPuzzle .u-sheet,
.moves-counter {
    max-width: 800px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Полная ширина счетчика ходов с выравниванием по краям */
#sec-moves-counter .u-sheet {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
}

#sec-moves-counter {
    max-width: 800px;
    width: 100%;
    margin: 0 auto 10px;
}

/* Выравнивание кнопок управления */
.control-buttons {
    width: 100%;
    max-width: 800px;
    margin: 10px auto;
    display: flex;
    justify-content: space-between;
}

/* Индикатор оставшихся ходов */
.moves-counter {
    width: 100%;
    max-width: 800px;
}

/* История ходов */
#movesPuzzle {
    max-width: 800px;
    width: 100%;
    margin: 10px auto;
}

/* =============== Добавлено ================ */
/* Стили для создания макета шахматной доски с областями для информации */
/* Макет шахматной доски в точном соответствии с предоставленной схемой */

/* Основные исправления для макета шахматной доски */

/* Установка корректного отображения всего макета */
.chess-layout {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Две равные колонки */
    grid-template-rows: 30px 1fr 30px; /* Верхняя часть, доска и нижняя часть */
    width: 100%;
    max-width: min(60vh, 90vw, 800px);
    margin: 0 auto;
    box-sizing: border-box;
    position: relative;
    gap: 0; /* Убираем промежутки между ячейками сетки */
}

/* Стиль для верхней панели */
.top-panel {
    position: relative;
    display: flex;
    align-items: center;
    height: 30px;
    padding: 0 5px;
    box-sizing: border-box;
    z-index: 5;
}

/* Стиль для нижней панели */
.bottom-panel {
    position: relative;
    display: flex;
    align-items: center;
    height: 30px;
    padding: 0 5px;
    box-sizing: border-box;
    z-index: 5;
}

/* Выравнивание левых панелей */
.turn-indicator-cell {
    justify-content: flex-start;
    grid-column: 1;
    grid-row: 1;
}

/* Выравнивание правых панелей */
.extra-pieces-top-cell {
    justify-content: flex-end;
    grid-column: 2;
    grid-row: 1;
}

/* Правильное размещение шахматной доски */
.board-container {
    grid-column: 1 / span 2; /* Растягивается на обе колонки */
    grid-row: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Выравнивание нижней левой ячейки - счетчик ходов */
.moves-counter-cell {
    justify-content: flex-start;
    grid-column: 1;
    grid-row: 3;
}

/* Выравнивание нижней правой ячейки - дополнительные фигуры снизу */
.extra-pieces-bottom-cell {
    justify-content: flex-end;
    grid-column: 2;
    grid-row: 3;
}

/* Правильное отображение индикатора хода */
.turn-indicator {
    display: inline-flex;
    align-items: center;
    background-color: transparent !important; /* Прозрачный фон */
    box-shadow: none !important; /* Убираем тень */
    padding: 0;
    margin: 0;
    position: static; /* Убираем абсолютное позиционирование */
}

/* Правильное размещение счетчика ходов */
.moves-counter {
    display: inline-flex;
    align-items: center;
    background-color: transparent;
    box-shadow: none;
    padding: 0;
    margin: 0;
    position: static; /* Убираем абсолютное позиционирование */
    white-space: nowrap;
}

/* Убираем абсолютное позиционирование для индикаторов хода */
#top-turn-indicator, #bottom-turn-indicator {
    position: static;
    right: auto;
    top: auto;
    bottom: auto;
    background-color: transparent !important;
    box-shadow: none !important;
}

/* Убираем фиксированное позиционирование для дополнительных фигур */
#top-extra-pieces, #bottom-extra-pieces {
    position: static;
    right: auto;
    top: auto;
    bottom: auto;
}

/* Правильное размещение доски */
#board {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1; /* Сохраняем квадратную форму */
    max-width: 100%;
}

/* Медиа-запросы для адаптивности */
@media screen and (max-width: 1199px) {
    /* На меньших экранах сохраняем структуру сетки */
    .chess-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 30px 1fr 30px;
    }

    /* Важно! Отключаем все стили, которые переопределяют наш макет на меньших экранах */
    #top-extra-pieces, #bottom-extra-pieces,
    #top-turn-indicator, #bottom-turn-indicator {
        position: static;
        width: auto;
        margin: 0;
    }

    .extra-pieces {
        flex-direction: row;
    }
}

/* Уменьшаем элементы на совсем маленьких экранах */
@media screen and (max-width: 480px) {
    .top-panel, .bottom-panel {
        height: 25px;
    }

    .turn-indicator img,
    .extra-pieces img,
    .extra-pieces svg {
        width: 18px;
        height: 18px;
    }
}

/* Обеспечиваем горизонтальное расположение фигур на всех разрешениях */

/* Убираем изменение направления flex на flex-direction: column */
.extra-pieces {
    display: flex;
    flex-direction: row !important; /* Принудительно устанавливаем горизонтальное направление */
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

/* Корректируем отступы для фигур */
.extra-piece-span {
    display: inline-block;
    margin: 0 3px !important; /* Одинаковые горизонтальные отступы на всех разрешениях */
    cursor: help;
    transition: transform 0.2s ease;
}

/* Исправляем стили для изображений фигур */
.extra-pieces img.extra-piece-svg,
.extra-pieces svg {
    width: 24px;
    height: 24px;
    margin: 0 3px;
    cursor: help;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

/* Медиа-запрос для больших экранов (от 1200px) */
@media (min-width: 1200px) {
    /* Обеспечиваем горизонтальное расположение фигур на больших экранах */
    .extra-pieces {
        flex-direction: row !important; /* Принудительно устанавливаем строчное направление */
        justify-content: flex-end;
    }

    /* Отменяем любые стили, которые могут менять направление flex */
    #top-extra-pieces, #bottom-extra-pieces {
        flex-direction: row !important;
    }

    /* Корректное расположение фигур на больших экранах */
    #top-extra-pieces .extra-pieces,
    #bottom-extra-pieces .extra-pieces {
        display: flex;
        flex-direction: row !important;
        justify-content: flex-end;
    }
}

/* Убедимся, что стили медиа-запроса для меньших экранов не перезаписывают наше принудительное горизонтальное расположение */
@media (max-width: 1199px) {
    .extra-pieces {
        flex-direction: row !important;
    }
}

/* Отключаем все стили, которые могут переопределять flex-direction на column */
.extra-pieces-row {
    display: flex;
    flex-direction: row !important;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    padding: 5px 0;
}

/* ======== СТИЛИ ДЛЯ БАЗОВОЙ ИНФОРМАЦИИ О КУРСЕ И ТЕМЕ ======== */
.basic-info {
    padding: 20px 0;
    text-align: center;
}

.puzzle-course-section {
    margin-bottom: 15px;
}

.puzzle-course-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.puzzle-theme-title {
    font-size: 1.2rem;
    color: #666;
}

/* ======== СТИЛИ ДЛЯ ЗАГОЛОВКА ЗАДАЧИ В СТИЛЕ THEME ======== */
.puzzle-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: clamp(15px, 3vw, 25px); /* Увеличили padding для вмещения всех элементов */
    margin-bottom: 5px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 250px; /* Минимальная высота для размещения всех элементов */
}

/* ПЕРВЫЙ ЭЛЕМЕНТ - ИНФОРМАЦИЯ О КУРСЕ И ТЕМЕ */
.puzzle-course-section {
    text-align: center;
    margin-bottom: clamp(15px, 3vw, 20px);
    order: 0;
}

.puzzle-course-title {
    font-size: clamp(1.2rem, 3.5vw, 1.6rem);
    font-weight: 600;
    margin: 0 0 5px 0;
    text-decoration: underline;
    color: white;
}

.puzzle-theme-title {
    font-size: clamp(1rem, 2.8vw, 1.3rem);
    font-weight: 500;
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
}

/* ВТОРОЙ ЭЛЕМЕНТ - НОМЕР ЗАДАЧИ */
.puzzle-number-section {
    text-align: center;
    margin-bottom: clamp(15px, 3vw, 20px);
    order: 1;
    padding: clamp(8px, 2vw, 12px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.puzzle-number-text {
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    opacity: 0.9;
    font-weight: 500;
    margin: 0;
    color: white;
}

/* ТРЕТИЙ ЭЛЕМЕНТ - ПРОГРЕСС ТЕМЫ */
.puzzle-progress-section {
    order: 2;
    margin-bottom: clamp(15px, 3vw, 20px);
}

.puzzle-progress-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(15px, 3vw, 25px);
    flex-wrap: wrap;
}

.puzzle-stat-item {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
    padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 16px);
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 100px;
    max-width: 160px;
    transition: transform 0.3s ease, background 0.3s ease;
}

.puzzle-stat-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.2);
}

.puzzle-stat-icon {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    opacity: 0.9;
    min-width: clamp(24px, 5vw, 30px);
    text-align: center;
    flex-shrink: 0;
}

.puzzle-stat-icon.solved {
    color: #4CAF50;
}

.puzzle-stat-icon.visible {
    color: #4CAF50;
}

.puzzle-stat-icon.hidden {
    color: rgba(255, 255, 255, 0.3);
}

.puzzle-stat-content {
    text-align: left;
    min-width: 0;
    flex: 1;
}

.puzzle-stat-number {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-weight: 700;
    line-height: 1;
    margin-bottom: 2px;
}

.puzzle-stat-label {
    font-size: clamp(0.65rem, 1.8vw, 0.75rem);
    opacity: 0.8;
    line-height: 1.1;
    word-wrap: break-word;
}

/* ЧЕТВЕРТЫЙ ЭЛЕМЕНТ - КНОПКИ НАВИГАЦИИ */
.puzzle-navigation {
    display: flex !important;
    justify-content: center !important;
    gap: clamp(6px, 1.5vw, 10px);
    flex-wrap: wrap;
    order: 3;
    margin-top: auto; /* Прижимаем к низу контейнера */
    z-index: 10 !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.puzzle-navigation .u-btn {
    display: flex;
    align-items: center;
    gap: clamp(4px, 1vw, 6px);
    padding: clamp(8px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
    font-size: clamp(0.75rem, 1.6vw, 0.85rem);
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    text-decoration: none;
    border-radius: 20px;
    white-space: nowrap;
    min-height: 38px;
}

.puzzle-navigation .u-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.puzzle-navigation .u-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    .puzzle-navigation .u-btn .u-btn-text {
        display: none !important;
    }

    .puzzle-navigation .u-btn {
        min-width: 40px;
        padding: 8px;
        justify-content: center;
    }

    .puzzle-navigation .u-btn img {
        margin: 0;
    }

    .puzzle-header {
        padding: clamp(12px, 2.5vw, 18px);
        min-height: 200px;
    }

    .puzzle-progress-stats {
        gap: 12px;
        margin-bottom: clamp(12px, 2.5vw, 16px);
    }

    .puzzle-stat-item {
        min-width: 85px;
        max-width: 130px;
        padding: 6px 10px;
    }

    .puzzle-navigation {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .puzzle-header {
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0 0 15px 15px;
        padding: 15px;
        min-height: 180px;
    }

    .puzzle-progress-stats {
        flex-direction: row;
        justify-content: space-around;
        gap: 6px;
    }

    .puzzle-stat-item {
        flex-direction: column;
        text-align: center;
        gap: 2px;
        padding: 8px 6px;
        min-width: 70px;
        max-width: 80px;
    }

    .puzzle-stat-content {
        text-align: center;
    }

    .puzzle-navigation .u-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 8px;
        border-radius: 18px;
    }
}

/* ======== СТИЛИ ДЛЯ ЗАГОЛОВКА ЗАДАЧИ ======== */
.task-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 15px;
    padding: clamp(20px, 4vw, 30px);
    margin: 0 auto 10px; /* Убираем отступ сверху и оставляем минимальный снизу */
    max-width: 800px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.task-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.task-text {
    color: #495057;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 500;
    line-height: 1.6;
    margin: 0;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    .task-header {
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0;
        padding: 15px;
    }
}

/* ======== СТИЛИ ДЛЯ БЛОКА ШАХМАТНОЙ ДОСКИ ======== */
.chess-board-header {
    background: linear-gradient(135deg, #f1f3f4 0%, #e8eaed 100%);
    border: 2px solid #dadce0;
    border-radius: 20px;
    padding: clamp(15px, 3vw, 20px) clamp(20px, 4vw, 30px);
    margin: 0 auto;
    max-width: 850px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: visible; /* Изменено с hidden на visible */
}

.chess-board-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #5f6368 0%, #9aa0a6 50%, #5f6368 100%);
}

.chess-board-header::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.chess-board-header .chess-layout {
    position: relative;
    z-index: 1;
    /* Увеличиваем отступы внутри макета */
    padding: 15px 0;
}

/* Возвращаем размеры лишних фигур к исходным значениям */
.chess-board-header .extra-pieces img.extra-piece-svg,
.chess-board-header .extra-pieces svg {
    width: 20px !important; /* Уменьшено с 24px */
    height: 20px !important; /* Уменьшено с 24px */
    margin: 0 2px !important; /* Уменьшены отступы */
}

.chess-board-header .extra-piece-span {
    margin: 0 2px !important; /* Уменьшены отступы */
}

/* Убираем лишние стили фона для индикаторов и счетчиков */
.chess-board-header .turn-indicator {
    background-color: transparent !important;
    border-radius: 8px;
    padding: 5px 10px;
    box-shadow: none !important;
    backdrop-filter: none;
}

.chess-board-header .moves-counter {
    background-color: transparent !important;
    border-radius: 8px;
    padding: 5px 10px;
    box-shadow: none !important;
    backdrop-filter: none;
}

.chess-board-header .extra-pieces {
    background-color: transparent; /* Убираем фон */
    border-radius: 8px;
    padding: 3px 8px;
    backdrop-filter: none; /* Убираем размытие */
}

/* Увеличиваем отступы для grid-макета чтобы элементы не налазили на доску */
.chess-board-header .chess-layout {
    grid-template-rows: 35px 1fr 35px; /* Увеличено с 30px до 35px */
    gap: 8px; /* Добавляем промежутки между ячейками */
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    .chess-board-header {
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0;
        padding: 10px 15px 15px;
    }

    .chess-board-header .chess-layout {
        padding: 10px 0;
        grid-template-rows: 30px 1fr 30px;
        gap: 5px;
    }

    .chess-board-header .extra-pieces img.extra-piece-svg,
    .chess-board-header .extra-pieces svg {
        width: 18px !important;
        height: 18px !important;
    }
}

#board, .cm-chessboard {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    font-size: 16px;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.puzzle-navigation a.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Стили для кнопок навигации в basic-info */
.basic-info .puzzle-navigation {
    display: flex !important;
    justify-content: center !important;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.basic-info .puzzle-navigation .u-btn {
    display: flex !important;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 2px solid #ddd;
    background: #f8f9fa;
    color: #495057;
    text-decoration: none;
    border-radius: 15px;
    transition: all 0.3s ease;
    min-height: 36px;
}

.basic-info .puzzle-navigation .u-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.basic-info .puzzle-navigation .u-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.basic-info .puzzle-navigation .u-btn img {
    width: 14px;
    height: 14px;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .basic-info .puzzle-navigation .u-btn .u-btn-text {
        display: none;
    }

    .basic-info .puzzle-navigation .u-btn {
        min-width: 40px;
        padding: 8px;
        justify-content: center;
    }
}

/* Обеспечиваем правильное отображение кнопок в шапке */
.puzzle-header .puzzle-navigation {
    order: 4; /* Размещаем после прогресса */
    margin-top: 15px !important; /* Отступ от прогресса */
}

/* Стили для кнопок внутри шапки курса */
.puzzle-header .puzzle-navigation .u-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
}

.puzzle-header .puzzle-navigation .u-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}
