/* Keep Safari browser chrome, the home indicator and landscape notches outside controls. */
#world{touch-action:none;height:100dvh}
.touch-controls[hidden],.touch-controls [hidden],.touch-menu [hidden]{display:none!important}
.touch-controls{position:fixed;inset:0;z-index:10;pointer-events:none;-webkit-user-select:none;user-select:none}
.touch-controls button,.touch-stick{pointer-events:auto;touch-action:none;-webkit-touch-callout:none}
.touch-controls button,.touch-menu button{min-height:44px;font-size:12px;border-radius:10px;background:#172b30d9;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.touch-toolbar{position:absolute;top:calc(env(safe-area-inset-top) + 56px);left:max(14px,env(safe-area-inset-left));display:flex;gap:7px;max-width:calc(100% - 28px)}
.touch-toolbar button{padding:10px 14px;white-space:nowrap}
.touch-status{position:absolute;top:calc(env(safe-area-inset-top) + 20px);left:max(16px,env(safe-area-inset-left));max-width:calc(100% - 125px);font-size:11px;letter-spacing:.025em;text-shadow:0 2px 5px #000;background:#172b306b;border-radius:5px;padding:5px 7px}
.touch-move{position:absolute;bottom:calc(env(safe-area-inset-bottom) + 18px);left:max(18px,env(safe-area-inset-left))}
.touch-stick{position:relative;width:128px;height:128px;border-radius:50%;background:#162c354d;border:1px solid #f5f4e56b;box-shadow:inset 0 0 35px #112c3426}
.touch-stick::before,.touch-stick::after{content:'';position:absolute;background:#ffffff20;inset:50% 12px auto;height:1px}.touch-stick::after{inset:12px auto 12px 50%;width:1px;height:auto}
.touch-stick-thumb{position:absolute;left:40px;top:40px;width:48px;height:48px;border-radius:50%;background:#f8f4e840;border:1px solid #f8f4e8ad;box-shadow:0 4px 15px #0002;pointer-events:none;will-change:transform}
.touch-stick-mark{position:absolute;top:11px;left:0;right:0;text-align:center;font-size:8px;letter-spacing:.16em;color:#fff9}
.touch-boost{display:block;margin:0 auto 10px;width:72px;padding:8px}
.touch-look-hint{position:absolute;right:max(20px,env(safe-area-inset-right));bottom:calc(env(safe-area-inset-bottom) + 157px);font-size:10px;color:#ffffffe0;text-shadow:0 2px 4px #000;text-align:right;max-width:145px;line-height:1.5}
.touch-pedals,.touch-flight{position:absolute;right:max(18px,env(safe-area-inset-right));bottom:calc(env(safe-area-inset-bottom) + 28px);display:flex;gap:10px}
.touch-pedals button{width:70px;min-height:82px;padding:10px 6px;border:1px solid #f5f4e570;font-size:13px}.touch-pedals button span{display:block;font-size:9px;margin-top:7px;color:#ffffffe0}.touch-pedals [data-hold="accelerate"]{background:#344b40c9}
.touch-flight button{min-width:64px;min-height:58px;padding:10px}
.touch-held,.touch-controls button.touch-held{background:#e3c5919e;border-color:#f8f4e8;color:#102528}
.touch-controls.touch-blocked{visibility:hidden}
.touch-menu{width:min(360px,calc(100vw - 32px));max-height:calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));border:1px solid #e3c59166;border-radius:12px;background:#172b30;color:#f8f4e8;padding:20px;overflow:auto;overscroll-behavior:contain}
.touch-menu::backdrop{background:#071415ad}.touch-menu-heading{display:flex;align-items:center;justify-content:space-between;gap:10px}.touch-menu-heading h2{font-size:24px;margin:0}.touch-menu-heading button{padding:10px}.touch-menu-actions{display:grid;gap:8px;margin-top:20px}.touch-menu p{font-size:12px;line-height:1.6;color:#eee7d9bf;margin-bottom:0}.touch-menu button[aria-pressed=true]{background:#e3c591;color:#172b30}
.touch-toolbar button.touch-far{opacity:.55}
/* A connected gamepad drives: thumb controls step aside, the toolbar stays reachable by tap. */
.touch-controls.touch-gamepad .touch-move,.touch-controls.touch-gamepad .touch-pedals,.touch-controls.touch-gamepad .touch-flight,.touch-controls.touch-gamepad .touch-look-hint{display:none}
.touch-controls.touch-gamepad .touch-toolbar{opacity:.72}
#touch-help{display:none}
body.touch-enabled{overscroll-behavior:none}body.touch-enabled header{max-width:calc(100vw - 150px)}body.touch-enabled header h1{font-size:32px}body.touch-enabled footer{display:none}body.touch-enabled.playing header{display:none}
body.touch-enabled #welcome{max-height:calc(100dvh - 124px - env(safe-area-inset-top) - env(safe-area-inset-bottom));overflow:auto;overscroll-behavior:contain;top:calc(50% + 22px);transform:translateY(-50%)}
body.touch-enabled #keyboard-help{display:none}body.touch-enabled #touch-help{display:block;font-size:12px;color:#e3c591;line-height:1.6}
body.touch-enabled #controller-help{font-size:10px}
body.touch-enabled .bg2-radio{top:calc(env(safe-area-inset-top) + 14px);right:max(14px,env(safe-area-inset-right));max-height:calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}
body.touch-enabled .bg2-radio>button{min-height:44px;border-radius:10px;font-size:12px}
body.touch-enabled .bg2-radio-panel button,body.touch-enabled .bg2-radio-panel select{min-height:44px}
body.touch-enabled .bg2-radio-player,body.touch-enabled .bg2-radio-player iframe{touch-action:auto}
@media (orientation:landscape) and (max-height:550px){
 .touch-toolbar{top:calc(env(safe-area-inset-top) + 14px);left:50%;transform:translateX(-50%);gap:5px}.touch-toolbar button{padding:9px 11px}
 .touch-status{top:calc(env(safe-area-inset-top) + 70px);font-size:10px;max-width:180px}
 .touch-move{bottom:calc(env(safe-area-inset-bottom) + 12px)}.touch-stick{width:108px;height:108px}.touch-stick-thumb{left:30px;top:30px}
 .touch-boost{position:absolute;left:118px;bottom:0;margin:0;min-width:54px;width:54px}.touch-pedals,.touch-flight{bottom:calc(env(safe-area-inset-bottom) + 18px)}
 .touch-look-hint{bottom:calc(env(safe-area-inset-bottom) + 112px)}
 body.touch-enabled header{top:14px;left:max(18px,env(safe-area-inset-left))}body.touch-enabled header h1{font-size:24px}body.touch-enabled header .eyebrow{font-size:8px}
 body.touch-enabled #welcome{left:50%;top:50%;transform:translate(-50%,-50%);max-height:calc(100dvh - 24px - env(safe-area-inset-bottom));padding:18px;width:min(400px,calc(100vw - 260px))}
 body.touch-enabled #welcome h2{font-size:26px;margin:6px 0}body.touch-enabled #welcome p{margin:8px 0}body.touch-enabled #controller-help{display:none}
 body.touch-enabled .map-panel{max-height:none}body.touch-enabled .map-layout{flex-direction:row}body.touch-enabled .map-panel{width:220px;display:flex;flex-direction:column;overflow:auto;padding:12px 14px}
 /* The primary action stays in reach: destination and Fast-travel first, the landmark list scrolls after. */
 body.touch-enabled .map-destination{order:-1;margin:0 0 12px;padding:0 0 12px;border-top:0;border-bottom:1px solid #d5c59428}body.touch-enabled .map-key,body.touch-enabled .map-limit{display:none}
}
@media (max-width:360px){.touch-toolbar{gap:5px}.touch-toolbar button{padding:9px 11px}.touch-move{left:12px}.touch-stick{width:116px;height:116px}.touch-stick-thumb{left:34px;top:34px}.touch-pedals,.touch-flight{right:12px;gap:7px}.touch-pedals button{width:65px}.touch-look-hint{right:12px;max-width:135px}}
/* A live YouTube dock keeps its full visible player; game controls sit outside it. */
@media (orientation:portrait){body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-toolbar{top:auto;bottom:calc(env(safe-area-inset-bottom) + 180px)}}
@media (orientation:landscape) and (max-height:550px){
 /* Leave a useful world-look strip as well as room for both thumbs. Requested video size stays saved. */
 body.touch-enabled{--touch-radio-reserve:440px}
 body.touch-enabled .touch-controls{--touch-effective-radio-width:min(var(--touch-radio-width),max(200px,calc(100vw - max(18px,env(safe-area-inset-left)) - max(18px,env(safe-area-inset-right)) - var(--touch-radio-reserve))))}
 body.touch-enabled .bg2-radio[data-has-player="true"]{--touch-effective-player-width:min(var(--player-width),max(200px,calc(100vw - max(18px,env(safe-area-inset-left)) - max(18px,env(safe-area-inset-right)) - var(--touch-radio-reserve))));width:calc(var(--touch-effective-player-width) + 18px);right:max(18px,env(safe-area-inset-right))}
 body.touch-enabled .bg2-radio[data-has-player="true"] .bg2-radio-player iframe{height:max(200px,calc(var(--touch-effective-player-width)*.5625))}
 body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-pedals,body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-flight{right:calc(var(--touch-effective-radio-width) + 32px + max(18px,env(safe-area-inset-right)));flex-direction:column}
 body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-flight button{width:70px}
 body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-look-hint{display:none}
 body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-toolbar{left:max(18px,env(safe-area-inset-left));transform:none;display:grid;grid-template-columns:repeat(4,minmax(44px,1fr));gap:6px;width:min(252px,calc(100vw - max(18px,env(safe-area-inset-left)) - max(18px,env(safe-area-inset-right)) - var(--touch-effective-radio-width) - 114px));max-width:none}
 body.touch-enabled:has(.bg2-radio[data-has-player="true"]) .touch-toolbar button{padding:8px 4px;font-size:11px;white-space:normal;min-width:0}
}
