/* No reserved header/taskbar rows: scene owns the container. */
#recruitment-portrait{background:center/cover no-repeat url('/play/commander-portrait.svg')}
#recruitment-dialog:has(#recruitment-card:not([hidden])) .recruitment-wheel-frame{display:none}
body.immersive{position:relative;display:block;container-type:inline-size}
body.immersive main{height:100%;width:100%}
body.immersive #connected{grid-template-rows:minmax(0,1fr)}
body.immersive #hud{position:absolute;top:env(safe-area-inset-top,0px);left:env(safe-area-inset-left,0px);width:min(350px,100%);z-index:15;background:none;border:0;box-shadow:none;padding:4px}
body.immersive #compact-player-bar{width:100%}
body.immersive #player-details{top:100%;width:min(380px,calc(100cqw - 8px));max-height:calc(100dvh - 120px);right:auto}
body.immersive #rail{position:absolute;bottom:env(safe-area-inset-bottom,0px);left:0;right:0;display:flex;justify-content:center;gap:4px;background:none;border:0;box-shadow:none;padding:4px;z-index:12;pointer-events:none}
body.immersive #rail>*{pointer-events:auto;flex:0 1 76px;min-width:0}
body.immersive #rail>button{min-height:44px;font-size:.75rem;white-space:nowrap}
body.immersive #rail .ui-icon{display:none}
#scene-more>summary{list-style:none;min-height:44px;padding:12px 8px;border:1px solid #89734d;background:#203038;border-radius:6px;cursor:pointer;font-size:.75rem;text-align:center}
.scene-menu,#scene-tasks{background:#172a30fa;border:1px solid #ae945f;border-radius:8px;box-shadow:0 6px 24px #0009;padding:8px}
.scene-menu{position:absolute;right:4px;bottom:100%;width:220px;display:grid;gap:5px}
#scene-more:not([open]) .scene-menu{display:none}
#scene-activity{position:absolute;z-index:13;bottom:calc(56px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);max-width:calc(100% - 16px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-height:44px;font-size:.8rem}
#scene-tasks{position:absolute;z-index:16;left:8px;bottom:calc(104px + env(safe-area-inset-bottom));width:min(400px,calc(100% - 16px));max-height:calc(100% - 165px);overflow:auto}
#scene-tasks>div{display:grid;gap:4px;margin-top:6px}
#scene-tasks .activity-controls{grid-template-columns:repeat(2,minmax(0,1fr))}
body.immersive #world-view{position:relative;display:block;height:100%}
body.immersive #world{height:100%;width:100%}
body.immersive #world-view>.controls{position:absolute;top:54px;right:4px;z-index:3;background:#182a2dbb;border-radius:6px;max-width:calc(100% - 8px)}
body.immersive #world-context{position:absolute;top:104px;right:8px;pointer-events:none;font-size:.7rem}
body.immersive #city-tools{top:54px;right:4px;left:auto}
body.immersive #buildings-nav{top:104px;bottom:auto;right:4px;left:auto}
body.immersive #settlement-nav{top:154px;bottom:auto;right:4px;left:auto}
body.immersive #overview.composing #world-view{margin-right:0}
body.immersive #panel{inset:54px 8px calc(104px + env(safe-area-inset-bottom));max-height:none}
body.immersive #panel.farming{top:auto;bottom:calc(104px + env(safe-area-inset-bottom));height:260px;max-height:calc(100% - 160px);left:auto;right:4px;width:min(410px,calc(100% - 8px))}
@media(max-height:500px){body.immersive #panel.farming{top:54px;bottom:calc(80px + env(safe-area-inset-bottom));height:auto;max-height:none}body.immersive #scene-activity{left:4px;transform:none;max-width:40%;bottom:56px}body.immersive:has(#panel.farming:not([hidden])) #scene-activity{visibility:hidden}}
@container(max-width:450px){body.immersive #rail>button{font-size:.7rem;padding:4px}body.immersive #hud{width:min(310px,100%)}body.immersive #world-view>.controls{gap:3px}body.immersive #world-view>.controls button{padding:4px;font-size:.65rem}}
/* Open controls own their space; background navigation must not cover them. */
body.immersive:has(#panel:not([hidden])) #scene-tasks,
body.immersive:has(#panel:not([hidden])) #scene-activity,
body.immersive:has(#city-placement:not([hidden])) #scene-tasks,
body.immersive:has(#city-placement:not([hidden])) #scene-activity,
body.immersive:has(#city-placement:not([hidden])) #rail,
body.immersive:has(#city-placement:not([hidden])) #city-menu{visibility:hidden;pointer-events:none}
body.immersive #city-placement{z-index:20;bottom:max(8px,env(safe-area-inset-bottom));max-height:calc(100% - 70px);overflow:auto;box-sizing:border-box}

/* Desktop navigation: Alliance is the middle of five equal-height tabs. */
@media (any-hover:hover) and (any-pointer:fine){
 body.immersive #rail{top:50%;bottom:auto;left:max(4px,env(safe-area-inset-left));right:auto;transform:translateY(-50%);flex-direction:column;width:92px;padding:4px;gap:4px}
 body.immersive #rail>*{flex:0 0 44px;width:84px;min-height:44px;box-sizing:border-box}
 body.immersive #rail>button{padding:6px;font-size:.75rem}
 body.immersive #scene-more>summary{height:44px;box-sizing:border-box;padding:12px 6px}
 body.immersive #scene-more .scene-menu{left:100%;right:auto;bottom:0;width:min(220px,calc(100cqw - 112px));max-height:calc(100dvh - 70px);overflow:auto}
 body.immersive #rail>#retry{position:absolute;bottom:100%;left:4px;height:auto}
 body.immersive #panel{left:104px}
 body.immersive #panel.city-workspace{left:auto}
 body.immersive #scene-tasks{left:104px;width:min(400px,calc(100% - 112px))}
}
@media (any-hover:hover) and (any-pointer:fine){@container(max-width:849px){body.immersive #panel.city-workspace{left:104px}}}

/* World-only on-hand totals and compact map controls. Panels remain above them. */
body.immersive #world-rss{position:absolute;top:54px;right:8px;z-index:1;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;width:min(480px,calc(100% - 16px));margin:0;pointer-events:none}
#world-rss>div{min-width:0;padding:4px 6px;border:1px solid #89734d88;border-radius:6px;background:#172a30ed;color:#f4e7c4}
#world-rss dt{font-size:.65rem;line-height:1.2;color:#d7cba9}#world-rss dd{margin:0;font-size:.8rem;line-height:1.3;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body.immersive #world-view>.controls{top:104px;z-index:1;gap:3px;padding:3px}
body.immersive #world-view>.controls button{min-height:32px;padding:4px 8px;font-size:.7rem}
body.immersive #world-context{top:140px;margin:4px 0}

#march-panel .march-fields{grid-template-columns:1fr 1.2fr 65px}#march-panel .march-fields>label:first-child{grid-column:1/-1}#march-panel .march-fields.scouting{grid-template-columns:1fr 1fr}#march-panel .march-fields.scouting>label:first-child{grid-column:auto}
/* Fort details reuse the compact World selection surface over the scene. */
body.immersive #panel.world-selection:has(#fort-panel:not([hidden])){inset:auto 4px calc(104px + env(safe-area-inset-bottom)) auto;width:min(410px,calc(100% - 8px));height:auto;max-height:40dvh;margin:0;overflow:auto}
@media(max-height:500px){body.immersive #panel.world-selection:has(#fort-panel:not([hidden])){bottom:calc(80px + env(safe-area-inset-bottom));max-height:40dvh}}
