:root {
    --sidebar-width: 350px; /* Reference value for sidebar width */
    --effective-sidebar-width: 350px; /* Effective sidebar width (updated by JS) */
    --sidebar-padding: 10px;
    --board-padding: 10px;
    --board-min-size: 300px;
}


body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: row; /* Change to row layout to accommodate sidebar */
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
    width: 100vw;
}
body.android-app #mobile-menu-toggle, body.android-app .sidebar-content {
    margin-top: env(safe-area-inset-top, 38px);
}
.container-fluid {
    padding-right: 0 !important;
    padding-left: 0 !important;
    margin: 0;
}
.row {
    margin-right: 0 !important;
    margin-left: 0 !important;
}
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-right: 0; /* Space will be handled by absolutely positioned sidebar */
    min-width: 0; /* Allow flex child to shrink below content */
    min-height: 100vh; /* Ensure full viewport height */
    position: relative; /* Ensure it doesn't interfere with fixed elements */
    z-index: 2; /* Higher than chess-board-panel but lower than sidebar */
    width: 100%;
    height: 100%;
}
.chess-container {
    position: relative; /* Change back to relative */
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh; /* Ensure it takes at least full viewport height */
}
.chess-board-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 100vh; /* Ensure it takes at least full viewport height */
    padding-right: 0; /* Space will be handled by absolutely positioned sidebar */
}
.chess-board {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    border: 2px solid #333;
    overflow: hidden; /* Ensure overlay stays within bounds */
    /* Отключаем выделение текста на игровом поле */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+/Edge */
    user-select: none; /* Standard */
    cursor: default;
    max-width: min(calc(100vw - var(--effective-sidebar-width)), 100vh);
    max-height: min(calc(100vw - var(--effective-sidebar-width)), 100vh);
    min-width: min(var(--board-min-size), min(calc(100vw - var(--effective-sidebar-width)), 100vh));
    min-height: min(var(--board-min-size), min(calc(100vw - var(--effective-sidebar-width)), 100vh));
    margin: auto; /* Center the board both vertically and horizontally */
    pointer-events: auto; /* Enable clicks on the board */
    box-sizing: border-box; /* Include border in size calculation */
}

/* On mobile devices, sidebar is hidden, so board can occupy full width */
@media (max-width: 991px) {
    .chess-board {
        max-width: min(calc(100vw - var(--effective-sidebar-width)), 100vh) !important;
        max-height: min(calc(100vw - var(--effective-sidebar-width)), 100vh) !important;
        min-width: min(var(--board-min-size), min(calc(100vw - var(--effective-sidebar-width)), 100vh)) !important;
        min-height: min(var(--board-min-size), min(calc(100vw - var(--effective-sidebar-width)), 100vh)) !important;
        margin: auto !important; /* Center the board both vertically and horizontally */
    }
}

/* Отключаем выделение текста и взаимодействие для фигур */
.square .piece-svg,
.square .piece-white,
.square .piece-black,
.square .moving-piece {
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+/Edge */
    user-select: none; /* Standard */
    pointer-events: none; /* Предотвращаем взаимодействие с курсором */
}

/* Глобальное отключение выделения текста и изображений для всего документа */
* {
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+/Edge */
    user-select: none; /* Standard */
}

