:root {
  --bg: #09111f;
  --bg-alt: #121f34;
  --panel: rgba(10, 18, 34, 0.72);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f7f7f3;
  --muted: #b3c1d9;
  --hot: #ff8d5c;
  --gold: #ffd166;
  --mint: #7df9c1;
  --tile-a: #ffbf69;
  --tile-b: #ff7f50;
  --tile-c: #ff5d8f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 191, 105, 0.16), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(125, 249, 193, 0.12), transparent 24%),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-alt) 100%);
}

button {
  font: inherit;
}

.page-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.55;
  animation: float 9s ease-in-out infinite;
}

.ambient-a {
  top: 8%;
  left: -4rem;
  width: 16rem;
  height: 16rem;
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.4), rgba(255, 93, 143, 0.14));
}

.ambient-b {
  right: -3rem;
  bottom: 8%;
  width: 15rem;
  height: 15rem;
  background: linear-gradient(135deg, rgba(125, 249, 193, 0.26), rgba(255, 141, 92, 0.18));
  animation-delay: -3s;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 2rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.hero {
  width: 100%;
  animation: rise-in 700ms ease-out both;
}

.eyebrow {
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
}

.hero h1,
.win-card h2 {
  margin: 0;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.hero h1 {
  max-width: 8ch;
  font-size: clamp(3.25rem, 9vw, 6.3rem);
}

.intro {
  max-width: 32rem;
  margin: 1rem 0 0;
  line-height: 1.65;
  color: var(--muted);
  font-size: 1.02rem;
}

.game-card {
  width: min(100%, 34rem);
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 32px;
  padding: 1rem;
  box-shadow: var(--shadow);
  animation: rise-in 850ms ease-out both;
}

.toolbar,
.board-header,
.footer-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toolbar {
  margin-bottom: 1rem;
}

.stat {
  min-width: 6.7rem;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label,
.board-subtitle {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.stat strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.25rem;
}

.board-wrap {
  padding: 1.1rem;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    rgba(5, 12, 24, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.board-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.board-subtitle {
  margin: 0.2rem 0 0;
}

.shuffle-button {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font-weight: 700;
  color: #1d1408;
  background: linear-gradient(135deg, var(--gold), var(--hot));
  box-shadow: 0 12px 24px rgba(255, 141, 92, 0.25);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.shuffle-button:hover,
.shuffle-button:focus-visible {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 18px 28px rgba(255, 141, 92, 0.34);
}

.board {
  position: relative;
  width: min(100%, 29rem);
  aspect-ratio: 1;
  margin: 1.2rem auto 0;
  border-radius: 24px;
  padding: 0.55rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(7, 14, 29, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.board::before {
  content: "";
  position: absolute;
  inset: 0.55rem;
  border-radius: 18px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: calc(100% / 4) calc(100% / 4);
  pointer-events: none;
}

.tile {
  position: absolute;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 18px;
  color: #1a1120;
  font-family: "Archivo", "Space Grotesk", sans-serif;
  font-size: clamp(1.45rem, 4.5vw, 2rem);
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1;
  letter-spacing: 0;
  background: linear-gradient(135deg, var(--tile-a), var(--tile-b) 58%, var(--tile-c));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 14px 28px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition:
    transform 180ms ease,
    left 220ms cubic-bezier(0.22, 1, 0.36, 1),
    top 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 180ms ease;
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 20px 36px rgba(0, 0, 0, 0.32);
}

.tile[data-correct="true"] {
  background: linear-gradient(135deg, #b7ffca, #7df9c1);
}

.tile::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.footer-note {
  margin-top: 1rem;
}

.note-pill {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.86rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.win-banner {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(3, 9, 18, 0.6);
  backdrop-filter: blur(10px);
}

.win-card {
  width: min(100%, 28rem);
  padding: 2rem;
  border-radius: 30px;
  text-align: center;
  background: linear-gradient(180deg, rgba(19, 31, 53, 0.98), rgba(10, 17, 31, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.win-card h2 {
  font-size: clamp(2rem, 8vw, 3.2rem);
}

.win-card p:last-of-type {
  color: var(--muted);
  line-height: 1.6;
}

.hidden {
  display: none;
}

@keyframes float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -18px, 0);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 2.5rem;
    padding: 2.5rem 2rem 3rem;
    justify-items: stretch;
  }

  .game-card {
    padding: 1.2rem;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app {
    min-height: auto;
    align-items: start;
    padding: 1rem 0.75rem 2rem;
  }

  .game-card {
    border-radius: 24px;
  }

  .board-wrap {
    padding: 0.85rem;
  }

  .board {
    width: min(100%, 24rem);
  }

  .stat {
    min-width: calc(50% - 0.5rem);
  }

  .footer-note {
    justify-content: center;
  }

  .note-pill {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}
