/* Shared viewport contract. Artwork owns its aspect ratio; UI owns readable width.
   Header/footer participate in layout. Only the middle work area scrolls. */
:root{--ui-gutter:clamp(12px,2.4vw,32px);--ui-content:1100px;--ui-safe-bottom:env(safe-area-inset-bottom,0px)}
.briefing-reopen{display:block;width:100%;box-sizing:border-box;font:inherit;font-size:14px;line-height:1.3;color:#dce1e8;background:#ffffff08;border:1px solid #ffffff30;border-radius:6px;padding:10px 12px;min-height:44px;margin-top:14px;cursor:pointer;text-align:center}
.briefing-reopen:hover{background:#ffffff14}
.briefing-reopen:focus-visible{outline:2px solid #ffe09a;outline-offset:2px}
html body .room-dialog{box-sizing:border-box;max-width:calc(100vw - 2 * var(--ui-gutter));max-height:calc(100dvh - 2 * var(--ui-gutter));overflow:auto;overscroll-behavior:contain}
#space-popover{max-height:calc(100dvh - 100px);overflow:auto;overscroll-behavior:contain}
#entry{padding:max(16px,env(safe-area-inset-top)) var(--ui-gutter) max(16px,var(--ui-safe-bottom));align-items:safe center}
.entry-card{max-width:100%;box-sizing:border-box}

/* Cleanup uses the same three-row viewport model as the learning devices. */
#ending-layout{position:fixed;inset:0;z-index:7;display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:12px;padding:var(--ui-gutter);padding-bottom:max(var(--ui-gutter),var(--ui-safe-bottom));box-sizing:border-box;pointer-events:none}
#ending-layout:has(#ending-panel[hidden]):has(#ending-inventory[hidden]):has(#ending-actions[hidden]){display:none}
html body #ending-layout>section,html body #ending-layout>#ending-actions{position:static;transform:none;max-height:none;min-height:0;pointer-events:auto;margin:0;justify-self:center}
html body #ending-layout>#ending-panel{grid-row:1;width:min(510px,100%)}
html body #ending-layout>#ending-inventory{grid-row:2;width:min(800px,100%);align-self:stretch;overflow:auto}
html body #ending-layout>#ending-actions{grid-row:3;width:min(800px,100%);display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
#ending-layout #ending-actions button{min-height:44px;flex:1;min-width:0;white-space:normal}
body:has(#ending-layout #ending-panel:not([hidden])) #space-hud{visibility:hidden}
@media(max-height:560px){#ending-layout{gap:8px;padding:8px}html body #ending-layout #ending-panel{padding:8px 12px}#ending-layout .ending-decision{margin:4px 0;min-height:0;font-size:15px}#ending-layout .ending-counts{font-size:13px}}
@media(max-width:760px),(pointer:coarse),(any-pointer:coarse){
 body.planet-map-controls #ending-layout{padding-top:calc(max(8px,env(safe-area-inset-top)) + 44px + var(--ui-gutter))}
}

/* Completion offers only issuance or return; the task dock owns both slots. */
#ending-layout #ending-actions[data-completed=true]{grid-template-columns:repeat(2,minmax(0,1fr))}
#ending-layout #ending-actions[data-completed=true] button{min-height:44px}
