/* A B C — bright, high contrast, and built for fingers on a tablet.
   Every tappable thing is at least 64px so a small hand can't miss it. */

:root {
  --bg: #fef6e4;
  --ink: #2b2b45;
  --muted: #6b6b8a;
  --card: #ffffff;
  --shadow: 0 10px 0 rgba(43, 43, 69, 0.16);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Baloo 2", "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #fff9ec, var(--bg) 60%);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* --- Top bar --- */
#bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(12px, 3vw, 28px);
}

#stars {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 800;
  min-width: 4.5ch;
}

#tabs {
  display: flex;
  gap: 8px;
  margin-left: auto;
  background: rgba(43, 43, 69, 0.08);
  padding: 5px;
  border-radius: 999px;
}

.tab {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  padding: 10px 22px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  min-height: 48px;
}

.tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(43, 43, 69, 0.15);
}

.icon-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(43, 43, 69, 0.08);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.icon-btn:active {
  transform: scale(0.92);
}

.pill {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  padding: 16px 30px;
  border-radius: 999px;
  background: #ffd166;
  color: var(--ink);
  box-shadow: 0 6px 0 #e0ac3d;
  min-height: 60px;
}

.pill:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #e0ac3d;
}

.pill.big {
  font-size: clamp(1.3rem, 5vw, 2rem);
  padding: 22px 60px;
}

#screen {
  padding: clamp(8px, 2vw, 20px) clamp(12px, 3vw, 28px) 48px;
}

/* --- Learn mode: the alphabet grid --- */
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(84px, 15vw, 130px), 1fr));
  gap: clamp(10px, 2vw, 18px);
  max-width: 1100px;
  margin: 0 auto;
}

.tile {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  aspect-ratio: 1;
  border-radius: 22px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 6px;
  color: #fff;
  background: hsl(var(--h) 78% 58%);
  box-shadow: 0 7px 0 hsl(var(--h) 78% 44%);
  transition: transform 120ms ease;
}

.tile:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 hsl(var(--h) 78% 44%);
}

.tile .glyph {
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1;
}

.tile .pic {
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  line-height: 1;
}

/* A letter the learner has answered correctly at least once. */
.tile.known::after {
  content: "⭐";
  position: absolute;
  font-size: 0.9rem;
}

.tile-wrap {
  position: relative;
  display: grid;
}

/* --- Play mode --- */
#play {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

#prompt {
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 800;
  margin: clamp(8px, 3vh, 28px) 0 6px;
}

#prompt-pic {
  font-size: clamp(4rem, 20vw, 9rem);
  line-height: 1.1;
  margin: 4px 0;
}

#replay {
  margin-bottom: clamp(10px, 3vh, 26px);
}

#choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(96px, 24vw, 190px), 1fr));
  gap: clamp(12px, 3vw, 24px);
  max-width: 760px;
  margin: 0 auto;
}

.choice {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(3rem, 12vw, 5.5rem);
  aspect-ratio: 1;
  border-radius: 28px;
  color: #fff;
  background: hsl(var(--h) 78% 58%);
  box-shadow: 0 9px 0 hsl(var(--h) 78% 44%);
  display: grid;
  place-items: center;
}

.choice:active {
  transform: translateY(6px);
  box-shadow: 0 3px 0 hsl(var(--h) 78% 44%);
}

.choice.right {
  animation: pop 520ms ease;
}

.choice.wrong {
  animation: shake 420ms ease;
}

.choice[disabled] {
  cursor: default;
  opacity: 0.45;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  45% { transform: translateX(12px); }
  70% { transform: translateX(-7px); }
}

/* --- Letter card --- */
#card {
  position: fixed;
  inset: 0;
  background: rgba(43, 43, 69, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

#card-inner {
  position: relative;
  background: var(--card);
  border-radius: 32px;
  padding: clamp(20px, 5vw, 40px);
  text-align: center;
  width: min(460px, 100%);
  box-shadow: var(--shadow);
  animation: pop 320ms ease;
}

#card-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

#card-letter {
  font-size: clamp(5rem, 26vw, 9rem);
  font-weight: 800;
  line-height: 1;
  color: hsl(var(--h) 78% 52%);
}

#card-emoji {
  font-size: clamp(3rem, 14vw, 5rem);
  line-height: 1.2;
}

#card-word {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  margin-bottom: 18px;
}

#card-nav {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}

/* --- Title screen --- */
#start {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 20%, #fff9ec, #ffe9b8 70%);
  text-align: center;
  padding: 20px;
}

#start h1 {
  font-size: clamp(4rem, 24vw, 10rem);
  margin: 0;
  line-height: 1;
}

#start h1 span {
  color: hsl(var(--h) 78% 55%);
  display: inline-block;
  animation: bob 2.4s ease-in-out infinite;
}

#start h1 span:nth-child(2) { animation-delay: 0.2s; }
#start h1 span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

#start p {
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  color: var(--muted);
  margin: 10px 0 32px;
}

/* --- Confetti --- */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

#confetti span {
  position: absolute;
  font-size: 1.8rem;
  animation: fall 1.5s linear forwards;
}

@keyframes fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
