
        :root {
            --col1: #F39;
            --col2: #3FF;
            --col3: #FF3;
            --col4: #A0F;
            --bg: #0a0a0f;
            --card-bg: #14141f;
            --text: #e8e8f0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 70%);
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            width: 100vw;
            overflow: hidden;
            font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
            -webkit-tap-highlight-color: transparent;
            -webkit-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
             background: 
        radial-gradient(ellipse at 20% 30%, rgba(10,15,42,0.8), rgba(3,5,11,0.9)),
        url('bg.jpg') no-repeat center center/cover;
        }

        /* ── Canvas wrapper for glow ── */
        #canvas-wrapper {
            position: absolute;
            /* will be positioned by JS */
            border-radius: 16px;
            box-shadow:
                0 0 40px rgba(255, 51, 153, 0.25),
                0 0 80px rgba(51, 255, 255, 0.15),
                0 0 120px rgba(255, 243, 51, 0.10),
                0 0 160px rgba(170, 0, 255, 0.08),
                0 20px 60px rgba(0, 0, 0, 0.6);
            transition: box-shadow 0.6s ease;
            overflow: hidden;
            /* ensures canvas respects border-radius */;
        }

        #canvas-wrapper.game-active {
            box-shadow:
                0 0 50px rgba(255, 51, 153, 0.35),
                0 0 90px rgba(51, 255, 255, 0.25),
                0 0 140px rgba(255, 243, 51, 0.18),
                0 0 180px rgba(170, 0, 255, 0.12),
                0 20px 70px rgba(0, 0, 0, 0.7);
        }

        canvas {
            display: block;
            /* fill wrapper */
            width: 100%;
            height: 100%;
            cursor: pointer;
            border-radius: 16px;
        }

        /* ── Preloader ── */
        #preloader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: #0a0a0f;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: opacity 0.5s ease, visibility 0.5s ease;
            opacity: 1;
            visibility: visible;
        }

        #preloader.fade-out {
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }

        .spinner-ring {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: conic-gradient(var(--col1) 0% 25%,
                    var(--col2) 25% 50%,
                    var(--col3) 50% 75%,
                    var(--col4) 75% 100%);
            animation: spin 1.2s cubic-bezier(0.6, 0.0, 0.4, 1.0) infinite;
            box-shadow:
                0 0 30px rgba(255, 51, 153, 0.5),
                0 0 50px rgba(51, 255, 255, 0.3),
                0 0 70px rgba(255, 243, 51, 0.2);
            margin-bottom: 28px;
        }

        .spinner-center {
            width: 28px;
            height: 28px;
            background: #0a0a0f;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .spinner-ring-wrapper {
            position: relative;
            width: 80px;
            height: 80px;
        }

        @keyframes spin {
            from {
                transform: rotate(0deg);
            }
            to {
                transform: rotate(360deg);
            }
        }

        .preloader-text {
            color: #ccc;
            font-size: 15px;
            letter-spacing: 6px;
            text-transform: uppercase;
            animation: pulse-text 1.5s ease-in-out infinite;
            font-weight: 500;margin-top: 20px;margin-bottom: 20px;
        }

        @keyframes pulse-text {
            0%,
            100% {
                opacity: 0.5;
            }
            50% {
                opacity: 1;
            }
        }

        .preloader-dots {
            display: flex;
            gap: 10px;
            margin-top: 16px;margin-top: 20px;
        }

        .preloader-dots span {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            animation: dot-bounce 1.2s ease-in-out infinite;
        }

        .preloader-dots span:nth-child(1) {
            background: var(--col1);
            animation-delay: 0s;
        }
        .preloader-dots span:nth-child(2) {
            background: var(--col2);
            animation-delay: 0.2s;
        }
        .preloader-dots span:nth-child(3) {
            background: var(--col3);
            animation-delay: 0.4s;
        }
        .preloader-dots span:nth-child(4) {
            background: var(--col4);
            animation-delay: 0.6s;
        }

        @keyframes dot-bounce {
            0%,
            80%,
            100% {
                transform: translateY(0);
                opacity: 0.4;
            }
            40% {
                transform: translateY(-18px);
                opacity: 1;
            }
        }

        /* ── How to Play Modal ── */
        #how-to-play-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.75);
            z-index: 900;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.4s ease, visibility 0.4s ease;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
        }

        #how-to-play-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .modal-card {
            background: var(--card-bg);
            border-radius: 20px;
            padding: 32px 28px 24px;
            max-width: 380px;
            width: 90%;
            text-align: center;
            box-shadow:
                0 0 40px rgba(255, 51, 153, 0.4),
                0 30px 60px rgba(0, 0, 0, 0.5);
            transform: translateY(20px) scale(0.95);
            transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        #how-to-play-overlay.show .modal-card {
            transform: translateY(0) scale(1);
        }

        .modal-title {
            font-size: 26px;
            font-weight: 700;
            margin-bottom: 6px;
            background: linear-gradient(135deg, var(--col1), var(--col2), var(--col3), var(--col4));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            letter-spacing: 1px;
        }

        .modal-subtitle {
            font-size: 13px;
            color: #888;
            margin-bottom: 20px;
            letter-spacing: 2px;
            text-transform: uppercase;
        }

        .instruction-list {
            list-style: none;
            text-align: left;
            margin-bottom: 24px;
        }

        .instruction-list li {
            display: flex;
            align-items: flex-start;
            gap: 14px;
            padding: 10px 8px;
            color: #c8c8d4;
            font-size: 14px;
            line-height: 1.5;
            border-radius: 10px;
            transition: background 0.3s;
        }

        .instruction-list li:hover {
            background: rgba(255, 255, 255, 0.03);
        }

        .instruction-icon {
            flex-shrink: 0;
            width: 38px;
            height: 38px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            font-weight: 700;
            color: #fff;
        }

        .icon-tap {
            background: var(--col1);
        }
        .icon-match {
            background: var(--col2);
            color: #000;
        }
        .icon-switch {
            background: conic-gradient(var(--col1) 0% 25%, var(--col2) 25% 50%, var(--col3) 50% 75%, var(--col4) 75% 100%);
        }
        .icon-star {
            background: var(--col3);
            color: #000;
        }
        .icon-die {
            background: #e04040;
        }

        .btn-lets-play {
            display: inline-block;
            padding: 14px 48px;
            font-size: 16px;
            font-weight: 700;
            letter-spacing: 2px;
            text-transform: uppercase;
            color: #fff;
            background: linear-gradient(135deg, var(--col1), var(--col4));
            border: none;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 8px 30px rgba(170, 0, 255, 0.4);
            outline: none;
            -webkit-tap-highlight-color: transparent;
        }

        .btn-lets-play:hover {
            transform: translateY(-2px);
            box-shadow: 0 12px 40px rgba(255, 51, 153, 0.5);
        }
        .btn-lets-play:active {
            transform: scale(0.96);
            box-shadow: 0 4px 15px rgba(170, 0, 255, 0.3);
        }

        /* ── Score badge overlay ── */
        .score-badge {
            position: fixed;
            top: 16px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 500;
            pointer-events: none;
            background: rgba(20, 20, 30, 0.85);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 30px;
            padding: 8px 22px;
            color: #fff;
            font-size: 18px;
            font-weight: 700;
            letter-spacing: 2px;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            opacity: 0;
            transition: opacity 0.5s ease;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        }

        .score-badge.visible {
            opacity: 1;
        }

        .score-badge .score-value {
            background: linear-gradient(135deg, var(--col3), #fff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-size: 22px;
        }

        /* ── Responsive ── */
        @media (max-width: 400px) {
            .modal-card {
                padding: 24px 18px 20px;
            }
            .modal-title {
                font-size: 22px;
            }
            .instruction-list li {
                font-size: 12px;
                gap: 10px;
                padding: 7px 4px;
            }
            .instruction-icon {
                width: 30px;
                height: 30px;
                font-size: 14px;
            }
            .btn-lets-play {
                padding: 12px 36px;
                font-size: 14px;
            }
            .spinner-ring {
                width: 60px;
                height: 60px;
            }
            .spinner-ring-wrapper {
                width: 60px;
                height: 60px;
            }
            .spinner-center {
                width: 22px;
                height: 22px;
            }
        }
