        body { margin: 0; overflow: hidden; background-color: #1a1a2e; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; user-select: none; touch-action: none; }
        canvas { image-rendering: pixelated; } /* 32-bit retro look */
        #ui-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
        #crosshair { position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; background: white; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 4px black, 0 0 8px rgba(255,255,255,0.5); }
        #crosshair.hit { transform: translate(-50%, -50%) scale(2); background: red; transition: 0.1s; box-shadow: 0 0 10px red; }
        
        /* Muck-style Bars */
        #hud-top { position: absolute; top: 20px; right: 20px; text-align: right; }
        .stat-box { background: rgba(0,0,0,0.6); padding: 10px 15px; border-radius: 8px; margin-bottom: 5px; color: white; font-weight: bold; font-size: 20px; border: 2px solid rgba(255,255,255,0.1); backdrop-filter: blur(5px); }
        
        #boss-bar-container { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 600px; text-align: center; }
        #boss-name { color: #fff; font-size: 24px; font-weight: 900; text-shadow: 2px 2px 0 #000, 0 0 20px rgba(255,170,0,0.5); letter-spacing: 1px; margin-bottom: 5px; text-transform: uppercase; }
        #boss-health-back { width: 100%; height: 25px; background: linear-gradient(180deg, #222, #111); border: 3px solid #000; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
        #boss-health-fill { width: 100%; height: 100%; background: linear-gradient(180deg, #ffcc00, #ff8800); transition: width 0.2s; box-shadow: 0 0 20px rgba(255,170,0,0.6); }

        #hud-bottom { position: absolute; bottom: 20px; left: 20px; display: flex; gap: 10px; }
        .item-slot { width: 60px; height: 60px; background: rgba(0,0,0,0.6); border: 3px solid #555; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; font-weight: bold; position: relative; backdrop-filter: blur(5px); }
        .item-slot.active { border-color: #ffaa00; background: rgba(50,50,0,0.8); transform: scale(1.1); box-shadow: 0 0 15px rgba(255,170,0,0.4); }
        .key-num { position: absolute; top: 2px; left: 5px; font-size: 12px; color: #aaa; }
        
        #overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, rgba(0,0,0,0.4), rgba(20,20,40,0.4)); display: flex; flex-direction: column; justify-content: center; align-items: center; pointer-events: auto; color: white; z-index: 10; font-family: 'Press Start 2P', cursive; }
        #overlay h1 { font-size: 100px; margin: 0 0 20px 0; color: #ffaa00; text-shadow: 4px 4px 0 #000, 0 0 40px rgba(255,170,0,0.6); letter-spacing: 5px; animation: pulse 2s infinite; line-height: 1.2; text-align: center; }
        @keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }
        button { padding: 25px 50px; font-size: 25px; cursor: pointer; background: linear-gradient(180deg, #ffcc00, #ff8800); color: #000; border: none; font-family: 'Press Start 2P', cursive; letter-spacing: 2px; border: 4px solid #fff; border-radius: 0; transition: 0.2s; box-shadow: 0 5px 20px rgba(255,170,0,0.4); }
        button:hover { transform: scale(1.05) translateY(-2px); background: linear-gradient(180deg, #fff, #ffcc00); box-shadow: 0 8px 30px rgba(255,170,0,0.6); }
        input { font-family: 'Press Start 2P', cursive; }

        #settings-icon:hover { transform: scale(1.1) rotate(90deg); }
        
        #damage-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; box-shadow: inset 0 0 0 0 rgba(255,0,0,0); transition: box-shadow 0.1s; pointer-events: none; }
        
        #minimap { position: absolute; bottom: 20px; right: 20px; width: 150px; height: 150px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.3); overflow: hidden; background: rgba(0,50,100,0.5); }
        #minimap canvas { width: 100%; height: 100%; }
        
        #combat-log { position: absolute; bottom: 100px; left: 20px; width: 300px; max-height: 150px; overflow: hidden; pointer-events: none; }
        .log-entry { color: white; font-size: 14px; padding: 3px 8px; background: rgba(0,0,0,0.4); margin-bottom: 2px; border-radius: 4px; animation: fadeIn 0.3s; opacity: 0.9; }
        .log-entry.damage { color: #ff6666; }
        .log-entry.heal { color: #66ff66; }
        .log-entry.event { color: #ffaa00; }
        @keyframes fadeIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 0.9; transform: translateX(0); } }

        /* New Styles for Pause Menu and Settings */
        #pause-menu { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 20; flex-direction: column; justify-content: center; align-items: center; font-family: 'Press Start 2P', cursive; color: white; }
        #pause-menu h2 { color: #ffaa00; margin-bottom: 40px; text-shadow: 4px 4px 0 #000; font-size: 40px; }
        
        .menu-btn { margin: 10px; width: 300px; padding: 20px; font-size: 18px; }
        
        #settings-modal { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 30; flex-direction: column; justify-content: center; align-items: center; font-family: 'Press Start 2P', cursive; color: white; }
        
        .setting-row { display: flex; align-items: center; justify-content: space-between; width: 500px; margin-bottom: 30px; }
        .setting-label { font-size: 16px; color: #aaa; }
        .setting-slider { width: 250px; cursor: pointer; }
/* Mobile Controls */
#mobile-controls {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#joystick-zone-left {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 40%;
    height: 40%;
    pointer-events: auto;
}

#joystick-zone-right {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40%;
    height: 40%;
    pointer-events: auto;
}

#mobile-jump-btn, #mobile-attack-btn {
    position: absolute;
    pointer-events: auto;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: bold;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    z-index: 101;
}

#mobile-jump-btn { bottom: 160px; right: 30px; }
#mobile-attack-btn { bottom: 80px; right: 160px; }

#mobile-jump-btn:active, #mobile-attack-btn:active {
    background: rgba(255, 170, 0, 0.5);
    transform: scale(0.95);
}

/* Mobile Adjustments */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls { display: block; }
    
    /* Move HUD elements out of the way */
    #hud-bottom { bottom: auto; top: 100px; left: 10px; flex-direction: column; transform: scale(0.7); transform-origin: top left; }
    #minimap { top: 10px; bottom: auto; right: 10px; width: 100px; height: 100px; }
    #combat-log { top: 100px; bottom: auto; left: 50%; transform: translateX(-50%); width: 80%; font-size: 10px; pointer-events: none; }
    #boss-bar-container { top: 50px; width: 90%; }
    
    /* Hide desktop prompts */
    #controls-icon { display: none; }
}


/* Improved Mobile Layout */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls { display: block; }
    
    /* Boss Bar: Top Center, smaller */
    #boss-bar-container { 
        top: 10px; 
        width: 50%; 
        left: 50%; 
        transform: translateX(-50%);
    }
    #boss-name { font-size: 12px; margin-bottom: 2px; }
    #boss-health-back { height: 15px; border-width: 2px; }
    
    /* Minimap: Top Right, smaller */
    #minimap { 
        top: 10px; 
        right: 10px; 
        bottom: auto; 
        width: 80px; 
        height: 80px; 
        border-width: 2px;
    }
    
    /* Stats: Top Left, smaller */
    #hud-top {
        top: 10px;
        left: 10px;
        right: auto;
        text-align: left;
        transform: scale(0.7);
        transform-origin: top left;
    }
    
    /* Inventory: Left Middle, vertical */
    #hud-bottom {
        top: 50%;
        left: 10px;
        bottom: auto;
        flex-direction: column;
        transform: translateY(-50%) scale(0.8);
        transform-origin: left center;
        gap: 5px;
    }
    
    /* Combat Log: Bottom Center, very small */
    #combat-log {
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 60%;
        font-size: 8px;
        max-height: 80px;
        pointer-events: none;
        text-align: center;
    }
    
    /* Hide desktop prompts */
    #controls-icon { display: none; }
    
    /* Adjust Buttons */
    #mobile-jump-btn { bottom: 120px; right: 20px; width: 60px; height: 60px; font-size: 8px; }
    #mobile-attack-btn { bottom: 40px; right: 100px; width: 60px; height: 60px; font-size: 8px; }
    
    /* Adjust Joysticks */
    #joystick-zone-left { bottom: 20px; left: 20px; width: 150px; height: 150px; }
    #joystick-zone-right { bottom: 20px; right: 20px; width: 150px; height: 150px; }
}


