#touch-controls,#touch-pause,#rotate-hint,.touch-help{display:none}
.touch-controls-available #game{touch-action:none}
.touch-controls-available #touch-pause{display:flex}
.touch-controls-available .touch-help{display:block}
.touch-controls-available #touch-controls{display:block;position:fixed;inset:0;pointer-events:none;z-index:4;user-select:none;-webkit-user-select:none}
#touch-controls button{display:flex;align-items:center;justify-content:center;min-width:52px;min-height:52px;border:1px solid #ffffff40;border-radius:12px;background:#11171bd9;color:#e4eaed;font-size:12px;font-weight:600;touch-action:none;pointer-events:auto;-webkit-touch-callout:none}
#touch-controls button.is-held{background:#eae7df;color:#161c20;border-color:#eae7df}
#touch-controls button svg{width:25px;height:25px;stroke-width:2}
#touch-controls small{color:inherit;font-size:9px;font-weight:400}
.touch-steering,.touch-flight,.touch-pedals{position:absolute;display:flex;gap:8px}
.touch-steering{left:max(20px,env(safe-area-inset-left));bottom:max(24px,env(safe-area-inset-bottom))}
.touch-steering button{width:64px;height:60px}
.touch-flight{left:max(20px,env(safe-area-inset-left));bottom:calc(max(24px,env(safe-area-inset-bottom)) + 70px);align-items:end}
#touch-controls .touch-flight button{min-width:44px;min-height:44px;flex-direction:column;gap:0}
#touch-controls [data-touch-control=lift]{width:54px}
#touch-controls [data-touch-control^=roll]{font-size:23px;line-height:1}
.touch-pedals{right:max(20px,env(safe-area-inset-right));bottom:max(24px,env(safe-area-inset-bottom));display:grid;grid-template-columns:62px 68px;grid-template-rows:44px 64px}
#touch-controls [data-touch-control=boost]{grid-column:2;min-height:44px;min-width:44px}
#touch-controls [data-touch-control=brake]{grid-row:2}
#touch-controls [data-touch-control=throttle]{grid-row:2;grid-column:2;background:#eae7df;color:#161c20;border-color:#eae7df;font-size:17px}
#touch-controls [data-touch-control=throttle].is-held{background:#b9d2bd;border-color:#b9d2bd}
.touch-controls-available .key-hints{display:none}
.touch-controls-available .pause-hint{display:none}
.touch-controls-available .pause-card button,.touch-controls-available .quality-row select,.touch-controls-available dialog .close,.touch-controls-available #car-controls-close,.touch-controls-available #wing-adjustment button{min-width:44px;min-height:44px}
.touch-controls-available .volume-row input{height:44px}
body[data-phase=intro] #touch-controls,body[data-phase=intro] #touch-pause{display:none}

/* Keep all course choices separate from the brand and utilities. */
@media(min-width:951px) and (max-width:1400px){
  header .brand{width:156px}
  header .locations button{min-width:66px;padding:0 7px;font-size:11px;gap:5px}
  header .utilities{gap:2px}
}

/* Tablets and touch laptops reserve both lower corners for held controls. */
@media(min-width:951px),(min-width:701px) and (min-height:551px),(min-height:551px) and (orientation:landscape){
  .touch-controls-available .hud-bar{position:absolute;inset:0;display:block;pointer-events:none}
  .touch-controls-available .speed-panel{position:absolute;left:max(24px,env(safe-area-inset-left));bottom:calc(max(24px,env(safe-area-inset-bottom)) + 144px)}
  .touch-controls-available .power-panel{position:absolute;right:max(24px,env(safe-area-inset-right));bottom:calc(max(24px,env(safe-area-inset-bottom)) + 144px)}
  .touch-controls-available .drive-actions{position:absolute;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translateX(-50%);padding:0}
  .touch-controls-available .bottom-controls button{min-width:44px;min-height:44px}
  .touch-controls-available .bottom-controls #car-controls-toggle{min-height:48px}
}

