/* Keep the wheel and pedals on opposite sides of the screen in either orientation. */
@media (any-pointer: coarse) {
  body {
    overscroll-behavior: none;
  }
  #touch,
  #touch-drive {
    -webkit-user-select: none;
    user-select: none;
  }
  body:not(.waiting) #touch {
    position: fixed;
    display: grid;
    grid-template-columns: repeat(2, clamp(44px, 13vw, 70px)) 1fr repeat(
        2,
        clamp(52px, 15vw, 80px)
      );
    grid-template-rows: 44px 48px;
    align-items: stretch;
    gap: 5px;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    pointer-events: none;
  }
  #touch button,
  #touch-drive button {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
    font-weight: 800;
    border: 1px solid #c1cbb88a;
    border-radius: 8px;
    box-shadow: inset 0 -3px #0004;
  }
  #touch button {
    padding: 4px;
    min-width: 0;
    margin: 0;
    background: #152821de;
    color: #fff4db;
  }
  #touch button:nth-child(3) {
    margin: 0;
  }
  #touch [data-key='ArrowLeft'] {
    grid-area: 2 / 1;
  }
  #touch [data-key='ArrowRight'] {
    grid-area: 2 / 2;
  }
  #touch [data-key='Space'] {
    grid-area: 1 / 4;
  }
  #touch [data-key='ShiftLeft'] {
    grid-area: 1 / 5;
  }
  #touch [data-key='ArrowDown'] {
    grid-area: 2 / 4;
  }
  #touch [data-key='ArrowUp'] {
    grid-area: 2 / 5;
    background: #ffd05a;
    border-color: #ffe4a0;
    color: #18251e;
  }
  #touch button:active,
  #touch-drive button:active {
    background: #fee3a4;
    color: #16221e;
    transform: translateY(2px);
  }
  .lower-left {
    left: max(10px, env(safe-area-inset-left));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 54px);
  }
  .lower-right {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 104px);
  }
  .lower-right p,
  header kbd,
  #nearby kbd,
  .keys-note {
    display: none;
  }
  #nearby {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 136px);
  }
  header:not(.top-bar) {
    top: max(5px, env(safe-area-inset-top));
    left: max(7px, env(safe-area-inset-left));
    right: max(7px, env(safe-area-inset-right));
  }
  header .top-actions :is(button, a, select) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  #cruise-tools {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .location,
  #guidance {
    top: calc(max(5px, env(safe-area-inset-top)) + 49px);
    max-width: 47%;
  }
  #meet {
    max-width: 32vw;
  }
  .card input,
  .card select,
  .text-input {
    font-size: 16px;
  }
  .card button,
  .map-buttons button,
  #close-map,
  #nearby button {
    min-height: 44px;
  }
  .card {
    margin-block: auto;
  }
  #lobby {
    align-items: start;
    padding-top: max(60px, calc(env(safe-area-inset-top) + 50px));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  body:has(#race-hud:not(.hidden)) #touch-drive {
    display: flex;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(7px, env(safe-area-inset-left));
    right: max(7px, env(safe-area-inset-right));
    gap: 4px;
  }
  #touch-drive button {
    min-height: 48px;
    min-width: 44px;
  }
  .hud-bottom-left,
  .hud-bottom-right {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 54px);
  }
  #btn-split-screen {
    display: none;
  }
  .dual-menu {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (any-pointer: coarse) and (max-height: 500px) {
  .location h1 {
    font-size: 18px;
    margin: 2px 0;
  }
  #nearby {
    max-width: 32vw;
    padding: 5px;
  }
  #spot-note,
  #nearby small {
    display: none;
  }
  .lower-left #mini-button {
    width: 80px;
  }
  .speed strong {
    font-size: 27px;
  }
  #landing {
    overflow-y: auto;
  }
}
@media (any-pointer: coarse) and (max-width: 395px) {
  .race-title {
    font-size: clamp(48px, 15vw, 63px);
  }
  .location h1 {
    font-size: 19px;
  }
  header:has(#cruise-tools:not([hidden])) .brand {
    display: none;
  }
  .atlas-layout {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  }
}
#meet {
  font: 600 12px system-ui;
  background: #17271f;
  color: #ffefcf;
  border: 1px solid #a9b2a4;
  padding: 5px;
}
