:root {
  --maroon: #6E191E;
  --maroon-2: #8E2A2F;
  --gold: #C98B1E;
  --gold-2: #A86B12;
  --gold-soft: #FFF1D2;
  --mint: #1F7A5C;
  --mint-soft: #E1F3EA;
  --rose-soft: #F8E4E1;
  --cream: #FAF2E6;
  --paper: #FFFDF9;
  --ink: #2B1A17;
  --muted: #6F5E57;
  --line: #EADBC6;
  --shadow: 0 6px 20px rgba(110, 25, 30, .08), 0 1px 3px rgba(110, 25, 30, .06);
  --r: 22px;
  /* Baloo 2 has no Tamil glyphs, so Tamil text uses Noto Sans Tamil: standard textbook letter shapes. */
  --font: "Baloo 2", "Noto Sans Tamil", "Nirmala UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream) radial-gradient(circle at 85% -10%, #fff6e3 0, transparent 45%) no-repeat;
  min-height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
}
input, select, textarea { -webkit-user-select: text; user-select: text; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); color: var(--maroon); }
h1 small, h2 small { display: block; font-size: .5em; font-weight: 500; color: var(--muted); margin-top: .2em; }
h2 { font-size: 1.3rem; color: var(--maroon); }
h3 { font-size: 1rem; color: var(--gold-2); margin-top: 1rem; }

.screen { max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; }
.screen.center { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 90dvh; }
.card { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 20px; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 18px; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 10px; }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 22px; border-radius: 999px; border: 2px solid transparent;
  font-weight: 700; font-size: 1.1rem; transition: transform .08s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--maroon); color: #fff; box-shadow: 0 4px 0 #4a0f13; }