/* Разрешаем выделение только для специфических элементов, где это необходимо */
input, textarea, pre, code, .form-control, .form-select {
    -webkit-user-select: text !important; /* Safari */
    -moz-user-select: text !important; /* Firefox */
    -ms-user-select: text !important; /* IE10+/Edge */
    user-select: text !important; /* Standard */
}
.square-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
}
.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5vw;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    aspect-ratio: 1 / 1;
    width: 100%;
    height: 100%;
}
@media (min-width: 768px) {
    .square {
        font-size: 3vw;
    }
}
@media (min-width: 992px) {
    .square {
        font-size: 2.5vw;
    }
}
@media (min-width: 1200px) {
    .square {
        font-size: 1.8vw;
    }
}
/* Responsive adjustments for different screen sizes */
@media (max-width: 767px) {
    body {
        flex-direction: column;
        margin: 0;
        padding: 0;
        height: 100vh;
        overflow: hidden; /* Prevent scrolling on mobile */
    }

    .main-content {
        padding-right: 0;
        order: 2; /* Show chess board below controls on mobile */
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 100vh; /* Ensure full viewport height */
        width: 100vw;
        height: 100vh;
        margin: 0;
        padding: 0;
    }

    .container-fluid {
        padding-right: 0 !important;
        padding-left: 0 !important;
        margin: 0;
    }

    .row {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    .chess-container {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100vh !important; /* Ensure it takes at least full viewport height */
    }

    .chess-board-panel {
        width: 100% !important;
        height: 100% !important;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        margin: 0 !important;
        min-height: 100vh !important; /* Ensure it takes at least full viewport height */
    }

    .chess-board {
        width: 100% !important;
        height: 100% !important;
        max-width: min(100vw, 100vh) !important;
        max-height: min(100vw, 100vh) !important;
        min-width: min(var(--board-min-size), min(100vw, 100vh)) !important;
        min-height: min(var(--board-min-size), min(100vw, 100vh)) !important;
    }

    /* Hide sidebar by default on mobile, it will be accessible via burger menu */
    .right-sidebar {
        display: none;
    }
    .right-sidebar.mobile-open {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 80%;
        max-width: 300px;
        z-index: 9999;
        transform: translateX(0) !important;
    }
}

/* Medium screens */
@media (min-width: 768px) and (max-width: 991px) {
    .main-content {
        padding-right: 0;
    }
    .right-sidebar {
        width: 280px;
    }
    .chess-board {
        max-width: min(100vw, 100vh); /* No need to account for sidebar since it's absolutely positioned */
        max-height: min(100vw, 100vh); /* No need to account for sidebar since it's absolutely positioned */
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .main-content {
        padding-right: 0;
    }
    .right-sidebar {
        width: 320px;
    }
    .chess-board {
        max-width: min(100vw, 100vh); /* No need to account for sidebar since it's absolutely positioned */
        max-height: min(100vw, 100vh); /* No need to account for sidebar since it's absolutely positioned */
    }
}
:root {
    --sidebar-width: 350px;
    --sidebar-padding: 10px;
    --board-padding: 10px;
    --board-min-size: 300px;
    --board-light-color: #c1cff9;
    --board-dark-color: #5b669b;
}

.light {
    background-color: var(--board-light-color);
}
.dark {
    background-color: var(--board-dark-color);
}
.square.selected {
    background-color: rgba(255, 255, 150, 0.7) !important; /* Light yellow */
    box-shadow: inset 0 0 10px rgba(200, 200, 0, 0.5);
}
.possible-move {
    position: relative;
    cursor: pointer;
}
.possible-move::after {
    content: '';
    position: absolute;
    width: 25%;
    height: 25%;
    border-radius: 50%;
    background-color: rgba(50, 50, 50, 0.4);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* On mobile devices, make the possible move indicators larger for better visibility */
@media (max-width: 767px) {
    .possible-move::after {
        width: 40%;
        height: 40%;
    }
}
.possible-capture {
    position: relative;
    cursor: pointer;
}
.possible-capture::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 6px solid rgba(220, 53, 69, 0.6);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* On mobile devices, make the possible capture indicators larger for better visibility */
@media (max-width: 767px) {
    .possible-capture::before {
        border-width: 5px;
    }
}
.controls {
    height: 100%;
}
.coord {
    position: absolute;
    font-size: 3vw;
    font-weight: bold;
    color: #333;
    z-index: 1;
}
@media (min-width: 768px) {
    .coord {
        font-size: 1vw;
    }
}
.coord-top-left {
    top: 2%;
    left: 5%;  /* Position on left side of the square */
}
.coord-top-right {
    top: 2%;
    right: 5%;  /* Position on right side of the square */
}
.coord-bottom-right {
    bottom: 2%;
    right: 5%;  /* Position on right side of the square */
}
.coord-bottom-left {
    bottom: 2%;
    left: 5%;  /* Position on left side of the square */
}
.history {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 5px;
    background: #f8f9fa;
    font-size: 0.9rem;
}
.check {
    background-color: rgba(220, 53, 69, 0.4) !important;
}
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.promotion-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}
.promotion-content {
    background: #f8f9fa; /* Match modal background */
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); /* Softer shadow */
    max-width: 500px;
    width: 90%;
    padding: 40px;
    text-align: center;
    color: #495057; /* Muted text color */
    position: relative;
    border: 1px solid #dee2e6; /* Subtle border */
}
.game-over-content {
    background: #f8f9fa; /* Match modal background */
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); /* Softer shadow */
    max-width: 500px;
    width: 90%;
    padding: 40px;
    text-align: center;
    color: #495057; /* Muted text color */
    position: relative;
    border: 1px solid #dee2e6; /* Subtle border */
}

