/* ==========================================================================
   Little Genius — styles
   Big touch targets, high contrast, playful, portrait-first, offline.
   No external fonts.
   ========================================================================== */

:root {
  --amber: #FFB627;
  --amber-dark: #E89C10;
  --bg: #FFF8EC;
  --ink: #3A2E1F;
  --card: #FFFFFF;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  --radius: 28px;
  --good: #35C759;
  --lock: #B9A98F;
  --tap: 0.08s;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}

/* Toddler-proofing */
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
}

/* ---------- Top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-height: 64px;
}
.screen-title {
  font-size: clamp(20px, 5vw, 28px);
  margin: 0;
  color: var(--amber-dark);
  font-weight: 800;
  flex: 1;
  text-align: center;
}
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.icon-btn {
  font-size: 28px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  flex: none;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.12); }

.star-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 24px;
  font-weight: 800;
  background: var(--card);
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

/* ---------- Screen ---------- */
#screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 18px 24px;
  min-height: 0;
  overflow-y: auto;
}

/* ---------- Home ---------- */
.home-hello {
  text-align: center;
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 700;
  color: var(--amber-dark);
  margin: 4px 0 14px;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  flex: 1;
  align-content: start;
}
@media (min-width: 620px) { .menu-grid { grid-template-columns: repeat(4, 1fr); } }

.menu-btn {
  position: relative;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 20px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 130px;
  transition: transform var(--tap);
}
.menu-btn:active { transform: scale(0.96); }
.menu-btn .emoji { font-size: 52px; line-height: 1; }
.menu-btn .label { font-size: 20px; font-weight: 800; }

.badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 13px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}
.badge.soon { background: #EDe9e0; color: #8a7c63; }
.badge.premium { background: var(--amber); color: #5a3d00; }

/* ---------- Learn mode ---------- */
.learn-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.learn-hero {
  border: none;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  width: min(70vw, 320px);
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  transition: transform var(--tap);
}
.learn-hero:active { transform: scale(0.97); }
.learn-hero .glyph { font-size: clamp(90px, 34vw, 190px); font-weight: 900; line-height: 1; }
.learn-hero .digit { font-size: clamp(90px, 34vw, 190px); font-weight: 900; line-height: 1; }
.learn-hero svg { width: 60%; height: 60%; }
.learn-caption { font-size: clamp(22px, 6vw, 32px); font-weight: 800; min-height: 40px; }
.learn-caption .obj { font-size: clamp(28px, 8vw, 44px); }

.learn-nav {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  padding-top: 8px;
}
.nav-btn {
  border: none;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 30px;
  width: 72px; height: 72px;
}
.nav-btn:active { transform: translateY(3px); }
.nav-btn.play { width: auto; padding: 0 26px; font-size: 22px; font-weight: 800; background: var(--good); color: #fff; }

/* Mode chooser (Learn / Play) shown when a section opens */
.mode-choose { display:flex; flex-direction:column; gap:18px; flex:1; justify-content:center; }
.mode-btn {
  border:none; border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow); cursor:pointer; padding:26px; font-size:26px; font-weight:800;
  display:flex; align-items:center; gap:16px; justify-content:center;
}
.mode-btn .emoji { font-size:40px; }
.mode-btn:active { transform: scale(0.97); }

/* ---------- Find-it game ---------- */
.prompt-bar {
  text-align: center;
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 800;
  margin: 4px 0 16px;
  min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.prompt-bar .say-btn { border: none; background: transparent; font-size: 32px; cursor: pointer; }

.choices {
  display: grid;
  gap: 16px;
  flex: 1;
  align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.choice {
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: clamp(56px, 20vw, 110px);
  font-weight: 800;
  transition: transform var(--tap);
  overflow: hidden;
}
.choice:active { transform: scale(0.95); }
.choice .digit { font-size: clamp(52px, 15vw, 92px); line-height: 1; }
.choice .objects { font-size: clamp(15px, 4.5vw, 26px); margin-top: 6px; max-width: 92%; word-break: break-word; line-height: 1.1; }
.choice.swatch { font-size: 0; }
.choice svg { width: 62%; height: 62%; }

@keyframes wiggle { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-6deg)} 75%{transform:rotate(6deg)} }
.choice.wrong { animation: wiggle 0.35s ease-in-out; }
.choice.selected { outline: 6px solid var(--amber); }
.choice.matched { opacity: 0.45; }

/* Match-It boards can hold more cards, so allow slightly smaller tiles */
.choices.match { grid-template-columns: repeat(3, 1fr); }

/* Counting game: the group of objects to count */
.count-objects {
  text-align: center;
  font-size: clamp(28px, 9vw, 52px);
  line-height: 1.15;
  margin: 4px auto 14px;
  max-width: 92%;
  word-break: break-word;
}
@keyframes pop { 0%{transform:scale(1)} 50%{transform:scale(1.12)} 100%{transform:scale(1)} }
.choice.right { animation: pop 0.4s ease-out; outline: 6px solid var(--good); }

/* lock overlay for premium items */
.lock-tag { position:absolute; top:8px; right:8px; font-size:22px; }
.choice, .learn-hero { position: relative; }

/* ---------- Cheer overlay ---------- */
.cheer {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(44px, 13vw, 84px); font-weight: 900; color: var(--amber-dark);
  pointer-events: none; opacity: 0; z-index: 60;
  text-shadow: 0 2px 0 #fff;
}
@keyframes cheerIn { 0%{opacity:0;transform:scale(0.6)} 25%{opacity:1;transform:scale(1.05)} 75%{opacity:1;transform:scale(1)} 100%{opacity:0;transform:scale(1)} }
.cheer.show { animation: cheerIn 1.2s ease-out; }

/* ---------- Confetti ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- Modals (parent gate, purchase) ---------- */
#modalHost:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  max-width: 420px; width: 100%; padding: 24px; text-align: center;
}
.modal h2 { margin: 0 0 6px; font-size: 24px; color: var(--amber-dark); }
.modal p { margin: 4px 0 16px; font-size: 17px; line-height: 1.4; }
.gate-question { font-size: 30px; font-weight: 800; margin: 6px 0 14px; }
.gate-answer { font-size: 30px; font-weight: 800; min-height: 40px; letter-spacing: 4px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.keypad button {
  border: none; border-radius: 16px; background: var(--bg); box-shadow: var(--shadow);
  font-size: 26px; font-weight: 800; padding: 14px 0; cursor: pointer;
}
.keypad button:active { transform: translateY(2px); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  border: none; border-radius: 16px; padding: 14px 18px; font-size: 18px; font-weight: 800;
  cursor: pointer; flex: 1; box-shadow: var(--shadow);
}
.btn.primary { background: var(--good); color: #fff; }
.btn.ghost { background: var(--bg); color: var(--ink); }

/* ---------- Parent zone ---------- */
.pz-section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.pz-section h3 { margin: 0 0 12px; font-size: 20px; }
.progress-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.progress-row .plabel { width: 110px; font-weight: 700; }
.progress-track { flex: 1; height: 16px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--good); border-radius: 999px; }
.progress-row .pnum { width: 62px; text-align: right; font-variant-numeric: tabular-nums; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid #eee2cf; }
.setting-row:first-of-type { border-top: none; }
.toggle { width: 60px; height: 34px; border-radius: 999px; border: none; background: #ccc; position: relative; cursor: pointer; }
.toggle.on { background: var(--good); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.toggle.on .knob { left: 29px; }
.select, .range { font-size: 16px; padding: 8px; border-radius: 12px; border: 1px solid #ddd; }

/* In-app privacy policy view */
.policy { text-align: left; line-height: 1.55; }
.policy h1 { font-size: 22px; color: var(--amber-dark); margin: 0 0 8px; }
.policy h2 { font-size: 18px; margin: 18px 0 6px; }
.policy p { font-size: 15px; margin: 6px 0; }
.policy .note { background: var(--bg); border-left: 4px solid var(--amber); padding: 10px 14px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  .choice.wrong, .choice.right, .cheer.show { animation: none; }
}
