/* Version: 4.0 - Updated game screen background + bot yielding for UI responsiveness */
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

body::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Screen management */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.screen::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.screen.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100vh;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.screen.active::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Main Menu Styles */
.menu-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 200px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    gap: 0.5rem;
    z-index: 1000;
}

.menu-sidebar-btn {
    padding: 1rem 1.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    border-left: 3px solid transparent;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-weight: 500;
    text-decoration: none;
    display: block;
    width: 100%;
}

.menu-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.menu-sidebar-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: #8a8a8a;
}

.menu-container {
    background: transparent;
    padding: 2rem;
    max-width: 1400px;
    width: 90%;
    margin-left: 200px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.menu-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.menu-content-wrapper {
    display: flex;
    gap: 3rem;
    align-items: center;
}

.menu-options-panel {
    flex: 1;
    max-width: 500px;
}

.menu-board-panel {
    flex: 0 0 auto;
}

.menu-container h1 {
    text-align: left;
    color: white;
    margin-bottom: 0.5rem;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.menu-subtitle {
    text-align: left;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    margin: 0 0 2rem 0;
    line-height: 1.5;
    font-weight: 400;
}

.toggles-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toggle-group label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    letter-spacing: 0.2px;
}

/* Bot Selection Cards - Compact */
.bot-selection {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bot-card {
    background: rgba(40, 40, 40, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(10px);
}

.bot-card:hover {
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(50, 50, 50, 0.9);
}

.bot-card.active {
    border-color: #8a8a8a;
    background: rgba(138, 138, 138, 0.2);
    box-shadow: 0 0 12px rgba(138, 138, 138, 0.3);
}

.bot-emoji {
    font-size: 2rem;
    flex-shrink: 0;
}

.bot-info {
    display: flex;
    flex-direction: column;
}

.bot-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.15rem;
}

.bot-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Color Selection Cards - Compact */
.color-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.color-card {
    background: rgba(40, 40, 40, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.color-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(50, 50, 50, 0.9);
}

.color-card.active {
    border-color: #8a8a8a;
    background: rgba(138, 138, 138, 0.2);
    box-shadow: 0 0 12px rgba(138, 138, 138, 0.3);
}

.king-image {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.color-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

/* Mode Selection Cards */
.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-card {
    padding: 16px 20px;
    background: rgba(40, 40, 40, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.mode-card:hover {
    background: rgba(60, 60, 60, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.mode-card.active {
    border-color: #8a8a8a;
    background: rgba(138, 138, 138, 0.2);
    box-shadow: 0 0 12px rgba(138, 138, 138, 0.3);
}

.mode-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.mode-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
}

/* Takeback Selection - Compact */
.takeback-selection {
    background: rgba(40, 40, 40, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.takeback-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.takeback-option input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #8a8a8a;
}

.takeback-option label {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-weight: 500;
}

.takeback-option.custom-takebacks {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.takeback-input {
    width: 50px;
    padding: 0.3rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
}

.takeback-option span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Preview Board - Interactive (same size as main game board) */
.preview-board {
    width: 700px;
    height: 700px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    outline: 3px solid rgba(255, 255, 255, 0.2);
}

.preview-square {
    position: relative;
    display: flex;
        align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

/* Preview board notations */
.preview-square::before,
.preview-square::after {
    position: absolute;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 15;
}

/* File letters (a-h) on bottom rank */
.preview-square[data-rank="7"]::after {
    content: attr(data-file-letter);
    bottom: 2px;
    right: 3px;
}

/* Rank numbers (1-8) on left file */
.preview-square[data-file="0"]::before {
    content: attr(data-rank-number);
    top: 2px;
    left: 3px;
}

/* Color notation based on square color */
.preview-square.light::before,
.preview-square.light::after {
    color: #BAA381;
}

.preview-square.dark::before,
.preview-square.dark::after {
    color: #ECD3AB;
}

.preview-square.light {
    background-color: #ECD3AB;
}

.preview-square.dark {
    background-color: #BAA381;
}

.preview-piece {
    position: absolute;
    top: 0;
    left: 0;
        width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: grab;
    transition: opacity 0.2s ease;
    z-index: 25;
}

.preview-piece.dragging {
    position: fixed !important;
    cursor: grabbing;
    z-index: 1000;
    pointer-events: none;
    opacity: 1;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
    transition: none;
}

.preview-piece.ghost-piece {
    opacity: 0.2 !important;
    pointer-events: none;
    z-index: 2;
    transition: none;
}

/* Animation piece - GPU-accelerated transform animation */
.preview-piece.animating-piece {
    opacity: 1 !important;
    will-change: transform !important;
    transition: none;
}

.preview-square .square-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.preview-square .square-highlight.selected {
    background-color: rgba(25, 70, 120, 0.6);
}

.preview-square.light .square-highlight.last-move {
    background-color: rgba(255, 255, 0, 0.4);
}

.preview-square.dark .square-highlight.last-move {
    background-color: rgba(255, 255, 0, 0.2);
}

.preview-square .legal-move {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 33%;
    height: 33%;
    background-color: rgba(25, 70, 120, 0.6);
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
}

.preview-square .legal-move.capture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(135deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%),
        linear-gradient(225deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%),
        linear-gradient(315deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%),
        linear-gradient(45deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%);
    background-position: top left, top right, bottom right, bottom left;
    background-size: 50% 50%;
    background-repeat: no-repeat;
    border-radius: 0;
    pointer-events: none;
    z-index: 5;
    transform: none;
}

/* Hover highlight on preview board squares with legal moves */
.preview-square:has(.legal-move):hover {
    cursor: pointer;
}

/* Hide move indicators and last-move highlight when hovering on preview board */
.preview-square:hover .legal-move {
    visibility: hidden !important;
}

.preview-square:has(.legal-move):hover .square-highlight.last-move {
    display: none !important;
}

.preview-square:has(.legal-move):hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(25, 70, 120, 0.55);
    z-index: 20;
    pointer-events: none;
}

/* Green highlights for preview board */
.preview-square .square-highlight-green {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.preview-square.light .square-highlight-green {
    background-color: rgba(76, 175, 80, 0.7);
}

.preview-square.dark .square-highlight-green {
    background-color: rgba(76, 175, 80, 0.6);
}

/* Color selection buttons */
.color-options, .piece-options, .board-options, .difficulty-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-btn, .piece-btn, .board-btn, .difficulty-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid #ddd;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.color-btn:hover, .piece-btn:hover, .board-btn:hover, .difficulty-btn:hover {
    border-color: #333;
    transform: translateY(-2px);
}

.color-btn.active, .piece-btn.active, .board-btn.active, .difficulty-btn.active {
    background: #8a8a8a;
    color: white;
    border-color: #7a7a7a;
}

/* Bot selection dropdown */
#bot-select {
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
}

#bot-select:focus {
    outline: none;
    border-color: #333;
}

/* Start game button */
.start-btn {
    width: 100%;
    margin: 1.5rem 0 0 0;
    display: block;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #8a8a8a, #7a7a7a);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(138, 138, 138, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
    background: linear-gradient(135deg, #9a9a9a, #8a8a8a);
}

/* Game Screen Styles */
#game-screen {
    flex-direction: column;
    padding: 2rem;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-bottom: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.game-info span {
    font-weight: 600;
    color: #333;
}

.game-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.control-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.control-btn:hover {
    border-color: #333;
    background: #f8f9ff;
}

.control-btn:active {
    transform: translateY(1px);
}

.game-content-wrapper {
    background-color: #4a4a4a;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='f'><feTurbulence baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23f)' opacity='0.06'/></svg>"),
        radial-gradient(circle at 40% 30%, rgba(255,255,255,0.05) 0%, transparent 60%),
        radial-gradient(circle at 70% 70%, rgba(0,0,0,0.08) 0%, transparent 65%),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 6px);
    background-blend-mode: overlay, overlay, multiply, overlay;
    background-size:
        180px 180px,
        100% 100%,
        100% 100%,
        200px 200px;
    background-repeat: repeat, no-repeat, no-repeat, repeat;
    background-position: center center;
    box-shadow: inset 0 40px 50px rgba(0,0,0,0.15), inset 0 -30px 40px rgba(0,0,0,0.12);
    padding: 3rem;
    max-width: 1500px;
    width: 95%;
    margin: 0 auto;
}

.game-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0;
}

.game-status {
    display: none;
    text-align: center;
    background: white;
    padding: 1rem;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
}

#game-status-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive design */

@media (max-width: 1400px) {
    .menu-content-wrapper {
        flex-direction: column;
        gap: 2rem;
    }
    
    .menu-options-panel {
        max-width: none;
        width: 100%;
    }
    
    .preview-board {
        width: 600px;
        height: 600px;
    }
}

@media (max-width: 1024px) {
    .preview-board {
        width: 500px;
        height: 500px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
        overflow-x: hidden;
    }
    
    /* Sidebar at top on mobile - MUST be visible */
    .menu-sidebar {
        width: 100vw !important;
        height: auto !important;
        min-height: 50px !important;
        max-height: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        flex-direction: row !important;
        padding: 0.75rem !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        z-index: 99999 !important;
        background: rgba(20, 20, 20, 0.98) !important;
        backdrop-filter: blur(10px);
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }
    
    .menu-sidebar > a {
        flex-shrink: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .menu-sidebar > div {
        margin-top: 0 !important;
        padding: 0 !important;
        border-top: none !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
        width: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .menu-sidebar > div > div {
        margin-bottom: 0 !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        color: white !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .menu-sidebar > div > button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        width: auto !important;
        min-width: auto !important;
    }
    
    .menu-sidebar-btn {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        border-left: none !important;
        text-align: center !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        min-width: auto !important;
    }
    
    /* Make menu container scrollable */
    .menu-container {
        padding: 1.5rem 1rem !important;
        padding-bottom: 2rem !important;
        margin: 0 !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 60px !important; /* Space for fixed sidebar */
        max-width: 100% !important;
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        min-height: calc(100vh - 60px) !important;
        max-height: calc(100vh - 60px) !important;
        flex: 1 1 auto;
        position: relative;
        box-sizing: border-box;
    }
    
    .menu-container h1 {
        font-size: 1.75rem;
    }
    
    .menu-subtitle {
        font-size: 0.85rem;
    }
    
    /* Hide preview board on mobile */
    .menu-board-panel,
    .preview-board {
        display: none !important;
    }
    
    .menu-content-wrapper {
        flex-direction: column !important;
        gap: 0;
        width: 100%;
        height: 100%;
    }
    
    .menu-options-panel {
        width: 100% !important;
        max-width: none !important;
        display: block !important;
        flex-direction: column;
    }
    
    /* Start button at bottom - normal flow, no weird positioning */
    .toggles-container {
        margin-bottom: 2rem;
    }
    
    .start-btn {
        min-height: 50px !important;
        font-size: 1.1rem !important;
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
        width: 100% !important;
        padding: 1rem 1.5rem !important;
        background: linear-gradient(135deg, #8a8a8a, #7a7a7a) !important;
        color: white !important;
        border: 2px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        display: block !important;
        position: relative !important;
        transform: none !important;
        box-sizing: border-box !important;
    }
    
    .screen.active {
        flex-direction: column;
        align-items: stretch;
        padding: 0 !important;
        overflow: hidden;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    #main-menu.screen.active {
        display: flex !important;
        flex-direction: column;
        overflow: hidden !important;
        height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }
    
    .game-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    
    .game-controls {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .control-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-height: 44px; /* Touch target size */
    }
    
    .color-options, .piece-options, .board-options, .difficulty-options {
        justify-content: center;
    }
    
    .game-content-wrapper {
        padding: 0.5rem 1rem 1rem 1rem !important;
        width: 100%;
    }
    
    .game-content {
        flex-direction: column;
        gap: 0.5rem;
        padding-top: 0;
        margin-top: 0;
    }
    
    /* All page containers need space for fixed sidebar */
    .settings-container,
    .game-wrapper,
    .auth-container,
    .archive-main-container {
        margin-left: 0;
        padding: 1.5rem 1rem;
        width: 100%;
    }
    
    /* Archive and other pages - add padding for fixed sidebar */
    .settings-page {
        padding-top: 60px;
    }
    
    /* Ensure content doesn't go under fixed sidebar */
    .settings-page > .menu-sidebar ~ * {
        margin-top: 0;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .bot-card, .color-card, .mode-card {
        min-height: 44px; /* Touch target size */
    }
    
    .game-sidebar {
        width: 50px;
    }
    
    #game-screen.active {
        padding-left: 50px;
    }
    
    /* Archive Page Mobile Styles */
    .archive-main-container {
        padding: 1rem !important;
        margin-top: 0 !important;
    }
    
    .archive-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }
    
    .archive-title-section {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    .archive-title-section h1 {
        font-size: 1.5rem !important;
        margin: 0 !important;
    }
    
    .archive-pagination-header {
        flex-direction: column !important;
        gap: 1rem !important;
        margin-bottom: 1rem !important;
        align-items: flex-start !important;
    }
    
    .archive-pagination {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    
    .pagination-btn {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    .archive-game-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .archive-game-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .archive-game-info {
        width: 100% !important;
    }
    
    .archive-game-actions {
        width: 100% !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
    }
    
    .archive-game-actions button {
        flex: 1 !important;
        min-height: 44px !important;
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Game Review Page Mobile Styles */
    .settings-container {
        padding: 1rem !important;
        margin-top: 0 !important;
    }
    
    .settings-container > div:first-child {
        margin-bottom: 1rem !important;
    }
    
    .settings-container > div:first-child a {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
    }
    
    .game-review-content {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .evaluation-bar-container {
        order: -1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .evaluation-bar {
        height: 50px !important;
        flex-direction: row !important;
    }
    
    .eval-white-section,
    .eval-black-section {
        position: absolute !important;
        height: 100% !important;
        width: 50% !important;
        align-items: center !important;
    }
    
    .eval-white-section {
        left: 0 !important;
        top: 0 !important;
    }
    
    .eval-black-section {
        right: 0 !important;
        top: 0 !important;
    }
    
    .eval-score {
        font-size: 12px !important;
    }
    
    .chess-board {
        width: 100% !important;
        max-width: 100vw !important;
        aspect-ratio: 1 / 1 !important;
    }
    
    .move-list-container {
        width: 100% !important;
        max-height: 300px !important;
        font-size: 0.85rem !important;
    }
    
    .move-list {
        padding: 0.75rem !important;
    }
    
    .move-item {
        padding: 0.5rem !important;
        min-height: 44px !important;
    }
    
    .game-review-controls {
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-top: 1rem !important;
    }
    
    .nav-buttons {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }
    
    .nav-btn {
        flex: 1 1 calc(50% - 0.25rem) !important;
        min-height: 44px !important;
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    .material-count-display {
        width: 100% !important;
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
        margin-bottom: 0.75rem !important;
    }
}

@media (max-width: 480px) {
    .menu-sidebar {
        padding: 0.5rem;
    }
    
    .menu-sidebar-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .menu-container {
        margin-top: 55px;
        padding: 1rem 0.75rem;
    }
    
    .menu-container h1 {
        font-size: 1.5rem;
    }
    
    .menu-subtitle {
        font-size: 0.8rem;
    }
    
    .bot-selection, .color-selection, .mode-selection {
        gap: 0.5rem;
    }
    
    .bot-card {
        padding: 0.6rem 0.8rem;
    }
    
    .color-card {
        padding: 0.75rem;
    }
    
    .mode-card {
        padding: 12px 16px;
    }
    
    .start-btn {
        min-height: 55px;
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .game-content-wrapper {
        padding: 0.25rem 0.75rem 0.75rem 0.75rem !important;
    }
    
    .game-content {
        gap: 0.5rem;
        padding-top: 0;
        margin-top: 0;
    }
    
    .game-header {
        padding: 0.75rem;
    }
    
    .control-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .settings-container,
    .archive-main-container {
        padding: 1rem 0.75rem !important;
    }
    
    .settings-page {
        padding-top: 55px;
    }
    
    /* Archive Page - Smaller Screens */
    .archive-header h1 {
        font-size: 1.25rem !important;
    }
    
    .archive-pagination {
        width: 100% !important;
        justify-content: center !important;
    }
    
    .pagination-btn {
        min-width: 40px !important;
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
    }
    
    .archive-game-card {
        padding: 0.75rem !important;
    }
    
    /* Game Review - Smaller Screens */
    .chess-board {
        max-width: calc(100vw - 2rem) !important;
    }
    
    .move-list-container {
        max-height: 250px !important;
        font-size: 0.8rem !important;
    }
    
    .nav-btn {
        font-size: 0.85rem !important;
        padding: 0.6rem !important;
    }
    
    .eval-score {
        font-size: 11px !important;
    }
}

/* Settings Page */
.settings-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.settings-container {
    background-color: #4a4a4a;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='f'><feTurbulence baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23f)' opacity='0.06'/></svg>"),
        radial-gradient(circle at 40% 30%, rgba(255,255,255,0.05) 0%, transparent 60%),
        radial-gradient(circle at 70% 70%, rgba(0,0,0,0.08) 0%, transparent 65%),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 6px);
    background-blend-mode: overlay, overlay, multiply, overlay;
    background-size:
        180px 180px,
        100% 100%,
        100% 100%,
        200px 200px;
    background-repeat: repeat, no-repeat, no-repeat, repeat;
    background-position: center center;
    box-shadow: inset 0 40px 50px rgba(0,0,0,0.15), inset 0 -30px 40px rgba(0,0,0,0.12);
    padding: 3rem;
    max-width: 1500px;
    width: 95%;
    margin-left: 200px;
}

.settings-container h1 {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
    font-size: 2.5rem;
    font-weight: 300;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    margin-bottom: 1.5rem;
    align-items: start;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-group .board-colors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.setting-group label {
    font-weight: 600;
    color: white;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.save-settings-btn {
    width: auto;
    padding: 0.75rem 2rem;
    background: #3a3a3a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    align-self: center;
}

.save-settings-btn:hover {
    background: #3a3a3a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.settings-link-btn {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #3a3a3a;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.back-btn {
    margin-top: 2rem;
    padding: 0.75rem 1.5rem;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Game Sidebar */
.game-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 60px;
    background: #3a3a3a;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    gap: 1rem;
    z-index: 1000;
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* Adjust game screen for sidebar */
#game-screen.active {
    padding-left: 60px;
}

/* Settings Page Visual Previews */
.piece-style-option {
    padding: 1rem;
    border: 3px solid #ddd;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
}

.board-color-option {
    padding: 0.75rem;
    border: 3px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.piece-style-option:hover,
.board-color-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.piece-style-option.active,
.board-color-option.active {
    border-color: #4a8f5a;
    background: rgba(255, 255, 255, 0.3);
    position: relative;
}

.piece-style-option.active::after,
.board-color-option.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4a8f5a;
    font-size: 3rem;
    font-weight: bold;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.board-color-option.active::after {
    left: calc(50% + 40px);
}

.piece-style-header {
    font-weight: 600;
    font-size: 1.1rem;
    color: white;
    margin-bottom: 0.75rem;
}

.board-color-header {
    font-weight: 600;
    font-size: 1rem;
    color: white;
    min-width: 80px;
}

.piece-preview-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-around;
}

.piece-preview-row img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.board-color-preview {
    display: grid;
    grid-template-columns: repeat(2, 70px);
    grid-template-rows: repeat(2, 70px);
    gap: 0;
    width: fit-content;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Board color squares */
.light-brown {
    background-color: #F0D9B5;
}

.dark-brown {
    background-color: #B58863;
}

.light-green {
    background-color: #EEEEEE;
}

.dark-green {
    background-color: #666666;
}

.light-blue {
    background-color: #E6E6FA;
}

.dark-blue {
    background-color: #4682B4;
}

.light-purple {
    background-color: #E8D5F2;
}

.dark-purple {
    background-color: #8B5A9F;
}

.light-grey {
    background-color: #d4d4d4;
}

.dark-grey {
    background-color: #959494;
}

/* View Game Page Styles */
.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.game-header {
    width: 100%;
    text-align: center;
}

.game-header a {
    display: inline-block;
    margin-bottom: 1rem;
}

.game-header h2 {
    margin: 0.5rem 0;
    font-size: 2rem;
}

.game-header p {
    color: #666;
    margin: 0.5rem 0;
}

.board-container {
    flex-shrink: 0;
}

/* Wider move list for archive viewer */
.game-wrapper .move-list-container {
    width: 500px !important;
    min-width: 500px;
}

@media (min-width: 1024px) {
    .game-wrapper {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 3rem;
    }

    .game-header {
        width: 100%;
        text-align: left;
        order: -1;
    }
}
