/* Speak Tamil: a bright, friendly light theme. Chunky "pressable" buttons, rounded type, lots of colour. */
:root {
  color-scheme: light;
  --bg: #fffdf8; --card: #ffffff; --ink: #2b2440; --muted: #7a7391; --line: #e9e4f2;
  /* mango is the main colour (buttons, your bubbles, rewards), with dark text on it for contrast.
     grape is the second colour, for small highlights. mint and rose are right and wrong. */
  --accent: #ffc531; --accent-dark: #e2a400; --accent-ink: #2b2440; --accent-text: #8f5b00; --soft: #fff4d1;
  --second: #6c4df6; --second-soft: #efeaff;
  --mango: #ffc531; --mango-dark: #e2a400; --mango-soft: #fff4d1;
  --sky: #29b6f6; --sky-soft: #dff4ff; --coral: #ff7a59; --coral-soft: #ffe8e1;
  --good: #14915c; --good-fill: #2fcb8a; --good-dark: #1fa36b; --good-bg: #ddf8ec;
  --bad: #d92d54; --bad-fill: #ff4f6d; --bad-bg: #ffe6eb;
  --round: "Nunito", "Baloo Thambi 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tamil: "Baloo Thambi 2", "Noto Sans Tamil", "Tamil Sangam MN", "Nunito", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(180deg, #ffeeb8 0, #fff8e6 170px, var(--bg) 340px) no-repeat var(--bg);
  color: var(--ink);
  font: 600 16px/1.45 var(--round);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: 0 16px env(safe-area-inset-bottom); }
#app:has(> .tabs) { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1 { font-size: 28px; font-weight: 900; margin: 20px 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 26px 0 10px; }
.sub { color: var(--muted); margin: 0 0 8px; }
.ta { font-family: var(--tamil); font-size: 20px; font-weight: 600; line-height: 1.5; }
[lang="ta"] { font-family: var(--tamil); }
.rom { color: var(--muted); font-size: 14px; font-style: italic; font-weight: 600; }
.en { color: var(--muted); font-size: 14px; }
.grow { flex: 1; min-width: 0; }

