:root {
  color-scheme: light;
  --ink: #16213e;
  --muted: #526173;
  --paper: #fffdf7;
  --panel: #ffffff;
  --line: #d8e1ea;
  --blue: #118ab2;
  --green: #06d6a0;
  --yellow: #ffd166;
  --pink: #ef476f;
  --purple: #7c3aed;
  --skin-line: #a95f3f;
  --shadow: 0 16px 40px rgba(22, 33, 62, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 209, 102, 0.18), transparent 28%),
    radial-gradient(circle at 90% 16%, rgba(6, 214, 160, 0.14), transparent 30%),
    linear-gradient(135deg, #fbfdff 0%, #fffdf8 58%, #f7fbff 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 44px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 54px;
  padding: 4px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.brand-lockup,
.header-action,
.primary-link,
.secondary-link {
  color: inherit;
  text-decoration: none;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 8px 14px rgba(17, 138, 178, 0.18));
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup strong {
  font-size: 1rem;
  font-weight: 900;
}

.brand-lockup small {
  max-width: 300px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.settings-button:hover,
.settings-button.is-open {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--ink);
}

.settings-button.is-open {
  background: #fff8df;
}

.settings-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.header-action,
.primary-link,
.secondary-link {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 8px 13px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.header-action,
.secondary-link {
  background: #ffffff;
}

.primary-link {
  background: var(--green);
}

.header-action:hover,
.primary-link:hover,
.secondary-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--ink);
}

.settings-panel {
  max-width: 560px;
  margin: -36px 0 38px auto;
  padding: 14px;
  border: 2px solid rgba(22, 33, 62, 0.52);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 28px rgba(22, 33, 62, 0.09);
}

.settings-panel[hidden] {
  display: none;
}

.settings-form {
  display: grid;
  gap: 9px;
}

.settings-form label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.key-row input,
.settings-form select {
  min-width: 0;
  height: 42px;
  border: 2px solid rgba(22, 33, 62, 0.7);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 750;
}

.settings-form select {
  width: 100%;
}

.key-row button {
  min-height: 42px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: var(--green);
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 900;
}

.saved-key-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 34px;
  padding: 6px 9px;
  border: 2px solid rgba(22, 33, 62, 0.28);
  border-radius: 8px;
  background: #e8fff8;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.saved-key-chip[hidden] {
  display: none;
}

.saved-key-chip span {
  color: var(--muted);
}

.saved-key-chip strong {
  letter-spacing: 0.04em;
}

.settings-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.settings-tip {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.4;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-weight: 900;
}

.home-hero {
  display: block;
  min-height: 0;
  padding: 0 0 32px;
}

.hero-copy h1 {
  margin: 0;
  max-width: 11ch;
  font-size: clamp(2.75rem, 6.4vw, 4.85rem);
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-copy p {
  max-width: 560px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: #37637a;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-showcase {
  display: none;
  place-items: center;
  width: 178px;
  min-height: 150px;
  justify-self: end;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(22, 33, 62, 0.08);
  text-align: center;
}

.hero-showcase span,
.hero-showcase small {
  color: var(--muted);
  font-weight: 800;
}

.hero-showcase strong {
  color: var(--pink);
  font-size: 3.4rem;
  line-height: 1;
  font-weight: 950;
}

.hero-showcase small {
  font-size: 0.76rem;
}

.lesson-gallery {
  scroll-margin-top: 92px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 2px 0 38px;
}

.lesson-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 136px;
  padding: 18px;
  border: 2px solid rgba(22, 33, 62, 0.52);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 26px rgba(22, 33, 62, 0.08);
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.lesson-card:hover,
.lesson-card.is-active {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(22, 33, 62, 0.12);
}

.lesson-card.main-lesson {
  grid-column: 1 / -1;
  min-height: 150px;
  background: linear-gradient(135deg, #ffffff, #eafff8);
}

.app-shell.is-learning .lesson-card.is-active {
  background: #fff8df;
}

.lesson-number {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(22, 33, 62, 0.9);
  border-radius: 8px;
  background: var(--yellow);
  color: var(--pink);
  font-size: 1.7rem;
  font-weight: 950;
}

.lesson-copy {
  min-width: 0;
}

.lesson-copy strong,
.lesson-copy small {
  display: block;
}

.lesson-copy strong {
  font-size: 1.05rem;
  font-weight: 950;
}

.lesson-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
}

.lesson-cta {
  grid-column: 1 / -1;
  align-self: end;
  justify-self: start;
  min-height: 34px;
  padding: 6px 10px;
  border: 2px solid rgba(22, 33, 62, 0.9);
  border-radius: 8px;
  background: var(--green);
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 950;
}

.control-strip,
.stage-tabs {
  display: grid;
  gap: 10px;
}

.control-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 34px 0 16px;
}

