/* ============================================================
   Piano Starters — storybook redesign
   Garden palette + Quicksand headings
   ============================================================ */

:root {
  /* Garden palette (greens + warm coral) */
  --cobalt: #2c6dc9;
  --cobalt-deep: #1b4d99;
  --cobalt-soft: #d6e6fb;
  --coral: #ec8c5e;
  --coral-deep: #a8552c;
  --coral-soft: #fadcc6;
  --teal: #29a39d;
  --teal-deep: #1a7672;
  --teal-soft: #cdebe8;
  --sun: #a8d36a;
  --sun-deep: #5b8528;
  --sun-soft: #e0f0c2;
  --plum: #a37bd1;
  --plum-soft: #e6dbf3;
  --leaf: #6dbf7a;
  --leaf-soft: #d5efd8;

  --cream: #f5fce8;
  --cream-deep: #d6e8b8;
  --paper: #fbfff0;
  --ink: #1f2a4a;
  --ink-soft: #4f5e7c;
  --ink-mute: #8493ad;

  --shadow-card:
    0 10px 0 -4px rgba(31, 42, 74, 0.06),
    0 22px 50px -10px rgba(31, 42, 74, 0.18);
  --shadow-press: 0 6px 0 -2px rgba(31, 42, 74, 0.08);

  --r-sm: 14px;
  --r-md: 22px;
  --r-lg: 32px;
  --r-pill: 999px;

  --font-heading: "Quicksand", "Baloo 2", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;

  color: var(--ink);
  font-family: var(--font-body);
  background: var(--cream);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background:
    radial-gradient(
      circle at 12% 8%,
      rgba(168, 211, 106, 0.22),
      transparent 32rem
    ),
    radial-gradient(
      circle at 88% 92%,
      rgba(41, 163, 157, 0.16),
      transparent 36rem
    ),
    linear-gradient(180deg, #f5fce8 0%, #e6f2cf 100%);
  color: var(--ink);
  overflow-x: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0;
  text-wrap: pretty;
}

p {
  margin: 0;
}

.classroom-exit {
  position: fixed;
  top: max(14px, calc(env(safe-area-inset-top) + 12px));
  left: max(14px, calc(env(safe-area-inset-left) + 12px));
  z-index: 95;
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 54px;
  min-height: 54px;
  padding: 0 16px 0 14px;
  border: 3px solid rgba(31, 42, 74, 0.14);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-family: var(--font-heading);
  font-weight: 900;
  box-shadow:
    0 7px 0 -2px rgba(31, 42, 74, 0.12),
    0 18px 30px -16px rgba(31, 42, 74, 0.42);
}

.classroom-exit svg {
  width: 24px;
  height: 24px;
}

.classroom-exit:hover {
  transform: translateY(-2px);
}

.classroom-exit:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 -2px rgba(31, 42, 74, 0.14);
}

.classroom-exit:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 3px;
}

body.game-active .classroom-exit,
body.ear-active .classroom-exit,
body.lesson-lab-active .classroom-exit,
body.lesson-deck-active .classroom-exit,
body.brain-quest-active .classroom-exit,
body.library-active .classroom-exit {
  display: inline-flex;
}

body.game-active #backToHome,
body.ear-active #earBack,
body.lesson-lab-active #lessonLabBack,
body.lesson-deck-active #lessonDeckBack,
body.brain-quest-active #brainQuestBack,
body.library-active #libraryBack {
  visibility: hidden;
  pointer-events: none;
}

/* ==========================================================
   APP SHELL
   ========================================================== */

.shell {
  position: relative;
  width: min(1280px, 100% - 40px);
  margin: 0 auto;
  padding: 28px 0 60px;
}

body.game-active .shell {
  display: none;
}

body.lesson-lab-active .shell,
body.lesson-lab-active .game,
body.lesson-lab-active .ear-game,
body.lesson-lab-active .sound-library,
body.lesson-lab-active .ambient-puppy {
  display: none;
}

body.brain-quest-active .shell,
body.brain-quest-active .game,
body.brain-quest-active .lesson-lab,
body.brain-quest-active .lesson-deck,
body.brain-quest-active .ear-game,
body.brain-quest-active .sound-library,
body.brain-quest-active .ambient-puppy {
  display: none;
}

body.lesson-deck-active .shell,
body.lesson-deck-active .game,
body.lesson-deck-active .lesson-lab,
body.lesson-deck-active .brain-quest-page,
body.lesson-deck-active .ear-game,
body.lesson-deck-active .sound-library,
body.lesson-deck-active .ambient-puppy {
  display: none;
}

/* ==========================================================
   HOME
   ========================================================== */

.home-hero {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border-radius: var(--r-lg);
  background:
    radial-gradient(
      circle at 78% 38%,
      rgba(255, 245, 200, 0.5),
      transparent 14rem
    ),
    linear-gradient(135deg, #3a86d6 0%, #1f5fb4 70%);
  color: #fff;
  box-shadow: var(--shadow-card);
  padding: 36px 40px;
  display: grid;
  grid-template-columns: minmax(420px, 1.9fr) minmax(260px, 1fr);
  gap: 36px;
  align-items: center;
  min-height: 260px;
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 22% 14%,
      rgba(255, 255, 255, 0.16),
      transparent 8rem
    ),
    radial-gradient(
      circle at 92% 86%,
      rgba(255, 255, 255, 0.1),
      transparent 10rem
    );
  pointer-events: none;
}

.home-hero .hero-text {
  position: relative;
  z-index: 4;
}

.home-hero .kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.18);
  color: #fff7d9;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.home-hero h1 {
  color: #fff;
  font-size: clamp(2.2rem, 4.5vw, 3.6rem);
  line-height: 1;
  margin: 0 0 12px;
  max-width: 13ch;
}

.home-hero .sub {
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.05rem;
  font-weight: 600;
  max-width: 32ch;
  margin: 0 0 18px;
  line-height: 1.4;
}

.resume-card,
.home-backpack-button {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(100%, 360px);
  min-height: 74px;
  padding: 11px 16px 11px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--r-md);
  color: var(--ink);
  box-shadow:
    0 7px 0 -2px rgba(31, 42, 74, 0.12),
    0 18px 30px -18px rgba(15, 32, 64, 0.42);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.72);
  font: inherit;
  text-align: left;
  transition: transform 160ms ease;
}

.home-backpack-button {
  margin-top: 12px;
}

.resume-card:hover,
.home-backpack-button:hover {
  transform: translateY(-2px);
  background: #fff;
}
.resume-card:active,
.home-backpack-button:active {
  transform: translateY(1px);
}
.resume-card[hidden] {
  display: none;
}

.resume-card .play-disc,
.backpack-disc {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(31, 42, 74, 0.08);
  box-shadow: 0 5px 0 -2px rgba(31, 42, 74, 0.14);
}

.resume-card .play-disc {
  background: linear-gradient(180deg, #fff5ea, #ffe0ca);
  color: var(--coral-deep);
}

.backpack-disc {
  background: linear-gradient(180deg, #eef7ff, #dcecff);
  color: var(--cobalt-deep);
}

.resume-card .play-disc svg,
.backpack-disc svg {
  width: 25px;
  height: 25px;
}

.resume-card .resume-label,
.home-backpack-button .resume-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0;
  text-transform: uppercase;
}

.resume-card .resume-title,
.home-backpack-button .resume-title {
  display: block;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.15rem;
  line-height: 1.15;
  color: var(--ink);
}

.resume-card .chev,
.home-backpack-button .chev {
  color: var(--ink-mute);
  font-size: 1.4rem;
  font-weight: 900;
}

.resume-card:focus-visible,
.home-backpack-button:focus-visible {
  outline: 4px solid rgba(255, 255, 255, 0.72);
  outline-offset: 3px;
}

.hero-art {
  position: relative;
  align-self: stretch;
  display: grid;
  place-items: center;
  z-index: 1;
}

.hero-art img {
  width: 100%;
  height: auto;
  border-radius: 22px;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.22);
}

/* ----- Lesson strip (3-step intro) ----- */

.lesson-strip {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 22px;
}

.lesson-strip article {
  padding: 18px 18px 16px;
  border-radius: var(--r-md);
  background: var(--paper);
  border: 2px solid var(--cream-deep);
  box-shadow: var(--shadow-press);
}

.lesson-strip h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin: 8px 0 6px;
}

.lesson-strip p {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.4;
}

.lesson-step {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ----- Personalized practice plan ----- */

.practice-plan {
  margin-top: 24px;
  padding: 22px;
  border-radius: var(--r-md);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(243, 251, 225, 0.9)),
    var(--paper);
  border: 2px solid var(--sun);
  box-shadow: var(--shadow-press);
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1.55fr);
  grid-template-areas:
    "copy actions"
    "stats actions";
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 1120px) {
  .practice-plan {
    grid-template-columns: minmax(270px, 0.85fr) minmax(0, 1.15fr);
    grid-template-areas:
      "copy actions"
      "stats actions";
  }

  .practice-plan-actions {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 760px) {
  .practice-plan {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "stats"
      "actions";
  }

  .practice-plan-stats {
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  }

  .practice-plan-actions {
    grid-template-columns: 1fr;
  }
}

.practice-plan-copy {
  grid-area: copy;
  display: grid;
  align-content: center;
  gap: 8px;
}

.practice-plan h2 {
  font-size: 1.35rem;
  line-height: 1.08;
}

.practice-plan p {
  color: var(--ink-soft);
  font-weight: 700;
  line-height: 1.35;
}

.practice-plan-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.practice-plan-links button,
.practice-plan-links a,
.sheet-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: var(--r-pill);
  border: 2px solid var(--teal);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.86rem;
  text-decoration: none;
  cursor: pointer;
}

.practice-plan-links button.real-piano-ready,
body.real-piano-mode .practice-plan-links #realPianoStart {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-deep);
}

.practice-plan-stats {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 10px;
  align-self: end;
}

.practice-plan-stats span {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 84px;
  padding: 12px 10px;
  border-radius: var(--r-md);
  background: #fff;
  border: 2px solid var(--cream-deep);
  text-align: center;
}

.practice-plan-stats b {
  font-family: var(--font-heading);
  color: var(--teal-deep);
  font-size: 1.45rem;
  line-height: 1;
}

.practice-plan-stats small,
.practice-plan-actions small {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.2;
}

.practice-plan-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.practice-plan-actions button {
  min-height: 108px;
  padding: 14px;
  border-radius: var(--r-md);
  border: 2px solid var(--cream-deep);
  background: #fff;
  color: var(--ink);
  text-align: left;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 5px;
  box-shadow: 0 5px 0 -2px rgba(31, 42, 74, 0.12);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.practice-plan-actions button:hover,
.practice-plan-actions button:focus-visible,
.practice-plan-actions button.playing {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: 0 8px 0 -2px rgba(29, 107, 104, 0.18);
}

.practice-plan-actions button.completed {
  border-color: var(--leaf);
  background: linear-gradient(180deg, var(--leaf-soft), #fff);
}

.practice-plan-actions button.completed span {
  background: var(--leaf-soft);
  color: #3a7d3a;
}

.practice-plan-actions span {
  width: fit-content;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.72rem;
}

.practice-plan-actions b {
  font-family: var(--font-heading);
  font-size: 1rem;
  line-height: 1.05;
}

.brain-link-quest {
  margin-top: 20px;
  width: min(100%, 440px);
  min-height: 300px;
  padding: 22px;
  border-radius: var(--r-md);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.94) 0 48%, rgba(205, 235, 232, 0.86) 48% 100%),
    var(--paper);
  border: 4px solid var(--teal);
  box-shadow: var(--shadow-press);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "copy"
    "path"
    "actions";
  gap: 14px;
  align-items: stretch;
  overflow: hidden;
  position: relative;
}

.brain-link-quest.active {
  border-color: var(--coral);
  box-shadow: 0 8px 0 -2px rgba(236, 140, 94, 0.18);
}

.brain-link-quest::after {
  content: "♪";
  position: absolute;
  right: 22px;
  top: 18px;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: 0 6px 0 -3px rgba(31, 42, 74, 0.14);
}

.brain-quest-copy {
  grid-area: copy;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 72px;
}

.brain-quest-copy h2 {
  font-size: 1.36rem;
  line-height: 1.12;
}

.brain-quest-copy p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.3;
}

.brain-quest-path {
  grid-area: path;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-self: end;
}

.brain-quest-step {
  min-height: 42px;
  padding: 8px 9px;
  border-radius: var(--r-sm);
  border: 2px solid var(--cream-deep);
  background: #fff;
  display: grid;
  align-content: center;
  gap: 2px;
  text-align: center;
}

.brain-quest-step b {
  font-family: var(--font-heading);
  font-size: 0.82rem;
}

.brain-quest-step small {
  color: var(--ink-soft);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.12;
}

.brain-link-quest:not(.active) .brain-quest-step small {
  display: none;
}

