/* Reset and base styles - Chat Spacing Fix v2.0 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Better touch interactions */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Cross-browser compatibility */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.2;
}

/* App Container */
.app-container {
    min-height: 100vh;
    width: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    /* Remove fixed height to allow natural flow */
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border-bottom: 2px solid #4a5568;
}

.app-header h1 {
    color: #fff;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.upload-controls {
    display: flex;
    gap: 1rem;
}

.header-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    /* Touch-friendly */
    min-height: 44px;
    touch-action: manipulation;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

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

/* Clean Top Navigation */
.clean-top-navigation {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    border-bottom: 1px solid #4a5568;
    gap: 2rem;
    min-height: 80px;
}

/* Game Moves Section - Simplified */
.top-moves-section {
    flex: 1;
    max-width: 60%;
    min-width: 300px;
}

.top-moves-section h3 {
    color: #e2e8f0;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clean-moves-list-container {
    background: #2d3748;
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid #4a5568;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.clean-moves-list-container .no-moves-msg {
    color: #a0aec0;
    font-style: italic;
    text-align: center;
    margin: 0;
}

/* Top Game Info Panel - Right Side (Collapsible) */
.top-game-info-panel {
    flex: 1;
    max-width: 50%;
    min-width: 250px;
}

.game-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
    transition: all 0.2s ease;
}

.game-info-header:hover {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 0.5rem;
    margin: 0 -0.5rem;
}

.game-info-header h3 {
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-btn {
    background: none;
    border: none;
    color: #e2e8f0;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.toggle-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.toggle-arrow.expanded {
    transform: rotate(180deg);
}

.collapsible-game-info {
    background: #2d3748;
    border-radius: 8px;
    border: 1px solid #4a5568;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.collapsible-game-info.collapsed {
    max-height: 0;
    padding: 0 0.75rem;
    opacity: 0;
    margin-top: 0;
}

.collapsible-game-info:not(.collapsed) {
    max-height: 200px;
    padding: 0.75rem;
    opacity: 1;
}

.collapsible-game-info .no-game-msg {
    color: #a0aec0;
    font-style: italic;
    text-align: center;
    margin: 0;
}

/* Main Content Layout */
.main-content {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 1.5rem;
    padding: 1rem;
    width: 100%;
    max-width: 100%;
    /* Allow content to flow naturally */
    overflow-x: auto;
    overflow-y: visible;
    min-height: calc(100vh - 120px); /* Account for header */
}

/* Sticky Analysis Sidebar */
.analysis-sidebar {
    width: 20%;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.5rem;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    z-index: 5;
}

.panel {
    background: #2d3748;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid #4a5568;
}

.panel h3 {
    color: #e2e8f0;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.panel h4 {
    color: #cbd5e0;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Game Information Panel */

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

.game-info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #4a5568;
}

.game-info-label {
    font-weight: 600;
    color: #a0aec0;
}

.game-info-value {
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
}

.no-game-msg, .no-moves-msg {
    color: #718096;
    text-align: center;
    font-style: italic;
    padding: 2rem 0;
}

/* Enhanced Evaluation Bar */
.evaluation-bar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: rgba(45, 55, 72, 0.5);
    border-radius: 12px;
    border: 1px solid #4a5568;
}

.evaluation-bar {
    flex: 1;
    height: 32px;
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    border: 3px solid #1a202c;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.2);
}

.eval-fill {
    height: 100%;
    background: linear-gradient(135deg, 
        #e53e3e 0%,    /* Red for losing */
        #f56565 25%,   /* Light red */
        #d69e2e 45%,   /* Yellow for equal */
        #68d391 55%,   /* Light green */
        #38a169 100%   /* Green for winning */
    );
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 50%;
    border-radius: 13px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.eval-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, 
        rgba(255, 255, 255, 0.3) 0%, 
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    border-radius: 13px 13px 0 0;
}

