body {
    margin: 0;
    overflow: hidden;
    background: #050505;
    user-select: none;
    font-family: 'Orbitron', sans-serif;
    touch-action: none;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    display: block;
}

.ui-layer {
    position: absolute;
    pointer-events: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Typography & Bases */
select,
button,
input {
    width: 100%;
    padding: 10px;
    background: #222;
    border: 1px solid #555;
    color: #fff;
    font-family: 'Orbitron';
    font-size: 1rem;
    cursor: pointer;
    box-sizing: border-box;
}

button.start-btn {
    background: #ffa500;
    color: #000;
    font-weight: bold;
    border: none;
    margin-top: 20px;
    font-size: 1.2rem;
}

label {
    display: block;
    text-align: left;
    color: #aaa;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.control-group {
    margin: 15px 0;
}

.section-title {
    color: #00aaff;
    font-size: 0.9rem;
    margin: 20px 0 10px 0;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Builder UI */
#builder-layer {
    display: none;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 55;
}

.builder-layout {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: row;
    pointer-events: none;
}

.builder-panel {
    width: 350px;
    height: 100%;
    background: rgba(10, 10, 10, 0.95);
    border-right: 2px solid #00aaff;
    padding: 20px;
    overflow-y: auto;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    flex-shrink: 0;
    cursor: default;
}

.builder-header {
    font-family: 'Cinzel';
    font-size: 1.5rem;
    color: #333;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.builder-view {
    flex-grow: 1;
    pointer-events: auto;
    cursor: grab;
    position: relative;
    /* v44.38: Ensure Start Button centers here, not screen */
}

.slider-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #888;
}

input[type=range] {
    /* v4.5.30: Fixed Appearance Warning */
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    margin-top: 5px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #00aaff;
    border-radius: 50%;
    cursor: pointer;
}

.palette-row {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.palette-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #444;
    cursor: pointer;
}

.palette-btn.selected {
    border-color: #fff;
    box-shadow: 0 0 8px #fff;
}

.custom-picker-wrap {
    position: relative;
    width: 30px;
    height: 30px;
}

.custom-picker-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #333;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #555;
    cursor: pointer;
    font-size: 20px;
    line-height: 0;
}

.hidden-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* HUD */
#hud-layer {
    display: none;
    z-index: 40;
}

.hud-stat {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #00ff00;
    /* Bright Green */
    font-size: 1.5rem;
    font-family: 'Cinzel';
    text-shadow: 0 0 5px #000, 0 0 10px #000;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 5px;
    z-index: 20000;
    /* Ensure above everything */
}

.bar-container {
    position: absolute;
    width: 300px;
    height: 20px;
    border: 2px solid #555;
    background: #222;
    pointer-events: none;
}

.health-fill {
    width: 100%;
    height: 100%;
    transition: width 0.1s;
}

#player-bar {
    top: 40px;
    left: 10px;
    border-color: #00ff00;
}

#player-health {
    background: #00ff00;
}

#boss-bar {
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    border-color: #ff0000;
    display: none;
}

#boss-health {
    background: #ff0000;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#minimap-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 150px;
    height: 150px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #ffa500;
    border-radius: 50%;
    overflow: hidden;
}

canvas#minimap {
    width: 100%;
    height: 100%;
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.joystick-zone {
    width: 150px;
    height: 150px;
    position: absolute;
    bottom: 50px;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

#stick-left {
    left: 40px;
}

#stick-right {
    right: 40px;
}

/* HUD Buttons & Icons - Standardized */
.hud-btn-icon,
.action-btn,
#ctl-toggle-btn,
#help-btn,
#btn-toggle-debug,
#btn-respawn {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 255, 255, 0.9) !important;
    background-size: 60% !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.8) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    display: flex !important;
    /* Ensure they take space */
    align-items: center;
    justify-content: center;
    font-size: 0 !important;
    /* Hide any fallback text */
    /* Hide any fallback text */
    color: transparent !important;
    position: relative;
    /* Context for ::after */
    overflow: hidden !important;
    /* Clip to circle */
}

/* v4.5.19: Icon Layering to remove black backgrounds */
/* v4.5.30: Simplified Icon Layering (Direct background) */
/* Since SVGs are transparent, we don't need the ::after hack anymore. */

/* Joystick Nubs - Gray */
.joystick-nub {
    width: 50px;
    height: 50px;
    background: rgba(136, 136, 136, 0.9);
    /* Gray */
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #888;
    border: 2px solid #bbb;
}

/* Mobile Action Grid */
#mobile-actions {
    position: absolute;
    bottom: 220px;
    /* Moved up to clear joystick */
    right: 20px;
    display: grid !important;
    grid-template-columns: 60px 60px 60px;
    grid-template-rows: 60px 60px 60px;
    gap: 15px;
    pointer-events: auto;
    z-index: 100;
}

