
        /* =====================================================================
           CSS STYLING & RESPONSIVENESS ARCHITECTURE
           ===================================================================== */
        :root {
            --primary: #EF476F;      /* Red/Pink for wrong/danger */
            --secondary: #118AB2;    /* Blue for buttons/neutral */
            --success: #06D6A0;      /* Green for correct */
            --warning: #FFD166;      /* Yellow for medium/warnings */
            --dark: #1E202B;         /* Dark background/text */
            --light: #F8F9FA;        /* Light background/text */
            --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        * {
            box-sizing: border-box;
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            touch-action: manipulation; 
        }

        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100vw;
            height: 100vh;
            background-color: #1A1C23; 
            font-family: var(--font-main);
            overflow: hidden;
        }
        
        #game-container {
            position: relative;
            width: 100vw;
            height: 100vh;
            max-width: 1280px;
            max-height: 720px;
            background: #000; 
            box-shadow: 0 0 50px rgba(0,0,0,0.9);
            overflow: hidden;
            border: 4px solid var(--dark);
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: contain; 
            z-index: 1;
        }
        
        /* --- UI Overlay System --- */
        .ui-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: rgba(30, 32, 43, 0.85);
            color: var(--light);
            text-align: center;
            z-index: 100;
            opacity: 1;
            transition: opacity 0.3s ease, visibility 0.3s ease;
        }

        .hidden {
            opacity: 0 !important;
            visibility: hidden !important;
            pointer-events: none !important;
        }

        h1.game-title {
            font-size: clamp(2.5rem, 5vw, 4.5rem);
            margin: 0 0 10px;
            text-shadow: 4px 4px 0 #000;
            color: var(--warning);
            letter-spacing: 2px;
            text-transform: uppercase;
        }

        p.subtitle {
            font-size: clamp(1.1rem, 2.5vw, 1.6rem);
            margin-bottom: 30px;
            color: #fff;
            text-shadow: 1px 1px 2px #000;
        }

        /* --- Difficulty Selector --- */
        .difficulty-panel {
            background: rgba(0,0,0,0.4);
            padding: 20px 30px;
            border-radius: 15px;
            margin-bottom: 30px;
            border: 2px solid rgba(255,255,255,0.1);
        }
        
        .difficulty-panel p {
            margin: 0 0 15px 0;
            font-weight: 800;
            font-size: 1.4rem;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .diff-buttons {
            display: flex;
            gap: 15px;
            justify-content: center;
        }

        .diff-btn {
            padding: 12px 24px;
            font-size: 1.2rem;
            font-weight: bold;
            border: 3px solid transparent;
            border-radius: 8px;
            background: #2D3142;
            color: white;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
        }

        .diff-btn:hover { background: #3d4259; }
        .diff-btn.active {
            background: var(--secondary);
            border-color: #48CAE4;
            box-shadow: 0 0 15px rgba(17, 138, 178, 0.6);
            transform: scale(1.05);
        }

        /* --- Global Buttons --- */
        button.primary-btn {
            padding: 20px 60px;
            font-size: 2rem;
            border: none;
            border-radius: 12px;
            background: var(--primary);
            color: white;
            cursor: pointer;
            font-weight: 900;
            text-transform: uppercase;
            box-shadow: 0 8px 0 #B93756, 0 15px 20px rgba(0,0,0,0.4);
            transition: transform 0.1s, box-shadow 0.1s;
            letter-spacing: 2px;
        }
        button.primary-btn:active {
            transform: translateY(8px);
            box-shadow: 0 0 0 #B93756, 0 5px 10px rgba(0,0,0,0.4);
        }

        /* --- Heads Up Display (HUD) --- */
        #hud {
            position: absolute;
            top: 20px;
            left: 30px;
            font-family: 'Courier New', Courier, monospace;
            z-index: 50;
            display: flex;
            flex-direction: column;
            pointer-events: none;
        }
        
        #hud-score {
            font-size: 2.8rem;
            font-weight: 900;
            color: var(--dark);
            text-shadow: 2px 2px 0 rgba(255,255,255,0.9);
            margin-bottom: 5px;
        }

        #hud-lives { 
            font-size: 1.4rem; 
            color: var(--primary); 
            font-weight: bold; 
            margin-top: 5px; 
            display: flex;
            align-items: center;
            gap: 8px;
            text-shadow: 1px 1px 0 #000;
        }
        .mistake-boxes { display: flex; gap: 5px; }
        .mistake-box {
            width: 18px; height: 18px;
            border: 2px solid var(--primary);
            background: rgba(0,0,0,0.5);
            border-radius: 3px;
            transition: background 0.3s;
        }
        .mistake-box.filled {
            background: var(--primary);
            box-shadow: 0 0 8px var(--primary);
        }

        .hud-badges {
            display: flex;
            gap: 10px;
            margin-top: 5px;
        }

        .diff-badge, .stage-badge {
            font-size: 1.2rem;
            font-weight: bold;
            background: var(--dark);
            color: white;
            padding: 6px 12px;
            border-radius: 8px;
            width: fit-content;
            font-family: var(--font-main);
            box-shadow: 0 4px 6px rgba(0,0,0,0.3);
            transition: all 0.5s ease;
        }

        .stage-badge.sunset {
            background: #FF9800 !important;
            color: #1E202B !important;
            box-shadow: 0 0 15px rgba(255, 152, 0, 0.8) !important;
        }

        /* High Score Display */
        #high-score-display {
            position: absolute;
            top: 20px;
            right: 30px;
            font-family: 'Courier New', Courier, monospace;
            font-size: 1.8rem;
            font-weight: 900;
            color: var(--warning);
            text-shadow: 2px 2px 0 var(--dark);
            text-align: right;
            z-index: 50;
        }

        /* --- Math Challenge Interface --- */
        #math-ui {
            background: var(--light);
            color: var(--dark);
            padding: 30px 40px;
            border-radius: 20px;
            box-shadow: 0 20px 50px rgba(0,0,0,0.6);
            border: 6px solid var(--dark);
            width: 90%;
            max-width: 600px;
            transform: scale(0.5);
            opacity: 0;
            transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
        }
        #math-screen:not(.hidden) #math-ui {
            transform: scale(1);
            opacity: 1;
        }

        #question {
            font-size: clamp(2.5rem, 6vw, 4rem);
            font-weight: 900;
            margin: 0 0 30px 0;
            color: var(--primary);
            text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
        }

        .answers-container {
            display: flex;
            gap: 20px;
            justify-content: space-between;
        }

        .answer-btn {
            flex: 1;
            padding: 20px 10px;
            font-size: 2.2rem;
            font-weight: 900;
            background: var(--secondary);
            color: white;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            box-shadow: 0 8px 0 #0C637F;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            transition: transform 0.1s, box-shadow 0.1s, filter 0.2s;
        }
        .answer-btn:active {
            transform: translateY(8px);
            box-shadow: 0 0 0 #0C637F;
        }
        .answer-btn:hover { filter: brightness(1.1); }
        .answer-btn.correct { background: var(--success) !important; box-shadow: 0 8px 0 #049A73 !important; }
        .answer-btn.wrong { background: var(--primary) !important; box-shadow: 0 8px 0 #B93756 !important; }
        
        .key-hint {
            font-size: 1.1rem;
            background: rgba(0,0,0,0.25);
            padding: 6px 12px;
            border-radius: 6px;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: bold;
        }

        /* --- Visual Feedback Flash --- */
        #flash-overlay {
            position: absolute;
            inset: 0;
            z-index: 90;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s ease-out;
        }
        .flash-red { background: rgba(239, 71, 111, 0.6); opacity: 1 !important; }
        .flash-green { background: rgba(6, 214, 160, 0.5); opacity: 1 !important; }
        .flash-gold { background: rgba(255, 209, 102, 0.4); opacity: 1 !important; }

        @media (max-width: 768px) {
            .answers-container { flex-direction: column; gap: 10px; }
            .answer-btn { padding: 15px; font-size: 1.8rem; }
            .key-hint { display: none; }
            #high-score-display { font-size: 1.4rem; top: 10px; right: 10px; }
        }
    
#hud .stage-badge{pointer-events:auto;cursor:pointer;border:2px solid #fff;font:inherit}.runner-stage-control{min-height:46px;padding:9px 14px;border:2px solid #ffd166;border-radius:12px;background:#1f5383;color:#fff;cursor:pointer}#runner-difficulty,#stage-complete{z-index:95;background:rgba(17,29,48,.97);color:#fff;text-align:center;padding:25px;gap:12px}#runner-difficulty h2,#stage-complete h2{font-size:clamp(27px,5vw,45px)}#runner-difficulty button{padding:13px 20px;min-height:48px;font:inherit;border:1px solid #9ab9dc;border-radius:10px;background:#285385;color:white}#course-status{color:#ffe19b;font-weight:700}.preview #runner-difficulty,.preview #stage-complete{display:none!important}@media(max-width:720px){#runner-difficulty{justify-content:flex-start;overflow-y:auto}#runner-difficulty button{width:100%}#course-status{font-size:13px}}
