/* One viewport contract, applied after the legacy layouts. Browser chrome is
   hidden by the Fullscreen API; this sheet fills the space actually granted. */
[hidden]{display:none!important}
[data-fullscreen]{white-space:nowrap;flex-shrink:0;touch-action:manipulation}
.mobile-header-tools{display:flex;align-items:center;gap:6px}
.title-fullscreen{position:absolute;top:max(16px,env(safe-area-inset-top));right:max(16px,env(safe-area-inset-right));z-index:4;min-height:44px;padding:8px 16px}
#fullscreen-status{position:fixed;z-index:1000;left:12px;right:12px;bottom:max(12px,env(safe-area-inset-bottom));margin:0;padding:12px;background:#122735f5;border:1px solid #c5ae77;border-radius:8px;font-size:13px;pointer-events:none}
#tactical-tools{pointer-events:none}
#tactical-tools>button,.tactical-view{pointer-events:auto}
#view-options{min-width:44px;min-height:44px;font-size:12px;white-space:nowrap}
#tactical-tools:not(.expanded) .tactical-view{display:none}
.tactical-view{margin-top:4px;width:max-content;max-width:100%;background:#142936f5;padding:4px;border-radius:6px;box-shadow:0 4px 12px #0005}
.status-card[hidden]{display:none!important}
@media(max-width:1100px),(pointer:coarse){
 html,body{width:100%;height:var(--game-height,100dvh);overflow:hidden;overscroll-behavior:none}
 #game-main{height:var(--game-height,100dvh);max-height:none;margin:0;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);gap:0}
 #game-main header{padding:0 10px;min-height:44px;height:44px;border-radius:0}
 #game-main header h1{font-size:16px;white-space:nowrap}.mobile-header-tools button{min-height:44px;font-size:12px;padding:5px 9px}
 #game-main .field{border:0;border-radius:0;min-height:0}
 body[data-game-mode=battle] #game-main{grid-template-rows:44px minmax(0,1fr) 54px}
 body[data-game-mode=battle] #game-main .game{min-height:0}
 body[data-game-mode=battle] #game-main .field{min-height:0;grid-template-rows:24px minmax(0,1fr) 24px}
 body[data-game-mode=battle] #tactical-tools{top:5px;left:5px;right:5px}
 body[data-game-mode=battle] .tile-legend{top:5px;right:0;font-size:10px;padding:5px;gap:4px}
 body[data-game-mode=battle] #battle-hud{display:flex;gap:5px;padding:5px}
 body[data-game-mode=battle] .status-card{flex:1;min-width:0;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto;gap:3px 7px;padding:6px}
 body[data-game-mode=battle] .status-label{grid-column:1/-1;font-size:10px;margin:0;line-height:12px}
 body[data-game-mode=battle] .status-identity{grid-column:1/-1;height:auto;min-height:30px;align-items:center;margin:0}
 body[data-game-mode=battle] .status-identity .avatar{display:block;width:29px;height:32px;flex:none}
 body[data-game-mode=battle] .status-identity strong{font-size:13px;line-height:16px}
 body[data-game-mode=battle] .status-identity span{font-size:10px;line-height:13px}
 body[data-game-mode=battle] .status-resource,body[data-game-mode=battle] .status-resource.mp{display:flex;grid-column:auto;grid-row:auto;width:auto;margin:0;padding:0 0 4px;font-size:10px;line-height:13px}
 body[data-game-mode=battle] .status-resource b{font-size:11px}
 body[data-game-mode=battle] .status-numbers{grid-column:1/-1;font-size:10px;line-height:14px;padding:0;margin:0;border:0}
 body[data-game-mode=battle] .status-numbers b{font-size:11px}
 body[data-game-mode=battle] .status-equipment{grid-column:1/-1;font-size:10px;line-height:13px;margin:0}
 body[data-game-mode=battle] #game-main aside{max-height:100px;padding:4px 6px}
 body[data-game-mode=battle] #field-controls{height:54px;padding:5px 7px}
 body[data-game-mode=battle] #field-interact,body[data-game-mode=battle] #touch-cancel{min-height:44px;font-size:12px}
 #scene{height:var(--game-height,100dvh);padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
 #scene .cinema canvas{top:0;bottom:0;height:100%;width:100%;max-height:none}
 #scene .cinema{border-radius:0}
 #scene .cinema-heading{background:#112a3699;pointer-events:none}
 #scene .cinema-unit{top:26px;height:66px;min-height:0;max-width:220px;background:#142c37cc;border-color:#8aa3aa66;pointer-events:none}
 #scene .scene-status-name strong{font-size:13px!important}#scene .scene-status-name small{font-size:10px!important}
 #scene .scene-status-stats{display:none}#scene .scene-status-resource{font-size:10px;margin-top:3px}
 #scene .scene-status-resource b{font-size:10px!important}
}
@media(max-width:1100px) and (orientation:landscape),(pointer:coarse) and (orientation:landscape){
 #game-main,body[data-game-mode=battle] #game-main{--panel-width:clamp(176px,24vw,220px);grid-template-columns:minmax(0,1fr) var(--panel-width);grid-template-rows:44px minmax(0,1fr)}
 body[data-game-mode=battle] #game-main header{grid-column:1/-1;height:44px}
 body[data-game-mode=battle] #game-main .game{grid-column:1/-1;grid-row:2;grid-template-columns:minmax(0,1fr) var(--panel-width);height:100%}
 body[data-game-mode=battle] .battle-panel{overflow:auto;padding-bottom:54px;min-height:0}
 body[data-game-mode=battle] #battle-hud{display:flex;flex-direction:column;flex:none}
 body[data-game-mode=battle] .status-card{grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto auto auto;padding:5px}
 body[data-game-mode=battle] #game-main aside{flex:none;width:auto;max-height:none;overflow:visible}
 body[data-game-mode=battle] #move-guide{font-size:11px;padding:2px 0;line-height:1.35}
 body[data-game-mode=battle] #commands button{font-size:12px;min-height:44px}
 body[data-game-mode=battle] #field-controls{width:var(--panel-width);height:54px;right:env(safe-area-inset-right);bottom:env(safe-area-inset-bottom);background:#152c37;border-top:1px solid #607680}
 body[data-game-mode=battle] .map-top,body[data-game-mode=battle] .map-bottom{padding:2px 8px;font-size:11px}
 body[data-game-mode=battle] .map-bottom #hint{font-size:11px}
 body[data-game-mode=hub] #game-main .game{grid-column:1/-1;grid-row:2;height:100%}
 body[data-game-mode=hub] #game-main .chapter{top:72px;max-width:calc(100% - 105px);left:8px}
 body[data-game-mode=hub] #mobile-dock{position:absolute;left:8px;bottom:max(8px,env(safe-area-inset-bottom));display:flex;border:0}
 body[data-game-mode=hub] #mobile-dock button{min-width:52px;min-height:44px;font-size:12px}
 body[data-game-mode=hub] #field-controls{position:absolute;right:8px;bottom:max(8px,env(safe-area-inset-bottom));height:48px;max-width:44%;padding:0}
 body[data-game-mode=hub] .field{grid-template-rows:24px minmax(0,1fr) 58px}
 #scene[open]{display:grid;grid-template-columns:minmax(0,1fr) 158px;grid-template-rows:auto minmax(0,1fr) auto;gap:5px}
 #scene .cinema{grid-column:1;grid-row:1/-1}#scene .cinema canvas{top:0;height:100%}
 #scene .cinema-controls{gap:4px;padding:3px;max-height:100%;overflow:auto}
 #scene .cinema-controls button,#scene .cinema-controls label{font-size:11px;padding:5px 3px;min-height:40px}
 #scene .cinema-controls #scene-next{min-height:44px!important}
 #scene #scene-text{font-size:12px!important;padding:5px!important;max-height:48px}
 #scene-presets{overflow:auto;min-height:0;max-height:100%;grid-template-columns:repeat(2,1fr)}
 #scene-presets button{font-size:10px;min-height:36px}
 #scene #scene-look{grid-column:1/-1}
}
