.game-page {
  min-height: 100svh;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(242, 184, 75, 0.20), transparent 22rem),
    radial-gradient(circle at 82% 10%, rgba(15, 118, 110, 0.16), transparent 20rem),
    linear-gradient(180deg, #fbfaf7 0%, #eef2e6 100%);
}

.game-page .site-header {
  border-bottom: 1px solid rgba(17, 19, 21, 0.08);
}

.game-shell {
  width: min(100vw, 1180px);
  min-height: calc(100svh - 74px);
  display: grid;
  place-items: center;
  margin: 0 auto;
  padding: 1rem;
}

.game-stage {
  width: min(100%, calc((100svh - 110px) * 16 / 9));
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

#game {
  width: 100%;
  height: auto;
  max-height: calc(100svh - 110px);
  aspect-ratio: 16 / 9;
  border: 3px solid #17252b;
  background: #9ed5e6;
  image-rendering: pixelated;
  box-shadow: 0 18px 48px rgba(23, 37, 43, 0.18);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-controls {
  display: none;
  width: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-cluster {
  display: flex;
  gap: 0.55rem;
}

.action-controls {
  justify-content: flex-end;
}

.touch-button {
  display: grid;
  place-items: center;
  min-width: 4.8rem;
  min-height: 3.35rem;
  border: 2px solid #17252b;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0)),
    #fffdf2;
  color: #17252b;
  box-shadow: 0 6px 0 #17252b;
  font: 900 1.05rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.touch-button:active,
.touch-button.is-pressed {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #17252b;
}

.jump-button {
  min-width: 4.9rem;
  min-height: 4.9rem;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.72), transparent 28%),
    #f4bf45;
  font-size: 2rem;
}

.start-button {
  min-width: 5.2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0)),
    #d7f0f0;
  font-size: 0.78rem;
}

.dpad-button {
  min-width: 4.9rem;
  min-height: 4.9rem;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.72), transparent 28%),
    #fffdf2;
  font-size: 2rem;
}

:fullscreen .game-shell {
  width: 100vw;
  min-height: 100vh;
  padding: 0;
  background: #17252b;
}

:fullscreen .game-stage {
  width: min(100vw, calc(100vh * 16 / 9));
  gap: 0;
}

:fullscreen .site-header {
  display: none;
}

:fullscreen #game {
  width: 100%;
  max-height: 100vh;
  border: 0;
  box-shadow: none;
}

@media (max-width: 760px), (pointer: coarse) {
  html:has(.game-page),
  body.game-page {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  .game-page {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }

  .game-page .site-header {
    display: none;
  }

  .game-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding: max(0.45rem, env(safe-area-inset-top)) max(0.45rem, env(safe-area-inset-right)) max(0.45rem, env(safe-area-inset-bottom)) max(0.45rem, env(safe-area-inset-left));
    align-items: stretch;
    background: #17252b;
  }

  .game-stage {
    width: 100%;
    height: 100%;
    align-content: start;
    gap: 0.55rem;
  }

  #game {
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: calc(100dvh - 4.6rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-width: 2px;
    box-shadow: none;
  }

  .touch-controls {
    display: grid;
    align-self: end;
  }

  :fullscreen .touch-controls {
    display: grid;
  }
}

@media (max-width: 420px) {
  .game-shell {
    padding: 0.5rem;
  }

  .touch-controls {
    gap: 0.5rem;
  }

  .touch-cluster {
    gap: 0.45rem;
  }

  .touch-button {
    min-width: 3.9rem;
    min-height: 3.9rem;
  }

  .start-button {
    min-width: 4.6rem;
    min-height: 3.3rem;
    font-size: 0.7rem;
  }

  .jump-button,
  .dpad-button {
    font-size: 1.8rem;
  }
}
