:root {
  --ink: #34324a;
  --cream: #fffaf0;
  --yellow: #ffc93c;
  --pink: #ff719a;
  --blue: #59b8ff;
  --green: #68d391;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #fff 0 5%, transparent 6%),
              radial-gradient(circle at 90% 25%, #fff 0 4%, transparent 5%),
              linear-gradient(145deg, #fff4d8, #e9f8ff);
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; touch-action: manipulation; }

.welcome-screen {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(145deg, #fff4d8 0%, #dff6ff 100%);
  transition: opacity .45s ease, visibility .45s ease;
}
.welcome-screen.closed { opacity: 0; visibility: hidden; pointer-events: none; }
.welcome-bubble {
  width: min(520px, 100%); padding: clamp(24px, 7vw, 48px); text-align: center;
  background: rgba(255,255,255,.94); border-radius: 40px; box-shadow: 0 12px 0 rgba(130,120,100,.17);
}
.welcome-bear {
  font-size: clamp(7rem, 30vw, 11rem); line-height: 1;
  filter: drop-shadow(0 8px 0 #dfcba5); animation: welcomeWave 1.5s ease-in-out infinite;
}
.welcome-bubble h1 { margin: 18px 0 6px; color: #ff6b6b; }
.welcome-bubble p { margin: 0 0 25px; font-size: clamp(1.4rem, 6vw, 2rem); font-weight: 900; }
.welcome-bubble button {
  min-height: 68px; padding: 14px 24px; border: 0; border-radius: 24px; cursor: pointer;
  color: #fff; background: #6c5ce7; box-shadow: 0 7px 0 #4e3fbd; font-size: clamp(1.1rem, 5vw, 1.4rem); font-weight: 900;
}
.welcome-bubble button:active { transform: translateY(5px); box-shadow: 0 2px 0 #4e3fbd; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}

.brand { font-size: clamp(1.6rem, 5vw, 2.3rem); font-weight: 900; color: #ff6b6b; }
.brand span { color: #4dabf7; }
.icon-button {
  width: 54px; height: 54px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 5px 0 #ddd3bd; font-size: 1.7rem; cursor: pointer;
}
.icon-button:active { transform: translateY(4px); box-shadow: 0 1px 0 #ddd3bd; }
.hidden { visibility: hidden; }

.install-button {
  display: block; margin: 0 auto 12px; padding: 12px 20px; border: 0; border-radius: 999px;
  color: #fff; background: #6c5ce7; box-shadow: 0 5px 0 #4e3fbd; cursor: pointer;
  font-weight: 900; font-size: 1rem;
}
.install-button:active { transform: translateY(4px); box-shadow: 0 1px 0 #4e3fbd; }
.install-button.hidden { display: none; }

main {
  width: min(1050px, calc(100% - 28px));
  margin: 0 auto;
  padding: 10px 0 max(45px, env(safe-area-inset-bottom));
}
.home { text-align: center; }
.hero-character { font-size: clamp(5rem, 15vw, 8rem); filter: drop-shadow(0 8px 0 #dfcba5); animation: bob 2.3s ease-in-out infinite; }
h1 { font-size: clamp(2rem, 6vw, 3.6rem); margin: 10px 0; line-height: 1.05; }
.home > p, .lesson > p { font-size: clamp(1.1rem, 3vw, 1.5rem); margin: 10px 0 28px; }

.activity-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.activity-card {
  min-height: 225px; border: 0; border-radius: 32px; padding: 18px 10px;
  color: #fff; cursor: pointer; box-shadow: 0 9px 0 rgba(52, 50, 74, .2);
  transition: transform .15s;
}
.activity-card:active, .choice:active { transform: translateY(6px); box-shadow: 0 3px 0 rgba(52, 50, 74, .2); }
.activity-card span { display: block; font-size: 5rem; }
.activity-card strong { display: block; font-size: 1.55rem; margin-top: 8px; }
.activity-card small { font-size: 1rem; }
.count { background: #ff826c; } .letters { background: #aa78e8; }
.colors { background: #48c6b7; } .animals { background: #f0a93b; }

.lesson { text-align: center; }
.lesson h1 { margin-top: 0; }
.prompt-card {
  background: rgba(255,255,255,.9); border-radius: 35px; padding: clamp(20px, 5vw, 48px);
  box-shadow: 0 10px 0 rgba(130, 120, 100, .16); min-height: 280px;
  display: grid; place-items: center;
}
.objects { font-size: clamp(3.3rem, 12vw, 6rem); letter-spacing: 10px; line-height: 1.25; }
.big-symbol { font-size: clamp(7rem, 25vw, 13rem); line-height: 1; font-weight: 900; }
.choices { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; margin-top: 28px; }
.choice {
  min-width: 105px; min-height: 90px; border: 5px solid #fff; border-radius: 25px;
  background: var(--yellow); color: var(--ink); font-size: clamp(2rem, 7vw, 3.7rem);
  font-weight: 900; cursor: pointer; box-shadow: 0 7px 0 rgba(52, 50, 74, .22);
}
.color-choice { width: 120px; height: 120px; border-radius: 50%; font-size: 0; }
.correct { animation: celebrate .6s ease; outline: 8px solid #77dd77; }
.wrong { animation: shake .35s ease; }
.feedback { height: 48px; margin: 22px 0 0; font-size: 1.7rem; font-weight: 900; }

@keyframes bob { 50% { transform: translateY(-10px) rotate(2deg); } }
@keyframes welcomeWave { 50% { transform: translateY(-8px) rotate(5deg) scale(1.03); } }
@keyframes celebrate { 50% { transform: scale(1.12) rotate(3deg); } }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

@media (max-width: 780px) { .activity-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .topbar { height: 64px; }
  .icon-button { width: 46px; height: 46px; font-size: 1.4rem; }
  .brand { font-size: 1.65rem; }
  main { width: min(100% - 20px, 500px); padding-top: 4px; }
  .hero-character { font-size: 4.8rem; }
  h1 { font-size: clamp(1.7rem, 8vw, 2.35rem); }
  .home > p, .lesson > p { font-size: 1.05rem; margin: 8px 0 18px; }
  .activity-grid { gap: 12px; }
  .activity-card {
    min-width: 0; min-height: 158px; border-radius: 23px; padding: 13px 6px;
    box-shadow: 0 6px 0 rgba(52, 50, 74, .2);
  }
  .activity-card span { font-size: clamp(3rem, 15vw, 4rem); }
  .activity-card strong { font-size: clamp(1.05rem, 5vw, 1.3rem); margin-top: 4px; }
  .activity-card small { display: block; font-size: .8rem; margin-top: 2px; }
  .lesson h1 { margin-bottom: 4px; }
  .prompt-card { min-height: 210px; border-radius: 27px; padding: 18px 10px; }
  .objects { font-size: clamp(2.8rem, 14vw, 4.5rem); letter-spacing: 3px; overflow-wrap: anywhere; }
  .big-symbol { font-size: clamp(6rem, 34vw, 10rem); }
  .choices { gap: 11px; margin-top: 20px; }
  .choice {
    flex: 1 1 78px; min-width: 78px; max-width: 120px; min-height: 76px;
    border-width: 4px; border-radius: 21px; font-size: clamp(2rem, 11vw, 3rem);
    box-shadow: 0 5px 0 rgba(52, 50, 74, .22);
  }
  .color-choice { width: 84px; height: 84px; flex: 0 1 84px; }
  .feedback { height: 38px; margin-top: 14px; font-size: 1.35rem; }
}

@media (max-width: 340px) {
  .activity-grid { gap: 9px; }
  .activity-card { min-height: 142px; }
  .activity-card small { display: none; }
  .prompt-card { min-height: 185px; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .topbar { height: 58px; }
  main { padding-top: 0; }
  .hero-character { display: none; }
  .home h1 { margin: 0; font-size: 1.8rem; }
  .home > p { margin: 3px 0 10px; }
  .activity-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .activity-card { min-height: 135px; }
  .activity-card span { font-size: 3rem; }
  .lesson h1 { font-size: 1.6rem; }
  .lesson > p { margin: 2px 0 8px; }
  .prompt-card { min-height: 145px; padding: 8px; }
  .big-symbol { font-size: 6rem; }
  .choices { margin-top: 10px; }
  .choice { min-height: 62px; }
  .feedback { margin-top: 8px; }
}