.brain-quest-step.current {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.brain-quest-step.done {
  border-color: var(--leaf);
  background: var(--leaf-soft);
}

.brain-quest-actions {
  grid-area: actions;
  display: grid;
  gap: 8px;
  justify-items: stretch;
  align-items: end;
}

.brain-quest-actions button {
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 2px solid var(--teal);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 5px 0 -2px rgba(29, 107, 104, 0.2);
  cursor: pointer;
}

.brain-say-prompt {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 360px;
}

.brain-say-prompt strong {
  flex-basis: 100%;
  text-align: right;
  font-family: var(--font-heading);
}

.brain-quest-end {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.brain-quest-end[hidden] {
  display: none;
}

.brain-quest-end div {
  padding: 12px;
  border-radius: var(--r-sm);
  background: #fff;
  border: 2px solid var(--teal-soft);
}

.brain-quest-end b,
.brain-quest-end span {
  display: block;
}

.brain-quest-end b {
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-size: 0.78rem;
}

.brain-quest-end span {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.25;
}

@media (max-width: 980px) {
  .lesson-slide-card {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .lesson-slide-demo {
    min-height: 280px;
  }

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

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

  .brain-quest-hero {
    min-height: auto;
  }

  .brain-quest-hero h2 {
    max-width: 16ch;
  }

  .brain-link-quest {
    grid-template-columns: 1fr;
  }

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

  .brain-quest-actions,
  .brain-say-prompt {
    justify-items: stretch;
    justify-content: stretch;
  }

  .brain-say-prompt strong {
    text-align: left;
  }
}

/* ----- Lesson Lab ----- */

.lesson-lab {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: none;
  grid-template-rows: auto 1fr;
  overflow-y: auto;
  background:
    radial-gradient(circle at 12% 8%, rgba(168, 211, 106, 0.2), transparent 30rem),
    radial-gradient(circle at 88% 88%, rgba(41, 163, 157, 0.16), transparent 32rem),
    linear-gradient(180deg, #f5fce8, #e6f2cf);
}

body.lesson-lab-active .lesson-lab {
  display: grid;
}

.brain-quest-page {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  grid-template-rows: auto 1fr;
  overflow-y: auto;
  background:
    radial-gradient(circle at 16% 12%, rgba(41, 163, 157, 0.2), transparent 28rem),
    radial-gradient(circle at 88% 80%, rgba(236, 140, 94, 0.16), transparent 30rem),
    linear-gradient(180deg, #f5fce8, #e1f4ef);
}

body.brain-quest-active .brain-quest-page {
  display: grid;
}

.lesson-deck {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: none;
  grid-template-rows: auto 1fr;
  overflow-y: auto;
  background:
    radial-gradient(circle at 18% 12%, rgba(168, 211, 106, 0.24), transparent 28rem),
    radial-gradient(circle at 82% 82%, rgba(109, 76, 165, 0.14), transparent 30rem),
    linear-gradient(180deg, #f5fce8, #e6f2cf);
}

body.lesson-deck-active .lesson-deck {
  display: grid;
}

.lesson-deck-stage {
  width: min(1080px, 100% - 40px);
  margin: 0 auto;
  padding: 28px 0 52px;
  display: grid;
  place-items: center;
}

.lesson-slide-card {
  width: min(960px, 100%);
  min-height: 560px;
  padding: clamp(22px, 4vw, 42px);
  border-radius: var(--r-md);
  border: 3px solid var(--cream-deep);
  background: var(--paper);
  box-shadow: var(--shadow-press);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  grid-template-rows: 1fr auto;
  gap: 24px;
}

.lesson-slide-copy {
  display: grid;
  align-content: center;
  gap: 12px;
}

.lesson-slide-copy h2 {
  max-width: 13ch;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.96;
}

.lesson-slide-copy p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.45;
}

.lesson-slide-demo {
  min-height: 360px;
  padding: 22px;
  border-radius: var(--r-md);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(205, 235, 232, 0.72)),
    var(--teal-soft);
  border: 2px solid var(--teal);
  display: grid;
  align-content: center;
  gap: 22px;
}

.lesson-slide-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 120px 1fr 180px;
  align-items: center;
  gap: 12px;
}

.lesson-slide-actions button {
  min-height: 44px;
  border-radius: var(--r-pill);
  border: 2px solid var(--teal);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  cursor: pointer;
}

.lesson-slide-actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.lesson-slide-actions span {
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-weight: 800;
}

.lesson-demo-piano {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  align-items: end;
}

.lesson-demo-piano span {
  min-height: 130px;
  border-radius: 0 0 14px 14px;
  border: 2px solid rgba(31, 42, 74, 0.18);
  background: #fff;
  display: grid;
  place-items: end center;
  padding: 10px 4px;
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-weight: 800;
}

.lesson-demo-piano span.active {
  animation: lesson-key-pop 1100ms ease-in-out infinite;
  background: var(--sun-soft);
  border-color: var(--sun);
  color: var(--ink);
}

.lesson-demo-arrow {
  justify-self: center;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-demo-cards,
.lesson-demo-beats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.lesson-demo-cards span {
  min-height: 96px;
  border-radius: var(--r-md);
  background: #fff;
  border: 3px solid var(--plum);
  display: grid;
  place-items: center;
  color: #6d4ca5;
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
}

.lesson-demo-beats span {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--teal);
  animation: lesson-beat 1200ms ease-in-out infinite;
}

.lesson-demo-beats span:nth-child(2) { animation-delay: 150ms; }
.lesson-demo-beats span:nth-child(3) { animation-delay: 300ms; }
.lesson-demo-beats span:nth-child(4) { animation-delay: 450ms; }

@keyframes lesson-key-pop {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-12px); }
}

@keyframes lesson-beat {
  0%, 100% { transform: scale(0.78); opacity: 0.55; }
  45% { transform: scale(1); opacity: 1; }
}

.brain-quest-stage {
  width: min(1100px, 100% - 40px);
  margin: 0 auto;
  padding: 26px 0 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 20px;
  align-items: start;
}

.brain-quest-hero {
  min-height: 300px;
  padding: 28px;
  border-radius: var(--r-md);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(243, 251, 225, 0.88)),
    var(--paper);
  border: 2px solid var(--teal);
  box-shadow: var(--shadow-press);
  display: grid;
  align-content: center;
  gap: 12px;
}

.brain-quest-hero h2 {
  max-width: 12ch;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.96;
}

.brain-quest-hero p {
  max-width: 58ch;
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.45;
}

.lesson-lab-stage {
  width: min(1100px, 100% - 40px);
  margin: 0 auto;
  padding: 26px 0 48px;
  display: grid;
  gap: 18px;
}

.lesson-lab-hero,
.lesson-plan-card,
.co-play-card,
.transfer-ladder-card,
.year-roadmap-card {
  border-radius: var(--r-md);
  background: var(--paper);
  border: 2px solid var(--cream-deep);
  box-shadow: var(--shadow-press);
}

.lesson-lab-hero {
  display: grid;
  gap: 8px;
  padding: 24px;
}

.lesson-lab-hero h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1;
}

.lesson-lab-hero p {
  color: var(--ink-soft);
  font-weight: 800;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.analytics-grid article {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 18px;
  border-radius: var(--r-md);
  background: #fff;
  border: 2px solid var(--cream-deep);
  box-shadow: 0 5px 0 -2px rgba(31, 42, 74, 0.1);
}

.analytics-grid span,
.lesson-steps small {
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.analytics-grid b {
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.05;
}

.analytics-grid small,
.lesson-steps p {
  color: var(--ink-soft);
  font-weight: 700;
  line-height: 1.35;
}

.lesson-plan-card {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.co-play-card,
.transfer-ladder-card {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.co-play-card {
  border-color: var(--teal);
  background: linear-gradient(135deg, #fff, var(--teal-soft));
}

.transfer-ladder-card {
  border-color: var(--sun);
  background: linear-gradient(135deg, #fff, var(--cream));
}

.transfer-ladder-card p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.35;
}

.year-roadmap-card {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.year-roadmap-card p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.35;
}

.lesson-plan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lesson-plan-head strong {
  font-family: var(--font-heading);
  color: var(--ink);
}

.lesson-steps,
.co-play-prompts,
.transfer-ladder-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.lesson-steps article,
.co-play-prompts article,
.transfer-ladder-steps article {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-md);
  background: #fff;
  border: 2px solid var(--cream-deep);
}

.co-play-prompts article,
.transfer-ladder-steps article {
  grid-template-columns: 1fr;
  align-content: start;
}

.lesson-step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sun);
  color: var(--ink);
  font-family: var(--font-heading);
  font-weight: 800;
}

.co-play-prompts article > span,
.transfer-ladder-steps article > span {
  width: max-content;
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 0.8rem;
}

.co-play-prompts article > span {
  border-radius: var(--r-pill);
}

.transfer-ladder-steps article > span {
  background: var(--sun);
  color: var(--ink);
}

.lesson-steps b,
.co-play-prompts b,
.transfer-ladder-steps b {
  display: block;
  margin: 4px 0;
  font-family: var(--font-heading);
  line-height: 1.05;
}

.co-play-prompts p,
.transfer-ladder-steps p {
  color: var(--ink-soft);
  font-weight: 750;
  line-height: 1.35;
}

.lesson-steps a {
  display: inline-flex;
  margin-top: 10px;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
}

.curriculum-week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.curriculum-week-grid article {
  min-height: 102px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 2px solid var(--cream-deep);
  background: #fff;
  display: grid;
  align-content: start;
  gap: 6px;
}

.curriculum-week-grid article.current {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.curriculum-week-grid span,
.curriculum-week-grid small {
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-size: 0.76rem;
  font-weight: 800;
}

.curriculum-week-grid b {
  font-family: var(--font-heading);
  color: var(--ink);
  line-height: 1.05;
}

/* ----- Streak chip ----- */

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink-soft);
  min-width: 56px;
  justify-content: center;
  transition: color 200ms ease, background 200ms ease;
}

.streak-flame {
  color: var(--ink-mute);
  font-size: 1.1rem;
}

.streak-chip.live {
  color: var(--coral-deep);
  background: var(--coral-soft);
}

.streak-chip.live .streak-flame {
  color: var(--coral);
  filter: drop-shadow(0 0 6px rgba(236, 140, 94, 0.6));
}

/* ----- Mini-staff ----- */

.mini-staff {
  display: block;
  width: 120px;
  height: 56px;
  margin-top: 6px;
}

.mini-staff line {
  stroke: var(--ink-mute);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.mini-staff #staffNote {
  fill: var(--coral);
  stroke: var(--coral-deep);
  stroke-width: 1.5;
}

.mini-staff #staffLedger {
  stroke: var(--ink-mute);
  stroke-width: 1.4;
}

.nn-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

/* ----- Mode picker ----- */

.section-title {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 36px 4px 16px;
}

.section-title h2 {
  font-size: 1.5rem;
  color: var(--ink);
}

.section-title .helper-text {
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 700;
}

.mode-picker {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 20px;
  align-items: stretch;
}

.mode-picker.has-shuffle {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

@media (max-width: 700px) {
  .mode-picker,
  .mode-picker.has-shuffle {
    grid-template-columns: 1fr;
  }
  .brain-boosts {
    grid-template-columns: 1fr;
  }
  .rhythm-head {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .rhythm-beats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.mode-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(5px, 0.8vw, 9px);
  padding: clamp(14px, 1.7vw, 20px);
  border-radius: var(--r-lg);
  border: 4px solid var(--mode-border, var(--ink));
  background: var(--mode-bg, #fff);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    transform 200ms cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 200ms ease;
  box-shadow:
    0 10px 0 -2px var(--mode-shadow, var(--ink)),
    0 28px 50px -16px rgba(31, 42, 74, 0.25);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 0;
  min-width: 0;
}

.mode-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--mode-image);
  background-size: cover;
  background-position: center;
  opacity: 0.96;
  pointer-events: none;
}

.mode-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.86) 0%, rgba(255, 255, 255, 0.66) 46%, rgba(255, 255, 255, 0.16) 100%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
  pointer-events: none;
}

.mode-card > * {
  position: relative;
  z-index: 1;
}

.mode-card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 16px 0 -2px var(--mode-shadow, var(--ink)),
    0 36px 60px -14px rgba(31, 42, 74, 0.32);
}

.mode-card:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 -2px var(--mode-shadow, var(--ink));
}

.mode-card .mode-icon {
  position: relative;
  width: clamp(46px, 5vw, 64px);
  height: clamp(46px, 5vw, 64px);
  border-radius: clamp(14px, 1.6vw, 20px);
  background: var(--mode-icon-bg, #fff);
  display: grid;
  place-items: center;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.06);
}

.mode-card .mode-icon svg {
  width: clamp(27px, 3.2vw, 40px);
  height: clamp(27px, 3.2vw, 40px);
}

.mode-card .mode-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1;
  margin: 0;
  color: var(--ink);
  position: relative;
}

.mode-card .mode-tag {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--mode-tag, var(--ink-soft));
  margin-top: 2px;
}

.mode-card .mode-go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: start;
  padding: clamp(6px, 0.8vw, 9px) clamp(11px, 1.2vw, 15px);
  border-radius: var(--r-pill);
  background: var(--mode-cta-bg, var(--ink));
  color: var(--mode-cta-fg, #fff);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.84rem;
  position: relative;
}

.mode-card .mode-go::after {
  content: "→";
  font-weight: 800;
}

/* Per-mode color */
.mode-card.mode-listen {
  --mode-bg: #f3fbe1;
  --mode-image: image-set(
    url("../assets/mode-cards/mode-card-listen-copy-16x9.webp") type("image/webp"),
    url("../assets/mode-cards/mode-card-listen-copy-16x9.png") type("image/png")
  );
  --mode-border: var(--sun);
  --mode-shadow: var(--sun-deep);
  --mode-blob: var(--sun-soft);
  --mode-icon-bg: #fff;
  --mode-tag: var(--sun-deep);
  --mode-cta-bg: var(--sun-deep);
}
.mode-card.mode-memory {
  --mode-bg: #efe5ff;
  --mode-image: image-set(
    url("../assets/mode-cards/mode-card-watch-remember-16x9.webp") type("image/webp"),
    url("../assets/mode-cards/mode-card-watch-remember-16x9.png") type("image/png")
  );
  --mode-border: var(--plum);
  --mode-shadow: #6d4ca5;
  --mode-blob: #e0d2ff;
  --mode-icon-bg: #fff;
  --mode-tag: #6d4ca5;
  --mode-cta-bg: #6d4ca5;
}
.mode-card.mode-explore {
  --mode-bg: var(--coral-soft);
  --mode-image: image-set(
    url("../assets/mode-cards/mode-card-make-own-16x9.webp") type("image/webp"),
    url("../assets/mode-cards/mode-card-make-own-16x9.png") type("image/png")
  );
  --mode-border: var(--coral);
  --mode-shadow: var(--coral-deep);
  --mode-blob: #ffd1c6;
  --mode-icon-bg: #fff;
  --mode-tag: var(--coral-deep);
  --mode-cta-bg: var(--coral-deep);
}

.mode-card.mode-rhythm {
  --mode-bg: var(--teal-soft);
  --mode-image: image-set(
    url("../assets/mode-cards/mode-card-tap-beat-16x9.webp") type("image/webp"),
    url("../assets/mode-cards/mode-card-tap-beat-16x9.png") type("image/png")
  );
  --mode-border: var(--teal);
  --mode-shadow: #1d6b68;
  --mode-blob: #d9f7f3;
  --mode-icon-bg: #fff;
  --mode-tag: #1d6b68;
  --mode-cta-bg: #1d6b68;
}

.mode-card.mode-shuffle {
  --mode-bg: var(--plum-soft);
  --mode-image: image-set(
    url("../assets/mode-cards/mode-card-surprise-mix-16x9.webp") type("image/webp"),
    url("../assets/mode-cards/mode-card-surprise-mix-16x9.png") type("image/png")
  );
  --mode-border: var(--plum);
  --mode-shadow: #6d4ca5;
  --mode-blob: #f0e1ff;
  --mode-icon-bg: #fff;
  --mode-tag: #6d4ca5;
  --mode-cta-bg: #6d4ca5;
}

.mode-card.mode-loop {
  --mode-bg: var(--teal-soft);
  --mode-image: image-set(
    url("../assets/mode-cards/mode-card-music-loop-16x9.webp") type("image/webp"),
    url("../assets/mode-cards/mode-card-music-loop-16x9.png") type("image/png")
  );
  --mode-border: var(--teal);
  --mode-shadow: #1d6b68;
  --mode-blob: #d9f7f3;
  --mode-icon-bg: #fff;
  --mode-tag: #1d6b68;
  --mode-cta-bg: #1d6b68;
}

.mode-card.mode-loop::after {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.72) 48%, rgba(255, 255, 255, 0.2) 100%),
    linear-gradient(0deg, rgba(205, 235, 232, 0.1), rgba(205, 235, 232, 0.1));
}

.brain-boosts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.brain-boosts button {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid var(--cream-deep);
  box-shadow: 0 4px 0 -1px rgba(31, 42, 74, 0.08);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease;
}

.brain-boosts button:hover,
.brain-boosts button:focus-visible {
  transform: translateY(-2px);
  border-color: var(--sun);
  box-shadow: 0 7px 0 -1px rgba(31, 42, 74, 0.12);
}

.brain-boosts b {
  font-family: var(--font-heading);
  color: var(--ink);
}

.brain-boosts span {
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 650;
}

.shuffle-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--plum-soft);
  color: var(--plum);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.72rem;
  vertical-align: middle;
}

/* ----- Solfège labels ----- */

.solfege {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-style: normal;
  font-size: 0.78rem;
  color: var(--coral-deep);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

body:not(.solfege-on) .solfege,
body:not(.solfege-on) .nn-solfege,
body:not(.solfege-on) .key-solfege,
body:not(.solfege-on) .interval-solfege {
  display: none;
}

.nn-letter {
  position: relative;
}

.nn-solfege {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-heading);
  font-weight: 700;
  font-style: normal;
  font-size: 0.78rem;
  color: var(--coral-deep);
  background: var(--coral-soft);
  padding: 2px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.key-solfege {
  display: block;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--coral-deep);
  margin-top: -2px;
}

/* ----- Step / Skip / Leap pattern label ----- */

.nn-pattern {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--cobalt-soft);
  color: var(--cobalt-deep);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  margin-top: 8px;
  align-self: flex-start;
  width: fit-content;
}

.nn-pattern[hidden] { display: none; }

.nn-pattern .pattern-arrow {
  font-size: 1rem;
  line-height: 1;
}

