#touch-pad {
  --safe-side: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --side: max(2.3vw, var(--safe-side), 12px);
  --pad-bottom: max(4dvh, calc(env(safe-area-inset-bottom) + 4px));
  --shoulder-top: max(4.8dvh, calc(env(safe-area-inset-top) + 2px));
  --stick: clamp(72px, 23dvh, 114px);
  --face: clamp(32px, 9dvh, 43px);
  --step: clamp(32px, 8.8dvh, 44px);
  --diamond: calc(44px + var(--step) * 2);
  --stick-inset: max(var(--side), calc(var(--safe-side) + (var(--diamond) - var(--stick)) / 2));
  --inner-gap: clamp(7px, 1.2vw, 12px);
  --ring: rgb(246 246 250 / 64%);
  --well: rgb(20 22 29 / 66%);
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  color: #f9f9fc;
  font: 500 15px/1 "Barlow Condensed", sans-serif;
  -webkit-text-stroke: 0;
}
@media (pointer: coarse) and (orientation: landscape) {
  #touch-pad:not([hidden]) { display: block; }
}
#touch-pad button {
  padding: 0;
  margin: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  color: inherit;
  outline-offset: 2px;
}
#touch-pad button > * { pointer-events: none; }
#touch-pad button:focus-visible { outline: 2px solid white; }
#touch-pad :is(.trigger, .stick-group, .face-buttons, .system-button) { position: absolute; }
#touch-pad :is(.trigger, .face, .system-button) > span,
#touch-pad .stick-cap {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  border: 1.5px solid var(--ring);
  background: var(--well);
  transition: transform 110ms ease-out, background-color 110ms, border-color 110ms;
}
#touch-pad .trigger {
  width: clamp(64px, 17dvh, 84px);
  height: 46px;
  top: var(--shoulder-top);
}
#touch-pad .lt { left: var(--side); }
#touch-pad .rt { right: var(--side); }
#touch-pad .trigger > span {
  width: 100%;
  height: 32px;
  font-size: 17px;
  letter-spacing: .06em;
  border-top: 2px solid rgb(255 255 255 / 85%);
  border-radius: 13px 8px 15px 7px;
}
#touch-pad .rt > span { border-radius: 8px 13px 7px 15px; }
#touch-pad .bumper { top: calc(var(--shoulder-top) + 44px); }
#touch-pad .lb { left: var(--side); }
#touch-pad .rb { right: var(--side); }
/* In short landscape windows, leave the full face-button diamond clear of the shoulders. */
@media (max-height: 326px) {
  #touch-pad .trigger {
    --shoulder-inset: calc(var(--stick-inset) + (var(--stick) + var(--diamond)) / 2 + var(--inner-gap));
  }
  #touch-pad :is(.lt, .lb) { left: var(--shoulder-inset); }
  #touch-pad :is(.rt, .rb) { right: var(--shoulder-inset); }
}
#touch-pad .bumper > span { width: 91%; height: 27px; border-radius: 7px; border-top-width: 1.5px; }
#touch-pad .stick-group {
  bottom: var(--pad-bottom);
  width: var(--stick);
  height: var(--stick);
  transform-origin: center bottom;
}
#touch-pad .left-side { left: var(--stick-inset); }
#touch-pad .right-side { right: var(--stick-inset); }
#touch-pad .stick {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--ring);
  border-radius: 50%;
  background: rgb(20 22 29 / 45%);
}
#touch-pad .stick::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: repeating-conic-gradient(from -1.8deg, rgb(255 255 255 / 56%) 0 3.6deg, transparent 3.6deg 90deg);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
#touch-pad .stick-cap {
  position: relative;
  width: 56%;
  height: 56%;
  border-radius: 50%;
  color: rgb(255 255 255 / 90%);
  background: rgb(54 57 66 / 80%);
  font-size: 16px;
  letter-spacing: .04em;
  transform: translate(var(--dx, 0px), var(--dy, 0px));
}
#touch-pad .stick[data-pressed] .stick-cap {
  background: rgb(93 96 107 / 90%);
  border-color: white;
  transition-duration: 0s;
}
#touch-pad .face-buttons {
  left: 50%;
  translate: -50% 0;
  bottom: calc(100% + 12px);
  width: var(--diamond);
  height: var(--diamond);
}
#touch-pad .face {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  clip-path: circle(50%);
}
#touch-pad .face > span {
  width: var(--face);
  height: var(--face);
  border-radius: 50%;
  color: var(--ink);
  font: var(--keycap-weight) clamp(15px,4.3dvh,20px)/1 var(--sans-font);
  background: rgb(21 23 30 / 77%);
}
#touch-pad .y { --ink: #ffdb66; top: 0; left: var(--step); }
#touch-pad .x { --ink: #83c9ff; top: var(--step); left: 0; }
#touch-pad .b { --ink: #ff918c; top: var(--step); right: 0; }
#touch-pad .a { --ink: #a6e487; bottom: 0; left: var(--step); }
#touch-pad .system-button {
  bottom: 0;
  width: 45px;
  height: 44px;
  align-items: end;
}
#touch-pad .select-button { left: calc(100% + var(--inner-gap)); }
#touch-pad .start-button { right: calc(100% + var(--inner-gap)); }
#touch-pad .system-button > span {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 26px;
  width: 100%;
  padding: 0 8px;
  border-radius: 14px;
}
#touch-pad .system-button svg { width: 17px; height: 15px; stroke: currentColor; stroke-width: 1.5; fill: none; }
#touch-pad :is(.trigger, .face, .system-button):is([data-pressed], :active) > span {
  background: rgb(92 95 104 / 90%);
  color: white;
  border-color: white;
  transform: scale(.95);
}
@media (prefers-reduced-motion: reduce) {
  #touch-pad button > span { transition: none; }
}
@media (prefers-reduced-motion: no-preference) {
  #touch-pad:not([hidden], [data-entered]) :is(.trigger, .stick-group) {
    animation: touch-controls-enter 380ms cubic-bezier(.2,.72,.24,1) both;
  }
}
@keyframes touch-controls-enter {
  from { opacity: 0; scale: .88; }
  to { opacity: 1; scale: 1; }
}
