/* ---------- tokens ---------- */
:root {
  --bg: #fff8ec;
  --bg-2: #ffeedd;
  --surface: #ffffff;
  --ink: #2b2d42;
  --muted: #6b7280;
  --line: rgba(43, 45, 66, 0.08);
  --brand: #ff7a59;
  --brand-ink: #ffffff;
  --accent: #4d96ff;
  --ok: #2fb344;
  --ok-soft: #e3f8e6;
  --bad: #e5484d;
  --bad-soft: #fde2e2;
  --gold: #ffb703;
  --tint-s: 85%;
  --tint-l: 91%;
  --tint-ink-s: 55%;
  --tint-ink-l: 32%;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 5px 0 rgba(43, 45, 66, 0.08), 0 10px 26px rgba(43, 45, 66, 0.07);
  --shadow-press: 0 1px 0 rgba(43, 45, 66, 0.1), 0 3px 10px rgba(43, 45, 66, 0.08);
  --font: "Baloo 2", "Noto Sans Devanagari", "Kohinoor Devanagari", "Mukta", "Nirmala UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d2033;
    --bg-2: #262a42;
    --surface: #2c3150;
    --ink: #f4f5fb;
    --muted: #b8bdd6;
    --line: rgba(255, 255, 255, 0.08);
    --ok-soft: #22402a;
    --bad-soft: #4a2628;
    --tint-s: 32%;
    --tint-l: 26%;
    --tint-ink-s: 80%;
    --tint-ink-l: 82%;
    --shadow: 0 5px 0 rgba(0, 0, 0, 0.35), 0 10px 26px rgba(0, 0, 0, 0.3);
    --shadow-press: 0 1px 0 rgba(0, 0, 0, 0.4), 0 3px 10px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, var(--bg-2) 0, transparent 40%),
    radial-gradient(circle at 90% 100%, var(--bg-2) 0, transparent 40%),
    var(--bg);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 800; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[lang="en"] { font-weight: 800; letter-spacing: 0.01em; }
small { font-weight: 600; }
svg { display: block; }

.skip {
  position: absolute; left: 8px; top: -60px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--brand); color: var(--brand-ink); z-index: 100;
}
.skip:focus { top: 8px; }

:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }

/* ---------- header / footer ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.25rem; font-weight: 800; min-height: 48px; }
.brand span { font-size: 1.5rem; }

.icon-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--surface); box-shadow: var(--shadow-press);
  font-size: 1.5rem; cursor: pointer; display: grid; place-items: center;
}
.icon-btn[aria-pressed="false"] { opacity: 0.55; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }
main:focus { outline: none; }

.site-foot {
  text-align: center; color: var(--muted); font-size: 0.95rem;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 10px 20px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-press); cursor: pointer;
  font-size: 1.1rem; font-weight: 800; white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 5px 0 #d8583a, 0 10px 24px rgba(255, 122, 89, 0.35); }
.btn.primary:active { box-shadow: 0 1px 0 #d8583a; }
.btn.back { padding-inline: 14px; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 20px 8px 28px; }
.hero-emoji { font-size: clamp(2.6rem, 9vw, 4.2rem); line-height: 1; letter-spacing: 0.1em; }
.hero-emoji span { display: inline-block; animation: float 3s ease-in-out infinite; }
.hero-emoji span:nth-child(2) { animation-delay: 0.5s; }
.hero-emoji span:nth-child(3) { animation-delay: 1s; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 3.4rem); margin-top: 8px; color: var(--brand); }
.hero .sub { font-size: 1.25rem; color: var(--muted); margin-top: 4px; }

.section-title {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 1.7rem; margin: 22px 4px 12px;
}
.section-title small { font-size: 1.05rem; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.topics { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.games { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 18px 12px 16px; border-radius: var(--radius);
  background: hsl(var(--hue) var(--tint-s) var(--tint-l));
  color: hsl(var(--hue) var(--tint-ink-s) var(--tint-ink-l));
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
  min-height: 150px;
}
.card:active { transform: scale(0.97); }
@media (hover: hover) { .card:hover { transform: translateY(-3px); } }
.card .big { font-size: 3rem; line-height: 1.1; }
.card .mr { font-size: 1.3rem; font-weight: 800; margin-top: 4px; }
.card .en { font-size: 0.95rem; opacity: 0.85; }
.card .count { font-size: 0.85rem; opacity: 0.7; margin-top: 4px; }
.card .badge {
  position: absolute; top: 8px; right: 10px;
  font-size: 1rem; background: var(--surface); border-radius: 999px; padding: 2px 8px;
  box-shadow: var(--shadow-press);
}
.card.game { align-items: flex-start; text-align: left; padding: 18px 18px 16px; }
.card.game .big { font-size: 2.6rem; }
.card.game .desc { font-size: 0.95rem; opacity: 0.85; margin-top: 6px; font-weight: 600; }
.card.game .stars { margin-top: 8px; font-size: 1.1rem; letter-spacing: 2px; }

/* ---------- topic page ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 4px 0 14px;
}
.topbar h1 {
  flex: 1 1 200px; font-size: clamp(1.5rem, 5vw, 2.1rem);
  color: hsl(var(--hue, 10) var(--tint-ink-s) var(--tint-ink-l));
}
.topbar h1 small { font-size: 0.65em; color: var(--muted); font-weight: 700; }
.qnum { font-size: 1.1rem; color: var(--muted); font-weight: 800; }

.tip, .ask { color: var(--muted); font-size: 1.1rem; margin: 0 2px 12px; }
.ask { font-size: 1.35rem; color: var(--ink); text-align: center; margin: 14px 0 6px; }
.ask small { color: var(--muted); font-size: 0.8em; }

.grid.cards { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.grid.cards.kind-sentence { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cards.kind-pair { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.flash {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 200px; padding: 20px 12px 16px;
  border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer; text-align: center;
  transition: transform 0.15s ease, outline-color 0.15s ease;
  outline: 4px solid transparent;
}
.flash:active { transform: scale(0.96); }
.flash.active { outline-color: var(--brand); transform: scale(1.03); }
.flash.pop { animation: pop 0.45s ease; }
.flash::after {
  content: "🔊"; position: absolute; top: 10px; right: 12px;
  font-size: 1rem; opacity: 0.55;
}
.flash .word { font-size: 1.5rem; color: hsl(var(--hue) var(--tint-ink-s) var(--tint-ink-l)); }
.flash .say { font-size: 1rem; color: var(--muted); font-weight: 600; }
.flash .mean { font-size: 1.25rem; font-weight: 800; }
.flash .numeral { font-size: 2rem; font-weight: 800; line-height: 1; color: hsl(var(--hue) var(--tint-ink-s) var(--tint-ink-l)); }
.flash .numeral small { font-size: 0.6em; color: var(--muted); }

.letter {
  font-size: 3.4rem; font-weight: 800; line-height: 1;
  color: hsl(var(--hue) var(--tint-ink-s) var(--tint-ink-l));
  display: inline-flex; align-items: baseline; gap: 6px;
}
.letter small { font-size: 0.6em; font-weight: 800; }

.pic { font-size: 3.6rem; line-height: 1.15; display: inline-block; }
.pic.sm { font-size: 2.2rem; }
.pic.swatch {
  width: 86px; height: 86px; border-radius: 50%;
  background: var(--sw); box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.1);
  display: grid; place-items: center; font-size: 2rem;
}
.pic.svg { width: 86px; height: 86px; }
.pic.svg svg { width: 100%; height: 100%; }
.pic.many {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 4px;
  max-width: 190px; line-height: 1.2;
}
.pic.many.few { font-size: 2.2rem; }
.pic.many.some { font-size: 1.6rem; }
.pic.many.lots { font-size: 1.15rem; max-width: 160px; }

.flash.pair { flex-direction: row; gap: 8px; min-height: 180px; }
.flash.pair .half { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.flash.pair .vs { font-size: 1.6rem; color: var(--muted); }
.flash.pair .pic { font-size: 2.8rem; }
.flash.pair .word { font-size: 1.3rem; }
.flash.pair .mean { font-size: 1.1rem; }

.flash.sentence { flex-direction: row; gap: 14px; text-align: left; min-height: 120px; padding: 16px 18px; }
.flash.sentence .pic { font-size: 2.8rem; flex: 0 0 auto; }
.flash.sentence .text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.flash.sentence .word { font-size: 1.35rem; }

.cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 26px 0 8px; }

/* ---------- quiz ---------- */
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 2px 0 10px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); border: 2px solid var(--line); }
.dots i.ok { background: var(--ok); border-color: var(--ok); }
.dots i.retry { background: var(--gold); border-color: var(--gold); }
.dots i.now { border-color: var(--brand); }

