:root {
  --paper: #fff4e0;
  --paper-2: #ffe9c4;
  --ink: #2b2140;
  --ink-soft: #6b5f80;
  --card: #ffffff;
  --tomato: #ff5a3c;
  --sun: #ffc23d;
  --teal: #12a594;
  --sky: #3d8bff;
  --berry: #d6336c;
  --good: #16a34a;
  --bad: #e5383b;
  --line: #2b2140;
  --radius: 22px;
  --shadow: 0 5px 0 var(--line);
  --font: "Baloo Bhaijaan 2", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 194, 61, .35) 0 90px, transparent 91px),
    radial-gradient(circle at 92% 70%, rgba(18, 165, 148, .18) 0 140px, transparent 141px),
    radial-gradient(rgba(43, 33, 64, .07) 1.2px, transparent 1.4px);
  background-size: auto, auto, 22px 22px;
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }
a { color: inherit; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px;
  background: rgba(255, 244, 224, .88);
  backdrop-filter: blur(8px);
  border-bottom: 3px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.45rem; text-decoration: none; display: flex; align-items: center; gap: 6px; }
.brand-star { color: var(--sun); -webkit-text-stroke: 2px var(--line); font-size: 1.6rem; display: inline-block; animation: wob 4s ease-in-out infinite; }
.crumb { color: var(--ink-soft); font-weight: 700; font-size: 1rem; }

main { max-width: 980px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---------- shared bits ---------- */
.btn {
  appearance: none; border: 3px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink);
  font-weight: 800; font-size: 1.15rem; line-height: 1;
  padding: 14px 24px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; user-select: none;
}
.btn:active, .btn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.show { background: var(--sun); font-size: 1.6rem; padding: 16px 44px; direction: ltr; }
.btn.good { background: var(--good); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.blue { background: var(--sky); color: #fff; }
.btn.small { font-size: 1rem; padding: 9px 16px; box-shadow: 0 3px 0 var(--line); }
.btn.round { width: 58px; height: 58px; padding: 0; font-size: 1.6rem; }
.btn:focus-visible, .chip:focus-visible, .tile:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 3px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 16px; font-weight: 800; font-size: 1.05rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

h1, h2 { margin: 0; line-height: 1.15; }
.muted { color: var(--ink-soft); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; margin: 6px 0 22px; }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--tomato); position: relative; }
.hero h1 em::after {
  content: ""; position: absolute; inset: auto -4px 4px -4px; height: 12px;
  background: var(--sun); z-index: -1; border-radius: 6px; transform: rotate(-1.5deg);
}
.hero p { margin: 6px 0 0; font-size: 1.15rem; }
.hero-badge {
  width: 112px; height: 112px; border-radius: 50%; border: 3px solid var(--line);
  background: var(--teal); color: #fff; display: grid; place-items: center; text-align: center;
  box-shadow: var(--shadow); transform: rotate(8deg); font-weight: 800; line-height: 1.05;
}
.hero-badge b { font-size: 2.1rem; display: block; }