@media(max-width:950px) and (max-height:550px){
  .touch-controls-available header{top:max(6px,env(safe-area-inset-top));left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));gap:10px;align-items:center}
  .touch-controls-available .brand{display:none}
  .touch-controls-available .locations{position:static;transform:none;flex:1;max-width:490px;min-width:0;gap:0;padding:2px;border-radius:6px;justify-content:space-between}
  .touch-controls-available .locations button{flex:1;min-width:0;height:44px;padding:0 7px;font-size:11px;gap:0}
  .touch-controls-available .location-number{display:none}
  .touch-controls-available .utilities{padding:0;gap:2px}
  .touch-controls-available .utilities button{width:44px;min-height:44px;padding:10px}
  .touch-controls-available .utilities #about-open{display:none}
  .touch-controls-available .hud-bar{position:absolute;inset:0;display:block;pointer-events:none}
  .touch-controls-available .speed-panel{position:absolute;top:72px;left:max(20px,env(safe-area-inset-left));width:90px}
  .touch-controls-available #speed{font-size:37px;letter-spacing:-2px}
  .touch-controls-available .speed-row{gap:6px}
  .touch-controls-available .unit{font-size:9px}
  .touch-controls-available .speed-line{margin:7px 0 6px}
  .touch-controls-available .small-stat{font-size:8px}
  .touch-controls-available .power-panel{position:absolute;right:max(20px,env(safe-area-inset-right));top:74px;display:flex;gap:10px;align-items:flex-start}
  .touch-controls-available .power-data{width:82px}
  .touch-controls-available .mode-summary{display:none}
  .touch-controls-available .gas-heading{font-size:9px}
  .touch-controls-available .gas-heading b{font-size:15px}
  .touch-controls-available .fuel{margin:7px 0 7px}
  .touch-controls-available .altitude-row{font-size:8px}
  .touch-controls-available .drive-actions{position:absolute;left:50%;bottom:max(19px,env(safe-area-inset-bottom));transform:translateX(-50%);padding:0;gap:0}
  .touch-controls-available .bottom-controls{gap:4px;flex-wrap:nowrap}
  .touch-controls-available .bottom-controls button{min-width:44px;min-height:44px;padding:10px}
  .touch-controls-available .bottom-controls button:not(#car-controls-toggle) span{display:none}
  .touch-controls-available .bottom-controls #car-controls-toggle{min-height:44px;padding:9px 13px;margin-left:0;gap:0}
  .touch-controls-available #car-controls-toggle>svg,.touch-controls-available .garage-trigger-label small{display:none}
  .touch-controls-available .garage-trigger-label strong{font-size:12px}
  .touch-controls-available #race-telemetry{top:67px;left:50%;padding:6px 10px;gap:10px;max-width:calc(100% - 250px)}
  .touch-controls-available #lap-time{font-size:17px}
  .touch-controls-available #lap{font-size:8px}
  .touch-controls-available .current-lap{gap:7px}
  .touch-controls-available .lap-history{gap:9px;padding-left:9px}
  .touch-controls-available .lap-history>span{font-size:7px;gap:2px}
  .touch-controls-available .lap-history output{font-size:9px}
  .touch-controls-available #lap-validity{font-size:8px}
  .touch-controls-available #notice{top:113px;padding:6px 10px;font-size:10px;max-width:55vw}
  .touch-controls-available .car-controls-panel{left:50%;right:auto;transform:translateX(-50%);top:66px;bottom:75px;width:350px;max-width:calc(100vw - 48px);max-height:none;padding:15px 18px;z-index:2}
  .touch-controls-available .panel-heading{margin-bottom:10px}
  .touch-controls-available .panel-heading h2{font-size:20px}
  .touch-controls-available .car-toggles button{min-height:48px}
  .touch-controls-available .wing-positions button{min-height:55px}
  .touch-controls-available #aero{min-height:44px;min-width:44px}
  .touch-controls-available #race-music{top:64px;right:50%;transform:translateX(50%);width:240px;max-height:calc(100dvh - 140px);overflow:auto}
  .touch-controls-available .music-heading{padding:5px 7px;gap:6px}
  .touch-controls-available .music-heading button{width:44px;height:44px}
  .touch-controls-available #pause{padding:8px}
  .touch-controls-available .pause-card{max-height:calc(100dvh - 16px);padding:18px 24px;width:min(420px,90vw)}
  .touch-controls-available .pause-heading{margin-bottom:14px}
  .touch-controls-available .pause-heading .eyebrow{display:none}
  .touch-controls-available .pause-heading h1{margin:0;font-size:23px}
  .touch-controls-available .pause-actions{margin-bottom:16px}
  .touch-controls-available .pause-settings{gap:9px;padding-top:12px}
  .touch-controls-available dialog{max-height:calc(100dvh - 24px);padding:24px;overscroll-behavior:contain}
  .touch-controls-available #controls .control-grid{display:none}
  .touch-controls-available .touch-help p{border:0;padding:0;margin:13px 0;font-size:12px}
  .touch-controls-available .intro-caption{left:max(25px,env(safe-area-inset-left));bottom:125px}
  .touch-controls-available .intro-caption h1{font-size:32px}
  .touch-controls-available .entry-actions{left:max(25px,env(safe-area-inset-left));bottom:52px}
  .touch-controls-available[data-phase=intro] .brand{display:flex;width:160px}
  .touch-controls-available[data-phase=intro] .locations{display:none}
  .touch-controls-available[data-phase=intro] .utilities{margin-left:auto}
  .touch-controls-available[data-phase=intro] .utilities #about-open{display:block;width:auto}
}
@media(max-width:700px) and (orientation:portrait){
  .touch-controls-available #rotate-hint{position:fixed;top:calc(max(18px,env(safe-area-inset-top)) + 90px);left:50%;transform:translateX(-50%);display:flex;flex-direction:column;gap:5px;width:250px;text-align:center;padding:13px 16px;border:1px solid #ffffff25;border-radius:8px;background:#101518db;z-index:3;pointer-events:none;font-size:15px;color:#e6eaec}
  .touch-controls-available #rotate-hint small{font-size:11px;color:#a9b5bc}
  .touch-controls-available .locations{max-width:calc(100vw - 24px);gap:0;padding:2px}
  .touch-controls-available .locations button{min-width:0;padding:0 8px;height:44px;font-size:11px}
  .touch-controls-available .locations .location-number{display:none}
  .touch-controls-available .brand{width:135px}
  .touch-controls-available .utilities #about-open{display:none}
  .touch-controls-available .utilities button{width:36px;min-height:44px}
  .touch-controls-available .hud-bar{bottom:175px;grid-template-columns:72px 1fr 80px}
  .touch-controls-available .drive-actions{position:fixed;left:50%;bottom:150px;transform:translateX(-50%)}
  .touch-controls-available .bottom-controls button{min-height:44px;min-width:44px}
  .touch-controls-available .bottom-controls #car-controls-toggle{min-height:44px}
  .touch-controls-available .car-controls-panel{top:100px;bottom:150px;max-height:none;left:12px;right:12px;width:auto}
  .touch-controls-available #race-telemetry{top:195px;gap:9px}
  .touch-controls-available #race-music{top:245px;right:50%;transform:translateX(50%);width:240px}
  .touch-controls-available #controls .control-grid{display:none}
}