/* Mobile Menu & Cutscene Fixes */
@media (hover: none) and (pointer: coarse) {
    /* Menu Adjustments */
    #overlay h1 { font-size: 40px; margin-bottom: 10px; }
    #overlay p { font-size: 12px; padding: 0 20px; }
    #overlay input { width: 150px; font-size: 16px; padding: 10px; }
    #overlay button { padding: 15px 30px; font-size: 16px; }
    
    /* Fix overlapping footer text */
    #overlay > div[style*='bottom: 40px'] { bottom: 10px; font-size: 10px; }
    #settings-icon { bottom: 10px; left: 10px; width: 40px; height: 40px; }
    
    /* Cutscene Adjustments */
    #cutscene-layer > div:first-child {
        width: 150px;
        height: 150px;
        left: 10px;
        bottom: 150px; /* Move face up */
    }
    
    #cutscene-layer > div:nth-child(2) {
        left: 10px;
        right: 10px;
        bottom: 10px;
        min-height: 120px;
        font-size: 12px;
    }
    
    #beast-dialogue { font-size: 12px; }
    #skip-btn { padding: 5px 10px; font-size: 10px; }
}


/* Mobile Sprint Button */
#mobile-sprint-btn {
    position: absolute;
    pointer-events: auto;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: bold;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    z-index: 101;
    bottom: 180px;
    left: 30px;
}

