:root {
  color-scheme: light;
  --ink: #18212f;
  --ink-soft: #2d3748;
  --muted: #5d6a7b;
  --paper: #f6f4ee;
  --paper-warm: #fbf6e7;
  --panel: #ffffff;
  --line: #d9e0e7;
  --line-soft: #e8ecf1;
  --green: #16846d;
  --green-soft: #d4ece4;
  --blue: #2f6fbd;
  --blue-soft: #dbe7f5;
  --red: #c94e4e;
  --red-soft: #f6dada;
  --yellow: #e7b63c;
  --yellow-soft: #faecbe;
  --purple: #7a5cc0;
  --purple-soft: #e5dcf5;
  --shadow-1: 0 6px 18px rgba(24, 33, 47, 0.08);
  --shadow-2: 0 18px 45px rgba(24, 33, 47, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

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

body {
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% -10%, rgba(231, 182, 60, 0.18), transparent 45%),
    radial-gradient(circle at 95% 10%, rgba(47, 111, 189, 0.12), transparent 40%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ===== Focus rings (a11y) ===== */
*:focus { outline: none; }
*:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: inherit;
}
a:focus-visible, button:focus-visible, .vocab-chip:focus-visible, .nav-link:focus-visible, .back:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 1px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ===== Header ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 0 rgba(24,33,47,0.06));
}

.nav { display: flex; gap: 4px; }
.nav-link {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}
.nav-link:hover { color: var(--ink); background: rgba(24,33,47,0.05); }
.nav-link.grownup { color: var(--purple); }

/* ===== Footer ===== */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(14px, 3vw, 28px);
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.6);
}

.footer-name { font-weight: 700; color: var(--ink-soft); }

/* ===== Main / views ===== */
main {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px) 0 clamp(24px, 4vw, 48px);
}

