/* Whip HUD. Loaded automatically by src/hud.js (no <link> needed).
   All fades and motion use one ease-in-out curve: --wh-ease. */

.whip-hud {
  --wh-font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue",
    "Segoe UI", Roboto, "Arial Black", Arial, sans-serif;
  --wh-ink: #fff4e6;
  --wh-ink-dim: rgba(255, 244, 230, 0.72);
  --wh-shade: rgba(26, 10, 24, 0.55);
  --wh-glass: rgba(24, 12, 26, 0.38);
  --wh-line: rgba(255, 244, 230, 0.34);
  --wh-accent: #ff5a2c;
  --wh-accent-2: #ffb340;
  --wh-ease: cubic-bezier(0.65, 0, 0.35, 1); /* ease-in-out (cubic) */
  --wh-pad: max(16px, env(safe-area-inset-left));
  --wh-pad-r: max(16px, env(safe-area-inset-right));
  --wh-pad-t: max(14px, env(safe-area-inset-top));
  --wh-pad-b: max(14px, env(safe-area-inset-bottom));

  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
  font-family: var(--wh-font);
  font-style: italic;
  font-weight: 800;
  color: var(--wh-ink);
  line-height: 1;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 0 rgba(26, 10, 24, 0.45), 0 2px 14px var(--wh-shade);
  opacity: 0;
  transition: opacity 0.6s var(--wh-ease);
}
.whip-hud.is-ready { opacity: 1; }
.whip-hud * { box-sizing: border-box; }

/* ---------- gauges, top left ---------- */
.wh-gauges {
  position: absolute;
  left: var(--wh-pad);
  top: var(--wh-pad-t);
  width: clamp(170px, 30vmin, 250px);
  transition: opacity 0.5s var(--wh-ease);
}
.whip-hud.is-crashed .wh-gauges { opacity: 0.4; }

.wh-speed { display: flex; align-items: baseline; gap: 8px; }
.wh-speed-num {
  font-size: clamp(44px, 7.2vmin, 68px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-width: 2.1ch;
}
.wh-speed-unit {
  font-size: clamp(14px, 2vmin, 18px);
  color: var(--wh-ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wh-spin { margin-top: 8px; width: 100%; }
.wh-spin-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: clamp(13px, 1.8vmin, 16px);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wh-ink-dim);
  margin-bottom: 6px;
  white-space: nowrap;
  transition: color 0.35s var(--wh-ease);
}
.wh-spin-val { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.wh-spin-track {
  position: relative;
  height: 12px;
  transform: skewX(-14deg);
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line), 0 2px 10px rgba(26, 10, 24, 0.25);
  border-radius: 2px;
  overflow: hidden;
  transition: box-shadow 0.25s var(--wh-ease);
}
.wh-spin-fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--wh-accent-2), var(--wh-accent));
  will-change: transform;
}
.wh-spin-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1.5px), rgba(26, 10, 24, 0.5) calc(10% - 1.5px) 10%);
}
.wh-spin.is-air .wh-spin-label { color: var(--wh-ink); }
.wh-spin.is-limit .wh-spin-track { box-shadow: inset 0 0 0 1.5px var(--wh-ink), 0 0 16px rgba(255, 90, 44, 0.6); }

/* Pump pressed state + charge bar */
.wh-pumpg {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.52;
  transition: opacity 0.22s var(--wh-ease), transform 0.22s var(--wh-ease);
}
.wh-pumpg.is-on,
.wh-pumpg.is-held { opacity: 1; }
.wh-pumpg-label {
  font-size: clamp(11px, 1.5vmin, 13px);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--wh-ink-dim);
  min-width: 3.9ch;
  white-space: nowrap;
  transition: color 0.2s var(--wh-ease);
}
.wh-pumpg-track {
  flex: 1;
  position: relative;
  height: 8px;
  transform: skewX(-14deg);
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  border-radius: 2px;
  overflow: hidden;
  transition: background-color 0.2s var(--wh-ease), box-shadow 0.2s var(--wh-ease);
}
.wh-pumpg-fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--wh-accent-2), var(--wh-accent));
  transition: transform 0.07s var(--wh-ease);
  will-change: transform;
}
.wh-pumpg.is-held .wh-pumpg-label { color: var(--wh-ink); }
.wh-pumpg.is-held .wh-pumpg-track {
  background: rgba(255, 179, 64, 0.18);
  box-shadow: inset 0 0 0 1.5px rgba(255, 244, 230, 0.82), 0 0 10px rgba(255, 179, 64, 0.35);
}
.wh-pumpg.is-full .wh-pumpg-label { color: var(--wh-accent-2); }
.wh-pumpg.is-full .wh-pumpg-track {
  box-shadow: inset 0 0 0 1.5px var(--wh-accent-2), 0 0 14px rgba(255, 179, 64, 0.65);
}
.wh-pumpg.is-pop { transform: translateX(2px); }
.wh-pumpg.is-pop .wh-pumpg-label { color: var(--wh-accent); }
.wh-pumpg.is-pop .wh-pumpg-track {
  background: rgba(255, 90, 44, 0.48);
  box-shadow: inset 0 0 0 1.5px var(--wh-ink), 0 0 16px rgba(255, 90, 44, 0.72);
}