.eval-center-line {
    position: absolute;
    left: 50%;
    top: -2px;
    bottom: -2px;
    width: 3px;
    background: linear-gradient(180deg, #1a202c 0%, #2d3748 50%, #1a202c 100%);
    transform: translateX(-50%);
    border-radius: 2px;
    box-shadow: 
        0 0 4px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.eval-score {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', 'Courier New', monospace;
    font-weight: 700;
    font-size: 1.2rem;
    color: #e2e8f0;
    min-width: 80px;
    text-align: center;
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    border: 2px solid #4a5568;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Position Analysis Panel */
.panel.analysis-panel {
    height: 600px !important; /* Force taller fixed height for better readability */
    overflow-y: auto !important; /* Force scrollable content */
    min-height: 600px !important; /* Prevent shrinking */
    max-height: 600px !important; /* Prevent growing */
}

/* Analysis Content */
.analysis-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.best-move {
    background: #4a5568;
    padding: 0.75rem;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    color: #667eea;
    border: 2px solid #667eea;
}

/* Move Comparison Section */
.move-comparison-section h4 {
    margin-bottom: 0.5rem;
}

.move-comparison {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.actual-move, .suggested-move {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

.actual-move {
    background: #4a5568;
    border-left: 4px solid #f56565;
}

.suggested-move {
    background: #2d5016;
    border-left: 4px solid #68d391;
}

.move-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #cbd5e0;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.move-text {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', 'Courier New', monospace;
    font-weight: 700;
    color: #f7fafc;
    font-size: 1.3rem;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.1),
        0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: inline-block;
    min-width: 60px;
    text-align: center;
}

.move-text:hover {
    transform: translateY(-1px);
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.1),
        0 4px 12px rgba(102, 126, 234, 0.3);
}

.move-toggle-section {
    margin-top: 0.5rem;
}

.toggle-move-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.toggle-move-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.toggle-move-btn:disabled {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.6;
}

.toggle-move-btn.showing-best {
    background: linear-gradient(135deg, #68d391 0%, #38a169 100%);
}

/* Best Move Highlight Display */
.best-move-highlight {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: 2px solid #60a5fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    animation: slideIn 0.3s ease-out;
}

.best-move-highlight.hidden {
    display: none;
}

.best-move-notation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.best-move-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
}

.best-move-text {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.best-move-description {
    font-size: 0.85rem;
    color: #cbd5e0;
    font-style: italic;
    line-height: 1.4;
}

.explanation-text {
    background: #1a202c;
    padding: 1rem;
    border-radius: 8px;
    color: #e2e8f0;
    line-height: 1.6;
    border-left: 4px solid #667eea;
}

.classification-badge {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    border-radius: 25px;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.classification-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.classification-badge:hover::before {
    left: 100%;
}

/* Enhanced Move Quality Classifications */
.classification-brilliant {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 50%, #5b21b6 100%);
    color: white;
    border: 2px solid #c084fc;
    box-shadow: 
        0 6px 20px rgba(168, 85, 247, 0.4),
        0 0 30px rgba(147, 51, 234, 0.3),
        inset 0 1px 3px rgba(255, 255, 255, 0.2);
    animation: brilliantGlow 2s ease-in-out infinite alternate;
}

@keyframes brilliantGlow {
    0% { box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4), 0 0 30px rgba(147, 51, 234, 0.3), inset 0 1px 3px rgba(255, 255, 255, 0.2); }
    100% { box-shadow: 0 8px 25px rgba(168, 85, 247, 0.6), 0 0 40px rgba(147, 51, 234, 0.5), inset 0 1px 3px rgba(255, 255, 255, 0.3); }
}

.classification-excellent {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    color: white;
    border: 2px solid #34d399;
    box-shadow: 
        0 6px 18px rgba(16, 185, 129, 0.4),
        0 0 25px rgba(5, 150, 105, 0.3),
        inset 0 1px 3px rgba(255, 255, 255, 0.2);
}

.classification-good {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%);
    color: white;
    border: 2px solid #38bdf8;
    box-shadow: 
        0 6px 18px rgba(14, 165, 233, 0.4),
        0 0 25px rgba(8, 145, 178, 0.3),
        inset 0 1px 3px rgba(255, 255, 255, 0.2);
}

.classification-inaccuracy {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #92400e 100%);
    color: white;
    border: 2px solid #fbbf24;
    box-shadow: 
        0 6px 18px rgba(245, 158, 11, 0.4),
        0 0 25px rgba(202, 138, 4, 0.3),
        inset 0 1px 3px rgba(255, 255, 255, 0.2);
}

.classification-mistake {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
    color: white;
    border: 2px solid #f87171;
    box-shadow: 
        0 6px 18px rgba(239, 68, 68, 0.4),
        0 0 25px rgba(220, 38, 38, 0.3),
        inset 0 1px 3px rgba(255, 255, 255, 0.2);
}

.classification-blunder {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 50%, #7f1d1d 100%);
    color: white;
    border: 2px solid #ef4444;
    box-shadow: 
        0 8px 25px rgba(220, 38, 38, 0.5),
        0 0 35px rgba(153, 27, 27, 0.4),
        inset 0 1px 3px rgba(255, 255, 255, 0.2);
    animation: blunderPulse 1.5s ease-in-out infinite alternate;
}

@keyframes blunderPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.02); }
}