/* ----- Memory "hold" phase bubble ----- */

.speech-bubble.tone-hold {
  background: #ecf6ff;
  border-color: var(--cobalt-soft);
  animation: hold-pulse 2.4s ease-in-out;
}
.speech-bubble.tone-hold::after { background: #ecf6ff; }

@keyframes hold-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* ----- Reflection card (end of song) ----- */

/* ----- Magic knobs (transpose + mirror) ----- */

.magic-knobs {
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: center;
  margin: 10px auto 0;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #fff5fb, #f0f5ff);
  border: 2px solid var(--plum-soft);
  box-shadow: 0 3px 0 -1px var(--plum-soft);
  max-width: 640px;
  width: 100%;
}

.magic-knobs .knob-block {
  display: flex;
  gap: 10px;
  align-items: center;
}

.magic-knobs .knob-label {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--plum);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.home-row {
  display: flex;
  gap: 6px;
}

.home-row button {
  width: 34px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid var(--plum-soft);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s, border-color 0.15s;
}

.home-row button:hover { transform: translateY(-1px); }

.home-row button[aria-pressed="true"] {
  background: var(--plum-soft);
  border-color: var(--plum);
  box-shadow: 0 3px 0 -1px var(--plum);
}

.mirror-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid var(--cobalt-soft);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}

.mirror-btn:hover { transform: translateY(-1px); }

.mirror-btn[aria-pressed="true"] {
  background: var(--cobalt-soft);
  border-color: var(--cobalt);
  box-shadow: 0 3px 0 -1px var(--cobalt);
}

.mirror-btn .mirror-arrows { font-size: 1.1rem; line-height: 1; }

.magic-knobs[hidden] { display: none; }
body.ear-active .magic-knobs,
body.library-active .magic-knobs { display: none; }

.reflection-card {
  display: none;
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #fff8e2, #f7fbe6);
  border: 3px solid var(--sun);
  box-shadow: var(--shadow-press);
  max-width: 540px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

body.reflection-open .reflection-card { display: grid; gap: 12px; }

.reflection-card h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.1rem;
}

.reflection-card .reflection-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reflection-card button {
  padding: 14px;
  border-radius: var(--r-md);
  border: 3px solid var(--sun-deep);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 5px 0 -1px var(--sun-deep);
}

.reflection-card button.correct {
  background: var(--leaf-soft);
  border-color: var(--leaf);
}

.reflection-card button.wrong {
  background: var(--coral-soft);
  border-color: var(--coral);
}

/* ----- Sound Library screen ----- */

.sound-library {
  position: fixed;
  inset: 0;
  z-index: 30;
  background:
    radial-gradient(circle at 14% 18%, rgba(168, 211, 106, 0.22), transparent 26rem),
    radial-gradient(circle at 84% 80%, rgba(41, 163, 157, 0.16), transparent 30rem),
    linear-gradient(180deg, #f5fce8 0%, #dfeec0 100%);
  display: none;
  grid-template-rows: auto 1fr;
  overflow-y: auto;
  animation: fade-in 280ms ease;
}

body.library-active .sound-library { display: grid; }
body.library-active .game,
body.library-active .ear-game,
body.library-active .shell,
body.library-active .ambient-puppy { display: none; }

.library-stage {
  padding: 8px 32px 32px;
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

.library-intro h2 {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.library-intro p {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.4;
  max-width: 56ch;
  margin-bottom: 20px;
}

.library-piano-wrap {
  margin: 0 auto 20px;
  max-width: 760px;
  width: 100%;
  display: grid;
  justify-items: center;
}

.library-piano-wrap .piano {
  width: 100%;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.library-card {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 8px;
  padding: 18px;
  border-radius: var(--r-md);
  border: 3px solid var(--lib-border, var(--sun));
  background: var(--lib-bg, #fff);
  box-shadow: 0 6px 0 -1px var(--lib-shadow, var(--sun-deep));
  cursor: pointer;
  font-family: var(--font-heading);
  text-align: left;
  color: var(--ink);
  transition: transform 160ms ease;
}

.library-card:hover { transform: translateY(-2px); }
.library-card.playing { background: #fff5d8; }

.library-card .lib-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--lib-name, var(--sun-deep));
  text-transform: uppercase;
}

.library-card h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
}

.library-card .lib-notes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-card .lib-note {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--lib-note-bg, var(--sun-soft));
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
}

.library-card .lib-song {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

.library-card.lib-step    { --lib-border: var(--sun);  --lib-shadow: var(--sun-deep);  --lib-name: var(--sun-deep); }
.library-card.lib-skip    { --lib-border: var(--teal); --lib-shadow: var(--teal-deep); --lib-name: var(--teal-deep); --lib-note-bg: var(--teal-soft); }
.library-card.lib-leap    { --lib-border: var(--plum); --lib-shadow: #6d4ca5;          --lib-name: #6d4ca5; --lib-note-bg: var(--plum-soft); }
.library-card.lib-octave  { --lib-border: var(--coral);--lib-shadow: var(--coral-deep);--lib-name: var(--coral-deep); --lib-note-bg: var(--coral-soft); }

.interval-solfege {
  font-size: 0.78rem;
  color: var(--coral-deep);
  margin-left: 4px;
}

/* ----- Ear training cards (home) ----- */

.ear-section {
  margin-top: 22px;
  padding: 24px;
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(245, 252, 232, 0.8)),
    linear-gradient(135deg, #fbfff0, #eef8d4);
  border: 2px solid var(--cream-deep);
  box-shadow: var(--shadow-press);
}

.ear-section-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.ear-section-head h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
  margin: 0;
}

.ear-helper {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.92rem;
}

.ear-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.ear-cards.ear-cards-three {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.ear-cards.ear-cards-four {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.ear-cards.ear-cards-four .ear-card {
  grid-column: span 2;
}

.ear-cards.ear-cards-four .ear-card:nth-child(4) {
  grid-column: 2 / span 2;
}

.ear-cards.ear-cards-four .ear-card:nth-child(5) {
  grid-column: 4 / span 2;
}

@media (max-width: 900px) {
  .practice-plan {
    grid-template-columns: 1fr;
  }

  .practice-plan-stats,
  .practice-plan-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .lesson-steps,
  .co-play-prompts,
  .transfer-ladder-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .curriculum-week-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  }

  .ear-cards,
  .ear-cards.ear-cards-three,
  .ear-cards.ear-cards-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ear-cards.ear-cards-four .ear-card,
  .ear-cards.ear-cards-four .ear-card:nth-child(4),
  .ear-cards.ear-cards-four .ear-card:nth-child(5) {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .practice-plan-stats,
  .practice-plan-actions {
    grid-template-columns: 1fr;
  }

  .lesson-lab-stage {
    width: min(100% - 24px, 1100px);
  }

  .analytics-grid,
  .lesson-steps,
  .co-play-prompts,
  .transfer-ladder-steps {
    grid-template-columns: 1fr;
  }

  .curriculum-week-grid {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    max-height: 520px;
  }

  .sheet-bridge-card {
    grid-template-columns: 1fr;
  }

  .sheet-bridge-actions {
    justify-content: flex-start;
  }

  .ear-section-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .ear-cards,
  .ear-cards.ear-cards-three,
  .ear-cards.ear-cards-four {
    grid-template-columns: 1fr;
  }
}

.ear-card.ear-echo {
  --ear-bg: #fff0f4;
  --ear-border: var(--coral);
  --ear-shadow: var(--coral-deep);
  --ear-icon-bg: var(--coral-soft);
  --ear-icon-fg: var(--coral-deep);
  --ear-go-color: var(--coral-deep);
}

.ear-card.ear-library {
  --ear-bg: #e8f5dc;
  --ear-border: var(--leaf);
  --ear-shadow: #3a7d3a;
  --ear-icon-bg: var(--leaf-soft);
  --ear-icon-fg: #3a7d3a;
  --ear-go-color: #3a7d3a;
}

.ear-card.ear-interval {
  --ear-bg: #e9fbf8;
  --ear-border: var(--teal);
  --ear-shadow: var(--teal-deep);
  --ear-icon-bg: var(--teal-soft);
  --ear-icon-fg: var(--teal-deep);
  --ear-go-color: var(--teal-deep);
}

.ear-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon copy"
    "go go";
  align-items: center;
  gap: 12px 14px;
  min-height: 172px;
  padding: 18px;
  border-radius: var(--r-md);
  border: 3px solid var(--ear-border, var(--sun));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 54%),
    var(--ear-bg, #fff);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 -1px var(--ear-shadow, var(--sun-deep));
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.ear-card:hover,
.ear-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 -1px var(--ear-shadow, var(--sun-deep));
}

.ear-card .ear-icon {
  grid-area: icon;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--ear-icon-bg, var(--sun-soft));
  color: var(--ear-icon-fg, var(--sun-deep));
  box-shadow: inset 0 -4px 0 rgba(31, 42, 74, 0.06);
}

.ear-card .ear-icon svg { width: 32px; height: 32px; }

.ear-card > div {
  grid-area: copy;
  min-width: 0;
}

.ear-card h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1rem, 1.25vw, 1.18rem);
  line-height: 1.05;
  color: var(--ink);
  margin: 0 0 6px;
  max-width: 11ch;
}

.ear-card p {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
  max-width: 20ch;
}

.ear-card .ear-go {
  grid-area: go;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.72);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ear-go-color, var(--sun-deep));
  white-space: nowrap;
}

.ear-card.ear-direction {
  --ear-bg: #fff8e2;
  --ear-border: var(--sun);
  --ear-shadow: var(--sun-deep);
  --ear-icon-bg: var(--sun-soft);
  --ear-icon-fg: var(--sun-deep);
  --ear-go-color: var(--sun-deep);
}

.ear-card.ear-name {
  --ear-bg: #f0e5ff;
  --ear-border: var(--plum);
  --ear-shadow: #6d4ca5;
  --ear-icon-bg: var(--plum-soft);
  --ear-icon-fg: #6d4ca5;
  --ear-go-color: #6d4ca5;
}

/* ----- Ear-training overlay (play screen) ----- */

.ear-game {
  position: fixed;
  inset: 0;
  z-index: 30;
  --ear-bg-image: url("../assets/kid-music-room-bg.png");
  background:
    linear-gradient(180deg, rgba(245, 252, 232, 0.66), rgba(213, 239, 216, 0.58)),
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.32), transparent 26rem),
    radial-gradient(circle at 84% 80%, rgba(41, 163, 157, 0.16), transparent 30rem),
    var(--ear-bg-image) center / cover no-repeat,
    linear-gradient(180deg, #f5fce8 0%, #dfeec0 100%);
  display: none;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  animation: fade-in 280ms ease;
}

body.ear-name-mode .ear-game,
body.ear-direction-mode .ear-game {
  --ear-bg-image: url("../assets/piano-classroom-banner.png");
}

body.ear-echo-mode .ear-game,
body.ear-interval-mode .ear-game {
  --ear-bg-image: url("../assets/kid-music-room-bg.png");
}

body.ear-active .ear-game { display: grid; }
body.ear-active .game { display: none; }
body.ear-active .shell { display: none; }
body.ear-active .ambient-puppy { display: none; }

.ear-score {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 14px;
  border-radius: var(--r-pill);
}

.ear-stage {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 24px;
  padding: 8px 32px 24px;
  align-items: end;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.ear-buddy {
  position: relative;
  align-self: end;
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100%;
  padding-bottom: 8px;
}

.ear-buddy .buddy-character svg,
.ear-buddy .buddy-character img.buddy-img,
.ear-buddy .buddy-character .buddy-sprite {
  width: 220px;
  height: auto;
  filter: drop-shadow(0 16px 24px rgba(31, 42, 74, 0.2));
  animation: buddy-float 4.6s ease-in-out infinite;
  border-radius: 22px;
  object-fit: cover;
}

.ear-play {
  display: grid;
  gap: 18px;
  justify-items: center;
  align-self: stretch;
  padding-bottom: 8px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.ear-replay {
  justify-self: center;
}

.ear-direction-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: 100%;
  max-width: 520px;
  display: none;
}

body.ear-direction-mode .ear-direction-controls { display: grid; }
body.ear-name-mode .ear-name-controls { display: grid; }
body.ear-name-mode .ear-piano-wrap { display: grid; }
body.ear-echo-mode .ear-echo-controls { display: grid; }
body.ear-echo-mode .ear-piano-wrap { display: grid; }
body.ear-interval-mode .ear-interval-controls { display: grid; }
body.ear-interval-mode .ear-piano-wrap { display: grid; }

.ear-name-controls,
.ear-echo-controls,
.ear-interval-controls,
.ear-piano-wrap {
  display: none;
  gap: 12px;
  width: 100%;
  justify-items: center;
}

.interval-target {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 10px;
  align-items: center;
}

.interval-target span,
.interval-target b {
  min-width: 58px;
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 3px solid var(--teal);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--teal-deep);
}

.interval-target b {
  min-width: 140px;
  background: var(--teal-soft);
  color: var(--ink);
}

.grok-explain-btn {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 2px solid var(--plum);
  background: #fff;
  color: #6d4ca5;
  font-family: var(--font-heading);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.grok-explain-btn span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--plum-soft);
}

.interval-explainer {
  max-width: 460px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 2px solid var(--plum-soft);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.echo-slots {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.echo-slot {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 3px dashed var(--coral);
  background: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--coral-deep);
}

.echo-slot.filled {
  border-style: solid;
  background: var(--coral-soft);
  box-shadow: 0 4px 0 -1px var(--coral);
}

.echo-slot.match { background: var(--leaf-soft); border-color: var(--leaf); box-shadow: 0 4px 0 -1px var(--leaf); color: #2d5a2d; }
.echo-slot.miss { background: #ffd9d9; border-color: #d44; box-shadow: 0 4px 0 -1px #b33; color: #7a1f1f; }

.echo-target {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 22px;
}

.echo-target span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-soft);
  padding: 2px 8px;
  border-radius: 8px;
  background: #f0eef9;
}

.echo-target.revealed span {
  background: var(--plum-soft);
  color: var(--plum);
}

.echo-target .echo-chunk {
  min-width: 64px;
  text-align: center;
  border: 2px solid var(--plum);
  background: var(--plum-soft);
  color: var(--plum);
}

.echo-target .echo-chunk.hidden {
  border-style: dashed;
  background: #fff;
  color: var(--ink-mute);
}

.ear-answer {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 28px 16px;
  border-radius: var(--r-lg);
  border: 4px solid var(--ink);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 0 -1px var(--ink);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.ear-answer .arrow {
  font-size: 2.4rem;
  line-height: 1;
}

.ear-answer.ear-up {
  background: linear-gradient(180deg, #fffaef, #fff5d8);
  border-color: var(--sun-deep);
  box-shadow: 0 8px 0 -1px var(--sun-deep);
}

.ear-answer.ear-down {
  background: linear-gradient(180deg, #eef8d4, #d6e8b8);
  border-color: var(--leaf);
  box-shadow: 0 8px 0 -1px #3a7d3a;
}

.ear-answer:hover {
  transform: translateY(-3px);
}

.ear-answer.correct {
  animation: ear-correct 600ms ease;
}

.ear-answer.wrong {
  animation: ear-wrong 600ms ease;
}

@keyframes ear-correct {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px) scale(1.04); box-shadow: 0 16px 0 -2px var(--leaf); }
}

@keyframes ear-wrong {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.ear-cue {
  color: var(--ink-soft);
  font-weight: 600;
  text-align: center;
}

.ear-name-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 520px;
}

.ear-name-buttons button {
  padding: 18px 8px;
  border-radius: var(--r-md);
  border: 3px solid var(--plum);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 0 -1px #6d4ca5;
  transition: transform 140ms ease;
}

.ear-name-buttons button:hover { transform: translateY(-2px); }
.ear-name-buttons button.correct { background: var(--leaf-soft); border-color: var(--leaf); }
.ear-name-buttons button.wrong { background: var(--coral-soft); border-color: var(--coral); }

.ear-piano-wrap .piano {
  --pw: min(580px, 76vw);
  width: var(--pw);
  height: 180px;
}

@media (max-width: 760px) {
  .ear-game {
    overflow: auto;
  }

  .ear-stage {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
    padding: 8px 18px 22px;
  }

  .ear-buddy {
    height: auto;
    min-height: 220px;
    justify-items: center;
  }

  .ear-buddy .speech-bubble {
    max-width: min(100%, 320px);
    justify-self: start;
  }

  .ear-buddy .buddy-character svg,
  .ear-buddy .buddy-character img.buddy-img,
  .ear-buddy .buddy-character .buddy-sprite {
    width: 150px;
  }

  .ear-play {
    max-width: 100%;
    padding-bottom: 20px;
  }

  .interval-target {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .interval-target span,
  .interval-target b {
    width: 100%;
  }

  .ear-piano-wrap .piano {
    --pw: min(580px, 92vw);
    height: 160px;
  }
}

/* ----- Level path ----- */

.level-path-section {
  margin-top: 26px;
  padding: 20px 22px;
  border-radius: var(--r-md);
  background: var(--paper);
  border: 2px solid var(--cream-deep);
  box-shadow: var(--shadow-press);
}

.level-path-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.level-path-header h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.level-stars-total {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--sun-deep);
  background: var(--sun-soft);
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 0.9rem;
}

.level-path {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scrollbar-width: thin;
}

.level-node {
  display: grid;
  gap: 4px;
  justify-items: center;
  flex-shrink: 0;
  min-width: 78px;
}

.level-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--cream-deep);
  background: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.95rem;
  transition: transform 160ms ease;
}

