/* ==========================================================================
   Global Variables
   ========================================================================== */
:root {
    /* Core Variables */
    --board-max-width: 600px;
    --control-bg: rgba(0, 0, 0, 0.2);
    --wrapper-bg: rgba(255, 255, 255, 0.05);
    --modal-bg: rgba(0, 0, 0, 0.85);
    --tooltip-bg: rgba(0, 0, 0, 0.9);
    --font-monospace: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Colors */
    --border-subtle: rgba(255, 255, 255, 0.1);
    --text-muted: rgba(255, 255, 255, 0.6);

    /* Transitions */
    --transition-quick: 0.15s ease;
    --transition-smooth: 0.3s ease;

    /* Import all variables from pattern-trainer.css */
    /* Layout */
    --header-height-mobile: 60px;
    --header-height-desktop: 70px;

    /* Additional engine-specific variables */
    --eval-badge-bg: rgba(0, 0, 0, 0.2);
    --eval-text-color: #fff;
    --analysis-bg: rgba(0, 0, 0, 0.85);
}

/* Header Components
-------------------------------------------------- */
/* Use exactly the same header styles as pattern-trainer.css */
.site-header {
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    min-height: 60px;
    background-color: var(--bs-dark);
}

.site-header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.header-logo {
    height: 32px;
    width: 32px;
    min-width: 32px;
    min-height: 32px;
    object-fit: contain;
    display: block;
}

.header-brand {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-brand:hover {
    opacity: 0.9;
    text-decoration: none;
    color: inherit;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.app-title {
    font-size: 1.1rem;
    font-weight: 500;
    white-space: nowrap;
    color: white;
    margin: 0;
    padding: 0;
}

@media (min-width: 768px) {
    .site-header {
        padding: 0.75rem 0;
        min-height: 70px;
    }

    .header-logo {
        height: 40px;
        width: 40px;
        min-width: 40px;
        min-height: 40px;
    }
}

@media (max-width: 576px) {
    .header-logo {
        height: 28px;
        width: 28px;
        min-width: 28px;
        min-height: 28px;
    }

    .app-title,
    .brand-name {
        font-size: 0.9rem;
    }
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
/* ...existing code... */

/* Board Container & Layout
-------------------------------------------------- */
.chessboard-wrapper {
    position: relative;
    width: 100%;
    max-width: var(--board-max-width);
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
    background: var(--wrapper-bg);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

#board {
    width: 100%;
    height: 100%;
}

.chessboard {
    width: 100%;
    height: 100%;
    border-radius: 0.25rem;
    overflow: hidden;
}

/* Container Adjustments */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Control Groups */
.btn-group {
    max-width: 600px;
    width: 100%;
}

/* Controls & Badges
-------------------------------------------------- */
/* Specificity fix for evaluation score */
.btn-group .controls-wrapper #analysisInfo {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.btn-group .controls-wrapper #analysisInfo #evalScore {
    position: static;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    background-color: var(--control-bg);
}

.btn-group .btn {
    position: static;
    flex: 1;
    min-width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin: 0;
}

.btn-group .btn:not(:last-child) {
    margin-right: 1px;
}

/* Controls & Badges - improved specificity */
.btn-group.controls-wrapper {
    position: relative;
    display: flex;
    gap: 0.25rem;
}

/* More specific selectors for nested elements */
.btn-group.controls-wrapper>.btn {
    position: static;
    flex: 1;
    min-width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin: 0;
}

.btn-group.controls-wrapper>#analysisInfo {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.btn-group.controls-wrapper>#analysisInfo>#evalScore {
    position: static;
    margin-left: 0.5rem;
    font-size: var(--font-size-xs);
    background-color: var(--eval-badge-bg);
    color: var(--eval-text-color);
}

/* Control Groups Layout */
.controls-wrapper {
    background: var(--control-bg);
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    gap: 0.25rem;
    max-width: var(--board-max-width);
    width: 100%;
}

/* Modal Improvements */
.modal-content {
    background-color: #fff;
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

/* Openings Navigator Modal Styles */
#openingsList {
    max-height: 50vh;
    /* Limit height to 50% of viewport height */
    overflow-y: auto;
    /* Enable vertical scrolling */
    scrollbar-width: thin;
    /* Firefox */
    -webkit-scrollbar-width: thin;
    /* Safari and Chrome */
}

#openingsList::-webkit-scrollbar {
    width: 6px;
}

#openingsList::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#openingsList::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#openingsList::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Make list items more compact and readable */
#openingsList .list-group-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

#openingsList .list-group-item:hover {
    background-color: #f8f9fa;
}

#openingsList .list-group-item.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .chessboard-wrapper,
    .btn-group {
        max-width: 100%;
        padding: 0 15px;
    }

    .controls-wrapper {
        padding: 0.375rem;
        gap: 0.2rem;
    }

    .btn-group .btn {
        padding: 0.375rem;
    }

    .chessboard-wrapper {
        padding: 0.375rem;
    }
}

@media (max-width: 576px) {

    .chessboard-wrapper,
    .btn-group {
        padding: 0 10px;
    }
}

/* Accessibility Improvements */
.btn:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.5);
    outline-offset: 2px;
}

[role="button"],
[role="tab"] {
    cursor: pointer;
}

/* Dark Mode Optimizations */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background-color: var(--modal-bg);
        color: #fff;
    }

    .btn-close {
        filter: invert(1) grayscale(100%) brightness(200%);
    }

    .form-control {
        background-color: rgba(255, 255, 255, 0.05);
        border-color: var(--border-subtle);
        color: #fff;
    }
}

/* ...existing code... */