/* Remove SVGs as we use background images now */
.action-btn svg {
    display: none !important;
}

/* --- BUTTON SPECIFIC STYLES --- */

/* JUMP (Green) */
#btn-jump {
    background-color: rgba(68, 255, 68, 0.5);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z'/%3E%3C/svg%3E") !important;
    grid-column: 2;
    grid-row: 1;
}

/* PREV WEAPON (Light Blue) */
#btn-prev {
    background-color: rgba(0, 191, 255, 0.5);
    /* Light Blue */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3E%3C/svg%3E") !important;
    grid-column: 1;
    grid-row: 2;
}

/* ATTACK (Red + Crossed Swords) */
#btn-attack {
    background-color: rgba(255, 68, 68, 0.5);
    /* Red */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6.91 7.41L13.5 14l-1.41 1.41L5.5 8.83l-1.09 1.09L2.83 8.33l4.59-4.59L8.83 5.15 7.74 6.24l.59.59.58-.59.83.83-.83 1.34zM19.59 13l-1.59 1.59-4.59-4.59 1.59-1.59 4.59 4.59zM16 11l-3 3 2 2 3-3-2-2zM5.41 17.59l4.59 4.59 1.41-1.41-4.59-4.59-1.41 1.41zM21.17 2.83l-4.59 4.59 1.09 1.09-1.41 1.41-6.59-6.59L11.09 1.91l4.59 4.59 1.09-1.09 1.41-1.41L21.17 2.83z'/%3E%3C/svg%3E") !important;
    grid-column: 2;
    grid-row: 2;
}

/* NEXT WEAPON (Light Blue) */
#btn-next {
    background-color: rgba(0, 191, 255, 0.5);
    /* Light Blue */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'/%3E%3C/svg%3E") !important;
    grid-column: 3;
    grid-row: 2;
}

/* SPRINT (Purple) */
#btn-sprint {
    background-color: rgba(138, 43, 226, 0.5);
    /* Purple */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M13.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM9.8 8.9L7 23h2.1l1.8-8 2.1 2v6h2v-7.5l-2.1-2 .6-3C14.8 12 16.8 13 19 13v-2c-1.9 0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5.1-.8.1L6 8.3V13h2V9.6l1.8-.7'/%3E%3C/svg%3E") !important;
    grid-column: 2;
    grid-row: 3;
    /* Match indicator color */
}

/* --- TOP/SIDE BUTTONS --- */

/* Info / Briefing (Left of Radar) */
#help-btn {
    position: absolute;
    top: 20px;
    right: 180px;
    background-color: rgba(0, 191, 255, 0.8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z'/%3E%3C/svg%3E") !important;
    z-index: 20005 !important;
}

/* Joystick Toggle (Left of Info) */
#ctl-toggle-btn {
    position: absolute;
    top: 20px;
    right: 250px;
    background-color: rgba(100, 100, 100, 0.8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M21 9H3V5h18v4zm0-6H3v2h18V3zM3 19h9v-4H3v4zm11 0h7v-4h-7v4zM3 13h18v-2H3v2z'/%3E%3C/svg%3E") !important;
    z-index: 20005 !important;
}

/* Settings (Beneath Radar) */
#btn-toggle-debug {
    position: absolute;
    top: 180px;
    right: 65px;
    /* Centered under 150px radar approx */
    background-color: rgba(68, 68, 68, 0.8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L5.09 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z'/%3E%3C/svg%3E") !important;
    z-index: 20005 !important;
    display: flex !important;
}

/* Respawn (Beneath Settings) */
#btn-respawn {
    position: absolute;
    top: 250px;
    right: 65px;
    background-color: rgba(255, 69, 0, 0.8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z'/%3E%3C/svg%3E") !important;
    z-index: 20005 !important;
    display: flex !important;
}

/* Weapon Carousel Updates */
/* Weapon Carousel Updates */
#weapon-carousel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.weapon-slot {
    width: 90px;
    height: 90px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #555;
    background-size: cover;
    background-position: center;
    transition: all 0.2s ease;
    border-radius: 5px;
    /* Square with slight round */
}

.weapon-slot.active {
    width: 140px;
    height: 140px;
    border-color: #00aaff;
    background-color: rgba(0, 170, 255, 0.3);
    /* Light Blue Tint */
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.8);
    z-index: 101;
}

@media (max-width: 800px) {

    /* Mobile adjustments... */
    #mobile-controls {
        display: block;
        /* Ensure visible on mobile */
    }
}

/* Win/Loss Screens - RESTORED */
#win-layer,
#loose-layer {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 30000 !important;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: auto;
}

#win-layer h1 {
    color: #00ff00;
    font-size: 4rem;
    text-shadow: 0 0 20px #00ff00;
}

#loose-layer h1 {
    color: #ff0000;
    font-size: 4rem;
    text-shadow: 0 0 20px #ff0000;
}