/* MPK Miniplay Teacher — bright, big and friendly for small hands on an iPad. */

:root {
  --sky: #bfe5ff;
  --sand: #fff3d6;
  --ink: #2a2150;
  --ink-soft: #625b86;
  --card: rgba(255, 255, 255, 0.94);
  --line: rgba(42, 33, 80, 0.1);
  --primary: #ff5a4e;
  --primary-dark: #d63c31;
  --secondary: #4c6fff;
  --secondary-dark: #3350d8;
  --good: #1fae5b;
  --oops: #e5760b;
  --gold: #ffc21a;
  --radius: 24px;
  --shadow: 0 12px 32px rgba(42, 33, 80, 0.16);
  --font: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --pad: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: linear-gradient(180deg, var(--sky) 0%, #e3f3ff 45%, var(--sand) 100%);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

input,
select,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

:focus-visible {
  outline: 4px solid var(--secondary);
  outline-offset: 3px;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#stage-park {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.boot {
  margin: auto;
  font-size: 28px;
  font-weight: 800;
  color: var(--ink-soft);
}

.fatal {
  margin: auto;
  max-width: 520px;
  padding: 24px;
  text-align: center;
  display: grid;
  gap: 12px;
}

.small {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.muted {
  color: var(--ink-soft);
}

/* ------------------------------------------------------------ screen frame */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
  position: relative;
  animation: fade-in 0.35s ease;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--pad);
  min-height: 72px;
}

.topbar-title {
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.spacer {
  flex: 1;
}

.round-btn {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 0 rgba(42, 33, 80, 0.14), 0 8px 18px rgba(42, 33, 80, 0.1);
  transition: transform 0.12s ease;
}

.round-btn:active {
  transform: translateY(3px) scale(0.96);
}

.icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.badge {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 4px 0 rgba(42, 33, 80, 0.12);
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 14px 24px;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(42, 33, 80, 0.16);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.2s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(42, 33, 80, 0.16);
}

.btn:disabled {
  filter: grayscale(0.7) opacity(0.6);
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 5px 0 var(--primary-dark);
}

.btn-primary:active {
  box-shadow: 0 1px 0 var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 5px 0 var(--secondary-dark);
}

.btn-secondary:active {
  box-shadow: 0 1px 0 var(--secondary-dark);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.9);
}

.btn-danger {
  background: #fff;
  color: #c62828;
  box-shadow: 0 5px 0 #f3c3c3;
}

.btn-hero {
  font-size: clamp(26px, 3.2vw, 34px);
  padding: 20px 46px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 7px 0 var(--primary-dark), 0 18px 30px rgba(214, 60, 49, 0.35);
  animation: breathe 2.4s ease-in-out infinite;
}

.btn-hero .icon {
  width: 34px;
  height: 34px;
}

.btn-wide {
  width: 100%;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

/* ------------------------------------------------------------ note chips & stars */

.chip {
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  margin: 0 0.08em;
  border-radius: 50%;
  background: var(--c, #ccc);
  color: var(--ink, #fff);
  font-weight: 900;
  font-size: 0.92em;
  line-height: 1;
  vertical-align: -0.3em;
  box-shadow: inset 0 -0.12em 0 rgba(0, 0, 0, 0.16), 0 0.08em 0.2em rgba(0, 0, 0, 0.15);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.chip-big {
  font-size: clamp(44px, 6vw, 72px);
}

.chip-sharp {
  --c: #2b2b30;
  --ink: #fff;
}

.stars {
  display: inline-flex;
  gap: 2px;
}

.star {
  color: rgba(42, 33, 80, 0.18);
  font-size: 22px;
  line-height: 1;
}

.star.on {
  color: var(--gold);
  text-shadow: 0 2px 0 #d99b00;
}

.stars.small .star {
  font-size: 18px;
}

.stars.big .star {
  font-size: clamp(56px, 8vw, 80px);
  animation: star-pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

.stars.big .star:nth-child(2) {
  animation-delay: 0.18s;
}

.stars.big .star:nth-child(3) {
  animation-delay: 0.36s;
}

/* ------------------------------------------------------------ mic indicator */

.mic-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  font-size: 15px;
  color: var(--good);
  box-shadow: 0 4px 0 rgba(42, 33, 80, 0.12);
}

.mic-pill .icon {
  width: 22px;
  height: 22px;
}

.mic-meter {
  width: 44px;
  height: 8px;
  border-radius: 99px;
  background: #e6ebf5;
  overflow: hidden;
}

.mic-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2ecc71, #ffd23f 70%, #ff6b4a);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.08s linear;
}

.mic-pill[data-state='muted'] {
  color: var(--ink-soft);
}

.mic-pill[data-state='off'] {
  color: #c62828;
}

.mic-pill[data-state='sim'],
.mic-pill[data-state='midi'] {
  color: var(--secondary);
}

/* ------------------------------------------------------------ 3D stage */

.stage-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

.stage-slot {
  position: absolute;
  inset: 0;
}

.stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ------------------------------------------------------------ coach bar */

.coach-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px var(--pad) calc(16px + var(--safe-b));
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  min-height: 104px;
}

.coach {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.coach-again {
  width: 52px;
  height: 52px;
  color: var(--secondary);
}

.coach-text {
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 900;
  line-height: 1.25;
  min-width: 0;
}

.coach-text.good {
  color: var(--good);
}

.coach-text.oops {
  color: var(--oops);
}

.coach-text.pop {
  animation: pop-in 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.coach-actions {
  display: flex;
  gap: 12px;
  flex: none;
}

.choices {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-choice {
  font-size: 24px;
  padding: 16px 26px;
  background: #fff3c4;
  box-shadow: 0 5px 0 #e2c65a;
}

.btn-choice:active {
  box-shadow: 0 1px 0 #e2c65a;
}

.lesson-staff {
  padding-top: 4px;
}

.btn-next {
  font-size: 24px;
  padding: 16px 30px;
  animation: nudge 1.6s ease-in-out infinite;
}

/* ------------------------------------------------------------ start */

.start {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
}

.start-stage {
  flex: 1;
  position: relative;
  min-height: 200px;
}

.start-card {
  align-self: center;
  width: min(620px, calc(100% - 32px));
  margin: 0 16px calc(24px + var(--safe-b));
  text-align: center;
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 26px 28px;
}

.title {
  font-size: clamp(34px, 4.6vw, 54px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.title-a {
  color: var(--primary);
}

.title-b {
  color: var(--secondary);
}

.tagline {
  font-size: clamp(18px, 2vw, 22px);
  color: var(--ink-soft);
  font-weight: 700;
}

.start-status {
  min-height: 1.2em;
  font-weight: 800;
  color: var(--ink-soft);
}

.fineprint {
  font-size: 13px;
  color: var(--ink-soft);
}

.mic-help {
  text-align: left;
  background: #fff6e5;
  border-radius: 18px;
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  font-size: 17px;
  line-height: 1.4;
}

.mic-help h2 {
  font-size: 20px;
}

.mic-help ol {
  margin: 0;
  padding-left: 22px;
}

/* ------------------------------------------------------------ home */

.hello {
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 900;
}

.home-stage {
  flex: 1;
  position: relative;
  min-height: 200px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 8px var(--pad) calc(20px + var(--safe-b));
}

.tile {
  border: 0;
  border-radius: 28px;
  padding: 18px 14px 20px;
  min-height: 150px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  color: #fff;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.18), 0 16px 26px rgba(42, 33, 80, 0.16);
  transition: transform 0.12s ease;
}

.tile:active {
  transform: translateY(5px) scale(0.98);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.t-learn {
  background: linear-gradient(160deg, #ff8a3d, #ff5a4e);
}

.t-songs {
  background: linear-gradient(160deg, #5f8bff, #4c5dff);
}

.t-free {
  background: linear-gradient(160deg, #34d399, #1fae5b);
}

.t-hunt {
  background: linear-gradient(160deg, #b57bff, #8b4dff);
}

.tile-emoji {
  font-size: 48px;
  line-height: 1;
}

.tile-title {
  font-size: 28px;
  font-weight: 900;
}

.tile-sub {
  font-size: 16px;
  font-weight: 700;
  opacity: 0.9;
}

.gear.holding::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 5px solid var(--secondary);
  clip-path: inset(0 0 0 0);
  animation: hold-ring var(--hold, 1.2s) linear forwards;
}

.gear {
  position: relative;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------ learning path */

.path-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-b);
}

.path-inner {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 140px;
}

.path-line {
  position: absolute;
  top: 24px;
  left: 16px;
  pointer-events: none;
  overflow: visible;
}

.trail,
.trail-done {
  fill: none;
  stroke-linecap: round;
  stroke-width: 12;
}

.trail {
  stroke: rgba(76, 111, 255, 0.28);
  stroke-dasharray: 2 22;
}

.trail-done {
  stroke: var(--gold);
  opacity: 0.85;
}

.path-list {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.node {
  transform: translateX(calc(var(--x) * min(22vw, 200px)));
  background: none;
  border: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0;
}

.node-disc {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  border: 6px solid #fff;
  box-shadow: 0 6px 0 rgba(42, 33, 80, 0.14), 0 14px 24px rgba(42, 33, 80, 0.14);
  transition: transform 0.15s ease;
}

.node:active .node-disc {
  transform: scale(0.94);
}

.node.done .node-disc {
  border-color: var(--gold);
}

.node.current .node-disc {
  border-color: var(--primary);
  animation: pulse 1.6s ease-in-out infinite;
}

.node.locked .node-disc {
  filter: grayscale(1);
  opacity: 0.55;
}

.node-letter {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--c);
  color: var(--ink);
  font-size: 42px;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15);
}

.node-emoji {
  font-size: 50px;
  line-height: 1;
}

.node-lock {
  position: absolute;
  right: -8px;
  bottom: -6px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
}

.node-lock .icon {
  width: 20px;
  height: 20px;
}

.node-label {
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 800;
  font-size: 17px;
  max-width: 260px;
  text-align: center;
  box-shadow: 0 3px 0 rgba(42, 33, 80, 0.1);
}

/* ------------------------------------------------------------ lessons & songs */

.dots {
  display: flex;
  gap: 8px;
  margin-left: 6px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(42, 33, 80, 0.15);
}

.dot.on {
  background: var(--good);
}

.dot.now {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 194, 26, 0.35);
}

.counter {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.tick {
  font-size: 34px;
  color: rgba(42, 33, 80, 0.18);
  line-height: 1;
}

.tick.on {
  color: var(--gold);
  text-shadow: 0 2px 0 #d99b00;
  animation: star-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.strip-wrap {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 0 var(--pad);
}

.strip {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 6px 4px;
  min-height: 84px;
  align-items: center;
}

.bubble {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--c);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.16), 0 4px 10px rgba(42, 33, 80, 0.15);
  transition: transform 0.2s ease, opacity 0.2s ease;
  position: relative;
}

.bubble.sharp {
  --c: #2b2b30;
  --ink: #fff;
  font-size: 22px;
}

.bubble.long {
  width: 86px;
}

.bubble.short {
  width: 48px;
  height: 48px;
  font-size: 25px;
}

.bubble.done {
  opacity: 0.35;
  transform: scale(0.84);
}

.bubble.current {
  transform: scale(1.28);
  box-shadow: 0 0 0 5px #fff, 0 0 26px var(--c), inset 0 -5px 0 rgba(0, 0, 0, 0.16);
  animation: bob 1.1s ease-in-out infinite;
  z-index: 1;
}

.bubble.playing {
  transform: scale(1.25);
  box-shadow: 0 0 0 5px #fff, 0 0 26px var(--c);
}

.bubble.shake {
  animation: shake 0.4s ease;
}

.phrase-info {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
}

.mode-toggle {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 4px 0 rgba(42, 33, 80, 0.14);
  background: #fff3c4;
  flex: none;
}

.mode-toggle.challenge {
  background: #ecdcff;
}

.mode-toggle .short {
  display: none;
}

@media (max-width: 960px) {
  .mode-toggle .long {
    display: none;
  }

  .mode-toggle .short {
    display: inline;
  }
}

.free-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px var(--pad) 0;
  min-height: 110px;
}

.big-note {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  flex: none;
}

.big-note .chip-big {
  animation: pop-in 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.big-note-hint {
  font-size: 64px;
  font-weight: 900;
  color: rgba(42, 33, 80, 0.2);
}

.trail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 26px;
  max-height: 100px;
  overflow: hidden;
}

.song-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(40px + var(--safe-b));
}

.song-section {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px var(--pad) 10px;
  font-size: 24px;
  font-weight: 900;
}

.song-section small {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
}

.song-grid {
  padding: 0 var(--pad) 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-content: start;
}

.song-card {
  border: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 6px 0 rgba(42, 33, 80, 0.1), 0 14px 26px rgba(42, 33, 80, 0.1);
  padding: 18px 20px;
  display: grid;
  gap: 8px;
  text-align: left;
  transition: transform 0.12s ease;
}

.song-card:active {
  transform: translateY(4px);
}

.song-card.locked {
  opacity: 0.6;
  filter: grayscale(0.7);
}

.song-emoji {
  font-size: 40px;
  line-height: 1;
}

.song-title {
  font-size: 22px;
  font-weight: 900;
}

.song-notes {
  font-size: 18px;
}

.song-stars {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lock-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  color: var(--ink-soft);
}

.lock-note .icon {
  width: 18px;
  height: 18px;
}

.challenge-badge {
  font-size: 22px;
}

/* ------------------------------------------------------------ music staff */

.staff {
  display: block;
  width: 100%;
  height: 100%;
  color: var(--ink);
  overflow: visible;
}

.staff .staff-lines line,
.staff .ledger,
.staff .bar {
  stroke: var(--ink);
  stroke-width: 1.7;
}

.staff .bar-thick,
.staff .beam,
.staff .dot {
  fill: var(--ink);
}

.staff .stem {
  stroke: var(--ink);
  stroke-width: 2.2;
}

.staff .flag {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
}

.staff .accidental {
  fill: var(--ink);
  font-family: 'Segoe UI Symbol', 'Apple Symbols', 'Noto Music', 'Times New Roman', serif;
  font-weight: 700;
}

.staff .head-letter {
  font: 900 20px var(--font);
  pointer-events: none;
}

.staff .item {
  transition: opacity 0.25s ease;
}

.staff .item.is-done {
  opacity: 0.3;
}

.staff .item.is-current .head,
.staff .item.is-playing .head {
  filter: drop-shadow(0 0 5px rgba(255, 194, 26, 0.95)) drop-shadow(0 0 2px rgba(255, 194, 26, 0.9));
}

.staff .item.is-current {
  animation: note-bob 1.1s ease-in-out infinite;
}

.staff .item.is-wrong {
  animation: note-shake 0.4s ease;
}

.staff .marker {
  fill: var(--primary);
  animation: note-bob 1.1s ease-in-out infinite;
}

.staff .clef-hl,
.staff.hl-clef .clef {
  color: var(--primary);
}

.staff.hl-lines .staff-lines line {
  stroke: var(--secondary);
  stroke-width: 3;
  animation: lines-pulse 1s ease-in-out infinite;
}

.staff-wrap {
  flex: none;
  height: clamp(140px, 25vh, 220px);
  padding: 0 var(--pad);
  display: flex;
  justify-content: center;
}

.staff-wrap .staff {
  width: auto;
  max-width: 100%;
}

@keyframes note-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes note-shake {
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes lines-pulse {
  50% {
    stroke-opacity: 0.35;
  }
}

/* ------------------------------------------------------------ result card */

.result-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 22, 64, 0.35);
  animation: fade-in 0.3s ease;
}

.result {
  width: min(560px, 100%);
  text-align: center;
  display: grid;
  gap: 12px;
  padding: 26px 30px 30px;
  animation: pop-in 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.result h2 {
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 900;
}

.result p {
  font-size: 19px;
  color: var(--ink-soft);
  font-weight: 700;
}

.result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ------------------------------------------------------------ setup & settings */

.setup-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr minmax(360px, 460px);
  gap: 16px;
  padding: 0 var(--pad) calc(16px + var(--safe-b));
}

.setup-stage {
  position: relative;
  min-height: 220px;
}

.setup-panel {
  overflow-y: auto;
  display: grid;
  gap: 14px;
  align-content: start;
}

.lead {
  font-weight: 800;
  font-size: 18px;
}

.setup-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.setup-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 17px;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.2s ease;
}

.setup-step.active {
  background: #fff3c4;
}

.step-num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.setup-test {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #eef4ff;
}

.setup-test h2 {
  font-size: 20px;
}

.heard-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 42px;
  align-items: center;
  font-size: 26px;
}

.heard-row .muted {
  font-size: 16px;
}

.verdict {
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.2em;
}

.verdict.ok {
  color: var(--good);
}

.verdict.warn {
  color: var(--oops);
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.text-input,
.select {
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

.select {
  max-width: 280px;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 4px var(--pad) calc(40px + var(--safe-b));
  display: grid;
  gap: 16px;
  align-content: start;
}

.settings-body h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

.row-text {
  flex: 1;
  display: grid;
  gap: 2px;
  font-size: 18px;
}

.row-text small {
  font-size: 14px;
  color: var(--ink-soft);
}

.toggle {
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  flex: none;
  width: 60px;
  height: 34px;
  border-radius: 999px;
  background: #d5d9e6;
  position: relative;
  transition: background 0.2s ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.toggle input:checked + .switch {
  background: var(--good);
}

.toggle input:checked + .switch::after {
  transform: translateX(26px);
}

.toggle input:focus-visible + .switch {
  outline: 4px solid var(--secondary);
  outline-offset: 2px;
}

.segmented {
  display: inline-flex;
  background: #eef0f7;
  border-radius: 999px;
  padding: 4px;
  flex: none;
}

.segmented button {
  border: 0;
  background: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  color: var(--ink-soft);
}

.segmented button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(42, 33, 80, 0.15);
}

.slider {
  width: min(260px, 45%);
  accent-color: var(--secondary);
  height: 32px;
}

.meter {
  position: relative;
  height: 20px;
  border-radius: 999px;
  background: #e6ebf5;
  overflow: hidden;
  margin: 8px 0;
}

.meter-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #2ecc71, #ffd23f 70%, #ff6b4a);
  transform-origin: left;
  transform: scaleX(0);
}

.meter-gate {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ink);
  opacity: 0.6;
}

.now {
  font-weight: 800;
  font-size: 18px;
}

.now-note {
  font-variant-numeric: tabular-nums;
}

.music-input {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 20px;
  line-height: 1.5;
}

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

.emoji-pick {
  width: 50px;
  height: 50px;
  font-size: 26px;
  border-radius: 14px;
  border: 3px solid transparent;
  background: #f1f2f8;
}

.emoji-pick.on {
  border-color: var(--secondary);
  background: #fff;
}

.syntax {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.syntax code {
  background: #eef0f7;
  padding: 1px 6px;
  border-radius: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--ink);
}

.problems {
  margin: 8px 0 0;
  padding-left: 20px;
  color: #c62828;
  font-weight: 700;
}

.problems:empty {
  display: none;
}

.editor-actions {
  flex-wrap: wrap;
  gap: 12px;
}

.editor-preview {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.editor-preview .staff {
  height: 140px;
  width: auto;
  max-width: 100%;
}

.editor .field {
  margin-bottom: 12px;
}

.about p + p {
  margin-top: 8px;
}

/* ------------------------------------------------------------ overlays */

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 50;
  max-width: min(92vw, 640px);
  padding: 14px 24px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 200%);
  transition: transform 0.35s cubic-bezier(0.3, 1.3, 0.5, 1);
  cursor: pointer;
}

#toast.show {
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------ animations */

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

@keyframes pop-in {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}

@keyframes star-pop {
  from {
    transform: scale(0) rotate(-40deg);
    opacity: 0;
  }
}

@keyframes bob {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -6px;
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 6px 0 rgba(42, 33, 80, 0.14), 0 0 0 0 rgba(255, 90, 78, 0.5);
  }
  50% {
    box-shadow: 0 6px 0 rgba(42, 33, 80, 0.14), 0 0 0 16px rgba(255, 90, 78, 0);
  }
}

@keyframes breathe {
  0%,
  100% {
    scale: 1;
  }
  50% {
    scale: 1.04;
  }
}

@keyframes nudge {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 4px 0;
  }
}

@keyframes shake {
  0%,
  100% {
    translate: 0 0;
  }
  20% {
    translate: -8px 0;
  }
  40% {
    translate: 8px 0;
  }
  60% {
    translate: -6px 0;
  }
  80% {
    translate: 4px 0;
  }
}

@keyframes hold-ring {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

.no-anim .screen,
.no-anim .result-backdrop,
.no-anim .result {
  animation: none;
}

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

/* ------------------------------------------------------------ portrait & small screens */

@media (orientation: portrait) {
  .tiles {
    grid-template-columns: repeat(2, 1fr);
  }

  .tile {
    min-height: 130px;
  }

  .setup-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 34%) 1fr;
  }

  .coach-bar {
    flex-wrap: wrap;
  }

  .coach-actions {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 700px) {
  :root {
    --pad: 12px;
  }

  .topbar {
    gap: 8px;
    min-height: 60px;
  }

  .round-btn {
    width: 46px;
    height: 46px;
  }

  .mic-label,
  .dots {
    display: none;
  }

  .bubble {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .bubble.long {
    width: 64px;
  }

  .bubble.short {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .btn {
    font-size: 17px;
    padding: 12px 18px;
  }

  .tile-title {
    font-size: 22px;
  }

  .mode-toggle {
    font-size: 13px;
    padding: 8px 10px;
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  .tile {
    min-height: 110px;
    padding: 12px;
  }

  .tile-emoji {
    font-size: 36px;
  }

  .coach-bar {
    min-height: 88px;
    padding-top: 10px;
  }
}