.level-dot:hover { transform: translateY(-2px); }

.level-node.played .level-dot { background: var(--sun-soft); border-color: var(--sun); color: var(--sun-deep); }
.level-node.complete .level-dot { background: var(--leaf-soft); border-color: var(--leaf); color: var(--ink); }
.level-node.current .level-dot {
  border-color: var(--coral);
  background: var(--coral-soft);
  color: var(--coral-deep);
  box-shadow: 0 0 0 4px rgba(236, 140, 94, 0.2);
}

.level-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-align: center;
  max-width: 78px;
  line-height: 1.15;
}

.level-stars {
  color: var(--sun-deep);
  font-size: 0.78rem;
  font-weight: 700;
}

.level-connector {
  height: 3px;
  width: 18px;
  border-radius: 999px;
  background: var(--cream-deep);
  flex-shrink: 0;
}

.level-connector.crossed {
  background: var(--sun);
}

/* ----- Ambient puppy ----- */

.ambient-puppy {
  position: absolute;
  left: 0;
  bottom: -2px;
  width: clamp(106px, 11.5vw, 154px);
  aspect-ratio: 1;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transform: translateX(-18%);
  animation:
    puppy-home-path 24s cubic-bezier(0.38, 0, 0.22, 1) infinite,
    puppy-little-hop 940ms ease-in-out infinite;
}

body.game-active .ambient-puppy { display: none; }

.ambient-puppy::after {
  content: "";
  position: absolute;
  left: 17%;
  right: 13%;
  bottom: 4%;
  height: 11%;
  border-radius: 50%;
  background: rgba(31, 42, 74, 0.16);
  filter: blur(6px);
  transform-origin: center;
  animation: puppy-shadow-step 640ms ease-in-out infinite;
}

.puppy-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background: image-set(
      url("../assets/sprites/puppy-action-sprite-12.webp") type("image/webp"),
      url("../assets/sprites/puppy-action-sprite-12.png") type("image/png")
    )
    0 0 / 600% 200% no-repeat;
  filter: drop-shadow(0 8px 12px rgba(31, 42, 74, 0.18));
  transform-origin: 50% 88%;
  animation:
    puppy-action-frame 8.4s step-end infinite,
    puppy-body-bob 640ms ease-in-out infinite;
}

.puppy-note {
  position: absolute;
  font-family: var(--font-heading);
  color: var(--coral);
  font-size: 1.3rem;
  opacity: 0;
  animation: puppy-note-float 3.4s ease-in-out infinite;
}

.puppy-note-1 {
  left: 62%;
  bottom: 70%;
  color: var(--coral);
  animation-delay: 0s;
}

.puppy-note-2 {
  left: 73%;
  bottom: 61%;
  color: var(--sun-deep);
  animation-delay: 1.1s;
}

.puppy-note-3 {
  left: 50%;
  bottom: 78%;
  color: var(--teal-deep);
  animation-delay: 2.2s;
}

@keyframes puppy-home-path {
  0% {
    opacity: 0;
    transform: translateX(-18%) translateY(0) scaleX(1);
  }

  8%,
  54% {
    opacity: 1;
  }

  62% {
    opacity: 0;
    transform: translateX(calc(100vw - 2rem)) translateY(-5px) scaleX(1);
  }

  100% {
    opacity: 0;
    transform: translateX(calc(100vw - 2rem)) translateY(-5px) scaleX(1);
  }
}

@keyframes puppy-little-hop {
  0%,
  100% { margin-bottom: 0; }
  45% { margin-bottom: 3px; }
  58% { margin-bottom: 0; }
}

@keyframes puppy-action-frame {
  0%,
  8.32% { background-position: 0 0; }
  8.33%,
  16.65% { background-position: 20% 0; }
  16.66%,
  24.99% { background-position: 40% 0; }
  25%,
  33.32% { background-position: 60% 0; }
  33.33%,
  41.65% { background-position: 80% 0; }
  41.66%,
  49.99% { background-position: 100% 0; }
  50%,
  58.32% { background-position: 0 100%; }
  58.33%,
  66.65% { background-position: 20% 100%; }
  66.66%,
  74.99% { background-position: 40% 100%; }
  75%,
  83.32% { background-position: 60% 100%; }
  83.33%,
  91.65% { background-position: 80% 100%; }
  91.66%,
  100% { background-position: 100% 100%; }
}

@keyframes puppy-body-bob {
  0%,
  100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3px) rotate(-0.6deg); }
  50% { transform: translateY(1px) rotate(0.4deg); }
  75% { transform: translateY(-6px) rotate(0.5deg); }
}

@keyframes puppy-shadow-step {
  0%,
  100% { opacity: 0.72; transform: scaleX(1); }
  50% { opacity: 0.5; transform: scaleX(0.84); }
}

@keyframes puppy-note-float {
  0% { opacity: 0; transform: translateY(0) rotate(-8deg) scale(0.82); }
  20% { opacity: 1; }
  56% { opacity: 0.8; transform: translateY(-22px) rotate(8deg) scale(1); }
  100% { opacity: 0; transform: translateY(-48px) rotate(16deg) scale(1.08); }
}

/* ----- Focus toggle / focus mode ----- */

.focus-btn[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}
.focus-btn[aria-pressed="true"] svg { color: #fff; }

body.focus-mode .buddy-stage,
body.focus-mode .extras-grid,
body.focus-mode .magic-knobs,
body.focus-mode .jam-props,
body.focus-mode .metronome-guide,
body.focus-mode .beat-coach,
body.focus-mode #modeChip,
body.focus-mode #starsRibbon,
body.focus-mode #streakChip,
body.focus-mode #midiIndicator,
body.focus-mode .ear-score,
body.focus-mode .ear-buddy {
  display: none !important;
}

body.focus-mode .game-topbar {
  padding-bottom: 8px;
}

body.focus-mode .top-center {
  justify-content: center;
}

body.focus-mode .stage {
  grid-template-columns: minmax(0, 1fr);
  max-width: 980px;
  margin: 0 auto;
  padding-top: clamp(4px, 2vh, 20px);
  width: 100%;
}

body.focus-mode .play-area {
  align-content: center;
  justify-items: center;
}

body.focus-mode .next-note-hero {
  max-width: min(760px, 100%);
  box-shadow:
    0 8px 0 -4px rgba(31, 42, 74, 0.08),
    0 20px 40px -22px rgba(31, 42, 74, 0.32);
}

body.focus-mode .ear-stage {
  grid-template-columns: minmax(0, 1fr);
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

body.focus-mode .ear-play {
  align-content: center;
}

body.focus-mode.memory-mode .stage,
body.focus-mode.rhythm-mode .stage {
  grid-template-columns: minmax(0, 1fr);
  max-width: 980px;
}

body.focus-mode.memory-mode .play-area,
body.focus-mode.rhythm-mode .play-area {
  justify-self: center;
  width: min(760px, 100%);
}

body.focus-mode.memory-mode .next-note-hero,
body.focus-mode.rhythm-mode .next-note-hero,
body.focus-mode.rhythm-mode .rhythm-panel {
  justify-self: center;
  width: min(720px, 100%);
}

body.focus-mode.memory-mode .memory-card-grid {
  justify-self: center;
  width: min(640px, 100%);
}

body.rhythm-mode .stage {
  grid-template-columns: 1fr minmax(420px, 720px);
  align-items: center;
  gap: clamp(18px, 4vw, 42px);
}

body.rhythm-mode .buddy-stage {
  align-self: center;
}

body.rhythm-mode .extras-grid,
body.rhythm-mode .magic-knobs,
body.rhythm-mode .reflection-card,
body.rhythm-mode .practice-review-card,
body.rhythm-mode .sheet-bridge-card {
  display: none !important;
}

body.rhythm-mode .metronome-guide,
body.rhythm-mode .beat-coach {
  display: none;
}

/* ----- Extras grid (mini-games) ----- */

.extras-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
  max-width: 720px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.extras-card {
  display: none;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid var(--cream-deep);
  box-shadow: var(--shadow-press);
  position: relative;
  z-index: 1;
}

body.extra-bridges .extra-bridges,
body.extra-brain .extra-brain,
body.extra-beat .extra-beat,
body.extra-lens .extra-lens,
body.extra-recorder .extra-recorder,
body.extra-composer .extra-composer,
body.extra-chords .extra-chords {
  display: grid;
  gap: 10px;
}

.extras-head {
  display: grid;
  gap: 2px;
}

.extras-eyebrow {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral-deep);
}

.extras-head strong {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 1rem;
}

.extras-cue {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
}

/* Brain Link */
.brain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.brain-grid > div {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--sun-soft);
}

.brain-grid span {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sun-deep);
  margin-bottom: 2px;
}

.brain-grid strong {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.2;
}

/* Beat Builder */
.beat-dots {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.beat-dots span {
  height: 18px;
  border-radius: 999px;
  background: var(--cream-deep);
  transition: background 140ms ease;
}

.beat-dots span.lit {
  background: var(--plum);
  box-shadow: 0 0 8px rgba(163, 123, 209, 0.6);
}

.beat-tap {
  justify-self: start;
}

/* Melody Lens */
.lens-sky {
  display: block;
  width: 100%;
  height: 90px;
  color: var(--teal);
  background: linear-gradient(180deg, #ecf6ff, #f5fce8);
  border-radius: 12px;
  padding: 6px;
}

/* Recording Studio */
.recorder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.recorder-row .round-btn {
  font-size: 0.88rem;
  padding: 8px 14px 8px 10px;
  border-width: 2px;
  box-shadow: 0 4px 0 -1px var(--ink);
}

#recordToggle[aria-pressed="true"] {
  background: var(--coral-soft);
  border-color: var(--coral-deep);
}

/* ----- Note teacher ----- */

.note-teacher {
  margin-top: 28px;
  padding: 20px 22px;
  border-radius: var(--r-md);
  background: #fff;
  border: 2px solid var(--cream-deep);
  box-shadow: var(--shadow-press);
  display: grid;
  gap: 14px;
}

.note-teacher-header {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
}

.kicker-chip {
  display: inline-grid;
  place-items: center;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--sun-soft);
  color: var(--sun-deep);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.note-teacher-header strong {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.3;
}

.note-teacher-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.note-teacher-row button {
  display: grid;
  gap: 2px;
  padding: 14px 4px 12px;
  border-radius: 12px 12px 18px 18px;
  border: 2px solid var(--cream-deep);
  background: linear-gradient(180deg, #fff, #f5fce8);
  font-family: var(--font-heading);
  color: var(--ink);
  cursor: pointer;
  box-shadow: inset 0 -6px 0 rgba(168, 211, 106, 0.18);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.note-teacher-row button b {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.note-teacher-row button small {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.note-teacher-row button:hover {
  transform: translateY(-3px);
  border-color: var(--sun);
}

.note-teacher-row button.playing {
  background:
    radial-gradient(circle at 50% 18%, #fff 0 18%, transparent 19%),
    linear-gradient(180deg, color-mix(in srgb, var(--teach-color, var(--sun)) 40%, white), #fff);
  border-color: color-mix(in srgb, var(--teach-color, var(--sun)) 76%, var(--ink));
  color: var(--ink);
  transform: translateY(-3px);
  box-shadow:
    inset 0 -6px 0 color-mix(in srgb, var(--teach-color, var(--sun)) 36%, transparent),
    0 0 0 5px color-mix(in srgb, var(--teach-color, var(--sun)) 35%, transparent),
    0 10px 22px color-mix(in srgb, var(--teach-color, var(--sun)) 42%, transparent);
}

.note-teacher-row button.heard:not(.playing) {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--teach-color, var(--sun)) 28%, white),
    #fff
  );
  border-color: color-mix(in srgb, var(--teach-color, var(--sun)) 54%, white);
  box-shadow:
    inset 0 -6px 0 color-mix(in srgb, var(--teach-color, var(--sun)) 24%, transparent),
    0 5px 14px color-mix(in srgb, var(--teach-color, var(--sun)) 22%, transparent);
}

/* ----- Warmups (tucked) ----- */

.warmup-strip {
  margin-top: 28px;
  padding: 22px;
  border-radius: var(--r-md);
  background: var(--paper);
  border: 2px dashed var(--cream-deep);
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) 1fr;
  gap: 22px;
  align-items: center;
}

.warmup-strip h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin: 0 0 4px;
}

.warmup-strip .warmup-copy p {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 0;
}

.warmup-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.warmup-btn {
  border: none;
  background: var(--cream);
  border-radius: var(--r-md);
  padding: 14px 12px;
  text-align: left;
  display: grid;
  gap: 4px;
  border: 2px solid transparent;
  transition: all 160ms ease;
  font-family: var(--font-body);
}

.warmup-btn .glyph {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--w-color, var(--teal-soft));
  color: var(--w-ink, var(--teal-deep));
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.warmup-btn .glyph svg {
  width: 22px;
  height: 22px;
}

.warmup-btn b {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.05;
}

.warmup-btn small {
  color: var(--ink-mute);
  font-size: 0.78rem;
  font-weight: 600;
}

.warmup-btn:hover {
  background: #fff;
  border-color: var(--w-color, var(--teal-soft));
  transform: translateY(-2px);
}
.warmup-btn.playing {
  background: #fff;
  border-color: var(--w-ink, var(--teal-deep));
}

/* ==========================================================
   IN-GAME — FULL BLEED
   ========================================================== */

.game {
  position: fixed;
  inset: 0;
  z-index: 30;
  background:
    radial-gradient(
      circle at 14% 18%,
      rgba(168, 211, 106, 0.22),
      transparent 26rem
    ),
    radial-gradient(
      circle at 84% 80%,
      rgba(41, 163, 157, 0.16),
      transparent 30rem
    ),
    linear-gradient(180deg, #f5fce8 0%, #dfeec0 100%);
  display: none;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  animation: fade-in 280ms ease;
}

.stage-fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.stage-fx-note {
  position: absolute;
  left: var(--fx-x, 50%);
  top: var(--fx-y, 54%);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--sun-deep);
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 900;
  text-shadow:
    0 2px 0 #fff,
    0 14px 26px rgba(31, 42, 74, 0.2);
  animation: stage-fx-rise 1180ms cubic-bezier(0.18, 0.9, 0.22, 1) both;
  animation-delay: var(--fx-delay, 0ms);
}

.stage-fx-memory { color: var(--plum); }
.stage-fx-rhythm,
.stage-fx-beat { color: var(--teal-deep); }
.stage-fx-phrase { color: var(--coral-deep); }
.stage-fx-bridge { color: var(--leaf-deep, #3a7d3a); }
.stage-fx-brain-spark { color: var(--sun-deep); }

.stage-fx-badge {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 3px solid currentColor;
  background: rgba(255, 255, 255, 0.92);
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 900;
  box-shadow: 0 8px 0 -2px rgba(31, 42, 74, 0.18);
  animation: stage-fx-badge-pop 1050ms ease both;
}

@keyframes stage-fx-rise {
  0% {
    opacity: 0;
    transform: translate3d(-50%, 24px, 0) rotate(-12deg) scale(0.72);
  }
  20% {
    opacity: 1;
  }
  74% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(-50% + 28px), -108px, 0) rotate(18deg) scale(1.18);
  }
}

@keyframes stage-fx-badge-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.86);
  }
  18%,
  78% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.96);
  }
}

