#race .race-view-actions {
  display: flex;
  flex: none;
  justify-self: end;
  gap: clamp(4px, .7vw, 8px);
}

#race .race-view-actions button {
  width: clamp(44px, 4.4vw, 51px);
  height: clamp(44px, 4.4vw, 51px);
  touch-action: manipulation;
}

#live-camera {
  background: #27243de8;
  border: 1px solid #e9dbff70;
  color: #fffdf4;
  box-shadow: 0 3px 0 #251e49aa;
}

#live-camera:hover {
  background: #503878;
  border-color: #f7daff;
}

#race .touch-control {
  --control-face: #f6eddf;
  --control-down: #dfd3c7;
  --control-edge: #4f3e5e;
  --control-fill: var(--control-face);
  --control-depth: inset 0 1px #ffffffaf, 0 3px 0 #282039d4;
  position: relative;
  min-width: 44px;
  min-height: 44px;
  gap: 2px;
  border-color: var(--control-edge);
  background: var(--control-fill);
  color: #231d35;
  box-shadow: var(--control-depth);
  opacity: 1;
}

#race .touch-control small {
  font-size: clamp(10px, 1.2vw, 12px);
  line-height: 1.15;
  white-space: nowrap;
}

#race .touch-jump {
  --control-face: #ffe390;
  --control-down: #ecc366;
  --control-edge: #66502e;
}

#race .touch-roll {
  --control-face: #e3d2fa;
  --control-down: #c8afea;
  --control-edge: #574071;
}

#race .touch-item {
  --control-face: #c3f1df;
  --control-down: #9dd6c4;
  --control-edge: #355f58;
}

#race .touch-control:is(.used, [data-blocked]):not(.cooling) {
  --control-face: #ddd7e1;
  --control-down: #c8c0d0;
  --control-edge: #62576e;
  border-style: dashed;
}

#race .touch-control:is([data-held], :active) {
  --control-fill: var(--control-down);
  --control-depth: inset 0 2px 0 #32243b60, 0 1px 0 #282039ad;
  transform: none;
}

#race .touch-control:focus-visible {
  outline: 2px solid #fff9e8;
  outline-offset: 2px;
  box-shadow: var(--control-depth), 0 0 0 5px #46345e;
}

#race .touch-roll::before {
  content: none;
}

#race .touch-roll.cooling {
  --control-face: #d8cbe6;
  --control-down: #c7b8d8;
  --control-edge: #625076;
  border-style: dotted;
}

@supports (background: conic-gradient(#fff, #000)) {
  #race .touch-roll.cooling {
    border: 3px solid transparent;
    background:
      linear-gradient(var(--control-fill), var(--control-fill)) padding-box,
      conic-gradient(#fff3a5 calc(var(--cooldown, 0) * 1turn), #524260 0) border-box;
  }
}

#race .touch-roll[data-flight-action="dive"]:not(.cooling) {
  --control-face: #ccedf5;
  --control-down: #aad3e0;
  --control-edge: #36677d;
}

#race .touch-roll[data-flight-action="pull-up"] {
  --control-face: #ffebad;
  --control-down: #ecc777;
  --control-edge: #765031;
  border: 3px solid #ffcf72;
}

@supports (background: conic-gradient(#fff, #000)) {
  #race .touch-roll[data-flight-action="pull-up"] {
    border-color: transparent;
    background:
      linear-gradient(var(--control-fill), var(--control-fill)) padding-box,
      conic-gradient(#fff1a7 calc(var(--pull-window, 1) * 1turn), #6e5544 0) border-box;
  }
}

#race .touch-roll[data-flight-action="climb"] {
  --control-face: #c0e7d9;
  --control-down: #9bc8bc;
  --control-edge: #416a64;
}

#app[data-play="ball"] #race .touch-item.shoot-ready {
  --control-face: #ffe398;
  --control-down: #ebc270;
  --control-edge: #684824;
  background: var(--control-fill);
  border-color: var(--control-edge);
  box-shadow: var(--control-depth), 0 0 0 2px #fff1ad;
}

#app[data-play="ball"] #race .touch-item.shoot-ready:focus-visible {
  box-shadow: var(--control-depth), 0 0 0 5px #46345e;
}

#race .joystick {
  -webkit-touch-callout: none;
  background: #251c3e80;
  border-color: #fff6e6d6;
  box-shadow: 0 0 0 1px #2b214f9e, inset 0 0 0 2px #271f3977;
}

#race .joystick-ring {
  border-color: #fff5dec9;
  pointer-events: none;
}

#race .stick {
  pointer-events: none;
  display: grid;
  place-items: center;
  background: #fff0d9;
  border-color: #4c3a60;
  box-shadow: 0 3px 0 #20172cc4;
}

#race .stick::after {
  content: "";
  width: 26%;
  aspect-ratio: 1;
  border: 1px solid #6a507c;
  border-radius: 50%;
}

#race .joystick:is([data-held], :active) {
  background: #30224bab;
  border-color: #ffedb1;
}

#race .joystick:is([data-held], :active) .stick {
  background: #fff6e5;
  border-color: #664a57;
  box-shadow: 0 2px 0 #241932b5;
}

#race :is(#dash-state, #interact-state) {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

#race .ability-status {
  bottom: var(--bottom);
}

@media (orientation: portrait) and (max-width: 480px) {
  #app[data-play="race"] .race-top {
    position: relative;
    inset: auto;
    margin: var(--top) var(--phone-right) 0 var(--phone-left);
    /* Reserve the progress meter and checkpoint flags below the tallest card. */
    padding-bottom: 32px;
  }

  #app[data-play="race"] .race-progress {
    top: auto;
    bottom: 0;
  }

  #app[data-play="race"] :is(#mission-hint, #race-callout) {
    position: relative;
    inset: auto;
    transform: none;
    margin: 5px auto 0;
  }

  #app[data-play="ball"] .race-top {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  #race .touch-actions {
    bottom: calc(var(--bottom) + 25px);
  }
}

@media (orientation: portrait) and (max-width: 350px) {
  #app[data-play="race"] .race-numbers {
    min-width: 125px;
    gap: 4px;
    padding-inline: 3px;
  }

  #app[data-play="race"] #race-time { font-size: 15px; }

  #app[data-play="ball"] #race {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-content: start;
    align-items: start;
    gap: 6px;
    padding: var(--top) var(--phone-right) 0 var(--phone-left);
  }

  #app[data-play="ball"] .race-top { display: contents; }
  #app[data-play="ball"] :is(#ball-score, .ball-drill) {
    grid-area: 1 / 1 / 2 / 3;
    justify-self: start;
  }
  #app[data-play="ball"] .race-view-actions { grid-area: 1 / 3; }
  #app[data-play="ball"] .race-place { grid-area: 2 / 1; }
  #app[data-play="ball"] #ball-coach {
    position: static;
    grid-area: 2 / 2 / 3 / 4;
    max-width: 100%;
  }
}

@media (forced-colors: active) {
  #race .touch-roll.cooling {
    border: 3px dotted ButtonText;
  }

  #race .touch-control:is([data-held], :active) {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}
