/* Gameplay occupies the visible viewport. Only the optional settings panel scrolls. */
html.battle-active, body.battle-active { width: 100%; height: 100%; height: 100dvh; min-height: 0; overflow: hidden; overscroll-behavior: none; }
body.battle-active { position: fixed; inset: 0; padding: 0; }
.battle-active .arena-screen { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr) auto; gap: 6px; width: 100%; max-width: none; height: 100%; height: 100dvh; margin: 0; padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); overflow: hidden; background: #080d1a; }
.battle-active .battle-toolbar { position: relative; z-index: 6; grid-row: 1; display: flex; align-items: center; flex-wrap: nowrap; justify-content: space-between; gap: 10px; margin: 0; min-width: 0; }
.battle-toolbar .back-btn, .battle-options > summary { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px; border: 1px solid #455570; border-radius: 6px; color: #f2f5fc; background: #152137; font-size: 11px; cursor: pointer; white-space: nowrap; }
.battle-toolbar-title { min-width: 0; overflow: hidden; color: #f3bd67; font-size: 13px; font-weight: 900; font-style: italic; white-space: nowrap; text-overflow: ellipsis; }
.battle-options > summary { list-style: none; }
.battle-options > summary::-webkit-details-marker { display: none; }
.battle-options-panel { position: absolute; z-index: 10; top: 50px; right: 0; width: min(560px, 100%); max-height: calc(100dvh - 82px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); padding: 15px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #6a7c97; border-radius: 8px; background: #101a2ff5; box-shadow: 0 12px 40px #0009; color: #d6e2f2; font-size: 12px; line-height: 1.6; }
.battle-options-panel h2 { font-size: 15px; }
.battle-options-panel .music-controls { margin: 0; padding: 10px; }
.battle-active .arena-screen .game-frame { grid-row: 2; width: 100%; min-width: 0; min-height: 0; max-height: 100%; height: 100%; margin: 0; border-radius: 9px; }
.battle-active .battle-viewport { width: 100%; height: 100%; min-height: 0; }
.battle-active .arena-screen #gameCanvas { width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; }
.battle-active .healing-inventory { position: absolute; z-index: 4; bottom: 10px; left: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; width: min(260px, calc(50% - 16px)); margin: 0; pointer-events: none; }
.battle-active .healing-slot { gap: 6px; padding: 6px 7px; border-radius: 5px; background: #09231cce; backdrop-filter: blur(3px); }
.battle-active .healing-thumbnail { width: 27px; height: 27px; border-radius: 4px; }
.battle-active .healing-slot > b { font-size: 8px; }
.battle-active .healing-slot > span { font-size: 9px; line-height: 1.35; }
.battle-active .healing-inventory > p { display: none; }
.battle-active .battle-viewport > .arena-note { position: absolute; z-index: 4; right: 9px; bottom: 9px; width: min(420px, 43%); margin: 0; padding: 5px 7px; border-radius: 4px; background: #101a2aaf; color: #e2edf9; font-size: 10px; line-height: 1.4; text-align: right; pointer-events: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.battle-active .arena-screen > .combat-help, .battle-active .arena-screen > .arena-note { display: none; }
.battle-active .touch-controls { grid-row: 3; margin: 0; gap: 6px; min-height: 0; }
.battle-active .touch-tip { display: none; }
.battle-active .touch-player { padding: 3px 4px 4px; border-radius: 6px; container-type: normal; }
.battle-active .touch-player legend { padding: 0 4px; font-size: 9px; line-height: 12px; }
.battle-active .touch-player-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 3px; }
.battle-active .touch-movement, .battle-active .touch-actions { display: contents; }
.battle-active .touch-button { grid-column: auto !important; grid-row: auto !important; min-height: 44px; height: 44px; padding: 3px; border-radius: 6px; font-size: 10px; }
.battle-active .touch-movement .touch-action-0, .battle-active .touch-movement .touch-action-1, .battle-active .touch-movement .touch-action-3 { font-size: 21px; }
.battle-active .touch-controls[data-two-player="true"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.battle-active .result-overlay { padding: 12px; }
.battle-active .result-panel { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 600px) {
    .battle-toolbar-title { font-size: 10px; }
    .battle-active .healing-inventory { left: 6px; bottom: 6px; width: min(220px, calc(65% - 12px)); }
    .battle-active .healing-slot { padding: 3px 5px; gap: 4px; }
    .battle-active .healing-thumbnail { width: 22px; height: 22px; }
    .battle-active .healing-slot > b { font-size: 7px; }
    .battle-active .healing-slot > span { font-size: 8px; }
    .battle-active .battle-viewport > .arena-note { right: 5px; bottom: 5px; width: 30%; font-size: 8px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    .battle-active .healing-inventory { width: min(220px, 37%); bottom: 5px; left: 5px; }
    .battle-active .healing-slot { padding: 3px 5px; }
    .battle-active .healing-thumbnail { width: 20px; height: 20px; }
    .battle-active .healing-slot > span { font-size: 8px; }
    .battle-active .battle-hud-overlay { top: 5px; left: 6px; right: 6px; }
    .battle-active .game-frame .hud-portrait { width: 30px; height: 30px; }
    .battle-active .hud-fighter { grid-template-columns: 30px minmax(0, 1fr); }
    .battle-active .hud-right { grid-template-columns: minmax(0, 1fr) 30px; }
}
