/* One dynamic viewport, shared game state. Phone layout is independent of desktop. */
html,body{width:100%;height:100%;overflow:hidden;overscroll-behavior:none}
body{position:fixed;inset:0;width:100%;height:100dvh}
#view{height:100dvh;max-height:100dvh}
#taskBackdrop{position:fixed;inset:0;z-index:7;background:#06111550;touch-action:manipulation}
@media (pointer:coarse),(max-width:700px),(max-width:1100px) and (max-height:500px){
 :root{--phone-controls:172px;--safe-top:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-bottom,0px)}
 button{min-height:44px;font-size:14px;touch-action:manipulation}
 .desktop,kbd,.menu-side,.menu-footer{display:none!important}
 #menu{height:100dvh;overflow:auto;padding:calc(var(--safe-top) + 18px) max(20px,env(safe-area-inset-right)) calc(var(--safe-bottom) + 18px) max(20px,env(safe-area-inset-left));align-items:center}
 #menu .menu-content{width:100%;max-width:600px;margin:auto;padding:0}
 #offline-status{font-size:11px!important;line-height:1.35;margin:0 0 10px}
 #menu .eyebrow{font-size:9px;line-height:1.4;letter-spacing:1.4px}
 h1{font-size:clamp(64px,19vw,100px);letter-spacing:-5px;margin:24px 0 24px}
 .smile-line{height:16px;bottom:-14px;border-width:3px}
 .edition{font-size:11px;letter-spacing:1.5px;margin-top:20px}
 .edition span{font-size:10px;margin-left:8px;padding-left:8px}
 .intro{font-size:22px;line-height:1.25;margin:20px 0 12px}
 .description{max-width:none;font-size:14px;line-height:1.5;margin:10px 0}
 .menu-actions{display:grid;grid-template-columns:1fr;gap:8px;margin-top:18px}
 .menu-actions .primary{width:100%}
 .menu-links{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:10px}
 .menu-links button{min-height:44px;font-size:12px;line-height:1.3;text-align:center}
 .small{font-size:11px;line-height:1.5;margin-top:12px}
 #hud{padding:calc(var(--safe-top) + 8px) max(12px,env(safe-area-inset-right)) 4px max(12px,env(safe-area-inset-left));height:60px;align-items:flex-start;gap:10px}
 #hud .brand{font-size:25px;line-height:1}.brand span{font-size:7px;letter-spacing:1px;margin-top:5px}
 .hud-right{font-size:17px;gap:9px;align-items:center}.hud-right button{width:44px;height:44px;padding:8px}
 #objective{top:calc(var(--safe-top) + 67px);left:max(12px,env(safe-area-inset-left));right:12px;max-width:calc(100% - 24px);font-size:13px}
 #objective>.eyebrow{font-size:9px;letter-spacing:1.5px}
 #objective>div:first-of-type{display:flex;align-items:center;gap:8px}#doneCount{font-size:25px}#objective button{font-size:13px;padding:8px 12px;margin-left:auto}
 #nextTask{font-size:12px;line-height:1.4;margin-top:4px;max-width:100%}
 #warning{top:calc(var(--safe-top) + 160px);width:calc(100% - 28px);font-size:12px;line-height:1.4}
 #touchControls{z-index:9;left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));bottom:calc(var(--safe-bottom) + 8px);gap:12px;align-items:flex-end}
 #movePad{width:100px;height:100px;flex-shrink:0}#movePad i{left:30px;top:30px}#movePad span{font-size:10px}
 .touch-actions{grid-template-columns:repeat(2,minmax(80px,1fr));gap:8px;max-width:208px}.touch-actions button{font-size:13px;line-height:1.15;min-height:48px;padding:8px}
 #touchInteract,#touchTurn{grid-column:auto}#touchBag{grid-column:span 2}
 #bottomHud{left:max(12px,env(safe-area-inset-left));right:12px;bottom:calc(var(--safe-bottom) + var(--phone-controls));display:flex;flex-wrap:wrap;gap:5px 10px;font-size:11px;line-height:1.35;align-items:center}
 #equipment{flex:1 1 200px}#location{font-size:11px;order:0}#batteryMeter{width:62px;flex-shrink:0}
 #caption{bottom:calc(var(--safe-bottom) + var(--phone-controls) + 38px);width:calc(100% - 28px);font-size:12px;line-height:1.4;padding:8px 10px;max-height:64px;overflow:auto}
 #interactPrompt{bottom:calc(var(--safe-bottom) + var(--phone-controls) + 90px);width:calc(100% - 28px);font-size:13px;line-height:1.4;white-space:normal}
 #stamina{bottom:calc(var(--safe-bottom) + var(--phone-controls) + 24px);width:100px}
 #stationPanel{left:12px;right:12px;top:calc(var(--safe-top) + 145px);bottom:calc(var(--safe-bottom) + var(--phone-controls) + 32px);width:auto;max-height:none;padding:14px;display:grid;grid-template-rows:auto minmax(0,1fr);overflow:hidden}
 .panel-top{gap:12px;align-items:center;margin-bottom:8px;padding-bottom:8px}.panel-top h2{font-size:19px;line-height:1.2;margin:4px 0}.panel-top .eyebrow{font-size:9px}.panel-top button{min-width:90px;padding:8px;font-size:13px}
 #stationBody{min-height:0;overflow:auto;overscroll-behavior:contain;padding-right:4px;padding-bottom:4px;font-size:14px;line-height:1.4}#stationBody p{font-size:14px;line-height:1.4;margin:8px 0}.numbers{font-size:26px!important;line-height:1.15;overflow-wrap:anywhere}#stationBody .actions{gap:8px}#stationBody button{min-height:44px}
 #qte{left:12px;right:12px;top:calc(var(--safe-top) + 145px);bottom:calc(var(--safe-bottom) + var(--phone-controls) + 24px);width:auto;max-height:none;transform:none;padding:14px;overflow:auto;overscroll-behavior:contain}
 #qte h2{font-size:20px;margin:4px 0 8px}#qte p{font-size:13px;line-height:1.4;margin:8px 0}#qte .qte-bottom{position:sticky;bottom:-14px;background:#14272b;padding:8px 0;display:flex;flex-wrap:nowrap}#qteHit{min-width:100px;min-height:44px}.defense-bar-label{font-size:10px}
 #modal{height:100dvh;padding:calc(var(--safe-top) + 12px) max(12px,env(safe-area-inset-right)) calc(var(--safe-bottom) + 12px) max(12px,env(safe-area-inset-left));align-items:center}
 .modal-card{width:100%;max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);overflow:auto;overscroll-behavior:contain;padding:24px 20px;font-size:14px;line-height:1.5}.modal-card h2{font-size:26px;line-height:1.15}.modal-card .corner{min-width:44px;min-height:44px;top:4px;right:4px}.task-row{font-size:14px;min-height:36px}.checklist-links button{min-height:44px}
 .letter-screen{height:100dvh;max-height:100dvh;gap:10px;padding:calc(var(--safe-top) + 12px) max(12px,env(safe-area-inset-right)) calc(var(--safe-bottom) + 12px) max(12px,env(safe-area-inset-left))}
 .letter-scroller{display:block;padding:2px 4px 8px;min-height:0;overflow:auto}.letter-paper{width:min(100%,650px);margin:0 auto;transform:none;padding:22px;font-size:23px;line-height:1.23}.letter-paper p{margin-bottom:16px}.letter-signature{font-size:1.3em}.letter-actions{gap:8px;flex-wrap:nowrap}.letter-actions button{min-width:0;flex:1;max-width:220px;min-height:44px;font-size:14px;padding:10px}
}
@media (max-width:1100px) and (max-height:500px){
 :root{--phone-controls:108px}
 #menu{padding:calc(var(--safe-top) + 10px) max(18px,env(safe-area-inset-right)) calc(var(--safe-bottom) + 10px) max(18px,env(safe-area-inset-left))}
 #menu .menu-content{max-width:900px;display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr);gap:6px 28px;align-items:center}
 #offline-status{grid-column:1/-1;margin:0}#menu .menu-content>.eyebrow{grid-column:1/-1}
 #menu h1{grid-column:1;grid-row:3/5;font-size:64px;margin:12px 0 16px;align-self:center}.edition{grid-column:1;grid-row:5;margin:8px 0 0}.intro{grid-column:1;grid-row:6;font-size:18px;margin:8px 0 0}.description{grid-column:2;grid-row:3;font-size:13px;line-height:1.4;margin:0}.menu-actions{grid-column:2;grid-row:4;margin:0;gap:6px}.menu-links{grid-column:2;grid-row:5;margin:0;gap:8px}.small{grid-column:2;grid-row:6;font-size:10px;margin:0}
 #hud{height:52px}#hud .brand{font-size:23px}#hud .brand span{display:none}#objective{top:calc(var(--safe-top) + 58px);width:28%;right:auto}#objective .eyebrow{display:none}#objective>div:first-of-type{flex-wrap:wrap;gap:4px}#objective button{margin:0}#nextTask{font-size:11px}#warning{top:calc(var(--safe-top) + 58px);left:66%;width:62%;font-size:12px}
 #touchControls{gap:16px}#movePad{width:84px;height:84px}#movePad i{left:22px;top:22px}.touch-actions{max-width:none;grid-template-columns:repeat(4,minmax(68px,1fr));grid-template-rows:48px;grid-auto-flow:column;grid-auto-columns:minmax(70px,1fr);gap:6px}#touchBag{grid-column:auto}.touch-actions button{font-size:12px;padding:7px}
 #bottomHud{bottom:calc(var(--safe-bottom) + 96px);font-size:10px}#equipment{flex:0 1 auto}#location{font-size:10px}#caption{bottom:calc(var(--safe-bottom) + 120px);width:52%;font-size:12px;max-height:48px}#interactPrompt{bottom:calc(var(--safe-bottom) + 168px);width:50%}#stamina{bottom:calc(var(--safe-bottom) + 120px);left:15%}
 #stationPanel,#qte{left:32%;right:12px;top:calc(var(--safe-top) + 58px);bottom:calc(var(--safe-bottom) + 136px);padding:10px}.panel-top h2{font-size:18px}.panel-top .eyebrow{display:none}.panel-top{margin-bottom:4px;padding-bottom:6px}.numbers{font-size:24px!important}#qte .qte-bottom{bottom:-10px}
 .letter-screen{gap:8px;padding-top:calc(var(--safe-top) + 8px);padding-bottom:calc(var(--safe-bottom) + 8px)}.letter-paper{font-size:21px;line-height:1.18;padding:16px 24px}.letter-paper p{margin-bottom:10px}.letter-signoff{line-height:1.05}
}

