/* Authoritative battle layout. World geometry lives in rules.js; camera in battle-view.js.
   Desktop: field + dossier. Portrait: field + scrolling roster. Short landscape: command rail. */
#game{display:flex;flex-direction:column;min-width:0;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);box-sizing:border-box}
#game.hidden{display:none}
#game .topbar{flex:none;height:52px;min-height:52px;padding:4px 10px;gap:8px;box-sizing:border-box}
#game .topbar .brand{margin-right:0}
#game .topbar .blue{margin-left:auto}
#game .topbar button{min-width:44px;min-height:44px;padding:6px}
#game #mobileMenu{display:none}
#app:has(#game:not(.hidden)) #audioControls{top:auto;bottom:8px;left:auto;right:12px;display:none}
/* Sound controls move into the dossier through the controller while playing. */
#game .phasebar{flex:none;min-height:28px;height:28px;padding:0 8px}
#game #turnStatus{min-height:44px;height:auto;padding:0 10px;gap:8px;box-sizing:border-box}
#game #turnStatus button{min-height:44px}
#game #flowNotice{min-width:0}
#game main{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 280px;gap:8px;padding:8px;overflow:hidden}
#game #boardWrap{display:flex;flex-direction:column;min-width:0;min-height:0;width:auto;height:auto;flex:auto;border:2px solid #756c4c;overflow:hidden}
#battleViewport{position:relative;flex:1;min-height:0;min-width:0;overflow:hidden}
#game canvas{display:block;width:100%;height:100%;touch-action:none;image-rendering:pixelated;cursor:crosshair}
#game canvas.panning{cursor:grab}
#cameraControls{flex:none;display:flex;align-items:center;gap:4px;min-height:44px;padding:0 4px;border-top:1px solid #514d38;background:#20251b}
#cameraControls button{min-width:44px;min-height:44px;padding:5px 9px;font:11px Arial;color:#eddda7;background:#2c3024;border:1px solid #766b47;border-radius:0;box-shadow:none}
#cameraControls button[aria-pressed=true]{background:#595033;border-color:#eed386}
#cameraControls button:disabled{opacity:.4}
#cameraHint{font:11px Arial;color:#bcb59b;margin-left:5px}
#game #sideRail{display:flex;flex-direction:column;min-height:0;max-height:none;width:auto;flex:auto;margin:0;overflow:auto}
#battleDetails{background:#20231b;border:1px solid #60583f}
#battleDetails>summary{padding:14px 10px;min-height:44px;box-sizing:border-box;cursor:pointer;font:11px Arial;letter-spacing:1px;color:#e2cc8f}
#game #phaseGuide{height:auto;min-height:0;display:flex;flex-wrap:wrap;padding:10px;gap:5px}
#game #phaseGuide span{font:12px/1.4 Arial;flex-basis:100%}
#game #lastEvent{height:auto;flex-wrap:wrap;padding:10px;gap:5px}
#game #lastEvent button{min-height:44px}
#game #unitPanel{width:auto;max-height:none}
#game #battleLog{display:block;min-height:100px;max-height:220px;overflow:auto}
#game #actionPreview{flex:none;min-height:0;max-height:30dvh;overflow:auto;padding:8px 12px;gap:8px;flex-direction:row;align-items:center}
#game .orderButtons{flex-wrap:wrap;justify-content:flex-end;gap:5px;max-width:55%}
#game .orderButtons button{min-height:44px;padding:8px 12px;width:auto;margin:0;font:11px Arial;border-radius:0}
#game #next{background:#b39a56;color:#191d16}
#game .bottom{display:none}
#game #orderDetail{font:12px/1.35 Arial}
#detailsToggle{display:none}
#game #terrainToggle{max-width:180px}
#game #battleAudio{display:flex;gap:8px;padding:8px}
#game #battleAudio button{min-width:60px;min-height:44px}
@media(max-width:750px),(orientation:landscape) and (max-height:600px){
 #game .topbar{height:48px;min-height:48px;padding:2px 6px;gap:4px}
 #game .topbar .brand,#game #leaderboardBtn{display:none}
 #game .topbar .blue{margin-left:0}
 #game .score{flex:1;padding:0 4px;gap:4px}
 #game .score small{display:none}
 #game .score b{font-size:24px}
 #game .round{min-width:66px;width:auto}
 #game .round b{font-size:16px}
 #game .round small{font-size:8px}
 #game #turnStatus{font-size:10px;padding:0 6px;gap:5px}
 #game #flowNotice:empty{display:none}
 #game #terrainToggle{max-width:120px;font-size:9px}
 #detailsToggle{display:block}
 #game main{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) 66px;padding:4px;gap:4px}
 #game #sideRail{display:contents}
 #game #battleRoster{display:flex;overflow-x:auto;overflow-y:hidden;gap:8px;min-width:0;scrollbar-width:thin}
 #game .rosterSide{flex:0 0 auto}
 #game .rosterSide>strong{font-size:8px;line-height:12px;margin:0 0 2px}
 #game .rosterSide>div{display:flex;margin:0;gap:3px}
 #game .rosterSide button{width:91px;min-height:44px;font-size:10px;gap:3px;padding:3px}
 #game .rosterSide small{font-size:9px;margin-top:2px}
 #game .rosterPortrait{display:block;flex:0 0 24px;width:24px;height:32px}
 #battleDetails{position:absolute;z-index:35;right:8px;left:8px;top:124px;bottom:12px;overflow:auto;box-shadow:0 6px 16px #000b}
 #battleDetails:not([open]){display:none}
 #battleDetails>summary{position:sticky;top:0;background:#343727;z-index:1}
 #game #actionPreview{flex-direction:column;align-items:stretch;padding:6px 8px;max-height:28dvh;gap:5px}
 #game .orderButtons{max-width:none}
 #game #orderSummary{font-size:14px}
 #game #orderDetail{margin:2px 0 0;font-size:11px}
 #cameraHint{display:none}
 #cameraControls{justify-content:center}
 #game #unitPanel .statgrid{position:static;display:grid;grid-template-columns:repeat(3,1fr)}
}
@media(orientation:landscape) and (max-height:600px){
 #game{display:grid;grid-template-columns:minmax(0,1fr) 270px;grid-template-rows:48px auto minmax(0,1fr) auto;gap:0}
 #game .topbar{grid-column:1 / -1;grid-row:1}
 #game .phasebar{grid-column:1;grid-row:2}
 #game #turnStatus{grid-column:2;grid-row:2;align-self:start;min-height:44px;flex-wrap:wrap;padding:2px 6px;gap:4px}
 #game #flowNotice{display:none}
 #game main{display:contents}
 #game #boardWrap{grid-column:1;grid-row:3 / 5;margin:4px;min-height:0}
 #game #battleRoster{grid-column:2;grid-row:3;align-self:start;margin:0 6px;max-height:100%;display:block;overflow:auto}
 #game .rosterSide>div{display:grid;grid-template-columns:repeat(4,minmax(0,1fr))}
 #game .rosterSide button{width:auto;min-width:0;font-size:9px;overflow:hidden}
 #game .rosterPortrait{display:none}
 #game .rosterSide>strong{margin:2px 0}
 #game #actionPreview{grid-column:2;grid-row:4;max-height:45dvh;overflow:auto;padding:6px}
 #game .orderButtons button{padding:6px;font-size:10px}
 #game #battleDetails{top:50px;left:auto;width:min(360px,90%);bottom:8px}
 #game #orderDetail{font-size:10px}
}

#trainingInstruction{font:12px/1.4 Arial;color:#f1d68e;margin:0 0 5px}
@media(orientation:landscape) and (max-height:600px){
 #game .score small{display:block;font:9px Arial;letter-spacing:.5px;max-width:100px}
 #game .score.blue:before,#game .score.red:after{display:none}
 #game #turnStatus:has(#pauseEnemy:not([hidden])){font-size:9px;gap:2px}
 #game #turnStatus:has(#pauseEnemy:not([hidden])) #terrainToggle{max-width:86px;padding:3px}
}
