/* Trainer Application Styles */

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--zen-bg-primary);
}

/* Sidebar */
.zen-sidebar {
    width: 220px;
    background: var(--zen-bg-secondary);
    border-right: 1px solid var(--zen-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--zen-shadow);
    position: relative;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--zen-border);
}

.logo-mini {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo-enso-mini {
    width: 32px;
    height: 32px;
    color: var(--zen-primary);
}

.logo-text {
    font-family: var(--font-zen);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--zen-primary);
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--zen-text-secondary);
    font-size: 0.9rem;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    color: var(--zen-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-elegant);
    font-size: 1rem;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--zen-bg-primary);
    color: var(--zen-primary);
}

.nav-item.active {
    background: var(--zen-bg-primary);
    color: var(--zen-primary);
    border-left-color: var(--zen-accent);
    font-weight: 500;
}

.nav-icon {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--zen-border);
}

.zen-quote {
    text-align: center;
    font-style: italic;
    color: var(--zen-text-secondary);
    font-size: 0.9rem;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--zen-bg-primary);
}

.content-section {
    display: none;
    padding: 2rem;
    max-width: none;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.content-section.active {
    display: block;
    animation: zen-fade-in 0.4s ease-out;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-title {
    font-size: 2rem;
    color: var(--zen-primary);
    font-weight: 400;
    margin: 0;
}

/* Training Section */
.training-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.zen-select {
    padding: 0.75rem;
    border: 2px solid var(--zen-border);
    border-radius: var(--zen-radius);
    background: var(--zen-bg-secondary);
    color: var(--zen-text-primary);
    font-family: var(--font-elegant);
    font-size: 1rem;
    min-width: 200px;
}

.training-board {
    background: var(--zen-bg-secondary);
    border-radius: var(--zen-radius);
    padding: 2rem;
    box-shadow: var(--zen-shadow);
    margin-bottom: 2rem;
    min-height: calc(100vh - 300px);
    height: 100%;
}

.board-container {
    display: grid;
    grid-template-columns: 220px 1fr 2fr;
    gap: 1.5rem;
    align-items: start;
    height: 100%;
    width: 100%;
}

.chess-board {
    width: 100%;
    max-width: none;
    min-width: 300px;
    margin: 0;
    aspect-ratio: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-info {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.current-opening h3 {
    font-size: 1.5rem;
    color: var(--zen-primary);
    margin-bottom: 0.5rem;
}

.current-opening p {
    color: var(--zen-text-secondary);
    margin-bottom: 0.5rem;
}

.difficulty {
    font-size: 1.2rem;
    color: var(--zen-warning);
}

/* Feedback messages */
.feedback-text {
    padding: 10px 15px;
    border-radius: 5px;
    margin: 10px 0;
    font-weight: 500;
    transition: all 0.3s ease;
}

.feedback-text.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-text.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.feedback-text.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.next-moves {
    background: var(--zen-bg-primary);
    padding: 1rem;
    border-radius: var(--zen-radius);
    border: 1px solid var(--zen-border);
}

.next-moves h4 {
    margin-bottom: 0.5rem;
    color: var(--zen-primary);
}

.next-moves-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--zen-primary);
}

.database-moves-section {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--zen-radius);
    border: 1px dashed var(--zen-border);
    background: var(--zen-bg-secondary);
}

.database-moves-loading,
.database-moves-error,
.database-moves-empty {
    font-size: 0.9rem;
    color: var(--zen-text-secondary);
}

.database-moves-error {
    color: var(--zen-danger);
}

.database-moves-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.database-move {
    border: 1px solid var(--zen-border);
    border-radius: var(--zen-radius);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    background: #fff;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.database-move:hover {
    background: #f8f9ff;
    border-color: var(--zen-primary);
}

.database-move-main {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--zen-primary);
}

.database-move-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--zen-text-secondary);
    margin-top: 0.25rem;
}

