:root {
  --ink: #2b2340;
  --paper: #fff8ec;
  --yellow: #ffd23f;
  --pink: #ff5c8a;
  --blue: #3a86ff;
  --green: #06d6a0;
  --purple: #8338ec;
  --orange: #ff8c42;
  --radius: 22px;
  --shadow: 6px 6px 0 var(--ink);
  --font-head: "Fredoka", "Comic Sans MS", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(43, 35, 64, .09) 1.5px, transparent 0);
  background-size: 26px 26px;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5em; }
h2 { font-size: clamp(2rem, 5vw, 3rem); }
h3 { font-size: 1.35rem; }
em { font-style: italic; }
small { font-size: .85em; opacity: .85; }
kbd {
  font-family: var(--font-body); font-weight: 800; font-size: .8em;
  border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px;
  padding: 0 .35em; background: #fff;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- progress ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 10px; z-index: 50;
  background: rgba(43, 35, 64, .1);
}
.progress__bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--pink), var(--yellow), var(--green), var(--blue), var(--purple));
  transition: width .15s linear;
}
.progress__label {
  position: absolute; right: 12px; top: 14px;
  font: 700 .8rem var(--font-head);
  background: var(--ink); color: #fff; padding: 2px 10px; border-radius: 99px;
}

/* ---------- cards & buttons ---------- */
.card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card--yellow { background: var(--yellow); }
.card--green  { background: #c9f7e8; }
.card--pink   { background: #ffd6e2; }
.card--purple { background: #e7dbff; }
.card--paper  { background: #fffdf6; }

.btn {
  display: inline-block;
  font: 700 1.1rem var(--font-head);
  color: var(--ink); text-decoration: none;
  background: var(--yellow);
  border: 3px solid var(--ink); border-radius: 99px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: .65em 1.4em;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .2s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { background: #ddd; color: #888; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 #888; border-color: #888; }
.btn--big { font-size: 1.35rem; background: var(--pink); color: #fff; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 4px dashed var(--blue); outline-offset: 3px;
}

/* ---------- speech bubbles ---------- */
.bubble {
  position: relative; display: inline-block;
  background: #fff; border: 3px solid var(--ink); border-radius: 20px;
  padding: .6em 1em; font-weight: 700;
}
.bubble--alt { background: #dff0ff; }
.bubble--big {
  font: 700 clamp(1.8rem, 6vw, 3.6rem) var(--font-head);
  padding: .5em 1em; margin: .5rem 0 1.5rem;
  background: #fff; box-shadow: var(--shadow);
  border-radius: 40px;
}
.bubble--big::after {
  content: ""; position: absolute; left: 18%; bottom: -26px;
  border: 14px solid transparent; border-top: 16px solid var(--ink);
}
.bubble--big::before {
  content: ""; position: absolute; left: calc(18% + 4px); bottom: -17px; z-index: 1;
  border: 10px solid transparent; border-top: 12px solid #fff;
}
/* strike-through that sweeps across every wrapped line */
.bubble__quote {
  background: linear-gradient(var(--pink), var(--pink)) no-repeat 0 58% / 0% 6px;
  -webkit-box-decoration-break: slice; box-decoration-break: slice;
  animation: strike .8s 1.4s ease-out forwards;
}
@keyframes strike { to { background-size: 100% 6px; } }

.wobble { animation: wobble 3.5s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg) scale(1.02); }
}

/* ---------- hero ---------- */
.hero {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4rem 1.25rem 3rem;
  position: relative;
}
.tag {
  font: 600 .95rem var(--font-head);
  background: var(--ink); color: var(--yellow);
  padding: .35em 1em; border-radius: 99px; margin-bottom: 1.5rem;
  transform: rotate(-1.5deg);
}
.hero__title { font-size: clamp(2rem, 6vw, 3.5rem); }
.hero__lead { max-width: 40rem; font-size: 1.2rem; margin: 1rem auto 2rem; }

.counter {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .25rem 1.25rem;
  text-align: left; max-width: 26rem; margin-bottom: 2rem; padding: 1rem 1.25rem;
  transform: rotate(1deg);
}
.counter__label { font-weight: 800; font-size: .95rem; line-height: 1.3; }
.counter__value {
  grid-row: span 2;
  font: 700 3.5rem/1 var(--font-head);
  background: var(--ink); color: var(--yellow);
  border-radius: 14px; padding: .1em .35em; min-width: 1.6em; text-align: center;
}
.counter__value.reset { animation: shake .5s; background: var(--pink); color: #fff; }
.counter__sub { font-size: .8rem; opacity: .8; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px) rotate(-3deg); }
  40%, 80% { transform: translateX(6px) rotate(3deg); }
}

/* ---------- steps ---------- */
main { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem; }
.step { padding: 4rem 0; }
.step__num {
  display: inline-block;
  font: 700 .9rem var(--font-head); text-transform: uppercase; letter-spacing: .08em;
  background: var(--blue); color: #fff; padding: .2em .9em; border-radius: 99px;
  margin-bottom: .75rem; transform: rotate(-2deg);
}
.step__intro { font-size: 1.2rem; max-width: 44rem; }

/* story chat */
.chat { display: flex; flex-direction: column; gap: .9rem; margin: 1.25rem 0 2rem; max-width: 44rem; }
.chat__row { display: flex; align-items: flex-end; gap: .6rem; }
.chat__row--them { justify-content: flex-end; }
.avatar { font-size: 2.2rem; line-height: 1; flex: none; }
.chat .bubble { max-width: 80%; font-weight: 700; }

.moral { display: flex; gap: 1rem; align-items: flex-start; max-width: 44rem; }
.moral p { margin: 0; }
.moral__icon { font-size: 2.5rem; line-height: 1; }

/* brain */
.brain { text-align: center; max-width: 44rem; margin: 1.5rem auto 2.5rem; }
.brain__head { font-size: 4rem; line-height: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12) rotate(4deg); } }
.brain__screen {
  margin: 1rem auto 1.25rem; padding: 1rem;
  min-height: 4.5rem; display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: #7dffb3;
  font: 700 clamp(1.1rem, 3vw, 1.5rem) ui-monospace, "SFMono-Regular", Menlo, monospace;
  border-radius: 14px; box-shadow: inset 0 0 0 4px #463a66;
}
.brain__screen.spinning { color: var(--yellow); }
.brain__note { margin: 1.25rem 0 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem; }
.fact { text-align: center; }
.fact:nth-child(1) { transform: rotate(-1.5deg); }
.fact:nth-child(2) { transform: rotate(1deg); }
.fact:nth-child(3) { transform: rotate(-.5deg); }
.fact__emoji { font-size: 3rem; line-height: 1.2; }
.fact p { margin: 0; }

/* magic words */
.magic { list-style: none; padding: 0; margin: 1.5rem 0 2rem; display: grid; gap: 1.25rem; counter-reset: magic; }
.magic__item { display: flex; gap: 1.25rem; align-items: center; counter-increment: magic; position: relative; }
.magic__item::before {
  content: counter(magic);
  position: absolute; top: -14px; left: -14px;
  width: 2.2rem; height: 2.2rem; display: grid; place-items: center;
  font: 700 1.1rem var(--font-head);
  background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 50%;
}
.magic__item:nth-child(odd) { margin-right: 8%; }
.magic__item:nth-child(even) { margin-left: 8%; }
.magic__finger { font-size: 3rem; line-height: 1; flex: none; width: 4rem; text-align: center; }
.magic__item h3 { margin-bottom: .2em; }
.magic__example {
  margin: 0; font-family: "Caveat", cursive; font-size: 1.6rem; line-height: 1.25; color: #4a3c75;
}

.bonus { display: flex; gap: 1.25rem; align-items: flex-start; }
.bonus__emoji { font-size: 3.5rem; line-height: 1; }
.bonus p { margin: 0; }

/* quiz */
.quiz { display: grid; gap: 2rem; margin-top: 1.5rem; }
.quiz__q h3 { margin-bottom: 1rem; }
.quiz__options { display: grid; gap: .8rem; }
.quiz__opt {
  text-align: left; font: 700 1.05rem var(--font-body); color: var(--ink);
  background: #fff; border: 3px solid var(--ink); border-radius: 16px;
  padding: .8em 1em; cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, background .2s;
}
.quiz__opt:hover:not(:disabled) { transform: translate(-2px, -2px); background: #fffbe6; }
.quiz__opt:disabled { cursor: default; }
.quiz__opt.correct { background: #b9f5dd; }
.quiz__opt.wrong { background: #ffc9d6; animation: shake .4s; }
.quiz__opt.dim { opacity: .5; }
.quiz__feedback { margin: 1rem 0 0; font-weight: 800; min-height: 1.6em; }
.quiz__score { text-align: center; font: 700 1.4rem var(--font-head); }

/* builder */
.builder { display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem; margin-top: 1.5rem; align-items: start; }
.builder__form { display: grid; gap: 1rem; }
.builder__form label { display: grid; gap: .35rem; font-weight: 800; }
.builder__form .check, .pledge .check { display: flex; gap: .6rem; align-items: center; font-weight: 700; }
textarea, input[type="text"], select {
  font: 1rem var(--font-body); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px; padding: .55em .75em;
  background: #fffdf6; width: 100%; resize: vertical;
}
input[type="checkbox"] { width: 1.4rem; height: 1.4rem; accent-color: var(--pink); flex: none; }
.builder__preview { position: sticky; top: 2rem; }
.builder__meter { display: flex; align-items: center; gap: .75rem; font-weight: 800; margin-bottom: 1rem; }
.meter { flex: 1; height: 18px; border: 3px solid var(--ink); border-radius: 99px; overflow: hidden; background: #fff; }
.meter__fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--yellow), var(--green)); transition: width .3s; }
#meterEmoji { font-size: 1.6rem; }
.report {
  white-space: pre-wrap; word-break: break-word;
  font: .95rem/1.55 ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: #fff; border: 2px dashed var(--ink); border-radius: 12px;
  padding: 1rem; margin: 0 0 1rem; min-height: 14rem;
}

/* pledge */
.pledge { display: grid; gap: 1rem; max-width: 40rem; margin-top: 1.5rem; }
.pledge__name { display: grid; gap: .35rem; font-weight: 800; }
.pledge .btn { justify-self: start; margin-top: .5rem; }

/* certificate */
.certificate { margin-top: 2.5rem; text-align: center; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6) rotate(-6deg); opacity: 0; } }
.certificate__inner {
  background: #fffdf3;
  border: 3px solid var(--ink); border-radius: 8px;
  outline: 10px double var(--orange); outline-offset: -22px;
  box-shadow: var(--shadow);
  padding: 3.5rem 2.5rem 2.5rem;
  max-width: 46rem; margin: 0 auto;
}
.certificate__seal { font-size: 4rem; line-height: 1; }
.certificate__kicker { font: 700 clamp(1.3rem, 3.5vw, 2rem) var(--font-head); color: var(--purple); margin: .5rem 0 1rem; }
.certificate__name {
  font: 700 clamp(2.4rem, 8vw, 4rem)/1.1 "Caveat", cursive; color: var(--pink);
  border-bottom: 3px solid var(--ink); display: inline-block; padding: 0 1rem; margin: .25rem 0 1rem;
}
.certificate__small { font-size: .95rem; opacity: .8; }
.certificate__footer { display: flex; justify-content: space-around; gap: 2rem; margin-top: 2rem; font-size: .85rem; font-weight: 700; }
.certificate__footer .sig { font: 700 1.8rem "Caveat", cursive; }
.certificate__footer .line { border-top: 2px solid var(--ink); width: 11rem; margin: .2rem auto; }
.certificate__actions { margin-top: 1.75rem; }

/* footer */
.footer { text-align: center; padding: 3rem 1.25rem 4rem; }
.footer p { margin: .25rem 0; }
.footer__small { font-size: .9rem; opacity: .75; }

/* floating bugs */
.bugs { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.bug {
  position: absolute; font-size: 1.9rem; pointer-events: auto; cursor: crosshair;
  user-select: none; will-change: transform, left, top;
  background: none; border: 0; padding: 0;
  filter: drop-shadow(2px 2px 0 rgba(43, 35, 64, .25));
}
.bug.squashed { animation: squash .45s forwards; pointer-events: none; }
@keyframes squash { 40% { transform: scale(1.6, .3); } 100% { transform: scale(2, 0); opacity: 0; } }
.squash-toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 200%); z-index: 60;
  background: var(--ink); color: #fff; font-weight: 800;
  padding: .6em 1.2em; border-radius: 99px; transition: transform .3s;
  max-width: calc(100vw - 2rem); text-align: center;
}
.squash-toast.show { transform: translate(-50%, 0); }

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

