/* =========================================================================
 * styles.css — CodeQuest Kids
 * A bright, friendly, high-contrast theme for ages 6–9.
 * Organized: tokens -> base -> topbar -> map -> lesson -> coder -> quiz
 *            -> trophies -> leaderboard -> parent -> modals/popups -> fx
 * ========================================================================= */

/* ---- design tokens ------------------------------------------------------- */
:root {
  --pink:   #ff7aa2;
  --orange: #ffb454;
  --blue:   #54c7ec;
  --purple: #9b8cff;
  --green:  #4fd18b;
  --yellow: #ffd166;

  --ink:    #2b2440;
  --ink-soft:#5b5470;
  --paper:  #fff7fb;
  --card:   #ffffff;
  --line:   #ece6f3;

  --ok:     #2faa6a;
  --bad:    #e0566f;

  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 8px 24px rgba(80, 50, 120, 0.12);
  --shadow-sm: 0 3px 10px rgba(80, 50, 120, 0.10);

  --font: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Fira Mono", "DejaVu Sans Mono", "Courier New", monospace;
}

body.dyslexia {
  --font: "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif;
  letter-spacing: 0.3px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #ffe9f2 0, transparent 60%),
    radial-gradient(1000px 500px at 110% 0%, #e8f6ff 0, transparent 55%),
    var(--paper);
  min-height: 100vh;
  font-size: 18px;
  line-height: 1.5;
}

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 8px 14px; border-radius: 8px; z-index: 1000;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  font-family: inherit; font-size: 1rem; font-weight: 700;
  border: none; border-radius: 999px; padding: 11px 20px; cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
  color: var(--ink); background: #f0ebf7;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.btn.big { font-size: 1.15rem; padding: 14px 26px; }
.btn.small { padding: 7px 14px; font-size: .9rem; }

.btn-primary { background: linear-gradient(180deg, var(--purple), #7d6bf0); color: #fff; box-shadow: var(--shadow-sm); }
.btn-run { background: linear-gradient(180deg, var(--green), #36b876); color: #fff; box-shadow: var(--shadow-sm); }
.btn-run span { font-size: 1.1em; }
.btn-ghost { background: #fff; border: 2px solid var(--line); }
.btn-ghost.subtle { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-danger { background: #ffe6ea; color: var(--bad); border: 2px solid #ffd0d8; }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }

/* ---- topbar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px); border-bottom: 2px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; font-family: inherit; }
.brand-bot { font-size: 1.7rem; animation: bob 3s ease-in-out infinite; }
.brand-name { font-weight: 800; font-size: 1.2rem; color: var(--ink); }

.stats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stat {
  display: flex; align-items: center; gap: 6px; background: #fff;
  border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px;
  font-weight: 800; cursor: default; font-family: inherit; color: var(--ink);
}
button.stat { cursor: pointer; }
.stat-emoji { font-size: 1.15rem; }
.stat-num { min-width: 1ch; }

.level-pill { flex-direction: column; align-items: stretch; gap: 3px; padding: 6px 14px; min-width: 132px; }
.level-rank { font-size: .82rem; font-weight: 800; color: var(--purple); }
.level-bar { height: 8px; background: #eee6f6; border-radius: 999px; overflow: hidden; }
.level-fill { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--pink), var(--orange)); transition: width .5s cubic-bezier(.2,.8,.2,1); }

.profile-chip { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 6px; cursor: pointer; font-family: inherit; font-weight: 800; color: var(--ink); }
.avatar { font-size: 1.4rem; line-height: 1; }

/* ---- layout -------------------------------------------------------------- */
.main { max-width: 920px; margin: 0 auto; padding: 20px 18px 80px; }
.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.page-title { font-size: 1.7rem; margin: 6px 0 14px; }
.page-sub { color: var(--ink-soft); margin-top: -6px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--ink-soft); }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- banner -------------------------------------------------------------- */
.banner { display: flex; align-items: center; gap: 16px; background: linear-gradient(120deg, #fff, #fff6fb); }
.banner-bot { font-size: 3rem; animation: bob 3s ease-in-out infinite; }
.banner-text { flex: 1; }
.banner-hi { font-weight: 800; font-size: 1.2rem; margin: 0 0 2px; }
.banner-text p { margin: 0; }

/* ---- tracks (parallel learning paths) ------------------------------------ */
.track-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 3px dashed var(--line); }
.track-emoji { font-size: 1.8rem; }
.track-title { margin: 0; font-size: 1.4rem; }
.track-blurb { margin: 2px 0 0; color: var(--ink-soft); font-size: .95rem; }

/* ---- quest map ----------------------------------------------------------- */
.questpath { display: flex; flex-direction: column; gap: 18px; }
.world { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px; border: 3px solid transparent; }
.world-locked { opacity: .9; }
.world-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.world-emoji {
  font-size: 2rem; background: var(--world, var(--purple)); color: #fff;
  width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px;
  box-shadow: var(--shadow-sm); flex: none;
}
.world-title { margin: 0; font-size: 1.25rem; }
.world-blurb { margin: 2px 0 0; color: var(--ink-soft); font-size: .98rem; }

.lessons-row { display: flex; gap: 12px; flex-wrap: wrap; }
.lesson-node {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 150px; padding: 16px 12px 14px; border-radius: var(--radius);
  background: #fbf8ff; border: 2px solid var(--line); cursor: pointer; font-family: inherit;
  color: var(--ink); text-align: center; transition: transform .1s ease, box-shadow .15s ease;
}
.lesson-node:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.lesson-node .node-emoji { font-size: 2rem; }
.lesson-node .node-title { font-weight: 800; font-size: .95rem; line-height: 1.2; }
.lesson-node.done { background: linear-gradient(180deg, #eafaf1, #ffffff); border-color: #bfead2; }
.lesson-node.locked { background: #f4f1f8; color: #a89fbb; cursor: not-allowed; }
.lesson-node.soon { width: 100%; flex-direction: row; justify-content: center; gap: 10px; cursor: default; color: var(--ink-soft); }
.lesson-node.prereq-lock { background: #fff6e9; border: 2px dashed var(--orange); color: #9a6a1a; font-weight: 700; }
.node-prog { width: 100%; height: 7px; background: #ece6f3; border-radius: 999px; overflow: hidden; }
.node-prog-fill { display: block; height: 100%; background: var(--world, var(--purple)); }

/* ---- lesson view --------------------------------------------------------- */
.lesson-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.lesson-title { font-size: 1.4rem; font-weight: 800; }
.lesson-emoji { font-size: 1.4rem; }

.dots { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.dot {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line);
  background: #fff; font-weight: 800; color: var(--ink-soft); cursor: pointer; font-family: inherit;
  display: grid; place-items: center;
}
.dot.current { border-color: var(--purple); color: var(--purple); box-shadow: 0 0 0 3px #ece6ff; }
.dot.done { background: var(--green); color: #fff; border-color: var(--green); }
.dot.locked { opacity: .5; cursor: not-allowed; }

.step-card { padding: 22px; }
.step-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.step-badge { font-weight: 800; font-size: .82rem; padding: 5px 12px; border-radius: 999px; background: #f0ebf7; color: var(--ink-soft); }
.step-badge.type-write, .step-badge.type-fill { background: #e9f6ff; color: #2b87b8; }
.step-badge.type-imagine { background: #fff3da; color: #b9821f; }
.step-badge.type-watch { background: #eafaf1; color: #2faa6a; }
.step-points { font-weight: 800; color: var(--orange); }
.step-title { font-size: 1.5rem; margin: 4px 0 10px; }
.step-body { font-size: 1.08rem; }
.step-body code, .analogy code, .hint code { background: #f3eefb; padding: 1px 6px; border-radius: 6px; font-family: var(--mono); font-size: .92em; color: #6b4ed8; }
.analogy {
  margin: 14px 0; padding: 12px 16px; border-radius: var(--radius);
  background: linear-gradient(180deg, #fff8e7, #fffdf7); border: 2px dashed var(--orange);
}
.analogy-label { font-weight: 800; color: #b9821f; }

.step-actions { margin-top: 18px; }

/* ---- coder (editor + console) ------------------------------------------- */
.coder { margin-top: 16px; }
.editor-wrap { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border: 2px solid #2b2440; }
.editor-bar { display: flex; align-items: center; gap: 10px; background: #2b2440; padding: 8px 14px; }
.editor-dotrow i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; background: #ff5f57; }
.editor-dotrow i:nth-child(2) { background: #febc2e; }
.editor-dotrow i:nth-child(3) { background: #28c840; }
.editor-name { color: #cfc7e6; font-size: .85rem; font-family: var(--mono); }
.editor {
  width: 100%; min-height: 150px; resize: vertical; border: none; outline: none;
  background: #1f1933; color: #f3f0ff; font-family: var(--mono); font-size: 1.02rem;
  line-height: 1.6; padding: 14px 16px; tab-size: 4; display: block;
}

.coder-actions { display: flex; gap: 10px; align-items: center; margin: 14px 0; flex-wrap: wrap; }

.hints { margin: 6px 0; }
.hint { background: #fffbe9; border-left: 4px solid var(--yellow); padding: 8px 12px; border-radius: 8px; margin: 6px 0; }
.prompts { margin: 6px 0 10px; color: var(--ink-soft); font-size: .95rem; }
.prompts-label { font-weight: 800; }

.console-label { font-weight: 800; color: var(--ink-soft); margin: 4px 2px; font-size: .9rem; }
.console {
  min-height: 70px; border-radius: var(--radius); padding: 14px 16px;
  background: #12101f; color: #d7ffe6; font-family: var(--mono); font-size: 1rem;
  border: 2px solid #2b2440; transition: border-color .2s ease;
}
.console[data-state="ok"] { border-color: var(--green); }
.console[data-state="fail"], .console[data-state="warn"] { border-color: var(--orange); }
.console-hint { color: #8b86a3; }
.out-text { margin: 0; white-space: pre-wrap; word-break: break-word; color: #eafff2; font-family: var(--mono); }
.out-error { margin-top: 8px; color: #ffd9a8; background: rgba(255,180,84,.12); padding: 8px 10px; border-radius: 8px; }
.out-pass { margin-top: 8px; color: #8ef0b6; font-weight: 800; }
.out-fail { margin-top: 8px; color: #ffd9a8; }
.fail-head { font-weight: 800; margin: 0 0 4px; }
.fail-list { margin: 0; padding-left: 20px; }
.fail-list li { margin: 3px 0; }

.next-row { margin-top: 16px; }

/* ---- web preview (HTML/CSS/JS lessons) ----------------------------------- */
.web-preview-wrap { border: 3px solid var(--purple); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow-sm); }
.web-preview { width: 100%; min-height: 220px; border: 0; display: block; background: #fff; }
.web-status { margin-top: 10px; }
.web-status[data-state="ok"] .out-pass { color: var(--ok); }

/* ---- quiz ---------------------------------------------------------------- */
.quiz { margin-top: 14px; }
.quiz-q { font-weight: 800; font-size: 1.15rem; }
.quiz-opt {
  display: block; width: 100%; text-align: left; margin: 8px 0; padding: 14px 18px;
  border-radius: var(--radius); border: 2px solid var(--line); background: #fff;
  font-family: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer; color: var(--ink);
}
.quiz-opt:hover { border-color: var(--purple); }
.quiz-opt.correct { background: #eafaf1; border-color: var(--green); }
.quiz-opt.wrong { background: #ffeef1; border-color: var(--bad); animation: shake .35s; }
.quiz-explain { background: #eafaf1; border-radius: 12px; padding: 10px 14px; font-weight: 700; color: #2faa6a; }

/* ---- lesson complete ----------------------------------------------------- */
.lesson-complete { text-align: center; padding: 34px 22px; }
.complete-emoji { font-size: 4rem; animation: pop .5s; }
.complete-line { font-size: 1.15rem; max-width: 520px; margin: 8px auto 16px; }
.complete-stats { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-weight: 800; margin-bottom: 16px; }
.complete-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- trophies ------------------------------------------------------------ */
.trophy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.trophy-card { background: #fff; border-radius: var(--radius); padding: 16px; text-align: center; border: 2px solid var(--line); box-shadow: var(--shadow-sm); }
.trophy-card.owned { background: linear-gradient(180deg, #fff8e7, #ffffff); border-color: var(--yellow); }
.trophy-card.locked { opacity: .75; filter: grayscale(.4); }
.trophy-emoji { font-size: 2.6rem; }
.trophy-name { font-weight: 800; margin: 4px 0; }
.trophy-desc { font-size: .9rem; color: var(--ink-soft); }
.trophy-date { font-size: .78rem; color: var(--green); margin-top: 6px; font-weight: 700; }

/* ---- leaderboard --------------------------------------------------------- */
.goal-card { display: flex; gap: 8px; align-items: center; background: linear-gradient(120deg, #fff, #f3fff8); font-weight: 700; }
.board { list-style: none; padding: 0; margin: 0; }
.board-row { display: flex; align-items: center; gap: 12px; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.board-row.me { border-color: var(--purple); background: #f7f4ff; box-shadow: var(--shadow-sm); }
.board-row.bot { opacity: .85; }
.board-place { font-size: 1.2rem; font-weight: 800; width: 42px; }
.board-avatar { font-size: 1.6rem; }
.board-name { flex: 1; font-weight: 800; }
.board-rank { color: var(--ink-soft); font-size: .85rem; }
.board-sparks { font-weight: 800; color: var(--orange); }

/* ---- parent panel -------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 10px; }
.statbox { background: #faf7ff; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.statbox-val { display: block; font-weight: 800; font-size: 1.15rem; }
.statbox-label { display: block; color: var(--ink-soft); font-size: .82rem; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.switch { width: 56px; height: 30px; border-radius: 999px; background: #ddd6ea; border: none; position: relative; cursor: pointer; transition: background .2s; }
.switch.on { background: var(--green); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: var(--shadow-sm); }
.switch.on .knob { left: 29px; }
.profile-list { margin: 8px 0 12px; }
.profile-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.profile-row-name { flex: 1; font-weight: 700; }
.profile-row.active { font-weight: 800; }
.tag { background: #eafaf1; color: var(--green); font-weight: 800; font-size: .78rem; padding: 2px 10px; border-radius: 999px; }
.export-box { width: 100%; min-height: 160px; font-family: var(--mono); font-size: .82rem; border-radius: 12px; border: 2px solid var(--line); padding: 10px; }
.voice-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.voice-select { font-family: inherit; font-size: .95rem; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: #fff; max-width: 260px; }
.voice-note { font-size: .82rem; margin: 8px 0 0; }
.parent-link { text-align: center; margin-top: 20px; }

/* ---- onboarding / inputs ------------------------------------------------- */
.onboard { text-align: center; }
.onboard-bot { font-size: 3.4rem; margin: 0; animation: bob 3s ease-in-out infinite; }
.onboard-hi { font-weight: 800; font-size: 1.25rem; margin: 4px 0; }
.field-label { display: block; text-align: left; font-weight: 800; margin: 14px 0 6px; color: var(--ink-soft); }
.text-input { width: 100%; font-family: inherit; font-size: 1.15rem; padding: 12px 16px; border-radius: var(--radius); border: 2px solid var(--line); outline: none; }
.text-input:focus { border-color: var(--purple); }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-opt { font-size: 1.7rem; width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.avatar-opt.sel { border-color: var(--purple); background: #f3efff; box-shadow: 0 0 0 3px #ece6ff; }
.profile-pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; margin: 6px 0; border-radius: var(--radius); border: 2px solid var(--line); background: #fff; cursor: pointer; font-family: inherit; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.profile-pick.active { border-color: var(--purple); background: #f7f4ff; }

/* ---- modals & popups ----------------------------------------------------- */
.overlay-root { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
.modal-back {
  position: fixed; inset: 0; background: rgba(43,36,64,.45); display: grid; place-items: center;
  padding: 20px; opacity: 0; transition: opacity .2s ease; pointer-events: auto; z-index: 210;
}
.modal-back.show { opacity: 1; }
.modal { position: relative; max-width: 480px; width: 100%; transform: translateY(10px); transition: transform .2s ease; }
.modal-back.show .modal { transform: translateY(0); }
.modal-title { margin-top: 0; }
.modal-x { position: absolute; top: 10px; right: 10px; padding: 4px 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.pop {
  background: #fff; border-radius: var(--radius-lg); padding: 26px 28px; text-align: center;
  max-width: 380px; box-shadow: var(--shadow); transform: scale(.9); transition: transform .25s cubic-bezier(.2,1.3,.5,1);
}
.modal-back.show .pop { transform: scale(1); }
.pop-emoji { font-size: 3rem; }
.pop-emoji.big-emoji { font-size: 4rem; animation: pop .5s; }
.pop h3 { margin: 6px 0; font-size: 1.5rem; }
.pop-rank { font-weight: 800; color: var(--purple); }
.pop-kicker { font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: .04em; font-size: .82rem; margin: 0; }
.pop-bonus { font-weight: 800; color: var(--orange); }

/* ---- toasts -------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-weight: 800; box-shadow: var(--shadow); opacity: 0; transition: all .3s ease;
  pointer-events: none; z-index: 220; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-spark { background: linear-gradient(120deg, #ff9a3c, #ff6f91); }
.toast-info { background: #4a4368; }

/* ---- mascot bubble ------------------------------------------------------- */
.mascot-bubble {
  position: fixed; left: 18px; bottom: 22px; background: #fff; border: 2px solid var(--line);
  border-radius: 18px; padding: 12px 18px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); max-width: 320px; font-weight: 700; transform: translateY(20px);
  opacity: 0; transition: all .35s ease; pointer-events: none; z-index: 220;
}
.mascot-bubble.show { transform: translateY(0); opacity: 1; }
.mascot-face { font-size: 1.8rem; }

/* ---- creed --------------------------------------------------------------- */
.creed { display: block; background: #f3fff8; border: 2px dashed var(--green); border-radius: var(--radius); padding: 12px 16px; margin: 16px 0; color: #2b6b4a; }
.creed-label { font-weight: 800; }

/* ---- confetti ------------------------------------------------------------ */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 215; }
.confetti i {
  position: absolute; top: -16px; width: 11px; height: 16px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(-10px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

/* ---- little animations --------------------------------------------------- */
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---- explainer (talking mascot) ------------------------------------------ */
.teach { margin-top: 8px; }
.explainer { border-radius: var(--radius-lg); background: linear-gradient(180deg, #faf7ff, #fff); border: 2px solid var(--line); padding: 14px; }
.ex-head { display: flex; align-items: flex-start; gap: 12px; }
.ex-face {
  font-size: 2.6rem; flex: none; width: 60px; height: 60px; display: grid; place-items: center;
  background: #fff; border-radius: 50%; border: 3px solid var(--purple); box-shadow: var(--shadow-sm);
}
.ex-face.talk { animation: talk .5s ease-in-out infinite; }
.ex-bubble-wrap { position: relative; flex: 1; }
.ex-bubble {
  background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px;
  font-size: 1.12rem; min-height: 30px; opacity: 0; transform: translateY(6px) scale(.99);
  transition: opacity .18s ease, transform .18s ease;
}
.ex-bubble.show { opacity: 1; transform: none; }
.ex-tail { position: absolute; left: -8px; top: 18px; width: 0; height: 0;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-right: 10px solid #fff;
  filter: drop-shadow(-2px 0 0 var(--line)); }
.ex-ctrls { display: flex; flex-direction: column; gap: 6px; flex: none; }
.ex-ctrl { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: #fff; cursor: pointer; font-size: 1.1rem; }
.ex-ctrl:hover { border-color: var(--purple); }
.ex-hint { text-align: center; color: var(--ink-soft); font-size: .85rem; margin-top: 10px; }

/* understanding check (Sparky pauses after each sentence) */
.ex-progress { text-align: center; color: var(--ink-soft); font-size: .82rem; margin: 8px 0 4px; font-weight: 700; }
.ex-ask-bar { text-align: center; margin-top: 6px; min-height: 10px; }
.ex-ask-bar.show { animation: dropin .25s; }
.ex-ask-q-text { font-weight: 800; font-size: 1.05rem; margin-bottom: 8px; }
.ex-ask-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ex-speaking { color: var(--ink-soft); font-style: italic; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.ready-pulse { animation: readypulse 1.1s ease-in-out infinite; }
@keyframes readypulse { 0%,100% { box-shadow: 0 0 0 0 rgba(155,140,255,.5); } 50% { box-shadow: 0 0 0 8px rgba(155,140,255,0); } }

.ex-stage { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; min-height: 96px; padding: 14px 6px 4px; justify-content: center; }
.ex-stage:empty { min-height: 0; padding: 0; }

/* pretend "screen" */
.ex-screen { background: #12101f; border-radius: 14px; overflow: hidden; min-width: 200px; box-shadow: var(--shadow-sm); }
.ex-screen-bar { background: #2b2440; color: #cfc7e6; font-family: var(--mono); font-size: .72rem; padding: 5px 12px; }
.ex-screen-body { padding: 10px 14px; min-height: 36px; font-family: var(--mono); color: #d7ffe6; font-size: 1rem; }
.ex-screen-line { white-space: pre-wrap; }
.ex-screen-line.ex-typed { animation: dropin .25s; }

/* a line of code, shown like an editor line, so kids connect CODE -> OUTPUT.
   Code is amber; the screen output below it is green — two clearly different things. */
.ex-code {
  display: flex; align-items: center; gap: 10px;
  background: #1b1830; border: 2px solid #2b2440; border-radius: 12px;
  padding: 8px 12px; box-shadow: var(--shadow-sm); min-width: 200px;
}
.ex-code-tag {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase;
  color: #2b2440; background: var(--yellow); border-radius: 999px; padding: 2px 8px; font-weight: 800;
}
.ex-code-text { font-family: var(--mono); color: #ffd27a; font-size: 1rem; white-space: pre-wrap; }

.ex-mega { font-size: 2.6rem; }
.ex-fly {
  position: absolute; background: var(--yellow); color: var(--ink); font-weight: 800;
  padding: 4px 12px; border-radius: 999px; box-shadow: var(--shadow-sm); animation: fly .65s ease forwards;
}
.ex-box { background: #fff; border: 3px solid var(--orange); border-radius: 14px; padding: 8px 12px; min-width: 120px; text-align: center; }
.ex-box-label { display: block; font-weight: 800; color: #b9821f; font-size: .85rem; }
.ex-box-slot { display: flex; min-height: 34px; align-items: center; justify-content: center; }
.ex-val { background: var(--blue); color: #fff; font-family: var(--mono); font-weight: 800; padding: 4px 12px; border-radius: 10px; }

.ex-math { font-family: var(--mono); font-size: 1.5rem; font-weight: 800; display: flex; align-items: center; gap: 4px; }
.ex-tile { background: var(--purple); color: #fff; border-radius: 10px; padding: 4px 12px; }
.ex-result { background: var(--green); }
.ex-op { color: var(--ink-soft); }

.ex-ask { display: flex; align-items: center; gap: 8px; background: #eef7ff; border: 2px solid var(--blue); border-radius: 14px; padding: 8px 14px; font-weight: 700; }
.ex-ask-bot { font-size: 1.5rem; }
.ex-answer .ex-ans-chip { background: var(--green); color: #fff; font-weight: 800; padding: 6px 14px; border-radius: 999px; }

.ex-fork { text-align: center; }
.ex-cond { font-weight: 800; background: #fff3da; border: 2px solid var(--orange); border-radius: 10px; padding: 4px 14px; display: inline-block; margin-bottom: 8px; }
.ex-branches { display: flex; gap: 12px; justify-content: center; }
.ex-branch { padding: 8px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 700; transition: all .25s; }
.ex-branch.chosen { border-color: var(--green); background: #eafaf1; transform: scale(1.06); box-shadow: var(--shadow-sm); }
.ex-branch.dim { opacity: .4; }

.ex-counter { text-align: center; }
.ex-count-num { font-size: 2rem; font-weight: 800; color: var(--purple); font-family: var(--mono); }
.ex-count-acts { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; min-height: 32px; }
.ex-act { font-size: 1.6rem; }
.ex-big-emoji { font-size: 3rem; }

@keyframes talk { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
@keyframes fly { 0% { transform: translate(0,0) scale(.8); opacity: 0; left: 10%; top: 8px; }
  30% { opacity: 1; } 100% { transform: translate(40px, 40px) scale(1); opacity: 0; left: 50%; top: 40px; } }
.pop-in { animation: pop .4s cubic-bezier(.2,1.3,.5,1); }
.drop-in { animation: dropin .4s cubic-bezier(.2,1.3,.5,1); }
@keyframes dropin { 0% { transform: translateY(-22px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

/* ---- watch it run (line-by-line) ----------------------------------------- */
.replay-host { margin-top: 12px; }
.replayrun { border: 2px solid var(--purple); border-radius: var(--radius); overflow: hidden; background: #fff; }
.rr-head { display: flex; align-items: center; justify-content: space-between; background: #f3efff; padding: 8px 12px; }
.rr-title { font-weight: 800; color: var(--purple); }
.rr-body { display: flex; gap: 0; flex-wrap: wrap; }
.rr-code { flex: 1 1 240px; background: #1f1933; padding: 10px 0; font-family: var(--mono); font-size: .98rem; }
.rr-line { display: flex; gap: 10px; padding: 2px 12px; color: #b9b1d6; transition: background .15s, color .15s; }
.rr-line.active { background: rgba(155,140,255,.28); color: #fff; }
.rr-gutter { color: #6a6294; width: 18px; text-align: right; flex: none; }
.rr-text { white-space: pre; }
.rr-screen { flex: 1 1 200px; background: #12101f; }
.rr-screen-bar { background: #2b2440; color: #cfc7e6; font-family: var(--mono); font-size: .72rem; padding: 6px 12px; }
.rr-screen-body { padding: 10px 14px; min-height: 60px; font-family: var(--mono); color: #d7ffe6; }
.rr-out-line { white-space: pre-wrap; animation: dropin .25s; }

/* ---- reduced motion ------------------------------------------------------ */
body.reduce-motion * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.small-note { font-size: .85rem; margin-top: 8px; }

/* ---- Sparky's Workshop --------------------------------------------------- */
/* Map launch card */
.workshop-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 2px dashed var(--purple); background: linear-gradient(100deg, #fff, #f6f2ff);
  cursor: pointer; margin: 0 0 18px; transition: transform .12s, box-shadow .12s;
}
.workshop-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.workshop-emoji { font-size: 2.2rem; }
.workshop-text { flex: 1; }
.workshop-title { font-weight: 800; font-size: 1.15rem; color: var(--ink); margin: 0; }
.workshop-sub { color: var(--ink-soft); margin: 2px 0 0; }
.workshop-go { font-weight: 800; color: var(--purple); white-space: nowrap; }

/* Sparky intro bubble */
.ws-bubble {
  display: flex; align-items: flex-start; gap: 10px; background: var(--card);
  border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
}
.ws-face { font-size: 1.8rem; line-height: 1; }
.ws-face.small { font-size: 1.4rem; }
.ws-say { color: var(--ink); }

/* Idea chips */
.ws-ideas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.ws-ideas-label { color: var(--ink-soft); font-weight: 700; }
.ws-chip {
  font: inherit; font-weight: 700; cursor: pointer; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px;
  transition: transform .1s, border-color .1s;
}
.ws-chip:hover { transform: translateY(-1px); border-color: var(--purple); }

.ws-editor { min-height: 220px; }

/* Answers-for-input box */
.ws-answers-wrap { margin: 10px 0 0; }
.ws-answers-label { display: block; font-weight: 700; color: var(--ink-soft); margin-bottom: 4px; }
.ws-answers {
  width: 100%; font-family: var(--mono); font-size: .95rem; padding: 8px 10px;
  border: 2px solid var(--line); border-radius: 12px; resize: vertical; box-sizing: border-box;
}

/* Sparky's coaching cards */
.ws-coach { margin-top: 12px; }
.ws-coach-card {
  display: flex; align-items: flex-start; gap: 10px; border-radius: var(--radius);
  padding: 12px 14px; border: 2px solid var(--line); animation: dropin .25s;
}
.ws-coach-card.win  { background: #f0fff7; border-color: #b6ebcf; }
.ws-coach-card.oops { background: #fff4f6; border-color: #f6c9d2; }
.ws-coach-head { font-weight: 800; color: var(--ink); margin: 0 0 4px; }
.ws-tip { margin: 6px 0 0; color: var(--ink); }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .brand-name { display: none; }
  .main { padding: 14px 12px 70px; }
  .lesson-node { width: calc(50% - 6px); }
  .banner { flex-direction: column; text-align: center; }
  .level-pill { min-width: 110px; }
  .workshop-card { flex-direction: column; text-align: center; }
}