.database-move-games {
    color: var(--zen-text-secondary);
    font-weight: normal;
    font-size: 0.85rem;
}

.database-move-percentage {
    font-weight: 600;
    color: var(--zen-text-secondary);
    font-size: 0.85rem;
}

.database-move-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.wdl-bar {
    display: flex;
    height: 8px;
    flex: 1;
    border-radius: 4px;
    overflow: hidden;
    background: #333;
}

.wdl-white {
    background: #f0f0f0;
    height: 100%;
}

.wdl-draw {
    background: #888;
    height: 100%;
}

.wdl-black {
    background: #333;
    height: 100%;
}

.wdl-label {
    font-size: 0.75rem;
    color: var(--zen-text-secondary);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

.training-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Repertoires Section */
.repertoires-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.repertoire-card {
    background: var(--zen-bg-secondary);
    padding: 1.5rem;
    border-radius: var(--zen-radius);
    box-shadow: var(--zen-shadow);
    border: 1px solid var(--zen-border);
    transition: all 0.3s ease;
}

.repertoire-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--zen-shadow-hover);
}

.repertoire-card h3 {
    color: var(--zen-primary);
    margin-bottom: 0.5rem;
}

.repertoire-meta {
    color: var(--zen-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.repertoire-actions {
    display: flex;
    gap: 0.5rem;
}

/* Progress Section */
.progress-dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--zen-bg-secondary);
    padding: 1.5rem;
    border-radius: var(--zen-radius);
    box-shadow: var(--zen-shadow);
    text-align: center;
    border: 1px solid var(--zen-border);
}

.stat-card h3 {
    color: var(--zen-text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--zen-primary);
}

.progress-chart {
    background: var(--zen-bg-secondary);
    padding: 2rem;
    border-radius: var(--zen-radius);
    box-shadow: var(--zen-shadow);
    border: 1px solid var(--zen-border);
    height: 400px;
}

/* Import section styles */
.import-container {
    max-width: 800px;
    margin: 0 auto;
}

.import-form {
    background: rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
}

.import-results {
    min-height: 50px;
    padding: 15px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pgn-textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
}

.pgn-textarea::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.file-input {
    width: 100%;
    padding: 10px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    cursor: pointer;
}

.file-input:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive Design for Trainer */
@media (max-width: 1024px) {
    .board-container {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .chess-board {
        min-width: 320px;
        max-width: none;
    }

    .training-board {
        min-height: auto;
    }

    .import-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .zen-sidebar {
        width: 100%;
        height: auto;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 0;
    }

    .nav-item {
        flex-shrink: 0;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .nav-item.active {
        border-left: none;
        border-bottom-color: var(--zen-accent);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .training-controls {
        width: 100%;
        justify-content: stretch;
    }

    .zen-select {
        flex: 1;
        min-width: 0;
    }

    .content-section {
        padding: 1rem;
    }

    .board-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chess-board {
        min-width: 280px;
        max-width: none;
    }

    #chessboard {
        border-width: 1px;
    }

    .training-board {
        padding: 1rem;
        min-height: auto;
    }
}

/* Chess Board Customization */
#chessboard {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border: 2px solid var(--zen-border);
    border-radius: var(--zen-radius);
    box-shadow: var(--zen-shadow);
    background: var(--zen-bg-secondary);
}

.chess-board .square-55d63 {
    border-radius: 4px !important;
}

.chess-board .white-1e1d7 {
    background-color: #f8f8f8 !important;
}

.chess-board .black-3c85d {
    background-color: #e8e8e8 !important;
}

.chess-board .highlight1-32417 {
    background-color: rgba(52, 152, 219, 0.3) !important;
}

.chess-board .highlight2-9c5d2 {
    background-color: rgba(39, 174, 96, 0.3) !important;
}

/* Ensure pieces are visible */
.chess-board .piece-417db {
    cursor: pointer !important;
}

.chess-board .spare-pieces-7492f {
    display: none !important;
}

/* Hide modals by default */
.modal {
    display: none;
}

.modal.show {
    display: block;
}

/* Site Updates Link */
.site-updates-link {
    font-size: 0.8rem;
    margin-left: 1rem;
    color: var(--zen-primary);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.site-updates-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Site Updates Modal Styles */
#siteUpdatesModal .modal-content {
    max-height: 85vh;
    overflow-y: auto;
}

.site-updates-content h3 {
    color: var(--zen-primary);
    margin-bottom: 1rem;
}

.update-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.update-list li {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.update-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--zen-success);
    font-weight: bold;
}