.quiz { max-width: 720px; margin: 0 auto; }
.prompt {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 22px 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px;
}
.prompt .pic { font-size: 5rem; }
.prompt .pic.swatch, .prompt .pic.svg { width: 120px; height: 120px; font-size: 2.6rem; }
.prompt .pic.many { max-width: 320px; }
.prompt .hint { font-size: 1.8rem; font-weight: 800; }
.prompt .ask { margin: 0; }
.prompt .word { font-size: 1.8rem; color: var(--brand); }
.prompt .reveal { font-size: 1.4rem; color: var(--ok); font-weight: 800; }
.letter-big {
  font-size: 5.5rem; line-height: 1; font-weight: 800; color: var(--brand);
  display: inline-flex; align-items: baseline; gap: 10px;
}
.letter-big small { font-size: 0.6em; }
.big-speak { font-size: 1.6rem; min-height: 72px; padding-inline: 28px; background: var(--accent); color: #fff; box-shadow: 0 5px 0 #2f6fd6; }

.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.opt {
  min-height: 78px; padding: 10px 12px;
  border: 3px solid transparent; border-radius: 18px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
  font-size: 1.45rem; font-weight: 800;
  transition: transform 0.12s ease;
  display: grid; place-items: center;
}
.opt:active:not(:disabled) { transform: scale(0.97); }
.opt:disabled { cursor: default; }
.opt.right { background: var(--ok); color: #fff; animation: pop 0.45s ease; }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); opacity: 0.75; animation: shake 0.4s ease; }
.options.pics .opt { min-height: 120px; font-size: 3.4rem; }
.options.pics .opt .pic { font-size: inherit; }
.options.pics .opt .pic.swatch, .options.pics .opt .pic.svg { width: 80px; height: 80px; font-size: 1.8rem; }
.options.pics .opt .pic.many { max-width: 100%; }
.options.pics .opt .pic.many.few { font-size: 2rem; }
.options.pics .opt .pic.many.some { font-size: 1.3rem; }
.options.pics .opt .pic.many.lots { font-size: 0.95rem; }

/* ---------- picker ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 52px; padding: 8px 18px; border-radius: 999px;
  background: hsl(var(--hue) var(--tint-s) var(--tint-l));
  color: hsl(var(--hue) var(--tint-ink-s) var(--tint-ink-l));
  font-size: 1.1rem; font-weight: 800; box-shadow: var(--shadow-press);
}
.chip:active { transform: scale(0.96); }

/* ---------- memory ---------- */
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 640px; margin: 0 auto; }
@media (max-width: 420px) { .memory { grid-template-columns: repeat(3, 1fr); } }
.mcard {
  position: relative; aspect-ratio: 1 / 1.08;
  border: 0; border-radius: 16px; background: transparent;
  padding: 0; cursor: pointer; perspective: 700px;
}
.mcard .front, .mcard .back {
  position: absolute; inset: 0; border-radius: 16px;
  display: grid; place-items: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.4s ease; box-shadow: var(--shadow);
}
.mcard .front { background: var(--brand); color: #fff; font-size: 2.2rem; }
.mcard .back { background: var(--surface); transform: rotateY(180deg); font-size: 2.4rem; padding: 6px; overflow: hidden; }
.mcard .back .pic { font-size: 2.6rem; }
.mcard .back .pic.swatch, .mcard .back .pic.svg { width: 60px; height: 60px; font-size: 1.4rem; }
.mcard .back .pic.many { font-size: 0.9rem; max-width: 100%; }
.mcard .back .word { font-size: 1.15rem; font-weight: 800; text-align: center; line-height: 1.1; }
.mcard.open .front, .mcard.done .front { transform: rotateY(180deg); }
.mcard.open .back, .mcard.done .back { transform: rotateY(0); }
.mcard.done .back { background: var(--ok-soft); outline: 3px solid var(--ok); }
.mcard.done { cursor: default; }

/* ---------- results ---------- */
.results {
  text-align: center; max-width: 560px; margin: 20px auto;
  padding: 30px 20px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.results .stars { font-size: 3.6rem; letter-spacing: 6px; line-height: 1.1; }
.results .stars span { display: inline-block; animation: pop 0.6s ease both; }
.results .stars span:nth-child(2) { animation-delay: 0.2s; }
.results .stars span:nth-child(3) { animation-delay: 0.4s; }
.results h1 { font-size: 2.4rem; color: var(--brand); margin-top: 10px; }
.results p[lang="en"] { font-size: 1.4rem; color: var(--muted); }
.results .score { margin: 10px 0 20px; font-size: 1.2rem; }
.results .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; left: var(--x);
  width: 10px; height: 14px; border-radius: 3px;
  animation: fall var(--d) var(--delay) ease-in forwards;
}

/* ---------- animations ---------- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes fall { to { transform: translateY(105vh) rotate(var(--r)); opacity: 0.9; } }

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

/* ---------- small screens ---------- */
@media (max-width: 480px) {
  body { font-size: 17px; }
  .grid.topics { grid-template-columns: repeat(2, 1fr); }
  .grid.cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid.cards.kind-sentence, .grid.cards.kind-pair { grid-template-columns: 1fr; }
  .flash { min-height: 180px; padding: 16px 8px 12px; }
  .flash .word { font-size: 1.3rem; }
  .flash .mean { font-size: 1.1rem; }
  .pic { font-size: 3rem; }
  .options { gap: 10px; }
  .opt { font-size: 1.25rem; min-height: 70px; }
  .topbar .btn { min-height: 48px; font-size: 1rem; }
}