/* reveal on scroll */
.reveal { opacity: 0; translate: 0 40px; transition: opacity .7s ease, translate .7s ease; }
.reveal.visible { opacity: 1; translate: 0 0; }

/* responsive */
@media (max-width: 760px) {
  .builder { grid-template-columns: 1fr; }
  .builder__preview { position: static; }
  .magic__item:nth-child(odd), .magic__item:nth-child(even) { margin: 0; }
  .magic__finger { font-size: 2.3rem; width: 2.8rem; }
  .counter { grid-template-columns: 1fr; text-align: center; }
  .counter__value { grid-row: auto; justify-self: center; }
  .certificate__inner { padding: 3rem 1.5rem 2rem; }
  .certificate__footer { flex-direction: column; gap: 1rem; }
  .progress__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; translate: none; }
}

/* print only the certificate */
@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .certificate, .certificate * { visibility: visible; }
  .certificate { position: absolute; inset: 0; margin: 0; animation: none; }
  .certificate__inner { box-shadow: none; }
  .certificate__actions { display: none; }
  .progress, .bugs, #confetti, .squash-toast { display: none; }
}

/* language switch */
.lang-switch {
  position: fixed; left: 12px; top: 16px; z-index: 55;
  display: flex; border: 3px solid var(--ink); border-radius: 99px; overflow: hidden;
  box-shadow: 3px 3px 0 var(--ink); background: #fff;
  font: 700 .85rem var(--font-head);
}
.lang-switch a { color: var(--ink); text-decoration: none; padding: 2px 10px; }
.lang-switch a + a { border-left: 3px solid var(--ink); }
.lang-switch a[aria-current] { background: var(--yellow); }
.lang-switch a:hover:not([aria-current]) { background: #ffe9a0; }
@media print { .lang-switch { display: none; } }