/* ---------- top right: buttons, tags, best ---------- */
.wh-right {
  position: absolute;
  right: var(--wh-pad-r);
  top: var(--wh-pad-t);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.wh-best {
  font-size: clamp(15px, 2.2vmin, 20px);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wh-ink-dim);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.6s var(--wh-ease);
}
.wh-best b { color: var(--wh-ink); font-weight: 900; font-size: 1.25em; margin-left: 6px; letter-spacing: 0; }
.wh-best.is-on { opacity: 1; }
.wh-tags { display: flex; gap: 8px; }
.wh-tag {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 9px 5px 8px;
  background: var(--wh-accent);
  color: #fff;
  text-shadow: none;
  transform: skewX(-12deg);
  border-radius: 2px;
  display: none;
}
.wh-tag.is-on { display: block; }

.wh-buttons { display: none; gap: 7px; pointer-events: auto; }
.wh-buttons { display: flex; }
/* On a computer: Tricks, Cam and Mute. The rest are on keys */
.whip-hud:not(.is-touch) .wh-btn:not([data-act="camera"]):not([data-act="mute"]):not([data-act="tricks"]) { display: none; }
/* On a phone: Reset, Tricks, Cam, Mute */
.whip-hud.is-touch .wh-btn[data-act="slowmo"],
.whip-hud.is-touch .wh-btn[data-act="gyro"],
.whip-hud.is-touch .wh-btn[data-act="tune"] { display: none !important; }
.wh-btn {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wh-ink);
  min-width: 48px;
  height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 10px;
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  text-shadow: none;
  cursor: pointer;
  touch-action: none;
  transition: background-color 0.25s var(--wh-ease), box-shadow 0.25s var(--wh-ease), transform 0.15s var(--wh-ease);
}
.wh-btn:active { transform: scale(0.95); }
.wh-btn.is-on { background: var(--wh-accent); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5); }

/* ---------- live air meter ---------- */
.wh-no-whip-text .wh-air, .wh-no-whip-text .wh-jump { display: none; }
.wh-air {
  position: absolute;
  left: 50%;
  top: 15%;
  width: clamp(200px, 40vmin, 300px);
  margin-left: calc(clamp(200px, 40vmin, 300px) / -2);
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s var(--wh-ease), transform 0.35s var(--wh-ease);
}
.wh-air.is-on { opacity: 1; transform: none; }
.wh-air-deg {
  font-size: clamp(34px, 6vmin, 54px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.wh-air-meter {
  position: relative;
  height: 26px;
  margin: 8px 0 6px;
}
.wh-air-meter::before { /* horizon rail */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--wh-line) 18%, var(--wh-line) 82%, transparent);
}
.wh-air-center {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 2px;
  height: 18px;
  margin-left: -1px;
  background: var(--wh-ink-dim);
}
.wh-air-needle {
  position: absolute;
  left: 50%;
  top: 0;
  width: 6px;
  height: 26px;
  margin-left: -3px;
  border-radius: 3px;
  background: var(--wh-accent);
  box-shadow: 0 0 10px rgba(255, 90, 44, 0.6);
  will-change: transform;
}
.wh-air-time {
  font-size: clamp(15px, 2.2vmin, 19px);
  font-variant-numeric: tabular-nums;
  color: var(--wh-ink-dim);
  letter-spacing: 0.04em;
}