.classification-neutral {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 50%, #374151 100%);
    color: #e2e8f0;
    border: 2px solid #9ca3af;
    box-shadow: 
        0 4px 12px rgba(107, 114, 128, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.classification-alternative {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

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


/* Board Navigation Bar - Below Chess Board */
.board-navigation-bar {
    width: 100%;
    max-width: min(700px, 70vw); /* Match board size */
    margin-top: 1rem;
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    border: 2px solid #667eea;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.position-info-section {
    flex: 1;
    min-width: 150px;
}

.position-indicator {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: #e2e8f0;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid #4a5568;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1);
    display: inline-block;
}

.navigation-controls-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.control-btn {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border: 2px solid #667eea;
    color: #e2e8f0;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.control-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateY(-2px);
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #4a5568 0%, #374151 100%);
    border-color: #6b7280;
    transform: none;
}

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

/* Specific button styling */
.reset-btn, .flip-btn {
    padding: 0 1rem;
    min-width: 80px;
}

.nav-btn {
    width: 44px;
    font-size: 1.1rem;
}

.nav-divider {
    width: 2px;
    height: 30px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 1px;
    margin: 0 0.25rem;
    box-shadow: 0 0 4px rgba(102, 126, 234, 0.3);
}



.moves-list-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

/* AI Chat Interface */
.chat-interface {
    width: 25%;
    min-width: 320px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    background: #2d3748;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid #4a5568;
    height: 600px; /* Fixed reasonable height */
    flex-shrink: 0;
    overflow: hidden; /* Prevent interface from growing */
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #4a5568;
    background: #1a202c;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0; /* Never shrink the header */
}

.chat-header h3 {
    color: #e2e8f0;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden; /* Important: prevent container overflow */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    border: none;
    background: #1a202c;
    min-height: 0; /* Important: allows flex item to shrink below content size */
    margin: 1rem 1.5rem 0 1.5rem;
    border-radius: 8px;
    border: 1px solid #4a5568;
}

/* Markdown Styling in Chat Messages */
.message-content h1.chat-h1 {
    font-size: 1.1rem !important;
    font-weight: bold !important;
    color: #f7fafc !important;
    margin: 0.75rem 0 0.5rem 0 !important;
    border-bottom: 1px solid #667eea !important;
    padding-bottom: 0.25rem !important;
}

.message-content h2.chat-h2 {
    font-size: 1.05rem !important;
    font-weight: bold !important;
    color: #e2e8f0 !important;
    margin: 0.6rem 0 0.4rem 0 !important;
    border-bottom: 1px solid #4a5568 !important;
    padding-bottom: 0.2rem !important;
}

.message-content h3.chat-h3 {
    font-size: 0.95rem !important;
    font-weight: bold !important;
    color: #cbd5e0 !important;
    margin: 0.5rem 0 0.3rem 0 !important;
}

.message-content strong {
    font-weight: bold;
    color: #f7fafc;
}

.message-content em {
    font-style: italic;
    color: #e2e8f0;
}

.message-content ul.chat-ul {
    margin: 0.3rem 0 !important;
    padding-left: 0 !important;
}

.message-content ul.chat-ol {
    margin: 0.3rem 0 !important;
    padding-left: 0 !important;
    list-style: none !important;
}

.message-content li.chat-li {
    margin: 0.05rem 0 !important;
    padding-left: 0 !important;
    color: #cbd5e0 !important;
    line-height: 1.4 !important;
}

.message-content li.chat-li-numbered {
    margin: 0.05rem 0 !important;
    padding-left: 0 !important;
    color: #cbd5e0 !important;
    line-height: 1.4 !important;
    list-style: none !important;
}

.message-content .chat-number {
    font-weight: bold !important;
    color: #f7fafc !important;
    margin-right: 0.2rem !important;
    display: inline-block !important;
}

/* Clean spacing for chat messages */
.message-content {
    font-size: 0.95rem;
    line-height: 1.4 !important;
}

/* Universal reset - no margins anywhere */
.message-content * {
    margin: 0 !important;
    line-height: inherit !important;
}

/* Very minimal spacing only for major sections */
.message-content > * {
    margin-bottom: 0.2rem !important;
}

.message-content > *:last-child {
    margin-bottom: 0 !important;
}

/* Force consistent spacing for all list items */
.message-content li,
.message-content .chat-li,
.message-content .chat-li-numbered {
    margin: 0.05rem 0 !important;
    padding: 0 !important;
}

.message-content pre.chat-code {
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.message-content code.chat-inline-code {
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 3px;
    padding: 0.2rem 0.4rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    color: #81c784;
}

/* Paragraph spacing */
.message-content p {
    margin: 0.3rem 0 !important;
    line-height: 1.4 !important;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.chat-message {
    margin-bottom: 1rem;
    animation: slideInChat 0.3s ease-out;
}

.chat-message:last-child {
    margin-bottom: 0;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.2 !important;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: 1rem;
}

.ai-message .message-content {
    background: #2d3748;
    color: #e2e8f0;
    border: 1px solid #4a5568;
    margin-right: 1rem;
}

.ai-message .message-content ul {
    margin: 0.3rem 0 !important;
    padding-left: 0 !important;
}

.ai-message .message-content li {
    margin: 0.05rem 0 !important;
    padding-left: 0 !important;
    color: #cbd5e0 !important;
    line-height: 1.4 !important;
}

.chat-status {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: #a0aec0;
    border-radius: 6px;
    background: #1a202c;
    border: 1px solid #4a5568;
}

.chat-status.error {
    background: #742a2a;
    color: #feb2b2;
    border-color: #c53030;
}

.chat-status.success {
    background: #065f46;
    color: #10b981;
    border-color: #10b981;
}

.chat-input-container {
    flex-shrink: 0; /* Never shrink the input area */
    padding: 1rem 1.5rem 1.5rem 1.5rem; /* Consistent padding */
    background: #2d3748; /* Match interface background */
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.chat-input {
    flex: 1;
    padding: 1rem;
    border: 2px solid #4a5568;
    border-radius: 8px;
    background: #1a202c;
    color: #e2e8f0;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
    resize: none;
    min-height: 45px;
}

.chat-input:focus:not(:disabled) {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-send-btn:disabled {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.chat-send-btn.loading {
    background: #4a5568;
    cursor: wait;
}

.chat-send-btn.loading span {
    opacity: 0.7;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #2d3748;
    border-radius: 12px;
    margin-right: 1rem;
    border: 1px solid #4a5568;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes slideInChat {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.move-row {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.move-row:hover {
    background: rgba(74, 85, 104, 0.7);
    transform: translateX(2px);
}

.move-row.current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid #60a5fa;
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.4),
        0 0 20px rgba(102, 126, 234, 0.2);
    transform: translateX(4px);
    animation: currentMoveGlow 2s ease-in-out infinite alternate;
}

@keyframes currentMoveGlow {
    0% { box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 0 20px rgba(102, 126, 234, 0.2); }
    100% { box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6), 0 0 30px rgba(102, 126, 234, 0.3); }
}

.move-row.current::before {
    content: '▶';
    position: absolute;
    left: -8px;
    color: #60a5fa;
    font-size: 0.8rem;
    animation: currentMoveArrow 1s ease-in-out infinite alternate;
}

@keyframes currentMoveArrow {
    0% { transform: translateX(0); }
    100% { transform: translateX(2px); }
}

.move-number {
    font-weight: bold;
    min-width: 30px;
    color: #a0aec0;
}

.move-notation {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.move-evaluation {
    font-size: 0.8rem;
    color: #a0aec0;
    min-width: 50px;
    text-align: right;
}

.white-move, .black-move {
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    margin: 0 0.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    font-weight: 700;
}

.white-move:hover, .black-move:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
    border: 1px solid #60a5fa;
}

.white-move.current, .black-move.current {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 800;
    border: 2px solid #34d399;
    box-shadow: 
        0 2px 8px rgba(16, 185, 129, 0.4),
        0 0 15px rgba(5, 150, 105, 0.3);
    transform: scale(1.1);
    animation: currentMoveSpanGlow 1.5s ease-in-out infinite alternate;
}

@keyframes currentMoveSpanGlow {
    0% { box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4), 0 0 15px rgba(5, 150, 105, 0.3); }
    100% { box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6), 0 0 25px rgba(5, 150, 105, 0.4); }
}

/* Sticky Board Container */
.board-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 1.5rem 2rem 1.5rem;
    background: #2d3748;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid #4a5568;
    /* position: sticky;
    top: 20px;
    height: fit-content;
    z-index: 10; */
    min-width: 0; /* Allow shrinking */
    max-width: 100%;
}

.board-header, .board-footer {
    width: 100%;
    max-width: min(700px, 70vw); /* Match bigger board size */
    margin: 0.75rem 0; /* Slightly less margin */
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #1a202c;
    border-radius: 8px;
    border: 1px solid #4a5568;
}

.player-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: #e2e8f0;
}

.player-elo {
    color: #a0aec0;
    font-family: 'Courier New', monospace;
}

.black-player {
    border-left: 4px solid #2d3748;
}

.white-player {
    border-left: 4px solid #e2e8f0;
}

/* Board Controls */
.board-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
}