.btn.primary:active { box-shadow: 0 1px 0 #4a0f13; transform: translateY(3px); }
.btn.ghost { background: var(--paper); border-color: var(--line); color: var(--maroon); }
.btn.danger-ghost { background: transparent; border-color: #E8C3BF; color: #A3302A; min-height: 46px; font-size: 1rem; }
.btn.big { min-height: 68px; font-size: 1.3rem; padding: 0 34px; }
.btn.small { min-height: 40px; font-size: .95rem; padding: 0 14px; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.link { background: none; border: 0; color: var(--maroon); text-decoration: underline; padding: 0; }
.actions { display: flex; gap: 12px; margin-top: 16px; align-items: center; }
.actions.center { justify-content: center; }
.actions.wrap { flex-wrap: wrap; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line); font-size: 1.3rem; box-shadow: var(--shadow); flex: none;
}
.icon-btn.corner { position: absolute; top: 16px; left: 16px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  background: linear-gradient(var(--cream) 70%, transparent);
}
.who { display: flex; align-items: center; gap: 10px; background: none; border: 0; font-weight: 700; font-size: 1.15rem; color: var(--maroon); padding: 0; }
.who[disabled] { cursor: default; opacity: 1; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--gold-soft); display: inline-grid; place-items: center; font-size: 1.6rem; border: 2px solid #F1D49B; }
.avatar.xl { width: 96px; height: 96px; font-size: 3.4rem; }
.pill { background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; white-space: nowrap; }

/* ---------- setup ---------- */
.setup { max-width: 640px; text-align: center; }
.setup .logo { width: 170px; height: auto; margin: 8px auto 4px; display: block; }
.form { text-align: left; display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; color: var(--maroon); }
.form input[type=text], .form input:not([type]), .form input[type=password] {
  min-height: 52px; border: 2px solid var(--line); border-radius: 14px; padding: 0 14px; background: #fff; font-size: 1.1rem;
}
.form input:focus { outline: none; border-color: var(--gold); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; color: var(--maroon); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: grid; place-items: center; min-width: 64px; min-height: 52px; padding: 0 16px;
  border-radius: 16px; border: 2px solid var(--line); background: #fff; font-weight: 700; color: var(--ink);
}
.avatars .chip span { font-size: 1.8rem; min-width: 60px; }
.chip input:checked + span { border-color: var(--maroon); background: var(--rose-soft); box-shadow: 0 0 0 3px rgba(110, 25, 30, .12); }
.chip input:focus-visible + span { outline: 3px solid var(--gold); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; grid-template-columns: none; gap: 10px; align-items: flex-start; font-weight: 400 !important; color: var(--ink) !important; font-size: .95rem; }
.check input { width: 22px; height: 22px; margin-top: 3px; flex: none; accent-color: var(--maroon); }
.error { color: #A3302A; font-weight: 600; margin: 0; }

/* ---------- profiles ---------- */
.profile-grid { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-top: 12px; }
.profile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 26px; display: grid; gap: 10px; justify-items: center; font-size: 1.2rem; color: var(--maroon); }

/* ---------- home ---------- */
.home { display: grid; gap: 18px; }
.hero { display: flex; align-items: center; gap: 24px; padding: 28px; background: linear-gradient(135deg, #FFF8EA, #FFF1D6); }
.mascot { font-size: clamp(4.5rem, 12vw, 8rem); background: none; border: 0; line-height: 1; padding: 0; filter: drop-shadow(0 6px 8px rgba(110, 25, 30, .15)); }
.mascot.bounce { animation: bounce .6s; }
@keyframes bounce { 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
.hero-text { flex: 1; display: grid; gap: 14px; }
.bubble { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; color: var(--maroon); }
.btn.today {
  flex-direction: column; gap: 0; min-height: 120px; border-radius: 28px; padding: 12px 28px;
  background: var(--maroon); color: #fff; box-shadow: 0 6px 0 #4a0f13; align-items: flex-start; text-align: left;
}
.btn.today:active { transform: translateY(4px); box-shadow: 0 2px 0 #4a0f13; }
.today-ta { font-size: clamp(2rem, 4.5vw, 2.8rem); line-height: 1.1; }
.today-en { font-size: 1rem; font-weight: 500; opacity: .8; }
.btn.today small { margin-top: 6px; font-size: 1.05rem; color: #FFE2A6; font-weight: 600; }
.btn.today.rest { background: var(--mint); box-shadow: 0 6px 0 #0f5039; cursor: default; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tile { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center; }
.tile b { display: block; font-size: 1.35rem; color: var(--maroon); }
.tile small { display: block; color: var(--muted); font-weight: 500; }
.tile-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--maroon); color: #F4C870; display: grid; place-items: center; font-size: 2.4rem; font-weight: 700; grid-row: span 2; }
.meter { grid-column: 2; height: 10px; border-radius: 99px; background: #F0E3CF; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--mint); border-radius: 99px; }
.stickers { grid-template-columns: 1fr; }
.sticker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sticker { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: #F3EADC; color: #C9B8A3; font-weight: 700; border: 2px dashed #DCC9AE; }
.sticker.got { background: var(--gold-soft); border: 2px solid #F1D49B; color: inherit; }
.sticker.big { width: 120px; height: 120px; font-size: 4rem; margin: 0 auto 10px; }

/* ---------- path ---------- */
.trail { list-style: none; padding: 10px 0 0; margin: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.node { display: grid; justify-items: center; gap: 20px; transform: translateY(calc(sin(var(--i) * 1.4rad) * 26px)); padding: 30px 0; }
.node-btn {
  position: relative; width: clamp(84px, 13vw, 120px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; background: var(--paper); border: 3px solid var(--line); box-shadow: var(--shadow);
}
.node.done .node-btn { background: var(--mint-soft); border-color: var(--mint); }
.node.current .node-btn { background: var(--maroon); border-color: var(--gold); color: #fff; box-shadow: 0 0 0 8px rgba(201, 139, 30, .25), var(--shadow); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(201, 139, 30, .12), var(--shadow); } }
.node.locked .node-btn { background: #F3EADC; opacity: .75; }
.node-chars { font-size: clamp(1.4rem, 3.4vw, 2.1rem); font-weight: 700; color: inherit; }
.node.done .node-chars { color: var(--mint); }
.node-chars.small { font-size: 1.6rem; }
.node-badge { position: absolute; right: -6px; top: -6px; font-size: 1.6rem; background: #fff; border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; box-shadow: var(--shadow); }
.node-now { position: absolute; bottom: -14px; background: var(--gold); color: #fff; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; }
.node-label { font-weight: 600; color: var(--muted); }
.next-level { display: flex; align-items: center; gap: 16px; margin-top: 18px; opacity: .8; }
.next-level b { display: block; color: var(--maroon); }
.next-level small { color: var(--muted); }

/* ---------- letter card + trace ---------- */
.learn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
.letter-card { display: grid; justify-items: center; align-content: center; gap: 6px; text-align: center; }
.big-letter {
  font-size: clamp(7rem, 22vw, 12rem); line-height: 1.15; font-weight: 700; color: var(--maroon);
  background: radial-gradient(circle, #FFF6E2 0, transparent 70%); border: 0; padding: 0 30px; border-radius: 30px;
}
.big-letter:active { transform: scale(.96); }
.translit { margin: -6px 0 6px; font-size: 1.3rem; color: var(--gold-2); font-weight: 700; }
.word { display: grid; justify-items: center; gap: 2px; background: var(--gold-soft); border: 2px solid #F1D49B; border-radius: 20px; padding: 12px 26px; min-width: 220px; }
.pic { font-size: 3.4rem; line-height: 1.2; }
.pic.xl { font-size: 6rem; }
.word-ta { font-size: 2rem; font-weight: 700; color: var(--ink); }
.word-ta mark { background: none; color: var(--maroon); text-decoration: underline 4px var(--gold); text-underline-offset: 6px; }
.word small { color: var(--muted); font-size: 1rem; }
.trace-wrap, .trace-solo { display: grid; justify-items: center; gap: 8px; }
.trace-host { width: min(100%, 440px); aspect-ratio: 1; }
.trace-solo { width: min(100%, 560px); }
.trace-solo .trace-host { width: min(100%, 56dvh); }
.trace-canvas {
  display: block; touch-action: none; border-radius: 24px; cursor: crosshair;
  background: #fff repeating-linear-gradient(0deg, transparent 0 39px, #F5ECDD 39px 40px);
  border: 2px solid var(--line);
}
.prompt { text-align: center; font-size: clamp(1.25rem, 2.6vw, 1.6rem); font-weight: 700; color: var(--maroon); margin: 4px 0 14px; }
.prompt small { display: block; font-size: .95rem; font-weight: 500; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 16px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--line); margin: 0 4px; }
.dot.on { background: var(--maroon); }

/* ---------- session ---------- */
.session-bar .progress { flex: 1; height: 16px; background: #F0E3CF; border-radius: 99px; overflow: hidden; }
.session-bar .progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #E6B04A); border-radius: 99px; transition: width .4s; }
.session { display: grid; justify-items: center; gap: 18px; }
.session .letter-card { width: min(100%, 560px); }
.cue { display: grid; justify-items: center; gap: 4px; min-width: 240px; padding: 18px 40px; cursor: pointer; }
.cue.speaker { font-size: 4.5rem; width: 180px; height: 180px; min-width: 0; border-radius: 50%; place-content: center; background: var(--gold-soft); border-color: #F1D49B; }
.silent-hint { font-size: 1.4rem; color: var(--gold-2); font-weight: 700; }
.choices { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 16px; width: min(100%, 760px); }
.choices.n3 { --n: 3; }
.choice {
  aspect-ratio: 1; max-height: 170px; width: 100%; border-radius: 26px; border: 3px solid var(--line); background: var(--paper);
  font-size: clamp(3.2rem, 9vw, 5.5rem); font-weight: 700; color: var(--maroon); box-shadow: 0 5px 0 #E3D2B9; justify-self: center;
}
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 #E3D2B9; }
.choice.right { background: var(--mint-soft); border-color: var(--mint); color: var(--mint); box-shadow: 0 5px 0 #9ACFB5; animation: pop .4s; }
.choice.wrong { background: var(--rose-soft); border-color: #D9928B; color: #A3302A; animation: shake .4s; }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.reward { position: relative; overflow: hidden; text-align: center; padding: 40px 30px; width: min(100%, 520px); display: grid; justify-items: center; gap: 8px; }
.reward-stats { display: flex; gap: 14px; font-size: 1.4rem; font-weight: 700; margin: 6px 0 16px; }
.reward-stats span { background: var(--gold-soft); border-radius: 99px; padding: 6px 18px; }
.confetti i { position: absolute; top: -20px; left: calc(var(--i) * 7.2%); color: hsl(calc(var(--i) * 40), 75%, 55%); font-style: normal; font-size: 1.4rem; animation: fall 2.2s calc(var(--i) * .09s) ease-in forwards; }
@keyframes fall { to { transform: translateY(560px) rotate(540deg); opacity: 0; } }

/* ---------- parent ---------- */
.pin-screen { position: relative; }
.pin-dots { display: flex; gap: 16px; margin: 6px 0 22px; }
.pin-dots i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--maroon); }
.pin-dots i.on { background: var(--maroon); }
.pin-dots.shake { animation: shake .4s; }
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.pinpad button { height: 76px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); font-size: 1.7rem; font-weight: 700; box-shadow: var(--shadow); }
.parent { display: grid; gap: 18px; }
.parent h2 { display: flex; align-items: center; gap: 10px; }
.parent h2 small { display: inline; margin: 0 0 0 6px; font-size: .7em; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.parent select { min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; padding: 0 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 10px; }
.stats div { background: var(--cream); border-radius: 16px; padding: 12px 14px; }
.stats b { display: block; font-size: 1.5rem; color: var(--maroon); }
.stats small { color: var(--muted); }
.letter-strength { display: flex; flex-wrap: wrap; gap: 8px; }
.ls { width: 48px; height: 48px; border-radius: 12px; display: inline-grid; place-items: center; font-size: 1.5rem; font-weight: 700; border: 2px solid transparent; }
.ls.strong { background: var(--mint); color: #fff; }
.ls.ok { background: var(--mint-soft); color: var(--mint); border-color: #9ACFB5; }
.ls.weak { background: var(--rose-soft); color: #A3302A; border-color: #E8C3BF; }
.ls.new { background: #F3EADC; color: #BFAE97; }
.legend { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.legend .ls { width: 28px; height: 28px; font-size: .9rem; border-radius: 8px; }
.note { background: var(--gold-soft); border-radius: 14px; padding: 10px 14px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.setting input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--maroon); }
.muted { background: #FBF6EE; }
.plain { padding-left: 18px; line-height: 1.6; }

/* ---------- guidance ---------- */
[data-fit] { display: inline-block; white-space: nowrap; line-height: 1.15; }
.choice { overflow: hidden; display: grid; place-items: center; padding: 6px; }
.big-letter { max-width: 100%; }
.hear {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px; margin: -4px 0 4px;
  border-radius: 99px; border: 2px solid #F1D49B; background: var(--gold-soft); color: var(--maroon);
  font-size: 1.15rem; font-weight: 700; line-height: 1;
}
.hear small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.hear:active { transform: scale(.96); }
.guide {
  display: flex; align-items: center; gap: 14px; width: min(100%, 760px); text-align: left;
  background: var(--paper); border: 2px solid #F1D49B; border-radius: 24px; padding: 10px 16px 10px 10px; box-shadow: var(--shadow);
}
.guide-bird { font-size: 2.8rem; line-height: 1; flex: none; }
.guide.talk .guide-bird { animation: bounce .6s; }
.guide-text { flex: 1; display: grid; }
.guide-text b { font-size: clamp(1.15rem, 2.4vw, 1.45rem); color: var(--maroon); line-height: 1.3; }
.guide-text small { color: var(--muted); font-size: .95rem; font-weight: 500; }
.guide-replay { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); font-size: 1.3rem; }
.trace-wrap .guide { margin-bottom: 4px; }
.cue small { color: var(--muted); font-size: 1rem; }
.blank {
  display: inline-block; min-width: 1.3em; margin-right: 2px; text-align: center; color: var(--gold-2);
  border-bottom: 4px dashed var(--gold); animation: blink 1.4s infinite;
}
@keyframes blink { 50% { opacity: .35; } }
.choices.nudge .choice { animation: wiggle 1s ease-in-out 2; }
.choices.nudge .choice:nth-child(2) { animation-delay: .1s; }
.choices.nudge .choice:nth-child(3) { animation-delay: .2s; }
.choices.nudge .choice:nth-child(4) { animation-delay: .3s; }
@keyframes wiggle { 25% { transform: rotate(-4deg) scale(1.04); } 75% { transform: rotate(4deg) scale(1.04); } }
.trace-host { position: relative; }
.trace-hand {
  position: absolute; left: 30%; top: 30%; font-size: 3rem; pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .2)); animation: handmove 2.4s ease-in-out infinite;
}
@keyframes handmove {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 1; }
  50% { transform: translate(60px, 40px); }
  85% { opacity: 1; }
  100% { transform: translate(110px, 10px); opacity: 0; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 99px; font-weight: 700; font-size: 1.15rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); text-align: center;
}

/* ---------- small screens / portrait ---------- */
@media (max-width: 760px) {
  .hero { flex-direction: column; text-align: center; padding: 22px 16px; }
  .btn.today { align-items: center; text-align: center; }
  .tiles, .learn-grid { grid-template-columns: 1fr; }
  .trail { grid-template-columns: repeat(3, 1fr); row-gap: 0; }
  .node { transform: none; padding: 14px 0; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row2 { grid-template-columns: 1fr; }
  .pill { padding: 4px 10px; }
  .guide { gap: 8px; padding: 8px 10px 8px 6px; }
  .guide-bird { font-size: 2rem; }
  .guide-replay { width: 40px; height: 40px; }
  .who span:last-child { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
