:root {
  color-scheme: light;
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  background: #87d9ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  min-height: 100svh;
}

.game-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.58), transparent 11rem),
    linear-gradient(180deg, #78d6ff 0%, #a9ecff 46%, #d7f7db 100%);
}

.game-shell::before {
  position: absolute;
  right: -7rem;
  bottom: -5rem;
  width: min(52vw, 28rem);
  aspect-ratio: 1;
  content: "";
  background: #7edb77;
  border-radius: 50%;
  box-shadow:
    -18vw 6vh 0 -3rem #92e181,
    -34vw 3vh 0 -5rem #63c96e;
  opacity: 0.82;
}

.game-shell::after {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18svh;
  content: "";
  background:
    linear-gradient(120deg, transparent 0 48%, rgba(255, 255, 255, 0.24) 49% 51%, transparent 52%),
    linear-gradient(180deg, rgba(117, 217, 125, 0), rgba(65, 184, 94, 0.58));
  opacity: 0.76;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.back-button {
  position: fixed;
  z-index: 4;
  display: grid;
  place-items: center;
  color: #16516c;
  background: rgba(255, 255, 255, 0.74);
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0.55rem 1.6rem rgba(29, 105, 135, 0.18);
  backdrop-filter: blur(14px);
}

.back-button {
  top: max(0.75rem, env(safe-area-inset-top));
  left: max(0.75rem, env(safe-area-inset-left));
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.back-button span {
  display: block;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  border-bottom: 0.3rem solid currentColor;
  border-left: 0.3rem solid currentColor;
  transform: rotate(45deg);
}

.back-button:active {
  transform: scale(0.95);
}

.back-button[hidden] {
  display: none;
}

.home-menu {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  justify-content: center;
  width: 100%;
  min-height: 100svh;
  padding: max(1rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 3rem)
    max(1rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  pointer-events: auto;
}

.home-menu[hidden] {
  display: none;
}

.home-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(58rem, 100%);
  margin: 0 auto;
}

.home-menu__header p {
  margin: 0;
  color: #16516c;
  font-size: clamp(1.35rem, 5vw, 2.75rem);
  font-weight: 900;
  text-shadow: 0 0.15rem 0 rgba(255, 255, 255, 0.68);
}

.sound-button {
  min-width: 6.5rem;
  min-height: 3rem;
  padding: 0.6rem 1rem;
  color: #16516c;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  box-shadow: 0 0.45rem 1.4rem rgba(29, 105, 135, 0.16);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.7rem, 2vw, 1.15rem);
  width: min(58rem, 100%);
  margin: 0 auto;
}

.game-grid button,
.game-grid a {
  display: grid;
  min-height: clamp(5.8rem, 16svh, 9rem);
  padding: 1rem;
  color: #174e68;
  font: inherit;
  font-size: clamp(1.2rem, 4vw, 2.1rem);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.58)),
    var(--tile-color, #fff4a8);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  box-shadow: 0 0.65rem 1.7rem rgba(29, 105, 135, 0.16);
  text-decoration: none;
}

.game-grid > :nth-child(2) {
  --tile-color: #ffd0e8;
}

.game-grid > :nth-child(3) {
  --tile-color: #fff49c;
}

.game-grid > :nth-child(4) {
  --tile-color: #d3f7b6;
}

.game-grid > :nth-child(5) {
  --tile-color: #bfe8ff;
}

.game-grid > :nth-child(6) {
  --tile-color: #ffc488;
}

.game-grid > :nth-child(7) {
  --tile-color: #f3bf5f;
}

.game-grid > :nth-child(8) {
  --tile-color: #d7f2a7;
}

.game-grid button:active,
.game-grid a:active,
.sound-button:active {
  transform: scale(0.97);
}

.game-grid span {
  align-self: center;
}

@media (prefers-reduced-motion: reduce) {
  .back-button:active,
  .game-grid button:active,
  .game-grid a:active,
  .sound-button:active {
    transform: none;
  }
}

@media (max-width: 34rem) {
  .home-menu {
    justify-content: flex-start;
    padding-top: max(1.2rem, env(safe-area-inset-top));
  }

  .home-menu__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .game-grid button,
  .game-grid a {
    min-height: 4.7rem;
  }
}
