:root {
            --candy-red: #e74c3c;
            --candy-red-dark: #c0392b;
            --candy-orange: #f39c12;
            --candy-orange-dark: #d68910;
            --candy-yellow: #f1c40f;
            --candy-yellow-dark: #d4ac0d;
            --candy-green: #2ecc71;
            --candy-green-dark: #27ae60;
            --candy-blue: #3498db;
            --candy-blue-dark: #2980b9;
            --candy-purple: #9b59b6;
            --candy-purple-dark: #8e44ad;
            --cell-size: min(52px, 11vw);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            background: url('https://raw.githubusercontent.com/arpit456jain/Amazing-Js-Projects/master/Candy%20Crush/utils/bg.png') center/cover no-repeat fixed;
            font-family: 'Segoe UI', 'Montserrat', sans-serif;
            color: #5d4e37;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            user-select: none;
            -webkit-user-select: none;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
            overflow-x: hidden;
        }

        /* Mode Selection Overlay */
        #modeSelection {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(240, 235, 225, 0.96);
            z-index: 20;
            backdrop-filter: blur(8px);
            transition: opacity 0.4s;
        }
        #modeSelection.hidden {
            opacity: 0;
            pointer-events: none;
        }
        #modeSelection h2 {
            color: #4a3728;
            margin-bottom: 10px;
            font-size: clamp(22px, 5vw, 34px);
            font-weight: 700;
            letter-spacing: 1px;
        }
        #modeSelection .subtitle {
            color: #8b7355;
            margin-bottom: 30px;
            font-size: 14px;
            letter-spacing: 2px;
            text-transform: uppercase;
        }
        #modeSelection button {
            margin: 8px;
            padding: 14px 36px;
            font-size: 17px;
            border: none;
            border-radius: 50px;
            background: linear-gradient(135deg, #ff9a56, #ff6b6b);
            color: #fff;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            box-shadow: 0 4px 14px rgba(255, 107, 107, 0.35);
            letter-spacing: 0.5px;
            font-weight: 600;
            min-width: 180px;
        }
        #modeSelection button:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 22px rgba(255, 107, 107, 0.45);
        }
        #modeSelection button:active {
            transform: translateY(-1px);
            box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
        }
        #modeSelection button.timed-btn {
            background: linear-gradient(135deg, #667eea, #764ba2);
            box-shadow: 0 4px 14px rgba(118, 75, 162, 0.35);
        }
        #modeSelection button.timed-btn:hover {
            box-shadow: 0 8px 22px rgba(118, 75, 162, 0.45);
        }

        /* Game Container */
        .game-container {
            display: none;
            flex-wrap: wrap;
            justify-content: center;
            align-items: flex-start;
            gap: 25px;
            padding: 15px;
            width: 100%;
            max-width: 700px;
        }
        .game-container.active {
            display: flex;
        }

        /* Score Board */
        .scoreBoard {
            background: linear-gradient(160deg, #fff9f0, #fef3e2);
            border-radius: 20px;
            padding: 22px 18px;
            text-align: center;
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            min-width: 150px;
            border: 2px solid #f0d9b5;
        }
        .scoreBoard h3 {
            font-size: 13px;
            letter-spacing: 3px;
            opacity: 0.7;
            margin: 0;
            text-transform: uppercase;
            color: #8b7355;
        }
        .scoreBoard h1 {
            font-size: 44px;
            margin: 0;
            font-weight: 700;
            color: #e67e22;
            line-height: 1;
        }
        #timer {
            font-size: 18px;
            font-weight: 600;
            margin: 4px 0;
            color: #c0392b;
            min-height: 24px;
        }
        #changeMode {
            margin-top: 8px;
            padding: 9px 22px;
            background: #95a5a6;
            color: #fff;
            border: none;
            border-radius: 20px;
            cursor: pointer;
            font-size: 13px;
            transition: background 0.3s;
            letter-spacing: 0.5px;
        }
        #changeMode:hover {
            background: #7f8c8d;
        }

        /* Grid */
        .grid {
            display: grid;
            grid-template-columns: repeat(8, var(--cell-size));
            grid-template-rows: repeat(8, var(--cell-size));
            gap: 3px;
            padding: 6px;
            background: rgba(140, 110, 80, 0.35);
            border-radius: 16px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25) inset, 0 2px 0 rgba(255, 255, 255, 0.5);
            width: fit-content;
        }

        /* Candy Cells */
        .grid .candy {
            width: var(--cell-size);
            height: var(--cell-size);
            border-radius: 22%;
            cursor: pointer;
            transition: transform 0.12s ease, opacity 0.25s, box-shadow 0.12s;
            position: relative;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), inset 0 2px 3px rgba(255, 255, 255, 0.5);
        }
        .grid .candy:hover {
            transform: scale(1.08);
            z-index: 2;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 2px 3px rgba(255, 255, 255, 0.5);
        }
        .grid .candy.selected {
            outline: 3px solid #fff;
            outline-offset: -1px;
            filter: brightness(1.25) drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
            transform: scale(0.92);
            animation: pulse 0.7s ease-in-out infinite;
            z-index: 3;
        }
        .grid .candy.selected:hover {
            transform: scale(0.92);
        }
        .grid .candy.popping {
            animation: popOut 0.35s ease-out forwards;
            pointer-events: none;
        }
        .grid .candy.dropping {
            animation: dropIn 0.4s ease-out;
        }

        @keyframes pulse {
            0%,
            100% {
                box-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
            }
            50% {
                box-shadow: 0 0 18px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.5);
            }
        }
        @keyframes popOut {
            0% {
                transform: scale(1);
                opacity: 1;
            }
            40% {
                transform: scale(1.25);
                opacity: 0.7;
            }
            100% {
                transform: scale(0);
                opacity: 0;
            }
        }
        @keyframes dropIn {
            0% {
                transform: translateY(calc(var(--drop-dist, -60) * 1px));
                opacity: 0.4;
            }
            60% {
                opacity: 1;
            }
            100% {
                transform: translateY(0);
                opacity: 1;
            }
        }

        /* Candy type styles with glossy gradients */
        .candy.type-0 {
            background: radial-gradient(circle at 35% 30%, #ff8a80, #e74c3c 60%, #c0392b);
        }
        .candy.type-1 {
            background: radial-gradient(circle at 35% 30%, #ffb74d, #f39c12 60%, #d68910);
        }
        .candy.type-2 {
            background: radial-gradient(circle at 35% 30%, #fff176, #f1c40f 60%, #d4ac0d);
        }
        .candy.type-3 {
            background: radial-gradient(circle at 35% 30%, #69f0ae, #2ecc71 60%, #27ae60);
        }
        .candy.type-4 {
            background: radial-gradient(circle at 35% 30%, #64b5f6, #3498db 60%, #2980b9);
        }
        .candy.type-5 {
            background: radial-gradient(circle at 35% 30%, #ce93d8, #9b59b6 60%, #8e44ad);
        }

        /* Game Over Overlay */
        #gameOverOverlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.65);
            z-index: 25;
            justify-content: center;
            align-items: center;
        }
        #gameOverOverlay.show {
            display: flex;
        }
        #gameOverOverlay .overlay-content {
            background: #fffef9;
            border-radius: 20px;
            padding: 30px 25px;
            text-align: center;
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
            max-width: 380px;
            width: 90%;
        }
        #gameOverOverlay h2 {
            font-size: 28px;
            margin-bottom: 8px;
            color: #e74c3c;
        }
        #gameOverOverlay .final-score {
            font-size: 50px;
            font-weight: 700;
            color: #e67e22;
            margin: 10px 0;
        }
        #gameOverOverlay button {
            margin: 6px;
            padding: 12px 28px;
            font-size: 16px;
            border: none;
            border-radius: 50px;
            background: linear-gradient(135deg, #ff9a56, #ff6b6b);
            color: #fff;
            cursor: pointer;
            font-weight: 600;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        #gameOverOverlay button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(255, 107, 107, 0.4);
        }

        /* Responsive */
        @media (max-width: 600px) {
            .game-container {
                flex-direction: column;
                align-items: center;
                gap: 12px;
                padding: 8px;
            }
            .scoreBoard {
                flex-direction: row;
                flex-wrap: wrap;
                justify-content: center;
                gap: 10px;
                padding: 12px 16px;
                width: 95%;
                border-radius: 14px;
            }
            .scoreBoard h1 {
                font-size: 30px;
            }
            .scoreBoard h3 {
                font-size: 11px;
                letter-spacing: 2px;
            }
            #timer {
                font-size: 15px;
            }
            #changeMode {
                font-size: 11px;
                padding: 7px 16px;
            }
            :root {
                --cell-size: min(44px, 11.5vw);
            }
            .grid {
                gap: 2px;
                padding: 4px;
            }
        }
        @media (max-width: 380px) {
            :root {
                --cell-size: min(38px, 12vw);
            }
            .grid {
                gap: 1.5px;
                padding: 3px;
            }
            .grid .candy {
                border-radius: 16%;
            }
        }
        @media (min-width: 601px) {
            .game-container {
                flex-direction: row;
                align-items: flex-start;
            }
        }