:root {
  --sky-top: #7dd3fc;
  --sky-bottom: #fef3c7;
  --ink: #1e3a5f;
  --card: #fffdf8;
  --shadow: 0 12px 0 rgba(30, 58, 95, 0.12);
  --pink: #fb7185;
  --yellow: #fbbf24;
  --green: #34d399;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --orange: #fb923c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", "Fredoka", system-ui, sans-serif;
  color: var(--ink);
  overflow: hidden;
}

body {
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--sky-top) 0%, #bae6fd 42%, var(--sky-bottom) 100%);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
}

.hidden {
  display: none !important;
}

.top-bar .icon-btn.hidden,
.top-bar .score-chip.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.sun {
  position: absolute;
  top: 28px;
  right: 36px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7c2, #fbbf24);
  box-shadow: 0 0 0 14px rgba(251, 191, 36, 0.22);
}

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 999px;
  opacity: 0.88;
  filter: drop-shadow(0 8px 0 rgba(255, 255, 255, 0.2));
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.cloud-a {
  width: 140px;
  height: 42px;
  top: 70px;
  left: 8%;
  animation: drift 22s linear infinite;
}

.cloud-a::before {
  width: 52px;
  height: 52px;
  top: -28px;
  left: 18px;
}

.cloud-a::after {
  width: 70px;
  height: 70px;
  top: -38px;
  left: 50px;
}

.cloud-b {
  width: 110px;
  height: 34px;
  top: 130px;
  right: 12%;
  animation: drift 28s linear infinite reverse;
}

.cloud-b::before {
  width: 40px;
  height: 40px;
  top: -20px;
  left: 16px;
}

.cloud-b::after {
  width: 56px;
  height: 56px;
  top: -30px;
  left: 40px;
}

.cloud-c {
  width: 160px;
  height: 46px;
  top: 28px;
  left: 42%;
  animation: drift 32s linear infinite;
}

.cloud-c::before {
  width: 60px;
  height: 60px;
  top: -30px;
  left: 22px;
}

.cloud-c::after {
  width: 76px;
  height: 76px;
  top: -42px;
  left: 58px;
}

.hill {
  position: absolute;
  bottom: -80px;
  width: 140%;
  height: 220px;
  border-radius: 50%;
}

.hill-back {
  left: -30%;
  background: #86efac;
}

.hill-front {
  right: -40%;
  height: 180px;
  background: #4ade80;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 18px 18px 32px;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: grid;
  grid-template-columns: 64px 1fr 84px;
  align-items: center;
  gap: 8px;
  min-height: 72px;
}

.logo {
  margin: 0;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.6);
}

.icon-btn,
.score-chip {
  min-height: 56px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 64px;
  font-size: 1.6rem;
  color: var(--ink);
}

.icon-btn:active,
.btn:active,
.game-card:active {
  transform: translateY(4px);
  box-shadow: 0 8px 0 rgba(30, 58, 95, 0.12);
}

.score-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.2rem;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tagline,
.prompt {
  text-align: center;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  margin: 4px 0 22px;
}

.prompt {
  min-height: 2.2em;
  font-weight: 800;
}

.game-grid {
  display: grid;
  gap: 18px;
}

@media (min-width: 720px) {
  .game-grid {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 24px;
  }
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px 24px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.12s ease;
}

.game-card:nth-child(1) {
  outline: 6px solid rgba(251, 113, 133, 0.25);
}

.game-card:nth-child(2) {
  outline: 6px solid rgba(56, 189, 248, 0.28);
}

.game-card:nth-child(3) {
  outline: 6px solid rgba(251, 191, 36, 0.35);
}

.game-emoji {
  font-size: 3.4rem;
  line-height: 1;
}

.game-name {
  font-family: "Fredoka", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.game-hint {
  opacity: 0.7;
}

.playfield {
  position: relative;
  flex: 1;
  min-height: 420px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}

.card {
  aspect-ratio: 1;
  border-radius: 20px;
  background: transparent;
  perspective: 800px;
  padding: 0;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

.card.flipped .card-inner,
.card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 20px;
  backface-visibility: hidden;
  box-shadow: var(--shadow);
  font-size: clamp(1.8rem, 7vw, 2.8rem);
}

.card-back {
  background: linear-gradient(160deg, #38bdf8, #818cf8);
}

.card-front {
  background: #fff;
  transform: rotateY(180deg);
}

.card.matched .card-front {
  outline: 5px solid #34d399;
}

.balloon {
  position: absolute;
  width: 86px;
  height: 110px;
  border: 0;
  background: transparent;
  padding: 0;
  animation: float-up linear forwards;
}

.balloon-body {
  width: 78px;
  height: 90px;
  margin: 0 auto;
  border-radius: 50% 50% 48% 48%;
  box-shadow: inset -10px -8px 0 rgba(0, 0, 0, 0.08), var(--shadow);
}

.balloon-string {
  width: 2px;
  height: 18px;
  margin: 0 auto;
  background: rgba(30, 58, 95, 0.35);
}

.balloon.pop {
  animation: pop 0.28s ease forwards;
}

.star {
  position: absolute;
  width: 72px;
  height: 72px;
  border: 0;
  background: transparent;
  font-size: 3rem;
  line-height: 1;
  padding: 0;
  filter: drop-shadow(0 8px 0 rgba(30, 58, 95, 0.12));
  animation: fall linear forwards;
}

.star.bonus {
  font-size: 3.4rem;
}

.star.caught {
  animation: pop 0.25s ease forwards;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(30, 58, 95, 0.28);
  padding: 20px;
}

.modal-card {
  width: min(100%, 420px);
  background: var(--card);
  border-radius: 32px;
  box-shadow: var(--shadow);
  text-align: center;
  padding: 32px 24px 28px;
}

.win-emoji {
  font-size: 4rem;
  margin: 0;
}

.modal-card h2 {
  font-family: "Fredoka", sans-serif;
  font-size: 2rem;
  margin: 4px 0 8px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  min-height: 58px;
  border-radius: 18px;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: var(--shadow);
}

.btn-primary {
  background: #34d399;
  color: #064e3b;
}

.btn-ghost {
  background: #e0f2fe;
  color: var(--ink);
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 4px;
  animation: confetti-fall 1.4s ease-in forwards;
}

@keyframes drift {
  from {
    transform: translateX(-40px);
  }
  to {
    transform: translateX(40px);
  }
}

@keyframes float-up {
  from {
    transform: translateY(0) rotate(-6deg);
  }
  to {
    transform: translateY(-120vh) rotate(8deg);
  }
}

@keyframes fall {
  from {
    transform: translateY(-80px) rotate(-12deg);
  }
  to {
    transform: translateY(110vh) rotate(18deg);
  }
}

@keyframes pop {
  60% {
    transform: scale(1.25);
    opacity: 1;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(420deg);
    opacity: 0.2;
  }
}

@media (max-width: 520px) {
  .memory-grid {
    gap: 8px;
  }

  .balloon {
    width: 72px;
  }

  .balloon-body {
    width: 64px;
    height: 76px;
  }
}
