/* Thumb zones: walking and jumping get the clearest, largest targets. */
@media (pointer:coarse),(max-width:1000px),(max-height:600px){
 #root #stage #touch{padding:8px max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));align-items:end;gap:16px;z-index:8}
 #root #stage #touch .dpad{display:grid;grid-template-columns:repeat(2,52px);grid-template-rows:44px 54px;gap:8px;align-items:end}
 #root #stage #touch .actions{display:grid;grid-template-columns:48px 52px 60px;grid-template-rows:44px 60px;max-width:none;gap:8px;align-items:end}
 #root #stage #touch button{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;width:100%;height:100%;min-width:44px;min-height:44px;margin:0;padding:3px;border-width:2px;border-radius:8px;font-size:26px;line-height:1;box-shadow:0 3px 0 #030b18, inset 0 1px 0 #fff2;touch-action:none;opacity:.88}
 #root #stage #touch button[hidden]{display:none!important}
 #root #stage #touch button small{font:10px/1 'VT323',monospace;letter-spacing:.3px;color:#f3faff}
 #root #stage #touch button svg{width:25px;height:25px;flex-shrink:0}
 #root #stage #touch .guard-button{grid-column:1;grid-row:1;width:44px;height:44px;justify-self:start;background:#172e43;border-color:#73879f;font-size:24px}
 #root #stage #touch .duel-dash,#root #stage #touch .dismount-button{grid-column:2;grid-row:1;width:44px;height:44px;justify-self:end}
 #root #stage #touch [data-key="ArrowLeft"]{grid-column:1;grid-row:2}
 #root #stage #touch [data-key="ArrowRight"]{grid-column:2;grid-row:2}
 #root #stage #touch [data-key="KeyV"]{grid-column:1;grid-row:1}
 #root #stage #touch .defend-button{grid-column:2;grid-row:1;width:44px;justify-self:end;background:#123b55;border-color:#79cadd}
 #root #stage #touch [data-key="KeyR"]{grid-column:1;grid-row:2;width:48px;height:50px;justify-self:end;background:#39304e;border-color:#a699cf;font-size:24px}
 #root #stage #touch [data-key="KeyQ"]{grid-column:2;grid-row:2;height:54px;background:#244d69;border-color:#a1d5eb}
 #root #stage #touch [data-key="ArrowUp"]{grid-column:3;grid-row:2;background:#984433;border-color:#ffb389;font-size:34px}
 #root #stage #touch .special-ready{background:#336342;border-color:#a5eabb}
 #root #stage #touch .parry-active{outline:3px solid #fff5b8;outline-offset:2px}
 #root #stage #touch button.held{opacity:1;filter:brightness(1.3);transform:translateY(2px);box-shadow:0 1px 0 #030b18}
 #root #stage #touch.menu-touch{display:none}
 #root #stage[data-mode="play"] #hud{top:max(6px,env(safe-area-inset-top));left:max(8px,env(safe-area-inset-left));right:164px;gap:5px;grid-template-columns:.8fr 1.5fr 1fr}
 #root #stage[data-mode="play"] #hud>span{padding:6px 7px;border-width:1px;min-width:0}
 #root #stage[data-mode="play"] #hud .special-key,#root #stage[data-mode="play"] #hud .run-clock,#root #stage[data-mode="play"] #hud .citizen-name{display:none}
 #root #stage[data-mode="play"] #hud b{font-size:clamp(8px,1.15vw,11px);line-height:1.5}
 #root #stage[data-mode="play"] #hud small{font-size:clamp(12px,1.7vw,16px);line-height:1.2}
 #root #stage[data-mode="play"] #hud .mini-meter{margin-top:4px;height:3px}
 #root #stage[data-mode="play"] #hud .play-ability>b{max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 #root #stage[data-mode="play"] :is(#sound,#pause,#fullscreen){width:44px;height:44px;min-height:44px;top:max(6px,env(safe-area-inset-top));padding:7px;border-width:2px}
 #root #stage[data-mode="play"] #pause{right:8px}#root #stage[data-mode="play"] #sound{right:58px}#root #stage[data-mode="play"] #fullscreen{right:108px}
}
@media (max-width:600px) and (orientation:portrait){
 #root #stage[data-mode="play"] #hud{right:8px;top:54px;grid-template-columns:.9fr 1.5fr}
 #root #stage[data-mode="play"] #hud .play-ability{grid-column:1/-1;display:flex;align-items:center;gap:8px;padding:4px 7px}
 #root #stage[data-mode="play"] #hud .play-ability .mini-meter{flex:1;min-width:20px;margin:0}
 #root #stage[data-mode="play"] #hud .play-ability>b{max-width:40%}
 #root #stage[data-mode="play"] #hud b{font-size:8px}#root #stage[data-mode="play"] #hud small{font-size:13px}
}

