/* --- Top UI --- */
.top-ui {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
}

.health-bar, .xp-bar {
    position: relative;
    width: 300px;
    height: 35px;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #555;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.player-hud-group {
    display: flex;
    /** @tweakable The gap between the health bar and money display. */
    gap: 10px;
    align-items: flex-start;
}

/** @tweakable Styles for the money display container. */
.money-display {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #555;
    border-radius: 18px;
    padding: 0 15px;
    height: 35px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    color: #ffdd44;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/** @tweakable Font size for the money icon. */
.money-icon {
    font-size: 20px;
    margin-right: 8px;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    transition: width 0.3s ease;
    width: 100%;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4444ff, #6666ff);
    transition: width 0.3s ease;
    width: 0%;
}

.health-text, .xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.stats {
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.stats div {
    margin-bottom: 5px;
}

/* --- Bottom UI --- */
.bottom-left-ui, .bottom-center-ui, .bottom-right-ui {
    position: absolute;
    bottom: 20px;
    display: flex;
    align-items: flex-end;
    gap: 20px;
    pointer-events: none;
}
.bottom-left-ui {
    left: 20px;
}
.bottom-center-ui {
    left: 50%;
    transform: translateX(-50%);
}
.bottom-right-ui {
    right: 20px;
}

.controls-hint {
    position: absolute;
    /* @tweakable vertical position of the controls hint text from the bottom of the screen */
    bottom: 110px;
    /* @tweakable horizontal position of the controls hint text from the right of the screen */
    right: 20px;
    text-align: right;
    font-size: 14px;
    color: #bbb;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    line-height: 1.4;
}

.grenade-ui {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

/* @tweakable styles for the new flare UI container */
.flare-ui {
    display: flex;
    gap: 10px;
    pointer-events: none;
    margin-bottom: 10px; /* Space between flares and grenades */
}

.flare-ui.hidden {
    display: none;
}

.flare-icon {
    width: 40px;
    height: 40px;
    background-image: url('/flare_icon.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    transition: all 0.3s ease;
}

.flare-icon.used {
    filter: grayscale(100%) opacity(0.4);
}

.grenade-icon {
    width: 40px;
    height: 40px;
    background-image: url('grenade_ui.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    transition: all 0.3s ease;
}

.grenade-icon.available::before {
    box-shadow: 
        inset 16px 0 0 -14px #6a8a6a,
        inset 0 16px 0 -14px #6a8a6a,
        inset -16px 0 0 -14px #6a8a6a,
        inset 0 -16px 0 -14px #6a8a6a,
        inset 12px 12px 0 -10px #6a8a6a,
        inset -12px 12px 0 -10px #6a8a6a,
        inset 12px -12px 0 -10px #6a8a6a,
        inset -12px -12px 0 -10px #6a8a6a,
        0 0 10px rgba(106, 138, 106, 0.3);
}

.grenade-icon.used {
    filter: grayscale(100%) opacity(0.4);
}

.ability-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ability-display.hidden {
    display: none;
}

.ability-icon {
    width: 60px;
    height: 60px;
    background-color: #222;
    border: 2px solid #88f;
    border-radius: 50%; 
    position: relative;
    overflow: hidden; 
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url('time_stop_icon.png');
    background-size: 70%;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 0 10px rgba(136, 136, 255, 0.5);
}

.ability-icon.on-cooldown {
    filter: grayscale(1);
    box-shadow: none;
}

.cooldown-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%; 
    background-color: rgba(100, 100, 255, 0.7);
    transition: height 0.1s linear;
}

.ability-key {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.ability-ammo-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-shadow: none;
}

#timeStopIcon {
    background-image: url('time_stop_icon.png');
}

#secondaryAbilityIcon {
    /* Default icon, will be overwritten by JS */
    background-image: url('/knife_icon.png'); 
    border-color: #ff8c00;
    box-shadow: 0 0 10px rgba(255, 140, 0, 0.5);
}

#bulletTimeIcon {
    background-image: url('/bullet_time_icon.png');
    border-color: #aaa;
    box-shadow: 0 0 10px rgba(220, 220, 220, 0.5);
}

#dashIcon {
    background-image: url('/asset/dash_icon.png');
    border-color: #aaa;
    box-shadow: 0 0 10px rgba(220, 220, 220, 0.5);
}

#shieldIcon {
    background-image: url('/asset/shield_icon.png');
    border-color: #8af;
    box-shadow: 0 0 10px rgba(136, 170, 255, 0.5);
}

.shield-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-shadow: none;
}

#finalStandIcon {
    background-image: url('/asset/final_stand_icon.png');
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .top-ui {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .health-bar, .xp-bar {
        width: 150px;
        height: 20px;
    }
    
    .controls-hint {
        display: none;
    }
}

/* --- Responsive & Mobile --- */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .top-ui {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .health-bar, .xp-bar {
        width: 150px;
        height: 20px;
    }
    
    .controls-hint {
        display: none;
    }

    /* --- New Mobile Ability Button Layout --- */

    .mobile-pause-btn {
        display: none; /* Hidden by default */
        position: absolute;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.7);
        border-radius: 50%;
        cursor: pointer;
        z-index: 15;
        pointer-events: auto;
        justify-content: space-evenly;
        align-items: center;
        padding: 0 12px;
    }

    .mobile-pause-btn span {
        display: block;
        width: 4px;
        height: 50%;
        background: white;
        border-radius: 2px;
    }

    body.is-mobile .mobile-pause-btn {
        display: flex;
    }

    body.is-mobile .bottom-left-ui,
    body.is-mobile .bottom-center-ui,
    body.is-mobile .bottom-right-ui {
        left: auto; /* Unset left positioning */
        transform: none; /* Unset transform */
        gap: 15px;
        align-items: flex-end;
        pointer-events: auto;
    }

    /* Dash is the primary ability, moved up from the corner */
    body.is-mobile .bottom-center-ui {
        right: 20px;
        bottom: 90px; /* Moved up from 20px to make space for pause */
        flex-direction: row-reverse; /* Puts Dash icon on the far right of its group */
    }

    /* Grenades/Time Stop are stacked vertically above Dash */
    body.is-mobile .bottom-left-ui {
        right: 20px;
        bottom: 180px; /* Moved up from 110px */
        flex-direction: column-reverse;
    }
    
    /* Shield and other passives go to the left of Dash */
    body.is-mobile .bottom-right-ui {
        right: 110px;
        bottom: 90px; /* Moved up from 20px */
        flex-direction: column-reverse;
    }

    body.is-mobile .grenade-ui {
        flex-direction: row-reverse;
        pointer-events: auto;
    }

    body.is-mobile .grenade-icon {
        pointer-events: auto;
        cursor: pointer;
    }

    body.is-mobile .ability-key {
        display: none;
    }

    /* Make icons bigger for touch */
    body.is-mobile .ability-icon,
    body.is-mobile .grenade-icon {
        width: 70px;
        height: 70px;
    }
}