:root {
  --sun: #ffd84d;
  --sky: #8fd3ff;
  --grass: #7ed957;
  --berry: #ff6b9a;
  --grape: #a685ff;
  --orange: #ff9f43;
  --ink: #2d2a4a;
  --cream: #fff8e7;
  --tap: 96px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

#app, .screen {
  position: fixed;
  inset: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen { display: flex; flex-direction: column; align-items: center; }

/* Play gate */
.play-gate {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh;
  background: radial-gradient(circle at 50% 40%, #fff3b0, var(--sun));
}
.play-letters { display: flex; gap: 10px; }
.play-letters b {
  font-size: min(18vw, 110px); line-height: 1;
  animation: bob 1.6s ease-in-out infinite;
}
.play-letters b:nth-child(1) { color: var(--berry); }
.play-letters b:nth-child(2) { color: var(--grape); animation-delay: .2s; }
.play-letters b:nth-child(3) { color: #2a9df4; animation-delay: .4s; }
.play-icon {
  width: min(48vw, 200px); height: min(48vw, 200px);
  border-radius: 50%;
  background: var(--grass); color: #fff;
  font-size: min(20vw, 90px);
  display: flex; align-items: center; justify-content: center; padding-left: 8px;
  box-shadow: 0 10px 0 #4fa832;
  animation: pulse 1.4s ease-in-out infinite;
}

/* Common */
.home-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px;
  width: var(--tap); height: var(--tap); border-radius: 28px;
  background: #fff; font-size: 48px;
  box-shadow: 0 6px 0 #e6dcc4;
  z-index: 5;
}
.big-btn {
  min-width: var(--tap); min-height: var(--tap);
  border-radius: 32px;
  box-shadow: 0 8px 0 rgba(0,0,0,.18);
  transition: transform .08s;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }

/* Menu */
.menu { justify-content: center; gap: 3vh; background: linear-gradient(var(--sky), #d6f0ff); }
.menu-btn {
  width: min(84vw, 380px); height: max(100px, min(20vh, 160px));
  display: flex; align-items: center; justify-content: center; gap: 18px;
  font-size: min(16vw, 72px); font-weight: 800; color: #fff;
}
.menu-btn .emoji { font-size: 1.1em; }
.menu-learn { background: var(--berry); }
.menu-pop { background: var(--orange); }
.menu-fill { background: var(--grape); }

/* Learn */
.learn { justify-content: space-between; background: linear-gradient(#fff3b0, var(--cream)); }
.learn-card {
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: none; padding-top: 70px;
}
.learn-letter { font-size: min(52vw, 22vh, 22dvh); font-weight: 900; line-height: 1; }
.learn-letter small { font-size: .6em; margin-left: .05em; opacity: .85; }
.learn-emoji { font-size: min(30vw, 12vh, 12dvh); line-height: 1.1; }
.learn-word { font-size: min(10vw, 48px, 6vh); font-weight: 700; }
.learn-nav { display: flex; justify-content: space-between; width: 100%; max-width: 480px; }
.arrow-btn {
  width: min(36vw, 150px); height: 104px; flex: none;
  font-size: 60px; color: #fff; background: #2a9df4;
}
.arrow-btn:disabled { opacity: .25; }
.wiggle { animation: wiggle .5s ease-in-out; }

/* Pop */
.pop { background: linear-gradient(#6ec6ff, #c9ecff 70%, var(--grass) 70%); overflow: hidden; }
.balloon {
  position: absolute; bottom: -180px;
  width: 110px; height: 136px;
  border-radius: 50% 50% 48% 48%;
  font-size: 64px; font-weight: 900; color: #fff;
  display: flex; align-items: center; justify-content: center;
  text-shadow: 0 3px 0 rgba(0,0,0,.2);
  box-shadow: inset -12px -14px 0 rgba(0,0,0,.12);
  animation: float-up linear forwards;
}
.balloon::after {
  content: ""; position: absolute; bottom: -38px; left: 50%;
  width: 2px; height: 40px; background: rgba(0,0,0,.35);
}
.balloon.popped { animation: pop .3s ease-out forwards; pointer-events: none; }

/* Fill */
.fill { justify-content: center; gap: 4vh; background: linear-gradient(#e9e0ff, var(--cream)); }
.fill-row { display: flex; gap: 2.5vw; }
.fill-cell {
  width: min(20vw, 110px, 24vh); height: min(24vw, 130px, 26vh);
  border-radius: 24px; background: #fff;
  font-size: min(15vw, 84px, 17vh); font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 #ddd3f5;
}
.fill-cell.gap { border: 6px dashed var(--grape); background: #f6f1ff; box-shadow: none; }
.fill-cell.filled { animation: pop-in .4s ease-out; color: var(--grape); border-style: solid; background: #fff; }
.fill-choices { display: flex; gap: 8vw; }
.choice-btn {
  width: max(100px, min(34vw, 160px, 28vh)); height: max(100px, min(34vw, 160px, 28vh));
  font-size: min(20vw, 100px, 18vh); font-weight: 900; color: #fff;
}
.choice-btn:nth-child(1) { background: var(--orange); }
.choice-btn:nth-child(2) { background: #2a9df4; }
.choice-btn.shake { animation: shake .45s ease-in-out; }
.choice-btn:disabled { opacity: .4; }
.cheer { font-size: min(10vw, 52px); font-weight: 800; color: var(--berry); min-height: 1.3em; text-align: center; }

/* Sparkles */
.sparkle {
  position: fixed; font-size: 40px; pointer-events: none; z-index: 10;
  animation: sparkle 1s ease-out forwards;
}

/* Done */
.done { justify-content: center; gap: 3vh; background: radial-gradient(circle, #fff3b0, var(--sun)); text-align: center; }
.done-star { font-size: min(40vw, 200px, 28vh); animation: bob 1.6s ease-in-out infinite; }
.done-text { font-size: min(11vw, 56px); font-weight: 800; margin: 0; }
.again-btn { width: min(70vw, 300px); height: 104px; flex: none; font-size: 56px; color: #fff; background: var(--grass); }

@keyframes bob { 50% { transform: translateY(-14px); } }
@keyframes pulse { 50% { transform: scale(1.07); } }
@keyframes wiggle { 25% { transform: rotate(-8deg) scale(1.08); } 75% { transform: rotate(8deg) scale(1.08); } }
@keyframes float-up { to { transform: translateY(calc(-100vh - 260px)); } }
@keyframes pop { to { transform: scale(1.6); opacity: 0; } }
@keyframes pop-in { 0% { transform: scale(.3); } 70% { transform: scale(1.2); } }
@keyframes shake { 20%, 60% { transform: translateX(-16px); } 40%, 80% { transform: translateX(16px); } }
@keyframes sparkle { to { transform: translate(var(--dx), var(--dy)) scale(.4) rotate(160deg); opacity: 0; } }

/* Short or sideways screens (phones turned landscape, small iPhones) */
@media (orientation: landscape) and (max-height: 560px) {
  .menu { flex-direction: row; gap: 3vw; padding-left: 120px; }
  .menu-btn { width: auto; flex: 1; max-width: 240px; height: 140px; flex-direction: column; gap: 4px; font-size: 40px; }
  .learn { flex-direction: row; justify-content: center; }
  .learn-card { padding-top: 0; }
  .learn-letter { font-size: 40vh; }
  .learn-emoji { font-size: 20vh; }
  .learn-word { font-size: 9vh; }
  .learn-nav { position: absolute; inset: 0; max-width: none; align-items: center; padding: 0 16px; pointer-events: none; }
  .learn-nav .arrow-btn { pointer-events: auto; width: 110px; }
  .learn .home-btn { top: 12px; }
  .done { flex-direction: row; gap: 6vw; }
  .done-star { font-size: 40vh; }
  .again-btn { width: 180px; }
  .done-text { font-size: 9vh; }
}

@media (prefers-reduced-motion: reduce) {
  .play-letters b, .play-icon, .done-star { animation: none; }
}