.game-over-content .close-btn {
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.1) !important;
    border: none !important;
    color: #495057 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    cursor: pointer !important;
    transition: background-color 0.3s !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.game-over-content .close-btn:hover {
    background: rgba(255,255,255,0.3) !important;
}
.hidden {
    display: none !important;
}
.close-btn {
    background: rgba(0,0,0,0.1);
    border: none;
    color: #495057;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.3s;
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.close-btn:hover {
    background: rgba(0,0,0,0.2);
}

.close-btn i {
    pointer-events: none; /* Prevent issues with clicking the icon */
}

/* Для модальных окон с белыми кнопками */
.modal-content .close-btn {
    background: none;
    color: #666;
    font-size: 1.5rem;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
}

.modal-content .close-btn:hover {
    color: #000;
}

.modal-content .close-btn i {
    pointer-events: none;
}
.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.btn-group-responsive .btn {
    flex: 1;
    min-width: 120px;
}
.status-combined-box {
    background-color: #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.status-item {
    display: flex;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #dee2e6;
}

.status-item:last-child {
    border-bottom: none;
}

.status-item strong {
    color: #495057;
    margin-right: 8px;
    min-width: 80px; /* Fixed width for labels to align them */
}

.status-item span {
    flex: 1;
    text-align: left;
}
.footer {
    margin-top: auto;
    padding: 20px 0;
    background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    color: white;
    text-align: center;
}
.piece-legend {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 10px;
}
.piece-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

.promotion-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}
.promotion-piece {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.promotion-piece:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.promotion-piece-name {
    margin-top: 10px;
    font-size: 14px;
}

.promotion-content .close-btn {
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.1) !important;
    border: none !important;
    color: #495057 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    cursor: pointer !important;
    transition: background-color 0.3s !important;
    position: absolute !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.promotion-content .close-btn:hover {
    background: rgba(255,255,255,0.3) !important;
}
.piece-svg {
    width: 70%;
    height: 70%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    min-width: 40%;
    min-height: 40%;
    font-size: 120%;
    line-height: 1;
    text-align: center;
    vertical-align: middle;
    color: inherit;
    font-weight: bold;
}

/* Disable default drag behavior for piece images in editor mode */
.editor-mode .piece-svg {
    pointer-events: auto;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.piece-white {
    filter: none;
    /* Белые фигуры теперь используют те же символы, что и черные, но белого цвета */
    color: #ffffff; /* Белый цвет для заливки */
    text-shadow:
        1px 1px 1px rgba(0, 0, 0, 0.7),
        -1px -1px 1px rgba(0, 0, 0, 0.7),
        1px -1px 1px rgba(0, 0, 0, 0.7),
        -1px 1px 1px rgba(0, 0, 0, 0.7);
}

.piece-black {
    filter: none;
    /* Черные фигуры - заливные символы */
    color: #000000; /* Черный цвет для заливки */
}

.piece-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70%;
    height: 70%;
    font-size: 250%;
    text-align: center;
    vertical-align: middle;
    pointer-events: none;
    margin: auto;
    text-shadow: 0px 0px 0px rgb(0 0 0), 0px 0px 0px rgb(0 0 0), 0px 0px 0px rgb(0 0 0), 0px 0px 0px rgb(0 0 0);
}

.search-progress {
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}
.search-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4dabf7, #339af0);
    width: 0%;
    transition: width 0.3s ease;
}
.depth-badge {
    background: #495057;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    display: inline-block;
    margin-left: 5px;
}
.eval-bar {
    height: 10px;
    background: linear-gradient(to right, #dc3545, #ffc107, #28a745);
    margin: 5px 0;
    border-radius: 5px;
    position: relative;
}
.eval-pointer {
    position: absolute;
    top: -5px;
    width: 3px;
    height: 20px;
    background: black;
    transform: translateX(-50%);
}
.move-analysis {
    font-size: 0.7rem;
    color: #666;
    margin-top: 5px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #dee2e6;
    min-height: 40px;
}
.tactical-warning {
    color: #dc3545;
    font-weight: bold;
}
.tactical-bonus {
    color: #28a745;
    font-weight: bold;
}
.defensive-move {
    color: #0d6efd;
    font-weight: bold;
}

/* Thinking indicator styles */
.thinking-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(0 0 0 / 48%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
}

.thinking-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border-radius: 10px;
}

