/* Battlefield rails and in-frame tools. Loaded after the language overrides. */
body:not(.site-page):has(#battle-frame){height:100dvh;min-height:0;overflow:hidden}
body:not(.site-page):has(#battle-frame) .app{display:flex;flex-direction:column;max-width:1360px;height:100dvh;min-height:0;padding:0 max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
body:not(.site-page):has(#battle-frame) .topbar{flex:0 0 62px;height:62px}
body:not(.site-page):has(#battle-frame) .layout{display:block;flex:1 1 0;min-height:0;padding:7px 0 0;margin:0}
body:not(.site-page):has(#battle-frame) .play-column{display:flex;flex-direction:column;height:100%;min-width:0;min-height:0;width:100%}
body:not(.site-page):has(#battle-frame) .play-column> :not(.game-shell){flex-shrink:0}
body:not(.site-page):has(#battle-frame) .play-caption{display:none}
body:not(.site-page) .layout #battle-frame{flex:1 1 0;width:100%;height:auto;min-height:0;max-height:none;border-radius:14px}
#battle-frame{--hud-inset:9px;--hud-top:9px;--hud-bottom:9px;--rail-width:68px;--dock-height:48px;--rail-paper:#fff9e7e6;--rail-ink:#795f49}
#battle-frame .compact-hud-left,#battle-frame .compact-hud-right{top:var(--hud-top);width:var(--rail-width);max-width:var(--rail-width);gap:6px;align-items:start;grid-template-columns:minmax(0,1fr)}
#battle-frame:has(#boss-hud:not([hidden])) .compact-hud-left,#battle-frame:has(#boss-hud:not([hidden])) .compact-hud-right{top:var(--hud-top);width:var(--rail-width)}
#battle-frame .compact-hud-left{left:var(--hud-inset)}
#battle-frame .compact-hud-left>*,#battle-frame .compact-hud-right>*{min-width:0;max-width:100%;box-sizing:border-box}
#battle-frame .compact-hud-left>*{width:100%}
#battle-frame .compact-hud-right{right:var(--hud-inset);justify-items:center}
#battle-frame .compact-hud-left>.live-pill{width:100%;padding:4px 3px;background:var(--rail-paper);border-radius:5px;text-align:center;font-size:10px;line-height:1.25;white-space:normal;overflow:visible;letter-spacing:0}
#battle-frame .progress-hud,#battle-frame .evolution-hud{width:100%;padding:6px 5px;border:1px solid #bba17d8f;border-radius:6px;box-shadow:none;background:var(--rail-paper);text-align:center}
#battle-frame .progress-hud>div:first-child,#battle-frame .evolution-hud>div:first-child{display:grid;grid-template-columns:minmax(0,1fr);min-width:0;justify-content:center;gap:3px;margin:0 0 5px;font-size:9px;line-height:1.2}
#battle-frame #objective-label{display:block;font-size:9px;line-height:1.2;white-space:normal;overflow:visible}
#battle-frame #objective-label b{display:block;font-size:19px;line-height:1.1;font-variant-numeric:tabular-nums}
#battle-frame #objective-label small{display:none}
#battle-frame #progress-text{font-size:9px;color:#9a8067;line-height:1.2}
#battle-frame .progress-track{height:3px;border:0}
#battle-frame #campaign-challenge{display:grid;justify-items:center;justify-self:stretch;width:100%;max-width:100%;gap:2px;padding:6px 3px;border-radius:6px;background:var(--rail-paper);font-size:9px;text-align:center}
#battle-frame #campaign-challenge::before{content:none}
#battle-frame #challenge-progress{display:grid;gap:2px;font-size:9px;line-height:1.2;white-space:normal;overflow:visible}
#battle-frame #challenge-progress b{font-size:17px;font-variant-numeric:tabular-nums}
#battle-frame #challenge-progress span{font-size:9px;font-weight:500}
#battle-frame .enemy-threat:not([hidden]){display:flex;flex-direction:column-reverse;justify-content:center;align-items:center;gap:2px;width:100%;padding:5px 2px;margin:0;border:1px solid #c6a6a078;border-radius:6px;background:#fff2ecde;white-space:normal;text-align:center;font-size:9px}
#battle-frame .enemy-threat b{font-size:17px;line-height:1.1;font-variant-numeric:tabular-nums}
#battle-frame .compact-hud-actions{display:grid;justify-items:center;gap:5px;width:100%}
#battle-frame .compact-hud-actions #auto-btn,#battle-frame .compact-hud-actions #pause-btn{display:flex;align-items:center;justify-content:center;min-height:44px;height:44px;padding:4px;gap:3px;border:1px solid #bba17dad;border-radius:7px;background:var(--rail-paper);box-shadow:none;color:var(--rail-ink)}
#battle-frame .compact-hud-actions #auto-btn{width:100%;font-size:0}
#battle-frame .compact-hud-actions #auto-btn::after{content:'Auto';order:0;font-size:10px}
#battle-frame .compact-hud-actions #auto-btn b{order:1;font-size:10px;margin:0}
#battle-frame .compact-hud-actions #auto-btn .game-icon{display:none}
#battle-frame .compact-hud-actions #pause-btn{width:44px;flex-basis:44px}
#battle-frame .evolution-hud{padding:5px 3px}
#battle-frame .evolution-hud span{font-size:8px}
#battle-frame #score-value{display:block;font-size:12px;font-variant-numeric:tabular-nums}
#battle-frame #evolution-count{font-size:9px;white-space:normal;line-height:1.25}
#battle-frame .battle-rail-button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;width:44px;min-height:44px;padding:4px 2px;border:1px solid #bba17dad;border-radius:7px;background:var(--rail-paper);color:var(--rail-ink);text-decoration:none;font-size:9px;line-height:1.2;pointer-events:auto;touch-action:manipulation}
#battle-frame .battle-rail-button .game-icon{width:22px;height:22px;object-fit:contain}
#battle-frame .compact-hud-help{position:relative;top:auto;left:auto;bottom:auto;max-width:none;width:44px;z-index:13}
#battle-frame .compact-hud-help>summary{width:44px;height:44px;border-radius:7px;box-shadow:none;font-size:10px;background:var(--rail-paper)}
#battle-frame .compact-hud-help-body{left:auto;right:0;bottom:auto;top:49px;width:min(300px,calc(100cqw - 24px));max-height:max(90px,calc(var(--compact-shell-height,500px) - 310px));border-radius:9px}
#battle-frame #combat-hud{top:var(--hud-top);left:50%;right:auto;width:min(290px,calc(100% - 2 * (var(--rail-width) + var(--hud-inset) + 9px)));padding:5px 7px;border-radius:7px;box-shadow:none;background:var(--rail-paper)}
#battle-frame .combat-hud-row{gap:5px;flex-wrap:nowrap;min-height:14px}
#battle-frame .player-health-label::after{font-size:9px}
#battle-frame .player-health-meter{height:7px;min-width:24px}
#battle-frame #player-health-value{min-width:43px;font-size:9px;line-height:1}
#battle-frame #boss-hud{padding-top:4px;margin-top:4px;border-top:1px solid #ceb99c75}
#battle-frame .boss-hud-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 5px;align-items:center}
#battle-frame #boss-name{max-width:none;min-width:0;white-space:normal;overflow:visible;font-size:8px;line-height:1.15}
#battle-frame #boss-health-value{font-size:8px;white-space:nowrap}
#battle-frame #boss-health-meter{grid-column:1/-1;order:3;width:100%;height:5px}

/* One flat toolbar inside the field. Drawers overlay it without resizing play. */
#battle-frame .battle-toolbar{position:absolute;left:var(--hud-inset);right:var(--hud-inset);bottom:var(--hud-bottom);z-index:14;display:flex;align-items:stretch;height:var(--dock-height);padding:0;border:1px solid #b49874;border-radius:7px;background:#fff8e5f5;box-shadow:0 2px 8px #78634418;pointer-events:none}
#battle-frame .battle-toolbar #arsenal-dock{position:static;flex:1 1 0;min-width:0;width:auto;max-width:none;height:100%;max-height:none;transform:none;isolation:auto;color:var(--rail-ink)}
#battle-frame #arsenal-toggle{position:relative;display:grid;grid-template-columns:34px minmax(0,1fr) auto 11px;gap:7px;align-items:center;width:100%;height:100%;min-height:44px;padding:4px 8px;border:0;border-radius:6px 0 0 6px;box-shadow:none;background:transparent}
#battle-frame #arsenal-current-art{display:grid;width:34px;height:34px;border:0;border-radius:4px;background:#f4e8cb}
#battle-frame #arsenal-current-art img,#battle-frame #arsenal-current-art svg{width:33px;height:30px}
#battle-frame #arsenal-current-name{font-size:11px;line-height:1.15;white-space:normal;overflow:visible;text-overflow:clip}
#battle-frame #arsenal-current-dps{font-size:9px;line-height:1.2;white-space:normal;overflow:visible;text-overflow:clip}
#battle-frame .arsenal-toggle-copy{gap:2px}
#battle-frame #arsenal-badge{position:static;top:auto;right:auto;align-self:center;width:auto;height:auto;max-width:48px;min-width:0;padding:4px;border-radius:4px;font-size:9px;line-height:1.2;background:#f8dea1}
#battle-frame #growth-toggle{display:flex;flex:0 0 82px;align-items:center;justify-content:center;gap:4px;min-width:0;min-height:44px;padding:4px 7px;border:0;border-left:1px solid #c9b18f;border-radius:0 6px 6px 0;background:#e7efd9;color:#65734e;font-size:11px;font-weight:750;line-height:1.2;pointer-events:auto;touch-action:manipulation;box-shadow:none}
#battle-frame #growth-toggle .game-icon{width:23px;height:23px}
#battle-frame #growth-toggle[aria-expanded='true']{background:#d3e6bd}
#battle-frame .battle-toolbar #arsenal-dock[data-open='true']{position:absolute;left:50%;right:auto;bottom:-1px;top:auto;transform:translateX(-50%);width:min(440px,calc(100cqw - 20px));height:calc(var(--compact-shell-height,500px) - 92px);max-height:680px;z-index:18}
#battle-frame #arsenal-dock[data-open='true']>#arsenal-toggle{display:none}
#battle-frame #arsenal-panel{border-radius:10px;box-shadow:0 3px 20px #614d3229}
#battle-frame .compact-fusion-reminder{bottom:calc(100% + 8px);max-width:min(280px,calc(100cqw - 170px));border-radius:7px}
#battle-frame .compact-fusion-reminder button{border-radius:5px}

/* Old upgrade IDs and delegated click listeners live in this paused drawer. */
body:not(.site-page) #battle-frame #growth-panel{display:flex;flex-direction:column;position:absolute;top:auto;left:auto;right:var(--hud-inset);bottom:calc(var(--hud-bottom) + var(--dock-height) + 8px);z-index:15;width:min(390px,calc(100% - 18px));height:auto;min-height:0;max-height:calc(100% - 95px);margin:0;padding:0;overflow:hidden;border:1.5px solid #b69b79;border-radius:10px;background:#fff9eafa;box-shadow:0 4px 20px #604c3526;color:var(--rail-ink);pointer-events:auto}
#battle-frame #growth-panel .growth-header{display:flex;flex:0 0 auto;align-items:center;justify-content:space-between;gap:10px;padding:7px 10px;background:#f6ecd5;border-bottom:1px solid #d5c0a1}
#battle-frame #growth-panel .growth-header h3{margin:0;font-size:15px}
#battle-frame #growth-panel .growth-header small{display:block;margin-top:3px;font-size:10px;color:#968067}
#battle-frame #close-growth{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;border:1px solid #c3a89a;border-radius:7px;background:#f3dfd1;color:#8b6b5c;touch-action:manipulation}
#battle-frame #close-growth .game-icon{width:26px;height:26px}
#battle-frame .growth-body{min-height:0;overflow:auto;overscroll-behavior:contain;padding:8px;touch-action:pan-y;scrollbar-width:thin}
#battle-frame #growth-panel .tabs,#battle-frame #growth-panel .panel-heading,#battle-frame #growth-panel .panel-footer{display:none}
#battle-frame #growth-panel .tab-panel{padding:0;overflow:visible}
#battle-frame #growth-panel #upgrades{display:grid;grid-template-columns:minmax(0,1fr);gap:7px}
#battle-frame #growth-panel .upgrade{display:grid;grid-template-columns:minmax(0,1fr) minmax(90px,auto);align-items:center;gap:7px;margin:0;padding:7px;border:1px solid #ddcbb0;border-radius:6px;background:#fffdf4;box-shadow:none}
#battle-frame #growth-panel .upgrade-top{display:flex;flex-wrap:nowrap;align-items:center;gap:7px;min-width:0}
#battle-frame #growth-panel .upgrade-icon{flex:0 0 30px;width:30px;height:30px;padding:2px;border:0;border-radius:5px}
#battle-frame #growth-panel .upgrade h3{margin:0;font-size:12px;line-height:1.25}
#battle-frame #growth-panel .upgrade p{display:none}
#battle-frame #growth-panel .upgrade .level{margin:0 0 0 auto;padding:3px;font-size:9px;white-space:nowrap;border-radius:4px}
#battle-frame #growth-panel .upgrade button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:90px;min-height:44px;margin:0;padding:5px 7px;border:0;border-radius:5px;font-size:11px;line-height:1.2;box-shadow:none}
#battle-frame #growth-panel .upgrade button span{display:flex;align-items:center;justify-content:center;gap:3px;font-size:10px}
#battle-frame #growth-panel .upgrade button .game-icon{width:16px;height:16px}
#battle-frame #growth-panel .rebirth-card{display:grid;grid-template-columns:30px minmax(0,1fr);gap:6px;margin:9px 0 0;padding:9px;border-radius:6px;box-shadow:none}
#battle-frame #growth-panel .rebirth-icon{width:30px;height:30px;font-size:22px}
#battle-frame #growth-panel .rebirth-card .section-kicker,#battle-frame #growth-panel .rebirth-card h3{display:none}
#battle-frame #growth-panel .rebirth-card p{margin:0;font-size:10px;line-height:1.45}
#battle-frame #growth-panel #rebirth-btn{grid-column:1/-1;min-height:44px;margin:3px 0 0;border-radius:5px;font-size:11px;box-shadow:none}
#battle-frame:has(#growth-panel:not([hidden])) #joystick,#battle-frame:has(#growth-panel:not([hidden])) #fire-btn{pointer-events:none;opacity:.35}
#battle-frame:has(#growth-panel:not([hidden])) .compact-fusion-reminder{display:none}
body.arsenal-open #battle-frame #growth-toggle{visibility:hidden;pointer-events:none}
#battle-frame.combat-failed .battle-toolbar,#battle-frame:has(#campaign-result:not([hidden])) .battle-toolbar{visibility:hidden;pointer-events:none}
#battle-frame #cat-audio-subtitle{bottom:calc(var(--hud-bottom) + var(--dock-height) + 14px);max-width:min(360px,calc(100% - 180px));padding:4px 7px;font-size:10px;line-height:1.35;border-radius:5px}
#battle-frame #evolution-banner{top:82px;max-width:calc(100% - 2 * (var(--rail-width) + 16px));border-radius:8px}

@container battle-hud (max-width:760px){
 #battle-frame{--rail-width:60px}
 #battle-frame .compact-hud-left,#battle-frame .compact-hud-right{width:60px;max-width:60px}
 #battle-frame #arsenal-current-name{font-size:10px}
 #battle-frame #arsenal-toggle{grid-template-columns:31px minmax(0,1fr) auto 9px;gap:5px;padding:4px 6px}
 #battle-frame #arsenal-current-art{width:31px;height:31px}
 #battle-frame #arsenal-badge{font-size:8px;max-width:39px;padding:3px}
 #battle-frame #growth-toggle{flex-basis:76px;font-size:10px;padding:4px 5px}
}
@media(pointer:coarse),(max-width:730px){
 body:not(.site-page):has(#battle-frame) .topbar{flex-basis:56px;height:56px}
 #battle-frame{--rail-width:60px;--hud-inset:7px;--hud-top:7px;--hud-bottom:7px}
 body:not(.site-page) .game-shell#battle-frame #joystick,body:not(.site-page) .game-shell#battle-frame #fire-btn{bottom:calc(var(--hud-bottom) + var(--dock-height) + 16px);width:72px;height:72px;z-index:9;touch-action:none}
 body:not(.site-page) .game-shell#battle-frame #joystick{left:12px}
 body:not(.site-page) .game-shell#battle-frame #fire-btn{right:12px}
 #battle-frame #joystick-thumb{left:14px;top:14px}
 #battle-frame #fire-btn small{display:none}
 #battle-frame #fire-btn .fire-label{gap:2px;font-size:13px}
 #battle-frame #fire-btn .game-icon{width:22px;height:22px}
}
@media(max-width:380px){
 #battle-frame{--hud-inset:5px;--rail-width:56px}
 #battle-frame .compact-hud-left,#battle-frame .compact-hud-right,#battle-frame:has(#boss-hud:not([hidden])) .compact-hud-left,#battle-frame:has(#boss-hud:not([hidden])) .compact-hud-right{width:56px;max-width:56px}
 #battle-frame #arsenal-badge{position:absolute;top:3px;right:6px;width:6px;height:6px;padding:0;border:0;border-radius:50%;font-size:0}
 #battle-frame #arsenal-toggle{grid-template-columns:29px minmax(0,1fr) 9px;gap:4px}
 #battle-frame #arsenal-current-art{width:29px;height:29px}
 #battle-frame #arsenal-current-art img{width:28px;height:27px}
 #battle-frame #growth-toggle{flex-basis:68px}
 #battle-frame #growth-toggle .game-icon{width:19px;height:19px}
}
@media(max-height:560px) and (orientation:landscape){
 body:not(.site-page):has(#battle-frame) .topbar{flex:0 0 44px;height:44px}
 body:not(.site-page):has(#battle-frame) .layout{padding-top:3px}
 #battle-frame{--rail-width:98px;--hud-top:5px;--hud-bottom:5px}
 #battle-frame .compact-hud-left,#battle-frame .compact-hud-right,#battle-frame:has(#boss-hud:not([hidden])) .compact-hud-left,#battle-frame:has(#boss-hud:not([hidden])) .compact-hud-right{width:98px;max-width:98px;gap:4px;grid-template-columns:repeat(2,minmax(0,1fr))}
 #battle-frame .compact-hud-left>.live-pill{grid-column:1/-1;padding:2px;font-size:9px}
 #battle-frame .progress-hud{grid-column:1;padding:4px 3px}
 #battle-frame #campaign-challenge{grid-column:2;padding:4px 2px}
 #battle-frame .enemy-threat:not([hidden]){grid-column:1/-1;flex-direction:row;gap:5px;padding:3px}
 #battle-frame .compact-hud-actions{grid-column:1/-1;display:flex;justify-content:space-between;gap:4px}
 #battle-frame .compact-hud-actions #auto-btn{flex:1;min-width:0}
 #battle-frame .evolution-hud{display:none}
 #battle-frame .compact-hud-help{grid-column:2}
 #battle-frame .compact-hud-help-body{top:49px;max-height:max(90px,calc(var(--compact-shell-height,300px) - 157px))}
 #battle-frame #evolution-banner{top:75px}
 #battle-frame .battle-toolbar #arsenal-dock[data-open='true']{height:calc(var(--compact-shell-height,300px) - 22px);max-height:none}
 body:not(.site-page) #battle-frame #growth-panel{max-height:calc(100% - 68px);bottom:calc(var(--hud-bottom) + var(--dock-height) + 5px)}
 body.menu-open:not(.site-page):has(#battle-frame) .site-nav{right:max(7px,env(safe-area-inset-right));justify-content:center}
}
