/* Common layout contract. Tune this block, rather than individual chapters. */
:root{--surface-gap:10px;--surface-padding:14px;--surface-target:44px;--surface-max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));--surface-scroll-color:#94774e;--ds-game-share:.68;--ds-context-share:.32;--ds-dialogue-space:clamp(126px,22dvh,190px)}
.ui-surface{display:flex;flex-direction:column;min-height:0;overflow:hidden!important;gap:var(--surface-gap)}
.ui-surface-heading,.ui-surface-actions{flex:none;min-width:0}
.ui-surface-heading:empty,.ui-surface-actions:empty{display:none}
.ui-surface-body{min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--surface-scroll-color) transparent;overflow-wrap:anywhere}
.ui-surface>.ui-surface-body{flex:1 1 auto;padding:2px 4px 10px}
.ui-more-below{background-image:linear-gradient(transparent,#8c693e33);background-size:100% 18px;background-position:bottom;background-repeat:no-repeat;background-attachment:scroll;border-bottom:2px solid #a98b5866}
.ui-scrollable:focus-visible{outline:2px solid #b18e54;outline-offset:-2px}
.ui-surface-actions{display:flex;flex-wrap:wrap;gap:8px;padding:10px 0 2px;border-top:1px solid #9b7a4f66;max-height:45%;overflow:auto;scrollbar-width:thin}
.ui-surface-actions>button,.ui-surface-actions>a{flex:1;min-height:var(--surface-target)}
.ui-surface-actions .choices,.ui-surface-actions .case-actions,.ui-surface-actions .reader-actions,.ui-surface-actions .unlock-destinations{width:100%;margin:0;display:flex;flex-wrap:wrap;gap:8px}
.ui-surface-actions :is(.choices,.case-actions,.reader-actions)>button{flex:1;min-width:min(140px,100%);min-height:var(--surface-target);white-space:normal}
#panel{max-height:var(--surface-max-height);overflow:hidden;box-sizing:border-box}
#panel:not(.phone-panel){height:min(640px,var(--surface-max-height))}
#panel:not(.phone-panel) #panel-content{height:100%;min-height:0}
#panel #close{position:absolute;top:8px;right:8px;min-width:var(--surface-target);min-height:var(--surface-target);z-index:70}
#panel-title{margin:0 44px 6px 0!important;font-size:clamp(21px,3vw,28px)}
#track-unlock.ui-surface{height:min(700px,var(--surface-max-height));max-height:var(--surface-max-height)}
#track-unlock .ui-surface-heading{display:block}
#track-unlock .ui-surface-actions{display:grid;grid-template-columns:1fr;max-height:50%}
#track-unlock h2{margin:0!important}
#tbt-case-panel .case-sheet.ui-surface{height:100%;box-sizing:border-box}
#tbt-case-panel:has(>.case-sheet.ui-surface){overflow:hidden!important}
#inspection-speech.ui-surface,#bathroom-phone-speech.ui-surface{max-height:min(55dvh,380px);height:auto;overflow:hidden;gap:6px;padding:12px;z-index:26}
#inspection-speech .ui-surface-body,#bathroom-phone-speech .ui-surface-body{font-size:clamp(15px,1.7cqw,20px);line-height:1.3}
#inspection-speech .ui-surface-actions button,#bathroom-phone-speech .ui-surface-actions button{font-size:16px;margin:0;min-height:var(--surface-target)}
#ds-dialogue{min-height:0;max-height:min(48dvh,65%);display:flex;overflow:visible}
#ds-dialogue .ds-message{min-height:0;overflow:hidden;gap:6px}
#ds-dialogue .ds-message>p:not(.sr-only){flex:1;min-height:0;overflow:auto;max-height:none;font-size:clamp(21px,3cqw,30px);line-height:1.12}
#ds-dialogue .ds-advance{flex:none;min-height:var(--surface-target)}
/* Phone: header/footer are fixed flex rows; only the middle content scrolls. */
#panel.phone-panel{height:min(760px,var(--surface-max-height));max-height:var(--surface-max-height);overflow:hidden}
.phone-panel #panel-content,.phone-shell{height:100%;min-height:0}
#phone-screen{min-height:0;overflow:hidden;flex:1}
#phone-screen>.phone-app-header,#phone-screen>.phone-replies,#phone-screen>.phone-music-player,.phone-home-bar,.phone-status{flex-shrink:0}
#phone-screen>.phone-library,#phone-screen>.phone-notes,#phone-screen>.phone-conversation{flex:1;min-height:0;overflow:auto}
#phone-screen .phone-music-player{position:static;margin:0;max-height:48%;overflow:auto;padding:10px 12px;border-top:2px solid #70583a}
.phone-music-player p:empty{display:none}
.phone-apps{flex:none}
.phone-message{flex-shrink:0}
.phone-transfer{min-height:0;overflow:auto}
.isma-monitor{min-height:0!important}
.isma-call-dialogue{min-height:0;display:flex!important;flex-direction:column;overflow:hidden!important}
.isma-call-dialogue>p{flex:1;min-height:0;overflow:auto;margin:6px 0!important;font-size:clamp(16px,2cqw,23px)!important}
.isma-call-dialogue>button{flex:none;align-self:flex-end;min-height:var(--surface-target);font-size:16px!important}
/* File explorers and all property/confirmation panels follow the same contract. */
.monitor-explorer{display:flex;flex-direction:column;overflow:hidden}
.monitor-explorer>header,.monitor-path,.monitor-properties{flex:none}
.monitor-files{min-height:0;overflow:auto;flex:1}
.monitor-properties{max-height:55%;overflow:auto;font-size:clamp(12px,1.3cqw,17px)}
.monitor-properties button{position:sticky;bottom:0;min-height:var(--surface-target);font-size:clamp(13px,1.4cqw,18px)}
.mobile-ds-bottom{display:contents}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .game-window{gap:var(--ds-gap)}
 .mobile-ds-top{flex:0 0 calc((100% - var(--ds-gap))*var(--ds-context-share));padding:clamp(12px,2.5vh,22px) 20px;overflow:auto}
 .mobile-ds-top h2{margin:8px 0;font-size:28px}.mobile-ds-rule{margin-bottom:10px}.mobile-ds-objective{margin:6px 0;font-size:23px}.mobile-ds-footer{display:none}
 .mobile-ds-bottom{position:relative;display:flex;flex:1;min-height:0;align-items:flex-start;justify-content:center;padding-bottom:var(--ds-dialogue-space);background:#3c2c1e}
 .mobile-ds .game-window .mobile-ds-bottom>.scene{flex:none;align-self:flex-start;margin:0;width:min(100%,calc((var(--ds-viewport,100dvh)*var(--ds-game-share) - var(--ds-dialogue-space) - var(--ds-gap))*4/3));aspect-ratio:4/3;height:auto;max-height:none;overflow:visible;border:0;isolation:isolate;container-type:inline-size}
 .mobile-ds #ds-dialogue{position:fixed;top:auto;bottom:max(6px,env(safe-area-inset-bottom));left:6px;right:6px;max-height:calc(var(--ds-dialogue-space) - 10px);height:calc(var(--ds-dialogue-space) - 20px);min-height:0;padding:18px 10px 5px;z-index:40}
 .mobile-ds #ds-dialogue .ds-message>p:not(.sr-only){max-height:none;min-height:0;font-size:23px;overflow:auto}
 .mobile-ds #inspection-speech.ui-surface,.mobile-ds #bathroom-phone-speech.ui-surface{position:fixed;inset:auto 6px max(6px,env(safe-area-inset-bottom));width:auto;max-height:min(48dvh,360px);margin:0;z-index:41}
 .mobile-ds .scene .inventory,.mobile-ds #mobile-ds-notebook{position:fixed;top:calc(var(--ds-viewport,100dvh)*var(--ds-context-share) + 48px);bottom:max(6px,env(safe-area-inset-bottom));left:6px;right:6px;width:auto;max-height:none;z-index:39;overflow:auto}
 .mobile-ds dialog#panel,.mobile-ds dialog#panel.phone-panel{height:var(--ds-viewport,100dvh);max-height:var(--ds-viewport,100dvh)}
 .mobile-ds #panel:not(.phone-panel) #panel-content{padding-top:8px}
 .mobile-ds .phone-replies button,.mobile-ds .phone-music-player button{min-height:var(--surface-target)}
 .mobile-ds .phone-shell{border-radius:6px}.mobile-ds .phone-home{justify-content:flex-start}
}
@media(max-height:560px){:root{--surface-gap:6px;--surface-padding:8px}#panel:not(.phone-panel){padding:14px}#panel-title{font-size:21px}.ui-surface-actions{padding:5px 0}.music-album{display:none}.phone-status{min-height:32px}.phone-home-bar{height:var(--surface-target)}}

.phone-music-player button{min-width:var(--surface-target)}
dialog:not([open]),.ui-surface[hidden],.ui-surface-heading[hidden],.ui-surface-actions[hidden]{display:none!important}
/* Illustrated close-ups keep their art; the live interaction uses the viewport. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds #studio-monitor:not([hidden]){position:fixed;inset:0;width:100vw;height:var(--ds-viewport,100dvh);z-index:45;overflow:hidden}
 .mobile-ds #studio-monitor .monitor-housing{inset:max(16px,env(safe-area-inset-top)) 8px 68px;width:auto;height:auto;padding:0}
 .mobile-ds #studio-monitor .monitor-back{position:fixed;left:12px;bottom:max(12px,env(safe-area-inset-bottom));top:auto;width:44px;height:44px;z-index:46}
 .mobile-ds .monitor-explorer{inset:4% 3% 12%;width:auto;height:auto}
 .mobile-ds .monitor-files{flex:1;align-items:flex-start;min-height:44px}
 .mobile-ds .monitor-properties{max-height:52%;font-size:14px;overflow:auto}
 .mobile-ds .monitor-properties button{font-size:15px;min-height:44px}
 .mobile-ds .monitor-files button{font-size:14px;min-height:44px;overflow-wrap:anywhere}
 .mobile-ds .monitor-path,.mobile-ds .monitor-explorer header,.mobile-ds .monitor-status{font-size:13px}
 .mobile-ds .monitor-folder{font-size:15px;width:30%}
 .mobile-ds .monitor-ad{max-height:82%;overflow:auto}.mobile-ds .monitor-ad p{font-size:14px}.mobile-ds .monitor-ad h3{font-size:20px}.mobile-ds .monitor-ad header{font-size:13px}.mobile-ds .monitor-ad button{min-height:44px;min-width:44px}
 .mobile-ds:has(#studio-monitor:not([hidden])) .game-tools,.mobile-ds:has(#studio-monitor:not([hidden])) #main-menu-toggle{visibility:hidden}
}
.mobile-ds #ds-dialogue .ds-advance,.monitor-explorer header button{min-height:var(--surface-target);min-width:var(--surface-target)}
/* Keep artwork and its hit targets on one registered inspection canvas. */
.mobile-ds-inspection-canvas .case-guitar-art{position:absolute;inset:0;z-index:0;object-fit:contain}
.mobile-ds-inspection-canvas>button{z-index:1}
.case-photo-talking #ds-dialogue{z-index:65}
/* One semantic switch: use an interface fullscreen; inspect content in an overlay. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds [data-ui-kind=fullscreen][data-ui-active=true]{position:fixed!important;inset:0!important;width:100vw!important;height:var(--ds-viewport,100dvh)!important;max-width:100vw!important;max-height:var(--ds-viewport,100dvh)!important;min-height:0!important;margin:0!important;transform:none!important;box-sizing:border-box;border-radius:0!important;z-index:60!important;overflow:hidden!important;padding:max(12px,env(safe-area-inset-top,0px)) 12px max(12px,env(safe-area-inset-bottom,0px))}
 .mobile-interface-open .mobile-ds-top{visibility:hidden}
 .mobile-interface-open .mobile-ds-bottom,.mobile-interface-open .scene{background:transparent!important}
 .mobile-interface-open .scene>*{visibility:hidden}
 .mobile-interface-open .scene>[data-ui-active=true],.mobile-interface-open .scene>[data-ui-active=true] *{visibility:visible}
 .mobile-interface-open .game-tools,.mobile-interface-open #main-menu-toggle{visibility:hidden!important}
 .mobile-ds #panel.phone-panel[data-ui-active=true]{padding:6px}
 .mobile-ds #inspection-speech[data-ui-active=true]{display:flex;gap:var(--surface-gap);text-align:left;background:var(--ui-paper,#f8edcc);border:2px solid var(--ui-edge,#765334)}
 .mobile-ds #inspection-speech[data-ui-active=true] .ui-surface-body{flex:1;align-content:center;font-size:clamp(18px,5vw,24px)}
 .mobile-ds #inspection-speech[data-ui-active=true] .ui-surface-actions{padding:12px 0 0;flex-shrink:0}
 .mobile-ds dialog#panel[data-ui-kind=panel],.mobile-ds dialog#panel[data-ui-kind=passive],.mobile-ds #tbt-case-panel[data-ui-kind=panel]:not([hidden]),.mobile-ds #tbt-case-panel[data-ui-kind=passive]:not([hidden]){position:fixed!important;inset:auto!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:calc(100vw - 24px)!important;max-width:720px!important;height:min(620px,82dvh)!important;min-height:0!important;max-height:82dvh!important;margin:0!important;box-sizing:border-box;border-radius:8px!important;z-index:55;overflow:auto}
 .mobile-ds #tbt-case-panel[data-ui-kind=passive][data-view=guitar]:not([hidden]){height:auto!important;aspect-ratio:4/3;max-height:none!important;overflow:hidden;background:#241b14}
 .mobile-ds #tbt-case-panel[data-ui-kind=passive] .case-story-photo img{object-fit:contain}
 .mobile-ds #tbt-case-panel[data-view=envelopes-choice][data-ui-active=true] .case-sheet{height:100%}
 .mobile-ds .inventory[data-ui-active=true],.mobile-ds #mobile-ds-notebook[data-ui-active=true]{overflow:auto!important;background:var(--ui-paper,#f8edcc)}
}

.ui-surface-dismiss{display:block;margin-left:auto;min-width:var(--surface-target);min-height:var(--surface-target);font-size:26px;background:#e5d2a3;color:#3c2b1d;border:1px solid #765334;z-index:3}

@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){.mobile-ds .inventory.ui-surface[data-ui-active=true],.mobile-ds #mobile-ds-notebook.ui-surface[data-ui-active=true]{display:flex;overflow:hidden!important}}

/* Fullscreen applications expose their software UI, never the physical prop. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen]{background:#294640!important;padding:0!important;border:0;border-radius:0;box-shadow:none}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-housing{inset:0 0 calc(56px + env(safe-area-inset-bottom,0px));width:100%;height:auto;margin:0;padding:0;border:0;border-radius:0;background:none;box-shadow:none}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-display{height:100%;border:0;border-radius:0}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-desktop{height:100%;width:100%}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-back{left:8px;bottom:max(6px,env(safe-area-inset-bottom));top:auto;z-index:4!important;background:#e8d9b5;border:1px solid #705b3f;border-radius:5px}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-usb-port{position:absolute;inset:auto 8px max(6px,env(safe-area-inset-bottom)) auto;width:auto;height:44px;padding:8px 12px;background:#e8d9b5;color:#293c37;font:14px 'Trebuchet MS',sans-serif;border:1px solid #705b3f;border-radius:5px;opacity:1;z-index:4;cursor:pointer}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-usb-port>*{display:none!important}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-usb-port::after{content:'Conectar USB'}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-usb-port.usb-connected::after{content:'USB conectado · Unidad externa'}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-taskbar{height:44px;font-size:13px}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-explorer{inset:12px 8px 52px;width:auto;height:auto}
 .mobile-ds #inspection-speech[data-ui-kind=panel]{height:auto;max-height:min(48dvh,360px);text-align:center}
 .mobile-ds #inspection-speech[data-ui-kind=panel] .ui-surface-body{flex:1;font-size:clamp(16px,4.5vw,21px);align-content:normal}
}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-interface-open .scene>:not([data-ui-active=true]){display:none!important}
}
/* Menu confirmations are native modal dialogs inside game-window. Keep their
   ancestor rendered while open: display:none would hide the modal but leave
   the browser's modal input lock active. The menu remains above the scene. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.game-menu-visible:has(#panel[open]) .game-window{display:flex}
}
/* Viewport composition: artwork + dialogue consume the available height. */
@media(max-width:900px) and (orientation:portrait){
 .mobile-ds-top{flex:0 0 auto;max-height:26%;padding:14px 20px}
 .mobile-ds-top h2{font-size:26px;margin:8px 0}
 .mobile-ds-rule{margin-bottom:8px}
 .mobile-ds-objective{font-size:21px;margin:6px 0}
 .mobile-ds-bottom{display:flex;flex-direction:column;justify-content:center;align-items:stretch;padding:0;gap:0}
 .mobile-ds .game-window .mobile-ds-bottom>.scene{width:100%;flex:none;align-self:center}
 .mobile-ds-bottom>#ds-dialogue{position:relative;inset:auto;flex:1;width:calc(100% - 12px);height:auto;max-height:none;min-height:120px;margin:18px 6px 6px;padding:18px 12px 8px}
 .mobile-ds-bottom:has(>#ds-dialogue:not([hidden])){justify-content:flex-start}
 .mobile-ds-bottom>#ds-dialogue .ds-message>p:not(.sr-only){max-height:none;min-height:0;font-size:23px}
}
/* A rotated phone keeps the mobile controls. Context/dialogue sit beside the
   4:3 scene rather than switching to the cramped desktop frame. */
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds{padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)}
 .mobile-ds .game-window{display:grid;grid-template-columns:minmax(210px,32%) minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:8px}
 .mobile-ds .mobile-ds-top{grid-column:1;grid-row:1;flex:none;padding:12px;max-height:42dvh;border-bottom:0;overflow:auto}
 .mobile-ds-heading{font-size:8px}.mobile-ds-heading>span:last-child{display:none}
 .mobile-ds-top h2{font-size:22px;margin:6px 0}.mobile-ds-rule{display:none}
 .mobile-ds-top small{font-size:9px}.mobile-ds-objective{font-size:18px;margin:6px 0}.mobile-ds-selection{font-size:17px}
 .mobile-ds-bottom{display:contents}
 .mobile-ds .game-window .mobile-ds-bottom>.scene{grid-column:2;grid-row:1 / 3;width:min(100%,calc((var(--ds-viewport,100dvh) - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))*4/3));align-self:center;justify-self:center;max-height:100%;aspect-ratio:4/3;overflow:visible}
 .mobile-ds-bottom>#ds-dialogue{grid-column:1;grid-row:2;position:relative;inset:auto;width:auto;height:auto;min-height:0;max-height:none;margin:12px 0 6px 6px;padding:18px 10px 5px;align-self:stretch}
 .mobile-ds-bottom>#ds-dialogue .ds-message>p:not(.sr-only){font-size:21px;line-height:1.1;min-height:0;max-height:none}
 .mobile-ds-bottom>#ds-dialogue .ds-advance{font-size:20px;min-height:44px}
 .mobile-ds .scene .game-tools{flex-direction:row;width:auto;right:4px;top:4px}
 .mobile-ds .scene .game-tools .tool{width:44px;height:44px}
 .mobile-ds #panel.phone-panel[data-ui-active=true]{inset:0;width:100%;height:var(--ds-viewport,100dvh)}
}

@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .game-window .mobile-ds-bottom>.scene{overflow:hidden}
 .mobile-ds .hotspot span{max-width:min(220px,70cqw);white-space:normal;overflow-wrap:anywhere}
}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .hotspot span{min-width:min(130px,45cqw)}
}

/* The exploration panel and dialogue share a permanent slot. Content changes,
   never the artwork position or dimensions. */
.mobile-ds-idle{display:none}
@media(max-width:900px) and (orientation:portrait){
 .mobile-ds-top{flex:0 0 clamp(140px,23dvh,180px);max-height:none;justify-content:flex-start}
 .mobile-ds-bottom{display:grid;grid-template-rows:auto minmax(0,1fr);flex:1;justify-content:normal;align-items:stretch;min-height:0}
 .mobile-ds .game-window .mobile-ds-bottom>.scene{grid-row:1;grid-column:1;align-self:start}
 .mobile-ds-bottom>#ds-dialogue,.mobile-ds-bottom>.mobile-ds-idle{grid-row:2;grid-column:1;min-height:0;align-self:stretch;margin:18px 6px 6px;width:auto;height:auto;max-height:none}
}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds-idle:not([hidden]){display:flex;flex-direction:column;gap:12px;padding:18px;background:linear-gradient(#f4e7c6,#e3cfa1);border:2px solid #8b6b42;border-radius:8px;color:#3c2b1d;overflow:auto;font:22px/1.2 'Nintendo DS',monospace}
 .mobile-ds-idle[hidden]{display:none}
 .mobile-ds-idle small{font:10px 'Trebuchet MS',sans-serif;letter-spacing:.12em;color:#775b38}
 .mobile-ds-idle p{margin:0;flex:1}
 .mobile-ds-idle button{min-height:44px;flex:none;border:1px solid #8b6b42;background:#fff4cd;color:#3c2b1d;font:21px 'Nintendo DS',monospace;padding:8px 12px}
 .mobile-ds-idle button[aria-pressed=true]{background:#bbd0ae;border-color:#52694d}
 .mobile-interface-open .mobile-ds-idle{visibility:hidden}
 .mobile-ds .scene.show-points .hotspot{background:#ffdc6b25;box-shadow:inset 0 0 0 2px #fff1ae,0 0 0 1px #533b22aa}
}
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .game-window{grid-template-rows:clamp(110px,40dvh,150px) minmax(0,1fr)}
 .mobile-ds-bottom>.mobile-ds-idle{grid-column:1;grid-row:2;margin:12px 0 6px 6px;min-height:0;padding:12px;font-size:20px}
}
@media(max-width:900px) and (orientation:portrait){
 .mobile-ds .mobile-ds-bottom,.mobile-ds .mobile-ds-bottom:has(>#ds-dialogue:not([hidden])){grid-template-columns:minmax(0,1fr);justify-content:stretch;width:100%;min-width:0}
}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .scene.show-points .hotspot span{opacity:0}
 .mobile-ds .scene.show-points .hotspot:focus-visible span{opacity:1}
}
/* Tools share the lower slot; never cover the scene's persistent icon rail. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .mobile-ds-bottom>#mobile-ds-notebook,.mobile-ds .mobile-ds-bottom>#inventory{position:relative!important;inset:auto!important;grid-column:1;grid-row:2;width:auto;min-width:0;min-height:0;max-height:none;margin:18px 6px 6px;align-self:stretch;overflow:hidden;z-index:24;transform:none}
 .mobile-ds .mobile-ds-bottom>#mobile-ds-notebook:not([hidden]),.mobile-ds .mobile-ds-bottom>#inventory:not([hidden]){display:flex;flex-direction:column}
 .mobile-ds #mobile-ds-notebook[hidden],.mobile-ds #inventory[hidden]{display:none!important}
 .mobile-ds #mobile-ds-notebook .ui-surface-body,.mobile-ds #inventory .ui-surface-body{flex:1;min-height:0;overflow:auto}
 .mobile-ds #speech-bubble{display:none!important}
 .mobile-ds .mobile-ds-bottom>#ds-dialogue[hidden]{display:none!important}
}
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .mobile-ds-bottom>#mobile-ds-notebook,.mobile-ds .mobile-ds-bottom>#inventory{margin:12px 0 6px 6px;padding:10px}
}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .mobile-ds-bottom>#inventory{padding:12px;color:#38291b;font:21px/1.2 'Nintendo DS',monospace}
 .mobile-ds #inventory #items button{font:20px/1.15 'Nintendo DS',monospace;min-height:44px}
 .mobile-ds #inventory h2{font:26px 'Nintendo DS',monospace}
 .mobile-ds #inventory #selection{font:18px/1.2 'Nintendo DS',monospace}
}
/* Tool drawers size against the usable viewport, not the short dialogue slot. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .mobile-ds-bottom>#mobile-ds-notebook,.mobile-ds .mobile-ds-bottom>#inventory{
  position:fixed!important;inset:auto!important;left:50%!important;bottom:max(8px,env(safe-area-inset-bottom,0px))!important;transform:translateX(-50%)!important;
  width:min(560px,calc(100vw - 16px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));height:min(600px,72dvh);max-height:calc(var(--ds-viewport,100dvh) - 16px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  margin:0;padding:12px;gap:10px;align-items:stretch;z-index:44;border:2px solid #765334;border-radius:12px;background:#f0dfb5;box-shadow:0 -8px 35px #25180c55;
 }
 .mobile-ds #mobile-ds-notebook>.ui-surface-heading,.mobile-ds #inventory>.ui-surface-heading{flex:none;min-height:44px}
 .mobile-ds #mobile-ds-notebook header,.mobile-ds #inventory .inventory-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0;padding:0 0 8px;border-bottom:1px solid #b79a65}
 .mobile-ds #mobile-ds-notebook header button,.mobile-ds #inventory #close-inventory{width:44px;min-width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;display:grid;place-items:center;font-size:28px}
 .mobile-ds #mobile-ds-notebook>.ui-surface-body,.mobile-ds #inventory>.ui-surface-body{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;padding:4px 4px 16px;scrollbar-width:thin;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
 .mobile-ds #mobile-ds-notebook .ui-surface-body p{font:22px/1.3 'Nintendo DS',monospace;margin:10px 0;max-width:none;color:#38291b}
 .mobile-ds #mobile-ds-notebook>.ui-surface-actions,.mobile-ds #inventory>.ui-surface-actions{flex:0 0 auto;max-height:none;padding:8px 0 0;overflow:visible;gap:8px}
 .mobile-ds #mobile-ds-notebook>.ui-surface-actions>button{flex:1 1 0;min-width:0;min-height:48px;width:auto;padding:8px;font:20px/1.15 'Nintendo DS',monospace;text-align:center;border:1px solid #b79a65;border-radius:6px;background:#fff2cf}
 .mobile-ds #inventory #items{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-items:stretch;padding:4px 0 12px}
 .mobile-ds #inventory #items button{width:100%;min-width:0;min-height:84px;padding:10px 6px;white-space:normal;overflow-wrap:anywhere;display:flex;align-items:center;justify-content:center;gap:6px;font:20px/1.15 'Nintendo DS',monospace}
 .mobile-ds #inventory #items button span{max-width:100%;min-width:0}
 .mobile-ds #inventory #items .item-icon{width:32px;height:32px;flex:none}
 .mobile-ds #inventory #selection{margin:6px 0 12px;max-width:none}
}
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .mobile-ds-bottom>#mobile-ds-notebook,.mobile-ds .mobile-ds-bottom>#inventory{height:calc(var(--ds-viewport,100dvh) - 20px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));width:min(620px,calc(100vw - 32px));padding:10px;gap:6px}
 .mobile-ds #inventory #items{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media(max-width:900px) and (orientation:portrait){
 .mobile-ds .mobile-ds-bottom>#mobile-ds-notebook,.mobile-ds .mobile-ds-bottom>#inventory{height:auto;min-height:min(280px,60dvh);max-height:min(600px,72dvh)}
 .mobile-ds #mobile-ds-notebook>.ui-surface-body,.mobile-ds #inventory>.ui-surface-body{flex:1 1 auto}
}

/* The monitor must use the phone viewport, not the contained 4:3 scene.
   Keep the explorer as one scroll area so file properties cannot be clipped. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .scene.monitor-view{container-type:normal;contain:none;overflow:visible}
 .mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-explorer{display:flex;flex-direction:column;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
 .mobile-ds #studio-monitor .monitor-files{flex:0 0 auto;overflow:visible;min-height:0;align-items:flex-start}
 .mobile-ds #studio-monitor .monitor-properties{flex:0 0 auto;max-height:none;overflow:visible;display:flex;flex-direction:column;gap:10px;font-size:14px}
 .mobile-ds #studio-monitor .monitor-properties>strong{overflow-wrap:anywhere}
 .mobile-ds #studio-monitor .monitor-properties dl{display:grid;grid-template-columns:1fr;gap:6px}
 .mobile-ds #studio-monitor .monitor-properties button{position:static;align-self:stretch;min-height:48px;flex:none;font-size:16px}
 .mobile-ds #studio-monitor .monitor-status{flex:none;margin:8px;overflow-wrap:anywhere}
}

/* Mount the mobile computer at body level to escape the scene's clipping. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds>#studio-monitor:not([hidden]){position:fixed!important;inset:0!important;width:100%!important;height:100dvh!important;max-height:none!important;z-index:70!important;box-sizing:border-box;overflow:hidden!important;container-type:inline-size;background:#294640}
 body.mobile-ds>#studio-monitor .monitor-housing{position:absolute;inset:max(8px,env(safe-area-inset-top)) 0 calc(60px + env(safe-area-inset-bottom))!important;width:100%!important;height:auto!important}
 body.mobile-ds>#studio-monitor .monitor-explorer{inset:8px 8px 48px!important;width:auto!important;height:auto!important}
 body.mobile-ds>#studio-monitor .monitor-back{position:absolute!important;left:8px!important;bottom:max(8px,env(safe-area-inset-bottom))!important;width:44px;height:44px;z-index:5!important}
}

/* Readable call typography at phone widths, independent of scene units. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .isma-call-top{font-size:14px!important;line-height:1.3;padding:10px!important}
 .mobile-ds .isma-call-label,.mobile-ds .isma-self-camera span{font-size:12px!important;line-height:1.3;padding:3px 5px!important}
 .mobile-ds .isma-call-dialogue>small,.mobile-ds .isma-call-dialogue>strong{font-size:15px!important;line-height:1.25}
}

.bathroom-note-sheet{padding:20px;background:#f5e6bd;border:1px solid #b29a70;color:#38291b}
.bathroom-note-sheet small{font:600 15px/1.3 'Trebuchet MS',sans-serif;letter-spacing:.1em}
.bathroom-note-sheet blockquote{margin:20px 0;font:italic 24px/1.5 'Trebuchet MS',sans-serif;overflow-wrap:anywhere}

/* A found paper note, framed as an object rather than an application window. */
#panel.bathroom-note-panel{background:radial-gradient(ellipse at 50% 35%,#594b37,#211b16 85%);color:#f4e5c7;border-color:#594833}
#panel.bathroom-note-panel #panel-title{font:500 18px/1.3 'Trebuchet MS',sans-serif;color:#e1cfac;letter-spacing:.03em;text-align:center;margin:12px 28px 0}
#panel.bathroom-note-panel #panel-content{display:flex;flex-direction:column;min-height:0}
#panel.bathroom-note-panel .ui-surface-body{display:flex;align-items:center;justify-content:center;padding:30px 14px;overflow:auto}
#panel.bathroom-note-panel .bathroom-note-sheet{position:relative;box-sizing:border-box;width:100%;max-width:440px;flex:none;padding:44px 28px 48px;border:1px solid #c4ac7a;border-radius:2px 3px 8px 2px;background:linear-gradient(95deg,transparent 48%,#93784414 49.6%,#fff7d329 50%,transparent 51.5%),repeating-linear-gradient(0deg,#805e2605 0 1px,transparent 1px 4px),linear-gradient(135deg,#f7e9c6,#e8d5a6);color:#403322;box-shadow:0 16px 28px #0005,2px 3px 0 #bca775, inset 0 0 35px #9a733b15;transform:rotate(-1deg)}
#panel.bathroom-note-panel .bathroom-note-sheet small{display:block;font:600 11px/1.4 'Trebuchet MS',sans-serif;letter-spacing:.17em;color:#816c4b;border-bottom:1px solid #a48b5b55;padding-bottom:12px}
#panel.bathroom-note-panel .bathroom-note-sheet blockquote{font:italic 26px/1.65 Georgia,'Times New Roman',serif;margin:24px 0 8px;letter-spacing:.01em;text-wrap:pretty}
.bathroom-note-tape{position:absolute;width:94px;height:28px;left:50%;top:-12px;transform:translateX(-50%) rotate(4deg);background:linear-gradient(100deg,#cbb580a8,#e2d09dbb,#cbb580a8);border:1px solid #dec99155;box-shadow:0 2px 3px #382a1b1a}
.bathroom-note-fold{position:absolute;right:-1px;bottom:-1px;width:24px;height:24px;background:linear-gradient(135deg,#b6a075 48%,#f8eac9 51%);box-shadow:-2px -2px 4px #7c63331a}
#panel.bathroom-note-panel .ui-surface-actions{justify-content:center;padding:10px 12px max(18px,env(safe-area-inset-bottom));border:0;background:none}
#panel.bathroom-note-panel [data-note-continue]{min-height:48px;min-width:180px;background:#e9d8b1;color:#46351e;border:1px solid #b59a67;border-radius:5px;box-shadow:0 3px 8px #0003;font:600 17px/1.3 'Trebuchet MS',sans-serif;padding:12px 22px}
#panel.bathroom-note-panel [data-note-continue]:active{background:#d9c397}
@media(max-height:500px){#panel.bathroom-note-panel .bathroom-note-sheet{padding:24px}#panel.bathroom-note-panel .bathroom-note-sheet blockquote{font-size:23px;margin:12px 0}#panel.bathroom-note-panel .ui-surface-body{padding:18px 12px}}

/* Reader actions occupy the same lower slot as dialogue, outside scene clipping. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .mobile-ds-bottom>#inspection-speech:not([hidden]){position:relative!important;inset:auto!important;transform:none!important;grid-column:1;grid-row:2;align-self:stretch;display:flex;flex-direction:column;box-sizing:border-box;width:auto!important;height:auto!important;min-height:0;max-height:none!important;margin:18px 6px 6px;padding:14px;background:#d9e1c3;border:2px solid #57674b;border-radius:7px;z-index:25;overflow:auto;text-align:left}
 .mobile-ds .mobile-ds-bottom>#inspection-speech .ui-surface-body{flex:1;min-height:0;overflow:auto;font-size:23px;line-height:1.3}
 .mobile-ds .mobile-ds-bottom>#inspection-speech .ui-surface-heading{flex:none}
 .mobile-ds .mobile-ds-bottom>#inspection-speech .ui-surface-actions{flex:none;padding-top:10px;gap:8px}
 .mobile-ds .mobile-ds-bottom>#inspection-speech .reader-actions button{flex:1;min-height:48px;font-size:20px}
}
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){.mobile-ds .mobile-ds-bottom>#inspection-speech:not([hidden]){grid-column:1;grid-row:2;margin:6px;}}

/* Reader controls use the warm lower-deck visual language and compact header. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds .mobile-ds-bottom>#inspection-speech:not([hidden]){display:grid;grid-template-rows:28px minmax(48px,1fr) auto;gap:6px;padding:10px 12px;background:repeating-linear-gradient(0deg,transparent 0 27px,#7f62380b 28px),linear-gradient(120deg,#f5e8c5,#dfc99b);border:2px solid #89663f;border-radius:7px;color:#4b3323;font:22px/1.15 'Nintendo DS',monospace;box-shadow:none;overflow:auto!important}
 body.mobile-ds #inspection-speech>.ui-surface-heading{position:relative;height:28px;min-height:28px;display:flex;align-items:center;padding:0 44px 0 0}
 body.mobile-ds #inspection-speech>.ui-surface-heading::before{content:'LECTOR · BOBO';font:600 12px/1.2 'Trebuchet MS',sans-serif;letter-spacing:.1em;color:#795c3d}
 body.mobile-ds #inspection-speech .ui-surface-dismiss{position:absolute;right:-4px;top:-6px;display:grid;place-items:center;margin:0;padding:0;flex:none;width:40px;min-width:40px;height:40px;min-height:40px;font:28px/1 Arial,sans-serif;color:#795a3e;border:0;background:transparent;box-shadow:none}
 body.mobile-ds #inspection-speech>.ui-surface-body{min-height:48px;padding:0 2px;overflow:auto;align-content:center;font:23px/1.2 'Nintendo DS',monospace;border:0;background:none}
 body.mobile-ds #inspection-speech .ui-surface-body>small{display:none}
 body.mobile-ds #inspection-speech .ui-surface-body>p{font:inherit;margin:0 0 4px}
 body.mobile-ds #inspection-speech>.ui-surface-actions{padding:6px 0 0;max-height:none;overflow:visible;border-top:1px solid #a98b5d66;gap:8px}
 body.mobile-ds #inspection-speech .reader-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 body.mobile-ds #inspection-speech .reader-actions button{width:100%;min-width:0;min-height:48px;margin:0;padding:8px 6px;background:linear-gradient(145deg,#fff8e0,#e0c99c);border:1px solid #977346;border-radius:3px 12px 3px 12px;box-shadow:inset 0 1px #fff9e8,0 2px 0 #a48151;color:#4b3323;font:22px/1.05 'Nintendo DS',monospace;white-space:normal}
 body.mobile-ds #inspection-speech .reader-actions button:active{background:#d8bd8c;box-shadow:inset 0 2px 4px #77563144}
 body.mobile-ds #inspection-speech .reader-actions button:disabled{opacity:.55}
 body.mobile-ds #inspection-speech>.ui-surface-actions[hidden]{display:none!important}
}

@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds #inspection-speech>.ui-surface-heading{z-index:2;overflow:visible;pointer-events:auto}
 body.mobile-ds #inspection-speech .ui-surface-dismiss{z-index:3;pointer-events:auto;touch-action:manipulation;min-width:44px;width:44px;min-height:44px;height:44px;cursor:pointer}
}

/* Debug uses the native modal and one scroll area, with touch-sized controls. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds #panel.debug-panel{background:#f1e3be;color:#4b3323}
 .mobile-ds #panel.debug-panel #panel-content{display:flex;flex-direction:column;min-height:0}
 .mobile-ds #panel.debug-panel .ui-surface-heading{flex:none;padding:8px 0}
 .mobile-ds #panel.debug-panel .ui-surface-body{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:8px 2px 24px}
 .mobile-ds #panel.debug-panel .debug-note{font-size:15px;line-height:1.45;padding:12px;background:#e2d1a9;border-radius:6px}
 .mobile-ds #panel.debug-panel .debug-actions,.mobile-ds #panel.debug-panel .debug-presets{display:grid;grid-template-columns:1fr;gap:9px}
 .mobile-ds #panel.debug-panel .debug-menu button{width:100%;min-height:50px;font:17px/1.3 'Trebuchet MS',sans-serif;padding:12px;text-align:left;border:1px solid #977346;border-radius:6px;color:#4b3323;background:#fff1ce;box-shadow:0 2px #a4815144;white-space:normal}
 .mobile-ds #panel.debug-panel .debug-menu button[data-debug-live]{background:#dec2ad}
 .mobile-ds #panel.debug-panel .debug-chapter{margin:16px 0;border:1px solid #b49a6b;border-radius:7px;background:#f8ebcb}
 .mobile-ds #panel.debug-panel .debug-chapter summary{min-height:50px;box-sizing:border-box;padding:14px 12px;font:600 18px/1.3 'Trebuchet MS',sans-serif;cursor:pointer;touch-action:manipulation}
 .mobile-ds #panel.debug-panel .debug-chapter summary small{display:block;margin:4px 0 0;font:13px/1.3 'Trebuchet MS',sans-serif;color:#795c3d}
 .mobile-ds #panel.debug-panel .debug-group{padding:0 10px 14px}
 .mobile-ds #panel.debug-panel .debug-menu h3{font:600 16px/1.3 'Trebuchet MS',sans-serif;margin:14px 0 9px}
 .mobile-ds #panel.debug-panel .debug-menu>small{font-size:13px;line-height:1.4}
}

/* Amsi's voice comes through the red bathroom telephone. */
#ds-dialogue.ds-red-phone{background:linear-gradient(#f8e7d5,#ead1bc);border-color:#7c4035;box-shadow:inset 0 0 0 2px #c49278,0 3px 0 #40251d44}
#ds-dialogue.ds-red-phone .ds-speaker{max-width:88%;width:auto}
#ds-dialogue.ds-red-phone .ds-speaker span{background:linear-gradient(#a94e40,#77392f);border-color:#582b25;box-shadow:inset 0 0 0 1px #cf8a6b,0 2px #40251d55}
#ds-dialogue.ds-red-phone .ds-speaker span::before{content:'☎ ';font-family:Arial,sans-serif}
#ds-dialogue.ds-red-phone .ds-speaker span::after{content:' · teléfono rojo';font-size:.8em}
#ds-dialogue.ds-red-phone .ds-message>p:not(.sr-only){color:#4d2c26}
#ds-dialogue.ds-red-phone .ds-advance{border-color:#9c6b56;background:#eed8bf;color:#673b30}

/* The CD player's messages retain their own device identity. */
#ds-dialogue.ds-cd-player{background:linear-gradient(#e5ebd2,#ccd6b6);border-color:#536344;box-shadow:inset 0 0 0 2px #a6b38d,0 3px 0 #34402b44}
#ds-dialogue.ds-cd-player .ds-speaker{max-width:88%;width:auto}
#ds-dialogue.ds-cd-player .ds-speaker span{background:linear-gradient(#61754d,#465738);border-color:#35442b;box-shadow:inset 0 0 0 1px #93a575,0 2px #34402b55}
#ds-dialogue.ds-cd-player .ds-speaker span::before{content:'◉ ';font-family:Arial,sans-serif}
#ds-dialogue.ds-cd-player .ds-speaker span::after{content:' · CD';font-size:.8em}
#ds-dialogue.ds-cd-player .ds-message>p:not(.sr-only){color:#33432b}
#ds-dialogue.ds-cd-player .ds-advance{background:#e3e9cf;border-color:#788963;color:#3f5133}

/* Reader choices share the same identity as its spoken device messages. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds .mobile-ds-bottom>#inspection-speech[data-speaker="REPRODUCTOR"]:not([hidden]){background:linear-gradient(#e5ebd2,#ccd6b6);border-color:#536344;box-shadow:inset 0 0 0 1px #a6b38d;color:#33432b}
 body.mobile-ds #inspection-speech[data-speaker="REPRODUCTOR"]>.ui-surface-heading::before{content:'◉ REPRODUCTOR · CD';color:#f5eed2;background:linear-gradient(#61754d,#465738);border:1px solid #35442b;border-radius:4px;padding:5px 9px;font:17px/1 'Nintendo DS',monospace;letter-spacing:.02em}
 body.mobile-ds #inspection-speech[data-speaker="REPRODUCTOR"] .ui-surface-dismiss{color:#465738}
 body.mobile-ds #inspection-speech[data-speaker="REPRODUCTOR"]>.ui-surface-body{color:#33432b}
 body.mobile-ds #inspection-speech[data-speaker="REPRODUCTOR"]>.ui-surface-actions{border-top-color:#78896366}
 body.mobile-ds #inspection-speech[data-speaker="REPRODUCTOR"] .reader-actions button{background:linear-gradient(#edf1db,#d8e0c2);border-color:#788963;color:#3f5133;box-shadow:inset 0 1px #f8fbe8,0 2px #65764a55}
 body.mobile-ds #inspection-speech[data-speaker="REPRODUCTOR"] .reader-actions button:active{background:#c7d3ad;box-shadow:inset 0 2px 4px #53634433}
}

@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds #inspection-speech>.ui-surface-heading:has(.reader-panel-heading)::before{content:none}
 body.mobile-ds #inspection-speech>.ui-surface-heading:has(.reader-panel-heading){padding:0;height:36px;min-height:36px}
 body.mobile-ds #inspection-speech:has(.reader-panel-heading){grid-template-rows:36px minmax(48px,1fr) auto}
 body.mobile-ds #inspection-speech .reader-panel-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;min-height:36px;margin:0}
 body.mobile-ds #inspection-speech .reader-panel-heading strong{font:17px/1 'Nintendo DS',monospace;color:#f5eed2;background:#536744;padding:5px 9px;border-radius:4px}
 body.mobile-ds #inspection-speech [data-reader-close]{position:relative;inset:auto;flex:0 0 44px;display:grid;place-items:center;width:44px;min-width:44px;height:44px;min-height:44px;padding:0;margin:0;z-index:5;pointer-events:auto;touch-action:manipulation;border:1px solid #788963;border-radius:5px;box-shadow:none;background:#e3e9cf;color:#3f5133;font:28px/1 Arial,sans-serif}
}

/* The reader header inherits no generic scene-header decoration. */
body.mobile-ds #inspection-speech .reader-panel-heading{background:transparent!important;background-image:none!important;border:0!important;box-shadow:none!important;padding:0!important;color:inherit}
body.mobile-ds #inspection-speech>.ui-surface-heading:has(.reader-panel-heading){background:transparent!important;background-image:none!important;border:0!important;box-shadow:none!important}

/* Dialogue is content-sized. The portrait yields space; text never scrolls. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds .monitor-video-call .isma-monitor{grid-template-rows:auto minmax(0,1fr) auto!important}
 .mobile-ds .monitor-video-call .isma-call-picture{min-height:0;overflow:hidden}
 .mobile-ds .monitor-video-call .isma-call-dialogue{height:auto!important;max-height:none!important;min-height:0!important;padding:12px!important;gap:8px;overflow:visible!important}
 .mobile-ds .monitor-video-call .isma-call-dialogue>p{flex:0 0 auto!important;height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;line-height:1.3!important;padding:0!important;margin:4px 0 8px!important;background:none!important;border:0!important;scrollbar-width:none}
 .mobile-ds .monitor-video-call .isma-call-dialogue>p::-webkit-scrollbar{display:none}
 .mobile-ds .monitor-video-call .isma-call-dialogue>button{flex:0 0 auto!important;min-height:44px}
}

/* Ramiro's envelope reveal stays on the artwork screen; dialogue stays below. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds .scene>#tbt-case-panel[data-view="envelopes-intro"][data-ui-kind]:not([hidden]){position:absolute!important;inset:0!important;left:0!important;top:0!important;transform:none!important;width:100%!important;height:100%!important;max-height:none!important;max-width:none!important;min-height:0!important;margin:0!important;border:0!important;border-radius:0!important;overflow:hidden!important;background:#493626}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] .case-sheet{box-sizing:border-box;height:100%;padding:14px;display:flex;flex-direction:column;background:linear-gradient(#e9d7ab,#c7aa77)}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] .ui-surface-heading{flex:none}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] header{padding:0 0 8px;border-bottom:1px solid #9b7a4f66}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] h2{font:25px/1.1 'Nintendo DS',monospace;margin:0}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] .ui-surface-body{display:flex;align-items:center;justify-content:center;min-height:0;flex:1;padding:0;overflow:hidden}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] .case-envelope-stage{width:100%;margin:0;max-height:100%}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-intro"] .case-envelope-table{display:block;width:100%;height:auto;max-height:100%;box-shadow:0 4px 12px #35231533}
}

/* Camera inspection escapes the scene container; its controls stay in view. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"][data-ui-kind]:not([hidden]){position:fixed!important;inset:0!important;transform:none!important;width:100vw!important;height:var(--ds-viewport,100dvh)!important;max-height:none!important;max-width:none!important;min-height:0!important;margin:0!important;padding:max(12px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom))!important;box-sizing:border-box;z-index:60;overflow:hidden!important;background:#ead9ae}
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"] .case-sheet{height:100%;min-height:0;box-sizing:border-box;display:flex;flex-direction:column;padding:0;gap:10px}
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"] .ui-surface-heading{flex:none}
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"] .ui-surface-body{flex:1;min-height:0;overflow:hidden;padding:0}
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"] .case-camera-gallery{height:100%;grid-template-rows:minmax(0,1fr) auto auto;gap:10px}
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"] .case-gallery-image{width:min(100cqw,calc((100cqh - 150px) * 4 / 3));height:auto;aspect-ratio:4/3}
 body.mobile-ds>#tbt-case-panel[data-view="camera-gallery"] .case-gallery-action{padding-bottom:4px}
 body.mobile-ds.ds-dialogue-visible>#tbt-case-panel[data-view="camera-gallery"][data-ui-kind]:not([hidden]){height:calc(var(--ds-viewport,100dvh) - var(--ds-dialogue-space) - 18px)!important;bottom:auto!important}
}

/* Debug laboratory: shared desktop and touch terminal theme. */
body #panel.debug-panel{color:#c5edd7;background:repeating-linear-gradient(0deg,#72ffb503 0 1px,transparent 1px 4px),#091711;border:1px solid #57c68b;border-radius:10px;box-shadow:0 24px 90px #000a,0 0 32px #54f89c18;width:min(860px,calc(100vw - 28px));max-height:calc(100dvh - 32px);font-family:'Courier New',monospace}
body #panel.debug-panel::backdrop{background:#030b08c9;backdrop-filter:blur(5px)}
body #panel.debug-panel :is(#panel-title,.ui-surface-heading){color:#a3ffca;background:transparent;border-color:#397c57;font-family:'Courier New',monospace}
body #panel.debug-panel #panel-title{font-size:24px;letter-spacing:1px}
body #panel.debug-panel #panel-title::before{content:'>_ ';color:#62ce91}
body #panel.debug-panel .debug-menu{font-family:'Courier New',monospace;padding:2px}
body #panel.debug-panel .debug-note{font:13px/1.6 'Courier New',monospace;color:#a9c7b6;background:#10271c;border:1px solid #2c5c40;border-left:3px solid #75f4aa;border-radius:4px;padding:12px 15px;margin:0 0 20px}
body #panel.debug-panel .debug-menu h3{font:700 12px/1.4 'Courier New',monospace;text-transform:uppercase;letter-spacing:1.5px;color:#7bc69b;margin:18px 0 10px}
body #panel.debug-panel .debug-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;border:0;padding:0;margin:0 0 20px}
body #panel.debug-panel .debug-presets{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
body #panel.debug-panel .debug-menu button{background:#11291e;color:#c0f5d4;border:1px solid #335e44;border-radius:4px;box-shadow:none;min-height:46px;padding:11px 13px;text-align:left;white-space:normal;font:13px/1.45 'Courier New',monospace;cursor:pointer;transition:background .15s,border-color .15s}
body #panel.debug-panel .debug-menu button:hover{background:#1b3b2a;border-color:#86efad;color:#e1ffec}
body #panel.debug-panel .debug-menu button:focus-visible{outline:2px solid #9affbe;outline-offset:3px}
body #panel.debug-panel .debug-menu button[data-debug-live]{background:#25251a;border-color:#736e40;color:#e6d79d}
body #panel.debug-panel .debug-chapter{border:1px solid #2e5d40;border-radius:5px;background:#0c2016;margin:12px 0;overflow:hidden}
body #panel.debug-panel .debug-chapter[open]{border-color:#5ca479}
body #panel.debug-panel .debug-chapter summary{padding:14px 16px;min-height:48px;box-sizing:border-box;cursor:pointer;font:700 16px/1.4 'Courier New',monospace;color:#b4faca;touch-action:manipulation;background:#112a1d}
body #panel.debug-panel .debug-chapter summary small{display:block;color:#7fa28c;font:11px/1.5 'Courier New',monospace;margin:4px 0 0 18px}
body #panel.debug-panel .debug-group{padding:0 16px 16px}
body #panel.debug-panel .debug-menu>small{color:#789e88;font:12px/1.6 'Courier New',monospace;margin:16px 0 2px}
body #panel.debug-panel :is(#close-panel,[data-ui-dismiss]){background:#143023;color:#adf5c8;border:1px solid #548367;border-radius:4px;box-shadow:none}
@media(max-width:600px){body #panel.debug-panel .debug-presets,body #panel.debug-panel .debug-actions{grid-template-columns:1fr}body #panel.debug-panel .debug-menu button{font-size:14px;min-height:50px}body #panel.debug-panel .debug-note{font-size:13px}body #panel.debug-panel .debug-group{padding:0 12px 14px}}
@media(prefers-reduced-motion:reduce){body #panel.debug-panel .debug-menu button{transition:none}}

/* Mobile TBT fixes: preserve terminal palette and keep physical inspections on the art screen. */
body.mobile-ds #panel.debug-panel{background:repeating-linear-gradient(0deg,#72ffb503 0 1px,transparent 1px 4px),#091711;color:#c5edd7;border-color:#57c68b}
body.mobile-ds #panel.debug-panel .debug-note{background:#10271c;color:#a9c7b6;border-color:#2c5c40}
body.mobile-ds #panel.debug-panel .debug-menu button{background:#11291e;color:#c0f5d4;border-color:#335e44;font-family:'Courier New',monospace;box-shadow:none}
body.mobile-ds #panel.debug-panel .debug-menu button[data-debug-live]{background:#25251a;border-color:#736e40;color:#e6d79d}
body.mobile-ds #panel.debug-panel .debug-chapter{background:#0c2016;border-color:#2e5d40}
body.mobile-ds #panel.debug-panel .debug-chapter summary{background:#112a1d;color:#b4faca;font-family:'Courier New',monospace}
body.mobile-ds #panel.debug-panel .debug-chapter summary small,body.mobile-ds #panel.debug-panel .debug-menu>small{color:#7fa28c}
body.mobile-ds #panel.debug-panel .debug-menu h3{color:#7bc69b;font-family:'Courier New',monospace}
.ds-choices{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;flex:none}
.ds-choices button{min-height:44px;padding:8px 16px;border:1px solid #806346;border-radius:6px;background:#f5e5bd;color:#392b20;font:24px/1.1 'Nintendo DS',monospace;cursor:pointer}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds .tbt-mobile-call{height:100%;min-height:0;overflow:hidden}
 body.mobile-ds .tbt-mobile-call .isma-monitor{height:100%!important;grid-template-rows:40px minmax(0,1fr) clamp(170px,36dvh,250px)!important;overflow:hidden}
 body.mobile-ds .tbt-mobile-call .isma-call-picture{min-height:0!important;height:100%!important;overflow:hidden}
 body.mobile-ds .tbt-mobile-call .isma-call-dialogue{display:grid!important;grid-template-rows:20px minmax(0,1fr) 44px;height:100%!important;min-height:0!important;max-height:none!important;box-sizing:border-box;padding:10px 12px!important;gap:5px;overflow:hidden!important}
 body.mobile-ds .tbt-mobile-call .isma-call-dialogue>p{height:100%!important;min-height:0!important;margin:0!important;font-size:18px!important;line-height:1.25!important;overflow:hidden!important;align-content:center}
 body.mobile-ds .tbt-mobile-call .isma-call-dialogue>button{height:44px!important;min-height:44px!important;padding:6px 12px!important;margin:0!important;justify-self:end;font-size:17px!important}
 body.mobile-ds .tbt-mobile-call .isma-call-dialogue>button[hidden]{display:block!important;visibility:hidden}
 body.mobile-ds .scene>#tbt-case-panel:is([data-view="envelopes-intro"],[data-view="envelopes-choice"],[data-view="envelope-opening"],[data-view="photo-front"],[data-view="photo-back"]):not([hidden]){position:absolute!important;inset:0!important;left:0!important;top:0!important;transform:none!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;min-height:0!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;box-sizing:border-box;overflow:hidden!important;z-index:24;background:#d9c599}
 body.mobile-ds #tbt-case-panel:is([data-view="envelopes-intro"],[data-view="envelopes-choice"],[data-view="photo-front"],[data-view="photo-back"]) .case-sheet{height:100%!important;min-height:0;box-sizing:border-box;padding:8px;display:flex;flex-direction:column;gap:6px}
 body.mobile-ds #tbt-case-panel:is([data-view="envelopes-intro"],[data-view="envelopes-choice"],[data-view="photo-front"],[data-view="photo-back"]) .ui-surface-heading{flex:none}
 body.mobile-ds #tbt-case-panel:is([data-view="envelopes-intro"],[data-view="envelopes-choice"],[data-view="photo-front"],[data-view="photo-back"]) .ui-surface-body{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;padding:0;overflow:hidden;background:none;border:0}
 body.mobile-ds #tbt-case-panel:is([data-view="photo-front"],[data-view="photo-back"],[data-view="envelopes-choice"]) .ui-surface-actions{display:none!important}
 body.mobile-ds #tbt-case-panel:is([data-view="photo-front"],[data-view="photo-back"]) .case-photo-stage{position:relative!important;inset:auto!important;width:100%;height:100%;min-height:0;display:flex;align-items:center;justify-content:center}
 body.mobile-ds #tbt-case-panel .case-story-photo{height:100%;max-height:100%;max-width:100%;margin:0;transform:none;box-sizing:border-box;aspect-ratio:4/3;padding:6px}
 body.mobile-ds #tbt-case-panel .case-story-photo img{object-fit:contain;width:100%;min-height:0;flex:1}
 body.mobile-ds #tbt-case-panel .case-story-photo figcaption{font-size:11px;flex:none}
 body.mobile-ds #tbt-case-panel[data-view="photo-back"] .case-photo-back{min-height:0!important;width:94%!important;margin:0!important;padding:16px!important;box-sizing:border-box;transform:none}
 body.mobile-ds #tbt-case-panel[data-view="photo-back"] .case-photo-back p{font:23px/1.2 'Nintendo DS',monospace}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-choice"] :is(.case-instructions,.case-feedback){display:none}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-choice"] .case-envelopes{width:100%;height:100%;padding:0;display:flex;align-items:center;justify-content:center;gap:4%}
 body.mobile-ds #tbt-case-panel[data-view="envelopes-choice"] .case-envelopes button{flex:0 0 28%;width:28%;aspect-ratio:1.5}
 body.mobile-ds .case-mobile-envelope-opening{position:absolute;inset:0;display:grid;place-items:center;padding:8%;box-sizing:border-box;overflow:hidden;background:#806044}
 body.mobile-ds .case-mobile-envelope-opening .case-story-photo{height:100%;max-width:100%;opacity:0;translate:0 18%;transition:opacity .5s,translate .5s}
 body.mobile-ds .case-mobile-envelope-opening.revealing .case-story-photo{opacity:1;translate:0 0}
 body.mobile-ds .case-mobile-opening-paper{position:absolute;width:58%;aspect-ratio:1.5;background:#efd8aa;border:2px solid #715338;display:grid;place-items:center;transition:opacity .4s}
 body.mobile-ds .case-mobile-opening-paper svg{width:25%;fill:#bd9642}
 body.mobile-ds .revealing .case-mobile-opening-paper{opacity:0}
 body.mobile-ds #ds-dialogue:has(.ds-choices) .ds-message>p{overflow:hidden}
}

#ds-dialogue .ds-advance[hidden]{display:none!important}
body.mobile-ds #panel.debug-panel .debug-tools{background:#10271c;color:#a9c7b6;border:1px solid #2c5c40}
body.mobile-ds #panel.debug-panel #close{background:#143023;color:#adf5c8;border-color:#548367}

@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 .mobile-ds-bottom:has(#ds-dialogue .ds-choices) #tbt-case-panel:is([data-view="photo-front"],[data-view="photo-back"]) header{display:flex!important;flex:none}
 .mobile-ds #tbt-case-panel:is([data-view="photo-front"],[data-view="photo-back"]) .case-close{min-width:44px;min-height:44px;position:relative;z-index:2}
}

@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){body.mobile-ds #tbt-case-panel:is([data-view="photo-front"],[data-view="photo-back"]) .case-close{position:static!important;left:auto!important;right:auto!important;top:auto!important;bottom:auto!important;margin-left:auto!important;flex:none}}

/* USB connection state uses the same readable game type as the file view. */
.tbt-master-explorer .monitor-no-drive{font-family:'Nintendo DS',monospace;font-size:clamp(21px,2.5cqw,28px);line-height:1.2}
.tbt-master-explorer .monitor-no-drive p{font:inherit;line-height:1.3}
.tbt-master-explorer .monitor-no-drive button{font:24px/1.15 'Nintendo DS',monospace;min-height:48px;white-space:normal;padding:10px 14px}
#studio-monitor .monitor-usb-port small{font-family:'Nintendo DS',monospace}
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds #studio-monitor .tbt-master-explorer .monitor-no-drive{padding:20px 16px;font:24px/1.2 'Nintendo DS',monospace}
 body.mobile-ds #studio-monitor .tbt-master-explorer .monitor-no-drive strong{font:26px/1.15 'Nintendo DS',monospace;display:block;margin-bottom:12px}
 body.mobile-ds #studio-monitor .tbt-master-explorer .monitor-no-drive p{font:24px/1.3 'Nintendo DS',monospace;margin:0 0 18px}
 body.mobile-ds #studio-monitor .tbt-master-explorer .monitor-no-drive button{width:100%;font:24px/1.15 'Nintendo DS',monospace;min-height:48px}
 body.mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-usb-port{font:23px/1.1 'Nintendo DS',monospace;display:flex;align-items:center;justify-content:center;max-width:calc(100% - 74px);height:auto;min-height:44px;box-sizing:border-box;white-space:normal;text-align:center}
 body.mobile-ds #studio-monitor[data-ui-kind=fullscreen] .monitor-usb-port::after{font:inherit}
}

/* First chapters: readable file metadata and precise, finger-sized inspections. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body.mobile-ds #studio-monitor .monitor-explorer{font-family:'Nintendo DS',monospace}
 body.mobile-ds #studio-monitor .monitor-explorer header,body.mobile-ds #studio-monitor .monitor-path,body.mobile-ds #studio-monitor .monitor-status{font:20px/1.15 'Nintendo DS',monospace}
 body.mobile-ds #studio-monitor .monitor-files button{font:21px/1.1 'Nintendo DS',monospace;overflow-wrap:anywhere;min-height:48px}
 body.mobile-ds #studio-monitor .monitor-properties{font:22px/1.2 'Nintendo DS',monospace}
 body.mobile-ds #studio-monitor .monitor-properties dt{color:#505442}
 body.mobile-ds #studio-monitor .monitor-properties button{font:23px/1.1 'Nintendo DS',monospace}
 body.mobile-ds #studio-monitor .monitor-explorer header button,body.mobile-ds #studio-monitor .monitor-ad header button{font:28px/1 Arial,sans-serif;min-width:44px;min-height:44px}
 body.mobile-ds #hatch-inspection .detail-note{left:calc(64.5% - 22px);top:calc(47% - 22px);width:44px;height:44px;z-index:3}
 body.mobile-ds #hatch-inspection .detail-coin-slot{left:calc(59.3% - 22px);top:calc(62.25% - 22px);width:44px;height:44px}
 body.mobile-ds #panel.bathroom-note-panel #close{background:#eddbb5;color:#3b2a1c;border:1px solid #baa071;font:28px/1 Arial,sans-serif;min-width:44px;min-height:44px}
 body.mobile-ds :is(.prologue-next,.ds-advance,.reader-actions button,.monitor-explorer button,#hatch-inspection button):focus-visible{outline:3px solid #26766a;outline-offset:2px;box-shadow:0 0 0 5px #fff7db}
}
@media(prefers-reduced-motion:reduce){
 #adventure-prologue .prologue-art,#adventure-prologue .prologue-message,.intro-entering #akiel-character{animation:none;transition:none}
}
