/* 99 Red Slots Classic Theme (Fixed for responsive board sizes) */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html, body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            overscroll-behavior: none;
        }

        body {
            font-family: 'San Francisco', 'Segoe UI', 'Arial Rounded MT Bold', Arial, sans-serif;
            background: linear-gradient(135deg, #e8eaed 0%, #cfd8dc 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #222;
        }

        .game-container {
            text-align: center;
            background: rgba(255,255,255,0.85);
            padding: 20px 12px 16px 12px;
            border-radius: 20px;
            backdrop-filter: blur(16px);
            box-shadow: 0 8px 32px 0 #b0bec540, 0 1.5px 6px 0 #b0bec520;
            border: 1.5px solid #e0e0e0;
            max-width: 480px;
            width: 100%;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            align-items: center;
        }

        .game-header {
            margin-bottom: 20px;
        }

        .game-title {
            font-size: clamp(1.8em, 6vw, 2.8em);
            font-weight: bold;
            color: #1976d2;
            text-shadow: 0 0 20px #e3f2fd;
            margin-bottom: 16px;
            letter-spacing: 2px;
        }

        .game-stats {
            display: flex;
            justify-content: center;
            gap: clamp(12px, 4vw, 20px);
            flex-wrap: wrap;
            margin-bottom: 20px;
        }

        .stat {
            background: rgba(255,255,255,0.7);
            padding: 8px 12px;
            border-radius: 12px;
            border: 1.5px solid #e0e0e0;
            min-width: clamp(60px, 20vw, 80px);
            position: relative;
            box-shadow: 0 1.5px 6px 0 #b0bec520;
        }

        .stat-label {
            font-size: clamp(0.7em, 2.5vw, 0.9em);
            opacity: 0.7;
            letter-spacing: 1px;
            color: #607d8b;
        }

        .stat-value {
            font-size: clamp(1.1em, 3.5vw, 1.4em);
            font-weight: bold;
            color: #1976d2;
            margin-top: 4px;
            text-shadow: 0 0 8px #e3f2fd;
        }

        .stat.moves {
            position: relative;
        }

        .extra-move-indicator {
            position: absolute;
            top: -8px;
            right: -8px;
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #fffde7 60%, #ffe082 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: #ffb300;
            font-size: 0.8em;
            box-shadow: 0 0 15px #ffe08280;
            opacity: 0;
            transform: scale(0.5);
            transition: all 0.3s cubic-bezier(.4,1.4,.6,1);
        }

        .extra-move-indicator.active {
            opacity: 1;
            transform: scale(1.1);
        }

        .game-board-container {
            width: 100%;
            display: flex;
            justify-content: center;
            margin-bottom: 20px;
        }

        /* FIXED: Responsive game board that scales based on container size */
        .game-board {
            display: grid;
            justify-content: center;
            align-items: center;
            background: rgba(255,255,255,0.7);
            padding: 2px;
            border-radius: 12px;
            border: 1.5px solid #e0e0e0;
            box-shadow: 0 2px 12px 0 #b0bec520;
            width: 100%;
            max-width: min(90vw, 450px);
            aspect-ratio: 1;
            min-width: 0;
            min-height: 0;
            gap: 2px;
        }

        /* FIXED: Responsive cell sizing that adapts to board size */
        .cell {
            width: 100%;
            height: 100%;
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: clamp(1.2rem, 4vw, 2.4rem);
            font-weight: bold;
            border: 2px solid #eee;
            border-radius: clamp(6px, 2vw, 12px);
            transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
            box-sizing: border-box;
            user-select: none;
            position: relative;
            overflow: hidden;
            background: linear-gradient(135deg, #f5f5f5 60%, #e3f2fd 100%);
            min-width: 0;
            min-height: 0;
            cursor: pointer;
        }

        /* Specific size adjustments for different grid sizes */
        .game-board.size-4 .cell {
            font-size: clamp(1.8rem, 5vw, 2.4rem);
        }

        .game-board.size-5 .cell {
            font-size: clamp(1.5rem, 4.5vw, 2rem);
        }

        .game-board.size-6 .cell {
            font-size: clamp(1.2rem, 4vw, 1.8rem);
        }

        .game-board.size-7 .cell {
            font-size: clamp(1rem, 3.5vw, 1.6rem);
        }

        .game-board.size-8 .cell {
            font-size: clamp(0.9rem, 3vw, 1.4rem);
        }

        .game-board.size-9 .cell {
            font-size: clamp(0.8rem, 2.5vw, 1.2rem);
        }

        .cell.selected {
            background: linear-gradient(135deg, #bbdefb 60%, #f8bbd0 100%);
            border-color: #90caf9;
            color: #222;
            transform: scale(1.05);
            box-shadow: 0 0 0 4px #90caf950, 0 2px 12px 0 #b0bec540;
            z-index: 2;
        }

        .cell.matched {
            animation: matchPulse 0.8s cubic-bezier(.4,1.4,.6,1);
        }

        .cell.swapping {
            transition: transform 0.4s cubic-bezier(.4,1.4,.6,1);
            z-index: 10;
        }

        @keyframes matchPulse {
            0% { transform: scale(1); }
            25% { transform: scale(1.1); box-shadow: 0 0 20px #90caf9; }
            50% { transform: scale(1.15); box-shadow: 0 0 30px #f8bbd0; }
            75% { transform: scale(1.1); box-shadow: 0 0 20px #90caf9; }
            100% { transform: scale(1); }
        }

        .cell.falling {
            animation: fall 0.7s cubic-bezier(.22,.68,.36,1) !important;
        }
        @keyframes fall {
            0% { transform: translateY(-120px); opacity: 0; }
            60% { transform: translateY(8px); opacity: 0.9; }
            100% { transform: translateY(0); opacity: 1; }
        }

        .cell.new-number {
            animation: sparkle 0.7s cubic-bezier(.4,1.4,.6,1);
        }
        @keyframes sparkle {
            0% { transform: scale(0.5); opacity: 0; background: #e3f2fd; }
            25% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 12px #90caf9; }
            50% { transform: scale(0.9); opacity: 1; }
            75% { transform: scale(1.05); opacity: 1; }
            100% { transform: scale(1); opacity: 1; }
        }

        .controls {
            display: flex;
            justify-content: center;
            gap: clamp(10px, 4vw, 20px);
            margin-bottom: 16px;
            flex-wrap: wrap;
        }

        .btn {
            background: linear-gradient(135deg, #90caf9 60%, #f8bbd0 100%);
            border: none;
            color: #263238;
            padding: clamp(8px, 2.5vw, 12px) clamp(16px, 5vw, 28px);
            border-radius: 20px;
            cursor: pointer;
            font-size: clamp(0.9em, 2.8vw, 1.1em);
            font-weight: bold;
            transition: all 0.22s cubic-bezier(.4,1.4,.6,1);
            box-shadow: 0 4px 12px #b0bec540;
            letter-spacing: 1px;
            text-transform: uppercase;
            position: relative;
            overflow: hidden;
        }

        .btn:hover {
            background: linear-gradient(135deg, #f8bbd0 60%, #90caf9 100%);
            color: #1976d2;
            transform: translateY(-2px) scale(1.04);
            box-shadow: 0 8px 24px #90caf950;
        }

        .btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .btn:disabled:hover {
            transform: none;
        }

        .message {
            height: clamp(30px, 8vw, 40px);
            font-size: clamp(0.9em, 3vw, 1.2em);
            font-weight: bold;
            color: #1976d2;
            text-shadow: 0 0 10px #e3f2fd;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255,255,255,0.7);
            border-radius: 10px;
            padding: 5px 10px;
        }

        .slot-frame {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 5;
            background: radial-gradient(circle, transparent 60%, #90caf930 100%);
            border-radius: 20px;
        }

        #gameOverOverlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(236,239,241,0.95);
            z-index: 9999;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }
        #gameOverOverlay div {
            color: #1976d2;
            font-size: clamp(1.5em, 5vw, 2.2em);
            font-weight: bold;
            text-align: center;
            text-shadow: 0 0 30px #b0bec540, 0 0 10px #90caf9;
            background: rgba(255,255,255,0.95);
            border-radius: 24px;
            padding: 24px 20px 20px 20px;
            border: 1.5px solid #e0e0e0;
            box-shadow: 0 8px 32px 0 #b0bec540;
            max-width: 90vw;
        }

        /* Hint animation */
        .hint-move {
            animation: hintAnim 1.2s ease-in-out infinite;
            border: 3px solid #ffd600 !important;
            box-shadow: 0 0 24px 8px #fffde7, 0 0 32px 8px #ffd60080 !important;
        }
        @keyframes hintAnim {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.1); }
        }

        /* Animations for combos, upgrades, and explosions */
        @keyframes comboAnim {
            0% { transform: scale(1); opacity: 1; }
            50% { transform: scale(1.2) rotate(10deg); opacity: 0.8; }
            100% { transform: scale(1) rotate(0deg); opacity: 1; }
        }

        @keyframes upgradeAnim {
            0% { transform: scale(1); }
            50% { transform: scale(1.3); }
            100% { transform: scale(1); }
        }

        @keyframes explodeAnim {
            0% { transform: scale(1); opacity: 1; }
            100% { transform: scale(0); opacity: 0; }
        }

        .combo-anim {
            animation: comboGrowSpin 0.9s cubic-bezier(.4,1.4,.6,1);
            z-index: 20;
        }
        @keyframes comboGrowSpin {
            0% { transform: scale(1) rotate(0deg); box-shadow: 0 0 0 #fff0; }
            20% { transform: scale(1.2) rotate(10deg); box-shadow: 0 0 24px #f8bbd0cc, 0 0 8px #fffde7; }
            40% { transform: scale(1.3) rotate(-10deg); box-shadow: 0 0 32px #90caf9cc, 0 0 16px #fffde7; }
            60% { transform: scale(1.15) rotate(8deg); box-shadow: 0 0 24px #ffd6e0cc, 0 0 8px #fffde7; }
            80% { transform: scale(1.1) rotate(-8deg); box-shadow: 0 0 16px #f8bbd0cc, 0 0 4px #fffde7; }
            100% { transform: scale(1) rotate(0deg); box-shadow: 0 0 0 #fff0; }
        }

        .upgrade-anim {
            animation: upgradePopSpin 0.9s cubic-bezier(.4,1.4,.6,1);
            z-index: 21;
        }
        @keyframes upgradePopSpin {
            0% { transform: scale(1) rotate(0deg); }
            20% { transform: scale(1.25) rotate(20deg); background: #fffde7; }
            40% { transform: scale(1.35) rotate(-20deg); background: #ffe082; }
            60% { transform: scale(1.1) rotate(10deg); background: #fffde7; }
            80% { transform: scale(1.05) rotate(-10deg); }
            100% { transform: scale(1) rotate(0deg); }
        }

        .explode-anim {
            animation: explodeCell 0.7s cubic-bezier(.4,1.4,.6,1);
            z-index: 22;
        }
        @keyframes explodeCell {
            0% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 #fff0; }
            40% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 32px #ffd6e0cc, 0 0 16px #fffde7; }
            60% { transform: scale(1.5); opacity: 0.7; box-shadow: 0 0 48px #f8bbd0cc, 0 0 32px #fffde7; }
            100% { transform: scale(0.1); opacity: 0; box-shadow: 0 0 0 #fff0; }
        }

        /* Mobile-first responsive design */
        @media (max-width: 480px) {
            body {
                padding: 4px;
            }
            
            .game-container {
                padding: 16px 8px 12px 8px;
                border-radius: 16px;
                max-width: 95vw;
            }

            .game-board {
                padding: 1px;
                border-radius: 8px;
                max-width: min(95vw, 350px);
            }

            .cell {
                border-radius: clamp(2px, 1vw, 8px);
                border-width: 1px;
            }
        }

        @media (max-width: 360px) {
            .game-container {
                padding: 12px 6px 10px 6px;
            }
            
            .game-stats {
                gap: 8px;
            }
            
            .stat {
                padding: 6px 8px;
                min-width: 50px;
            }

            .game-board {
                max-width: min(95vw, 320px);
            }
        }

        /* Landscape orientation optimization */
        @media (orientation: landscape) and (max-height: 600px) {
            body {
                align-items: flex-start;
                padding-top: 10px;
            }
            
            .game-container {
                padding: 12px 8px 8px 8px;
            }
            
            .game-header {
                margin-bottom: 12px;
            }
            
            .game-title {
                margin-bottom: 4px;
            }
            
            .game-stats {
                margin-bottom: 12px;
            }
            
            .game-board {
                margin-bottom: 12px;
                max-width: min(70vh, 400px);
            }
            
            .message {
                height: 30px;
                font-size: 0.9em;
            }
        }

        /* High DPI displays */
        @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
            .cell {
                border-width: 0.5px;
            }
        }