.reset-board-btn {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reset-board-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.3);
}

.reset-board-btn:disabled {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.flip-board-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flip-board-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.interactive-status {
    padding: 0.5rem 1rem;
    background: #1a202c;
    border-radius: 6px;
    border: 1px solid #4a5568;
    color: #a0aec0;
    font-size: 0.85rem;
    text-align: center;
}

.interactive-status.modified {
    background: #2d5016;
    color: #9ae6b4;
    border-color: #38a169;
}

/* Chess Board */
.board-wrapper {
    position: relative;
}

.chess-board {
    width: 95%;
    max-width: min(700px, 70vw); /* Bigger board */
    min-width: min(500px, 75vw); /* Larger minimum */
    margin: 0 auto;
    border: 3px solid #4a5568;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Let chessboard.js handle animations naturally */

/* Game Moves Panel - Below Position Analysis */
.moves-panel {
    margin-top: 1.5rem;
}

.moves-panel h3 {
    color: #e2e8f0;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.moves-panel .moves-list {
    max-height: 300px;
    overflow-y: auto;
    background: rgba(16, 22, 32, 0.7);
    border-radius: 8px;
    border: 1px solid #4a5568;
    padding: 0.5rem;
}

.moves-panel .no-moves-msg {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 2rem 1rem;
}

/* Chessboard.js customizations */
.highlight-square {
    background-color: rgba(255, 255, 0, 0.4) !important;
}

/* Best move highlighting */
.highlight-from {
    background-color: rgba(251, 191, 36, 0.8) !important;
    box-shadow: inset 0 0 0 4px #f59e0b, 0 0 15px rgba(251, 191, 36, 0.6) !important;
    animation: pulseGlow 2s infinite;
}

.highlight-to {
    background-color: rgba(34, 197, 94, 0.8) !important;
    box-shadow: inset 0 0 0 4px #22c55e, 0 0 15px rgba(34, 197, 94, 0.6) !important;
}

.highlight-capture {
    background-color: rgba(239, 68, 68, 0.8) !important;
    box-shadow: inset 0 0 0 4px #ef4444, 0 0 15px rgba(239, 68, 68, 0.6) !important;
}

@keyframes pulseGlow {
    0%, 100% { 
        box-shadow: inset 0 0 0 4px #f59e0b, 0 0 15px rgba(251, 191, 36, 0.6);
    }
    50% { 
        box-shadow: inset 0 0 0 4px #f59e0b, 0 0 25px rgba(251, 191, 36, 1);
    }
}

/* Move arrow */
.move-arrow {
    position: absolute;
    pointer-events: none;
    z-index: 15;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.4));
}