/* ===== Home ===== */
.hero {
  text-align: center;
  margin-bottom: clamp(20px, 4vw, 36px);
}
.eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: #6d4c0e;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 7vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.lead {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  max-width: 600px;
  margin: 0 auto;
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.mission-card {
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.mission-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.mission-card[data-tone="vibration"] { background: linear-gradient(180deg, #fff, var(--yellow-soft)); }
.mission-card[data-tone="pitch"] { background: linear-gradient(180deg, #fff, var(--blue-soft)); }
.mission-card[data-tone="volume"] { background: linear-gradient(180deg, #fff, var(--red-soft)); }
.mission-card[data-tone="medium"] { background: linear-gradient(180deg, #fff, var(--green-soft)); }

.mission-num {
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.mission-card h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}
.mission-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.mission-card .emoji {
  font-size: 2.4rem;
  line-height: 1;
  position: absolute;
  right: 16px;
  top: 16px;
  filter: drop-shadow(0 2px 0 rgba(24,33,47,0.05));
}
.mission-card .progress {
  margin-top: auto;
  display: flex;
  gap: 4px;
}
.mission-card .progress span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(24,33,47,0.08);
}
.mission-card .progress span.done { background: var(--green); }

.extra-row {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.extra-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.extra-card strong { display: block; font-size: 1.05rem; }
.extra-card p { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; }
.extra-icon { font-size: 1.8rem; }

/* ===== Mission view ===== */
.mission-head {
  margin-bottom: 16px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 8px;
}
.back:hover { background: rgba(24,33,47,0.05); color: var(--ink); }

.mission-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
}
.mission-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 1.4rem;
}
.mission-badge[data-tone="vibration"] { background: var(--yellow-soft); }
.mission-badge[data-tone="pitch"] { background: var(--blue-soft); }
.mission-badge[data-tone="volume"] { background: var(--red-soft); }
.mission-badge[data-tone="medium"] { background: var(--green-soft); }

.mission-title { margin: 0; font-size: clamp(1.6rem, 3.5vw, 2.4rem); letter-spacing: -0.02em; }

.stages {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}
.stages li {
  text-align: center;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(24,33,47,0.05);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stages li[aria-current="step"] { background: var(--ink); color: #fff; }
.stages li.done { background: var(--green-soft); color: #0c5a4a; }

.vocab-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.vocab-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  transition: background .12s ease, border-color .12s ease;
}
.vocab-chip:hover { background: var(--paper-warm); }
.vocab-chip[aria-expanded="true"] {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
}

.vocab-popover {
  position: absolute;
  z-index: 90;
  background: var(--ink);
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.35;
  box-shadow: var(--shadow-2);
  max-width: calc(100vw - 16px);
  pointer-events: auto;
}
.vocab-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--ink);
  border-top: 0;
}

.stage-body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: clamp(16px, 3vw, 24px);
}

.stage-body h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}
.stage-body p { color: var(--ink-soft); line-height: 1.45; }

.stage-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  min-height: 44px;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn.primary:hover { background: #0d1320; }
.btn.ghost { background: transparent; }
.btn.accent { background: var(--green); border-color: var(--green); color: #fff; }
.btn.warn { background: var(--red); border-color: var(--red); color: #fff; }
.btn.subtle { background: rgba(24,33,47,0.05); border-color: transparent; color: var(--ink-soft); }

/* ===== Free Play lab ===== */
.lab-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.lab-head h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -0.02em; }
.lab-mode { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.lab-mode-btn {
  border: 0;
  background: #fff;
  padding: 8px 14px;
  font-weight: 700;
  color: var(--ink);
  border-right: 1px solid var(--line);
  min-height: 40px;
}
.lab-mode-btn:last-child { border-right: 0; }
.lab-mode-btn.active { background: var(--ink); color: #fff; }

.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.panel + .panel { margin-top: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 1.15rem; }
.panel h3 { margin: 14px 0 8px; font-size: 0.95rem; }

canvas {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  background: #f5f8fb;
  border: 1px solid var(--line-soft);
}

#waveCanvas { height: clamp(220px, 38vw, 380px); }
#particleCanvas { height: 140px; margin-top: 10px; }
#micWaveCanvas, #micFftCanvas { height: 160px; margin-bottom: 10px; }

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.metric {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fbfcfd;
}
.metric span { display: block; color: var(--muted); font-size: 0.72rem; }
.metric strong { font-size: 1.1rem; }

.control { display: grid; gap: 6px; margin: 10px 0; }
.control label {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 0.92rem;
}
.control label span { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
input[type="range"] { width: 100%; accent-color: var(--blue); }

.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.segmented button {
  border: 0; border-right: 1px solid var(--line);
  background: #fff; min-height: 40px; color: var(--ink);
  font-weight: 600;
}
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: var(--blue); color: #fff; }

.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.insight {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--yellow);
  background: var(--yellow-soft);
  border-radius: 6px;
  color: #533e0c;
  font-size: 0.92rem;
}

/* ===== Mic microscope ===== */
.mic-status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--red-soft); color: var(--red);
  font-size: 0.85rem; font-weight: 700;
}
.mic-status.live { background: var(--green-soft); color: #0c5a4a; }

/* ===== Notebook ===== */
.notebook {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 14px;
}
@media (max-width: 760px) { .notebook { grid-template-columns: 1fr; } }
.notebook table {
  width: 100%; border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.notebook th, .notebook td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.92rem;
}
.notebook th { background: #fafbfc; color: var(--muted); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.notebook tr:last-child td { border-bottom: 0; }
.notebook .graph-wrap { background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px; }
.notebook canvas { height: 220px; background: #fff; border: 0; }

.frame {
  background: var(--yellow-soft);
  border: 1px dashed var(--yellow);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.95rem;
  color: #533e0c;
  margin-top: 12px;
  line-height: 1.7;
}
.frame select, .frame input {
  border: 1px solid var(--yellow);
  background: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  margin: 0 2px;
  font-weight: 700;
}

/* ===== Quiz ===== */
.quiz-question {
  background: var(--blue-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
.quiz-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.quiz-options button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  min-height: 56px;
}
.quiz-options button.correct { background: var(--green-soft); border-color: var(--green); }
.quiz-options button.wrong { background: var(--red-soft); border-color: var(--red); }
.quiz-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}
.quiz-feedback.ok { background: var(--green-soft); color: #0c5a4a; }
.quiz-feedback.no { background: var(--red-soft); color: #6d2424; }

/* ===== Grown-up ===== */
.grownup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.grownup-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.grownup-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.grownup-card .stat { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.grownup-card .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.grownup-actions { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 19, 32, 0.55);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-2);
}
.modal h2 { margin: 0 0 4px; }
.modal p { color: var(--muted); margin: 0 0 14px; }
.modal input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.modal .btn { width: 100%; justify-content: center; }

/* ===== Hum-O-Meter (Mission 1 Explore) ===== */
.hum-card {
  background: linear-gradient(180deg, #fff, var(--purple-soft));
}
.hum-meter {
  position: relative;
  width: 64px;
  height: 180px;
  margin: 6px auto 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 0 2px 6px rgba(24,33,47,0.06);
  overflow: hidden;
}
.hum-meter-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, var(--blue), var(--green));
  border-radius: 0 0 11px 11px;
  transition: height 80ms linear, background 200ms ease;
}
.hum-meter-fill.loud {
  background: linear-gradient(180deg, var(--yellow), var(--red));
}
.hum-meter-threshold {
  position: absolute;
  left: 0; right: 0;
  bottom: 25%;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 10px);
  opacity: 0.5;
  pointer-events: none;
}
.insight.celebrate {
  border-left-color: var(--green);
  background: var(--green-soft);
  color: #0c5a4a;
  animation: humPulse 600ms ease;
}
@keyframes humPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ===== Vibration cards with Hear-it (Mission 1 Investigate) ===== */
.vib-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.hear-btn {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}
.hear-btn:active { transform: translateY(1px); }

/* ===== Bottle Xylophone (Mission 2 Pattern) ===== */
.xylo-card {
  background: linear-gradient(180deg, #fff, var(--blue-soft));
}
.xylo-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
}
.xylo-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  align-items: end;
  padding: 12px 6px;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  min-height: 180px;
}
.xylo-bottle {
  background: transparent;
  border: 0;
  padding: 4px 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.xylo-glass {
  position: relative;
  width: 100%;
  max-width: 38px;
  height: 130px;
  border: 2px solid var(--ink);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.4), rgba(218, 232, 244, 0.4));
  overflow: hidden;
  box-shadow: inset 0 -3px 6px rgba(24,33,47,0.08);
}
.xylo-water {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(47, 111, 189, 0.55), rgba(47, 111, 189, 0.85));
  border-top: 2px solid rgba(47, 111, 189, 0.9);
  transition: height 120ms ease;
}
.xylo-note {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--paper-warm);
  border-radius: 6px;
  padding: 2px 6px;
}
.xylo-bottle:hover .xylo-glass { box-shadow: inset 0 -3px 6px rgba(24,33,47,0.08), 0 0 0 3px var(--blue-soft); }
.xylo-bottle.ringing .xylo-glass {
  animation: xyloRing 380ms ease;
  box-shadow: inset 0 -3px 6px rgba(24,33,47,0.08), 0 0 0 3px var(--yellow);
}
@keyframes xyloRing {
  0% { transform: translateY(0); }
  30% { transform: translateY(-4px) rotate(-1.5deg); }
  60% { transform: translateY(0) rotate(1deg); }
  100% { transform: translateY(0); }
}

/* ===== Mission 3 — walk away from speaker ===== */
.walkaway-card { background: linear-gradient(180deg, #fff, var(--red-soft)); }
.walkaway-card canvas { background: #f5f8fb; cursor: grab; }
.walkaway-card canvas:active { cursor: grabbing; }

/* ===== Mission 3 — misconception buster ===== */
.mb-card { background: linear-gradient(180deg, #fff, var(--blue-soft)); }
.mb-card canvas { background: #fff; }
.mb-challenge {
  background: var(--blue-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.mb-success {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--green-soft);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  color: #0c5a4a;
  font-weight: 700;
  font-size: 1rem;
}

/* ===== Mission 4 — vacuum jar wrap & pump tip ===== */
.jar-wrap { position: relative; }
.jar-wrap canvas { cursor: pointer; }
.pump-tip {
  position: absolute;
  right: 12px;
  top: 12px;
  max-width: 220px;
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  animation: pumpTipIn 0.25s ease;
}
.pump-tip::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--ink);
}
@keyframes pumpTipIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Mission 4 — string telephone ===== */
.phone-card { background: linear-gradient(180deg, #fff, var(--green-soft)); }
.phone-card canvas { background: #fbfcfd; }

/* ===== Mission 4 — astronaut scene ===== */
.astro-card { background: linear-gradient(180deg, #fff, #e3e8f0); }
.astro-card canvas { background: #0d1320; }

/* ===== Hint box ===== */
.hint-box {
  margin-bottom: 12px;
}
.hint-toggle {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  color: var(--ink-soft);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hint-toggle:hover { background: var(--yellow-soft); border-color: var(--yellow); }
.hint-toggle[aria-expanded="true"] { background: var(--yellow-soft); border-color: var(--yellow); color: #533e0c; }

.hint-panel {
  margin-top: 10px;
  background: var(--paper-warm);
  border: 1px dashed var(--yellow);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  animation: hintSlide 220ms ease;
}
@keyframes hintSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hint-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 8px;
}
.hint-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #533e0c;
}
.hint-label {
  background: #fff;
  border: 1px solid var(--yellow);
  color: #6d4c0e;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.hint-item.hint-tier-2 .hint-label { background: var(--yellow-soft); }
.hint-item.hint-tier-3 .hint-label { background: var(--yellow); color: #fff; }

.hint-actions { display: flex; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .hint-panel { animation: none; }
}

/* ===== Badge row & pills ===== */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 18px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.badge-row-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow-1);
}
.badge-pill-emoji { font-size: 1.15rem; line-height: 1; }
.badge-pill-name { color: var(--ink-soft); }

.mission-card-badge {
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== Continue-where-you-left-off banner ===== */
.continue-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff, var(--blue-soft));
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  margin: 0 0 18px;
  box-shadow: var(--shadow-1);
  transition: transform .12s ease, box-shadow .12s ease;
}
.continue-banner:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.continue-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.continue-text { flex: 1; min-width: 0; }
.continue-text strong { display: block; font-size: 1rem; }
.continue-text p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.85rem; text-transform: capitalize; }
.continue-arrow {
  font-size: 1.4rem;
  color: var(--blue);
  font-weight: 800;
  flex-shrink: 0;
}

/* ===== Celebration overlay ===== */
.celebrate-backdrop {
  background: rgba(13, 19, 32, 0.65);
  animation: celebFadeIn 240ms ease;
}
.celebrate-modal {
  position: relative;
  text-align: center;
  max-width: 380px;
  overflow: visible;
  padding-top: 18px;
}
.celebrate-eyebrow {
  background: var(--green-soft);
  color: #0c5a4a;
  margin: 4px 0 8px;
}
.celebrate-badge {
  font-size: 4.4rem;
  line-height: 1;
  display: block;
  margin: 6px auto 6px;
  animation: badgePop 600ms cubic-bezier(.2, .9, .3, 1.4);
}
.celebrate-modal h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.celebrate-blurb {
  margin: 0 0 16px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.celebrate-close { width: 100%; justify-content: center; }

.sparkle-layer {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}
.sparkle {
  position: absolute;
  width: 14px;
  height: 14px;
  background:
    radial-gradient(circle, var(--yellow) 0 30%, transparent 32%),
    linear-gradient(90deg, transparent 45%, var(--yellow) 45% 55%, transparent 55%) center/100% 2px no-repeat,
    linear-gradient(0deg, transparent 45%, var(--yellow) 45% 55%, transparent 55%) center/2px 100% no-repeat;
  border-radius: 50%;
  opacity: 0;
  animation: sparkleTwinkle 1.8s ease-in-out infinite;
}
.sparkle:nth-child(1) { top: 4%;  left: 8%;  animation-delay: 0s;   }
.sparkle:nth-child(2) { top: 12%; right: 6%; animation-delay: 0.2s; background-color: var(--blue);   }
.sparkle:nth-child(3) { top: 40%; left: 2%;  animation-delay: 0.4s; }
.sparkle:nth-child(4) { top: 60%; right: 4%; animation-delay: 0.6s; }
.sparkle:nth-child(5) { bottom: 8%; left: 10%; animation-delay: 0.8s; }
.sparkle:nth-child(6) { bottom: 14%; right: 12%; animation-delay: 1.0s; }
.sparkle:nth-child(7) { top: 50%; right: 24%; animation-delay: 1.2s; }
.sparkle:nth-child(8) { top: 28%; left: 22%;  animation-delay: 0.5s; }

@keyframes celebFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes badgePop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes sparkleTwinkle {
  0%, 100% { opacity: 0; transform: scale(0.6) rotate(0deg); }
  50% { opacity: 1; transform: scale(1) rotate(45deg); }
}

.celebrate-modal.no-motion .celebrate-badge,
.celebrate-modal.no-motion .sparkle,
.no-motion .celebrate-modal .celebrate-badge,
.no-motion .celebrate-modal .sparkle,
.celebrate-backdrop.no-motion,
.no-motion.celebrate-backdrop {
  animation: none !important;
}
.celebrate-backdrop.no-motion { animation: none !important; }
.no-motion .sparkle { opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  .celebrate-backdrop { animation: none; }
  .celebrate-badge { animation: none; }
  .sparkle { animation: none; opacity: 0.6; }
}

/* ===== Grown-up additions ===== */
.grownup-badges {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.grownup-badges h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}
.grownup-settings {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.grownup-settings h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}
.setting-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
}
.setting-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--green);
  flex-shrink: 0;
}
.setting-row .setting-hint {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 920px) {
  .lab-grid { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .stages { grid-template-columns: repeat(5, 1fr); font-size: 0.62rem; }
  .stages li { padding: 4px 2px; }
  .readout { grid-template-columns: 1fr 1fr; }
  .nav-link { padding: 6px 8px; font-size: 0.85rem; }
  .xylo-row { gap: 3px; padding: 8px 4px; }
  .xylo-glass { max-width: 30px; height: 110px; }
  .xylo-note { font-size: 0.7rem; padding: 2px 4px; }
  .celebrate-badge { font-size: 3.6rem; }
  .badge-row { padding: 8px 10px; }
  .continue-banner { padding: 12px 14px; gap: 10px; }
}