.app-shell:not(.is-learning) .control-strip,
.app-shell:not(.is-learning) .mission-card {
  display: none;
}

.stage-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.factor-tab,
.stage-tab,
.secondary-button,
.lesson-actions button,
.answer-row button,
.quick-pad button {
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 850;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.factor-tab:hover:not(:disabled),
.stage-tab:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.lesson-actions button:hover:not(:disabled),
.answer-row button:hover:not(:disabled),
.quick-pad button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.factor-tab.is-active,
.stage-tab.is-active {
  background: var(--yellow);
}

.mission-card {
  scroll-margin-top: 92px;
  min-width: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow);
  padding: 20px;
}

.mission-header,
.stage-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.mission-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.voice-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: #fff8df;
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 900;
}

.voice-button.is-on {
  background: var(--green);
}

.ghost-voice {
  background: #ffffff;
}

.voice-status {
  align-self: center;
  max-width: 180px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

h2,
h3 {
  margin: 4px 0 0;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.7rem, 4vw, 2.75rem);
}

h3 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.score-card,
.stage-count {
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  box-shadow: 0 4px 0 var(--ink);
  text-align: center;
  font-weight: 900;
}

.score-card {
  min-width: 92px;
  padding: 10px 12px;
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-card strong {
  font-size: 2rem;
  line-height: 1;
}

.stage-count {
  padding: 8px 11px;
}

.stage {
  display: none;
  margin-top: 20px;
}

.stage.is-active {
  display: block;
}

.trick-intro {
  max-width: 66ch;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.trick-visual {
  margin: 14px 0;
}

.focus-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 104px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff8df;
}

.focus-text {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.lesson-actions,
.practice-actions,
.answer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.lesson-actions button:not(.secondary-button),
.answer-row button {
  background: var(--green);
}

.hands-wrap {
  display: grid;
  gap: 10px;
}

.anchor-anim {
  display: grid;
  gap: 12px;
}

.anchor-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #f9fcff;
}

.anchor-block {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 110px;
  padding: 12px;
  border: 2px solid rgba(22, 33, 62, 0.8);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
  font-weight: 900;
}

.anchor-block span,
.anchor-block small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.anchor-block strong {
  color: var(--ink);
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
}

.dot-stack {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-height: 44px;
  margin: 3px auto;
}

.dot-group {
  display: flex;
  justify-content: center;
  gap: 3px;
  min-height: 9px;
}

.dot-group i {
  display: block;
  width: 7px;
  height: 7px;
  border: 1px solid rgba(22, 33, 62, 0.58);
  border-radius: 50%;
  background: #ffffff;
}

.anchor-dots .dot-group i {
  background: var(--yellow);
}

.extra-dots .dot-group i {
  background: var(--green);
}

.answer-dots .dot-group i {
  background: #ff9fbd;
}

.base-block {
  background: #fff8df;
}

.extra-block {
  background: #e8fff8;
}

.answer-block {
  background: #fff0f4;
}

.anchor-operator,
.anchor-equals {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #ffffff;
  color: var(--pink);
  font-size: 1.5rem;
  font-weight: 950;
}

.anchor-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff8df;
  font-weight: 900;
}

.anchor-chips span,
.anchor-chips strong {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 5px 9px;
  border-radius: 8px;
}

.anchor-chips strong {
  min-width: 42px;
  border: 2px solid var(--ink);
  background: #ffffff;
  color: var(--pink);
}

.anchor-phase-0 .anchor-board {
  grid-template-columns: 1fr;
}

.anchor-phase-0 .extra-block,
.anchor-phase-0 .answer-block,
.anchor-phase-0 .anchor-operator,
.anchor-phase-0 .anchor-equals,
.anchor-phase-0 .anchor-chips,
.anchor-phase-1 .answer-block,
.anchor-phase-1 .anchor-equals {
  display: none;
}