@media (pointer:coarse),(max-width:700px),(max-width:1100px) and (max-height:500px){
#hud .brand{display:none}#hud{justify-content:flex-end}#objective{top:calc(var(--safe-top) + 8px);right:auto;width:60%;max-width:60%}#objective button{margin-left:0}#objective>div:first-of-type{flex-wrap:wrap}
#touchControls{left:calc(max(12px,env(safe-area-inset-left)) + 24px)}#movePad i{left:calc(50% - 20px);top:calc(50% - 20px)}
#warning{z-index:30;top:calc(var(--safe-top) + 110px);left:14px;transform:none;width:calc(100% - 28px);background:#35121aeb;color:#fff;padding:8px;border:1px solid #fa7272;max-height:64px;overflow:auto}#warning:empty{display:none}}
@media (max-width:1100px) and (max-height:500px){#objective{width:28%;max-width:28%}#objective>.eyebrow{display:block}#warning{left:12px;top:calc(var(--safe-top) + 118px);width:28%;max-height:100px;font-size:12px}}

/* Short landscape tasks retain visible actions above the touch-control row. */
@media (max-width:1100px) and (max-height:500px){
 #stationPanel,#qte{bottom:calc(var(--safe-bottom) + 112px)}
 #stationBody .numbers{float:left;margin:0 12px 4px 0!important;line-height:1.3}
 #stationBody p{font-size:12px;line-height:1.35;margin:6px 0}
 #stationBody .actions{clear:both;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:6px 0}
 #stationBody .subtle{display:none}
}

@media (pointer:coarse),(max-width:700px),(max-width:1100px) and (max-height:500px){#qte{background:#14272b}}

@media(pointer:coarse),(max-width:700px),(max-width:1100px) and (max-height:500px){#objective #nextTask{display:block!important;margin-top:5px;font-size:11px;line-height:1.35;max-height:18dvh;overflow-y:auto;overscroll-behavior:contain;pointer-events:auto;white-space:normal}}
