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] {
    -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;
}

.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 {
    position: absolute;
    bottom: 50px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
}

#stick-left {
    left: 40px;
}

#stick-right {
    right: 40px;
}

.joystick-nub {
    width: 50px;
    height: 50px;
    background: rgba(255, 165, 0, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #ffa500;
}

#mobile-actions {
    position: absolute;
    bottom: 180px;
    /* v41.6 Lowered to be right above joystick */
    right: 20px;
    display: flex;
    flex-direction: column;
    /* Stacked look might be better or grid? User says 5 buttons. */
    gap: 10px;
    pointer-events: auto;
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    overflow: hidden;
}

.action-btn svg {
    pointer-events: none;
    fill: #fff;
}

#btn-attack {
    background: #ff4444;
}

#btn-jump {
    background: #44ff44;
}

#btn-switch {
    background: #4444ff;
    font-size: 16px;
}

@media (max-width: 800px) {
    #mobile-controls {
        display: none;
    }

    /* Wait for JS */
    .builder-layout {
        flex-direction: column;
    }

    .builder-view {
        height: 40%;
        width: 100%;
        pointer-events: auto;
    }

    .builder-panel {
        width: 100%;
        height: 60%;
        border-right: none;
        border-top: 2px solid #00aaff;
    }
}

#win-layer,
#loose-layer {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 60;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: auto;
}

#help-btn {
    position: absolute;
    top: 20px;
    right: 190px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffa500;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    z-index: 45;
}

#help-modal {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #ffa500;
    padding: 20px;
    z-index: 60;
    pointer-events: auto;
    text-align: center;
}

#ctl-toggle-btn {
    position: absolute;
    top: 20px;
    right: 240px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #00aaff;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    z-index: 45;
}

#help-modal ul {
    text-align: left;
    color: #ccc;
    line-height: 1.6;
}

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

.weapon-slot {
    width: 50px;
    height: 50px;
    border: 2px solid #555;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 0.8rem;
    transition: all 0.2s;
    text-transform: uppercase;
    font-weight: bold;
}

.weapon-slot.active {
    width: 70px;
    height: 70px;
    border-color: #00aaff;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 0 10px rgba(0, 170, 255, 0.5);
    transform: translateY(-5px);
}

.weapon-slot.prev,
.weapon-slot.next {
    opacity: 0.7;
}

@media (max-width: 800px) {
    .builder-layout {
        flex-direction: column;
    }

    .builder-view {
        width: 100%;
        height: 45%;
        /* Slightly more space for character */
        pointer-events: auto;
    }

    .builder-panel {
        width: 100%;
        height: 55%;
        border-right: none;
        border-top: 2px solid #00aaff;
        padding: 10px;
    }

    /* Move Start Button up slightly */
    #main-start-btn {
        top: 10px !important;
        width: 160px !important;
        height: 50px !important;
        font-size: 16px !important;
    }
}