/* The visible hem, including source PNG padding, meets the panel's top edge.
   Two pixels continue behind the panel to cover antialiasing during rotation. */
.game-view #dialogue .portrait{
 bottom:calc(var(--dialogue-panel-height,240px) - var(--portrait-bottom-gap,0px) - 2px);
 mask-image:linear-gradient(to bottom,transparent,black 1.5%,black 100%);
}
.game-view:has(#dialogue:not([hidden])) #hotspots{visibility:hidden}
.game-view:has(#dialogue:not([hidden])) .objective-card{visibility:hidden}
@media(orientation:portrait) and (max-width:700px){
 .close-scene .objective-card{top:70px;left:16px;right:16px;width:auto;display:flex;align-items:center;gap:8px;padding:7px 10px}
 .close-scene .objective-eyebrow{display:none}
 .close-scene .objective-card .progress-track{display:none}
 .close-scene .objective-card p{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0;font-size:13px;line-height:1.7}
 .close-scene .objective-card>button{width:44px;min-width:44px;min-height:44px;flex-shrink:0;border:0;padding:3px 5px;font-size:0}
 .close-scene .objective-card>button span{font-size:18px}
}
/* Close interiors keep the full head lane clear. The objective shares the top
   header row, between Back and the three tools, with a real44px hint button. */
@media(orientation:landscape) and (max-height:480px){
 body.close-scene .chapter-heading{visibility:hidden}
 body.close-scene .game-view .objective-card{top:max(4px,env(safe-area-inset-top));left:calc(max(17px,env(safe-area-inset-left)) + 94px);right:calc(max(17px,env(safe-area-inset-right)) + 110px);width:auto;height:44px;min-height:44px;display:grid;grid-template-columns:minmax(0,1fr) 44px;grid-template-rows:1fr;align-items:center;gap:5px;padding:0 5px 0 9px}
 body.close-scene .game-view .objective-card .objective-eyebrow,body.close-scene .game-view .objective-card .progress-track{display:none}
 body.close-scene .game-view .objective-card p{grid-column:1;grid-row:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0;font-size:12px;line-height:1.3}
 body.close-scene .game-view .objective-card>button{grid-column:2;grid-row:1;width:44px;min-height:44px;padding:0;border:0;font-size:0;justify-content:center}
 body.close-scene .game-view .objective-card>button span{font-size:20px}
}
/* Large text can otherwise consume the entire short viewport and
   collapse a portrait to zero height. The full paragraph stays scrollable. */
@media(max-height:700px){
 body.large-text .game-view .dialogue-panel>p{max-height:24dvh;overflow-y:auto;overscroll-behavior:contain}
}
.dialogue-more{height:20px;min-height:20px;flex-shrink:0;margin:0;text-align:right;color:#415353;font:12px/20px var(--serif);visibility:hidden}
/* Large text uses the established side composition on short landscape
   screens, leaving a substantial portrait beside the reading area. */
@media(orientation:landscape) and (max-height:480px){
 body.large-text:not(.side-portrait-dialogue) #dialogue{--reading-panel-bottom:max(28px,calc(env(safe-area-inset-bottom) + 20px))}
 body.large-text:not(.side-portrait-dialogue) .game-view #dialogue .portrait{left:max(12px,env(safe-area-inset-left));right:auto;bottom:calc(var(--reading-panel-bottom) - var(--portrait-bottom-gap,0px));width:min(29vw,calc((100dvh - 80px)*.66667));height:auto;aspect-ratio:2/3;transform:none;animation:none}
 body.large-text:not(.side-portrait-dialogue) #dialogue .portrait:not(.speaking):not(.reacting){display:none}
 body.large-text:not(.side-portrait-dialogue) #dialogue .dialogue-panel{left:calc(min(29vw,(100dvh - 80px)*.66667) + 24px + env(safe-area-inset-left));right:max(18px,calc(env(safe-area-inset-right) + 12px));bottom:var(--reading-panel-bottom);max-height:calc(100dvh - 72px);display:flex;flex-direction:column;padding:11px 18px}
 body.large-text:not(.side-portrait-dialogue) #dialogue .dialogue-top,body.large-text:not(.side-portrait-dialogue) #dialogue .dialogue-footer{flex-shrink:0}
 body.large-text:not(.side-portrait-dialogue) #dialogue #dialogue-text{min-height:0;max-height:none;overflow-y:auto;overscroll-behavior:contain;margin:12px 0}
 body.large-text.side-portrait-dialogue #dialogue #dialogue-text{max-height:none}
 body.large-text.side-portrait-dialogue #dialogue .dialogue-footer{display:flex;flex-direction:row;align-items:center;gap:6px;padding:8px 0 0}
 body.large-text.side-portrait-dialogue #dialogue .dialogue-footer>div{display:flex;gap:2px;min-width:0}
 body.large-text.side-portrait-dialogue #dialogue .dialogue-footer .text-button{min-height:38px;padding:3px 4px;font-size:11px}
 body.large-text.side-portrait-dialogue #dialogue #dialogue-next{min-width:144px;min-height:52px}
}
@media(orientation:landscape) and (max-height:360px){body.large-text:not(.side-portrait-dialogue) #dialogue{--reading-panel-bottom:max(24px,calc(env(safe-area-inset-bottom) + 16px))}}
/* Side portraits have a separate landscape composition; their hem ends at the
   panel's bottom instead of being suspended beside its text. */
@media(orientation:landscape) and (max-height:600px){
 .side-portrait-dialogue .game-view #dialogue:has(.packed-portrait:is(.speaking,.reacting):not([hidden])) .packed-portrait:is(.speaking,.reacting){bottom:calc(max(18px,env(safe-area-inset-bottom) + 12px) - var(--portrait-bottom-gap,0px));}
}