.move-arrow svg {
    width: 100%;
    height: 100%;
}

.move-arrow line {
    stroke: #22c55e;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 0;
    marker-end: url(#arrowhead);
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.6));
}

.move-arrow polygon {
    fill: #22c55e;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.6));
}

.highlight-move {
    background-color: rgba(102, 126, 234, 0.6) !important;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2d3748;
    border-radius: 12px;
    min-width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 1px solid #4a5568;
}

.modal-header {
    background: #1a202c;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4a5568;
}

.modal-header h3 {
    color: #e2e8f0;
    font-size: 1.2rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #4a5568;
    color: #e2e8f0;
}

.modal-body {
    padding: 2rem;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #1a202c;
    margin-bottom: 1rem;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #2d3748;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-area h3 {
    color: #667eea;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.upload-area p {
    color: #a0aec0;
}

.upload-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #a0aec0;
}

/* Player Selection */
.player-selection {
    background: #2a2a3a;
    border: 1px solid #4a5568;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.player-selection h4 {
    margin: 0 0 0.75rem 0;
    color: #e2e8f0;
    font-size: 1rem;
}

.player-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.player-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #cbd5e0;
    transition: color 0.2s ease;
}

.player-option:hover {
    color: #e2e8f0;
}

.player-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 16px;
    height: 16px;
    border: 2px solid #4a5568;
    border-radius: 50%;
    position: relative;
    transition: all 0.2s ease;
}

