.game-controller {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  --gc-size: clamp(64px, 17vw, 82px);
  --gc-gap: clamp(16px, 4vw, 24px);
}

.game-controller.is-visible {
  display: block;
}

.game-controller [hidden] {
  display: none !important;
}

.gc-cluster {
  position: absolute;
  bottom: calc(max(14px, env(safe-area-inset-bottom)));
  display: flex;
  gap: var(--gc-gap);
  pointer-events: none;
}

.gc-left {
  left: calc(max(12px, env(safe-area-inset-left)));
  align-items: flex-end;
}

.gc-right {
  right: calc(max(12px, env(safe-area-inset-right)));
  align-items: flex-end;
  gap: calc(var(--gc-gap) + 4px);
}

.gc-actions {
  display: flex;
  align-items: flex-end;
  gap: var(--gc-gap);
  padding-bottom: calc(var(--gc-size) * 0.62);
  pointer-events: none;
}

.gc-vertical {
  display: flex;
  flex-direction: column;
  gap: var(--gc-gap);
  pointer-events: none;
}

.gc-btn {
  position: relative;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: var(--gc-size);
  height: var(--gc-size);
  padding: 0;
  border: 2px solid rgb(255 255 255 / 58%);
  border-radius: 20px;
  background: rgb(17 35 43 / 58%);
  color: #fff;
  font: 900 calc(var(--gc-size) * 0.4) / 1 ui-sans-serif, system-ui, -apple-system, sans-serif;
  text-shadow: 0 1px 3px rgb(0 0 0 / 45%);
  box-shadow: 0 4px 0 rgb(0 0 0 / 32%), inset 0 1px 0 rgb(255 255 255 / 22%);
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  transition: transform 80ms ease, background 80ms ease, box-shadow 80ms ease;
}

/* Include near-edge taps while leaving a neutral gap between controls. */
.gc-btn::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: inherit;
}

.gc-btn.is-down,
.gc-btn:active {
  transform: translateY(3px) scale(0.97);
  background: rgb(64 116 135 / 82%);
  box-shadow: 0 1px 0 rgb(0 0 0 / 32%), inset 0 2px 8px rgb(0 0 0 / 22%);
}

.gc-btn.gc-round {
  width: calc(var(--gc-size) * 1.06);
  height: calc(var(--gc-size) * 1.06);
  border-radius: 50%;
  font-size: calc(var(--gc-size) * 0.42);
}

.gc-btn.gc-a {
  background: rgb(50 190 108 / 92%);
  border-color: rgb(226 255 237 / 85%);
}

.gc-btn.gc-a.is-down,
.gc-btn.gc-a:active {
  background: rgb(38 156 86 / 96%);
}

.gc-btn.gc-b {
  background: rgb(224 78 78 / 92%);
  border-color: rgb(255 227 227 / 85%);
}

.gc-btn.gc-b.is-down,
.gc-btn.gc-b:active {
  background: rgb(188 56 56 / 96%);
}

.gc-btn .gc-label {
  display: block;
  line-height: 1;
  pointer-events: none;
}

@media (max-height: 430px) and (orientation: landscape) {
  .game-controller {
    --gc-size: clamp(58px, 15vh, 68px);
  }
  .gc-cluster {
    bottom: calc(max(8px, env(safe-area-inset-bottom)));
  }
}

@media (prefers-reduced-motion: reduce) {
  .gc-btn {
    transition: none;
  }
}

@media (max-width: 560px) {
  .gc-actions {
    flex-direction: column;
    padding-bottom: 0;
  }
}


@media (max-width: 370px) {
  .gc-right {
    flex-direction: column;
  }

  .gc-actions {
    flex-direction: row;
  }
}
