:root {
  --ink: #1b1144;
  --ink-soft: #4a3d73;
  --paper: #fff6e8;
  --paper-2: #ffe8f2;
  --white: #fffdf8;
  --pink: #ff4d8d;
  --pink-deep: #e0186a;
  --yellow: #ffe14d;
  --mint: #5dffc4;
  --lavender: #c9b6ff;
  --blue: #4da3ff;
  --orange: #ff8a3d;
  --success: #12b886;
  --danger: #e03131;
  --shadow: 6px 6px 0 #1b1144;
  --shadow-sm: 4px 4px 0 #1b1144;
  --radius: 22px;
  --font-display: "Baloo 2", "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", "Fredoka", system-ui, sans-serif;
  --font-fun: "Fredoka", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, #ffd0e6 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d6e8ff 0%, transparent 50%),
    radial-gradient(800px 500px at 80% 100%, #d6ffe8 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.55;
  min-height: 100vh;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 80;
}

a { color: var(--pink-deep); }
code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.05em 0.4em;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--ink);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.brand-badge {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 22px;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}
.nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex-shrink: 0;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.92rem;
  padding: 8px 12px;
  border: 3px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
}
.nav a:hover, .nav a.active {
  border-color: var(--ink);
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
}
.stats {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  font-weight: 800;
}
.stat {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 0.9rem;
}

.panel {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 20px 24px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 4px;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.section-head p { margin: 0 0 22px; color: var(--ink-soft); }

.hero { padding-top: 32px; position: relative; }
.blobs { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute;
  font-size: 2.4rem;
  animation: float 5.5s ease-in-out infinite;
  filter: drop-shadow(3px 3px 0 rgba(27,17,68,0.15));
}
.b1 { top: 8%; left: 2%; animation-delay: 0s; }
.b2 { top: 12%; right: 4%; animation-delay: 0.7s; }
.b3 { bottom: 10%; left: 8%; animation-delay: 1.2s; }
.b4 { bottom: 18%; right: 6%; animation-delay: 1.8s; }
.b5 { top: 40%; left: -6px; animation-delay: 0.3s; font-size: 1.6rem; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-14px) rotate(8deg); }
}

.hero-card, .lesson-card, .ex-card, .quiz-card {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  position: relative;
}
.hero-card { text-align: center; }
.eyebrow {
  display: inline-block;
  background: var(--mint);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  margin: 0 0 12px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  line-height: 0.95;
  margin: 0 0 12px;
  letter-spacing: -0.04em;
}
.pop {
  background: linear-gradient(90deg, #ff4d8d, #ff8a3d, #ffe14d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0;
  filter: drop-shadow(0 0 0 transparent);
  position: relative;
}
/* Fallback so gradient text stays bold/visible */
@supports (-webkit-background-clip: text) {
  .pop { color: transparent; }
}
.lede { font-size: 1.15rem; max-width: 34em; margin: 0 auto 20px; }
.name-row { max-width: 320px; margin: 0 auto 18px; text-align: left; }
.name-row label { display: block; font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.optional { font-weight: 600; color: var(--ink-soft); font-size: 0.85rem; }
input[type="text"], input[type="number"] {
  width: 100%;
  font: inherit;
  font-weight: 800;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 #1b1144;
}
input:focus {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}
.hero-actions, .lesson-done, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}
.hello { font-weight: 800; margin: 16px 0 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-fun);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 18px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  background: var(--white);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn-primary { background: var(--pink); color: #fff; }
.btn-ghost { background: var(--yellow); }
.btn-mint { background: var(--mint); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-lavender { background: var(--lavender); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }

.lesson-card { margin-bottom: 18px; }
.lesson-card h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 8px;
}
.pills { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pills li {
  background: var(--lavender);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 12px;
  font-weight: 700;
}
.rate-grid, .formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.rate-card, .formula {
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.rate-card p { margin: 8px 0 0; font-size: 0.95rem; }
.rate-pct {
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1;
}
.rate-name { font-weight: 800; }
.r21 { background: #ffd0e0; }
.r12 { background: #ffe9b0; }
.r06 { background: #c8ffea; }
.r00 { background: #dce7ff; }
.formula { background: #fff8c9; }
.formula code { display: block; font-size: 1.05rem; margin: 8px 0; padding: 8px; }
.formula p { margin: 0; }
.f-tag {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
}
.note {
  background: #fff3c4;
  border: 3px dashed var(--ink);
  border-radius: 14px;
  padding: 10px 14px;
}
.worked {
  background: #eafaf1;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
}
.worked h4 { margin: 0 0 6px; font-family: var(--font-display); }
.worked ol { margin: 8px 0 0; padding-left: 1.2em; }
.tiny { font-size: 0.9rem; font-weight: 700; color: var(--success); }

.progress-wrap { margin-bottom: 14px; }
.progress-label { font-weight: 800; margin-bottom: 6px; }
.progress-bar {
  height: 18px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 3px 3px 0 var(--ink);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--orange), var(--yellow));
  transition: width 0.4s ease;
}

.ex-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.ex-dot {
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font-weight: 800;
  font-family: var(--font-fun);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.ex-dot:hover { transform: translate(-1px, -1px); }
.ex-dot.current { background: var(--yellow); }
.ex-dot.done { background: var(--mint); }
.ex-dot.current.done { background: linear-gradient(135deg, var(--mint), var(--yellow)); }

.ex-kicker {
  font-weight: 800;
  color: var(--pink-deep);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  margin: 0 0 6px;
}
.ex-card h3 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  margin: 0 0 10px;
  line-height: 1.15;
}
.story {
  background: #f3e9ff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-weight: 700;
}
.ask { font-size: 1.1rem; margin: 0 0 12px; }
.answer-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.answer-row input { flex: 1; min-width: 180px; font-size: 1.25rem; }
.feedback {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  font-weight: 700;
  display: none;
}
.feedback.show { display: block; animation: popin 0.25s ease; }
.feedback.ok { background: #d3f9d8; }
.feedback.ko { background: #ffe3e3; }
.hint, .steps {
  margin-top: 14px;
  background: #fff8e1;
  border: 3px dashed var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
}
.steps { background: #e7f5ff; border-style: solid; }
.steps ol { margin: 8px 0 0; padding-left: 1.2em; }
.hint[hidden], .steps[hidden] { display: none; }
@keyframes popin {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.choices { display: grid; gap: 10px; margin: 14px 0; }
.choice {
  text-align: left;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.choice:hover:not(:disabled) { background: #fff3c4; transform: translate(-1px, -1px); }
.choice:disabled { cursor: default; }
.choice.correct { background: #d3f9d8; }
.choice.wrong { background: #ffe3e3; }
.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
  margin-bottom: 8px;
}
.timer-big {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  text-align: center;
  margin: 0 0 8px;
}
.timer-big.warn { color: var(--danger); animation: pulse 0.8s ease infinite; }
@keyframes pulse {
  50% { transform: scale(1.06); }
}
.score-hero {
  text-align: center;
  padding: 10px 0 6px;
}
.score-hero .big {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  line-height: 1;
  margin: 0;
}
.stars-row { font-size: 1.8rem; letter-spacing: 0.1em; }

.foot {
  max-width: 980px;
  margin: 20px auto 40px;
  padding: 0 20px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  text-align: center;
}
.linkish {
  background: none;
  border: none;
  color: var(--pink-deep);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

@media (max-width: 700px) {
  body { font-size: 16.5px; }
  .stats .stat:last-child { display: none; }
  .hero-card, .lesson-card, .ex-card, .quiz-card { padding: 20px 16px; }
  .topbar { padding: 8px 10px; }
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