/* ---------- landing card ---------- */
.wh-jump {
  position: absolute;
  left: 50%;
  top: 13%;
  width: max-content;
  max-width: 92vw;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 14px) scale(0.94);
  transition: opacity 0.7s var(--wh-ease), transform 0.7s var(--wh-ease);
}
.wh-jump.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-duration: 0.45s;
}
.wh-jump-main {
  font-size: clamp(44px, 10vmin, 104px);
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.wh-jump-label { color: var(--wh-accent); margin-right: 0.22em; }
.wh-jump-sep { color: var(--wh-ink-dim); margin: 0 0.32em; font-weight: 700; }
.wh-jump-time { font-size: 0.72em; text-transform: none; }
.wh-jump-sub {
  margin-top: 10px;
  font-size: clamp(14px, 2.3vmin, 21px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wh-ink-dim);
}
.wh-jump-best {
  display: none;
  margin: 12px auto 0;
  width: max-content;
  font-size: clamp(14px, 2vmin, 18px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 12px 6px 10px;
  background: var(--wh-accent);
  color: #fff;
  text-shadow: none;
  transform: skewX(-12deg);
  border-radius: 2px;
}
.wh-jump.is-best .wh-jump-best { display: block; }

/* ---------- crash card ---------- */
.wh-crash {
  position: absolute;
  left: 50%;
  top: 32%;
  min-width: min(440px, 86vw);
  padding: 26px 34px 24px;
  text-align: center;
  background: rgba(24, 10, 22, 0.56);
  box-shadow: inset 0 0 0 1.5px var(--wh-line), 0 20px 60px rgba(20, 6, 18, 0.35);
  border-radius: 18px;
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  transition: opacity 0.5s var(--wh-ease), transform 0.5s var(--wh-ease);
  cursor: pointer;
}
.wh-crash.is-on { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.wh-crash-title {
  font-size: clamp(40px, 8vmin, 76px);
  font-weight: 900;
  text-transform: uppercase;
  color: var(--wh-accent);
  letter-spacing: -0.01em;
}
.wh-crash-reason {
  margin-top: 10px;
  font-size: clamp(18px, 2.8vmin, 26px);
}
.wh-crash-hint {
  margin-top: 18px;
  font-size: clamp(14px, 2vmin, 17px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wh-ink-dim);
}

/* ---------- toast (toggle feedback) ---------- */
.wh-toast {
  position: absolute;
  left: 50%;
  bottom: 30%;
  padding: 9px 16px 9px 14px;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  border-radius: 10px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.35s var(--wh-ease), transform 0.35s var(--wh-ease);
  white-space: nowrap;
}
.wh-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- control hint ---------- */
.wh-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--wh-pad-b) + 18px);
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  width: max-content;
  max-width: 92vw;
  font-size: clamp(14px, 2vmin, 17px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wh-ink);
  opacity: 0;
  transition: opacity 1.2s var(--wh-ease);
}
.whip-hud.is-ready .wh-hint { opacity: 1; }
.whip-hud.is-ready .wh-hint.is-gone { opacity: 0; }
.wh-hint span { white-space: nowrap; }
.wh-hint kbd {
  display: inline-block;
  min-width: 1.75em;
  padding: 4px 6px 3px;
  margin-right: 4px;
  font: inherit;
  font-style: normal;
  font-weight: 800;
  text-align: center;
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  border-radius: 6px;
  text-shadow: none;
}
.wh-hint .wh-hint-touch { display: none; }
.whip-hud.is-touch .wh-hint .wh-hint-key { display: none; }
.whip-hud.is-touch .wh-hint .wh-hint-touch { display: block; text-align: left; }
.whip-hud.is-touch .wh-hint { flex-direction: column; align-items: flex-start; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92vw; background: rgba(30, 18, 8, 0.42); padding: 10px 13px; border-radius: 12px; }
.whip-hud.is-touch .wh-hint .wh-hint-touch { white-space: normal; text-transform: none; letter-spacing: 0.01em; font-size: 13.5px; line-height: 1.5; }
.whip-hud.is-touch .wh-hint .wh-hint-touch kbd { text-transform: none; font-size: 12px; padding: 1px 6px; margin-right: 4px; }
.whip-hud.is-touch .wh-hint { bottom: calc(var(--wh-pad-b) + clamp(210px, 34vmin, 256px)); }