#mobile-sprint-btn.active {
    background: rgba(255, 170, 0, 0.8);
    border-color: #fff;
}

/* Mobile HUD Adjustments - Right Side */
@media (hover: none) and (pointer: coarse) {
    /* Move Inventory to Right Side */
    #hud-bottom {
        top: 50%;
        left: auto;
        right: 10px; /* Move to right */
        bottom: auto;
        flex-direction: column;
        transform: translateY(-50%) scale(0.8);
        transform-origin: right center;
        gap: 10px;
        pointer-events: auto; /* Ensure clickable */
    }
    
    /* Ensure slots are touchable */
    .item-slot {
        pointer-events: auto;
    }
    
    /* Adjust Menu Footer for Mobile */
    #menu-footer {
        bottom: 10px;
        right: 10px;
        font-size: 8px;
        text-align: right;
    }
    
    /* Ensure Joysticks don't overlap HUD */
    #joystick-zone-right {
        bottom: 20px;
        right: 80px; /* Move left to avoid HUD */
        width: 120px;
        height: 120px;
    }
    
    #joystick-zone-left {
        bottom: 20px;
        left: 20px;
        width: 120px;
        height: 120px;
    }
    
    /* Adjust Action Buttons */
    #mobile-jump-btn { bottom: 100px; right: 100px; }
    #mobile-attack-btn { bottom: 40px; right: 180px; }
}


/* Menu Footer - Desktop Default */
#menu-footer {
    position: absolute;
    bottom: 20px;
    right: 20px;
    text-align: right;
    font-size: 12px;
    line-height: 1.5;
    color: #aaa;
}

/* Mobile Sprint Button */
#mobile-sprint-btn {
    position: absolute;
    pointer-events: auto;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: bold;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    z-index: 101;
    bottom: 180px;
    left: 30px;
}

#mobile-sprint-btn.active {
    background: rgba(255, 170, 0, 0.8);
    border-color: #fff;
}

/* Mobile HUD Adjustments - Right Side */
@media (hover: none) and (pointer: coarse) {
    /* Move Inventory to Right Side */
    #hud-bottom {
        top: 50%;
        left: auto;
        right: 10px; /* Move to right */
        bottom: auto;
        flex-direction: column;
        transform: translateY(-50%) scale(0.8);
        transform-origin: right center;
        gap: 10px;
        pointer-events: auto; /* Ensure clickable */
    }
    
    /* Ensure slots are touchable */
    .item-slot {
        pointer-events: auto;
    }
    
    /* Adjust Menu Footer for Mobile */
    #menu-footer {
        bottom: 10px;
        right: 10px;
        font-size: 8px;
        text-align: right;
    }
    
    /* Ensure Joysticks don't overlap HUD */
    #joystick-zone-right {
        bottom: 20px;
        right: 80px; /* Move left to avoid HUD */
        width: 120px;
        height: 120px;
    }
    
    #joystick-zone-left {
        bottom: 20px;
        left: 20px;
        width: 120px;
        height: 120px;
    }
    
    /* Adjust Action Buttons */
    #mobile-jump-btn { bottom: 100px; right: 100px; }
    #mobile-attack-btn { bottom: 40px; right: 180px; }
}


/* Force Menu Footer to Bottom Right on Mobile */
@media (hover: none) and (pointer: coarse) {
    #menu-footer {
        position: absolute !important;
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        width: auto !important;
        text-align: right !important;
        font-size: 8px !important;
        z-index: 100 !important;
    }
    
    #menu-footer p {
        margin: 2px 0 !important;
    }
}

