/* =========================================
   BATTLE UI V5 — mobile control layout tune
   Keeps mechanics and base fantasy skin intact.
   ========================================= */

#battle-action-panel {
    --battle-gap: 3px;
    --battle-item-size: clamp(40px, 10.8vw, 46px);
    --battle-scroll-width: clamp(108px, 29vw, 122px);
}

/* Top toolbar: Auto | (HP MP Scroll) — one horizontal row. */
#battle-action-panel .battle-toolbar-v5 {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: 30% 67% !important;
    grid-template-rows: auto !important;
    justify-content: space-between !important;
    align-items: end !important;
    column-gap: 0 !important;
}

#battle-action-panel .battle-toolbar-v5 > #ba-auto-attack-toggle {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    align-self: end !important;
    width: 72% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 4% !important;
    aspect-ratio: 1000 / 500 !important;
    font-size: clamp(7px, 2vw, 9px) !important;
    gap: 2px !important;
    transform: translateY(11px) !important;
}

#battle-action-panel .battle-toolbar-v5 > #ba-auto-attack-toggle::before {
    width: clamp(9px, 2.5vw, 12px) !important;
}

#battle-action-panel .battle-toolbar-v5 > .battle-consumables-v5 {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    align-self: end !important;
    width: max-content !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns:
        var(--battle-item-size)
        var(--battle-item-size)
        var(--battle-scroll-width) !important;
    column-gap: var(--battle-gap) !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Bottom command row: bigger Attack | skill grid. */
#battle-action-panel .battle-command-layout-v5 {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: 30% 67% !important;
    grid-template-rows: auto !important;
    grid-template-areas: "attack skills" !important;
    justify-content: space-between !important;
    column-gap: 0 !important;
    row-gap: 0 !important;
    align-items: start !important;
}

#battle-action-panel .battle-command-layout-v5 > #ba-basic-attack-btn {
    grid-area: attack !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    aspect-ratio: 1 / 1 !important;
    font-size: clamp(11px, 3vw, 13px) !important;
}

#battle-action-panel .battle-command-layout-v5 > .battle-skills-row {
    grid-area: skills !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    align-self: start !important;
    gap: var(--battle-gap) !important;
}

/* Keep the escape button anchored with the same basic spacing unit. */
#battle-action-panel .arena-escape-row {
    margin: 0 !important;
}

@media (max-width: 359px) {
    #battle-action-panel {
        --battle-item-size: 37px;
        --battle-scroll-width: 100px;
        --battle-gap: 2px;
    }

    #battle-action-panel .battle-toolbar-v5,
    #battle-action-panel .battle-command-layout-v5 {
        grid-template-columns: 30% 68% !important;
    }
}

@media (min-width: 600px) {
    #battle-action-panel .battle-toolbar-v5,
    #battle-action-panel .battle-command-layout-v5 {
        grid-template-columns: 125px 350px !important;
    }

    #battle-action-panel .battle-toolbar-v5 > #ba-auto-attack-toggle {
        width: 90px !important;
        transform: translateY(11px) !important;
    }
}