/* Historical HUD: translucent panels reserve more room for the route. */
#root #stage[data-history-theme]:not([data-history-theme='']) #hud{gap:6px}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud>span{padding:6px 9px;gap:3px;background:#101c2ba6;text-shadow:0 1px 2px #09121f;box-shadow:none}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud .play-objective{background:color-mix(in srgb,var(--episode-dark) 68%,transparent)}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud b{font-size:9px;line-height:1.3}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud small{font-size:16px;line-height:1.1}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud .episode-status>b{display:none}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud .run-clock time{font-size:23px}
#root #stage[data-history-theme]:not([data-history-theme='']) #hud .mini-meter{height:3px;margin-top:1px}
@media(pointer:coarse),(max-height:600px),(max-width:760px){
 #root #stage[data-history-theme]:not([data-history-theme='']) #hud{gap:4px}
 #root #stage[data-history-theme]:not([data-history-theme='']) #hud>span{padding:4px 6px;gap:2px}
 #root #stage[data-history-theme]:not([data-history-theme='']) #hud b{font-size:8px;line-height:1.25}
 #root #stage[data-history-theme]:not([data-history-theme='']) #hud small{font-size:13px;line-height:1.1}
 #root #stage[data-history-theme]:not([data-history-theme='']) #hud .citizen-name{display:none}
 #root #stage[data-history-theme]:not([data-history-theme='']) #hud .hud-objective-line>span:last-child{grid-column:auto}
}
/* Pause: story preferences sit beside the clock in equally sized cards. */
#root #stage .pause-header-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:390px;max-width:100%;flex-shrink:0;align-items:stretch}
#root #stage .pause-header-cards>.run-badge,#root #stage .pause-header-cards>.story-settings{box-sizing:border-box;width:100%;min-width:0;max-width:none;min-height:68px;margin:0;padding:5px 8px;border-width:2px;background:#123039aa;flex:none}
#root #stage .pause-header-cards .story-settings>strong{font:14px/1.1 VT323,monospace;color:#dfefdf;white-space:nowrap}
#root #stage .pause-header-cards .story-switches{gap:8px}
#root #stage .pause-header-cards .story-settings label{font:17px/1 VT323,monospace;min-height:36px;gap:4px}
@media(max-width:600px){
 #root #stage .pause-panel .run-heading{flex-wrap:wrap}
 #root #stage .pause-header-cards{width:100%;gap:6px}
 #root #stage .pause-header-cards>.run-badge,#root #stage .pause-header-cards>.story-settings{padding:3px 5px;min-height:66px}
 #root #stage .pause-header-cards .story-settings>strong{font-size:13px}
 #root #stage .pause-header-cards .story-settings label{font-size:16px;min-height:40px}
 #root #stage .pause-header-cards .story-switches{gap:5px}
}
@media(max-height:500px) and (orientation:landscape){
 #root #stage .pause-header-cards{width:350px}
 #root #stage .pause-header-cards>.run-badge,#root #stage .pause-header-cards>.story-settings{min-height:60px;padding:2px 5px}
}

@media(max-width:400px){
 #root #stage #touch{gap:8px;padding-left:max(8px,env(safe-area-inset-left));padding-right:max(8px,env(safe-area-inset-right))}
 #root #stage #touch .dpad,#root #stage #touch .actions{gap:4px}
}