.player-option input[type="radio"]:checked + .radio-custom {
    border-color: #667eea;
    background: #667eea;
}

.player-option input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.player-help {
    font-size: 0.85rem;
    color: #a0aec0;
    margin: 0;
    font-style: italic;
}

/* Settings Modal */
.settings-section {
    background: #2a2a3a;
    border: 1px solid #4a5568;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.settings-section h4 {
    margin: 0 0 1rem 0;
    color: #e2e8f0;
    font-size: 1.1rem;
}

.settings-description {
    color: #cbd5e0;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.settings-description a {
    color: #667eea;
    text-decoration: none;
}

.settings-description a:hover {
    text-decoration: underline;
}

.api-key-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.api-key-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #4a5568;
    border-radius: 6px;
    background: #1a202c;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.api-key-input:focus {
    outline: none;
    border-color: #667eea;
}

.toggle-visibility-btn {
    padding: 0.75rem;
    border: 2px solid #4a5568;
    border-radius: 6px;
    background: #2d3748;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-visibility-btn:hover {
    background: #4a5568;
}

.api-key-status {
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    min-height: 1.5rem;
}

.api-key-status.success {
    background: #065f46;
    color: #10b981;
    border: 1px solid #10b981;
}

.api-key-status.error {
    background: #7f1d1d;
    color: #f87171;
    border: 1px solid #f87171;
}