.thinking-text {
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
}

/* Clock-like spinner */
.clock-spinner {
    width: 150px;
    height: 150px;
    border: 14px solid rgba(255, 255, 255, 0.3);
    border-top: 14px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Engine loading message styles */
.engine-loading-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 950;
}

.loading-message-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: #ffffff;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 80%;
    text-align: center;
}

.loading-spinner-large {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(200, 200, 200, 0.3);
    border-top: 8px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #333;
    font-size: 1.1rem;
    font-weight: 500;
    max-width: 400px;
    line-height: 1.5;
}

/* WASM loading progress styles */
.engine-loading-progress-container {
    width: 80%;
    margin-top: 15px;
}

.engine-loading-progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 5px;
}

.engine-loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #4dabf7, #339af0);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.engine-loading-progress-text {
    color: #333;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}

/* Стили для модального окна настроек */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(0 0 0 / 85%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: #f8f9fa; /* Match body background */
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); /* Softer shadow */
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #dee2e6; /* Subtle border */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0 20px;
    border-bottom: 1px solid #dee2e6; /* Consistent border color */
    position: relative;
    min-height: 40px;
    background-color: #f8f9fa; /* Match modal background */
    border-top-left-radius: 10px; /* Match modal border radius */
    border-top-right-radius: 10px;
}

.modal-title {
    margin: 0;
    font-size: 1.5rem;
    color: #495057; /* Muted text color */
}


.modal-body {
    padding: 20px;
}

.btn-group-responsive {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 576px) {
    .btn-group-responsive {
        flex-direction: row;
    }
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #dee2e6; /* Consistent border color */
    background-color: #f8f9fa; /* Match modal background */
    border-bottom-left-radius: 10px; /* Match modal border radius */
    border-bottom-right-radius: 10px;
}

.engine-selection-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.engine-selection-buttons .btn {
    text-align: left;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    transition: all 0.3s ease;
}

.engine-selection-buttons .btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

.engine-selection-buttons .btn:active {
    transform: translateY(0);
}

.engine-selection-buttons .btn h4 {
    margin: 0 0 5px 0;
}

.engine-selection-buttons .btn small {
    margin: 0;
    opacity: 0.8;
}  
/* Star rating display for Stockfish skill level */  
.star-rating {  
    font-size: 1.2em;  
    letter-spacing: 2px;  
}  
.skill-level {
    font-size: 0.9em;
    color: #666;
    margin-left: 5px;
}

/* Editor mode tools */
.editor-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

.editor-tool {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    font-weight: bold;
}

.editor-tool:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.editor-tool.active {
    border-color: #0d6efd;
    background: #e7f1ff;
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.2);
}

.editor-tool-icon {
    display: block;
    font-size: 24px;
    margin-bottom: 5px;
}

.editor-piece-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #ced4da;
}

.editor-piece-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
}

.editor-piece-option:hover {
    background: #f8f9fa;
    border-color: #0d6efd;
}

.editor-piece-option.selected {
    border-color: #0d6efd;
    background: #e7f1ff;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.2);
}