/* ---------- tuning panel ---------- */
.wh-panel {
  position: absolute;
  right: var(--wh-pad-r);
  top: calc(var(--wh-pad-t) + 64px);
  z-index: 20;
  width: min(336px, calc(100vw - 32px));
  max-height: calc(100% - var(--wh-pad-t) - var(--wh-pad-b) - 72px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 15px 16px 13px;
  background: rgba(20, 9, 22, 0.95);
  box-shadow: inset 0 0 0 1.5px var(--wh-line), 0 20px 60px rgba(16, 4, 14, 0.55);
  border-radius: 16px;
  text-shadow: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(16px);
  transition: opacity 0.4s var(--wh-ease), transform 0.4s var(--wh-ease), visibility 0s var(--wh-ease) 0.4s;
}
.wh-panel.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.4s var(--wh-ease), transform 0.4s var(--wh-ease), visibility 0s var(--wh-ease) 0s;
}
.wh-panel-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 244, 230, 0.14);
}
.wh-panel-title { font-size: 20px; font-weight: 900; text-transform: uppercase; margin-right: auto; }
.wh-panel-key { font-size: 11.5px; letter-spacing: 0.1em; color: var(--wh-ink-dim); text-transform: uppercase; }
.wh-panel-close {
  display: none;
  min-width: 34px;
  width: 34px;
  height: 30px;
  padding: 0;
  font-style: normal;
  font-size: 13px;
}
.whip-hud.is-touch .wh-panel-key { display: none; }
.whip-hud.is-touch .wh-panel-close { display: inline-flex; align-items: center; justify-content: center; }

.wh-panel-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.wh-panel-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 6px 4px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 244, 230, 0.34) transparent;
}
.wh-panel-rows::-webkit-scrollbar { width: 5px; }
.wh-panel-rows::-webkit-scrollbar-track { background: transparent; }
.wh-panel-rows::-webkit-scrollbar-thumb { background: rgba(255, 244, 230, 0.32); border-radius: 3px; }

.wh-panel-shade {
  position: absolute;
  left: 0;
  right: 6px;
  height: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--wh-ease);
}
.wh-panel-shade-top {
  top: 0;
  background: linear-gradient(180deg, rgba(20, 9, 22, 0.94), rgba(20, 9, 22, 0));
}
.wh-panel-shade-bottom {
  bottom: 0;
  background: linear-gradient(0deg, rgba(20, 9, 22, 0.94), rgba(20, 9, 22, 0));
}
.wh-panel.is-more-up .wh-panel-shade-top,
.wh-panel.is-more-down .wh-panel-shade-bottom {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

.wh-row { margin-bottom: 8px; }
.wh-row:last-child { margin-bottom: 2px; }
.wh-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.wh-row.is-changed .wh-row-top > span:first-child::after {
  content: " •";
  color: var(--wh-accent);
}
.wh-row-val { font-variant-numeric: tabular-nums; color: var(--wh-accent-2); }
.wh-range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
.wh-range:focus { outline: none; }
.wh-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--wh-accent) var(--wh-fill, 50%), rgba(255, 244, 230, 0.22) var(--wh-fill, 50%));
}
.wh-range::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 244, 230, 0.22); }
.wh-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--wh-accent); }
.wh-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--wh-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.wh-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--wh-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.wh-panel-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 244, 230, 0.14);
}
.wh-panel-note { font-size: 11.5px; letter-spacing: 0.06em; color: var(--wh-ink-dim); text-transform: uppercase; }

