        body, html {
            margin: 0; padding: 0;
            width: 100%; height: 100%;
            overflow: hidden;
            background-color: #87CEEB;
            font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
            touch-action: none; /* Prevent browser scrolling on touch */
        }
        canvas {
            display: block;
        }

        /* HUD UI */
        #hud {
            position: absolute;
            top: 10px;
            left: 10px;
            right: 10px;
            display: flex;
            justify-content: space-between;
            pointer-events: none;
            z-index: 10;
            text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
            color: white;
            font-size: 24px;
            font-weight: bold;
        }
        .hp-container {
            display: flex;
            gap: 5px;
        }
        .heart { color: #ff4d4d; }
        .level { color: #87cefa; }
        .score { color: #ffd700; }

        /* Mobile Controls */
        #mobile-controls {
            display: none; /* Hidden by default, shown if touch device */
            position: absolute;
            bottom: 20px;
            left: 20px;
            right: 20px;
            z-index: 10;
        }
        /* D-Pad */
        .dpad {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 150px;
            height: 150px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            pointer-events: auto;
        }
        .dpad-btn {
            position: absolute;
            width: 50px;
            height: 50px;
            background: rgba(255, 255, 255, 0.5);
            border: 2px solid rgba(0,0,0,0.3);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            user-select: none;
        }
        .dpad-btn:active { background: rgba(255, 255, 255, 0.8); }
        #btn-up { top: 0; left: 50px; }
        #btn-down { bottom: 0; left: 50px; }
        #btn-left { top: 50px; left: 0; }
        #btn-right { top: 50px; right: 0; }

        /* Action Button */
        .action-btn-container {
            position: absolute;
            bottom: 0;
            right: 0;
        }
        .action-btn {
            width: 80px;
            height: 80px;
            background: rgba(255, 215, 0, 0.5);
            border: 3px solid rgba(0,0,0,0.3);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: bold;
            color: #333;
            pointer-events: auto;
            user-select: none;
        }
        .action-btn:active { background: rgba(255, 215, 0, 0.9); }

        @media (hover: none) and (pointer: coarse) {
            #mobile-controls { display: block; }
        }

        /* Math Challenge Modal */
        #math-modal-overlay {
            display: none;
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 20;
            justify-content: center;
            align-items: center;
        }
        #math-modal {
            background: #fff8dc;
            border: 8px solid #8b4513;
            border-radius: 20px;
            padding: 20px 40px;
            text-align: center;
            box-shadow: 0 10px 25px rgba(0,0,0,0.5);
            max-width: 90%;
            width: 400px;
        }
        #math-title {
            color: #d2691e;
            font-size: 28px;
            margin-top: 0;
            text-shadow: 1px 1px 0 #fff;
        }
        #math-question {
            font-size: 48px;
            color: #333;
            margin: 20px 0;
            font-weight: bold;
        }
        .answers-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-top: 20px;
        }
        .answer-btn {
            background: #ffdead;
            border: 4px solid #cd853f;
            border-radius: 12px;
            padding: 15px;
            font-size: 24px;
            font-family: inherit;
            font-weight: bold;
            color: #555;
            cursor: pointer;
            transition: transform 0.1s, background 0.2s;
        }
        .answer-btn:hover { background: #f5deb3; }
        .answer-btn:active { transform: scale(0.95); background: #deb887; }

        #math-feedback {
            margin-top: 15px;
            font-size: 20px;
            font-weight: bold;
            height: 24px;
        }
