@media (prefers-reduced-motion: no-preference) {
  html.play-intro .site-title,
  html.play-intro .site-subtitle,
  html.play-intro .theme-toggle,
  html.play-intro .game-card {
    animation: site-entrance 550ms cubic-bezier(.2, .75, .25, 1)
               var(--intro-delay, 0ms) backwards;
  }

  .site-title {
    --intro-y: -28px;
  }

  .site-subtitle {
    --intro-y: -12px;
    --intro-delay: 90ms;
  }

  .theme-toggle {
    --intro-x: 18px;
    --intro-delay: 120ms;
  }

  .game-card {
    --intro-x: -22px;
    --intro-y: 14px;
    --intro-delay: 170ms;
  }

  .game-card:nth-child(even) { --intro-x: 22px; }
  .game-card:nth-child(2) { --intro-delay: 220ms; }

  @keyframes site-entrance {
    from {
      opacity: 0;
      transform: translate(var(--intro-x, 0px), var(--intro-y, 0px));
    }

    to {
      opacity: 1;
      transform: translate(0, 0);
    }
  }
}
.game-grid {
  font-family: system-ui, sans-serif;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 18px;
  max-width: 1080px;
  margin: 12px auto 48px;
  padding: 0 20px;
}

.game-card {
  --card-color: #eee8ff;

  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  aspect-ratio: 2.5;
  min-height: 135px;
  padding: 18px;
  border: 2px solid #252525;
  border-radius: 16px;
  background: var(--card-color);
  color: #151515;
  box-shadow: 0 4px 0 #252525;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.game-card:nth-child(2) { --card-color: #ffedce; }

@media (hover: hover) {
  .game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 #252525;
  }
}

.game-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #252525;
  transition-duration: 60ms;
}

.game-card:focus-visible {
  outline: 3px solid #5940bf;
  outline-offset: 5px;
}

@media (prefers-reduced-motion: reduce) {
  .game-card { transition: none; }
  .game-card:hover,
  .game-card:active { transform: none; }
}
body {
  transition: background-color 300ms ease, color 300ms ease;
}

html[data-theme="dark"] body {
  background-color: #18181d;
  color: #f5f3fa;
}

html[data-theme="dark"] .site-subtitle {
  color: #c5c0ce;
}

html[data-theme="dark"] .game-card {
  background-color: var(--card-color);
  color: #151515;
  border-color: #252525;
}

.game-card {
  transition: transform 160ms ease, box-shadow 160ms ease,
              background-color 300ms ease, color 300ms ease,
              border-color 300ms ease;
}

@media (max-width: 480px) {
  .site-header { padding-top: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  body, .game-card { transition: none; }
}
.sound-toggle {
  position: absolute;
  top: 12px;
  right: 62px;
  height: 42px;
  padding: 0 13px;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: #f8f8f8;
  color: #292929;
  font: 600 0.8rem system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 250ms ease, color 250ms ease,
              border-color 250ms ease, transform 150ms ease;
}

.sound-toggle:hover { transform: translateY(-2px); }
.sound-toggle:active { transform: scale(0.95); }
.sound-toggle:focus-visible { outline: 3px solid #8b68e8; outline-offset: 4px; }

html[data-theme="dark"] .sound-toggle {
  background: #292832;
  border-color: #494653;
  color: #f5f3fa;
}

.sound-toggle[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px #8b68e8;
}

@media (prefers-reduced-motion: reduce) {
  .sound-toggle { transition: none; }
  .sound-toggle:hover,
  .sound-toggle:active { transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  html.opening-game .site-header,
  html.opening-game .game-grid,
  html.opening-game .theme-toggle,
  html.opening-game .sound-toggle {
    animation: game-page-exit 195ms ease-in both;
  }
  @keyframes game-page-exit {
    from { opacity: 1; translate: 0 0; }
    to { opacity: 0; translate: 0 -7px; }
  }
}