/* A captured, proportional thumb pad leaves room for the lift controls above. */
#touch-steering-slider{display:none;position:absolute;left:max(20px,env(safe-area-inset-left));bottom:max(24px,env(safe-area-inset-bottom));width:168px;height:64px;border:1px solid #ffffff40;border-radius:14px;background:#0a111bd9;color:#cad8e1;touch-action:none;pointer-events:auto;cursor:grab;-webkit-touch-callout:none;--steering-position:50%}
#touch-controls[data-steering-mode=slider] #touch-steering-slider{display:flex;align-items:center;justify-content:space-between}
#touch-controls[data-steering-mode=slider] .touch-steering{display:none}
#touch-steering-slider:focus-visible{outline:2px solid #dce8eb;outline-offset:4px}
#touch-steering-slider.is-held{cursor:grabbing;border-color:#dce8eb88;background:#15232eea}
.steering-rail{position:absolute;left:24px;right:24px;top:50%;height:2px;background:#7b98ac38}
.steering-center{position:absolute;left:50%;top:-5px;height:12px;width:1px;background:#bbced46b}
.steering-thumb{position:absolute;top:50%;left:var(--steering-position);transform:translate(-50%,-50%);display:grid;place-items:center;width:44px;height:44px;border:1px solid #d1dde74a;border-radius:11px;background:#30404d;box-shadow:0 3px 12px #0004}
.steering-thumb svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
#touch-steering-slider.is-held .steering-thumb{background:#e2e8e6;color:#20313e;border-color:#e2e8e6}
.steering-direction{padding:0 11px;font-size:20px;color:#8ea7ba55}
@media(max-width:950px) and (max-height:550px),(max-width:700px) and (orientation:portrait){
  .touch-controls-available #touch-steering-slider{bottom:max(20px,env(safe-area-inset-bottom))}
  .touch-controls-available #race-result{top:116px;width:min(330px,calc(100vw - 32px));padding:13px 40px 13px 16px;gap:15px}
  .touch-controls-available #race-result-time{font-size:22px}
  .touch-controls-available #race-result-dismiss{width:36px;height:36px;top:4px;right:3px}
}