/* ---------- touch pads ---------- */
.wh-touch {
  display: none;
  --size: clamp(76px, 18.5vmin, 108px);
  --pad-gap: clamp(9px, 2vmin, 14px);
}
.whip-hud.is-touch .wh-touch { display: block; }
.wh-pads {
  position: absolute;
  bottom: var(--wh-pad-b);
}
/* Left thumb cluster: Steer Left/Right at bottom, 8-way Body pad stacked directly above */
.wh-pads-left {
  left: var(--wh-pad);
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 8px var(--pad-gap);
  align-items: end;
  justify-items: center;
  transition: opacity 0.3s var(--wh-ease);
}
/* Right thumb cluster: Brake bottom-left, Gas bottom-right, Pump stacked directly above Gas */
.wh-pads-right {
  right: var(--wh-pad-r);
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 8px var(--pad-gap);
  align-items: end;
  justify-items: end;
  transition: opacity 0.3s var(--wh-ease);
}
.whip-hud.is-panel .wh-pads-left,
.whip-hud.is-panel .wh-pads-right { opacity: 0.14; }
.wh-pad {
  position: relative;
  width: var(--size);
  height: var(--size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 2px var(--wh-line), 0 6px 24px rgba(20, 6, 18, 0.25);
  font-size: clamp(14px, 2.8vmin, 19px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background-color 0.12s var(--wh-ease), transform 0.12s var(--wh-ease), box-shadow 0.12s var(--wh-ease);
}
.wh-pad > span { position: relative; z-index: 1; }
.wh-pad svg { width: 42%; height: 42%; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.wh-pad.is-down {
  background: rgba(255, 90, 44, 0.78);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65), 0 4px 18px rgba(255, 90, 44, 0.35);
  transform: scale(0.95);
}

.wh-pad-steer[data-pad="left"] { grid-column: 1; grid-row: 2; }
.wh-pad-steer[data-pad="right"] { grid-column: 2; grid-row: 2; }
.wh-pad-body {
  grid-column: 1 / span 2;
  grid-row: 1;
  width: calc(var(--size) * 1.58);
  height: calc(var(--size) * 0.96);
  border-radius: 22px;
  overflow: hidden;
  font-size: clamp(11px, 2.2vmin, 14px);
}
.wh-pad-body.is-down {
  background: rgba(255, 120, 52, 0.28);
  box-shadow: inset 0 0 0 2.5px rgba(255, 244, 230, 0.86), 0 4px 18px rgba(255, 90, 44, 0.32);
  transform: scale(0.97);
}
.wh-body-puck {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 179, 64, 0.92), rgba(255, 90, 44, 0.72));
  box-shadow: 0 0 12px rgba(255, 90, 44, 0.55);
  opacity: 0;
  transform: translate(0, 0) scale(0.75);
  transition: opacity 0.14s var(--wh-ease), transform 0.09s var(--wh-ease);
  pointer-events: none;
  will-change: transform, opacity;
}
.wh-pad-body.is-down .wh-body-puck { opacity: 1; }
.wh-body-label {
  position: relative;
  z-index: 2;
  letter-spacing: 0.08em;
  pointer-events: none;
}
.wh-body-dir {
  position: absolute;
  z-index: 1;
  font-style: normal;
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
  color: rgba(255, 244, 230, 0.52);
  text-shadow: none;
  pointer-events: none;
  transition: color 0.14s var(--wh-ease), transform 0.14s var(--wh-ease);
}
.wh-body-n { top: 5px; left: 50%; transform: translateX(-50%); }
.wh-body-s { bottom: 5px; left: 50%; transform: translateX(-50%); }
.wh-body-w { left: 8px; top: 50%; transform: translateY(-50%); font-size: 13px; }
.wh-body-e { right: 8px; top: 50%; transform: translateY(-50%); font-size: 13px; }
.wh-body-diag {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 244, 230, 0.28);
  pointer-events: none;
  transition: background-color 0.14s var(--wh-ease), transform 0.14s var(--wh-ease);
}
.wh-body-nw { top: 9px; left: 12px; }
.wh-body-ne { top: 9px; right: 12px; }
.wh-body-sw { bottom: 9px; left: 12px; }
.wh-body-se { bottom: 9px; right: 12px; }
.wh-pad-body.is-f .wh-body-n,
.wh-pad-body.is-b .wh-body-s,
.wh-pad-body.is-l .wh-body-w,
.wh-pad-body.is-r .wh-body-e { color: var(--wh-ink); }
.wh-pad-body.is-f.is-l .wh-body-nw,
.wh-pad-body.is-f.is-r .wh-body-ne,
.wh-pad-body.is-b.is-l .wh-body-sw,
.wh-pad-body.is-b.is-r .wh-body-se { background: var(--wh-accent-2); transform: scale(1.45); }

.wh-pad-brake {
  grid-column: 1;
  grid-row: 2;
  width: calc(var(--size) * 0.92);
  height: calc(var(--size) * 0.92);
}
.wh-pad-gas {
  grid-column: 2;
  grid-row: 2;
  width: calc(var(--size) * 1.06);
  height: calc(var(--size) * 1.32);
  border-radius: 14px 14px 24px 24px;
}
.wh-pad-pump {
  grid-column: 2;
  grid-row: 1;
  width: calc(var(--size) * 1.06);
  height: calc(var(--size) * 0.8);
  border-radius: 22px 22px 14px 14px;
  overflow: hidden;
}
/* Subtle seam cue between Pump and Gas */
.wh-pads-right::after {
  content: "";
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: center;
  width: 26px;
  height: 3px;
  margin-bottom: -5.5px;
  border-radius: 2px;
  background: rgba(255, 244, 230, 0.28);
  pointer-events: none;
  transition: background-color 0.15s var(--wh-ease), box-shadow 0.15s var(--wh-ease);
}
.wh-pads-right.is-combo::after {
  background: var(--wh-accent-2);
  box-shadow: 0 0 10px rgba(255, 179, 64, 0.75);
}
.wh-pad-charge {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  background: linear-gradient(0deg, rgba(255, 90, 44, 0.78), rgba(255, 179, 64, 0.86));
  transition: transform 0.07s var(--wh-ease);
  pointer-events: none;
  will-change: transform;
}
/* Keep Pump's pressed state distinct from its rising charge fill so both read together */
.wh-pad-pump.is-down {
  background: rgba(255, 120, 52, 0.3);
  box-shadow: inset 0 0 0 2.5px rgba(255, 244, 230, 0.88), 0 4px 18px rgba(255, 140, 52, 0.35);
  transform: scale(0.95);
}
.wh-pad-pump.is-full {
  box-shadow: inset 0 0 0 2.5px var(--wh-accent-2), 0 0 22px rgba(255, 179, 64, 0.58);
}
.wh-pad-pump.is-pop {
  background: rgba(255, 90, 44, 0.85);
  box-shadow: inset 0 0 0 2.5px var(--wh-ink), 0 0 24px rgba(255, 90, 44, 0.7);
}