.update-list li strong {
    color: var(--zen-primary);
    display: block;
    margin-bottom: 0.5rem;
}

.update-note {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--zen-border);
    color: var(--zen-text-secondary);
    font-style: italic;
}

/* Move Tree Styles */
.move-tree-root {
    overflow-x: auto;
    overflow-y: auto;
    padding: 8px;
    background: #fff;
    height: 100%;
    width: 100%;
    font-size: 15px;
    font-family: 'Segoe UI', Arial, sans-serif;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    white-space: nowrap;
}

/* Chrome/Edge scrollbar styling */
.move-tree-root::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.move-tree-root::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.move-tree-root::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.move-tree-root::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.move-tree-root h3 {
    color: var(--zen-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 400;
}

/* Chess Tree Visualization */
.chess-tree {
    display: flex;
    flex-direction: row;
    gap: 0;
    min-width: 100%;
    flex-wrap: nowrap;
}

/* Move Tree Mainline (horizontal) - FIXED */
.chess-tree-mainline, .chess-tree-mainline.compact-mainline {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    width: 100% !important;
    flex-direction: row !important;
    line-height: 1 !important;
}

/* Horizontal connector between moves - ENHANCED */
.tree-connector-horizontal, .tree-connector-horizontal.compact-connector {
    width: 24px !important;
    height: 4px !important;
    background: #000 !important;
    margin: 0 2px !important;
    flex-shrink: 0 !important;
    align-self: center !important;
    display: inline-block !important;
    vertical-align: middle !important;
    border-radius: 2px !important;
    min-width: 24px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Clickable ellipsis indicator */
.move-ellipsis {
    display: inline-block !important;
    padding: 4px 8px !important;
    background: #007bff !important;
    color: white !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-weight: bold !important;
    margin: 0 4px !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

.move-ellipsis:hover {
    background: #0056b3 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
}

/* Move pair styling - FIXED */
.move-pair {
    display: inline-block !important;
    padding: 2px 8px !important;
    background: #f7f7f7 !important;
    border-radius: 4px !important;
    margin-right: 0 !important;
    font-weight: 500 !important;
    min-width: 32px !important;
    text-align: center !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.move-number, .move-dot, .move-text {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.95em !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

.move-dot {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Branches (vertical stack) */
.chess-tree-branches {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-left: 2.5rem;
    padding: 0;
}

.chess-tree-branches.compact-branches {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-left: 0.5rem;
    padding: 0;
}

.chess-tree-branch {
    display: flex;
    align-items: flex-start;
    position: relative;
    margin: 0;
    padding: 0;
    margin-left: 24px;
    border-left: 2px solid #ddd;
    padding-left: 8px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.branch-toggle {
    font-size: 1.1em;
    margin-right: 4px;
    color: #888;
    cursor: pointer;
    user-select: none;
}

.chess-tree-node {
    min-width: 0;
    margin: 0;
    padding: 0;
    display: inline-block;
}

.chess-node-content {
    padding: 0.5rem 0.8rem;
    min-width: 60px;
    font-size: 1em;
    margin: 0;
    box-shadow: var(--zen-shadow);
    border-radius: var(--zen-radius);
    background: var(--zen-bg-primary);
    border: 2px solid var(--zen-border);
    display: inline-block;
    white-space: nowrap;
}

.chess-node-content:hover {
    background: var(--zen-accent);
    color: white;
}

.chess-node-move {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    font-weight: 500;
}

.move-number {
    font-weight: 600;
    color: var(--zen-primary);
    min-width: 30px;
}

.move-text {
    font-family: var(--font-elegant);
    font-weight: 500;
}

.leaf-indicator {
    color: var(--zen-accent);
    font-size: 0.8rem;
}

/* Remove old vertical/children styles for compactness */
.chess-tree-children,
.chess-tree-children::before,
.chess-tree-children .chess-tree-node,
.chess-tree-children .chess-tree-node::before,
.chess-tree-children::after {
    display: none !important;
}

/* Enhanced connection lines for multiple children */
.chess-tree-children::after {
    content: '';
    position: absolute;
    top: 1.5rem;
    left: 0;
    right: 0;
    height: 3px;
    background: #000000;
    z-index: 1;
    border-radius: 1px;
}

/* Hide horizontal line for single child */
.chess-tree-children[data-children-count="1"]::after {
    display: none;
}

/* Current position highlighting */
.chess-tree-node.current-position .chess-node-content {
    background: var(--zen-accent);
    color: white;
    border-color: var(--zen-accent);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.chess-tree-node.current-position .move-number,
.chess-tree-node.current-position .move-text {
    color: white;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--zen-primary);
    font-size: 1.1rem;
}

/* Clean up any old connection line elements */
.connection-line,
.horizontal-line {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chess-tree-children {
        flex-direction: column;
        gap: 1rem;
    }
    
    .chess-tree-children .chess-tree-node::after {
        display: none;
    }
    
    .chess-tree-children .chess-tree-node::before {
        left: 0;
        transform: none;
    }
    
    .move-tree-root {
        min-width: auto;
        overflow-x: auto;
    }
}

/* Canvas-based move tree visualization */
.canvas-tree-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    background: var(--zen-bg-secondary);
    border-radius: var(--zen-radius);
    position: relative;
    padding: 1rem;
}

#move-tree-canvas {
    display: block;
    background: white;
    border: 1px solid var(--zen-border);
    border-radius: var(--zen-radius);
    cursor: grab;
    box-shadow: var(--zen-shadow);
}

#move-tree-canvas:active {
    cursor: grabbing;
}

/* Canvas tree node hover effects */
.canvas-tree-container:hover #move-tree-canvas {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    background: white;
    border-radius: var(--zen-radius-lg);
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--zen-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.1rem;
    color: var(--zen-text);
    font-weight: 500;
}

/* Statistics Styles */
#stats-content {
    max-height: calc(100vh - 300px);
    overflow-y: scroll; /* Changed from auto to scroll to always show scrollbar */
    overflow-x: hidden;
    padding-right: 10px;
}

/* Custom scrollbar for statistics */
#stats-content::-webkit-scrollbar {
    width: 8px;
}

#stats-content::-webkit-scrollbar-track {
    background: var(--zen-bg-tertiary);
    border-radius: 4px;
}