.editor-color-selector {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.editor-color-option {
    flex: 1;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.editor-color-option.white {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.editor-color-option.black {
    background: #343a40;
    color: white;
}

.editor-color-option.selected {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.editor-mode-indicator {
    display: inline-block;
    padding: 3px 8px;
    background: #0d6efd;
    color: white;
    border-radius: 4px;
    font-size: 0.8em;
    margin-left: 10px;
}

/* Settings modal styles */
.color-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.color-option {
    text-align: center;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.color-option:hover {
    background: #f0f0f0;
}

.color-option.selected {
    border: 2px solid #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
    background: #e7f1ff;
}

/* Стиль для круга под пальцем при перетаскивании на мобильных устройствах */
.drag-indicator-circle {
    position: fixed;
    border-radius: 50%;
    background-color: rgba(255, 255, 0, 0.4); /* Желтый цвет с 40% прозрачностью */
    pointer-events: none;
    z-index: 999;
    transform: translate(-50%, -50%);
}

/* Color selection modal styles */
.color-modal-container {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
}

.color-modal-option {
    background: white;
    border: 2px solid #dee2e6 !important;
    color: #6c757d !important; /* Muted gray to match site theme */
    transition: all 0.3s ease;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 12px !important;
    font-weight: 500 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

.color-modal-option:hover {
    background: #e9ecef;
    border-color: #adb5bd !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}

.color-modal-option.selected,
.color-modal-option:active,
.color-modal-option:checked {
    background: #0d6efd;
    border-color: #0d6efd !important;
    color: white !important;
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3) !important;
}

/* Specific styles for the color circle icons */
.color-modal-option i {
    font-size: 1.2em !important;
    margin-right: 8px !important;
}

/* Improve contrast for white circle in light theme */
.color-modal-option[for="white-modal"] i {
    border: 1px solid #ccc;
    border-radius: 50%;
    padding: 5px;
    background: #f8f9fa;
}

.color-modal-option[for="black-modal"] i {
    border: 1px solid #ccc;
    border-radius: 50%;
    padding: 5px;
    background: #f8f9fa;
}

/* Override Bootstrap outline button styles for color selection to match site theme */
.color-modal-container .btn-outline-dark {
    color: #6c757d !important; /* Muted gray to match site theme */
    border-color: #6c757d !important;
    background: white !important;
}

.color-modal-container .btn-outline-dark:hover {
    color: white !important;
    background-color: #6c757d !important; /* Muted gray to match site theme */
    border-color: #6c757d !important;
}

.color-modal-container .btn-outline-dark.focus,
.color-modal-container .btn-outline-dark:focus {
    box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, 0.5) !important; /* Match muted gray */
}

.color-modal-container .btn-outline-dark:not(:disabled):not(.disabled).active,
.color-modal-container .btn-outline-dark:not(:disabled):not(.disabled):active,
.show > .color-modal-container .btn-outline-dark.dropdown-toggle {
    color: white !important;
    background-color: #6c757d !important; /* Muted gray to match site theme */
    border-color: #6c757d !important;
}

/* Ensure selected state overrides all other styles */
.color-modal-option.selected {
    background: #6c757d !important; /* Muted gray to match site theme */
    border-color: #6c757d !important;
    color: white !important;
}

.color-preview {
    width: 60px;
    height: 60px;
    margin: 0 auto 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.color-option span {
    display: block;
    font-size: 0.8em;
    margin-top: 3px;
}

/* Hide the actual radio buttons for color selection */
input[name="color-modal"] {
    display: none;
}

/* Modern stylish range sliders */
.form-range {
    appearance: none;
    height: 12px; /* Increased height for better touch accessibility */
    border-radius: 6px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    position: relative;
    box-sizing: border-box;
    margin: 10px 0; /* Add some margin for better spacing */
}

.form-range::-webkit-slider-thumb {
    appearance: none;
    width: 30px; /* Increased width for better touch accessibility */
    height: 30px; /* Increased height for better touch accessibility */
    border-radius: 50%;
    background: #6c757d; /* Muted gray to match site theme */
    cursor: pointer;
    -webkit-appearance: none;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    margin-top: -9px; /* Adjusted to center the larger thumb on the track */
    position: relative;
    z-index: 2;
}

.form-range::-webkit-slider-thumb:hover {
    background: #5a6268; /* Darker gray on hover */
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(108, 117, 125, 0.4); /* Gray shadow to match */
}

.form-range::-moz-range-thumb {
    width: 30px; /* Increased width for better touch accessibility */
    height: 30px; /* Increased height for better touch accessibility */
    border-radius: 50%;
    background: #6c757d; /* Muted gray to match site theme */
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    margin-top: -9px; /* Adjusted to center the larger thumb on the track */
}

.form-range::-moz-range-thumb:hover {
    background: #5a6268; /* Darker gray on hover */
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(108, 117, 125, 0.4); /* Gray shadow to match */
}

/* Track for the range input */
.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 12px; /* Increased height to match the form-range */
    border-radius: 6px;
    background: #e0e0e0;
    cursor: pointer;
}

/* For Firefox */
.form-range::-moz-range-track {
    width: 100%;
    height: 12px; /* Increased height to match the form-range */
    border-radius: 6px;
    background: #e0e0e0;
    cursor: pointer;
}

/* Create the filled portion using pseudo-elements and JavaScript */
.form-range {
    background: linear-gradient(to right, #6c757d 0%, #6c757d 0%, #e0e0e0 0%, #e0e0e0 100%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* Better touch targets for mobile devices */
@media (max-width: 767px) {
    .form-range {
        height: 16px;
        margin: 15px 0;
    }

    .form-range::-webkit-slider-thumb {
        width: 36px;
        height: 36px;
        margin-top: -10px;
    }

    .form-range::-moz-range-thumb {
        width: 36px;
        height: 36px;
        margin-top: -10px;
    }

    .form-range::-webkit-slider-runnable-track {
        height: 16px;
    }

    .form-range::-moz-range-track {
        height: 16px;
    }
}

/* Modern stylish checkboxes */
.form-check-input {
    width: 22px;
    height: 22px;
    border: 2px solid #adb5bd;
    border-radius: 4px;
    background-color: white;
    position: relative;
    transition: all 0.2s ease;
}

.form-check-input:checked {
    background-color: #0d6efd !important;
    border-color: #0d6efd;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
    background-size: 16px;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.form-check-input:hover {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.form-check-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

/* Specific style for the "Ограничить силу игры" checkbox to add 10px gap and align vertically */
.form-check {
    display: flex;
    align-items: center;
}

#engine-limit-strength + .form-check-label {
    margin-left: 10px;
}

/* Muted button styles - Override Bootstrap defaults with more subtle colors */
.btn-primary {
    background-color: #6c757d !important; /* Gray instead of blue */
    border-color: #6c757d !important;
    color: white !important;
}

.btn-primary:hover {
    background-color: #5a6268 !important; /* Darker gray */
    border-color: #545b62 !important;
}

/* Override btn-success for the "Start New Game" button to match site theme */
#start-new-game {
    background-color: #78909C !important; /* Muted blue-gray to match site theme */
    border-color: #78909C !important;
    color: white !important;
}

#start-new-game:hover {
    background-color: #546E7A !important; /* Darker blue-gray on hover */
    border-color: #546E7A !important;
}

/* Keep original btn-success for other uses */
.btn-success {
    background-color: #4CAF50 !important; /* More muted green */
    border-color: #4CAF50 !important;
    color: white !important;
}

.btn-success:hover {
    background-color: #43A047 !important;
    border-color: #43A047 !important;
}

.btn-warning {
    background-color: #8BC34A !important; /* More muted yellow/green */
    border-color: #8BC34A !important;
    color: white !important;
}

.btn-warning:hover {
    background-color: #7CB342 !important;
    border-color: #7CB342 !important;
}

.btn-danger {
    background-color: #9E9E9E !important; /* Gray instead of red */
    border-color: #9E9E9E !important;
    color: white !important;
}

.btn-danger:hover {
    background-color: #757575 !important;
    border-color: #757575 !important;
}

.btn-info {
    background-color: #78909C !important; /* Muted blue-gray */
    border-color: #78909C !important;
    color: white !important;
}

.btn-info:hover {
    background-color: #546E7A !important;
    border-color: #546E7A !important;
}

.btn-secondary {
    background-color: #6e8a98 !important;
    border-color: #90A4AE !important;
    color: white !important;
}

.btn-secondary:hover {
    background-color: #78909C !important;
    border-color: #78909C !important;
}

.btn-light {
    background-color: #CFD8DC !important;
    border-color: #CFD8DC !important;
    color: #263238 !important;
}

.btn-light:hover {
    background-color: #B0BEC5 !important;
    border-color: #B0BEC5 !important;
}

.btn-dark {
    background-color: #455A64 !important; /* Muted dark blue-gray */
    border-color: #455A64 !important;
    color: white !important;
}

.btn-dark:hover {
    background-color: #37474F !important;
    border-color: #37474F !important;
}

.btn-outline-primary {
    color: #6c757d !important;
    border-color: #6c757d !important;
}

.btn-outline-primary:hover {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: white !important;
}

.btn-outline-secondary {
    color: #90A4AE !important;
    border-color: #90A4AE !important;
}

.btn-outline-secondary:hover {
    background-color: #90A4AE !important;
    border-color: #90A4AE !important;
    color: white !important;
}

.btn-outline-success {
    color: #4CAF50 !important;
    border-color: #4CAF50 !important;
}

.btn-outline-success:hover {
    background-color: #4CAF50 !important;
    border-color: #4CAF50 !important;
    color: white !important;
}

.btn-outline-warning {
    color: #8BC34A !important;
    border-color: #8BC34A !important;
}

.btn-outline-warning:hover {
    background-color: #8BC34A !important;
    border-color: #8BC34A !important;
    color: white !important;
}

.btn-outline-danger {
    color: #9E9E9E !important;
    border-color: #9E9E9E !important;
}

.btn-outline-danger:hover {
    background-color: #9E9E9E !important;
    border-color: #9E9E9E !important;
    color: white !important;
}

/* Right sidebar styles */
.right-sidebar {
    width: 350px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: #dbe1e6;
    border-left: 1px solid #c0cdda;
    min-height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 999;
    box-sizing: border-box; /* Ensure padding is included in width calculation */
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-top: 20px;
    padding-bottom: 20px;
}

.sticky-header {
    position: sticky;
    top: 0;
    background-color: inherit;
    z-index: 100;
    padding: 10px 0;
}

.logo-area {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.settings-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.settings-btn {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    text-decoration: none !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    transition: transform 0.3s ease;
}

.settings-btn:hover {
    transform: rotate(90deg); /* Rotate a quarter turn on hover */
}

/* Ensure theme toggle icon is monochrome */
#dark-mode-toggle i {
    filter: grayscale(100%) brightness(0.7);
}

.logo-area h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #495057;
}

.site-info {
    text-align: center;
    position: static !important; /* Ensure it's not sticky */
}

.site-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #6c757d;
}

/* Styling for the edit position button at the bottom */
#edit-position {
    margin: 10px auto;
    display: block;
}

/* Controls container in sidebar */
.controls-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

/* Custom scrollbar styling */
.controls-container::-webkit-scrollbar {
    width: 8px;
}

.controls-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.controls-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.controls-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* For Firefox */
.controls-container {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.controls {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Стили для кнопки установки PWA */
#install-pwa-button {
    background-color: #c8d4de;
    border: 1px solid #b5c2cf;
    color: #3b4248;
}

#install-pwa-button:hover {
    background-color: #bfcedd;
    border-color: #adb5bd;
}

[data-theme="dark"] #install-pwa-button {
    background-color: #343434;
    border: 1px solid #4d4d4d;
    color: #e9ecef;
}

[data-theme="dark"] #install-pwa-button:hover {
    background-color: #3e3e3e;
    border-color: #525252;
}

/* Container for small action buttons */
.small-buttons-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.small-action-btn {
    flex: 0 0 auto;
}

/* Hide the old controls container */
.col-lg-4 .controls {
    display: none !important;
}

/* Adjust main content to account for the sidebar */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #c7cfd5;
}