/* Portrait phones: compact gauges on the left, 3 x 2 buttons on the right, zero overlap even at 360px */
@media (max-aspect-ratio: 1/1) {
  .whip-hud {
    --wh-pad: max(14px, env(safe-area-inset-left));
    --wh-pad-r: max(14px, env(safe-area-inset-right));
  }
  .whip-hud.is-touch .wh-gauges { width: clamp(120px, calc(100vw - 208px), 162px); }
  .whip-hud.is-touch .wh-speed-num { font-size: clamp(34px, 9.5vw, 44px); }
  .whip-hud.is-touch .wh-speed-unit { font-size: 13px; }
  .whip-hud.is-touch .wh-spin { margin-top: 6px; }
  .whip-hud.is-touch .wh-spin-label { font-size: 12px; margin-bottom: 5px; }
  .whip-hud.is-touch .wh-pumpg { margin-top: 6px; }
  .whip-hud.is-touch .wh-buttons { display: grid; grid-template-columns: repeat(2, 56px); gap: 5px; justify-content: end; }
  .whip-hud.is-touch .wh-buttons .wh-btn { min-width: 0; width: 52px; height: 35px; padding: 0 2px; font-size: 10.5px; letter-spacing: 0.02em; }
  .whip-hud.is-touch .wh-air,
  .whip-hud.is-touch .wh-jump { top: calc(var(--wh-pad-t) + 154px); }
  .whip-hud.is-touch .wh-jump-main { font-size: clamp(34px, 9.5vw, 56px); }
  .whip-hud.is-touch .wh-crash { top: 41%; min-width: min(330px, 88vw); padding: 20px 24px 18px; }
  .whip-hud.is-touch .wh-touch { --size: clamp(68px, 19vw, 84px); --pad-gap: clamp(7px, 2vw, 11px); }
  .whip-hud.is-touch .wh-toast { bottom: calc(var(--wh-pad-b) + clamp(256px, 66vw, 296px)); }
  .whip-hud.is-touch .wh-hint {
    bottom: calc(var(--wh-pad-b) + clamp(176px, 46vw, 212px));
    max-width: 92vw;
    font-size: 12.5px;
    gap: 5px 12px;
  }
  .whip-hud.is-touch .wh-panel {
    top: calc(var(--wh-pad-t) + 94px);
    max-height: calc(100% - var(--wh-pad-t) - var(--wh-pad-b) - 252px);
    width: min(330px, calc(100vw - 28px));
  }
}

