/* Last layout layer: reserve HUD and controls separately from the live terrain. */
#game{--hud-bottom:174px}
#game[data-screen=battle] .hud-top{padding-bottom:12px}
#game[data-screen=battle] .hud-top .heading{gap:10px}
#game[data-screen=battle] .hud-top .mission-meta{min-width:0}
#game[data-screen=battle] .hud-top .mission-meta #stage-label{overflow-wrap:anywhere}
.power-strip{display:grid;grid-template-columns:1fr 1fr .75fr;gap:6px;margin-top:9px;direction:rtl}
.power-cell{display:grid;grid-template-columns:25px minmax(0,1fr);grid-template-rows:auto auto;align-items:center;gap:0 5px;padding:5px 7px;border:1px solid #769cb466;border-bottom:3px solid #071d2c;border-radius:11px;background:linear-gradient(145deg,#244f66ed,#123448ef);min-width:0;text-shadow:none}
.power-cell>img{width:25px;height:29px;object-fit:contain;grid-row:1/3;filter:drop-shadow(0 2px 1px #06132199)}
.power-cell>span{font-size:10px;line-height:1.5;color:#c2dce1;white-space:nowrap}
.power-cell>b{font:800 15px/1.1 Arial,sans-serif;color:#eaf4db;font-variant-numeric:tabular-nums}
.power-cell small{font-size:8px;color:#ddc09b;margin-inline-start:2px}
.enemy-power{background:linear-gradient(145deg,#684b4aed,#3c2c39ef);border-color:#c49b7f66}
.enemy-power>b{color:#ffe0c1}.castle-tier{border-color:#c0a96488}.castle-tier>b{color:#ffe5a5}
#game[data-screen=battle] .view-tools{display:grid;grid-template-columns:repeat(2,44px);gap:6px;left:max(12px,env(safe-area-inset-left));top:max(12px,env(safe-area-inset-top));right:auto}
#game[data-screen=battle] .view-tools .icon-button{width:44px;height:44px;min-width:44px;min-height:44px;padding:4px;border-radius:12px}
#game[data-screen=battle] .view-tools .ui-art{max-width:100%;max-height:100%}
@media(max-width:540px){
 #game{--hud-bottom:174px}
 #game[data-screen=battle] .hud-top{width:100%;max-width:none;padding:max(9px,env(safe-area-inset-top)) 12px 10px;background:linear-gradient(#102c40ef,#183b4cbd 86%,#183b4c00)}
 #game[data-screen=battle] .hud-top .mission-meta #stage-label{font-size:12px;line-height:1.45;margin:0 0 3px}
 #game[data-screen=battle] .hud-top .mission-meta>span{font-size:10px;line-height:1.4}#game[data-screen=battle] .hud-top .mission-meta>small{display:none}
 #game[data-screen=battle] .hud-top .wallet{flex:none}#game[data-screen=battle] .hud-top .wallet #coins{font-size:19px}
 .base-health{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:3px 10px;margin-top:7px}
 .base-health>.base-row{grid-column:1;grid-row:1;font-size:10px;line-height:1.35}.base-health>.health-track{grid-column:1;grid-row:2;height:6px}
 .base-health>.base-row.enemy{grid-column:2}.base-health>.health-track.enemy{grid-column:2}
 .power-strip{margin-top:7px;gap:5px}.power-cell{padding:4px 5px;grid-template-columns:23px minmax(0,1fr);column-gap:4px}.power-cell>img{width:23px;height:27px}.power-cell>span{font-size:9px}.power-cell>b{font-size:14px}
 #game[data-screen=battle] .view-tools{top:calc(var(--hud-bottom) + 7px);grid-template-columns:repeat(2,44px);gap:6px}
 .build-entry{left:max(12px,env(safe-area-inset-left));bottom:146px;width:146px;min-height:46px;padding:8px 12px;font-size:11px}.build-entry img{width:26px;height:26px}
 .placement-dock,.tower-dock,.quick-build{max-height:calc(100dvh - var(--hud-bottom) - 18px);overflow-y:auto;overscroll-behavior:contain}
}
@media(max-width:350px){#game[data-screen=battle] .hud-top{padding-inline:9px}.power-strip{gap:4px}.power-cell{padding-inline:4px}.power-cell>span{font-size:8px}.power-cell small{font-size:7px}.power-cell>img{width:21px}.build-entry{bottom:140px}}
@media(max-height:550px) and (min-width:541px){
 #game[data-screen=battle] .hud-top{right:max(8px,env(safe-area-inset-right));left:auto;top:0;width:300px;max-width:300px;padding:8px 10px 10px}
 #game[data-screen=battle] .hud-top .mission-meta #stage-label{font-size:11px}#game[data-screen=battle] .hud-top .mission-meta>small{display:none}#game[data-screen=battle] .hud-top .mission-meta>span{font-size:9px}
 #game[data-screen=battle] .hud-top .wallet .ui-art{width:24px;height:24px}#game[data-screen=battle] .hud-top .wallet #coins{font-size:17px}
 .base-health{display:grid;grid-template-columns:1fr 1fr;gap:3px 9px;margin-top:5px}.base-health>.base-row{grid-column:1;grid-row:1;font-size:9px}.base-health>.health-track{grid-column:1;grid-row:2;height:5px}.base-health>.base-row.enemy,.base-health>.health-track.enemy{grid-column:2}
 .power-strip{margin-top:6px;gap:4px}.power-cell{padding:3px 4px;grid-template-columns:20px minmax(0,1fr);column-gap:3px}.power-cell>img{width:20px;height:25px}.power-cell>span{font-size:8px}.power-cell>b{font-size:13px}.power-cell small{font-size:7px}
 #game[data-screen=battle] .view-tools{top:max(10px,env(safe-area-inset-top));left:max(10px,env(safe-area-inset-left));display:grid;grid-template-columns:repeat(4,44px);gap:6px;max-width:194px}
 .build-entry{left:max(10px,env(safe-area-inset-left));bottom:max(10px,env(safe-area-inset-bottom));width:165px;min-height:48px}
 .quick-build,.placement-dock,.tower-dock{max-height:calc(100dvh - 145px);overflow-y:auto;overscroll-behavior:contain}
}
@media(prefers-reduced-motion:reduce){.power-cell{transition:none;animation:none}}