body.game-active .game {
  display: grid;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Song-specific backgrounds layered behind the tint */
body.game-active .game::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--song-bg, url("../assets/kid-music-room-bg.png"));
  background-size: cover;
  background-position: center;
  opacity: var(--song-bg-opacity, 0.72);
  pointer-events: none;
  transition: opacity 400ms ease;
  z-index: 0;
}

body.game-active .game::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(245, 252, 232, 0.2), rgba(255, 247, 230, 0.28)),
    radial-gradient(circle at 50% 76%, rgba(255, 255, 255, 0.32), transparent 30rem);
  pointer-events: none;
  z-index: 0;
}

body.song-bg-mary-lamb .game {
  --song-bg: url("../assets/kid-music-room-bg.png");
  --song-bg-opacity: 0.86;
}
body.song-bg-free-play .game {
  --song-bg: url("../assets/mode-cards/mode-card-make-own-16x9.png");
  --song-bg-opacity: 0.82;
}
body.song-bg-twinkle-start .game {
  --song-bg: url("../assets/song-bg-twinkle-start.png");
  --song-bg-opacity: 0.84;
}
body.song-bg-ode-to-joy .game {
  --song-bg: url("../assets/song-bg-ode-to-joy.png");
  --song-bg-opacity: 0.84;
}
body.song-bg-jingle-bells .game {
  --song-bg: url("../assets/song-bg-jingle-bells.png");
  --song-bg-opacity: 0.84;
}
body.song-bg-bach-doorway .game,
body.song-bg-bach-lantern .game,
body.song-bg-bach-cadence .game {
  --song-bg: url("../assets/bach-study-room-bg.png");
  --song-bg-opacity: 0.86;
}
body.song-bg-firefly-violin .game,
body.song-bg-pirate-fiddle .game,
body.song-bg-moonbeam .game,
body.song-bg-dragonfly .game,
body.song-bg-shooting-star .game,
body.song-bg-wild-horse .game {
  --song-bg: url("../assets/kid-music-room-bg.png");
  --song-bg-opacity: 0.8;
}
body.song-bg-hot-cross-buns .game,
body.song-bg-au-clair .game,
body.song-bg-lightly-row .game,
body.song-bg-lavender-lullaby .game,
body.song-bg-old-macdonald .game,
body.song-bg-london-bridge .game {
  --song-bg: url("../assets/kid-music-room-bg.png");
  --song-bg-opacity: 0.86;
}
body.song-bg-comet-tail .game,
body.song-bg-lantern-frog .game {
  --song-bg: url("../assets/kid-music-room-bg.png");
  --song-bg-opacity: 0.8;
}

@supports (background-image: image-set(url("../assets/kid-music-room-bg.webp") type("image/webp"))) {
  .ear-game {
    --ear-bg-image: image-set(
      url("../assets/kid-music-room-bg.webp") type("image/webp"),
      url("../assets/kid-music-room-bg.png") type("image/png")
    );
  }

  body.ear-name-mode .ear-game,
  body.ear-direction-mode .ear-game {
    --ear-bg-image: image-set(
      url("../assets/piano-classroom-banner.webp") type("image/webp"),
      url("../assets/piano-classroom-banner.png") type("image/png")
    );
  }

  body.ear-echo-mode .ear-game,
  body.ear-interval-mode .ear-game {
    --ear-bg-image: image-set(
      url("../assets/kid-music-room-bg.webp") type("image/webp"),
      url("../assets/kid-music-room-bg.png") type("image/png")
    );
  }

  body.game-active .game::before {
    background-image: var(
      --song-bg,
      image-set(
        url("../assets/kid-music-room-bg.webp") type("image/webp"),
        url("../assets/kid-music-room-bg.png") type("image/png")
      )
    );
  }

  body.song-bg-mary-lamb .game {
    --song-bg: image-set(
      url("../assets/kid-music-room-bg.webp") type("image/webp"),
      url("../assets/kid-music-room-bg.png") type("image/png")
    );
  }

  body.song-bg-free-play .game {
    --song-bg: image-set(
      url("../assets/mode-cards/mode-card-make-own-16x9.webp") type("image/webp"),
      url("../assets/mode-cards/mode-card-make-own-16x9.png") type("image/png")
    );
  }

  body.song-bg-twinkle-start .game {
    --song-bg: image-set(
      url("../assets/song-bg-twinkle-start.webp") type("image/webp"),
      url("../assets/song-bg-twinkle-start.png") type("image/png")
    );
  }

  body.song-bg-ode-to-joy .game {
    --song-bg: image-set(
      url("../assets/song-bg-ode-to-joy.webp") type("image/webp"),
      url("../assets/song-bg-ode-to-joy.png") type("image/png")
    );
  }

  body.song-bg-jingle-bells .game {
    --song-bg: image-set(
      url("../assets/song-bg-jingle-bells.webp") type("image/webp"),
      url("../assets/song-bg-jingle-bells.png") type("image/png")
    );
  }

  body.song-bg-bach-doorway .game,
  body.song-bg-bach-lantern .game,
  body.song-bg-bach-cadence .game {
    --song-bg: image-set(
      url("../assets/bach-study-room-bg.webp") type("image/webp"),
      url("../assets/bach-study-room-bg.png") type("image/png")
    );
  }

  body.song-bg-firefly-violin .game,
  body.song-bg-pirate-fiddle .game,
  body.song-bg-moonbeam .game,
  body.song-bg-dragonfly .game,
  body.song-bg-shooting-star .game,
  body.song-bg-wild-horse .game,
  body.song-bg-hot-cross-buns .game,
  body.song-bg-au-clair .game,
  body.song-bg-lightly-row .game,
  body.song-bg-lavender-lullaby .game,
  body.song-bg-old-macdonald .game,
  body.song-bg-london-bridge .game,
  body.song-bg-comet-tail .game,
  body.song-bg-lantern-frog .game {
    --song-bg: image-set(
      url("../assets/kid-music-room-bg.webp") type("image/webp"),
      url("../assets/kid-music-room-bg.png") type("image/png")
    );
  }
}

.game-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  position: relative;
  z-index: 1;
}

.top-left-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.top-right-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow:
    var(--shadow-press),
    0 12px 24px -8px rgba(31, 42, 74, 0.2);
  transition: transform 140ms ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
}
.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 -1px rgba(31, 42, 74, 0.08);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  color: var(--ink);
}

.top-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.metronome-guide,
.beat-coach {
  --beat-swing: 1500ms;
  min-height: 52px;
  display: grid;
  grid-template-columns: 42px auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow:
    var(--shadow-press),
    0 12px 24px -10px rgba(31, 42, 74, 0.22);
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease;
}

.metronome-guide {
  grid-template-columns: 42px auto;
}

.beat-coach {
  grid-template-columns: 32px auto;
}

.metronome-guide:hover,
.beat-coach:hover {
  transform: translateY(-2px);
}

.metronome-guide:active,
.beat-coach:active {
  transform: translateY(2px);
}

.metronome-guide.running,
.beat-coach.running {
  background: #fff8df;
}

.metronome-guide.running,
.beat-coach.learning,
.beat-coach.running {
  box-shadow:
    0 0 0 3px rgba(255, 212, 89, 0.55),
    0 13px 24px -11px rgba(31, 42, 74, 0.28);
}

.metronome-pendulum {
  grid-row: 1 / 3;
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(224, 240, 194, 0.86)),
    var(--sun-soft);
  box-shadow: inset 0 -3px 0 rgba(31, 42, 74, 0.08);
  overflow: hidden;
}

.metronome-pendulum::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 7px;
  height: 3px;
  border-radius: 999px;
  background: rgba(91, 133, 40, 0.28);
}

.pendulum-string {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 3px;
  height: 27px;
  border-radius: 999px;
  background: var(--sun-deep);
  transform-origin: 50% 4px;
  transform: translateX(-50%) rotate(-24deg);
}

.pendulum-weight {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 2px 0 rgba(168, 85, 44, 0.3);
  transform: translateX(-50%) translateX(-10px);
}

.metronome-guide.running .pendulum-string {
  animation: metronome-swing var(--beat-swing) ease-in-out infinite;
}

.metronome-guide.running .pendulum-weight {
  animation: metronome-weight var(--beat-swing) ease-in-out infinite;
}

@keyframes metronome-swing {
  0%,
  100% {
    transform: translateX(-50%) rotate(-25deg);
  }
  50% {
    transform: translateX(-50%) rotate(25deg);
  }
}

@keyframes metronome-weight {
  0%,
  100% {
    transform: translateX(-50%) translateX(-10px);
  }
  50% {
    transform: translateX(-50%) translateX(10px);
  }
}

.beat-coach-icon {
  grid-row: 1 / 3;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sun-soft);
  color: var(--sun-deep);
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.meter-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-heading);
  line-height: 1;
}

.meter-copy strong {
  font-size: 0.88rem;
}

.meter-copy small {
  color: var(--ink-mute);
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 44px;
}

.meter-dots {
  display: grid;
  grid-template-columns: repeat(4, 14px);
  gap: 4px;
}

.meter-dots i {
  height: 7px;
  border-radius: 999px;
  background: var(--cream-deep);
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease;
}

.meter-dots i.lit {
  transform: translateY(-1px);
  background: var(--sun);
  box-shadow: 0 0 0 3px rgba(255, 212, 89, 0.22);
}

.song-pill {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 20px;
  background: #fff;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-card);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  border: none;
  font-size: 1.05rem;
}

.song-pill .chev-disc {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cream-deep);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.song-pill .mode-chip {
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--cream-deep);
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.stars-ribbon {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
}

.stars-ribbon .ribbon-star {
  width: 22px;
  height: 22px;
  color: var(--cream-deep);
  transition:
    color 220ms ease,
    transform 220ms ease;
}

.stars-ribbon .ribbon-star.filled {
  color: var(--sun-deep);
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px rgba(168, 211, 106, 0.7));
}

.midi-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.midi-indicator::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-mute);
}

.midi-indicator.connected {
  color: var(--sun-deep);
}

body.real-piano-mode .midi-indicator {
  background: #e6f7f1;
  color: var(--teal-deep);
}

.midi-indicator.connected::before {
  background: var(--sun);
  box-shadow: 0 0 8px rgba(168, 211, 106, 0.8);
  animation: midi-pulse 1.8s ease-in-out infinite;
}

@keyframes midi-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* ----- Stage layout ----- */

.stage {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 24px;
  padding: 4px 32px 16px;
  align-items: end;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.buddy-stage {
  position: relative;
  align-self: end;
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100%;
  padding-bottom: 8px;
}

.speech-bubble {
  position: relative;
  align-self: end;
  background: var(--paper);
  padding: 22px 24px;
  border-radius: 28px 28px 28px 6px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
  border: 3px solid #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--ink);
  line-height: 1.3;
  max-width: 320px;
  min-height: 80px;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -14px;
  left: 32px;
  width: 22px;
  height: 22px;
  background: var(--paper);
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(45deg);
  box-shadow: 4px 4px 8px rgba(31, 42, 74, 0.08);
}

.speech-bubble .who {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral-deep);
  margin-bottom: 4px;
}

.speech-bubble.tone-cheer {
  background: #f7fbe6;
  border-color: var(--sun-soft);
}
.speech-bubble.tone-cheer::after {
  background: #f7fbe6;
}
.speech-bubble.tone-hint {
  background: #ecf6ff;
  border-color: var(--cobalt-soft);
}
.speech-bubble.tone-hint::after {
  background: #ecf6ff;
}
.speech-bubble.tone-win {
  background: #ecfaef;
  border-color: var(--leaf-soft);
}
.speech-bubble.tone-win::after {
  background: #ecfaef;
}

.buddy-character {
  align-self: end;
  display: grid;
  justify-items: center;
}

.buddy-character svg,
.buddy-character img.buddy-img,
.buddy-character .buddy-sprite {
  width: var(--buddy-size, 240px);
  height: auto;
  filter: drop-shadow(0 16px 24px rgba(31, 42, 74, 0.2));
  animation: buddy-float 4.6s ease-in-out infinite;
}

.buddy-character img.buddy-img {
  border-radius: 22px;
  object-fit: cover;
}

.buddy-character .buddy-sprite {
  display: block;
  aspect-ratio: 3 / 4;
  max-width: 100%;
  background-position: 0 0;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  animation:
    buddy-idle-cycle 28s step-end infinite,
    buddy-breathe 7.5s ease-in-out infinite;
}

.buddy-character.buddy-cheer .buddy-sprite {
  animation:
    buddy-cheer-cycle 1.9s step-end 1,
    buddy-cheer-bounce 1.9s ease-out 1;
}

.buddy-character.buddy-help .buddy-sprite {
  animation:
    buddy-help-cycle 1.6s step-end 1,
    buddy-help-nod 1.6s ease-in-out 1;
}

.buddy-character.buddy-listen .buddy-sprite {
  animation:
    buddy-listen-cycle 1.8s step-end 1,
    buddy-listen-sway 1.8s ease-in-out 1;
}

.buddy-sprite-chloe {
  background-image: image-set(
    url("../assets/sprites/chloe-buddy-sprite-16.webp") type("image/webp"),
    url("../assets/sprites/chloe-buddy-sprite-16.png") type("image/png")
  );
}

.buddy-sprite-noah {
  background-image: image-set(
    url("../assets/sprites/noah-buddy-sprite-16.webp") type("image/webp"),
    url("../assets/sprites/noah-buddy-sprite-16.png") type("image/png")
  );
}

@keyframes buddy-float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}