/* Landscape phones and short viewports: keep center readouts below the top bar and inside the pad channel */
@media (min-aspect-ratio: 1/1) and (max-height: 540px) {
  .whip-hud {
    --wh-pad-t: max(10px, env(safe-area-inset-top));
    --wh-pad-b: max(10px, env(safe-area-inset-bottom));
  }
  .wh-gauges { width: clamp(144px, 23vw, 188px); }
  .wh-speed-num { font-size: clamp(34px, 9.5vh, 46px); }
  .wh-spin { margin-top: 5px; }
  .wh-spin-label { font-size: 12px; margin-bottom: 4px; }
  .wh-pumpg { margin-top: 5px; }
  .whip-hud.is-touch .wh-right { gap: 5px; }
  .whip-hud.is-touch .wh-tags { gap: 6px; }
  .whip-hud.is-touch .wh-tag { font-size: 11px; padding: 4px 7px 4px 6px; }
  .whip-hud.is-touch .wh-best { font-size: 13.5px; }
  .whip-hud.is-touch .wh-buttons { gap: 5px; }
  .whip-hud.is-touch .wh-buttons .wh-btn { min-width: 44px; height: 34px; padding: 0 7px; font-size: 11px; letter-spacing: 0.05em; }
  .whip-hud.is-touch .wh-air,
  .whip-hud.is-touch .wh-jump { top: calc(var(--wh-pad-t) + 46px); max-width: calc(100vw - 380px); }
  .whip-hud.is-touch .wh-jump-main { font-size: clamp(30px, 9vh, 46px); }
  .whip-hud.is-touch .wh-jump-sub { margin-top: 5px; font-size: 12px; letter-spacing: 0.06em; }
  .whip-hud.is-touch .wh-jump-best { margin-top: 6px; padding: 4px 10px; font-size: 11.5px; }
  .whip-hud.is-touch .wh-crash {
    top: 52%;
    min-width: 0;
    width: min(310px, calc(100vw - 380px));
    padding: 16px 20px 14px;
  }
  .whip-hud.is-touch .wh-crash-title { font-size: clamp(30px, 8.5vh, 44px); }
  .whip-hud.is-touch .wh-crash-reason { margin-top: 6px; font-size: 15px; }
  .whip-hud.is-touch .wh-crash-hint { margin-top: 10px; font-size: 12px; }
  .whip-hud.is-touch .wh-touch { --size: clamp(64px, 18vh, 84px); --pad-gap: clamp(8px, 1.8vw, 13px); }
  .whip-hud.is-touch .wh-pad-body { height: calc(var(--size) * 0.9); }
  .whip-hud.is-touch .wh-hint {
    bottom: calc(var(--wh-pad-b) + 6px);
    max-width: calc(100vw - 384px);
    font-size: 11.5px;
    gap: 4px 12px;
  }
  .whip-hud.is-touch .wh-panel {
    top: calc(var(--wh-pad-t) + 42px);
    max-height: calc(100% - var(--wh-pad-t) - var(--wh-pad-b) - 46px);
    width: min(320px, calc(100vw - 32px));
    padding: 12px 14px 10px;
  }
}

/* Page-level touch behaviour (only once a touch device is detected): no scroll, zoom or callouts */
html.whip-touch,
html.whip-touch body {
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .whip-hud, .whip-hud * { transition-duration: 0.01s !important; }
}

/* Whip coach: the keys to try next, the same caps as the start-up hints, floating beside the rider */
.wh-coach {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity 0.35s var(--wh-ease);
  white-space: nowrap;
  will-change: transform;
}
.wh-coach.is-on { opacity: 1; }
.wh-coach-name { margin-bottom: 6px; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--wh-ink); }
.wh-coach-how { margin-top: 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--wh-ink-dim); }
.wh-coach-keys { display: flex; align-items: center; gap: 5px; font-size: 19px; color: var(--wh-ink); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.wh-coach-keys kbd {
  display: inline-block;
  min-width: 1.75em;
  padding: 4px 6px 3px;
  font: inherit;
  font-style: normal;
  font-weight: 800;
  text-align: center;
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  border-radius: 6px;
  text-shadow: none;
}
.wh-coach.is-nailed kbd { background: rgba(127, 224, 160, 0.55); box-shadow: inset 0 0 0 1.5px #7fe0a0; transition: background 0.35s var(--wh-ease), box-shadow 0.35s var(--wh-ease); }
.wh-type {
  position: absolute;
  left: 0;
  top: 0;
  padding: 7px 12px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--wh-glass);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.35s var(--wh-ease);
  will-change: transform;
}
.wh-type.is-on { opacity: 1; }
.wh-mode {
  position: absolute;
  right: 18px;
  top: 52px;
  z-index: 20;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #17130f;
  background: var(--wh-accent);
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--wh-ease);
}
.wh-mode.is-on { opacity: 1; }
.wh-hint:not(.is-gone) ~ .wh-coach.is-on { opacity: 0; }
.wh-hint.is-gone ~ .wh-coach.is-on { transition-delay: 1s; }

/* On a phone the whip name sits next to the Body pad, plain and small like the desktop's */
.whip-hud.is-touch .wh-toast {
  left: calc(var(--wh-pad) + clamp(76px, 18.5vmin, 108px) * 1.58 + 28px);
  bottom: calc(var(--wh-pad-b) + clamp(76px, 18.5vmin, 108px) + clamp(9px, 2vmin, 14px));
  right: auto;
  max-width: 34vw;
  padding: 6px 9px;
  font-size: 12px;
  white-space: normal;
  transform: translate(0, 8px);
}
.whip-hud.is-touch .wh-toast.is-on { transform: translate(0, 0); }
@media (max-aspect-ratio: 1/1) {
  .whip-hud.is-touch .wh-toast {
    left: calc(var(--wh-pad) + clamp(68px, 19vw, 84px) * 1.58 + 26px);
    bottom: calc(var(--wh-pad-b) + clamp(68px, 19vw, 84px) + clamp(7px, 2vw, 11px));
  }
}

