  :root {
    /* ===== THEME VARIABLES SYSTEM ===== */
    /* Board Layout */
    --board-gap: 1px;
    --board-padding: 4px;
    --board-radius: 8px;
    --board-border: none;
    --board-border-color: transparent;
    --board-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.15);
    
    /* Tile Sizing */
    --tile-size: 24px;
    --tile-radius: 3px;
    --tile-border-width: 0;
    --tile-border-style: none;
    
    /* Tile Shadows */
    --tile-shadow-unrevealed: inset 2px 2px 4px rgba(255, 255, 255, 0.8),
                              inset -2px -2px 4px rgba(0, 0, 0, 0.1);
    --tile-shadow-revealed: inset -1px -1px 2px rgba(0, 0, 0, 0.1),
                           inset 1px 1px 2px rgba(0, 0, 0, 0.05);
    --tile-shadow-active: inset -1px -1px 2px rgba(255, 255, 255, 0.8),
                         inset 1px 1px 2px rgba(0, 0, 0, 0.2);
    
    /* Animations */
    --tile-transition: all 0.1s ease;
    --tile-hover-transform: none;
    --tile-hover-bg-shift: #edf2f7;
    
    /* Status Display */
    --status-border: 2px solid #e2e8f0;
    --status-border-radius: 8px;
    --status-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --status-bg: #f8fafc;
}
        /* ===== CSS RESET & BASE STYLES ===== */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