/* Adjust container to account for sidebar */
.container.py-4 {
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    position: fixed;
    top: 15px;
    right: 25px;
    z-index: 1000;
    display: none;
}

@media (max-width: 991px) {
    .mobile-menu-toggle {
        display: block;
    }
}

.burger-menu-btn {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

/* Menu icon styles */
.menu-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-icon-close.hidden {
    opacity: 0;
    visibility: hidden;
}

.menu-icon-hamburger.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Font Awesome icon styles */
.fas {
    display: inline-block;
}

/* Specific overrides for better contrast in different themes */
[data-theme="dark"] .settings-btn i,
[data-theme="dark"] .close-btn i {
    color: #ffffff;
}

[data-theme="light"] .settings-btn i,
[data-theme="light"] .close-btn i {
    color: #495057;
}

/* Ensure theme toggle icon adapts to theme */
[data-theme="dark"] #dark-mode-toggle i {
    color: #ffffff;
}

[data-theme="light"] #dark-mode-toggle i {
    color: #495057;
}

/* Mobile sidebar styles */
.right-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
}

.right-sidebar {
    transition: transform 0.3s ease;
}

@media (max-width: 991px) {
    .mobile-menu-toggle {
        display: block;
    }

    .right-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        z-index: 999;
        transform: translateX(100%);
        width: 280px;
        background: white;
    }

    .right-sidebar.mobile-open {
        transform: translateX(0);
    }
}