@keyframes buddy-cheer-bounce {
  0% { transform: translateY(0) rotate(-0.8deg) scale(1); }
  34% { transform: translateY(-5px) rotate(1.3deg) scale(1.015); }
  68% { transform: translateY(1px) rotate(-0.6deg) scale(0.998); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes buddy-help-nod {
  0%,
  100% { transform: translateY(0) rotate(-0.5deg); }
  32% { transform: translateY(2px) rotate(0.9deg); }
  64% { transform: translateY(-1px) rotate(-0.8deg); }
}

@keyframes buddy-breathe {
  0%,
  100% { transform: translateY(0) rotate(-0.7deg); }
  50% { transform: translateY(-4px) rotate(0.7deg); }
}

@keyframes buddy-listen-sway {
  0%,
  100% { transform: translateY(0) rotate(-0.4deg); }
  50% { transform: translateY(-3px) rotate(0.8deg); }
}

@keyframes buddy-idle-cycle {
  0%,
  38% {
    background-position: 0 0;
  }

  38.01%,
  50% {
    background-position: 33.333% 0;
  }

  50.01%,
  62% {
    background-position: 66.666% 0;
  }

  62.01%,
  100% {
    background-position: 100% 0;
  }
}

@keyframes buddy-cheer-cycle {
  0%,
  18% {
    background-position: 0 66.666%;
  }

  18.01%,
  36% {
    background-position: 33.333% 66.666%;
  }

  36.01%,
  54% {
    background-position: 66.666% 66.666%;
  }

  54.01%,
  100% {
    background-position: 100% 66.666%;
  }
}

@keyframes buddy-help-cycle {
  0%,
  26% { background-position: 0 100%; }
  36.01%,
  62% { background-position: 33.333% 100%; }
  70.01%,
  84% { background-position: 66.666% 100%; }
  84.01%,
  100% { background-position: 100% 100%; }
}

@keyframes buddy-listen-cycle {
  0%,
  25% { background-position: 0 33.333%; }
  34.01%,
  50% { background-position: 33.333% 33.333%; }
  67.01%,
  75% { background-position: 66.666% 33.333%; }
  75.01%,
  100% { background-position: 100% 33.333%; }
}

/* ----- Center play area ----- */

.play-area {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
  min-height: 0;
  align-self: stretch;
  padding-bottom: 8px;
}

.next-note-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #fff, #f7fbe6);
  border-radius: var(--r-md);
  border: 3px solid var(--cream-deep);
  box-shadow: var(--shadow-card);
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.next-note-hero .nn-label {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  display: block;
}

.next-note-hero .nn-cue {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.15rem;
  margin-top: 2px;
}

/* Brain Link card — the visible 4-channel reinforcement.
   Lights up hear/see/say/play for the current target note across every mode. */
.brain-link-card {
  position: relative;
  overflow: hidden;
  margin-top: 8px;
  padding: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(243, 251, 225, 0.9)),
    repeating-linear-gradient(45deg, rgba(41, 163, 157, 0.08) 0 8px, transparent 8px 16px);
  border: 2px dashed rgba(41, 163, 157, 0.36);
  border-radius: var(--r-sm);
  box-shadow:
    0 6px 0 -3px rgba(41, 163, 157, 0.16),
    0 18px 28px -22px rgba(31, 42, 74, 0.4);
}

.brain-link-card::before {
  content: "";
  position: absolute;
  inset: 30px 18px auto;
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(41, 163, 157, 0.32) 0 8px, transparent 8px 14px);
  pointer-events: none;
}

.brain-link-title {
  position: relative;
  display: block;
  font-family: var(--font-heading);
  font-weight: 900;
  letter-spacing: 0;
  font-size: 0.72rem;
  color: var(--teal-deep);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 6px;
}

.brain-link-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.brain-link-cell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  align-items: center;
  justify-items: center;
  gap: 2px;
  min-height: 72px;
  padding: 7px 5px;
  background: #ffffff;
  border: 2px solid rgba(58, 51, 28, 0.12);
  border-radius: 12px;
  font-family: var(--font-heading);
  color: var(--ink);
  transition: transform 140ms ease, background 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  cursor: default;
}

button.brain-link-cell {
  cursor: pointer;
}

button.brain-link-cell:hover {
  border-color: var(--sun);
  background: #fff8e6;
}

button.brain-link-cell:focus-visible {
  outline: 3px solid var(--teal-soft);
  outline-offset: 2px;
}

.brain-link-icon {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--teal-deep);
}

.brain-link-label {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.brain-link-hint {
  font-family: var(--font-body, var(--font-heading));
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.15;
  min-height: 1.6em;
}

.brain-link-cell.fired {
  background: linear-gradient(135deg, #fff8d9, #f4ffd7);
  border-color: var(--sun);
  box-shadow:
    0 0 0 4px rgba(254, 213, 102, 0.32),
    0 9px 18px -12px rgba(91, 133, 40, 0.58);
  transform: translateY(-1px);
}

.brain-link-cell.fired .brain-link-icon {
  color: var(--sun-ink, #a06b1c);
}

body.brain-spark-zone .brain-link-card {
  animation: brain-passport-glow 900ms ease both;
}

@keyframes brain-passport-glow {
  0% {
    box-shadow: 0 0 0 rgba(168, 211, 106, 0);
  }
  40% {
    box-shadow:
      0 0 0 8px rgba(168, 211, 106, 0.28),
      0 18px 32px -20px rgba(91, 133, 40, 0.52);
  }
  100% {
    box-shadow:
      0 6px 0 -3px rgba(41, 163, 157, 0.16),
      0 18px 28px -22px rgba(31, 42, 74, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .brain-link-cell,
  .brain-link-cell.fired,
  body.brain-spark-zone .brain-link-card {
    transition: none;
    animation: none;
    transform: none;
  }
}

/* Hide the card in modes where the channels don't apply.
   Free play + rhythm + memory-match + library all keep it visible because
   even there the target note benefits from hear/see/say/play reinforcement. */
.brain-link-card[hidden] {
  display: none;
}

.song-note-path {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  max-width: 420px;
}

.song-note-path[hidden] {
  display: none;
}

.song-note-chip {
  min-width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid var(--cream-deep);
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.86rem;
}

.song-note-chip.played {
  background: var(--leaf-soft);
  border-color: var(--leaf);
  color: var(--sun-deep);
}

.song-note-chip.current {
  background: var(--sun);
  border-color: var(--sun-deep);
  color: var(--ink);
  box-shadow: 0 0 0 4px rgba(168, 211, 106, 0.22);
}

.pattern-badge {
  width: fit-content;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 2px solid var(--coral);
  background: #fff7d9;
  color: var(--coral-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  box-shadow: 0 5px 0 -2px var(--coral);
  animation: badge-pop 360ms ease;
}

.pattern-badge[hidden] {
  display: none;
}

@keyframes badge-pop {
  0% { transform: scale(0.82); opacity: 0; }
  70% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

.melody-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  gap: 6px;
  max-width: 460px;
  margin-top: 10px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  border: 2px solid var(--cream-deep);
}

.melody-map[hidden] {
  display: none;
}

.map-place {
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 42px;
  border-radius: 12px;
  background: #fff;
  border: 2px solid transparent;
  font-family: var(--font-heading);
  color: var(--ink-soft);
}

.map-place b {
  font-size: 0.92rem;
  line-height: 1;
}

.map-place small {
  font-size: 0.58rem;
  font-weight: 800;
}

.map-place.touched {
  background: var(--leaf-soft);
  color: var(--sun-deep);
}

.map-place.current {
  background: var(--sun-soft);
  border-color: var(--sun);
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(168, 211, 106, 0.24);
}

.direction-predictor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--ink-soft);
}

.direction-predictor[hidden] {
  display: none;
}

.direction-predictor button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 900;
}

.practice-review-card {
  display: grid;
  gap: 12px;
  width: min(720px, 88vw);
  margin: 0 auto;
  padding: 16px;
  border-radius: var(--r-md);
  border: 3px solid var(--leaf);
  background: linear-gradient(180deg, #fff, #f3fbe1);
  box-shadow: 0 7px 0 -2px #3a7d3a;
}

.practice-review-card[hidden] {
  display: none;
}

.practice-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.practice-review-head strong {
  font-family: var(--font-heading);
  color: var(--ink);
}

.practice-review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.practice-review-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid var(--cream-deep);
}

.practice-review-grid b {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.practice-review-grid span {
  font-weight: 800;
  color: var(--ink);
}

.report-btn {
  justify-self: start;
}

.next-mode-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: min(720px, 88vw);
  margin: 0 auto;
  padding: 16px;
  border-radius: var(--r-md);
  border: 3px solid var(--plum);
  background:
    radial-gradient(circle at 16% 24%, rgba(255, 255, 255, 0.82), transparent 5.8rem),
    linear-gradient(135deg, #fff, #efe5ff 54%, #e9fbf8);
  box-shadow: 0 7px 0 -2px #6d4ca5;
  animation: next-mode-pop 360ms ease both;
}

.next-mode-card[hidden] {
  display: none;
}

.next-mode-card strong {
  display: block;
  margin: 8px 0 4px;
  font-family: var(--font-heading);
  color: var(--ink);
}

.next-mode-card p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.35;
}

.next-mode-card button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 2px solid var(--plum);
  background: #fff;
  color: #6d4ca5;
  font-family: var(--font-heading);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 -2px #6d4ca5;
}

.next-mode-card button:hover,
.next-mode-card button:focus-visible {
  transform: translateY(-2px);
}

@keyframes next-mode-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sheet-bridge-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  width: min(720px, 88vw);
  margin: 0 auto;
  padding: 16px;
  border-radius: var(--r-md);
  border: 3px solid var(--teal);
  background: linear-gradient(135deg, #fff, var(--teal-soft));
  box-shadow: 0 7px 0 -2px var(--teal-deep);
}

.sheet-bridge-card[hidden] {
  display: none;
}

.sheet-bridge-card strong {
  display: block;
  margin: 8px 0 4px;
  font-family: var(--font-heading);
  color: var(--ink);
}

.sheet-bridge-card p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.35;
}

.sheet-bridge-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sheet-bridge-actions a,
.sheet-bridge-actions button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  border: 2px solid var(--teal);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  text-decoration: none;
}

.balance-break-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: min(720px, 88vw);
  margin: 0 auto;
  padding: 16px;
  border-radius: var(--r-md);
  border: 3px solid var(--coral);
  background: linear-gradient(135deg, #fff, var(--coral-soft));
  box-shadow: 0 7px 0 -2px var(--coral-deep);
}

.balance-break-card[hidden] {
  display: none;
}

.balance-break-card strong {
  display: block;
  margin: 8px 0 4px;
  font-family: var(--font-heading);
  color: var(--ink);
}

.balance-break-card p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.35;
}

.balance-break-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.balance-break-actions button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  border: 2px solid var(--coral);
  background: #fff;
  color: var(--coral-deep);
  font-family: var(--font-heading);
  font-weight: 800;
}

.next-note-hero .nn-letter {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 3.05rem;
  line-height: 1;
  color: var(--ink);
  background: var(--key-color, var(--sun));
  width: 76px;
  height: 76px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 -8px 0 rgba(0, 0, 0, 0.12),
    0 8px 16px rgba(31, 42, 74, 0.2);
  animation: pulse-glow 1.4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      inset 0 -8px 0 rgba(0, 0, 0, 0.12),
      0 8px 16px rgba(31, 42, 74, 0.2);
  }
  50% {
    transform: scale(1.04);
    box-shadow:
      inset 0 -8px 0 rgba(0, 0, 0, 0.12),
      0 12px 28px rgba(168, 211, 106, 0.6);
  }
}

.next-note-hero .progress-tube {
  width: 160px;
  height: 14px;
  border-radius: var(--r-pill);
  background: var(--cream-deep);
  overflow: hidden;
  position: relative;
}

.next-note-hero .progress-tube > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--teal), var(--sun));
  border-radius: inherit;
  transition: width 240ms ease;
}

.next-note-hero .progress-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 6px;
  text-align: right;
}

/* Memory cards */

.memory-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(108px, 1fr));
  gap: 16px;
  width: min(760px, 100%);
  margin: 0 auto;
  perspective: 900px;
}

.memory-card-grid[hidden] {
  display: none;
}

.memory-note-card {
  appearance: none;
  border: 0;
  background: transparent;
  min-height: 148px;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  perspective: inherit;
}

.memory-note-card:disabled {
  cursor: default;
}

.memory-card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 148px;
  transform-style: preserve-3d;
  transition: transform 260ms ease;
}

.memory-note-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 4px solid var(--cobalt-soft);
  box-shadow:
    0 8px 0 -1px rgba(31, 42, 74, 0.18),
    0 16px 28px -18px rgba(31, 42, 74, 0.42);
  backface-visibility: hidden;
  font-family: var(--font-heading);
  font-weight: 700;
}

.memory-card-back {
  gap: 4px;
  background:
    radial-gradient(circle at 25% 18%, rgba(255, 255, 255, 0.92), transparent 1.9rem),
    radial-gradient(circle at 78% 82%, rgba(255, 212, 89, 0.24), transparent 2.4rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(205, 235, 232, 0.9)),
    var(--cobalt-soft);
  color: var(--cobalt-deep);
  font-size: 1.4rem;
}

.memory-card-spark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--coral-deep);
  font-size: 1.85rem;
  box-shadow: inset 0 -3px 0 rgba(31, 42, 74, 0.08);
}

.memory-card-front {
  transform: rotateY(180deg);
  grid-template-rows: 1fr auto auto;
  gap: 4px;
  background: var(--memory-color, var(--sun-soft));
  border-color: var(--memory-color, var(--sun));
  color: var(--ink);
}

.memory-staff {
  width: min(92px, 86%);
  height: 62px;
  align-self: end;
  padding: 4px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 -3px 0 rgba(31, 42, 74, 0.08);
  overflow: visible;
}

.memory-staff line {
  stroke: rgba(31, 42, 74, 0.54);
  stroke-width: 2;
  stroke-linecap: round;
}

.memory-staff .staff-ledger {
  stroke: var(--ink);
  stroke-width: 2.3;
}

.memory-staff .staff-note-head {
  fill: var(--ink);
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(-18deg);
}

.memory-card-note {
  font-size: 2.8rem;
  line-height: 1;
}

.memory-card-solfege {
  align-self: start;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.72);
  color: var(--coral-deep);
  font-size: 0.76rem;
}

.memory-note-card.remembered .memory-card-back {
  border-color: var(--leaf);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(213, 239, 216, 0.92)),
    var(--leaf-soft);
}

.memory-note-card:not(:disabled):hover .memory-card-inner,
.memory-note-card:not(:disabled):focus-visible .memory-card-inner {
  transform: translateY(-3px);
}

.memory-note-card.flipped:not(:disabled):hover .memory-card-inner,
.memory-note-card.flipped:not(:disabled):focus-visible .memory-card-inner {
  transform: translateY(-3px) rotateY(180deg);
}

body.memory-mode .stage {
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  align-items: stretch;
}

body.memory-mode .play-area {
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 22px;
}

body.memory-mode .next-note-hero {
  max-width: 760px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), #f2efff);
  border-color: var(--plum-soft);
}

body.memory-mode .next-note-hero .nn-letter {
  background: var(--plum-soft);
  animation: none;
}

body.memory-mode .magic-knobs,
body.memory-mode .reflection-card,
body.memory-mode .piano-wrap,
body.memory-mode .piano-controls,
body.memory-mode .extras-grid {
  display: none;
}

body.memory-mode .memory-card-grid {
  align-self: start;
  padding: 22px;
  border-radius: 32px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.64), rgba(239, 246, 255, 0.54)),
    rgba(255, 255, 255, 0.38);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}

/* Rhythm tapping */

.rhythm-panel {
  display: grid;
  gap: 18px;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 2.4vw, 26px);
  border-radius: var(--r-md);
  border: 3px solid var(--teal);
  background: linear-gradient(135deg, #f7fffb, var(--teal-soft));
  box-shadow: var(--shadow-card);
}

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

.rhythm-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  font-family: var(--font-heading);
}

.rhythm-kicker,
.rhythm-head small {
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: #fff;
  color: #1d6b68;
  font-weight: 700;
}

.rhythm-head strong {
  color: var(--ink);
  font-size: 1.3rem;
}

.rhythm-beats {
  display: grid;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  gap: 10px;
}

.rhythm-variants {
  display: inline-flex;
  justify-self: start;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  padding: 4px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.76);
  border: 2px solid rgba(26, 118, 114, 0.18);
}

.rhythm-variants button {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  border: 0;
  background: transparent;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.9rem;
}