.panel {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 22px;
}
.panel h2 { font-size: 1.15rem; margin-bottom: 10px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.tile {
  position: relative; overflow: hidden;
  border: 3px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 20px 18px; min-height: 168px; text-decoration: none;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  transition: transform .15s;
  animation: rise .5s both;
}
.tile:hover { transform: translateY(-3px) rotate(-.6deg); }
.tile:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.tile .ico { position: absolute; top: 12px; left: 16px; font-size: 3.4rem; transform: rotate(-10deg); }
.tile h3 { margin: 0; font-size: 1.6rem; font-weight: 800; }
.tile p { margin: 0; font-size: 1rem; font-weight: 600; opacity: .85; }
.tile:nth-child(1) { background: var(--sun); animation-delay: .05s; }
.tile:nth-child(2) { background: #ffd7cc; animation-delay: .12s; }
.tile:nth-child(3) { background: #bdeee6; animation-delay: .19s; }
.tile:nth-child(4) { background: #cfe0ff; animation-delay: .26s; }

.review-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 2px dashed #e6dccb; padding: 4px 0; }
.history li:last-child { border-bottom: 0; }

/* ---------- flashcard ---------- */
.stage { display: grid; justify-items: center; gap: 18px; }
.counter { font-weight: 800; font-size: 1.1rem; color: var(--ink-soft); }
.card {
  width: min(100%, 560px); background: var(--card);
  border: 3px solid var(--line); border-radius: 28px; box-shadow: 0 8px 0 var(--line);
  padding: 22px; display: grid; justify-items: center; gap: 16px;
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.card .pic { width: 100%; height: min(42vh, 400px); min-height: 200px; position: relative; }
.card .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.answer { min-height: 112px; display: grid; place-items: center; text-align: center; }
.word {
  direction: ltr; font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 800; line-height: 1;
  letter-spacing: .5px;
}
.meaning { font-size: 1.35rem; font-weight: 700; color: var(--teal); margin-top: 4px; }
.reveal { animation: pop .3s cubic-bezier(.2, 1.4, .4, 1) both; display: grid; justify-items: center; gap: 6px; }
.say {
  border: 0; background: none; font-size: 1.7rem; cursor: pointer; padding: 2px 8px;
  border-radius: 12px;
}
.say:hover { background: var(--paper); }
.nav { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }

/* ---------- all words grid ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.mini {
  background: var(--card); border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 4px 0 var(--line); padding: 10px; display: grid; gap: 8px; justify-items: center;
  animation: rise .4s both;
}
.mini .pic { width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
.mini .pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.mini .slot { min-height: 64px; display: grid; place-items: center; text-align: center; }
.mini .w { direction: ltr; font-weight: 800; font-size: 1.35rem; line-height: 1.05; }
.mini .m { font-weight: 700; color: var(--teal); font-size: .95rem; }
.mini a { font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.mini .say { font-size: 1.1rem; padding: 0 4px; }
.picked { color: var(--bad); font-weight: 700; font-size: .95rem; }
.picked s { text-decoration-thickness: 2px; }
.reveal .picked { font-size: 1.1rem; margin-top: 2px; }

/* ---------- tests ---------- */
.setup { display: grid; gap: 18px; max-width: 640px; margin: 0 auto; }
.setup .panel { margin: 0; }
.progress { width: min(100%, 560px); height: 18px; border: 3px solid var(--line); border-radius: 999px; background: var(--card); overflow: hidden; }
.progress i { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--teal) 0 12px, #19bba8 12px 24px); transition: width .3s; }
.judge { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.judge .btn { min-width: 150px; font-size: 1.35rem; }
.hint { font-weight: 700; color: var(--ink-soft); text-align: center; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(100%, 560px); }
.opt {
  direction: ltr; border: 3px solid var(--line); border-radius: 18px; background: var(--card);
  box-shadow: 0 4px 0 var(--line); font-family: inherit; font-weight: 800; font-size: 1.5rem;
  padding: 14px 10px; cursor: pointer; color: var(--ink); min-height: 72px;
  transition: transform .08s;
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt.right { background: var(--good); color: #fff; animation: bounce .45s; }
.opt.wrong { background: var(--bad); color: #fff; animation: shake .4s; }
.opt:disabled { cursor: default; }
.opt.dim { opacity: .45; }

.feedback { font-size: 1.6rem; font-weight: 800; min-height: 2.2rem; text-align: center; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }

/* ---------- results ---------- */
.result { text-align: center; display: grid; gap: 16px; justify-items: center; }
.score {
  width: 190px; height: 190px; border-radius: 50%; border: 4px solid var(--line);
  display: grid; place-items: center; box-shadow: 0 8px 0 var(--line);
  background: conic-gradient(var(--good) calc(var(--p) * 1%), #ffd7cc 0);
  animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.score div { width: 140px; height: 140px; border-radius: 50%; background: var(--card); border: 3px solid var(--line); display: grid; place-items: center; }
.score b { font-size: 2.6rem; line-height: 1; }
.score span { font-weight: 700; color: var(--ink-soft); }
.result h2 { font-size: 2rem; }
.wrong-list { width: 100%; text-align: right; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; }

/* ---------- motion ---------- */
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wob { 50% { transform: rotate(18deg) scale(1.1); } }
@keyframes bounce { 40% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

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

@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr; }
  .tile { min-height: 130px; }
  .hero { grid-template-columns: 1fr; }
  .hero-badge { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mini .w { font-size: 1.15rem; }
  .opt { font-size: 1.25rem; }
  .judge .btn { min-width: 130px; }
  .card { padding: 14px; }
}