/* ===== DEFAULT THEME VARIABLES (MODERN) ===== */
:root {
    /* Board Layout */
    --board-gap: 1px;
    --board-padding: 4px;
    --board-radius: 8px;
    --board-border: none;
    --board-border-color: transparent;
    --board-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.15);
    
    /* Board Colors */
    --board-bg: #a0aec0;
    
    /* Tile Layout */
    --tile-size: 24px;
    --tile-radius: 3px;
    --tile-border-width: 0;
    --tile-border-style: none;
    --tile-border-color: transparent;
    
    /* Tile Colors */
    --tile-unrevealed: #e2e8f0;
    --tile-revealed: #ffffff;
    --tile-hover: #edf2f7;
    --tile-flag: #fed7d7;
    --tile-flag-color: #e53e3e;
    --tile-bomb: #feb2b2;
    --tile-bomb-exploded: #e53e3e;
    --tile-bomb-color: #742a2a;
    
    /* Tile Shadows */
    --tile-shadow-unrevealed: inset 2px 2px 4px rgba(255, 255, 255, 0.8),
                              inset -2px -2px 4px rgba(0, 0, 0, 0.1);
    --tile-shadow-revealed: inset -1px -1px 2px rgba(0, 0, 0, 0.1),
                           inset 1px 1px 2px rgba(0, 0, 0, 0.05);
    --tile-shadow-active: inset -1px -1px 2px rgba(255, 255, 255, 0.8),
                         inset 1px 1px 2px rgba(0, 0, 0, 0.2);
    --tile-shadow-flag: inset 2px 2px 4px rgba(255, 255, 255, 0.6),
                       inset -2px -2px 4px rgba(231, 76, 60, 0.2);
    
    /* Animations */
    --tile-transition: all 0.1s ease;
    --tile-hover-transform: none;
    
    /* Number Colors */
    --num-1: #3182ce;
    --num-2: #38a169;
    --num-3: #e53e3e;
    --num-4: #805ad5;
    --num-5: #d69e2e;
    --num-6: #e53e3e;
    --num-7: #2d3748;
    --num-8: #4a5568;
}
        html, body {
            height: 100%;
            overflow-x: hidden;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
            line-height: 1.6;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
            -webkit-touch-callout: none;
        }

        /* ===== MAIN CONTAINER ===== */
        .container {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            padding: 8px;
            max-width: 100vw;
        }

        /* ===== DESKTOP LAYOUT (NEW) ===== */
        @media (min-width: 1024px) {
            .container {
                flex-direction: row;
                gap: 8px;
                align-items: flex-start;
            }
            
            .sidebar {
                width: 300px;
                flex-shrink: 0;
                display: flex;
                flex-direction: column;
                gap: 12px;
                transition: all 0.3s ease;
            }
            
          
            
            .main-content {
                flex: 1;
                display: flex;
                flex-direction: column;
                gap: 8px;
                min-height: calc(100vh - 16px);
            }
            .game-board-container {
        padding: 10px;
        gap: 6px;
    }
    
    .game-board-container .game-status {
        padding: 6px;
    }
    
    .game-board-container .status-grid {
        gap: 6px;
    }
        }

        /* ===== HEADER ===== */
        .header {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 12px 16px;
            margin-bottom: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        @media (min-width: 1024px) {
            .header {
                margin-bottom: 0;
                padding: 10px 14px;
            }
            
           
        }

        .header h1 {
            text-align: center;
            color: #2d3748;
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 8px;
            background: linear-gradient(135deg, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        @media (min-width: 1024px) {
            .header h1 {
                font-size: 1.3rem;
                margin-bottom: 6px;
            }
            
          
        }

        .connection-status {
            text-align: center;
            padding: 6px 12px;
            border-radius: 16px;
            font-size: 0.8rem;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        @media (min-width: 1024px) {
            .connection-status {
                padding: 4px 8px;
                font-size: 0.75rem;
            }
            
         
        }

        .connection-status.connected {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .connection-status.connecting {
            background: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
        }

        .connection-status.disconnected {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        /* ===== GAME CONTROLS ===== */
        .game-controls {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 12px;
            margin-bottom: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        @media (min-width: 1024px) {
            .game-controls {
                margin-bottom: 0;
                padding: 10px;
            }
            
          
        }

        .difficulty-section, .custom-section {
            margin-bottom: 12px;
        }

        @media (min-width: 1024px) {
            .difficulty-section, .custom-section {
                margin-bottom: 10px;
            }
            
        
        }

        .difficulty-section h3, .custom-section h3 {
            color: #2d3748;
            margin-bottom: 8px;
            font-size: 0.95rem;
            font-weight: 600;
        }

        @media (min-width: 1024px) {
            .difficulty-section h3, .custom-section h3 {
                font-size: 0.85rem;
                margin-bottom: 6px;
            }
            
         
        }

        .difficulty-buttons {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 8px;
            margin-bottom: 10px;
        }

        @media (min-width: 1024px) {
            .difficulty-buttons {
                grid-template-columns: 1fr 1fr;
                gap: 6px;
                margin-bottom: 8px;
            }
          
        }

        .difficulty-btn {
            padding: 8px 12px;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            background: #f8fafc;
            color: #4a5568;
            cursor: pointer;
            transition: all 0.2s ease;
            font-weight: 500;
            text-align: center;
            position: relative;
            overflow: hidden;
            font-size: 0.85rem;
        }

        @media (min-width: 1024px) {
            .difficulty-btn {
                padding: 6px 8px;
                font-size: 0.75rem;
            }
            
          
        }

        .difficulty-btn:hover {
            border-color: #667eea;
            background: #edf2f7;
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
        }

        .difficulty-btn.active {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            border-color: #667eea;
            box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
        }

        .difficulty-btn .desc {
            font-size: 0.7rem;
            opacity: 0.8;
            margin-top: 2px;
        }

        @media (min-width: 1024px) {
            .difficulty-btn .desc {
                font-size: 0.65rem;
                margin-top: 1px;
            }
            
          
        }

        .custom-inputs {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            margin-bottom: 10px;
        }

        @media (min-width: 1024px) {
            .custom-inputs {
                gap: 6px;
                margin-bottom: 8px;
            }
            
         
        }

        .input-group {
            display: flex;
            flex-direction: column;
        }

        .input-group label {
            font-size: 0.8rem;
            color: #4a5568;
            margin-bottom: 3px;
            font-weight: 500;
        }

        @media (min-width: 1024px) {
            .input-group label {
                font-size: 0.7rem;
                margin-bottom: 2px;
            }
            
         
        }

        .input-group input {
            padding: 6px 8px;
            border: 2px solid #e2e8f0;
            border-radius: 6px;
            font-size: 0.9rem;
            transition: border-color 0.2s ease;
            background: #f8fafc;
            width: 100%;
            min-width: 0;
        }

        @media (min-width: 1024px) {
            .input-group input {
                padding: 4px 6px;
                font-size: 0.8rem;
            }
            
        
        }

        .input-group input:focus {
            outline: none;
            border-color: #667eea;
            background: white;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
        }

        .action-buttons {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        @media (min-width: 1024px) {
            .action-buttons {
                gap: 6px;
            }
        }

        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            overflow: hidden;
            flex: 1;
            min-width: 100px;
        }

        @media (min-width: 1024px) {
            .btn {
                padding: 6px 12px;
                font-size: 0.8rem;
                min-width: 80px;
            }
            
       
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 3px 16px rgba(102, 126, 234, 0.4);
        }

        .btn-secondary {
            background: #e2e8f0;
            color: #4a5568;
            border: 2px solid #cbd5e0;
        }

        .btn-secondary:hover {
            background: #edf2f7;
            border-color: #a0aec0;
            transform: translateY(-1px);
        }

        .btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none !important;
        }

        /* ===== PLAYER STATS (NEW) ===== */
        .player-stats {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 12px;
            margin-bottom: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        @media (min-width: 1024px) {
            .player-stats {
                margin-bottom: 0;
                padding: 10px;
            }
            
         
        }

        .player-stats h3 {
            color: #2d3748;
            margin-bottom: 8px;
            font-size: 0.95rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        @media (min-width: 1024px) {
            .player-stats h3 {
                font-size: 0.85rem;
                margin-bottom: 6px;
            }
            
        
        }

        .stats-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }
@media (max-width: 768px) {
    .stat-item.best-efficiency {
        grid-column: span 2;
    }
}
        @media (min-width: 1024px) {
            .stats-grid {
                gap: 6px;
            }
         
        }

        .stat-item {
            background: #f8fafc;
            padding: 8px 6px;
            border-radius: 8px;
            border: 2px solid #e2e8f0;
            text-align: center;
        }

        @media (min-width: 1024px) {
            .stat-item {
                padding: 6px 4px;
            }
            
        
        }

        .stat-item .label {
            font-size: 0.7rem;
            color: #718096;
            margin-bottom: 2px;
            font-weight: 500;
        }

        @media (min-width: 1024px) {
            .stat-item .label {
                font-size: 0.65rem;
            }
            
         
        }

        .stat-item .value {
            font-size: 1rem;
            font-weight: 700;
            color: #2d3748;
            line-height: 1.2;
        }

        @media (min-width: 1024px) {
            .stat-item .value {
                font-size: 0.9rem;
            }
            
          
        }

        .stat-item.win-rate .value {
            color: #38a169;
        }

        .stat-item.best-time .value {
            color: #667eea;
            font-size: 0.85rem;
        }

        @media (min-width: 1024px) {
            .stat-item.best-time .value {
                font-size: 0.75rem;
            }
            
         
        }

        /* Best time difficulty indicator */
        .best-time-difficulty {
            font-size: 0.7rem;
            color: #667eea;
            margin-top: 2px;
            margin-bottom: 4px;
            font-weight: 600;
            line-height: 1;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            background: linear-gradient(90deg, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }

        @media (min-width: 1024px) {
            .best-time-difficulty {
                font-size: 0.65rem;
            }
            
        
        }

        /* Best times list - always visible */
        .best-times-list {
            margin-top: 4px;
            font-size: 0.7rem;
            max-height: 120px;
            overflow-y: auto;
        }

        .best-times-list:empty {
            display: none;
        }

        .best-time-entry {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 2px 4px;
            border-radius: 3px;
            margin-bottom: 1px;
            font-size: 0.65rem;
        }

        .best-time-entry:last-child {
            margin-bottom: 0;
        }

        .best-time-entry:nth-child(1) {
            background: linear-gradient(90deg, #dbeafe, #bfdbfe);
            color: #1e40af;
            font-weight: 600;
            border: 1px solid #93c5fd;
        }

        .best-time-entry:nth-child(2) {
            background: linear-gradient(90deg, #dcfce7, #bbf7d0);
            color: #166534;
            font-weight: 500;
        }

        .best-time-entry:nth-child(3) {
            background: linear-gradient(90deg, #fef3c7, #fde68a);
            color: #92400e;
            font-weight: 500;
        }

        .best-time-entry:nth-child(4),
        .best-time-entry:nth-child(5) {
            background: #f8fafc;
            color: #475569;
        }

        .best-time-rank {
            font-weight: 600;
            min-width: 18px;
            font-size: 0.6rem;
        }

        .best-time-value {
            font-family: 'Courier New', monospace;
            font-size: 0.6rem;
            letter-spacing: 0.5px;
        }
        /* Best efficiency display in stats */
.stat-item.best-efficiency .value {
    color: #9f7aea;
    font-size: 0.95rem;
}

.best-efficiency-difficulty {
    font-size: 0.7rem;
    color: #9f7aea;
    margin-top: 2px;
    margin-bottom: 4px;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.best-efficiency-list {
    margin-top: 4px;
    font-size: 0.7rem;
    max-height: 120px;
    overflow-y: auto;
}

.best-efficiency-list:empty {
    display: none;
}

.best-efficiency-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 1px;
    font-size: 0.65rem;
    gap: 8px;
}

.best-efficiency-entry:last-child {
    margin-bottom: 0;
}

/* Top 5 styling similar to best times */
.best-efficiency-entry:nth-child(1) {
    background: linear-gradient(90deg, #e9d8fd, #d6bcfa);
    color: #553c9a;
    font-weight: 600;
    border: 1px solid #b794f4;
}

.best-efficiency-entry:nth-child(2) {
    background: linear-gradient(90deg, #dcfce7, #bbf7d0);
    color: #166534;
    font-weight: 500;
}

.best-efficiency-entry:nth-child(3) {
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #92400e;
    font-weight: 500;
}

.best-efficiency-entry:nth-child(4),
.best-efficiency-entry:nth-child(5) {
    background: #f8fafc;
    color: #475569;
}

.best-efficiency-rank {
    font-weight: 600;
    min-width: 18px;
    font-size: 0.6rem;
}

.best-efficiency-value {
    font-weight: 700;
    color: #9f7aea;
    min-width: 45px;
    text-align: right;
}

.best-efficiency-bv {
    font-family: 'Courier New', monospace;
    font-size: 0.6rem;
    color: #64748b;
    min-width: 50px;
    text-align: center;
}

.best-efficiency-time {
    font-size: 0.6rem;
    color: #94a3b8;
    min-width: 35px;
    text-align: right;
}

@media (min-width: 1024px) {
    .stat-item.best-efficiency .value {
        font-size: 0.9rem;
    }
    
    .best-efficiency-list {
        font-size: 0.65rem;
        max-height: 100px;
    }
}

        @media (min-width: 1024px) {
            .best-times-list {
                font-size: 0.65rem;
                max-height: 100px;
            }
            
       
        }

        .stats-actions {
            margin-top: 8px;
            display: flex;
            gap: 6px;
        }

        @media (min-width: 1024px) {
            .stats-actions {
                margin-top: 6px;
                gap: 4px;
            }
            
        
        }

        .btn-small {
            padding: 4px 8px;
            font-size: 0.7rem;
            border-radius: 6px;
            flex: 1;
        }

        @media (min-width: 1024px) {
            .btn-small {
                padding: 3px 6px;
                font-size: 0.65rem;
            }
            
         
        }

        /* ===== GAME STATUS ===== */
       

        .status-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 6px;
            text-align: center;
            margin-bottom: 6px;
        }

        @media (min-width: 1024px) {
            .status-grid {
                gap: 4px;
                margin-bottom: 4px;
            }
        }

        .status-item {
            background: #f8fafc;
            padding: 6px 4px;
            border-radius: 8px;
            border: 2px solid #e2e8f0;
        }

        @media (min-width: 1024px) {
            .status-item {
                padding: 5px 3px;
            }
        }

        .status-item .label {
            font-size: 0.7rem;
            color: #718096;
            margin-bottom: 2px;
            font-weight: 500;
        }

        @media (min-width: 1024px) {
            .status-item .label {
                font-size: 0.65rem;
            }
        }

        .status-item .value {
            font-size: 1rem;
            font-weight: 700;
            color: #2d3748;
            line-height: 1.2;
        }

        @media (min-width: 1024px) {
            .status-item .value {
                font-size: 0.9rem;
            }
        }

        .status-item.time .value {
            color: #667eea;
            font-size: 0.9rem;
        }

        @media (min-width: 1024px) {
            .status-item.time .value {
                font-size: 0.8rem;
            }
        }

        .status-item.bombs .value {
            color: #e53e3e;
        }

        .status-item.flags .value {
            color: #38a169;
        }

        .game-state {
            text-align: center;
            padding: 8px 12px;
            border-radius: 8px;
            font-weight: 600;
            font-size: 0.85rem;
            transition: all 0.3s ease;
        }

        @media (min-width: 1024px) {
            .game-state {
                padding: 6px 8px;
                font-size: 0.75rem;
            }
        }

        .game-state.waiting {
            background: #e2e8f0;
            color: #4a5568;
        }

        .game-state.playing {
            background: #bee3f8;
            color: #2b6cb0;
        }

        .game-state.won {
            background: #c6f6d5;
            color: #22543d;
            animation: pulse 1s infinite;
        }

        .game-state.lost {
            background: #fed7d7;
            color: #742a2a;
        }

        @keyframes pulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.02); }
        }

        /* ===== GAME BOARD ===== */
      .game-board-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex: 1;
    position: relative;
    /* THÊM MỚI */
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* Game status inside board container */
.game-board-container .game-status {
    margin-bottom: 0;
    padding: 8px;
    background: rgba(248, 250, 252, 0.8);
    border-radius: 8px;
    /* Không cần box-shadow vì đã có từ container */
}

/* Time and Flags compact display */
.time-flags-compact {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

.time-item, .flags-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    min-width: 80px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.time-flags-compact .label {
    font-size: 0.7rem;
    color: #718096;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-flags-compact .value {
    font-size: 1.2rem;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    line-height: 1;
}

.time-item {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff, #e8f2ff);
}

.time-item .value {
    color: #667eea;
}

.flags-item {
    border-color: #e53e3e;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
}

.flags-item .value {
    color: #e53e3e;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .time-flags-compact {
        gap: 12px;
    }
    
    .time-item, .flags-item {
        padding: 6px 10px;
        min-width: 70px;
    }
    
    .time-flags-compact .label {
        font-size: 0.65rem;
    }
    
    .time-flags-compact .value {
        font-size: 1.1rem;
    }
}

.game-board-container .game-state {
    text-align: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.game-board-container .game-state.waiting {
    background: #e2e8f0;
    color: #4a5568;
}

.game-board-container .game-state.playing {
    background: #bee3f8;
    color: #2b6cb0;
}

.game-board-container .game-state.won {
    background: #c6f6d5;
    color: #22543d;
    animation: pulse 1s infinite;
}

.game-board-container .game-state.lost {
    background: #fed7d7;
    color: #742a2a;
}

        .board-wrapper {
            flex: 1;
            height: 100%;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* IE and Edge */
            touch-action: pan-x pan-y;
            cursor: default;
            scroll-behavior: smooth;
            will-change: scroll-position;
        }

        .board-wrapper::-webkit-scrollbar {
            display: none; /* Chrome, Safari, Opera */
        }

        .board-wrapper.dragging {
            cursor: grabbing;
            scroll-behavior: auto;
            touch-action: none;
        }

        .board-wrapper.dragging * {
            pointer-events: none;
            user-select: none;
        }

        .board-wrapper.dragging .tile {
            pointer-events: none;
        }

        .board-center {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100%;
            padding: 8px;
        }

        @media (max-width: 768px) {
            .board-center {
                justify-content: flex-start;
                align-items: flex-start;
            }
        }

        .game-board {
    display: inline-grid;
    gap: var(--board-gap);
    background: var(--board-bg);
    padding: var(--board-padding);
    border-radius: var(--board-radius);
    border: var(--board-border);
    border-color: var(--board-border-color);
    box-shadow: var(--board-shadow);
    touch-action: pan-x pan-y;
    margin-left: auto;
    margin-right: auto;
}

       .tile {
    width: var(--tile-size);
    height: var(--tile-size);
    border: var(--tile-border-style);
    border-width: var(--tile-border-width);
    border-radius: var(--tile-radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--tile-transition);
    position: relative;
    background: #e2e8f0;
    box-shadow: var(--tile-shadow-unrevealed);
}

        .tile:hover {
            background: #edf2f7;
            transform: var(--tile-hover-transform);
        }

      .tile.unrevealed {
    background: var(--tile-unrevealed);
    box-shadow: var(--tile-shadow-unrevealed);
}

       .tile.unrevealed:active {
    box-shadow: var(--tile-shadow-active);
}

        .tile.revealed {
    background: var(--tile-revealed);
    box-shadow: var(--tile-shadow-revealed);
    cursor: default;
}

        .tile.revealed:hover {
            background: #ffffff;
        }

       .tile.flagged {
    background: var(--tile-flag);
    color: var(--tile-flag-color);
    box-shadow: var(--tile-shadow-flag);
}

      .tile.bomb {
    background: var(--tile-bomb);
    color: var(--tile-bomb-color);
    box-shadow: var(--tile-shadow-revealed);
}

       .tile.bomb-exploded {
    background: var(--tile-bomb-exploded);
    color: white;
    animation: explode 0.3s ease-out;
    box-shadow: 
        0 0 10px rgba(229, 62, 62, 0.8),
        inset -1px -1px 2px rgba(0, 0, 0, 0.3);
}

        @keyframes explode {
            0% { transform: scale(1); }
            50% { transform: scale(1.15); }
            100% { transform: scale(1); }
        }

        /* Tile number colors */
       .tile[data-number="1"] { color: var(--num-1); }
.tile[data-number="2"] { color: var(--num-2); }
.tile[data-number="3"] { color: var(--num-3); }
.tile[data-number="4"] { color: var(--num-4); }
.tile[data-number="5"] { color: var(--num-5); }
.tile[data-number="6"] { color: var(--num-6); }
.tile[data-number="7"] { color: var(--num-7); }
.tile[data-number="8"] { color: var(--num-8); }

        /* ===== RESPONSIVE DESIGN ===== */
        @media (max-width: 768px) {
            .container {
                padding: 6px;
                flex-direction: column;
            }

            .header {
                padding: 10px;
                margin-bottom: 8px;
            }

            .header h1 {
                font-size: 1.3rem;
            }

            .game-controls, .game-status, .game-board-container, .player-stats {
                padding: 10px;
                margin-bottom: 8px;
            }

            .status-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 6px;
            }

            .status-item {
                padding: 6px 4px;
            }

            .status-item .value {
                font-size: 0.9rem;
            }

            .status-item.time .value {
                font-size: 0.8rem;
            }

            .tile {
                width: 40px;
                height: 40px;
                font-size: 18px;
            }

            .difficulty-buttons {
                grid-template-columns: 1fr 1fr;
            }

            .custom-inputs {
                grid-template-columns: 1fr 1fr 1fr;
            }

            .action-buttons {
                flex-direction: column;
            }

            .btn {
                min-width: auto;
            }

            .stats-grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 480px) {
            .container {
                padding: 4px;
            }

            .header h1 {
                font-size: 1.2rem;
            }

            .difficulty-buttons {
                grid-template-columns: 1fr;
            }

            .tile {
                width: 34px;
                height: 34px;
                font-size: 16px;
            }

            .status-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* ===== LOADING & ANIMATIONS ===== */
        .loading {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 30px;
            color: #718096;
            flex-direction: column;
            height: 100%;
        }

        .spinner {
            width: 30px;
            height: 30px;
            border: 3px solid #e2e8f0;
            border-top: 3px solid #667eea;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: 12px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .fade-in {
            animation: fadeIn 0.3s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(5px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* ===== VICTORY/DEFEAT OVERLAY ===== */
        .game-result-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            backdrop-filter: blur(5px);
        }

        .game-result-modal {
            background: white;
            border-radius: 16px;
            padding: 24px;
            text-align: center;
            max-width: 350px;
            width: 90%;
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
            animation: modalSlideIn 0.4s ease-out;
        }

        @keyframes modalSlideIn {
            from { 
                opacity: 0; 
                transform: translateY(-30px) scale(0.95); 
            }
            to { 
                opacity: 1; 
                transform: translateY(0) scale(1); 
            }
        }

        .result-icon {
            font-size: 3rem;
            margin-bottom: 16px;
        }

        .result-icon.won {
            color: #38a169;
        }

        .result-icon.lost {
            color: #e53e3e;
        }

        .result-title {
            font-size: 1.6rem;
            font-weight: 700;
            margin-bottom: 12px;
            color: #2d3748;
        }

        .result-stats {
            background: #f8fafc;
            border-radius: 8px;
            padding: 16px;
            margin: 16px 0;
            border: 2px solid #e2e8f0;
        }

        .result-stats .stat-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 6px;
            padding: 2px 0;
            font-size: 0.9rem;
        }

        .result-stats .stat-row:last-child {
            margin-bottom: 0;
            border-top: 1px solid #e2e8f0;
            padding-top: 8px;
            margin-top: 8px;
            font-weight: 600;
        }

        /* ===== FLAG ANIMATION ===== */
        @media (max-width: 768px) {
            @keyframes flag-zoom-in {
                0% {
                    transform: scale(0);
                    opacity: 0;
                }
                80% {
                    transform: scale(1.99);
                    opacity: 1;
                }
                100% {
                    transform: scale(1);
                }
            }

            .tile.flagged {
                animation: flag-zoom-in 0.8s ease-out;
            }
        }

        @keyframes flash-highlight {
            0% {
                background-color: #f8fafc;
                transform: scale(1);
            }
            50% {
                background-color: #c6f6d5;
                transform: scale(1.1);
            }
            100% {
                background-color: #f8fafc;
                transform: scale(1);
            }
        }

        .highlight-animation {
            animation: flash-highlight 0.5s ease-in-out;
        }
/* ===== DAILY CHALLENGE STYLES ===== */
.daily-challenge-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (min-width: 1024px) {
    .daily-challenge-section {
        margin-bottom: 0;
        padding: 10px;
    }
    
 
}

.dc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dc-header h3 {
    color: #2d3748;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

@media (min-width: 1024px) {
    .dc-header h3 {
        font-size: 0.85rem;
    }
    
 
}

.dc-content {
    transition: all 0.3s ease;
}

.dc-content.hidden {
    display: none;
}

/* Challenge Info */
.dc-info {
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
}

.dc-date-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.dc-date {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.85rem;
}

.dc-time-left {
    font-size: 0.75rem;
    color: #e53e3e;
    font-weight: 500;
}

.dc-board-info {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.8rem;
}

.dc-difficulty {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    background: #bee3f8;
    color: #2b6cb0;
}

.dc-special-badge {
    text-align: center;
    margin-top: 6px;
    padding: 4px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Player Status */
.dc-player-status {
    margin-bottom: 10px;
}

.dc-warning {
    text-align: center;
    padding: 8px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 6px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.8rem;
}

.dc-played {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dc-result {
    background: #f0f9ff;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #bae6fd;
}

.dc-result .label {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 2px;
}

.dc-result .value {
    font-size: 1rem;
    font-weight: 700;
    color: #0284c7;
}

/* Mini Leaderboard */
.dc-leaderboard h4 {
    font-size: 0.85rem;
    color: #2d3748;
    margin-bottom: 6px;
}

.dc-leaderboard-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    margin-bottom: 8px;
}

.dc-player-row {
    display: grid;
    grid-template-columns: 40px 1fr 60px;
    gap: 6px;
    padding: 4px 6px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.75rem;
    align-items: center;
}

.dc-player-row:hover {
    background: #f8fafc;
}

.dc-player-row.current-user {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    font-weight: 600;
}

.dc-rank {
    text-align: center;
    font-weight: 700;
    color: #4a5568;
}

.dc-rank.top-1 { color: #d69e2e; }
.dc-rank.top-2 { color: #a0aec0; }
.dc-rank.top-3 { color: #cd7f32; }

.dc-player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dc-player-time {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #667eea;
}

.dc-stats {
    display: flex;
    justify-content: space-between;
    padding: 6px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.7rem;
    color: #64748b;
}

.dc-stats strong {
    color: #2d3748;
}

/* Responsive */
@media (min-width: 1024px) {
    .dc-info {
        padding: 8px;
    }
    
  
}

/* ===== DAILY CHALLENGE MODE STYLES ===== */
.daily-challenge-mode {
    background: linear-gradient(135deg, #1e293b, #334155);
}

.daily-challenge-mode .game-board {
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

.daily-challenge-mode .tile:hover {
    animation: dc-hover 0.3s;
}

@keyframes dc-hover {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
        /* ===== UTILITY CLASSES ===== */
        .hidden {
            display: none !important;
        }

        .text-center {
            text-align: center;
        }

        .mt-1 { margin-top: 8px; }
        .mt-2 { margin-top: 16px; }
        .mb-1 { margin-bottom: 8px; }
        .mb-2 { margin-bottom: 16px; }

        /* ===== ACCESSIBILITY ===== */
        @media (prefers-reduced-motion: reduce) {
            * {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }

        /* ===== TOUCH IMPROVEMENTS ===== */
        @media (hover: none) {
            .tile:hover {
                background: #e2e8f0;
            }
            
            .tile.revealed:hover {
                background: #ffffff;
            }
            
            .difficulty-btn:hover {
                transform: none;
                box-shadow: none;
            }
            
            .btn:hover {
                transform: none;
            }
        }
        /* ===== FIREBASE AUTH STYLES ===== */
.user-info {
    margin-top: 8px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 12px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.user-welcome {
    margin-bottom: 8px;
    text-align: center;
}

.user-welcome span {
    display: block;
    font-size: 1rem;
    color: #2d3748;
    font-weight: 700;
}

/* HIGHLIGHT USER NAME */
#userDisplayName {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    color: #667eea !important;
    text-shadow: 0 1px 2px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.user-type {
    font-size: 0.6rem !important;
    color: #a0aec0 !important;
    font-weight: 400;
   opacity: 0.7;
}

.user-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.login-form {
    margin-bottom: 16px;
}

.login-input {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #f8fafc;
    transition: border-color 0.2s ease;
}

.login-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.login-divider {
    text-align: center;
    margin: 12px 0;
    color: #718096;
    font-size: 0.8rem;
    position: relative;
}

.login-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e2e8f0;
    z-index: 1;
}

.login-divider::after {
    content: 'or';
    background: white;
    padding: 0 12px;
    position: relative;
    z-index: 2;
}

.login-toggle {
    text-align: center;
    font-size: 0.8rem;
    color: #718096;
}

.btn-link {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
    margin-left: 4px;
}

.btn-link:hover {
    color: #5a67d8;
}

/* Responsive adjustments */
@media (min-width: 1024px) {
    .user-info {
        padding: 6px;
    }
    
 
}
/* THÊM VÀO <style> TAG - Leaderboard Styles */

/* ===== LEADERBOARD SECTION ===== */
.leaderboard-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (min-width: 1024px) {
    .leaderboard-section {
        margin-bottom: 0;
        padding: 10px;
    }
    
 
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.leaderboard-header h3 {
    color: #2d3748;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

@media (min-width: 1024px) {
    .leaderboard-header h3 {
        font-size: 0.85rem;
    }
    
 
}

/* ===== LEADERBOARD CONTENT ===== */
.leaderboard-content {
    transition: all 0.3s ease;
}

.leaderboard-content.hidden {
    display: none;
}

/* ===== DIFFICULTY TABS ===== */
.difficulty-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

@media (min-width: 1024px) {
    .sidebar.compact .difficulty-tabs {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

.leaderboard-tab {
    padding: 6px 8px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

@media (min-width: 1024px) {
    .leaderboard-tab {
        padding: 4px 6px;
        font-size: 0.7rem;
    }
    
   
}

.leaderboard-tab:hover {
    border-color: #667eea;
    background: #edf2f7;
}

.leaderboard-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

/* ===== LEADERBOARD META ===== */
.leaderboard-meta {
    background: #f8fafc;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
}

@media (min-width: 1024px) {
    .leaderboard-meta {
        padding: 6px;
    }
    
  
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.75rem;
}

.meta-row:last-child {
    margin-bottom: 0;
}

@media (min-width: 1024px) {
    .meta-row {
        font-size: 0.7rem;
        margin-bottom: 2px;
    }
    

}

.meta-label {
    color: #718096;
    font-weight: 500;
}

.meta-value {
    color: #2d3748;
    font-weight: 600;
}

.meta-value.rank-good {
    color: #38a169;
}

/* ===== LEADERBOARD STATES ===== */
.leaderboard-state {
    text-align: center;
    padding: 20px;
    color: #718096;
    font-size: 0.8rem;
}

@media (min-width: 1024px) {
    .leaderboard-state {
        padding: 15px;
        font-size: 0.75rem;
    }
    
 
}

.error-text {
    color: #e53e3e;
    margin-bottom: 8px;
    font-weight: 500;
}

/* ===== LEADERBOARD TABLE ===== */
.leaderboard-table {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
}

@media (min-width: 1024px) {
    .leaderboard-table {
        max-height: 250px;
    }
    

}

.table-header {
    display: grid;
    grid-template-columns: 50px 1fr 70px 50px 50px;
    gap: 4px;
    padding: 8px 6px;
    background: #edf2f7;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.7rem;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
    z-index: 1;
}

@media (min-width: 1024px) {
    .table-header {
        padding: 6px 4px;
        font-size: 0.65rem;
        grid-template-columns: 40px 1fr 60px 40px 40px;
        gap: 2px;
    }
    
 
}

.table-body {
    min-height: 100px;
}

/* ===== PLAYER ROW ===== */
.player-row {
    display: grid;
    grid-template-columns: 50px 1fr 70px 50px 50px;
    gap: 4px;
    padding: 6px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.75rem;
    transition: background-color 0.2s ease;
    align-items: center;
}

@media (min-width: 1024px) {
    .player-row {
        padding: 4px;
        font-size: 0.7rem;
        grid-template-columns: 40px 1fr 60px 40px 40px;
        gap: 2px;
    }
    
 
}

.player-row:hover {
    background-color: #f8fafc;
}

.player-row.current-user {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border: 1px solid rgba(102, 126, 234, 0.3);
    font-weight: 600;
}

/* ===== TABLE COLUMNS ===== */
.col-rank, .rank {
    text-align: center;
    font-weight: 700;
    color: #4a5568;
}

.rank.top-1 { color: #d69e2e; font-size: 1em; }
.rank.top-2 { color: #a0aec0; }
.rank.top-3 { color: #e6a564; }

.col-player, .player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #2d3748;
    font-weight: 500;
}

.col-time, .player-time {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #667eea;
    font-size: 0.7rem;
}

@media (min-width: 1024px) {
    .col-time, .player-time {
        font-size: 0.65rem;
    }
    

}

.col-games, .player-games,
.col-winrate, .player-winrate {
    text-align: center;
    font-weight: 500;
    color: #4a5568;
}

.player-winrate.high {
    color: #38a169;
    font-weight: 600;
}

/* ===== LEADERBOARD FOOTER ===== */
.leaderboard-footer {
    padding: 8px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    gap: 6px;
    justify-content: center;
}

@media (min-width: 1024px) {
    .leaderboard-footer {
        padding: 6px;
        gap: 4px;
    }
    

}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .difficulty-tabs {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table-header,
    .player-row {
        grid-template-columns: 40px 1fr 60px;
        gap: 6px;
    }
    
    .col-games, .player-games,
    .col-winrate, .player-winrate {
        display: none;
    }
       .game-board-container {
        padding: 8px;
        gap: 6px;
    }
    
    .game-board-container .status-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
    
    .game-board-container .status-item {
        padding: 4px 2px;
    }
    
    .game-board-container .status-item .label {
        font-size: 0.6rem;
    }
    
    .game-board-container .status-item .value {
        font-size: 0.75rem;
    }
}


@media (max-width: 480px) {
    .difficulty-tabs {
        grid-template-columns: 1fr 1fr;
    }
    
    .leaderboard-tab {
        font-size: 0.7rem;
        padding: 8px 4px;
    }
    
    .table-header,
    .player-row {
        grid-template-columns: 35px 1fr 55px;
    }
}

/* Chord click active state */
.tile.chord-active {
    animation: chord-pulse 0.2s ease-out;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5) !important;
}

@keyframes chord-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Chord error feedback */
.tile.chord-error {
    animation: chord-shake 0.3s ease-in-out;
    background-color: #ffcccc !important;
}

@keyframes chord-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}
.stat-item.total-score .value {
    color: #9f7aea; /* Purple color for score */
    font-size: 1rem;
}

@media (min-width: 1024px) {
    .stat-item.total-score .value {
        font-size: 0.9rem;
    }
    
 
}

/* Score animation when updated */
@keyframes score-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: #b794f4; }
    100% { transform: scale(1); }
}

.stat-item.total-score.updating .value {
    animation: score-pulse 0.6s ease-out;
}
.col-score, .player-score {
    text-align: center;
    font-weight: 600;
    color: #9f7aea;
    font-size: 0.75rem;
}

@media (min-width: 1024px) {
    .col-score, .player-score {
        font-size: 0.7rem;
    }
    
 
}

/* Adjust grid for Score tab */
.table-header:has(.col-score),
.player-row:has(.player-score) {
    grid-template-columns: 50px 1fr 80px 50px 50px;
}

@media (min-width: 1024px) {
    .table-header:has(.col-score),
    .player-row:has(.player-score) {
        grid-template-columns: 40px 1fr 70px 40px 40px;
    }
    

}

/* Mobile responsive */
@media (max-width: 768px) {
    .table-header:has(.col-score),
    .player-row:has(.player-score) {
        grid-template-columns: 40px 1fr 70px;
    }
}
/* Notification animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
/* ===== GEM STYLES ===== */
.stat-item.gems {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border: 2px solid #9f7aea;
    position: relative;
    overflow: hidden;
}

.stat-item.gems.featured {
    grid-column: span 2;
}

.stat-item.gems .value {
    color: #9f7aea;
    font-size: 1.1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Gem earn animation */
@keyframes gem-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); filter: brightness(1.3); }
    100% { transform: scale(1); }
}

.stat-item.gems.earning .value {
    animation: gem-pulse 0.6s ease-out;
}

/* Floating gem animation */
.gem-earn-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #9f7aea, #b794f4);
    color: white;
    padding: 20px 40px;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: 0 10px 40px rgba(159, 122, 234, 0.4);
    z-index: 10000;
    animation: gem-notification 2s ease-out forwards;
}

@keyframes gem-notification {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    40% {
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -100px) scale(0.9);
    }
}

/* Daily challenge gem preview */
.dc-gem-rewards {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border: 1px solid #9f7aea;
    border-radius: 8px;
    padding: 8px;
    margin-top: 8px;
}

.dc-gem-rewards h5 {
    margin: 0 0 6px 0;
    color: #9f7aea;
    font-size: 0.85rem;
}

.dc-reward-tier {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 2px 0;
}

.dc-reward-tier.highlight {
    font-weight: 600;
    color: #9f7aea;
}

@media (min-width: 1024px) {
    .stat-item.gems .value {
        font-size: 1rem;
    }
    
 
}/* ===== REPLAY SECTION STYLES ===== */
.replay-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (min-width: 1024px) {
    .replay-section {
        margin-bottom: 0;
        padding: 10px;
    }
    
 
}

.replay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.replay-header h3 {
    color: #2d3748;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.replay-content {
    transition: all 0.3s ease;
}

.replay-content.hidden {
    display: none;
}

.replay-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.replay-empty {
    text-align: center;
    padding: 20px;
    color: #718096;
    font-size: 0.8rem;
}

.replay-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.replay-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.replay-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-color: #667eea;
}

.replay-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.replay-difficulty {
    font-weight: 600;
    font-size: 0.75rem;
}

.replay-difficulty.Beginner { color: #38a169; }
.replay-difficulty.Intermediate { color: #d69e2e; }
.replay-difficulty.Expert { color: #e53e3e; }
.replay-difficulty.Extreme { color: #805ad5; }

.replay-time {
    font-size: 0.7rem;
    color: #4a5568;
    font-family: 'Courier New', monospace;
}

.replay-controls {
    background: #f8fafc;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.replay-controls.hidden {
    display: none;
}

.replay-timeline {
    position: relative;
    background: #e2e8f0;
    height: 6px;
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden; /* Ensure scaleX doesn't show outside */
}

.replay-progress {
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.replay-time-display {
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    color: #4a5568;
    min-width: 80px;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
}

.replay-mode-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    z-index: 1000;
    display: none;
}

.replay-mode-indicator.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.game-board.replay-mode {
    position: relative;
}

.game-board.replay-mode::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    pointer-events: all;
    z-index: 10;
}

.ghost-cursor {
    position: absolute;
    width: 24px;
    height: 24px;
    background: radial-gradient(circle at center, rgba(102, 126, 234, 0.8), rgba(102, 126, 234, 0.4), transparent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    transition: all 0.15s ease-out;
}

.ghost-cursor::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(102, 126, 234, 0.6);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Tile reveal animation for replay */
@keyframes tile-reveal {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tile.replay-reveal {
    animation: tile-reveal 0.2s ease-out;
}

/* Flag animation for replay */
@keyframes flag-zoom-in {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(90deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.tile.replay-flag {
    animation: flag-zoom-in 0.3s ease-out;
}

/* Exit replay button */
.exit-replay-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e53e3e;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
    z-index: 1001;
    display: none;
}

.exit-replay-btn.active {
    display: block;
}

.exit-replay-btn:hover {
    background: #c53030;
    transform: translateY(-1px);
}

/* Responsive adjustments */
@media (min-width: 1024px) {
    .replay-header h3 {
        font-size: 0.85rem;
    }
    

}
/* THÊM vào CSS */

.replay-result {
    font-size: 0.9rem;
    margin-left: 4px;
}

.replay-result.victory {
    color: #38a169;
}

.replay-result.defeat {
    color: #e53e3e;
}

/* Lost game replay items */
.replay-item.defeat {
    background: linear-gradient(to right, rgba(254, 215, 215, 0.3), #f8fafc);
}

.replay-item.defeat:hover {
    background: linear-gradient(to right, rgba(254, 215, 215, 0.5), #edf2f7);
}
/* ===== OPTIMIZED GHOST CURSOR STYLES ===== */

/* ✅ OPTIMIZED: Hardware accelerated ghost cursor */
.ghost-cursor.optimized {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    
    /* ✅ PERFORMANCE: Use will-change for better rendering */
    will-change: transform, opacity;
    
    /* ✅ SMOOTH: Optimized transition with hardware acceleration */
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.15s ease-out;
    
    /* ✅ VISUAL: Improved gradient for better visibility */
    background: radial-gradient(
        circle at center, 
        rgba(102, 126, 234, 0.9) 0%,
        rgba(102, 126, 234, 0.6) 40%,
        rgba(102, 126, 234, 0.3) 70%,
        transparent 100%
    );
    
    /* ✅ GLOW: Subtle shadow for depth */
    box-shadow: 
        0 0 8px rgba(102, 126, 234, 0.4),
        0 0 16px rgba(102, 126, 234, 0.2);
    
    /* ✅ INITIAL: Hidden by default */
    display: none;
    opacity: 0;
    
    /* ✅ PERFORMANCE: Force hardware layer */
    transform: translate3d(-50%, -50%, 0);
}

/* ✅ ACTIVE: When cursor is showing */
.ghost-cursor.optimized.active {
    display: block;
    opacity: 1;
}

/* ✅ CLICK: Click effect animation */
.ghost-cursor.optimized.clicking {
    transform: translate3d(-50%, -50%, 0) scale(0.8);
    background: radial-gradient(
        circle at center, 
        rgba(102, 126, 234, 1) 0%,
        rgba(102, 126, 234, 0.8) 40%,
        rgba(102, 126, 234, 0.4) 70%,
        transparent 100%
    );
    box-shadow: 
        0 0 12px rgba(102, 126, 234, 0.6),
        0 0 24px rgba(102, 126, 234, 0.3);
}

/* ✅ PERFORMANCE: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .ghost-cursor.optimized {
        transition: none;
        animation: none;
    }
}

/* ===== REPLAY MODE OPTIMIZATIONS ===== */

/* ✅ PERFORMANCE: Optimize replay mode board */
.game-board.replay-mode {
    position: relative;
    /* Force hardware acceleration */
    transform: translateZ(0);
    will-change: scroll-position;
}

/* ✅ PREVENT: Disable interactions during replay */
.game-board.replay-mode::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    pointer-events: all;
    z-index: 10;
    /* Remove unnecessary backdrop blur for performance */
}

/* ✅ OPTIMIZED: Tile animations for replay */
.tile.replay-reveal {
    animation: tile-reveal-optimized 0.15s ease-out;
}

@keyframes tile-reveal-optimized {
    0% {
        transform: scale(0.9);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tile.replay-flag {
    animation: flag-zoom-optimized 0.2s ease-out;
}

@keyframes flag-zoom-optimized {
    0% {
        transform: scale(0.5) rotate(-45deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.1) rotate(5deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* ✅ PERFORMANCE: Optimize chord animations */
.tile.chord-active {
    animation: chord-pulse-optimized 0.15s ease-out;
}

@keyframes chord-pulse-optimized {
    0% { 
        transform: scale(1); 
        box-shadow: 0 0 0 rgba(102, 126, 234, 0.5);
    }
    50% { 
        transform: scale(0.95); 
        box-shadow: 0 0 8px rgba(102, 126, 234, 0.6);
    }
    100% { 
        transform: scale(1); 
        box-shadow: 0 0 4px rgba(102, 126, 234, 0.3);
    }
}

/* ===== REPLAY TIMELINE OPTIMIZATIONS ===== */

/* ✅ SMOOTH: Optimized timeline progress */
.replay-progress {
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
    width: 0%;
    /* ✅ PERFORMANCE: Use transform instead of width animation */
    transform: scaleX(0);
    transform-origin: left;
    transition: none;
    will-change: transform;
}

/* ✅ PERFORMANCE: Optimize replay controls */
.replay-controls {
    /* Force hardware acceleration */
    transform: translateZ(0);
    will-change: opacity;
}

.replay-controls.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
}

.replay-controls:not(.hidden) {
    opacity: 1;
    pointer-events: all;
    transition: opacity 0.2s ease-in;
}

/* ===== MOBILE OPTIMIZATIONS ===== */

@media (max-width: 768px) {
    /* ✅ MOBILE: Larger ghost cursor for touch devices */
    .ghost-cursor.optimized {
        width: 24px;
        height: 24px;
    }
    
    /* ✅ MOBILE: Reduce animation complexity */
    .tile.replay-reveal,
    .tile.replay-flag,
    .tile.chord-active {
        animation-duration: 0.1s;
    }
    
    /* ✅ MOBILE: Simplify transitions */
    .replay-progress {
        transition: transform 0.05s linear;
    }
}

/* ===== DEBUG MODE (OPTIONAL) ===== */

/* ✅ DEBUG: Performance monitoring overlay */
.replay-performance-monitor {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    z-index: 10001;
    display: none;
    pointer-events: none;
}

.replay-performance-monitor.visible {
    display: block;
}

.replay-performance-monitor .metric {
    display: block;
    margin-bottom: 2px;
}

.replay-performance-monitor .metric.warning {
    color: #ff6b6b;
}

.replay-performance-monitor .metric.good {
    color: #51cf66;
}
/* ===== CONTAINER SCROLL FOR ALL CONTENT ===== */
@media (min-width: 1024px) {
    .container {
        min-height: 100vh;
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: flex-start;
        padding: 8px;
        /* ✅ THÊM: Cho phép scroll toàn bộ */
        overflow-x: auto;
        overflow-y: auto;
        max-width: 100vw;
        max-height: 100vh;
        /* ✅ THÊM: Scrollbar styling */
        scrollbar-width: thin;
        scrollbar-color: #cbd5e0 #f7fafc;
    }

    /* ✅ THÊM: Style scrollbar cho container */
    .container::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    .container::-webkit-scrollbar-track {
        background: #f7fafc;
        border-radius: 4px;
    }

    .container::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 4px;
    }

    .container::-webkit-scrollbar-thumb:hover {
        background: #a0aec0;
    }

    .container::-webkit-scrollbar-corner {
        background: #f7fafc;
    }

    /* ✅ THÊM: Sidebar cố định width, không co giãn */
    .sidebar {
        width: 300px;
        flex-shrink: 0;
        min-width: 300px;
        max-width: 300px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        /* Không transition nữa */
    }

    /* ✅ THÊM: Main content linh hoạt */
    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-height: calc(100vh - 16px);
        min-width: 0; /* Cho phép shrink */
    }

    /* ✅ THÊM: Board container không overflow */
    .game-board-container {
        padding: 12px;
        gap: 8px;
        /* Reset overflow về mặc định */
        overflow: visible;
    }

    .board-wrapper {
        flex: 1;
        height: 100%;
        /* Reset overflow về mặc định */
        overflow: visible;
        touch-action: pan-x pan-y;
        cursor: default;
    }

    .board-center {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100%;
        padding: 8px;
        /* ✅ THÊM: Cho phép board mở rộng tự nhiên */
        width: max-content;
        min-width: 100%;
    }

    .game-board {
        display: inline-grid;
        gap: 1px;
        background: #a0aec0;
        padding: 4px;
        border-radius: 8px;
        box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.15);
        /* ✅ THÊM: Board size tự nhiên */
        width: max-content;
        margin: 0 auto;
    }
}
/* ===== PERIOD SELECTOR STYLES ===== */
.period-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: #f8fafc;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

@media (min-width: 1024px) {
    .period-selector {
        margin-bottom: 8px;
    }
}

.period-tab {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
    min-width: 0;
}

@media (min-width: 1024px) {
    .period-tab {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
}

.period-tab:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.period-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.period-icon {
    font-size: 1.2rem;
    line-height: 1;
}

@media (min-width: 1024px) {
    .period-icon {
        font-size: 1rem;
    }
}

.period-label {
    font-size: 0.7rem;
    white-space: nowrap;
}

@media (min-width: 1024px) {
    .period-label {
        font-size: 0.65rem;
    }
}

.period-countdown {
    font-size: 0.65rem;
    opacity: 0.8;
    font-family: 'Courier New', monospace;
    min-height: 1em;
    display: block;
}

@media (min-width: 1024px) {
    .period-countdown {
        font-size: 0.6rem;
    }
}

.period-tab.active .period-countdown {
    opacity: 0.9;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .period-selector {
        gap: 2px;
        padding: 3px;
    }
    
    .period-tab {
        padding: 6px 4px;
    }
    
    .period-label {
        font-size: 0.65rem;
    }
    
    .period-icon {
        display: none;
    }
}

/* Loading state for period switch */
.leaderboard-content.period-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Period indicator in meta */
.leaderboard-meta .current-period {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
    margin-top: 4px;
}
/* ===== 3BV STATS STYLES ===== */
.bv-stats-compact {
    margin-top: 12px;
    padding: 10px;
    background: linear-gradient(135deg, #f0f4ff, #e8f2ff);
    border: 2px solid #667eea;
    border-radius: 8px;
    animation: fadeIn 0.3s ease;
}

.bv-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.bv-icon {
    font-size: 1.2rem;
}

.bv-text {
    font-weight: 700;
    color: #2d3748;
    font-size: 0.9rem;
    min-width: 80px;
}

.bv-progress-bar {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bv-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 4px rgba(102, 126, 234, 0.5);
}

.bv-metrics {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.bv-metric {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1;
    justify-content: center;
}

.metric-icon {
    font-size: 0.9rem;
}

.metric-value {
    font-weight: 600;
    font-size: 0.8rem;
    color: #2d3748;
}

/* Efficiency color coding */
.bv-metric.efficiency-excellent { background: #d4edda; }
.bv-metric.efficiency-good { background: #fff3cd; }
.bv-metric.efficiency-fair { background: #f8d7da; }

/* Animation for new records */
@keyframes bv-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); filter: brightness(1.1); }
    100% { transform: scale(1); }
}

.bv-new-record {
    animation: bv-pulse 0.6s ease;
}

/* Post-game BV Summary */
.bv-summary {
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    border: 2px solid #e2e8f0;
}

.bv-summary-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 12px;
    text-align: center;
}

.bv-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bv-summary-item {
    background: white;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}

.bv-summary-label {
    font-size: 0.75rem;
    color: #718096;
    margin-bottom: 4px;
}

.bv-summary-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2d3748;
}

.bv-summary-value.record {
    color: #667eea;
    text-shadow: 0 0 2px rgba(102, 126, 234, 0.3);
}

.bv-grade {
    margin-top: 12px;
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    padding: 8px;
    border-radius: 8px;
}

.bv-grade.grade-s { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.bv-grade.grade-a { background: #d4edda; color: #155724; }
.bv-grade.grade-b { background: #fff3cd; color: #856404; }
.bv-grade.grade-c { background: #f8d7da; color: #721c24; }

/* Mobile responsive */
@media (max-width: 768px) {
    .bv-stats-compact {
        padding: 8px;
        font-size: 0.85rem;
    }
    
    .bv-metrics {
        flex-wrap: wrap;
    }
    
    .bv-metric {
        padding: 3px 6px;
    }
}
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}
/* ===== POST-GAME BV SUMMARY ===== */
.post-game-bv-summary {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    animation: fadeIn 0.5s ease;
}

/* Compact layout for post-game */
.bv-postgame-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.bv-postgame-label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

.bv-postgame-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
}

.bv-postgame-value.highlight {
    color: #667eea;
}

/* Grade display inline */
.bv-postgame-grade {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
}

.bv-postgame-grade.grade-s { 
    background: linear-gradient(135deg, #fbbf24, #f59e0b); 
    color: white;
}
.bv-postgame-grade.grade-a { 
    background: linear-gradient(135deg, #34d399, #10b981); 
    color: white;
}
.bv-postgame-grade.grade-b { 
    background: linear-gradient(135deg, #60a5fa, #3b82f6); 
    color: white;
}
.bv-postgame-grade.grade-c { 
    background: linear-gradient(135deg, #f87171, #ef4444); 
    color: white;
}

/* Compact grid for metrics */
.bv-postgame-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.bv-postgame-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: #f8fafc;
    border-radius: 4px;
    font-size: 0.75rem;
}

.bv-postgame-metric-label {
    color: #64748b;
}

.bv-postgame-metric-value {
    font-weight: 600;
    color: #1e293b;
}

/* New record pulse */
.bv-record-indicator {
    display: inline-block;
    background: #e53e3e;
    color: white;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 600;
    animation: pulse 1s infinite;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .post-game-bv-summary {
        padding: 8px;
    }
    
    .bv-postgame-row {
        padding: 4px 6px;
    }
    
    .bv-postgame-metrics {
        grid-template-columns: 1fr;
    }
}
/* Estimated time styling */
.bv-metric.estimated-time {
    background: #fef3c7;
    border: 1px solid #fbbf24;
}

.bv-metric.estimated-time .metric-value {
    color: #92400e;
}

/* Pulse animation when time is running out */
.bv-metric.estimated-time.time-warning {
    animation: time-warning-pulse 1s infinite;
}

@keyframes time-warning-pulse {
    0%, 100% { 
        background: #fef3c7;
        transform: scale(1);
    }
    50% { 
        background: #fed7aa;
        transform: scale(1.02);
    }
}


/* Mobile layout for 4 metrics */
@media (max-width: 480px) {
    .bv-metrics {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }
    
    .bv-metric {
        padding: 3px 4px;
        font-size: 0.7rem;
    }
    
    .metric-icon {
        font-size: 0.8rem;
    }
}
/* Loss state styling */
.post-game-bv-summary.game-loss {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fca5a5;
}

.bv-postgame-row.loss {
    background: #fee2e2;
}

.bv-postgame-row.loss-reason {
    background: #fef3c7;
    border: 1px solid #fbbf24;
}

.bv-postgame-value.incomplete {
    color: #dc2626;
}

/* Grade styling for incomplete games */
.game-loss .bv-postgame-grade {
    opacity: 0.8;
    position: relative;
}

.game-loss .bv-postgame-grade::after {
    content: '*';
    position: absolute;
    top: -2px;
    right: -8px;
    font-size: 0.8rem;
    color: #dc2626;
}

/* Add disclaimer for loss */
.post-game-bv-summary.game-loss::after {
    content: '* Grade based on partial completion';
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: #7f1d1d;
    margin-top: 8px;
    font-style: italic;
}
/* Tooltip container */
.tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.tooltip-trigger {
    cursor: help;
    border-bottom: 1px dotted #666;
}

/* Tooltip content */
.tooltip-wrapper .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    
    /* Style */
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 1000;
    
    /* Animation */
    transition: opacity 0.3s, visibility 0.3s;
}

/* Arrow */
.tooltip-wrapper .tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Show on hover */
.tooltip-wrapper:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Multi-line support */
.tooltip-content.multiline {
    white-space: normal;
    max-width: 250px;
    text-align: center;
    line-height: 1.4;
}

/* Adjust position for edge cases */
.tooltip-wrapper:first-child .tooltip-content {
    left: 0;
    transform: translateX(0);
}

.tooltip-wrapper:last-child .tooltip-content {
    left: auto;
    right: 0;
    transform: translateX(0);
}
/* Special styling for grade tooltip */
.bv-postgame-grade.tooltip-trigger {
    cursor: help;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.5);
}

/* Adjust grade colors in tooltip */
.tooltip-content strong {
    color: #fbbf24; /* gold color for headers */
}
/* Adjust metric layout for labels */
.bv-metric {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}

.metric-icon {
    font-size: 16px;
}

.metric-label {
    font-size: 12px;
    color: #718096;
    font-weight: 500;
}

.metric-value {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

/* Responsive - hide labels on very small screens */
@media (max-width: 480px) {
    .metric-label {
        display: none;
    }
    
    .bv-metric {
        gap: 2px;
        padding: 4px 4px;
    }
}

/* Theme variations */
[data-theme="dark"] .metric-label {
    color: #a0aec0;
}

[data-theme="dark"] .metric-value {
    color: #e2e8f0;
}

[data-theme="neon"] .metric-label {
    color: #64ffda;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
}
.metric-label {
    cursor: help;
}

.metric-label[title]:hover {
    text-decoration: underline dotted;
}
/* ===== METRIC SELECTOR STYLES ===== */
.metric-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    background: #f8fafc;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.metric-tab {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
}

.metric-tab:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.metric-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.score-tab {
    display: block !important; /* Always show Score tab */
}

/* Efficiency display colors */
.player-efficiency {
    font-weight: 600;
}

.player-efficiency.gold {
    color: #d69e2e;
}

.player-efficiency.silver {
    color: #718096;
}

.player-efficiency.bronze {
    color: #cd7f32;
}

/* Best efficiency display in stats */
.stat-item.best-efficiency .value {
    color: #667eea;
    font-size: 0.95rem;
}

.best-efficiency-list {
    margin-top: 4px;
    font-size: 0.7rem;
    max-height: 120px;
    overflow-y: auto;
}

.best-efficiency-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 1px;
    font-size: 0.65rem;
}

.best-efficiency-entry:nth-child(1) {
    background: linear-gradient(90deg, #dbeafe, #bfdbfe);
    color: #1e40af;
    font-weight: 600;
}

.best-efficiency-entry:nth-child(2) {
    background: linear-gradient(90deg, #dcfce7, #bbf7d0);
    color: #166534;
}

.best-efficiency-entry:nth-child(3) {
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    color: #92400e;
}

@media (min-width: 1024px) {
    .metric-selector {
        margin-bottom: 6px;
    }
    
    .metric-tab {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}
/* THÊM vào phần CSS */
/* Efficiency table columns */
.col-efficiency, .player-efficiency {
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.col-bv, .player-bv {
    text-align: center;
    font-size: 0.75rem;
    color: #4a5568;
    font-family: 'Courier New', monospace;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .metric-selector {
        margin-bottom: 6px;
    }
    
    .metric-tab {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    
    /* Hide games column on mobile for efficiency */
    .table-header:has(.col-efficiency) .col-games,
    .player-row:has(.player-efficiency) .player-games {
        display: none;
    }
    
    .table-header:has(.col-efficiency),
    .player-row:has(.player-efficiency) {
        grid-template-columns: 40px 1fr 70px 60px;
    }
}
/* Difficulty mini tabs */
.difficulty-mini-tabs {
    display: flex;
    gap: 2px;
    margin: 4px 0;
    justify-content: center;
}

.diff-mini-tab {
    padding: 2px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    outline: none;
}

.diff-mini-tab:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.diff-mini-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #667eea;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.2);
}

/* Adjust spacing for stat items with tabs */
.stat-item.best-time,
.stat-item.best-efficiency {
    padding-top: 6px;
}

@media (min-width: 1024px) {
    .difficulty-mini-tabs {
        gap: 1px;
        margin: 3px 0;
    }
    
    .diff-mini-tab {
        padding: 1px 6px;
        font-size: 0.7rem;
    }
}
/* Make Best Times and Best Efficiency span full width */
.stat-item.best-time,
.stat-item.best-efficiency {
    grid-column: span 2;
}

/* Adjust padding for better look when full width */
.stat-item.best-time,
.stat-item.best-efficiency {
    padding: 10px 12px;
}

@media (min-width: 1024px) {
    .stat-item.best-time,
    .stat-item.best-efficiency {
        padding: 8px 10px;
    }
}

/* Center align difficulty tabs when full width */
.difficulty-mini-tabs {
    display: flex;
    gap: 4px;
    margin: 6px 0;
    justify-content: center;
}

/* Slightly larger tabs when full width */
.diff-mini-tab {
    padding: 3px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f8fafc;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    outline: none;
}

@media (min-width: 1024px) {
    .difficulty-mini-tabs {
        gap: 3px;
        margin: 4px 0;
    }
    
    .diff-mini-tab {
        padding: 2px 10px;
        font-size: 0.75rem;
    }
}
/* ===== NEW LAYOUT STYLES FOR REFACTORED PAGES ===== */

/* Hide old sidebar on refactored pages */
body:not(.daily-challenge-page):not(.leaderboard-page) .sidebar {
    display: none !important;
}

/* Connection keeper iframe */
#connection-keeper {
    display: none !important;
    width: 0;
    height: 0;
    position: absolute;
    top: -9999px;
    left: -9999px;
}

/* Ensure full width for no-sidebar layout */
.no-sidebar .main-content {
    width: 100%;
    max-width: none;
}

/* Compact stats animation */
.stat-compact-value {
    transition: all 0.3s ease;
}

.stat-compact.updating .stat-compact-value {
    transform: scale(1.1);
    color: #3498db;
}

/* Page transition animations */
.main-header-nav .nav-link {
    position: relative;
    overflow: hidden;
}

.main-header-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: #3498db;
    transition: width 0.3s ease;
}

.main-header-nav .nav-link:hover::after,
.main-header-nav .nav-link.active::after {
    width: 100%;
}

/* Gem animation */
.stat-compact.gems.earning {
    animation: gemEarn 0.6s ease;
}

@keyframes gemEarn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .game-controls-horizontal {
        padding: 0.5rem;
    }
    
    .difficulty-buttons-horizontal {
        flex-wrap: wrap;
    }
    
    .difficulty-btn-compact {
        flex: 1 1 45%;
        min-width: 100px;
    }
    
    .themes-stats-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .theme-selector-horizontal {
        justify-content: center;
        width: 100%;
    }
    
    .stats-compact {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .stat-compact {
        flex: 1 1 45%;
        min-width: 100px;
        text-align: center;
    }
}

/* Daily Challenge page specific responsive */
@media (max-width: 968px) {
    .daily-challenge-page .dc-main-content {
        grid-template-columns: 1fr;
    }
    
    .daily-challenge-page .dc-sidebar {
        order: -1;
        max-width: 500px;
        margin: 0 auto;
    }
}

/* Leaderboard page specific responsive */
@media (max-width: 1024px) {
    .leaderboard-page .leaderboard-main {
        grid-template-columns: 1fr;
    }
    
    .leaderboard-page .leaderboard-filters {
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .leaderboard-page .filter-section {
        margin-bottom: 0;
    }
}

/* Loading states */
.period-loading {
    opacity: 0.6;
    pointer-events: none;
}

.period-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #3498db;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

/* Smooth page transitions */
body {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fix for theme previews in horizontal layout */
.theme-selector-horizontal .theme-btn {
    padding: 0.5rem;
    background: rgba(52, 73, 94, 0.5);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-selector-horizontal .theme-btn:hover {
    background: rgba(52, 73, 94, 0.8);
    transform: translateY(-2px);
}

.theme-selector-horizontal .theme-btn.active {
    background: #3498db;
    border-color: #2980b9;
}

.theme-selector-horizontal .theme-preview {
    width: 24px;
    height: 24px;
    display: block;
    border-radius: 4px;
}

/* Fix replay section styling */
.replay-section {
    margin-top: 2rem;
    background: #2c3e50;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.replay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.replay-header h3 {
    margin: 0;
    color: #ecf0f1;
}

/* Ensure game board is centered */
.main-game-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - 200px);
}

.game-board-container {
    width: 100%;
    max-width: 1200px;
}