/* ---------- cards and lists ---------- */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px; }
button.card { border-bottom-width: 5px; transition: transform 0.06s; }
button.card:not(:disabled):active { transform: translateY(2px); border-bottom-width: 3px; margin-bottom: 2px; }
.list { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.row .emoji { font-size: 24px; width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 15px; background: var(--soft); }
.row .title { font-weight: 800; }
.row .meta { color: var(--muted); font-size: 13px; }
/* each stop on the trip gets its own colour */
.list > .card:nth-child(6n + 1) .emoji { background: var(--mango-soft); }
.list > .card:nth-child(6n + 2) .emoji { background: var(--good-bg); }
.list > .card:nth-child(6n + 3) .emoji { background: var(--sky-soft); }
.list > .card:nth-child(6n + 4) .emoji { background: var(--coral-soft); }
.list > .card:nth-child(6n + 5) .emoji { background: var(--soft); }
.list > .card:nth-child(6n + 6) .emoji { background: var(--bad-bg); }
.card.locked { opacity: 0.55; cursor: default; background: #faf8fd; }
.card.locked .emoji { background: var(--line) !important; filter: grayscale(1); }
.pill { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: var(--accent-text); white-space: nowrap; }
.bar { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--second); background-image: linear-gradient(180deg, #ffffff55 0 35%, #fff0 35%); transition: width 0.4s ease; }
.bar > i.gold { background-color: var(--mango); }
.pips { display: flex; gap: 5px; flex: none; }
.pips i { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.pips i.on { background: var(--mango); box-shadow: inset 0 -2px 0 var(--mango-dark); }

/* ---------- buttons ---------- */
.btn { background: var(--accent); color: var(--accent-ink); border-radius: 16px; padding: 12px 18px; font-weight: 800; letter-spacing: 0.02em; border-bottom: 4px solid var(--accent-dark); transition: transform 0.06s; }
.btn:not(:disabled):active { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; }
.btn:disabled { background: var(--line); color: #b3adc6; border-bottom-color: #d6d0e3; cursor: default; }
.btn.ghost { background: var(--card); color: var(--accent-text); border: 2px solid var(--line); border-bottom-width: 4px; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon { font-size: 15px; padding: 5px 9px; border-radius: 11px; background: var(--sky-soft); border-bottom: 3px solid #bfe6fb; }
.icon:active, .hear:active, .tile:active { transform: translateY(2px); }

.cta { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin-top: 12px; padding: 16px; border-radius: 22px; background: var(--accent); color: var(--accent-ink); border-bottom: 6px solid var(--accent-dark); background-image: radial-gradient(circle at 92% 0%, #ffffff55 0 70px, #fff0 71px); transition: transform 0.06s; }
.cta:active { transform: translateY(3px); border-bottom-width: 3px; margin-bottom: 3px; }
.cta .emoji { font-size: 30px; width: 58px; height: 58px; flex: none; display: grid; place-items: center; border-radius: 18px; background: #ffffff8c; }
.cta .title { font-weight: 900; font-size: 18px; }
.cta .meta { font-size: 13px; opacity: 0.9; }
.cta .go { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #fff; color: var(--ink); font-size: 16px; box-shadow: 0 3px 0 var(--accent-dark); }

/* ---------- home: streak, goal, week, level ---------- */
.hero { display: flex; align-items: flex-start; gap: 12px; }
.hero h1 { color: var(--ink); }
.hero h1::first-letter { color: var(--accent-dark); }
.streak { margin-top: 20px; padding: 6px 12px; border-radius: 99px; background: var(--card); border: 2px solid var(--line); font-weight: 900; filter: grayscale(1); opacity: 0.6; white-space: nowrap; }
.streak.lit { filter: none; opacity: 1; background: var(--mango-soft); border-color: var(--mango); color: #a86b00; }
.streak b { margin-left: 4px; }
.level .badge { width: 40px; height: 40px; border-radius: 50%; background: var(--mango); color: var(--ink); display: grid; place-items: center; font-weight: 900; font-size: 18px; flex: none; box-shadow: 0 3px 0 var(--mango-dark); }
.goal { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; font-weight: 800; color: var(--ink); }
.goal .bar { margin-top: 0; }
.week { display: flex; gap: 6px; margin-top: 12px; }
.week .day { flex: 1; text-align: center; font-size: 12px; font-weight: 800; padding: 6px 0; border-radius: 12px; background: #f4f1fa; color: #b3adc6; }
.week .day.on { background: var(--soft); color: var(--accent-text); }
.week .day.gold { background: var(--mango); color: var(--ink); box-shadow: inset 0 -3px 0 var(--mango-dark); }
.week .day.today { outline: 2px solid var(--second); outline-offset: 1px; }

/* ---------- settings ---------- */
.seg { display: inline-flex; background: #f4f1fa; border-radius: 12px; padding: 3px; }
.seg button { padding: 5px 10px; border-radius: 10px; font-size: 13px; font-weight: 800; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--accent-text); box-shadow: 0 2px 0 var(--line); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 2px solid var(--line); }
.setting:first-child { border-top: 0; }
details summary { cursor: pointer; font-weight: 800; }
.note { font-size: 13px; color: var(--muted); margin: 12px 0 28px; }

/* ---------- lesson: top bar, avatar, hearts ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0 10px; position: sticky; top: 0; background: #fff3cc; margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-bottom: 2px solid var(--line); z-index: 2; }
.top .back { font-size: 20px; font-weight: 900; color: var(--accent-text); padding: 4px 8px 4px 0; }
.top .title { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.en.one { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toprow { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.avatar { width: 84px; height: 84px; flex: none; border-radius: 50%; overflow: hidden; background: var(--mango-soft); border: 4px solid #fff; box-shadow: 0 0 0 2px var(--line), 0 4px 0 2px var(--line); display: grid; place-items: center; font-size: 34px; }
.avatar canvas { display: block; width: 100% !important; height: 100% !important; }
.avatar.big { width: 140px; height: 140px; margin: 0 auto 10px; font-size: 60px; }
.hearts { white-space: nowrap; font-size: 15px; letter-spacing: 1px; }
.hearts span { display: inline-block; }
.hearts .gone { opacity: 0.35; filter: grayscale(1); }
.hearts .break { animation: heartbreak 0.5s ease; }
.combo { font-weight: 900; color: var(--coral); display: inline-block; }
.combo.pop, .tile.pop { animation: pop 0.25s ease; }
.chip { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--second-soft); color: var(--second); white-space: nowrap; vertical-align: middle; }
.fb.bad .chip { background: #fff; color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

/* ---------- lesson: chat ---------- */
.log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 14px 0; }
.bubble { position: relative; max-width: 86%; padding: 11px 14px; border-radius: 20px; animation: rise 0.25s ease both; }
.bubble.them { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-bottom-left-radius: 6px; align-self: flex-start; }
.bubble.me { background: var(--accent); color: var(--accent-ink); border-bottom: 4px solid var(--accent-dark); border-bottom-right-radius: 6px; align-self: flex-end; }
.bubble.me .rom, .bubble.me .en { color: inherit; opacity: 0.85; }
.bubble .tools { display: flex; gap: 6px; margin-top: 6px; }
.react { position: absolute; bottom: -12px; right: 10px; background: var(--card); border: 2px solid var(--line); border-radius: 99px; padding: 0 6px; font-size: 14px; animation: pop 0.3s ease; }
.bubble.me .react { right: auto; left: 10px; }
.typing { display: flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-dark); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.hidden-text { filter: blur(7px); user-select: none; }

/* ---------- lesson: answering ---------- */
.task { position: sticky; bottom: 0; background: var(--bg); margin: 0 -16px; padding: 12px 16px 18px; border-top: 2px solid var(--line); max-height: 78vh; overflow-y: auto; }
.cue { font-weight: 800; font-size: 17px; margin-bottom: 10px; }
.cue small { display: block; font-weight: 600; color: var(--muted); font-size: 13px; }
.opts { display: grid; gap: 10px; }
.optrow { display: flex; gap: 8px; align-items: stretch; }
.optrow .opt { flex: 1; }
.opt { text-align: left; background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 16px; padding: 10px 14px; width: 100%; transition: transform 0.06s; }
.opt:active { transform: translateY(2px); border-bottom-width: 3px; margin-bottom: 2px; border-color: var(--accent-dark); background: var(--soft); }
.opt.right { border-color: var(--good-fill); background: var(--good-bg); }
.opt.wrong { border-color: var(--bad-fill); background: var(--bad-bg); }
.hear { flex: none; width: 50px; border-radius: 16px; background: var(--sky-soft); border-bottom: 5px solid #bfe6fb; font-size: 18px; }

.slots { min-height: 60px; border: 2px dashed #d3cbe6; border-radius: 16px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-content: flex-start; background: #faf8fd; }
.pool { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; min-height: 46px; }
.tile { background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 13px; padding: 6px 11px; font-family: var(--tamil); font-size: 18px; font-weight: 600; text-align: center; }
.tile .rom { display: block; font-size: 12px; font-family: var(--round); }
.tile.used { visibility: hidden; }
.tile.glue { border-color: #cfc3ff; background: var(--second-soft); color: var(--second); }
.slots .tile.glue { margin-left: -4px; }
.tile.shake { animation: shake 0.35s ease; border-color: var(--bad-fill); }

/* ---------- lesson: feedback ---------- */
.fb { border-radius: 18px; padding: 14px; margin-bottom: 12px; animation: rise 0.2s ease both; }
.fb.good { background: var(--good-bg); }
.fb.bad { background: var(--bad-bg); }
.fb.teach { background: var(--sky-soft); }
.fb .head { font-weight: 900; font-size: 18px; margin-bottom: 4px; }
.fb.good .head { color: var(--good); }
.fb.bad .head { color: var(--bad); }
.fb .why { margin-top: 8px; font-size: 14px; }
.fb.shake { animation: shake 0.35s ease; }
.label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-top: 8px; }
.label:first-child { margin-top: 0; }
.hl-bad { background: #fff; color: var(--bad); border-radius: 9px; }
.hl-bad b { text-decoration: line-through; }
.hl-good { background: var(--good-bg); color: var(--good); border-radius: 9px; }
.task.bad .hl-good { background: #fff; }
.gloss { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.gw { display: flex; flex-direction: column; background: var(--card); border: 2px solid #00000010; border-radius: 12px; padding: 4px 9px; }
.gw b { font-weight: 600; font-size: 16px; }
.gw i { font-size: 13px; color: var(--accent-text); font-weight: 700; }
.gw small { color: var(--muted); font-size: 11px; max-width: 130px; }
details.more { margin-top: 8px; font-size: 13px; }
details.more summary { color: var(--muted); font-weight: 700; }
.fix { margin-bottom: 10px; }
.fix .cue { margin-bottom: 6px; }
.fix .pool { margin-bottom: 0; }
.fixed { color: var(--good); font-weight: 800; padding: 6px 0; }

/* ---------- end screens and rewards ---------- */
.center { text-align: center; padding: 20px 0 28px; }
.big { font-size: 52px; }
.bigstars { font-size: 56px; letter-spacing: 6px; color: var(--line); }
.bigstars span { display: inline-block; }
.bigstars span.on { color: var(--mango); text-shadow: 0 4px 0 var(--mango-dark); animation: starin 0.45s ease both; }
.news { display: inline-block; font-weight: 800; color: var(--second); background: var(--second-soft); border-radius: 14px; padding: 8px 14px; margin: 10px 0 0; }
.xpfloat { position: fixed; left: 50%; bottom: 40%; transform: translateX(-50%); font-weight: 900; font-size: 24px; color: var(--mango-dark); text-shadow: 0 2px 0 #fff; pointer-events: none; z-index: 10; animation: floatup 1s ease forwards; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9; }
.confetti span { position: absolute; top: -40px; font-size: 22px; animation: fall linear forwards; }

@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes floatup { from { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } to { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes starin { from { transform: scale(0) rotate(-40deg); opacity: 0; } 70% { transform: scale(1.3); } to { transform: none; opacity: 1; } }
@keyframes heartbreak { 0% { transform: scale(1.6); opacity: 1; } 40% { transform: scale(0.7) rotate(-15deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- a scene's four levels, shown at the end of a lesson ---------- */
.track { display: flex; justify-content: center; gap: 4px; margin: 14px auto 4px; max-width: 360px; }
.track .stop { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: #b3adc6; position: relative; }
.track .stop i { font-style: normal; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--line); color: var(--muted); z-index: 1; }
.track .stop + .stop::before { content: ""; position: absolute; top: 15px; right: 50%; width: 100%; height: 4px; background: var(--line); }
.track .stop.done { color: var(--accent-text); }
.track .stop.done i { background: var(--accent); color: var(--ink); box-shadow: 0 3px 0 var(--accent-dark); }
.track .stop.done + .stop::before, .track .stop.done::before { background: var(--accent); }
.track .stop.next { color: var(--second); }
.track .stop.next i { background: #fff; color: var(--second); box-shadow: 0 0 0 3px var(--second); }
.center h1 { margin-top: 8px; }
.center .bubble { margin: 12px auto !important; }

/* ---------- lesson frame: progress bar, tinted answer sheet, one big Continue ---------- */
.lessonbar { flex-basis: 100%; margin-top: 2px; height: 10px; background: #ffffffb0; }
.lessonbar > i { background-color: var(--good-fill); }
.btn.wide { display: block; width: 100%; padding: 14px 18px; font-size: 17px; border-radius: 18px; }
.task .btns { margin-bottom: 10px; }
.task.good { background: var(--good-bg); border-top-color: #b6ecd2; }
.task.bad { background: var(--bad-bg); border-top-color: #ffc7d1; }
.task.good .fb, .task.bad .fb { background: none; padding: 0 0 2px; }
.task.good .btn.wide { background: var(--good-fill); border-bottom-color: var(--good-dark); color: #fff; }
.task.bad .btn.wide:not(:disabled) { background: var(--bad-fill); border-bottom-color: var(--bad); color: #fff; }
.task.bad .hl-bad { background: #fff; }
.task.bad .gw, .task.good .gw { border-color: #0000001a; }

/* ---------- bottom tabs and the You page ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 2px solid var(--line); }
.tabs button { flex: 1; max-width: 170px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 14px; font-size: 12px; font-weight: 800; color: var(--muted); }
.tabs .ico { position: relative; font-size: 22px; line-height: 1; filter: grayscale(1); opacity: 0.6; }
.tabs button.on { background: var(--soft); color: var(--accent-text); }
.tabs button.on .ico { filter: none; opacity: 1; }
.tabs button { position: relative; }
.tabs button > b { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; padding: 1px 4px; border-radius: 99px; background: var(--bad-fill); color: #fff; font: 800 11px/16px var(--round); filter: none; }
.goal + .btn, .cta + .goal { margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 16px; padding: 10px 6px; }
.stat span { font-size: 22px; }
.stat b { font-size: 20px; font-weight: 900; }
.stat small { color: var(--muted); font-size: 12px; text-align: center; }

/* a sentence shown word by word, each with its romanization underneath */
.words { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 2px 0; }
.words .w { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 1px 5px 3px; margin-left: -5px; }
.words .w + .w { margin-left: 0; }
.words .w b { font-family: var(--tamil); font-size: 20px; font-weight: 600; line-height: 1.35; }
.words .w small { font-size: 13px; font-style: italic; font-weight: 700; color: var(--muted); line-height: 1.2; }
.words .w.hl-bad small, .words .w.hl-good small { color: inherit; }

/* debugging: reset progress */
.reset { margin-top: 20px; padding: 6px 12px; border-radius: 99px; background: var(--card); border: 2px dashed var(--bad-fill); color: var(--bad); font-size: 13px; font-weight: 800; white-space: nowrap; }