.rhythm-variants button[aria-pressed="true"] {
  background: #fff;
  box-shadow: 0 4px 10px rgba(26, 118, 114, 0.14);
}

.rhythm-beat {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid var(--cream-deep);
  background: #fff;
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-weight: 700;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease;
}

.rhythm-beat.hit {
  border-color: var(--coral);
  background: var(--coral-soft);
  color: var(--coral-deep);
}

.rhythm-beat.rest {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.56);
}

.rhythm-beat.active {
  transform: scale(1.12);
  border-color: #1d6b68;
  background: var(--teal-soft);
  color: #1d6b68;
}

.rhythm-beat.tapped {
  background: var(--sun-soft);
  border-color: var(--sun);
  color: var(--sun-deep);
}

.rhythm-tap {
  min-height: 86px;
  border: 0;
  border-radius: var(--r-md);
  background: #1d6b68;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.45rem;
  cursor: pointer;
  box-shadow: 0 7px 0 #124947;
  transition:
    transform 90ms ease,
    box-shadow 90ms ease;
}

.rhythm-tap:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #124947;
}

.rhythm-tap:disabled {
  opacity: 0.62;
  cursor: default;
}

.rhythm-status {
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink-soft);
  font-weight: 800;
  text-align: center;
}

.beat-builder-toggle,
.beat-builder-head button {
  justify-self: center;
  border: 2px solid var(--teal);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  padding: 8px 14px;
}

.beat-builder {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  border: 2px dashed var(--teal);
  background: rgba(255, 255, 255, 0.7);
}

.beat-builder[hidden] {
  display: none;
}

.beat-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-heading);
}

.beat-builder-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 8px;
}

.builder-slot {
  min-height: 62px;
  border-radius: 16px;
  border: 3px solid var(--cream-deep);
  background: #fff;
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 800;
}

.builder-slot.sound {
  border-color: var(--coral);
  background: var(--coral-soft);
  color: var(--coral-deep);
}

.builder-slot.rest {
  border-style: dashed;
}

.builder-slot span {
  font-size: 0.72rem;
  text-transform: uppercase;
}

body.rhythm-mode .piano-wrap {
  display: none;
}

body.rhythm-mode .play-area {
  justify-content: center;
  align-content: center;
}

body.rhythm-mode .next-note-hero {
  width: min(720px, 100%);
  margin: 0 auto;
  grid-template-columns: auto 1fr auto;
}

body.rhythm-mode .next-note-hero .mini-staff {
  opacity: 0.72;
}

body.rhythm-mode .extras-grid,
body.rhythm-mode .magic-knobs,
body.rhythm-mode .reflection-card,
body.rhythm-mode .practice-review-card,
body.rhythm-mode .sheet-bridge-card,
body.rhythm-mode .metronome-guide,
body.rhythm-mode .beat-coach,
body.rhythm-mode .piano-wrap {
  display: none !important;
}

body.rhythm-mode .stage {
  grid-template-columns: 1fr minmax(420px, 720px);
  align-items: center;
  gap: clamp(18px, 4vw, 42px);
}

body.rhythm-mode .play-area {
  justify-content: center;
  align-content: center;
}

body.rhythm-mode .next-note-hero {
  width: min(720px, 100%);
  margin: 0 auto;
  grid-template-columns: auto 1fr auto;
}

/* Piano */

.piano-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.piano {
  --pw: min(760px, 100%);
  width: var(--pw);
  max-width: 100%;
  height: clamp(158px, min(28vw, 26vh), 228px);
  background: linear-gradient(180deg, #1f4f9e 0%, #14377a 100%);
  border-radius: 18px;
  border: 5px solid #14377a;
  padding: 10px 12px;
  box-shadow:
    0 20px 40px -10px rgba(31, 42, 74, 0.4),
    inset 0 6px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  display: flex;
  align-items: flex-end;
}

.piano::before {
  content: "";
  position: absolute;
  inset: 4px 6px auto 6px;
  height: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent);
  border-radius: 8px;
}

.keys {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: clamp(3px, 0.72vw, 6px);
  width: 100%;
  height: 100%;
}

.played-note-float {
  position: absolute;
  z-index: 8;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--note-color, var(--sun));
  text-shadow:
    0 2px 0 #fff,
    0 8px 16px rgba(31, 42, 74, 0.18);
  animation: played-note-rise 920ms ease-out forwards;
}

.white-key {
  position: relative;
  border: none;
  border-radius: 0 0 16px 16px;
  background: var(--key-fill, #fff);
  box-shadow:
    inset 0 -10px 0 rgba(0, 0, 0, 0.1),
    0 4px 0 rgba(0, 0, 0, 0.18);
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 8px 6px 12px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 80ms ease,
    box-shadow 80ms ease,
    background-color 160ms ease;
}

.white-key:active,
.white-key.pressed {
  transform: translateY(3px);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.white-key .key-name {
  align-self: end;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 1.3rem;
  text-align: center;
}

.white-key .key-letter {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
}

.white-key.highlight,
.black-key.highlight {
  animation: key-bloom 1.4s ease-in-out infinite;
  box-shadow:
    inset 0 -10px 0 rgba(0, 0, 0, 0.06),
    0 4px 0 rgba(0, 0, 0, 0.18),
    0 0 0 4px color-mix(in srgb, var(--highlight-color, var(--leaf)) 56%, white),
    0 0 30px color-mix(in srgb, var(--highlight-color, var(--leaf)) 70%, transparent);
}

@keyframes key-bloom {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.1);
  }
}

.white-key.played,
.black-key.played {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--played-color, var(--sun)) 76%, white),
    var(--played-color, var(--sun))
  );
  animation: key-pop 360ms ease;
}

@keyframes key-pop {
  0% {
    transform: translateY(3px) scale(0.98);
  }
  50% {
    transform: translateY(-4px) scale(1.03);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.black-key {
  position: absolute;
  width: clamp(34px, 10%, 54px);
  height: 46%;
  min-height: 62px;
  top: 0;
  background: linear-gradient(180deg, #2c2c3e 0%, #1a1a26 100%);
  border-radius: 0 0 10px 10px;
  border: none;
  box-shadow:
    inset 0 -6px 0 rgba(255, 255, 255, 0.06),
    0 4px 0 rgba(0, 0, 0, 0.4);
  display: grid;
  align-content: end;
  padding-bottom: 8px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.74rem;
  text-align: center;
  z-index: 2;
  transition:
    transform 80ms ease,
    box-shadow 80ms ease,
    background-color 160ms ease;
}

.black-key:active,
.black-key.pressed {
  transform: translateY(2px);
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.04);
}

@keyframes played-note-rise {
  0% {
    opacity: 0;
    transform: translate3d(0, 8px, 0) rotate(-8deg) scale(0.72);
  }

  18% {
    opacity: 1;
    transform: translate3d(0, -12px, 0) rotate(3deg) scale(1.05);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--float-drift, 10px), -82px, 0) rotate(18deg) scale(1.22);
  }
}

/* Round control buttons under piano */

.piano-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 4px;
}

.round-btn {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 22px 12px 14px;
  border-radius: var(--r-pill);
  border: 3px solid var(--ink);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: 0 6px 0 -1px var(--ink);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.round-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 -1px var(--ink);
}
.round-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 -1px var(--ink);
}

.round-btn .glyph {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--btn-color, var(--cream-deep));
  color: var(--btn-ink, var(--ink));
}

.round-btn .glyph svg {
  width: 16px;
  height: 16px;
}

.round-btn.active {
  background: var(--btn-color, var(--cream-deep));
}

.note-card-panel {
  width: min(720px, 88vw);
}

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

.note-card-page {
  position: relative;
  display: grid;
  grid-template-columns: minmax(160px, 0.75fr) 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-radius: 18px 18px 26px 26px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(31, 42, 74, 0.035) 0 1px,
      transparent 1px 28px
    ),
    linear-gradient(180deg, #fffef8, #fff9e8);
  border: 3px solid color-mix(in srgb, var(--note-card-color, var(--sun)) 42%, white);
  box-shadow:
    0 8px 0 -2px color-mix(in srgb, var(--note-card-color, var(--sun)) 38%, var(--ink)),
    0 18px 34px rgba(31, 42, 74, 0.18);
}

.note-card-staff-wrap {
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.note-card-staff {
  display: block;
  width: 100%;
  max-width: 210px;
}

.note-card-staff line {
  stroke: var(--ink-mute);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.note-card-staff #noteCardStaffNote {
  fill: var(--note-card-color, var(--sun));
  stroke: var(--ink);
  stroke-width: 2;
  transform: rotate(-18deg);
  transform-origin: center;
}

.note-card-kicker,
.note-card-tts {
  font-family: var(--font-heading);
  font-weight: 700;
}

.note-card-kicker {
  color: var(--plum);
  font-size: 0.76rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.note-card-copy h3 {
  margin: 4px 0 6px;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--ink);
}

.note-card-copy p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  line-height: 1.35;
}

.note-card-try {
  font-weight: 700;
  color: var(--ink);
}

.note-card-tts {
  border: 2px solid var(--cobalt-soft);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}

.note-card-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(31, 42, 74, 0.08);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================
   BACKPACK DRAWER
   ========================================================== */

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(31, 42, 74, 0.4);
  backdrop-filter: blur(2px);
  animation: fade-in 200ms ease;
  display: none;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  width: min(480px, 94vw);
  background: var(--paper);
  box-shadow: -20px 0 50px rgba(31, 42, 74, 0.25);
  padding: 22px 24px 32px;
  overflow-y: auto;
  display: none;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

body.drawer-open .drawer-scrim {
  display: block;
}
body.drawer-open .drawer {
  display: grid;
  animation: slide-in 280ms cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h2 {
  font-size: 1.4rem;
}

.drawer-body {
  overflow-y: auto;
  padding-right: 4px;
}

.drawer-section {
  border-radius: var(--r-md);
  background: #fff;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-press);
}

.drawer-section h3 {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

.drawer-section-tools {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(205, 235, 232, 0.42)),
    #fff;
  border: 2px solid rgba(41, 163, 157, 0.18);
}

.drawer-tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.drawer-tool-grid button {
  display: grid;
  gap: 3px;
  min-height: 62px;
  padding: 12px 14px;
  border: 2px solid var(--line, var(--cream-deep));
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-family: var(--font-heading);
  text-align: left;
  box-shadow: 0 5px 0 -2px rgba(31, 42, 74, 0.08);
}

.drawer-tool-grid button[aria-pressed="true"],
.drawer-tool-grid button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.drawer-tool-grid b {
  font-weight: 900;
}

.drawer-tool-grid small {
  color: var(--ink-soft);
  font-weight: 700;
  line-height: 1.3;
}

.song-list {
  display: grid;
  gap: 8px;
}

.song-group-header {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 8px 4px 2px;
}

.song-group-header:first-child {
  padding-top: 0;
}

.song-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 2px solid var(--cream-deep);
  background: var(--cream);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  font-size: 0.98rem;
  cursor: pointer;
}

.song-row .num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}

.song-row.active {
  background: #f3fbe1;
  border-color: var(--sun);
}
.song-row.active .num {
  background: var(--sun);
}

.song-row .meta {
  font-size: 0.74rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.song-row:hover {
  transform: translateY(-1px);
}

.buddy-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.buddy-chip {
  display: grid;
  gap: 8px;
  padding: 14px 12px;
  border-radius: var(--r-md);
  border: 2px solid var(--cream-deep);
  background: var(--cream);
  font-family: var(--font-heading);
  font-weight: 700;
  text-align: center;
  font-size: 1rem;
  color: var(--ink);
  justify-items: center;
  cursor: pointer;
}

.buddy-chip svg,
.buddy-chip-img {
  width: 56px;
  height: 56px;
}
.buddy-chip-img {
  border-radius: 14px;
  object-fit: cover;
}
.buddy-chip.active {
  background: #f3fbe1;
  border-color: var(--sun);
}

.drawer-toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.drawer-toggle-row .lbl {
  display: grid;
  gap: 2px;
}

.drawer-toggle-row .lbl b {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
}

.drawer-toggle-row .lbl small {
  color: var(--ink-mute);
  font-size: 0.82rem;
}

.toggle {
  width: 52px;
  height: 30px;
  border-radius: var(--r-pill);
  background: var(--cream-deep);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 180ms ease;
}

.toggle::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  box-shadow: 0 2px 4px rgba(31, 42, 74, 0.2);
  transition: left 220ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

.toggle[aria-pressed="true"] {
  background: var(--teal);
}
.toggle[aria-pressed="true"]::after {
  left: 25px;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.drawer-actions button {
  padding: 12px;
  border-radius: var(--r-md);
  border: 2px solid var(--cream-deep);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
}

.drawer-actions button.danger {
  color: var(--coral-deep);
  border-color: var(--coral-soft);
}
.drawer-actions button.danger:hover {
  background: var(--coral-soft);
}

.midi-status {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--cream);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.midi-status.connected {
  background: #f3fbe1;
  color: var(--sun-deep);
}

.midi-status.listening {
  background: #e6f7f1;
  color: var(--teal-deep);
  border: 2px solid var(--teal);
}

.midi-status small {
  font-weight: 600;
  color: var(--ink-mute);
  font-size: 0.78rem;
}

.drawer-midi-action {
  width: 100%;
  margin-top: 10px;
  min-height: 40px;
  border: 2px solid var(--teal);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 800;
  cursor: pointer;
}

.drawer-midi-action[aria-pressed="true"] {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-deep);
}

.midi-footnote {
  display: block;
  margin-top: 8px;
  color: var(--ink-mute);
  font-weight: 650;
  line-height: 1.35;
}

.midi-calibration {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
}

.midi-calibration-head {
  display: grid;
  gap: 3px;
}

.midi-calibration-head b {
  font-family: var(--font-heading);
  color: var(--ink);
}

.midi-calibration-head small {
  color: var(--ink-mute);
  font-weight: 650;
  line-height: 1.35;
}

.midi-calibration-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.midi-cal-step {
  min-height: 34px;
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--cream);
  color: var(--ink-soft);
  font-family: var(--font-heading);
  font-weight: 900;
}

.midi-cal-step.done {
  border-color: var(--leaf);
  background: var(--leaf-soft);
  color: var(--sun-deep);
}

.midi-cal-step.current {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-deep);
}

.midi-calibration-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.midi-calibration-actions button {
  min-height: 36px;
  border: 2px solid var(--teal);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 850;
  cursor: pointer;
}

.parent-teacher-view {
  display: grid;
  gap: 16px;
  margin: 28px auto 0;
  max-width: 1160px;
  padding: 20px;
  border: 3px solid var(--teal-soft);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, #fff, #f7fffb);
  box-shadow: 0 10px 0 -5px rgba(29, 107, 104, 0.18);
}

.parent-teacher-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.parent-teacher-head h2 {
  margin: 4px 0 0;
  font-family: var(--font-heading);
  color: var(--ink);
}

.parent-teacher-head button,
.drawer-actions button {
  cursor: pointer;
}

.parent-teacher-head button {
  min-height: 40px;
  padding: 0 16px;
  border: 2px solid var(--teal);
  border-radius: var(--r-pill);
  background: var(--teal);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 900;
}

.parent-teacher-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.parent-stat {
  min-height: 78px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
}

.parent-stat b {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.55rem;
  color: var(--teal-deep);
}

.parent-stat small {
  color: var(--ink-mute);
  font-weight: 750;
}

.parent-teacher-body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr);
  gap: 12px;
}

.parent-teacher-insights,
.parent-teacher-midi {
  display: grid;
  gap: 10px;
}

.parent-insight,
.parent-midi-card {
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  line-height: 1.35;
}

.parent-insight b,
.parent-midi-card b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-heading);
  color: var(--ink);
}