.anchor-phase-1 .anchor-board {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.anchor-phase-1 .extra-block,
.anchor-phase-1 .anchor-operator {
  animation: tilePulse 1.8s ease-in-out infinite;
}

.anchor-phase-1 .extra-dots .dot-group {
  animation: groupPop 1.8s ease-in-out infinite;
  animation-delay: calc(var(--row, 0) * 80ms);
}

.anchor-phase-2 .answer-block {
  animation: answerPop 1.8s ease-in-out infinite;
}

.anchor-phase-2 .answer-dots .dot-group {
  animation: groupPop 2s ease-in-out infinite;
}

.visual-problem {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff8df;
  font-weight: 900;
}

.visual-problem strong {
  color: var(--pink);
  font-size: 1.3rem;
}

.hands-svg {
  display: block;
  width: 100%;
  max-height: 320px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(135deg, #f9fcff, #eafbf5);
}

.hand-guides text {
  fill: var(--ink);
  font-size: 24px;
  font-weight: 900;
  text-anchor: middle;
}

.hand-phase-0 .hand-guides,
.hand-phase-0 .motion-cues,
.hand-phase-0 .count-strip,
.hand-phase-1 .hand-guides,
.hand-phase-1 .count-strip {
  display: none;
}

.hand-phase-0 .finger-shape {
  animation: numberPop 2.4s ease-in-out infinite;
  animation-delay: var(--delay);
}

.hand-phase-0 .finger-shape.folded {
  animation: numberPop 2.4s ease-in-out infinite;
  animation-delay: var(--delay);
}

.hand-phase-1 .finger-shape.left-count,
.hand-phase-1 .finger-shape.right-count {
  animation: none;
}

.hand-phase-1 .finger-shape.folded {
  animation: foldedPulse 2.2s ease-in-out infinite;
}

.count-zone {
  fill: rgba(255, 209, 102, 0.14);
  stroke: rgba(22, 33, 62, 0.18);
  stroke-width: 3;
}

.left-zone {
  animation: countZone 4.8s ease-in-out infinite;
}

.right-zone {
  animation: countZone 4.8s ease-in-out 1.7s infinite;
}

.noun-hand path {
  fill: url(#skin);
  stroke: var(--skin-line);
  stroke-linejoin: round;
  stroke-width: 1.25;
}

.finger-shape {
  filter: drop-shadow(0 6px 6px rgba(22, 33, 62, 0.12));
}

.finger-shape.left-count {
  animation: fingerPulse 4.8s ease-in-out infinite;
  animation-delay: calc(0.6s + var(--delay));
}

.finger-shape.right-count {
  animation: fingerPulse 4.8s ease-in-out infinite;
  animation-delay: calc(2.1s + var(--delay));
}

.finger-shape.folded {
  animation: foldedPulse 4.8s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.finger-shape circle {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 3;
}

.finger-shape.folded circle {
  fill: var(--pink);
}

.finger-shape text {
  fill: var(--ink);
  font-size: 22px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
}

.finger-shape.folded text {
  fill: #ffffff;
}

.fold-arrow {
  fill: none;
  stroke: var(--pink);
  stroke-dasharray: 10 10;
  stroke-linecap: round;
  stroke-width: 7;
  animation: arrowDash 1.8s linear infinite;
}

.fold-label {
  fill: var(--pink);
  font-size: 20px;
  font-weight: 900;
  text-anchor: middle;
  animation: labelPop 4.8s ease-in-out infinite;
}

.fold-target {
  fill: rgba(239, 71, 111, 0.16);
  stroke: var(--pink);
  stroke-width: 5;
  animation: foldedPulse 2.2s ease-in-out infinite;
}

.count-strip,
.hands-answer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--green);
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 900;
  text-align: center;
}

.hand-phase-0 .count-strip,
.hand-phase-1 .count-strip {
  display: none;
}

.count-strip strong {
  display: inline-grid;
  place-items: center;
  min-width: 72px;
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  color: var(--pink);
  font-size: 1.55rem;
  animation: answerPop 4.8s ease-in-out infinite;
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
}

.left-pill {
  animation: pillPulse 4.8s ease-in-out infinite;
}

.right-pill {
  animation: pillPulse 4.8s ease-in-out 1.7s infinite;
}

.table-grid,
.pattern-grid {
  display: grid;
  gap: 10px;
}

.table-grid {
  grid-template-columns: repeat(3, minmax(86px, 1fr));
}

.grid-anim,
.ladder-anim {
  display: grid;
  gap: 12px;
}

.jump-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff8df;
}

.jump-node {
  display: grid;
  place-items: center;
  min-height: 82px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
  font-weight: 900;
}

.jump-node span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.jump-arrow {
  display: grid;
  place-items: center;
  min-height: 56px;
  color: var(--pink);
  font-size: 1.35rem;
  font-weight: 900;
  position: relative;
}

.jump-arrow::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 50%;
  border-top: 5px dashed currentColor;
  transform: translateY(-50%);
}

