/* =========================================
   BATTLE FLOW UI
   Restored pre-battle transition + post-battle result screen.
   Does not change the battle arena layout.
   ========================================= */

body.battle-scroll-locked {
    overflow: hidden !important;
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
}

body.battle-scroll-locked #game-log-shell,
body.battle-scroll-locked #main-bottom-nav {
    display: none !important;
}

#battle-transition-overlay,
#battle-result-overlay {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .88);
    color: #fff;
}

/* =========================================
   PRE-BATTLE TRANSITION
   ========================================= */

#battle-transition-overlay {
    z-index: 3000;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}

.battle-transition-icon {
    font-size: 48px;
    line-height: 1;
}

.battle-transition-text {
    font-size: 20px;
    font-weight: 700;
}

/* =========================================
   POST-BATTLE RESULT
   ========================================= */

#battle-result-overlay {
    z-index: 1900;
    overflow-y: auto;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(8, 5, 3, .88) !important;
    backdrop-filter: blur(2px);
}

.battle-result-card {
    width: min(100%, 420px);
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 18px;
    color: #f3dfac !important;
    background:
        radial-gradient(circle at 50% 0%, rgba(131, 84, 35, .28), transparent 44%),
        linear-gradient(180deg, #332015 0%, #1b120d 55%, #120c09 100%) !important;
    border: 2px solid #9b6b2f !important;
    border-radius: 14px !important;
    box-shadow:
        0 0 0 2px rgba(39, 24, 13, .92),
        0 12px 36px rgba(0, 0, 0, .7),
        inset 0 0 24px rgba(205, 145, 59, .08) !important;
    font-family: Georgia, "Times New Roman", serif;
}

.battle-result-title {
    margin: 0 0 14px;
    text-align: center;
    color: #f4ce73 !important;
    text-shadow: 0 2px 3px #000;
    letter-spacing: .04em;
}

.battle-result-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.battle-result-stat {
    padding: 8px;
    text-align: center;
    color: #f5e5bd !important;
    background: rgba(14, 9, 6, .64) !important;
    border: 1px solid rgba(184, 126, 52, .55) !important;
    border-radius: 7px;
}

.battle-result-drops-title {
    margin: 10px 0 7px;
    font-weight: 700;
    color: #eac66e !important;
}

.battle-result-card {container-type:inline-size}
.battle-result-drops {
    --loot-slot:calc((100cqw - 24px) / 4);
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    grid-auto-rows:var(--loot-slot);
    gap:8px;
    max-height:calc(var(--loot-slot) * 2.5 + 16px);
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-width:none;
    touch-action:pan-y;
}
.battle-result-drops::-webkit-scrollbar {display:none}
.battle-result-drop {
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;
    min-width:0;min-height:0;
    width:100%;height:100%;
    box-sizing:border-box;
    padding:0;
    --item-rarity-inset:15%;
    --item-rarity-radius:10%;
    cursor:pointer;
    font:inherit;
    color:#f0dfb4 !important;
    background:url('../assets/ui/frames/inventory-slot-frame.webp') center/100% 100% no-repeat !important;
    border:0 !important;
    border-radius:0;
    box-shadow:none;
}
.battle-result-drop img {position:relative;z-index:1;display:block;width:72%;height:72%;object-fit:contain;pointer-events:none}
.battle-result-drop [hidden] {display:none!important}
.battle-result-drop-fallback {font-size:11px;line-height:1.15;overflow-wrap:anywhere;max-height:100%;overflow:hidden}
.battle-result-drop-count {
    position:absolute;z-index:2;right:13%;bottom:12%;
    padding:1px 3px;border-radius:3px;background:rgba(8,5,3,.88);
    color:#fff0bd;font:bold 12px/1.2 system-ui,sans-serif;pointer-events:none;
}
.battle-result-drop:focus-visible {outline:2px solid #f4ce73;outline-offset:-3px}
@supports not (width:1cqw) {
    .battle-result-drops {--loot-slot:clamp(38px,calc((100vw - 96px) / 4),89px)}
}
.battle-result-drops:has(.battle-result-empty) {display:block;max-height:none}
.battle-result-empty {
    padding: 8px 0;
    color: #cbb98e !important;
}

.battle-result-return {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    color: #fff0bd !important;
    background: linear-gradient(180deg, #6d4722, #3b2716) !important;
    border: 1px solid #b17b35 !important;
    border-radius: 8px;
    box-shadow: inset 0 0 8px rgba(255, 212, 120, .08) !important;
}

.battle-result-return:active,
.battle-result-drop:active {
    filter: brightness(1.12);
}

@media (max-width: 390px) {
    #battle-result-overlay {
        padding: 12px;
    }

    .battle-result-card {
        padding: 14px;
    }

    .battle-result-title {
        font-size: 22px;
    }
}