#stats-content::-webkit-scrollbar-thumb {
    background: var(--zen-primary);
    border-radius: 4px;
    opacity: 0.7;
}

#stats-content::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

.overall-stats {
    background: var(--zen-bg-secondary);
    border-radius: var(--zen-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--zen-shadow);
}

.overall-stats h3 {
    color: var(--zen-primary);
    margin-bottom: 1rem;
}

.overall-stats p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.overall-stats span {
    font-weight: bold;
    color: var(--zen-primary);
}

.repertoire-stats {
    background: var(--zen-bg-secondary);
    border-radius: var(--zen-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--zen-shadow);
}

.repertoire-stats h3 {
    color: var(--zen-primary);
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--zen-primary);
    padding-bottom: 0.5rem;
}

.repertoire-stats p {
    margin: 0.5rem 0;
}

.opening-stats {
    margin-top: 1.5rem;
}

.opening-stats h4 {
    color: var(--zen-text);
    margin-bottom: 1rem;
}

.opening-stat-item {
    background: white;
    border: 1px solid var(--zen-border);
    border-radius: var(--zen-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.opening-stat-item strong {
    color: var(--zen-primary);
    display: block;
    margin-bottom: 0.5rem;
}

.opening-moves {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--zen-text-secondary);
    margin-bottom: 0.5rem;
}

.opening-stats-details {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.opening-stats-details span {
    color: var(--zen-text);
}

.no-training-data {
    color: var(--zen-text-secondary);
    font-style: italic;
    padding: 1rem;
    text-align: center;
}

/* Mobile styles for Site Updates */
@media (max-width: 768px) {
    .loading-content {
        padding: 1.5rem;
        width: 80%;
        max-width: 300px;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .site-updates-link {
        display: block;
        margin-left: 0;
        margin-top: 0.5rem;
        font-size: 0.75rem;
    }
    
    h1 {
        font-size: 1.3rem;
        line-height: 1.4;
    }
    
    #siteUpdatesModal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 2rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .site-updates-content {
        font-size: 0.9rem;
    }
    
    .update-list li {
        margin-bottom: 1rem;
        padding-left: 1.2rem;
    }
    
    .update-list li strong {
        font-size: 0.95rem;
    }
    
    /* Mobile Statistics Styles */
    #stats-content {
        max-height: calc(100vh - 200px);
    }
    
    .overall-stats {
        padding: 1rem;
    }
    
    .repertoire-stats {
        padding: 1rem;
    }
    
    .opening-stat-item {
        padding: 0.75rem;
    }
    
    .opening-stats-details {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .opening-moves {
        font-size: 0.8rem;
        word-break: break-all;
    }
}

/* ============================================================================
   STOCKFISH ENGINE PANEL COMPACT STYLES
   ============================================================================ */

/* Position Setup Panel */
.setup-btn {
    background: #7c4dff;
    color: white;
    border: none;
    font-weight: 600;
}

.setup-btn:hover {
    background: #651fff;
}

.setup-btn.active {
    background: #f44336;
}

/* When setup mode is active, elevate controls above overflowing spare pieces */
.controls.setup-active {
    position: relative;
    z-index: 200;
}

.position-setup-panel {
    margin: 8px 0;
    padding: 8px;
    background: #f3e5f5;
    border: 1px solid #ce93d8;
    border-left: 3px solid #7c4dff;
    border-radius: 4px;
    font-size: 0.85rem;
}

.setup-fen-row {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.setup-fen-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ce93d8;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.78rem;
}

.setup-fen-btn {
    padding: 4px 10px;
    background: #7c4dff;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.78rem;
}

.setup-fen-btn:hover {
    background: #651fff;
}

.setup-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.setup-turn-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.setup-turn-toggle span {
    font-weight: 600;
    color: #333;
}

.setup-turn-btn {
    padding: 2px 8px;
    font-size: 0.78rem;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    border-radius: 3px;
}

.setup-turn-btn.active {
    background: #333;
    color: white;
    border-color: #333;
}

.setup-actions {
    display: flex;
    gap: 4px;
}

.setup-actions .btn {
    padding: 3px 10px;
    font-size: 0.78rem;
}

.setup-hint {
    margin-top: 6px;
    font-size: 0.75rem;
    color: #888;
    font-style: italic;
}

/* Spare pieces styling (chessboard.js built-in, override for nicer look) */
.spare-pieces-7492f {
    padding: 4px 0;
}

/* Endgame Prover Panel */
.endgame-panel {
    margin: 0 0 10px 0;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.endgame-panel.endgame-detecting,
.endgame-panel.endgame-analyzing,
.endgame-panel.endgame-proving {
    background: #fff8e1;
    border-left: 3px solid #ffc107;
}

.endgame-panel.endgame-proved {
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
}

.endgame-panel.endgame-no-mate {
    background: #f5f5f5;
    border-left: 3px solid #9e9e9e;
}

.endgame-panel.endgame-winning {
    background: #fff3e0;
    border-left: 3px solid #ff9800;
}

.endgame-panel.endgame-error {
    background: #fbe9e7;
    border-left: 3px solid #f44336;
}

.endgame-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.endgame-icon {
    font-size: 1.1rem;
}

.endgame-title {
    font-weight: 600;
    color: #333;
    flex: 1;
}

.endgame-badge {
    background: #4caf50;
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.endgame-toggle {
    font-size: 0.7rem;
    color: #666;
}

.endgame-details {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.endgame-stats {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 6px;
}

.endgame-proof-tree {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    background: rgba(255,255,255,0.5);
    border-radius: 3px;
}

.proof-or {
    color: #1565c0;
}

.proof-defense {
    color: #c62828;
}

.proof-defense-count {
    color: #666;
    font-style: italic;
    font-size: 0.75rem;
}

.proof-checkmate {
    color: #2e7d32;
    font-weight: 700;
}

.proof-leaf {
    color: #2e7d32;
}

.proof-more {
    color: #999;
    font-style: italic;
}

.proof-and-branch {
    border-left: 2px solid #e0e0e0;
    padding-left: 6px;
    margin: 2px 0;
}

/* Spinner for endgame detection */
.endgame-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ffc107;
    border-top-color: transparent;
    border-radius: 50%;
    animation: endgame-spin 0.8s linear infinite;
}

.endgame-proved .endgame-spinner {
    display: none;
}

@keyframes endgame-spin {
    to { transform: rotate(360deg); }
}

.engine-panel-compact {
    margin: 0 0 10px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    border-left: 3px solid #4caf50;
    font-size: 0.85rem;
}

.engine-header-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.engine-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

.btn-toggle-engine {
    padding: 3px 10px;
    font-size: 0.75rem;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.btn-toggle-engine:hover {
    background: #45a049;
}

.engine-content-compact {
    padding-top: 6px;
}

.engine-eval-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.eval-score-compact {
    font-size: 1rem;
    font-weight: bold;
    color: #2c3e50;
    min-width: 50px;
}

.eval-bar-container-compact {
    flex: 1;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.eval-bar-compact {
    height: 100%;
    width: 50%;
    background: #888;
    transition: width 0.2s ease, background-color 0.2s ease;
}

.engine-controls-compact {
    margin-bottom: 6px;
}

.engine-controls-compact label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #555;
}

.engine-controls-compact select {
    padding: 2px 4px;
    font-size: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.engine-lines-compact {
    max-height: 200px;
    overflow-y: auto;
}

.engine-line-compact {
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.8rem;
    display: flex;
    gap: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.engine-line-compact:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

.engine-line-compact:last-child {
    border-bottom: none;
}

.line-num {
    color: #999;
    min-width: 15px;
}

.line-score {
    font-weight: bold;
    color: #2c3e50;
    min-width: 50px;
}

.line-moves {
    font-family: monospace;
    color: #555;
    line-height: 1.3;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .engine-panel-compact {
        margin-bottom: 8px;
        padding: 6px;
    }

    .eval-score-compact {
        font-size: 0.9rem;
    }

    .line-moves {
        font-size: 0.75rem;
    }
}

/* Nested Folder Styles */
.tree-children {
    position: relative;
}

.tree-children::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color, #3a4a5a);
    opacity: 0.5;
}

.folder-item[data-folder-level="1"] {
    font-size: 0.95em;
}

.folder-item[data-folder-level="2"] {
    font-size: 0.9em;
}

.folder-item[data-folder-level="3"] {
    font-size: 0.85em;
}
