/* Phone controls (js/touch.js; touch screens, or ?touch). Kept out of style.css on purpose. */
body.touchui { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#touch { --L: calc(env(safe-area-inset-left, 0px) + 12px); --R: calc(env(safe-area-inset-right, 0px) + 12px); --B: calc(env(safe-area-inset-bottom, 0px) + 26px);
  position: fixed; inset: 0; z-index: 20; pointer-events: none; touch-action: none; }
#touch button { pointer-events: auto; touch-action: none; font: inherit; color: var(--ink); padding: 0; margin: 0; cursor: pointer;
  background: rgba(28,18,36,.62); border: 1px solid rgba(255,255,255,.16); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#touch .t-sys { position: absolute; top: 14px; left: var(--L); display: flex; gap: 8px; }
#touch .t-sys button { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; color: var(--dim); }
#touch .t-zone { position: absolute; left: 0; bottom: 0; width: calc(var(--L) + 220px); height: 280px; pointer-events: auto; touch-action: none; }
#touch .t-base { position: absolute; left: calc(var(--L) + 14px); bottom: calc(var(--B) + 20px); width: 124px; height: 124px; border-radius: 50%;
  background: rgba(28,18,36,.45); border: 1.5px solid rgba(255,255,255,.22); }
#touch .t-base::before, #touch .t-base::after { content: ""; position: absolute; top: 50%; margin-top: -6px; border: 6px solid transparent; }
#touch .t-base::before { left: 8px; border-right-color: rgba(255,255,255,.35); }
#touch .t-base::after { right: 8px; border-left-color: rgba(255,255,255,.35); }
#touch .t-knob { position: absolute; left: 33px; top: 33px; width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffb08a, #ff6a4a 70%); box-shadow: 0 0 16px rgba(255,120,80,.6), inset 0 -3px 0 rgba(0,0,0,.25); }
#touch .t-zone.on .t-knob { box-shadow: 0 0 22px rgba(255,120,80,.85), inset 0 -3px 0 rgba(0,0,0,.25); }
#touch .t-hint { position: absolute; left: calc(var(--L) + 76px); transform: translateX(-50%); font-size: 9px; letter-spacing: 2px; color: var(--dim); text-shadow: 0 1px 3px #000a; }
#touch .t-up { bottom: calc(var(--B) + 150px); }
#touch .t-dn { bottom: calc(var(--B) + 2px); }
#touch .t-chip { position: absolute; width: 50px; height: 50px; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#touch .t-chip b { font-size: 16px; line-height: 1; }
#touch .t-chip span { font-size: 7px; letter-spacing: 1.5px; color: var(--dim); margin-top: 3px; }
#touch .t-chip i { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.1); }
#touch .t-chip u { display: block; height: 100%; width: 0; background: rgba(255,255,255,.4); }
#touch .t-chip.ready { border-color: rgba(120,255,160,.7); box-shadow: 0 0 12px rgba(120,255,160,.22); }
#touch .t-chip.ready u { background: #7dffa6; }
#touch .t-chip.cool u { background: #ffb347; }
#touch .t-chip.on { border-color: #8ce6ff; box-shadow: 0 0 14px #8ce6ff88; } #touch .t-chip.on u { background: #8ce6ff; }
#touch .t-chip.air { border-color: #8cc4ff; box-shadow: 0 0 14px #8cc4ff99; } #touch .t-chip.air u { background: #8cc4ff; }
#touch .t-chip.empty { opacity: .6; }
#t-rocket { right: calc(var(--R) + 62px); bottom: calc(var(--B) + 94px); } #t-rocket b { color: #ffb08a; }
#t-jump { right: calc(var(--R) + 4px); bottom: calc(var(--B) + 94px); } #t-jump b { color: #8cc4ff; }
#t-boost { right: calc(var(--R) + 96px); bottom: calc(var(--B) + 24px); } #t-boost b { color: #ff8a9a; }
#touch .t-hand { position: absolute; right: var(--R); bottom: calc(var(--B) + 22px); width: 86px; height: 62px; border-radius: 16px;
  border-color: rgba(255,180,120,.55); background: repeating-linear-gradient(-55deg, rgba(255,138,60,.85) 0 9px, rgba(30,16,30,.75) 9px 20px);
  box-shadow: 0 0 18px rgba(255,138,92,.35); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 7px; }
#touch .t-hand span { background: rgba(22,13,30,.85); padding: 3px 6px; border-radius: 6px; font-size: 8px; letter-spacing: 1.5px; font-weight: 600; }
#touch .down { filter: brightness(1.3); transform: scale(.94); }

#menux { position: absolute; top: 8px; right: 10px; width: 44px; height: 44px; border-radius: 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); cursor: pointer; }
body.touchui #menu .menu-head { position: relative; padding-right: 64px; }

/* the controls screen before a run: no controller picture on a phone */
body.touchui #ready svg { display: none; }
body.touchui #ready .keyline { max-width: 520px; margin: 10px auto 14px; font-size: 14px; line-height: 1.5; color: var(--ink); }

/* phone-sized HUD: small map, speed beside it, no keyboard chips (the touch buttons replace them) */
@media (max-height: 500px) {
  body.touchui #mapwrap { --s: 1; width: 92px; height: 92px; top: 12px; right: calc(env(safe-area-inset-right, 0px) + 8px); }
  body.touchui #hud-br { --s: .45; top: 30px; bottom: auto; right: calc(env(safe-area-inset-right, 0px) + 112px); width: auto; transform-origin: top right; }
  body.touchui #abil, body.touchui #hud-br .badges, body.touchui #hud-br .rpmbar, body.touchui #rpmtxt, body.touchui #hud-br .gearbox,
  body.touchui #hud-tl, body.touchui #hud-bl { display: none !important; }
  body.touchui #combat { --s: .8; }
  /* lobby fits a 390 px-tall screen (and scrolls from the top if it ever doesn't) */
  body.touchui #start { place-items: start center; padding: 8px 0; }
  body.touchui #start .card { padding: 10px 26px 12px; }
  body.touchui #start h1 { font-size: 24px; margin-bottom: 2px; }
  body.touchui .lname { margin-bottom: 0 !important; }
  body.touchui .lobby { gap: 6px; width: 500px; grid-template-columns: 1fr 1fr; align-items: end; }
  body.touchui #bsettings, body.touchui #lmsg { grid-column: 1 / -1; }
  body.touchui #start .card > p.dim:last-child { display: none; }
  /* car picker: car on the left, name / stats / Select on the right */
  body.touchui #garage { place-items: start center; }
  body.touchui #garage .gcard { display: grid; grid-template-columns: auto 300px; column-gap: 18px; align-items: center; padding: 10px 16px; }
  body.touchui #garage .gcard > * { grid-column: 2; }
  body.touchui #garage h2 { font-size: 18px; margin-bottom: 2px; }
  body.touchui #garage .gstage { grid-column: 1; grid-row: 2 / span 7; }
  body.touchui #gview { width: 340px; height: 220px; }
  body.touchui #gname { font-size: 24px; }
  body.touchui #gblurb { min-height: 0; margin: 2px auto 6px; font-size: 13px; }
  body.touchui #gstats { width: 280px; gap: 3px; margin-bottom: 6px; }
  body.touchui #garage .gcard > p.dim { display: none; }
  body.touchui .lobby button, body.touchui .lobby input { padding: 6px 12px; font-size: 14px; }
}
