/*
 * TURN is gesture-first. Prevent browser text selection and the iOS Copy /
 * Look Up / Translate callout throughout the app, then opt the deliberately
 * readable/copyable information surfaces back in below.
 */
body,
body * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

/*
 * Selection allowlist: How to Play + Drive By Ear help/training, visible
 * version information, About, History/Changelog, Achievements and Give
 * Feedback. Keep controls and the rest of the game gesture-only.
 */
body .m8-how-dialog .m8-guide-grid,
body .m8-how-dialog .m8-guide-grid *,
body .turn-dbe-training-dialog .m8-dialog-card,
body .turn-dbe-training-dialog .m8-dialog-card *,
body .m8-home-build,
body .m8-home-build *,
body .install-kicker,
body .install-kicker *,
body .m8-about-content,
body .m8-about-content *,
body .turn-history-panel,
body .turn-history-panel *,
body .turn-history-release,
body .turn-history-release *,
body .turn-achievements-content,
body .turn-achievements-content *,
body .m8-feedback-content,
body .m8-feedback-content * {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
}

.pedals {
  display: block;
}

.drive-stack {
  --drive-pad-height: clamp(190px, 26vw, 268px);
  --drift-lock-bubble-width: clamp(52px, 7.2vw, 74px);
  --shift-bubble-width: clamp(58px, 7.8vw, 80px);
  --reverse-bubble-width: clamp(52px, 7.2vw, 74px);
  --drive-brake-color: var(--turn-control-brake, #ff7b54);
  position: relative;
  isolation: isolate;
  width: clamp(190px, 24vw, 260px);
  height: var(--drive-pad-height);
  display: grid;
  pointer-events: auto;
}

.drive-pad {
  --boost-charge: 100%;
  position: relative;
  z-index: 2;
  height: var(--drive-pad-height);
  overflow: hidden;
  display: grid;
  grid-template-rows: 32% 44% 24%;
  border: 4px solid var(--ink);
  border-radius: 30px;
  background: var(--lime);
  box-shadow: 7px 8px 0 var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.drive-lock-bubble {
  position: absolute;
  z-index: 1;
  top: 0;
  right: calc(100% - 4px);
  width: var(--drift-lock-bubble-width);
  /* Grid percentages use the pad's inner height; finish on the GAS border's far edge. */
  height: calc(32% + 5.44px);
  box-sizing: border-box;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 999px 0 0 999px;
  background: #748ffc;
  color: var(--ink);
  opacity: 0;
  transform: translateX(62%) scaleX(0.38);
  transform-origin: right center;
  transition:
    opacity 80ms ease-out,
    transform 140ms cubic-bezier(.2,.88,.25,1),
    background-color 100ms ease;
  pointer-events: none;
}

.drive-lock-bubble span {
  display: block;
  transform: rotate(-90deg);
  font-size: clamp(0.58rem, 1.55vw, 0.82rem);
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 1;
}

.controls .drive-shift-bubble {
  position: absolute;
  z-index: 1;
  /* Share the GAS row's two 4px horizontal borders exactly. */
  top: calc(32% + 1.44px);
  right: calc(100% - 4px);
  width: var(--shift-bubble-width);
  height: calc(44% + 0.48px);
  min-height: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 999px 0 0 999px;
  background: #8ce99a;
  color: var(--ink);
  box-shadow: none;
  opacity: 0;
  transform: translateX(62%) scaleX(0.38);
  transform-origin: right center;
  transition:
    opacity 80ms ease-out,
    transform 140ms cubic-bezier(.2,.88,.25,1),
    background-color 100ms ease;
  pointer-events: none;
}

.drive-shift-bubble span {
  display: inline-flex;
  padding: 0;
  align-items: center;
  justify-content: center;
  gap: .32em;
  transform: rotate(-90deg);
  font-size: clamp(0.58rem, 1.48vw, 0.8rem);
  font-weight: 950;
  letter-spacing: 0.035em;
  line-height: 1;
  white-space: nowrap;
}

.drive-shift-bubble i {
  display: inline-block;
  width: 0;
  overflow: hidden;
  opacity: 0;
  font-size: .9em;
  font-style: normal;
  line-height: 1;
  transition: width 100ms ease, opacity 100ms ease;
}

.controls .drive-reverse-bubble {
  position: absolute;
  z-index: 1;
  right: calc(100% - 4px);
  bottom: 0;
  width: var(--reverse-bubble-width);
  height: calc(24% + 2.08px);
  min-height: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 999px 0 0 999px;
  background: var(--drive-brake-color);
  color: var(--ink);
  box-shadow: none;
  opacity: 0;
  transform: translateX(62%) scaleX(0.38);
  transform-origin: right center;
  transition:
    opacity 80ms ease-out,
    transform 140ms cubic-bezier(.2,.88,.25,1),
    background-color 100ms ease;
  pointer-events: none;
  touch-action: none;
  font-size: clamp(0.78rem, 2vw, 1.12rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.drive-stack.is-brake-ready .drive-reverse-bubble,
.drive-stack.is-reversing .drive-reverse-bubble,
.drive-reverse-bubble:focus-visible {
  opacity: 1;
  transform: translateX(0) scaleX(1);
  pointer-events: auto;
}

.drive-stack.is-brake-ready .drive-pad {
  border-bottom-left-radius: 0;
}

.drive-stack.is-reversing .drive-reverse-bubble,
.drive-reverse-bubble.is-active {
  background: var(--turn-orange-200, #ffb89f);
  box-shadow: inset 0 0 0 5px rgb(255 248 232 / 0.62);
}

.drive-reverse-bubble:focus-visible {
  outline: 4px solid var(--paper);
  outline-offset: 3px;
}

.drive-stack.is-shift-available.is-gas-ready .drive-shift-bubble,
.drive-stack.is-shift-active .drive-shift-bubble,
.drive-shift-bubble:focus-visible {
  opacity: 1;
  transform: translateX(0) scaleX(1);
  pointer-events: auto;
}

.drive-stack.is-shift-active .drive-shift-bubble {
  background: #51cf66;
}

.drive-stack.is-shift-active .drive-shift-bubble i {
  width: .72em;
  opacity: 1;
}

.drive-shift-bubble:focus-visible {
  outline: 4px solid var(--paper);
  outline-offset: 3px;
}

.drive-stack.is-drift-ready .drive-lock-bubble {
  opacity: 1;
  transform: translateX(0) scaleX(1);
}

.drive-stack.is-drift-ready .drive-pad {
  border-top-left-radius: 0;
}

.drive-stack.is-drift-locking .drive-lock-bubble {
  background: #8b5cf6;
  box-shadow: inset 0 0 0 5px rgb(255 248 232 / 0.62);
}

.drive-pad-top {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.drive-zone,
.drive-pad .drive-gas-zone,
.drive-pad .drive-brake-zone {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  color: var(--ink);
  font-size: clamp(0.78rem, 2vw, 1.12rem);
  letter-spacing: 0.025em;
  text-transform: uppercase;
  touch-action: none;
}

.drive-zone:active,
.drive-pad .drive-gas-zone:active,
.drive-pad .drive-brake-zone:active {
  transform: none;
  box-shadow: none;
}

.drive-drift-zone {
  border-right: 2px solid var(--ink);
  background: #54c2ef;
}

.drive-boost-zone {
  position: relative;
  overflow: hidden;
  border-left: 2px solid var(--ink);
  background:
    linear-gradient(
      to top,
      #ff6b6b 0 var(--boost-charge),
      #ffb2aa var(--boost-charge) 100%
    );
}

.drive-boost-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgb(255 255 255 / 0);
  transition: background 100ms ease;
}

.drive-pad .drive-gas-zone {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  border-top: 4px solid var(--ink);
  background: #c8db08;
}

.drive-pad .drive-gas-zone::after {
  content: none;
}

.drive-pad .drive-brake-zone {
  display: grid;
  place-items: center;
  padding: 6px 12px;
  border-top: 4px solid var(--ink);
  background: var(--drive-brake-color);
  font-size: clamp(0.6rem, 1.45vw, 0.82rem);
  letter-spacing: 0.035em;
  white-space: nowrap;
}

.drive-pad[data-drive-zone="gas"] .drive-gas-zone,
.drive-drift-zone.is-active,
.drive-boost-zone.is-active,
.drive-brake-zone.is-active {
  box-shadow: inset 0 0 0 6px rgb(255 248 232 / 0.78);
}

.drive-pad[data-drive-zone="gas"] .drive-gas-zone {
  background: #d9eb12;
}

.drive-drift-zone.is-active {
  background: #38d9ff;
}

.drive-brake-zone.is-active {
  background: var(--drive-brake-color);
}

.drive-pad.is-boosting .drive-boost-zone {
  background:
    linear-gradient(
      to top,
      #ff3f4a 0 var(--boost-charge),
      #ff9a8e var(--boost-charge) 100%
    );
}

.drive-pad.is-boosting {
  box-shadow:
    7px 8px 0 var(--ink),
    0 0 0 5px rgb(255 90 95 / 0.28);
}

:root.turn-left-handed-controls .controls {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
}

:root.turn-left-handed-controls .pedals {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

:root.turn-left-handed-controls .utility-group {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: end;
  transform: none;
}

:root.turn-left-handed-controls .drive-lock-bubble {
  right: auto;
  left: calc(100% - 4px);
  border-radius: 0 999px 999px 0;
  transform: translateX(-62%) scaleX(0.38);
  transform-origin: left center;
}

:root.turn-left-handed-controls .drive-shift-bubble {
  right: auto;
  left: calc(100% - 4px);
  border-radius: 0 999px 999px 0;
  transform: translateX(-62%) scaleX(0.38);
  transform-origin: left center;
}

:root.turn-left-handed-controls .drive-reverse-bubble {
  right: auto;
  left: calc(100% - 4px);
  border-radius: 0 999px 999px 0;
  transform: translateX(-62%) scaleX(0.38);
  transform-origin: left center;
}

:root.turn-left-handed-controls .drive-stack.is-shift-available.is-gas-ready .drive-shift-bubble,
:root.turn-left-handed-controls .drive-stack.is-shift-active .drive-shift-bubble,
:root.turn-left-handed-controls .drive-shift-bubble:focus-visible {
  transform: translateX(0) scaleX(1);
}

:root.turn-left-handed-controls .drive-stack.is-brake-ready .drive-reverse-bubble,
:root.turn-left-handed-controls .drive-stack.is-reversing .drive-reverse-bubble,
:root.turn-left-handed-controls .drive-reverse-bubble:focus-visible {
  transform: translateX(0) scaleX(1);
}

:root.turn-left-handed-controls .drive-stack.is-drift-ready .drive-lock-bubble {
  transform: translateX(0) scaleX(1);
}

:root.turn-left-handed-controls .drive-stack.is-drift-ready .drive-pad {
  border-top-left-radius: 30px;
  border-top-right-radius: 0;
}

:root.turn-left-handed-controls .drive-stack.is-brake-ready .drive-pad {
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 0;
}

:root.turn-left-handed-controls .drive-boost-zone {
  border-right: 2px solid var(--ink);
  border-left: 0;
}

:root.turn-left-handed-controls .drive-drift-zone {
  border-right: 0;
  border-left: 2px solid var(--ink);
}

.drive-boost-zone.is-locked::after {
  content: "LEAVE";
  position: absolute;
  right: 7px;
  bottom: 6px;
  padding: 2px 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.44rem;
  letter-spacing: 0.06em;
}

@media (max-height: 430px) {
  .drive-stack {
    --drive-pad-height: clamp(174px, 23.5vw, 205px);
    --drift-lock-bubble-width: clamp(48px, 6.8vw, 64px);
    --shift-bubble-width: clamp(52px, 7.2vw, 70px);
    --reverse-bubble-width: clamp(48px, 6.8vw, 64px);
    width: clamp(174px, 23vw, 224px);
  }

  .drive-pad {
    border-width: 3px;
    border-radius: 24px;
    box-shadow: 5px 6px 0 var(--ink);
  }

  .drive-pad .drive-gas-zone,
  .drive-pad .drive-brake-zone {
    border-top-width: 3px;
  }

  .drive-drift-zone {
    border-right-width: 1.5px;
  }

  .drive-boost-zone {
    border-left-width: 1.5px;
  }

  .drive-lock-bubble {
    right: calc(100% - 3px);
    height: calc(32% + 4.08px);
    border-width: 3px;
  }

  .controls .drive-shift-bubble {
    right: calc(100% - 3px);
    top: calc(32% + 1.08px);
    height: calc(44% + 0.36px);
    border-width: 3px;
  }

  .controls .drive-reverse-bubble {
    right: calc(100% - 3px);
    height: calc(24% + 1.56px);
    border-width: 3px;
  }

  :root.turn-left-handed-controls .drive-lock-bubble {
    right: auto;
    left: calc(100% - 3px);
  }

  :root.turn-left-handed-controls .drive-shift-bubble {
    right: auto;
    left: calc(100% - 3px);
  }

  :root.turn-left-handed-controls .drive-reverse-bubble {
    right: auto;
    left: calc(100% - 3px);
  }

  :root.turn-left-handed-controls .drive-stack.is-drift-ready .drive-pad {
    border-top-left-radius: 24px;
  }

  :root.turn-left-handed-controls .drive-stack.is-brake-ready .drive-pad {
    border-bottom-left-radius: 24px;
  }

  :root.turn-left-handed-controls .drive-boost-zone {
    border-right-width: 1.5px;
  }

  :root.turn-left-handed-controls .drive-drift-zone {
    border-left-width: 1.5px;
  }
}

@media (max-width: 700px) and (max-height: 430px) {
  :root.turn-left-handed-controls .utility-group[data-menu-state="staged"] {
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drive-lock-bubble,
  .controls .drive-shift-bubble,
  .controls .drive-reverse-bubble,
  .drive-shift-bubble i {
    transition: none;
  }
}