.jump-arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 18px;
  height: 18px;
  border-right: 5px solid currentColor;
  border-top: 5px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

.jump-arrow span {
  z-index: 1;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
}

.grid-phase-0 .jump-arrow,
.grid-phase-0 .target-node {
  opacity: 0.18;
}

.grid-phase-0 .hands-answer,
.grid-phase-1 .hands-answer {
  display: none;
}

.grid-phase-0 .fact-tile:not(.is-start),
.grid-phase-1 .fact-tile:not(.is-start):not(.is-current) {
  opacity: 0.35;
}

.grid-phase-1 .jump-arrow {
  animation: jumpMove 1.5s ease-in-out infinite;
}

.grid-phase-1 .target-node {
  opacity: 0.42;
}

.grid-phase-2 .target-node,
.grid-phase-3 .target-node {
  background: var(--green);
  animation: tilePulse 1.8s ease-in-out infinite;
}

.fact-tile {
  display: grid;
  place-items: center;
  min-height: 72px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #e9f8ff;
  text-align: center;
  font-weight: 900;
}

.fact-tile.is-current {
  background: var(--green);
  animation: tilePulse 1.8s ease-in-out infinite;
}

.fact-tile.is-start {
  background: var(--yellow);
}

.digit-builder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0;
}

.digit-lane {
  border: 2px dashed var(--ink);
  border-radius: 8px;
  padding: 12px;
  background: #f9fcff;
}

.bead-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.digit-lane span {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 4px;
  border-radius: 50%;
  background: var(--yellow);
  font-weight: 900;
}

.digit-lane span.is-current {
  background: var(--green);
  animation: tilePulse 1.8s ease-in-out infinite;
}

.ladder-phase-0 .left-lane {
  opacity: 0.2;
}

.ladder-phase-0 .combine-strip,
.ladder-phase-1 .combine-strip {
  display: none;
}

.ladder-phase-0 .ones-lane {
  animation: laneGlow 1.8s ease-in-out infinite;
}

.ladder-phase-1 .left-lane {
  opacity: 1;
  animation: laneGlow 1.8s ease-in-out infinite;
}

.ladder-phase-1 .ones-lane {
  opacity: 0.72;
}

.combine-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 68px;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--green);
  font-weight: 900;
}

.combine-strip span,
.combine-strip strong {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
}