/* Custom styles for select dropdowns to make them more obviously dropdowns */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 4 7 7 7-7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px 12px;
    padding-right: 30px !important; /* Make room for the arrow */
    cursor: pointer;
}

/* Dark mode specific styles for dropdown arrows */
[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e0e0e0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 4 7 7 7-7'/%3e%3c/svg%3e");
}

/* Стили для анимации перемещения фигур */
.moving-piece {
    position: absolute !important;
    z-index: 1000 !important;
    pointer-events: none !important;
    transition: none !important;
    animation: movePieceLinear 0.3s linear forwards !important;
}

@keyframes movePieceLinear {
    from {
        left: var(--start-left);
        top: var(--start-top);
    }
    to {
        left: var(--end-left);
        top: var(--end-top);
    }
}

/* Стили для подсветки клетки при перетаскивании */
#square-container .square.drag-over {
    background-color: rgba(255, 253, 150, 0.849) !important; /* Желтый с полупрозрачностью */
    transition: background-color 0.2s ease !important;
    z-index: 10 !important; /* Ensure it's above other elements */
}

/* Стили для перетаскиваемой фигуры */
.dragging-piece {
    position: fixed !important;
    z-index: 1000 !important;
    pointer-events: none !important;
    opacity: 0.9 !important;
    transform: translate(-50%, -50%) !important;
}