.api-key-status.info {
    background: #1e3a8a;
    color: #60a5fa;
    border: 1px solid #60a5fa;
}

.settings-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.save-btn, .clear-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-btn {
    background: #059669;
    color: white;
}

.save-btn:hover {
    background: #047857;
}

.save-btn:disabled {
    background: #4a5568;
    cursor: not-allowed;
}

.clear-btn {
    background: #dc2626;
    color: white;
}

.clear-btn:hover {
    background: #b91c1c;
}

.settings-note {
    font-size: 0.85rem;
    color: #a0aec0;
    margin: 0;
    font-style: italic;
}

.settings-security-note {
    font-size: 0.9rem;
    color: #10b981;
    background: #065f46;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #10b981;
    margin-bottom: 1rem;
}

/* Paste Modal */
#pgnTextInput {
    width: 100%;
    height: 200px;
    padding: 1rem;
    border: 2px solid #4a5568;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    background: #1a202c;
    color: #e2e8f0;
    margin-bottom: 1rem;
}

#pgnTextInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.validate-btn, .parse-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.validate-btn {
    background: #38a169;
    color: white;
}

.validate-btn:hover {
    background: #2f855a;
    transform: translateY(-2px);
}

.parse-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
    color: #e2e8f0;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #4a5568;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Message Container */
.message-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
}

.message-success {
    background: #38a169;
    color: white;
    border: 1px solid #2f855a;
}

.message-error {
    background: #e53e3e;
    color: white;
    border: 1px solid #c53030;
}

.message-info {
    background: #3b82f6;
    color: white;
    border: 1px solid #2563eb;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Mobile-First Responsive Design */

/* Enhanced Responsive Design for New Layout */

/* Tablet styles (768px to 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    .clean-top-navigation {
        padding: 0.75rem 1rem;
        min-height: 70px;
    }
    
    .top-moves-section {
        min-width: 250px;
        max-width: 50%;
    }
    
    .clean-moves-list-container {
        max-height: 120px;
    }
    
    .board-container {
        padding: 0.75rem 1rem 1.5rem 1rem;
        position: static; /* Remove sticky on tablets */
    }
    
    .board-navigation-bar {
        padding: 0.75rem 1rem;
        max-width: 100%;
    }
    
    .position-indicator {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    .control-btn {
        height: 40px;
        font-size: 0.9rem;
    }
    
    .nav-btn {
        width: 40px;
    }
    
    
    .analysis-sidebar {
        min-width: 250px;
        max-width: 300px;
        position: static; /* Remove sticky on tablets */
        height: auto;
    }
}

