/* The compact driving layout is scoped to touch input in the racing sedan. */
body.racer-touch-driving {
  --racer-bottom:max(28px,calc(env(safe-area-inset-bottom) + 8px));
  --racer-left:max(14px,calc(env(safe-area-inset-left) + 8px));
  --racer-right:max(14px,calc(env(safe-area-inset-right) + 8px));
  --racer-exit-size:44px;
  --racer-pedal-height:clamp(70px,26vh,108px);
  --racer-pedal-width:clamp(145px,23vw,202px);
  --racer-steer-width:clamp(112px,19vw,170px);
  --racer-steer-height:48px;
  --racer-steer-bottom:var(--racer-bottom);
  --racer-hand-height:44px;
  --racer-gap:12px;
}
body.racer-touch-driving :is(#brand,#stick,#turn-help,#phone-unfold,#bolha-public-chat,#action,#drive-pad .drive-brake,#drive-pad .drive-handbrake),
body.racer-touch-driving #bolha-phone-dock:not(.engaged) #phone {display:none}
body.racer-touch-driving #drive-pad {
  left:var(--racer-left);bottom:calc(var(--racer-steer-bottom) + var(--racer-steer-height) + 8px);
  flex-direction:row;gap:6px;
}
body.racer-touch-driving #drive-pad :is(.drive-lightwrap,.drive-light,.drive-horn) {width:44px;height:44px}
body.racer-touch-driving #drive-pad :is(.drive-light,.drive-horn) {
  display:grid;place-items:center;padding:0;border:1px solid #355571;border-radius:11px;
  background:#0e2236;color:#b7d8fa;font-size:18px;
}
body.racer-touch-driving #drive-pad .drive-lightmenu {left:0;bottom:54px;max-width:calc(100vw - 28px)}
body.racer-touch-driving #drive-hud {
  top:auto;left:auto;right:var(--racer-right);
  bottom:calc(var(--racer-bottom) + var(--racer-pedal-height) + var(--racer-hand-height) + 2 * var(--racer-gap));
  padding:6px 9px;border:1px solid #355571;border-radius:9px;background:#0e2236;
}
body.racer-touch-driving #drive-hud b {font-size:18px}
body.racer-touch-driving #drive-hud > span {display:none}
#racer-touch button {
  position:fixed;z-index:16;touch-action:none;user-select:none;-webkit-user-select:none;
  color:#eaf4ff;border:1px solid #355571;border-radius:11px;background:#0e2236;
}
#racer-touch button:focus-visible {outline:2px solid #abd8ff;outline-offset:2px}
#racer-touch .racer-exit {
  top:max(18px,env(safe-area-inset-top));left:var(--racer-left);
  width:var(--racer-exit-size);height:var(--racer-exit-size);padding:10px;display:grid;place-items:center;
}
#racer-touch .racer-exit svg {width:22px;height:22px}
#racer-touch .racer-steer {
  left:var(--racer-left);bottom:var(--racer-steer-bottom);width:var(--racer-steer-width);
  height:var(--racer-steer-height);padding:0;border:0;background:none;
}
.racer-steer::before {
  content:"";position:absolute;inset:16% 0;border:1px solid #718391;border-radius:20px;
  background:repeating-linear-gradient(90deg,#7f8f9a 0 1px,transparent 1px 12%) center/78% 20% no-repeat,
             linear-gradient(#0c131b,#202c38);
  box-shadow:inset 0 2px 6px #05080c;
}
.racer-steer::after {
  content:"";position:absolute;top:0;bottom:0;width:25%;left:calc(37.5% + var(--steer-offset,0%));
  border:1px solid #9baab7;border-radius:8px;
  background:repeating-linear-gradient(90deg,#b4bec7 0 1px,#566675 1px 3px) center/36% 35% no-repeat,
             linear-gradient(#687787,#273746);
  box-shadow:0 2px 4px #02050a;
  transition:left 100ms ease-out;
}
.racer-steer.held::after {transition:none}
#racer-touch .racer-handbrake {
  right:var(--racer-right);bottom:calc(var(--racer-bottom) + var(--racer-pedal-height) + var(--racer-gap));
  width:92px;height:var(--racer-hand-height);font:600 13px var(--b-font);
}
.racer-pedals {
  /* Extend into half of the grid gap on each side, leaving 6px between pedals. */
  --pedal-hit-inner:max(0px,calc(var(--racer-pedal-width) * .03 - 3px));
  --pedal-hit-left:clamp(0px,calc(100vw - var(--racer-left) - var(--racer-steer-width) - 8px - var(--racer-right) - var(--racer-pedal-width)),clamp(12px,3vw,24px));
  --pedal-hit-right:min(12px,calc(var(--racer-right) - env(safe-area-inset-right) - 4px));
  --pedal-hit-bottom:min(16px,calc(var(--racer-bottom) - env(safe-area-inset-bottom) - 4px));
  position:fixed;right:var(--racer-right);bottom:var(--racer-bottom);z-index:16;
  width:var(--racer-pedal-width);height:var(--racer-pedal-height);
  display:grid;grid-template-columns:54fr 40fr;align-items:end;gap:6%;pointer-events:none;
}
#racer-touch .racer-pedal {
  position:relative;width:100%;height:100%;padding:0;border:0;background:none;pointer-events:auto;
}
#racer-touch .racer-brake {height:75%}
.racer-pedal::after {
  content:"";position:absolute;bottom:calc(-1 * var(--pedal-hit-bottom));
}
.racer-brake::after {
  top:calc(-8px - var(--racer-pedal-height) * .25);
  left:calc(-1 * var(--pedal-hit-left));right:calc(-1 * var(--pedal-hit-inner));
}
.racer-gas::after {
  top:-8px;left:calc(-1 * var(--pedal-hit-inner));right:calc(-1 * var(--pedal-hit-right));
}
#racer-touch .held {filter:brightness(1.24)}
#racer-touch .racer-pedal.held .racer-pedal-face {translate:0 2px}
.racer-pedal::before {
  content:"";position:absolute;left:42%;width:16%;height:48%;bottom:-3%;border-radius:2px;
  background:linear-gradient(90deg,#161c24,#4a5663 42%,#171e27);box-shadow:1px 2px 3px #05080d;
}
.racer-pedal-face {
  position:absolute;inset:3% 10% 10%;display:grid;place-items:center;border:1px solid #c8cfd5;
  border-radius:22% 22% 14% 14% / 26% 26% 16% 16%;
  background:linear-gradient(140deg,#e2e9ed,#77828e 65%,#abb6c2);
  box-shadow:inset 0 1px #fff5,inset 0 -1px #0a1019b3,0 3px #222c37,0 5px 8px #02060cb3;
}
.racer-gas .racer-pedal-face {inset-inline:15%;transform:skewX(-3deg)}
.racer-pedal-face::after {
  content:"";width:76%;height:72%;
  background:radial-gradient(circle at 50% 47%,#1a2129 0 23%,#56616b 26% 29%,#e7eff5 32% 36%,transparent 39%) center/8px 8px;
}
@media(orientation:portrait) {
  body.racer-touch-driving {
    --racer-pedal-height:clamp(66px,8.3vh,108px);
    --racer-pedal-width:clamp(126px,43vw,202px);
    --racer-steer-width:clamp(104px,35vw,170px);
    --racer-steer-bottom:calc(var(--racer-bottom) + 14px);
  }
}
@media(prefers-reduced-motion:reduce) {
  .racer-steer::after {transition:none}
}

.nord-compact {
  --nord-top:max(18px,env(safe-area-inset-top));
  position:fixed;top:var(--nord-top);left:50%;transform:translateX(-50%);
  z-index:17;display:grid;justify-items:center;gap:5px;
  width:min(320px,calc(100vw - 32px));pointer-events:none;
  color:#eff7ff;font:600 13px/1.2 var(--b-font);
  transition:top 160ms ease-out;
}
body.profile-folded .nord-compact {--nord-top:max(11px,env(safe-area-inset-top))}
.nord-compact.with-guide {top:max(var(--nord-top),88px)}
.nord-compact-details {max-width:100%;pointer-events:auto}
.nord-compact summary {
  display:flex;align-items:center;justify-content:center;gap:6px;min-height:36px;
  padding:4px 10px;border:1px solid #59788e;border-radius:100px;
  background:#102538;box-shadow:0 2px 7px #050a139c;list-style:none;white-space:nowrap;
  cursor:pointer;font-variant-numeric:tabular-nums;
}
.nord-compact summary::-webkit-details-marker {display:none}
.nord-clock {font-size:15px;min-width:4.9em;text-align:center}
.nord-sector,.nord-invalid {padding:3px 5px;border-radius:5px;background:#203c52;color:#d1e7fb}
.nord-invalid {background:#554019;color:#ffdd93}
.nord-records,.nord-banner {
  display:grid;justify-items:center;gap:4px;max-width:100%;
  padding:7px 10px;border:1px solid #658ca9;border-radius:9px;
  background:#122b40;color:#e4f3ff;text-align:center;box-shadow:0 2px 7px #050a139c;
}
.nord-records {margin-top:5px}
.nord-banner span {font-weight:500}
.nord-banner span:empty {display:none}
.nord-banner[data-tone="warning"] {background:#352917;border-color:#bb8b47;color:#ffe2a3}
.nord-banner[data-tone="danger"] {background:#391e28;border-color:#be7484;color:#ffd4da}
@media(orientation:portrait),(max-width:790px) {
  .nord-compact,body.profile-folded .nord-compact {
    --nord-top:calc(max(18px,env(safe-area-inset-top)) + var(--bolha-profile-height,110px) + 16px);
  }
}
@media(orientation:landscape) and (min-width:791px) and (max-width:900px) {
  .nord-compact {width:min(260px,calc(100vw - 500px))}
}
@media(orientation:landscape) and (max-height:500px) {
  body.racer-touch-driving .nord-compact {
    --nord-left:calc(var(--racer-left) + var(--racer-exit-size) + var(--racer-gap));
    --nord-top:max(18px,env(safe-area-inset-top));
    left:var(--nord-left);transform:none;
    width:min(260px,calc(100vw - var(--nord-left) - var(--racer-right) - 252px - var(--racer-gap)));
    justify-items:start;
  }
  body.racer-touch-driving .nord-compact summary {flex-wrap:wrap}
}
@media(prefers-reduced-motion:reduce) {
  .nord-compact {transition:none}
}