.parent-insight span,
.parent-midi-card span {
  color: var(--ink-soft);
  font-weight: 700;
}

.drawer .parent-teacher-view {
  margin: 0;
  max-width: none;
  padding: 16px;
  border-width: 2px;
  border-radius: var(--r-md);
  box-shadow: none;
}

.drawer .parent-teacher-head {
  align-items: stretch;
  flex-direction: column;
}

.drawer .parent-teacher-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.drawer .parent-teacher-body {
  grid-template-columns: 1fr;
}

.drawer .parent-teacher-head button {
  width: 100%;
}

.mode-connection-path {
  position: relative;
  z-index: 4;
  display: grid;
  gap: 16px;
  margin: 28px auto 0;
  max-width: 1160px;
  padding: 20px;
  border: 3px dashed rgba(41, 163, 157, 0.34);
  border-radius: var(--r-md);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.82)),
    image-set(
      url("../assets/connected-mode-passport.webp") type("image/webp"),
      url("../assets/connected-mode-passport.png") type("image/png")
    )
      center / cover no-repeat,
    #fff;
  box-shadow:
    0 8px 0 -4px rgba(41, 163, 157, 0.18),
    0 18px 38px -28px rgba(31, 42, 74, 0.42);
  overflow: hidden;
}

.mode-connection-path > * {
  position: relative;
  z-index: 1;
}

.mode-connection-head {
  display: grid;
  gap: 6px;
}

.mode-connection-head h2 {
  margin: 0;
  font-family: var(--font-heading);
  color: var(--ink);
}

.mode-connection-head p {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 750;
  line-height: 1.4;
}

.mode-connection-steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.mode-connection-step {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 6px;
  min-height: 140px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 0 -2px rgba(31, 42, 74, 0.1);
  transition:
    transform 160ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.mode-connection-step:hover,
.mode-connection-step:focus-visible {
  transform: translateY(-2px);
  border-color: var(--teal);
}

.mode-connection-step::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -13px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  text-align: center;
  line-height: 22px;
  font-family: var(--font-heading);
  font-weight: 900;
}

.mode-connection-step:last-child::after {
  content: "";
  display: none;
}

.mode-connection-step span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--teal);
  color: var(--teal-deep);
  font-family: var(--font-heading);
  font-weight: 900;
}

.mode-connection-step b {
  font-family: var(--font-heading);
  font-size: 1.1rem;
}

.mode-connection-step small {
  color: var(--ink-soft);
  font-weight: 700;
  line-height: 1.28;
}

.mode-connection-step.done {
  background: var(--leaf-soft);
  border-color: var(--leaf);
}

.mode-connection-step.next {
  background: var(--teal-soft);
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(41, 163, 157, 0.16);
  animation: map-step-pulse 1500ms ease-in-out infinite;
}

@keyframes map-step-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(41, 163, 157, 0.14);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(41, 163, 157, 0.08),
      0 12px 24px -18px rgba(31, 42, 74, 0.35);
  }
}

.jam-props {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 720px;
  width: 100%;
  margin: -4px auto 0;
  padding: 12px;
  border: 2px solid rgba(168, 211, 106, 0.48);
  border-radius: var(--r-md);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.74)),
    image-set(
      url("../assets/jam-props-toy-shelf.webp") type("image/webp"),
      url("../assets/jam-props-toy-shelf.png") type("image/png")
    )
      center / cover no-repeat,
    #fff;
  box-shadow: 0 7px 0 -3px rgba(31, 42, 74, 0.12);
}

.jam-props button {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px 12px;
  border: 3px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 0 -2px rgba(31, 42, 74, 0.16);
}

.jam-props button:hover,
.jam-props button:focus-visible {
  transform: translateY(-2px);
  border-color: var(--teal);
}

.jam-props span {
  grid-row: 1 / span 2;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--sun-soft);
  color: var(--sun-deep);
  font-family: var(--font-heading);
  font-weight: 900;
}

.jam-props b {
  font-family: var(--font-heading);
  font-size: 0.92rem;
}

.jam-props small {
  color: var(--ink-mute);
  font-size: 0.76rem;
  font-weight: 750;
}

.jam-props.beating button[data-jam-prop="beat"] span {
  animation: prop-bounce 300ms ease;
}

@keyframes prop-bounce {
  0%,
  100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */

@media (max-width: 900px) {
  .parent-teacher-head,
  .parent-teacher-body,
  .mode-connection-steps,
  .jam-props {
    grid-template-columns: 1fr;
  }
  .parent-teacher-head {
    align-items: stretch;
    flex-direction: column;
  }
  .mode-connection-step::after {
    top: auto;
    right: 16px;
    bottom: -16px;
    transform: rotate(90deg);
  }
  .game-topbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .top-left-controls {
    flex-wrap: wrap;
  }
  .top-center {
    justify-content: flex-start;
  }
  .home-hero {
    grid-template-columns: 1fr;
    padding: 28px 24px;
  }
  .hero-art {
    display: none;
  }
  .mode-picker {
    grid-template-columns: 1fr;
  }
  .warmup-strip {
    grid-template-columns: 1fr;
  }
  .warmup-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
  .stage {
    grid-template-columns: 1fr;
    padding: 8px 18px 16px;
  }
  .play-area {
    min-width: 0;
    width: 100%;
  }
  .buddy-stage {
    display: none;
  }
  .next-note-hero {
    grid-template-columns: auto 1fr;
    min-width: 0;
    width: min(100%, 720px);
  }
  .next-note-hero .nn-body {
    min-width: 0;
  }
  .next-note-hero .progress-tube {
    display: none;
  }
  .next-note-hero .progress-label {
    display: none;
  }
  body.memory-mode .stage {
    grid-template-columns: 1fr;
  }
  body.memory-mode .memory-card-grid {
    grid-template-columns: repeat(2, minmax(112px, 1fr));
    padding: 14px;
  }
}

@media (max-width: 560px) {
  .lesson-strip {
    grid-template-columns: 1fr;
  }

  .game-topbar {
    padding: 16px 20px 8px;
  }

  .next-note-hero {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
    justify-items: start;
  }

  .next-note-hero .nn-letter {
    width: 74px;
    height: 74px;
    border-radius: 18px;
    font-size: 3rem;
    margin-bottom: 12px;
  }

  .song-note-path {
    max-width: 100%;
  }

  .melody-map {
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(4, minmax(42px, 1fr));
  }

  .magic-knobs {
    width: 100%;
    padding: 10px;
    gap: 10px;
  }

  .magic-knobs .knob-block {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .home-row {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .piano {
    --pw: 100%;
    height: clamp(156px, 44vw, 206px);
    padding: 8px 9px;
  }

  .next-mode-card,
  .sheet-bridge-card,
  .balance-break-card {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .sheet-bridge-actions,
  .balance-break-actions {
    justify-content: stretch;
  }

  .sheet-bridge-actions a,
  .sheet-bridge-actions button,
  .balance-break-actions button {
    flex: 1 1 140px;
  }
}

@media (max-height: 760px) and (min-width: 901px) {
  .piano {
    height: 200px;
  }
  .buddy-character svg,
  .buddy-character img.buddy-img {
    width: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-puppy,
  .ambient-puppy::after,
  .puppy-sprite,
  .puppy-note,
  .played-note-float,
  .stage-fx-note,
  .stage-fx-badge,
  .buddy-character .buddy-sprite,
  .ear-buddy .buddy-character .buddy-sprite,
  .ear-buddy .buddy-character img.buddy-img,
  .metronome-guide.running .pendulum-string,
  .midi-indicator.connected::before,
  .pattern-badge,
  .pulse-glow,
  .memory-card-inner,
  .jam-props.beating button[data-jam-prop="beat"] span,
  .next-mode-card,
  .mode-connection-step.next,
  .bridge-trail,
  .bridge-stone,
  .composer-slot.pulse {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  .ambient-puppy {
    opacity: 1;
    transform: translateX(min(58vw, 680px));
  }

  .puppy-sprite {
    background-position: 0 0;
  }

  .puppy-note-1 {
    opacity: 1;
    transform: translateY(-18px) rotate(-8deg);
  }
}

/* ----- Note Bridges ----- */

.extra-bridges {
  --bridge-step: var(--leaf);
  --bridge-skip: var(--cobalt);
  --bridge-leap: var(--coral);
  --bridge-octave: var(--plum);
  --bridge-same: var(--ink-mute);
  --bridge-start: 0%;
  --bridge-span: 0%;
  --bridge-dir: 1;
}

.bridge-board {
  position: relative;
  padding: 14px 6px 24px;
  background: linear-gradient(180deg, var(--cream), var(--cream-deep));
  border-radius: 16px;
  overflow: hidden;
}

.bridge-board::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 18px;
  height: 4px;
  background: rgba(31, 42, 74, 0.12);
  border-radius: 999px;
}

.bridge-stones {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  z-index: 1;
}

.bridge-stone {
  --stone-color: var(--sun);
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 14px;
  background: var(--stone-color);
  border: 2px solid rgba(31, 42, 74, 0.12);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.85rem;
  position: relative;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.bridge-stone em {
  font-style: normal;
}

.bridge-stone.from {
  border-color: var(--ink-soft);
  box-shadow: 0 4px 0 -1px rgba(31, 42, 74, 0.22);
}

.bridge-stone.to {
  transform: translateY(-3px) scale(1.06);
  border-color: var(--coral-deep);
  box-shadow:
    0 0 0 3px rgba(236, 140, 94, 0.35),
    0 6px 0 -1px var(--coral-deep);
  animation: bridge-pulse 1.4s ease-in-out infinite;
}

@keyframes bridge-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(236, 140, 94, 0.35),
      0 6px 0 -1px var(--coral-deep);
  }
  50% {
    box-shadow:
      0 0 0 6px rgba(236, 140, 94, 0.18),
      0 6px 0 -1px var(--coral-deep);
  }
}

.bridge-arc {
  position: absolute;
  left: calc(6px + var(--bridge-start));
  bottom: 10px;
  width: var(--bridge-span);
  height: 28px;
  pointer-events: none;
  transition:
    left 220ms ease,
    width 220ms ease;
}

.bridge-arc::before {
  content: "";
  position: absolute;
  inset: auto 0 6px 0;
  height: 16px;
  border-top: 3px dashed var(--ink-soft);
  border-left: 3px dashed transparent;
  border-right: 3px dashed transparent;
  border-radius: 50%;
  opacity: 0.55;
}

.bridge-board[data-kind="step"] .bridge-arc::before {
  border-top-color: var(--bridge-step);
}
.bridge-board[data-kind="skip"] .bridge-arc::before {
  border-top-color: var(--bridge-skip);
}
.bridge-board[data-kind="leap"] .bridge-arc::before {
  border-top-color: var(--bridge-leap);
}
.bridge-board[data-kind="octave"] .bridge-arc::before {
  border-top-color: var(--bridge-octave);
}
.bridge-board[data-kind="idle"] .bridge-arc::before,
.bridge-board[data-kind="same"] .bridge-arc::before {
  opacity: 0;
}

.bridge-walker {
  position: absolute;
  left: 0;
  bottom: -2px;
  font-size: 1.1rem;
  color: var(--coral-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  transform: translateX(-50%);
}

.bridge-walker.hop {
  animation: bridge-hop 520ms ease;
}

@keyframes bridge-hop {
  0% {
    transform: translate(-50%, 0);
  }
  40% {
    transform: translate(calc(-50% + var(--bridge-span) * 0.5), -22px);
  }
  100% {
    transform: translate(calc(-50% + var(--bridge-span)), 0);
  }
}

.bridge-board.bridge-cheer {
  animation: bridge-cheer 700ms ease;
}

@keyframes bridge-cheer {
  0% {
    box-shadow: inset 0 0 0 0 rgba(168, 211, 106, 0);
  }
  40% {
    box-shadow: inset 0 0 0 8px rgba(168, 211, 106, 0.4);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(168, 211, 106, 0);
  }
}

.bridge-trail-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bridge-trail {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  flex: 1;
  min-height: 22px;
  padding: 4px 6px;
  background: rgba(31, 42, 74, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.trail-tile {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--ink-mute);
  flex: 0 0 auto;
  animation: trail-pop 240ms ease;
}

@keyframes trail-pop {
  from {
    transform: scale(0.2);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.trail-step {
  background: var(--bridge-step);
}
.trail-skip {
  background: var(--bridge-skip);
}
.trail-leap {
  background: var(--bridge-leap);
}
.trail-octave {
  background: var(--bridge-octave);
}
.trail-same {
  background: var(--bridge-same);
}

.bridge-streak {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--sun-soft);
  border: 2px solid var(--sun);
  padding: 2px 10px;
  border-radius: 999px;
  min-width: 28px;
  text-align: center;
  transition:
    transform 220ms ease,
    background 220ms ease;
}

.bridge-streak.milestone {
  background: var(--leaf);
  color: #fff;
  transform: scale(1.15);
}

/* ----- Compose-a-Bar studio ----- */
.composer-slots {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.composer-slots .slot {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px dashed var(--plum);
  background: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--plum);
}

.composer-slots .slot.filled {
  border-style: solid;
  background: var(--plum-soft);
  box-shadow: 0 3px 0 -1px var(--plum);
}

.composer-slots .slot.armed {
  animation: composer-pulse 900ms ease-in-out infinite;
}

.composer-prompt-card {
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 16px;
  border: 2px solid var(--sun);
  background: #fff8e2;
  color: var(--coral-deep);
  font-family: var(--font-heading);
  font-weight: 800;
}

.composer-prompt-card[hidden] {
  display: none;
}

.composer-prompt-card.complete {
  border-color: var(--leaf);
  background: var(--leaf-soft);
  color: #2d5a2d;
}

@keyframes composer-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 3px 0 -1px var(--plum); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 4px rgba(163,123,209,0.25); }
}

.composer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.composer-row .round-btn {
  font-size: 0.88rem;
  padding: 8px 14px 8px 10px;
  border-width: 2px;
  box-shadow: 0 4px 0 -1px var(--ink);
}

.composer-row .round-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 2px 0 -1px var(--ink);
}

#composerArm[aria-pressed="true"] {
  background: var(--plum-soft);
  border-color: var(--plum);
}

.composer-save {
  display: grid;
  gap: 6px;
}

.name-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.name-picker button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--plum-soft);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--plum);
  cursor: pointer;
}

.name-picker button:hover {
  background: var(--plum-soft);
}

.composer-saved {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-tune {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 2px solid var(--cobalt-soft);
  background: var(--cobalt-soft);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--cobalt-deep);
  cursor: pointer;
}

.saved-tune .tune-notes {
  opacity: 0.7;
  font-weight: 600;
  font-size: 0.78rem;
}

.saved-tune:hover {
  transform: translateY(-1px);
}

/* ----- Chord Builder ----- */
.chord-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chord-picker button {
  padding: 7px 12px;
  border-radius: 999px;
  border: 2px solid var(--teal-soft);
  background: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--teal-deep);
  cursor: pointer;
}

.chord-picker button.active {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--ink);
}

.chord-slots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chord-slot {
  min-width: 62px;
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 8px;
  border-radius: 14px;
  border: 3px dashed var(--chord-color, var(--sun));
  background: rgba(255, 255, 255, 0.84);
  font-family: var(--font-heading);
  color: var(--ink);
}

.chord-slot b {
  font-size: 1.25rem;
  line-height: 1;
}

.chord-slot small {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.chord-slot.match {
  border-style: solid;
  background: color-mix(in srgb, var(--chord-color, var(--sun)) 36%, white);
  box-shadow: 0 4px 0 -1px var(--chord-color, var(--sun));
}

.chord-slot.miss {
  border-style: solid;
  background: var(--coral-soft);
  border-color: var(--coral);
}