/* Specific styles for text pieces during dragging - preserve original font size */
.dragging-piece.piece-text {
    text-shadow:
        1px 1px 1px rgba(0, 0, 0, 0.5),
        -1px -1px 1px rgba(255, 255, 255, 0.5),
        1px -1px 1px rgba(0, 0, 0, 0.3),
        -1px 1px 1px rgba(0, 0, 0, 0.3) !important;
    /* Prevent text selection and text cursor */
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    cursor: grabbing !important;
}

/* Убедимся, что фигуры могут получать mouse-события */
.piece-svg, .piece-text {
    pointer-events: auto !important;
}

/* Курсор при перетаскивании */
.dragging-piece {
    cursor: grabbing !important;
}

/* Курсор для фигур, которые можно перетаскивать */
.draggable-piece {
    cursor: grab !important;
}

/* Курсор при перетаскивании */
.dragging-piece {
    cursor: grabbing !important;
}  
/* Start game overlay */
.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* 70% transparency */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.start-game-button {  
    background-color: #212529;
    color: #fdfdfd;
    border: none;
    border-radius: 10px; 
    padding: 20px 40px;  
    font-size: 1.5rem;  
    font-weight: bold;  
    cursor: pointer;  
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);  
    transition: all 0.3s ease;  
    z-index: 1001;  
}  
.start-game-button:hover {  
    background-color: #546E7A;  
    transform: scale(1.05);  
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);  
}  
.start-game-button:active {  
    transform: scale(0.98);  
}

/* When modal is open, disable pointer events on everything except the modal */
body.modal-open *:not(.modal-overlay):not(.modal-overlay *):not(#settings-modal-main):not(#settings-modal-main *):not(#settings-modal):not(#settings-modal *) {
    pointer-events: none;
}

/* When start overlay is visible, disable pointer events on everything except the overlay and its children */
.start-overlay:not(.hidden) ~ * {
    pointer-events: none;
}

/* When modal is open, hide the mobile menu toggle button */
body.modal-open .mobile-menu-toggle {
    visibility: hidden;
}

/* Specific styles for awesome piece format - occupy 82% of cell */
.square img[src*="chess-"] {
    width: 82% !important;
    height: 82% !important;
}