/* The phone tutorial sits up over the sky, clear of the rider */
@media (max-aspect-ratio: 1/1) {
  .whip-hud.is-touch .wh-hint {
    top: calc(var(--wh-pad-t) + 118px);
    bottom: auto;
    width: min(92vw, 350px);
  }
}

/* Whip number pressed: its name and how to do it by hand */
.wh-type b { font-weight: inherit; }
.wh-type-keys { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; }
.wh-type-keys span { opacity: 0.7; }
.wh-type-keys kbd { display: inline-block; min-width: 22px; padding: 2px 6px; font: inherit; text-align: center; background: var(--wh-glass); box-shadow: inset 0 0 0 1.5px var(--wh-line); border-radius: 6px; }

/* Trick list: the same glass, key caps and italic capitals as the buttons and hints */
.wh-tricks {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100% - var(--wh-pad-t) - var(--wh-pad-b) - 12px);
  padding: 14px 16px 10px;
  color: var(--wh-ink);
  background: var(--wh-shade);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1.5px var(--wh-line);
  border-radius: 14px;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(-50% + 12px));
  transition: opacity 0.3s var(--wh-ease), transform 0.3s var(--wh-ease), visibility 0s linear 0.3s;
}
.wh-tricks.is-on { opacity: 1; visibility: visible; transform: translate(-50%, -50%); transition: opacity 0.3s var(--wh-ease), transform 0.3s var(--wh-ease), visibility 0s; }
.whip-hud.is-tricks .wh-touch, .whip-hud.is-tricks .wh-hint { visibility: hidden; }
.wh-tricks-head { display: flex; align-items: center; justify-content: space-between; font-size: clamp(14px, 2vmin, 17px); letter-spacing: 0.06em; text-transform: uppercase; }
.wh-tricks-close { width: 36px; height: 36px; color: var(--wh-ink); font: inherit; cursor: pointer; background: var(--wh-glass); border: 0; border-radius: 9px; box-shadow: inset 0 0 0 1.5px var(--wh-line); transition: background 0.25s var(--wh-ease); }
.wh-tricks-close:hover { background: rgba(255, 244, 230, 0.16); }
.wh-tricks-note { margin: 6px 0 6px; font-size: 13px; line-height: 1.35; color: var(--wh-ink-dim); }
.wh-tricks-list { overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-right: 4px; }
.wh-tricks-list h3 { margin: 12px 0 2px; font: inherit; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--wh-ink-dim); }
.wh-tricks-row { display: grid; grid-template-columns: 34px 1fr auto 26px; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255, 244, 230, 0.12); }
.wh-tricks-num { width: 30px; height: 30px; padding: 0; color: var(--wh-ink); font: inherit; font-size: 14px; cursor: pointer; background: var(--wh-glass); border: 0; border-radius: 7px; box-shadow: inset 0 0 0 1.5px var(--wh-line); transition: background 0.25s var(--wh-ease); }
.wh-tricks-num:hover { background: rgba(255, 244, 230, 0.16); }
.wh-tricks-num.is-empty { background: none; box-shadow: none; cursor: default; }
.wh-tricks-text { display: flex; flex-direction: column; min-width: 0; }
.wh-tricks-text b { font-weight: inherit; font-size: clamp(14px, 2vmin, 16px); letter-spacing: 0.06em; text-transform: uppercase; }
.wh-tricks-text span { font-size: 12.5px; color: var(--wh-ink-dim); }
.wh-tricks-keys { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; font-size: 12.5px; }
.wh-tricks-keys span { opacity: 0.65; }
.wh-tricks-keys kbd { min-width: 22px; padding: 2px 6px; font: inherit; text-align: center; white-space: nowrap; background: var(--wh-glass); box-shadow: inset 0 0 0 1.5px var(--wh-line); border-radius: 6px; }
.wh-tricks-done { font-size: 12px; font-style: normal; color: var(--wh-ink-dim); text-align: right; }
@media (max-aspect-ratio: 1/1) {
  .wh-tricks-row { grid-template-columns: 34px 1fr 24px; }
  .wh-tricks-keys { grid-column: 2 / 4; grid-row: 2; justify-content: flex-start; }
}