/* Mobile Base Styles (< 768px) */
@media (max-width: 767px) {
    .app-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
        text-align: center;
    }
    
    .upload-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .header-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-width: 120px;
    }
    
    .main-content {
        flex-direction: column;
        padding: 0.75rem;
        gap: 1rem;
    }

    /* New layout mobile styles */
    .clean-top-navigation {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 1rem;
        min-height: auto;
    }

    .top-moves-section {
        max-width: 100%;
        min-width: auto;
    }

    .clean-moves-list-container {
        max-height: 100px;
        padding: 0.5rem;
    }

    .top-game-info-panel {
        max-width: 100%;
        min-width: auto;
    }
    
    /* Stack layout vertically on mobile */
    .analysis-sidebar {
        width: 100%;
        flex-direction: column;
        order: 2; /* Move sidebar below board on mobile */
        overflow-y: visible;
        padding-right: 0;
    }
    
    .board-container {
        order: 1; /* Board first on mobile */
        padding: 0.75rem 0;
        min-height: auto;
        position: static; /* Remove sticky on mobile */
    }

    .board-navigation-bar {
        flex-direction: column;
        gap: 1rem;
        padding: 0.75rem;
        margin-top: 0.75rem;
        max-width: 100%;
    }

    .position-info-section {
        min-width: auto;
        text-align: center;
    }

    .position-indicator {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .navigation-controls-section {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .control-btn {
        height: 44px;
        font-size: 0.9rem;
        min-height: 44px; /* Touch-friendly */
    }

    .reset-btn, .flip-btn {
        min-width: 80px;
        padding: 0 0.75rem;
    }

    .nav-btn {
        width: 44px;
    }

    
    .chat-interface {
        order: 3; /* Chat last on mobile */
        width: 100%;
        height: 400px; /* Shorter on mobile */
        margin-top: 1rem;
    }
    
    /* Make chess board responsive */
    .chess-board {
        width: 100% !important;
        max-width: 350px !important;
        min-width: 280px !important;
        margin: 0 auto !important;
    }
    
    .board-header, .board-footer {
        max-width: 350px;
        margin: 0.5rem auto;
    }
    
    .board-navigation {
        max-width: 350px;
        margin: 0.75rem auto 0 auto;
        padding: 0.75rem;
    }
    
    .player-info {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .board-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .reset-board-btn, .flip-board-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-width: 100px;
    }
    
    /* Panel adjustments */
    .panel {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .panel h3 {
        font-size: 1rem;
    }
    
    /* Navigation controls */
    .nav-controls {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .nav-btn {
        padding: 0.5rem;
        font-size: 0.9rem;
        min-width: 60px;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 1rem !important;
        min-width: auto !important;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* Tablet Styles (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .main-content {
        flex-direction: column;
        gap: 1.25rem;
        padding: 1rem;
    }
    
    /* Horizontal layout for sidebar on tablet */
    .analysis-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        order: 2;
    }
    
    .panel {
        min-width: 280px;
        flex-shrink: 0;
        margin-right: 1rem;
    }
    
    .board-container {
        order: 1;
        padding: 1.25rem;
    }
    
    .chat-interface {
        order: 3;
        width: 100%;
        height: 500px;
        margin-top: 1rem;
    }
    
    .chess-board {
        max-width: min(600px, 75vw) !important;
        min-width: min(400px, 65vw) !important;
    }
    
    .board-header, .board-footer {
        max-width: min(600px, 75vw);
    }
    
    .board-navigation {
        max-width: min(600px, 75vw);
    }
}

/* Large Desktop Styles (> 1024px) */
@media (min-width: 1025px) {
    .main-content {
        flex-direction: row;
        gap: 1.5rem;
        padding: 1rem;
    }
    
    .analysis-sidebar {
        width: 20%;
        min-width: 280px;
        max-width: 400px;
        flex-direction: column;
        order: 1;
        overflow-y: auto;
        padding-right: 0.5rem;
    }
    
    .board-container {
        flex: 1 1 auto;
        order: 2;
        padding: 1.5rem;
    }
    
    .chat-interface {
        width: 25%;
        min-width: 320px;
        max-width: 500px;
        order: 3;
        height: 600px;
    }
    
    .chess-board {
        max-width: min(700px, 70vw) !important;
        min-width: min(500px, 60vw) !important;
    }
    
    .board-header, .board-footer {
        max-width: min(700px, 70vw);
    }
    
    .board-navigation {
        max-width: min(700px, 70vw);
    }
}

/* Extra small devices (< 480px) */
@media (max-width: 479px) {
    .app-header h1 {
        font-size: 1.3rem;
    }
    
    .header-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 100px;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .chess-board {
        max-width: 300px !important;
        min-width: 250px !important;
    }
    
    .board-header, .board-footer {
        max-width: 300px;
    }
    
    .board-navigation {
        max-width: 300px;
        margin: 0.5rem auto 0 auto;
        padding: 0.5rem;
    }
    
    .player-info {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .panel {
        padding: 0.75rem;
    }
    
    .chat-interface {
        height: 350px;
    }
    
    .modal-content {
        width: 98% !important;
        margin: 0.5rem !important;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a202c;
}

::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #667eea;
}