.combine-strip small {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.combine-strip strong {
  min-width: 76px;
  color: var(--pink);
  font-size: 1.55rem;
  animation: answerPop 2.2s ease-in-out infinite;
}

.combine-strip .equals-mark {
  min-width: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.example-card {
  display: grid;
  grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 12px;
  padding: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff8df;
}

.example-problem {
  display: grid;
  place-items: center;
  min-height: 106px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  color: var(--pink);
  font-size: clamp(1.7rem, 4vw, 2.45rem);
  font-weight: 900;
  text-align: center;
}

.example-detail {
  display: grid;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 1.06rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.example-detail strong {
  color: var(--ink);
}

.problem-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 132px;
  margin-top: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #e8fff8);
  font-size: clamp(2.5rem, 7vw, 4.4rem);
  font-weight: 900;
}

.answer-slot {
  color: var(--pink);
}

.answer-form label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
}

.answer-row {
  margin-top: 0;
}

.answer-row input {
  min-width: 0;
  width: min(100%, 380px);
  height: 52px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: #ffffff;
  font-size: 1.4rem;
  font-weight: 900;
}

.quick-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.quick-pad button {
  background: #f7f1ff;
}

.feedback {
  min-height: 64px;
  margin-top: 14px;
  padding: 12px;
  border-left: 6px solid var(--blue);
  border-radius: 8px;
  background: #eef8ff;
  color: var(--ink);
  font-weight: 750;
}

.feedback.correct {
  border-left-color: var(--green);
  background: #e8fff8;
}

.feedback.try-again {
  border-left-color: var(--pink);
  background: #fff0f4;
}

@keyframes fingerPulse {
  0%,
  20%,
  100% {
    opacity: 1;
  }
  34%,
  48% {
    opacity: 1;
    filter: drop-shadow(0 0 12px rgba(6, 214, 160, 0.9));
  }
}

@keyframes numberPop {
  0%,
  100% {
    filter: drop-shadow(0 6px 6px rgba(22, 33, 62, 0.1));
  }
  45%,
  60% {
    filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.95));
  }
}

@keyframes foldedPulse {
  0%,
  100% {
    filter: drop-shadow(0 6px 6px rgba(22, 33, 62, 0.12));
  }
  12%,
  25% {
    filter: drop-shadow(0 0 14px rgba(239, 71, 111, 0.95));
  }
}

@keyframes countZone {
  0%,
  24%,
  100% {
    fill: rgba(255, 209, 102, 0.14);
  }
  34%,
  52% {
    fill: rgba(6, 214, 160, 0.22);
  }
}

@keyframes arrowDash {
  to {
    stroke-dashoffset: -40;
  }
}

@keyframes labelPop {
  0%,
  100% {
    opacity: 0.35;
  }
  10%,
  34% {
    opacity: 1;
  }
}

@keyframes pillPulse {
  0%,
  24%,
  100% {
    transform: scale(1);
  }
  34%,
  52% {
    transform: scale(1.06);
  }
}

@keyframes answerPop {
  0%,
  58% {
    transform: scale(0.96);
    opacity: 0.65;
  }
  70%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes tilePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes jumpMove {
  0%,
  100% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(8px);
  }
}

@keyframes laneGlow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(6, 214, 160, 0);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(6, 214, 160, 0.22);
  }
}

@keyframes groupPop {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 760px) {
  .site-header {
    margin-bottom: 34px;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-bottom: 26px;
  }

  .hero-copy h1 {
    max-width: 10ch;
  }

  .hero-showcase {
    justify-self: start;
  }

  .lesson-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mission-header,
  .stage-title-row {
    display: grid;
  }

  .mission-tools {
    justify-content: start;
  }

  .score-card,
  .stage-count {
    width: fit-content;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 24px, 980px);
    padding-top: 14px;
  }

  .site-header {
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
  }

  .header-actions {
    gap: 8px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand-lockup small {
    display: none;
  }

  .header-action {
    min-height: 40px;
    padding-inline: 10px;
    font-size: 0.86rem;
  }

  .settings-button {
    width: 40px;
    height: 40px;
  }

  .settings-panel {
    margin: -14px 0 28px;
  }

  .key-row {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    font-size: 2.65rem;
  }

  .hero-copy p {
    max-width: 34ch;
    margin-top: 8px;
    font-size: 0.98rem;
  }

  .hero-showcase {
    display: none;
  }

  .lesson-gallery {
    grid-template-columns: 1fr;
  }

  .lesson-card {
    min-height: 122px;
    padding: 16px;
  }

  .mission-card {
    padding: 14px;
  }

  .stage-tabs {
    grid-template-columns: 1fr;
  }

  .focus-card,
  .example-card,
  .digit-builder,
  .anchor-board {
    grid-template-columns: 1fr;
  }

  .anchor-operator,
  .anchor-equals {
    justify-self: center;
  }

  .jump-board {
    grid-template-columns: 1fr;
  }

  .jump-arrow {
    min-height: 46px;
  }

  .jump-arrow::after {
    right: 40%;
  }

  .hands-svg {
    min-height: 205px;
    max-height: 245px;
  }

  .table-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-row {
    align-items: stretch;
  }

  .answer-row input,
  .answer-row button {
    width: 100%;
  }
}
