:root {
  --bg: #fff8ec;
  --surface: #ffffff;
  --ink: #2b2140;
  --muted: #6b6280;
  --primary: #ff7a3d;   /* mango orange */
  --primary-dark: #e45f22;
  --green: #2fb36b;     /* banana leaf */
  --blue: #3c8dff;
  --purple: #8a5cf6;
  --pink: #ff5c8a;
  --yellow: #ffc83d;
  --line: #f0e3cc;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(43, 33, 64, .08), 0 12px 24px rgba(43, 33, 64, .08);
  --font: "Baloo Chettan 2", "Noto Sans Malayalam", "Noto Color Emoji", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1150px; margin: 0 auto; padding: 24px 16px 48px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
p { margin: 0 0 1em; }
a { color: var(--blue); }
.ml { font-family: "Baloo Chettan 2", "Noto Sans Malayalam", "Noto Color Emoji", sans-serif; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 3px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mascot { font-size: 34px; }
.brand b { display: block; font-size: 1.3rem; color: var(--primary); line-height: 1; }
.brand small { color: var(--muted); font-size: .8rem; }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  text-decoration: none; color: var(--ink); font-weight: 600;
}
.site-nav a:hover { background: #fff1dd; }
.site-nav a.active { background: var(--primary); color: #fff; }
.star-pill {
  background: var(--yellow); padding: 6px 14px; border-radius: 999px;
  font-weight: 700; white-space: nowrap;
}
.nav-toggle { display: none; margin-left: auto; font-size: 26px; background: none; border: 0; cursor: pointer; color: var(--ink); }

@media (max-width: 860px) {
  .site-header { flex-wrap: wrap; padding: 10px 16px; }
  .nav-toggle { display: block; }
  .star-pill { order: 2; }
  .site-nav { display: none; order: 3; width: 100%; flex-direction: column; }
  .nav-open .site-nav { display: flex; }
}

.site-footer { text-align: center; padding: 24px 16px; color: var(--muted); border-top: 3px solid var(--line); background: var(--surface); }
.site-footer p { margin: 0; }
.site-footer .credit { font-size: .8rem; margin-top: 8px; }
/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 1.05rem;
  padding: 12px 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--primary); color: #fff; text-decoration: none;
  box-shadow: 0 4px 0 var(--primary-dark);
  transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn.green { background: var(--green); box-shadow: 0 4px 0 #20864f; }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 #2468c9; }
.btn.purple { background: var(--purple); box-shadow: 0 4px 0 #6a3fd1; }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: 0 4px 0 var(--line); border: 2px solid var(--line); }
.btn.small { padding: 8px 14px; font-size: .95rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center;
  padding: 32px; border-radius: 32px;
  background: linear-gradient(135deg, #ffe2c2 0%, #ffd6e4 50%, #d9e9ff 100%);
  margin-bottom: 40px;
}
.hero h1 span { color: var(--primary); }
.hero p { font-size: 1.15rem; }
.hero-art {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.hero-art div {
  aspect-ratio: 1; display: grid; place-items: center;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 700;
  animation: bob 3s ease-in-out infinite;
}
.hero-art div:nth-child(2n) { animation-delay: .5s; color: var(--primary); }
.hero-art div:nth-child(3n) { animation-delay: 1s; color: var(--purple); }
.hero-art div:nth-child(5n) { color: var(--green); }
@keyframes bob { 50% { transform: translateY(-8px); } }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding: 24px 18px; }
}

/* ---------- cards ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  background: var(--surface); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); border: 2px solid var(--line);
}
.feature { text-decoration: none; color: var(--ink); transition: transform .15s; display: block; }
.feature:hover { transform: translateY(-4px) rotate(-.5deg); }
.feature .icon { font-size: 44px; display: block; margin-bottom: 6px; }
.feature h3 { color: var(--primary); }
.feature:nth-child(2) h3 { color: var(--green); }
.feature:nth-child(3) h3 { color: var(--blue); }
.feature:nth-child(4) h3 { color: var(--purple); }
.feature:nth-child(5) h3 { color: var(--pink); }

.section { margin: 48px 0; }
.levels .card { border-top: 8px solid var(--primary); }
.levels .card:nth-child(2) { border-top-color: var(--green); }
.levels .card:nth-child(3) { border-top-color: var(--purple); }
.levels ul { padding-left: 1.1em; margin: 0; }
.tag { display: inline-block; background: #fff1dd; border-radius: 999px; padding: 2px 12px; font-weight: 700; font-size: .9rem; margin-bottom: 8px; }

.progress-strip { display: flex; flex-wrap: wrap; gap: 16px; }
.progress-strip .card { flex: 1 1 160px; text-align: center; }
.progress-strip b { display: block; font-size: 2.2rem; color: var(--primary); }

.parents { background: #eaf6ef; border-color: #cbe9d7; }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.tab {
  font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- letter grid ---------- */
.letter-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.letter-tile {
  position: relative; font: inherit; cursor: pointer;
  aspect-ratio: 1; border-radius: 20px; border: 2px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .12s;
}
.letter-tile:hover { transform: scale(1.06); }
.letter-tile .big { font-size: 2.6rem; font-weight: 700; line-height: 1.1; }
.letter-tile .tr { font-size: .9rem; color: var(--muted); }
.letter-tile.done::after { content: "⭐"; position: absolute; top: 4px; right: 6px; font-size: 14px; }
.letter-tile:nth-child(4n+1) .big { color: var(--primary); }
.letter-tile:nth-child(4n+2) .big { color: var(--green); }
.letter-tile:nth-child(4n+3) .big { color: var(--blue); }
.letter-tile:nth-child(4n+4) .big { color: var(--purple); }

/* ---------- modal flashcard ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(43, 33, 64, .55); place-items: center; padding: 16px;
}
.modal.open { display: grid; }
.flash {
  width: min(440px, 100%); background: var(--surface); border-radius: 32px;
  padding: 28px 24px; text-align: center; position: relative;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.flash .close { position: absolute; top: 10px; right: 14px; font-size: 28px; background: none; border: 0; cursor: pointer; color: var(--muted); }
.flash .huge { font-size: 7rem; line-height: 1.1; font-weight: 700; color: var(--primary); }
.flash .tr { font-size: 1.4rem; color: var(--muted); margin-bottom: 12px; }
.flash .example { background: #fff4e3; border-radius: 20px; padding: 14px; margin: 12px 0 18px; }
.flash .example .emoji { font-size: 3rem; }
.flash .example .word { font-size: 2rem; font-weight: 700; }
.flash .btn-row { justify-content: center; }
.word-say { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 4px 12px; border-radius: 16px; }
.word-say:hover { background: #ffe9cf; }
.word-say .say-icon { font-size: 1.1rem; vertical-align: middle; }
.sign-sum { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.sign-sum > b { color: var(--muted); font-size: 1.3rem; }
.sign-part { display: flex; flex-direction: column; align-items: center; background: var(--surface); border-radius: 14px; padding: 4px 10px; min-width: 52px; }
.sign-part span { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.sign-part small { color: var(--muted); font-size: .8rem; }
.sign-part.result span { color: var(--primary); }

/* ---------- writing ---------- */
.write-layout { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .write-layout { grid-template-columns: 1fr; } }
.canvas-wrap {
  position: relative; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow);
  border: 2px solid var(--line); overflow: hidden; touch-action: none;
  background-image: linear-gradient(#f3e8d6 2px, transparent 2px);
  background-size: 100% 25%;
}
.canvas-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.write-side .card { margin-bottom: 16px; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 3px var(--ink); }
.picker { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow-y: auto; }
.picker button {
  font: inherit; font-size: 1.4rem; width: 48px; height: 48px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer;
}
.picker button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.picker button.done { border-color: var(--green); }
.meter { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.meter > div { height: 100%; background: var(--green); width: 0; transition: width .4s; }

/* ---------- words ---------- */
.word-card { text-align: center; cursor: pointer; perspective: 800px; background: none; border: 0; padding: 0; font: inherit; color: inherit; }
.word-inner {
  position: relative; height: 200px; transition: transform .5s; transform-style: preserve-3d;
}
.word-card.flipped .word-inner { transform: rotateY(180deg); }
.word-face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); border: 2px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px;
}
.word-face .emoji { font-size: 4rem; line-height: 1.1; }
.word-face .word { font-size: 2rem; font-weight: 700; color: var(--primary); }
.word-back { transform: rotateY(180deg); background: #f1ecff; }
.word-back .word { color: var(--purple); }

/* ---------- reading ---------- */
.sentence {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border-radius: 20px; padding: 16px 20px; margin-bottom: 12px;
  border: 2px solid var(--line); box-shadow: var(--shadow);
}
.sentence .ml-text { font-size: 1.7rem; font-weight: 700; flex: 1 1 260px; }
.sentence .ml-text span { cursor: pointer; border-radius: 8px; padding: 0 2px; }
.sentence .ml-text span:hover { background: #ffe9cf; }
.sentence .hint { flex-basis: 100%; color: var(--muted); display: none; }
.show-hints .sentence .hint { display: block; }
.story-head { display: flex; align-items: center; gap: 14px; margin: 32px 0 14px; }
.story-head .emoji { font-size: 3rem; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--primary); }

/* ---------- games ---------- */
.game-pick .card { cursor: pointer; text-align: center; transition: transform .15s; font: inherit; color: inherit; }
.game-pick .card:hover { transform: translateY(-4px); }
.game-pick .icon { font-size: 52px; }
.quiz { max-width: 640px; margin: 0 auto; text-align: center; }
.quiz .q-top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 12px; }
.quiz .prompt { font-size: 1.4rem; margin-bottom: 8px; }
.quiz .prompt-big { font-size: 5rem; line-height: 1.15; font-weight: 700; color: var(--primary); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.choice {
  font: inherit; font-size: 2.2rem; font-weight: 700; padding: 18px 8px; border-radius: 20px; cursor: pointer;
  background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow); color: var(--ink);
}
.choice small { display: block; font-size: 1rem; color: var(--muted); font-weight: 600; }
.choice.right { background: #dff6e8; border-color: var(--green); animation: pop .3s; }
.choice.wrong { background: #ffe1e8; border-color: var(--pink); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- toast / confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 16px; z-index: 60;
  max-width: calc(100% - 32px); text-align: center; transition: transform .3s;
}
.toast.show { transform: translate(-50%, 0); }
.confetti { position: fixed; top: -40px; z-index: 70; pointer-events: none; animation: fall 2.4s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
