:root {
  --bg: #1a1428;
  --card: #2a2240;
  --accent: #9b7ede;
  --accent-light: #c4b5fd;
  --gold: #f5c842;
  --text: #f8f4ff;
  --hint: #b8aed4;
  --correct: #5eead4;
  --wrong: #fca5a5;
  --white-key: #fffef8;
  --white-key-border: #c4b8a8;
  --hint-glow: #f5c842;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(165deg, #1a1428 0%, #2d1f4e 50%, #1a2838 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#screenGame.hidden,
.screen.hidden.screen-game {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  width: 0 !important;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 1.5rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
}

.total-stars {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
}

.screen { flex: 1; display: flex; flex-direction: column; }

.screen[aria-hidden="true"] {
  pointer-events: none !important;
  user-select: none;
}

.keyboard-dock {
  flex-shrink: 0;
  touch-action: manipulation;
}

.keyboard-dock.hidden {
  display: none !important;
  pointer-events: none !important;
  height: 0 !important;
  overflow: hidden !important;
}

.card {
  background: var(--card);
  border-radius: 1.25rem;
  padding: 1.5rem 1.25rem;
  margin: 0.5rem 0;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.emoji-big { font-size: 3rem; margin-bottom: 0.5rem; }

.title-big {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0.25rem 0;
}

.hint {
  color: var(--hint);
  font-size: 1rem;
  line-height: 1.45;
  margin: 0.5rem 0;
}

.btn-primary, .btn-secondary, .btn-success {
  display: inline-block;
  margin: 0.5rem 0.25rem;
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6d4cbd);
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.btn-success {
  background: linear-gradient(135deg, #2dd4bf, #0d9488);
  color: #042f2e;
}

.name-input {
  width: 100%;
  max-width: 280px;
  padding: 0.75rem 1rem;
  font-size: 1.15rem;
  border-radius: 0.75rem;
  border: 2px solid var(--accent);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  text-align: center;
  margin: 0.75rem auto;
  display: block;
}

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.75rem 0;
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  border-radius: 1rem;
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.lesson-card.done { border-color: var(--correct); opacity: 0.9; }

.lesson-emoji { font-size: 1.75rem; }
.lesson-title { display: block; font-weight: 600; }
.lesson-body { flex: 1; min-width: 0; }
.lesson-sub { display: block; font-size: 0.8rem; color: var(--hint); }
.lesson-tags { display: block; font-size: 0.72rem; color: var(--accent-light); margin-top: 0.15rem; }
.lesson-badge { color: var(--correct); font-weight: 700; }

.lesson-bar {
  text-align: center;
  padding: 0.35rem 0;
}

.lesson-progress {
  font-size: 0.9rem;
  color: var(--hint);
}

.lesson-hint {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-light);
  min-height: 2.5rem;
  margin: 0.25rem 0;
}

.lesson-done {
  color: var(--correct);
  font-size: 1.2rem;
  font-weight: 700;
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#keyboardHost {
  margin-top: auto;
  padding: 0.5rem 0 0;
  touch-action: manipulation;
}

.piano-wrap {
  padding: 0.35rem 0.25rem 0.5rem;
  background: #0f0a18;
  border-radius: 0.5rem 0.5rem 0 0;
  box-shadow: inset 0 -4px 12px rgba(0, 0, 0, 0.4);
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.key.white {
  flex: 1;
  min-width: 2.1rem;
  height: clamp(7rem, 28vw, 10rem);
  border: 1px solid var(--white-key-border);
  border-radius: 0 0 0.35rem 0.35rem;
  background: linear-gradient(180deg, #fff 0%, var(--white-key) 85%);
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: background 0.08s, transform 0.08s;
}

.key-label {
  position: absolute;
  bottom: 0.35rem;
  left: 0;
  right: 0;
  font-size: 0.55rem;
  color: #6b5b4f;
  pointer-events: none;
}

@media (min-width: 500px) {
  .key-label { font-size: 0.65rem; }
}

.key.white.active {
  background: linear-gradient(180deg, #e8e0f5 0%, #d4c8f0 100%);
  transform: translateY(2px);
}

.key.white.hint {
  box-shadow: 0 0 0 3px var(--hint-glow), 0 0 16px var(--hint-glow);
  z-index: 1;
}

.key.white.correct {
  box-shadow: 0 0 0 3px var(--correct);
}

.key.white.wrong {
  box-shadow: 0 0 0 2px var(--wrong);
}

.play-toolbar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

a.parent-link {
  color: var(--accent-light);
  font-size: 0.9rem;
}

.level-badge {
  font-size: 0.85rem;
  color: var(--accent-light);
  margin: 0 0.5rem;
}

.center { text-align: center; }

.hero-banner {
  margin: 0.35rem 0 0.65rem;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.hero-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(55vh, 320px);
  min-height: 200px;
  object-fit: cover;
  object-position: center 40%;
}

.home-card .title-big {
  margin-bottom: 0.35rem;
}

.home-progress-main {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: #f3e8ff;
}

.home-progress-meta {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.card-scroll { max-height: 55vh; overflow-y: auto; text-align: left; }

.home-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin: 0.5rem 0;
}

.nav-tile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--card);
  border: 2px solid rgba(155, 126, 222, 0.35);
  border-radius: 1rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.nav-emoji { font-size: 2rem; }
.nav-label { font-size: 1.1rem; font-weight: 600; }

.btn-block { display: block; width: 100%; margin: 0.5rem 0; }
.btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 1.1rem;
  cursor: pointer;
}

.lesson-card.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.35); }
.lesson-card.song-card { padding: 0.65rem 0.75rem; }

.song-cover {
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 0.65rem;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.song-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lib-section { margin-bottom: 1rem; }
.lib-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  margin: 0.5rem 0 0.35rem;
  padding-left: 0.15rem;
}
.lesson-meta { font-size: 0.85rem; color: var(--hint); }

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  border-radius: 1rem;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.profile-card.active { border-color: var(--accent); background: rgba(155, 126, 222, 0.2); }
.profile-emoji { font-size: 2rem; }
.profile-name { flex: 1; font-weight: 600; font-size: 1.05rem; }
.profile-meta { font-size: 0.85rem; color: var(--hint); }

.screen-game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.game-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.game-top-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.35rem 0;
}

.game-title {
  flex: 1;
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
  text-align: left;
}

.mic-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 46%;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.mic-indicator:active {
  transform: scale(0.97);
}

.mic-indicator.mic-wait { border-color: rgba(251, 191, 36, 0.5); }
.mic-indicator.mic-on { border-color: rgba(96, 165, 250, 0.55); }
.mic-indicator.mic-hear {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.12);
}
.mic-indicator.mic-off { opacity: 0.65; }

.mic-icon { font-size: 1.1rem; line-height: 1; }

.mic-pulse {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #60a5fa;
  transform: scale(1);
  transition: transform 0.08s ease, opacity 0.08s ease;
}

.mic-indicator.mic-hear .mic-pulse {
  background: #22c55e;
  animation: mic-pulse-beat 0.45s ease infinite;
}

.mic-indicator.mic-wait .mic-pulse {
  background: #fbbf24;
  animation: mic-pulse-beat 0.8s ease infinite;
}

@keyframes mic-pulse-beat {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.mic-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
}

.scroll-lane {
  position: relative;
  flex: 1;
  min-height: 140px;
  max-height: 38vh;
  margin: 0.35rem 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(30, 20, 50, 0.6) 100%);
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hit-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  height: 3px;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
  z-index: 2;
}

.fall-note {
  position: absolute;
  transform: translateX(-50%);
  min-width: 2.5rem;
  padding: 0.35rem 0.65rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  transition: top 0.05s linear;
  z-index: 1;
}

.fall-note.left-hand { background: #0d9488; }

.feedback-bar {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 1.6rem;
  margin: 0.2rem 0;
  color: var(--accent-light);
}

.feedback-bar.fb-ok { color: var(--correct); }
.feedback-bar.fb-bad { color: var(--wrong); }
.feedback-bar.fb-hint { color: var(--gold); }
.feedback-bar.fb-mic { color: var(--accent-light); }
.feedback-bar.fb-warn { color: #fbbf24; }

.key.white.mic-live {
  box-shadow: 0 0 0 3px #60a5fa, 0 0 18px #60a5fa;
  z-index: 2;
}

.key.white.mic-ok {
  box-shadow: 0 0 0 3px var(--correct), 0 0 20px var(--correct);
}

.key.white.mic-bad {
  box-shadow: 0 0 0 3px var(--wrong), 0 0 14px var(--wrong);
}

.keyboard-dock #keyboardHost,
.screen-game #keyboardHost {
  flex-shrink: 0;
}

.screen-game .oct-whites .key.white {
  height: clamp(6rem, 36vh, 9.5rem);
  min-width: 1.75rem;
}

/* —— App bar (кнопка «Назад» всегда слева) —— */
.app-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0 0.5rem;
  min-height: 2.75rem;
}

.btn-back {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.app-bar-title {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
}

.app-bar-stars {
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
}

.card-compact { padding: 1rem 1.1rem; }
.screen-hint { margin: 0.25rem 0.5rem 0.65rem; padding: 0 0.25rem; }

/* —— Нотный стан —— */
.staff-area {
  flex: 1;
  min-height: 280px;
  margin: 0.15rem 0;
  padding-top: 0.35rem;
  background: #fffef8;
  border-radius: 0.65rem;
  border: 2px solid #d4c4a8;
  overflow: visible;
  position: relative;
}

.staff-area:has(.staff-grand) {
  min-height: 340px;
}

.staff-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 280px;
  padding-top: 1.25rem;
  box-sizing: border-box;
}

.staff-viewport.staff-grand {
  min-height: 340px;
}

.staff-clefs-column {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 54px;
  z-index: 12;
  pointer-events: none;
}

.staff-clef-slot {
  position: absolute;
  left: 0;
  width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.staff-clef-slot.bass {
  display: none;
}

.staff-viewport.staff-grand .staff-clef-slot.bass {
  display: flex;
}

.staff-system {
  position: relative;
  padding-left: 54px;
  min-height: 280px;
}

.staff-viewport.staff-grand .staff-system {
  min-height: 340px;
}

.staff-treble,
.staff-bass {
  position: absolute;
  left: 0;
  right: 0;
  height: 72px;
}

.staff-bass-slot {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.2s ease, opacity 0.2s ease;
}

.staff-bass-slot.active {
  max-height: 200px;
  opacity: 1;
  pointer-events: auto;
}

.staff-line-h {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  background: #3d2e22;
}

.staff-clef-wrap {
  position: absolute;
  left: -52px;
  z-index: 4;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
}

.staff-clef-wrap.treble {
  top: -6px;
  height: 88px;
}

.staff-clef-wrap.bass {
  top: -4px;
  height: 76px;
}

.staff-clef {
  font-size: 6.75rem;
  line-height: 0.75;
  color: #1a120c;
}

.staff-clef.bass-clef {
  font-size: 5.25rem;
  line-height: 0.7;
}

.play-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 5px;
  margin-left: -2px;
  background: linear-gradient(180deg, #e11d48, #be123c);
  box-shadow: 0 0 10px rgba(225, 29, 72, 0.45);
  z-index: 5;
}

.staff-notes-layer,
.staff-ledger-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.staff-ledger-layer { z-index: 7; }

.staff-bars-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.bar-line {
  position: absolute;
  width: 2px;
  background: rgba(61, 46, 34, 0.42);
}

.bar-line.bar-treble,
.bar-line.bar-bass {
  z-index: 1;
}

.ledger-line {
  position: absolute;
  height: 1.5px;
  background: #3d2e22;
  z-index: 5;
}

.note-on-staff {
  position: absolute;
  z-index: 11;
  transition: left 0.05s linear;
}

.note-head-mask {
  position: absolute;
  left: 50%;
  top: 72%;
  width: 22px;
  height: 14px;
  margin: -7px 0 0 -11px;
  border-radius: 50%;
  background: #fffef8;
  z-index: 1;
  pointer-events: none;
}

.note-on-staff.dur-whole .note-head-mask {
  top: 58%;
  width: 24px;
  height: 16px;
  margin: -8px 0 0 -12px;
}

.note-span {
  position: absolute;
  left: 12px;
  top: 70%;
  height: 3px;
  margin-top: -1px;
  border-radius: 2px;
  background: rgba(124, 58, 237, 0.14);
  pointer-events: none;
  z-index: 0;
}

.rest-on-staff .note-span {
  background: rgba(61, 46, 34, 0.08);
}

.note-glyph,
.rest-glyph {
  position: relative;
  z-index: 2;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.note-glyph {
  width: 36px;
  height: 88px;
}

.note-glyph.dur-whole {
  width: 38px;
  height: 52px;
}

.rest-glyph {
  width: 28px;
  height: 28px;
}

.rest-glyph.dur-half {
  width: 32px;
  height: 16px;
}

.rest-glyph.dur-whole {
  width: 22px;
  height: 14px;
}


.state-pending .note-glyph,
.state-pending .rest-glyph {
  filter: none;
  color: #1a120c;
  opacity: 0.92;
}
.state-now .note-glyph,
.state-now .rest-glyph {
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.95));
  color: #1a120c;
}
.state-ok .note-on-staff,
.state-ok .rest-on-staff {
  outline: 2px solid rgba(34, 197, 94, 0.55);
  outline-offset: 2px;
  border-radius: 4px;
}
.state-bad .note-on-staff,
.state-bad .rest-on-staff {
  outline: 2px solid rgba(239, 68, 68, 0.55);
  outline-offset: 2px;
  border-radius: 4px;
}
.state-ok .note-glyph.dur-quarter,
.state-ok .note-glyph.dur-eighth {
  filter: invert(48%) sepia(79%) saturate(2476%) hue-rotate(86deg) brightness(96%) contrast(92%);
}
.state-bad .note-glyph.dur-quarter,
.state-bad .note-glyph.dur-eighth {
  filter: invert(27%) sepia(90%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
}

/* —— Клавиатура (октавы + чёрные клавиши) —— */
.piano-octaves {
  display: flex;
  width: max-content;
  min-width: 100%;
  gap: 3px;
}

.piano-octave {
  position: relative;
  flex: 7 0 0;
  min-width: 12.5rem;
}

.oct-whites {
  display: flex;
  gap: 2px;
  height: 100%;
}

.oct-blacks {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  z-index: 30;
  pointer-events: none;
}

.oct-blacks .key.black {
  pointer-events: auto;
  position: absolute;
  top: 0;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0 0 0.28rem 0.28rem;
  background: linear-gradient(180deg, #4a4a4a 0%, #0d0d0d 92%) !important;
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.65);
  cursor: pointer;
  transform: translateX(-50%);
  min-height: 2.5rem;
}

.black-cs { left: 13%; width: 13%; }
.black-ds { left: 27%; width: 13%; }
.black-fs { left: 55%; width: 13%; }
.black-gs { left: 69%; width: 13%; }
.black-as { left: 83%; width: 13%; }

.key.black.active {
  background: linear-gradient(180deg, #666 0%, #222 100%) !important;
  transform: translateX(-50%) translateY(2px);
}

.key.black.hint {
  box-shadow: 0 0 0 3px var(--hint-glow), 0 0 14px var(--hint-glow);
  z-index: 40;
}

.key.black.correct { box-shadow: 0 0 0 2px var(--correct); }
.key.black.wrong { box-shadow: 0 0 0 2px var(--wrong); }
.key.black.mic-live { box-shadow: 0 0 0 2px #60a5fa; }
.key.black.mic-ok { box-shadow: 0 0 0 2px var(--correct); }
.key.black.mic-bad { box-shadow: 0 0 0 2px var(--wrong); }

/* —— Уровни: горизонтальный путь —— */
#screenCurriculum {
  background: linear-gradient(160deg, #2a1848 0%, #4a2878 55%, #1e2848 100%);
  border-radius: 1rem;
  padding: 0.5rem 0.25rem 1rem;
  margin: 0.25rem 0;
}

.curriculum-path {
  overflow-y: auto;
  max-height: calc(100dvh - 5.5rem);
  padding: 0.25rem 0.35rem 1rem;
}

.curriculum-path.hidden {
  display: none !important;
  pointer-events: none !important;
}

.curriculum-detail:not(.hidden) {
  position: relative;
  z-index: 50;
  pointer-events: auto;
  isolation: isolate;
}

#screenCurriculum.showing-detail .curriculum-path {
  display: none !important;
  pointer-events: none !important;
}

.home-footer-links {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.home-footer-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent-light);
  text-decoration: underline;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.home-footer-sep {
  margin: 0 0.35rem;
  opacity: 0.5;
}

#btnGlobalBack,
.path-card {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#btnGlobalBack {
  position: relative;
  z-index: 120;
  pointer-events: auto;
}

.app-bar {
  position: relative;
  z-index: 110;
}

.curriculum-detail .card,
.curriculum-detail button {
  position: relative;
  z-index: 41;
  pointer-events: auto;
  touch-action: manipulation;
}

.app-bar {
  position: relative;
  z-index: 60;
  pointer-events: auto;
}

.app-bar .btn-back {
  touch-action: manipulation;
  cursor: pointer;
}

.cur-block {
  margin-bottom: 1rem;
}

.cur-block-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin: 0.5rem 0.25rem 0.15rem;
}

.cur-block-sub {
  font-size: 0.8rem;
  color: var(--hint);
  margin: 0 0.25rem 0.5rem;
}

.cur-block-row {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding: 0.35rem 0.25rem 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}


.path-card {
  flex: 0 0 min(76vw, 288px);
  scroll-snap-align: center;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "num mode"
    "body body"
    "stars status";
  align-items: center;
  gap: 0.45rem 0.5rem;
  padding: 0.95rem 1rem 1rem;
  background: linear-gradient(145deg, #7c3aed, #5b21b6);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 1.1rem;
  color: #fff;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
}

.path-card.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 200, 66, 0.35), 0 12px 32px rgba(0, 0, 0, 0.4);
}

.path-card.done { border-color: var(--correct); }
.path-card.locked { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.4); }

.path-num {
  grid-area: num;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.85;
}

.path-play {
  grid-area: mode;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.95;
}

.path-card-body {
  grid-area: body;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.path-emoji {
  flex-shrink: 0;
  font-size: 1.85rem;
  line-height: 1;
}

.path-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  min-width: 0;
}

.path-level {
  font-size: 0.8rem;
  opacity: 0.9;
}

.path-card-status {
  grid-area: status;
  font-size: 1.35rem;
  line-height: 1;
  justify-self: end;
}

.path-card-status.done { color: #86efac; }
.path-card-status.lock { opacity: 0.9; }

.curriculum-detail .card { text-align: left; }
.step-preview {
  text-align: left;
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  color: var(--hint);
}

/* —— Библиотека: сетка карточек —— */
#screenLibrary {
  background: linear-gradient(165deg, #6d28d9 0%, #7c3aed 40%, #5b21b6 100%);
  border-radius: 1rem;
  padding: 0.5rem 0.35rem 1rem;
}

.library-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.35rem 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.lib-tab {
  flex-shrink: 0;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.lib-tab.active {
  background: #fff;
  color: #5b21b6;
}

.lib-tab.locked { opacity: 0.45; cursor: not-allowed; }

#screenLibrary .screen-hint { color: rgba(255, 255, 255, 0.85); }

.song-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  padding: 0.35rem 0.25rem;
}

.song-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: none;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #2a1848;
  color: #fff;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.song-card.locked { opacity: 0.5; cursor: not-allowed; }

.song-premium {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  font-size: 0.55rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #422006;
  padding: 0.15rem 0.5rem;
  transform: rotate(-35deg) translate(-12%, 40%);
  min-width: 4rem;
  text-align: center;
}

.song-premium:empty { display: none; }

.song-cover {
  aspect-ratio: 1;
  background: #1a1028;
}

.song-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.song-info {
  padding: 0.45rem 0.5rem 0.55rem;
  background: rgba(0, 0, 0, 0.35);
}

.song-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.song-sub {
  display: block;
  font-size: 0.65rem;
  opacity: 0.8;
  margin-top: 0.1rem;
}

.song-stars { display: block; margin-top: 0.2rem; }
.song-stars .star { color: rgba(255, 255, 255, 0.25); font-size: 0.75rem; }
.song-stars .star.on { color: var(--gold); }

.nav-courses { border-color: rgba(124, 58, 237, 0.6); }
.nav-songs { border-color: rgba(167, 139, 250, 0.5); }

/* —— Профиль: настройки микрофона —— */
.settings-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
}

.settings-title {
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.65rem 0;
  font-size: 0.95rem;
}

.setting-check {
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 0.65rem;
}

.setting-check input { width: 1.2rem; height: 1.2rem; }

.setting-select {
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid var(--accent);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.settings-hint { font-size: 0.85rem; margin-top: 0.5rem; }

/* —— Модальное подтверждение выхода —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
}

.modal:not(.hidden) {
  display: flex;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  position: relative;
  background: var(--card);
  border-radius: 1.25rem;
  padding: 1.5rem 1.25rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.modal-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.screen-game .game-title {
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  margin: 0;
  padding: 0 0.35rem;
  flex-shrink: 0;
  line-height: 1.2;
}

.game-prompt {
  flex-shrink: 0;
  margin: 0.1rem 0.3rem 0.2rem;
  padding: 0.4rem 0.65rem;
  background: rgba(245, 200, 66, 0.15);
  border: 2px solid var(--gold);
  border-radius: 0.75rem;
  text-align: center;
}

.prompt-step {
  display: block;
  font-size: 0.8rem;
  color: var(--hint);
  margin-bottom: 0.15rem;
}

.prompt-main {
  display: block;
  font-size: clamp(1.15rem, 3.5vw, 1.5rem);
  font-weight: 800;
  color: var(--gold);
  line-height: 1.25;
}

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

/* Горизонтальный планшет / телефон */
html.landscape-app .page {
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0.2rem 0.6rem 0.35rem;
}

@media (orientation: landscape) {
  .page {
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: 0.2rem 0.6rem 0.35rem;
  }

  .screen {
    min-height: 0;
    overflow: auto;
  }

  .screen-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .screen-game .game-body {
    flex-direction: row;
    align-items: stretch;
    gap: 0.5rem;
  }

  .staff-area {
    flex: 1;
    max-height: none;
    min-height: 180px;
  }

  .staff-viewport,
  .staff-system {
    min-height: 185px;
  }

  .screen-game .feedback-bar {
    width: min(32vw, 220px);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem;
    margin: 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.65rem;
  }

  .screen-game #keyboardHost {
    flex-shrink: 0;
    max-height: 46vh;
  }

  .screen-game .oct-whites .key.white {
    height: clamp(6.5rem, 42vh, 10.5rem);
    min-width: 2rem;
  }

  .screen-game .oct-blacks {
    height: 60%;
  }

  .home-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .song-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  #screenLibrary,
  #screenCurriculum {
    max-height: calc(100dvh - 3.5rem);
    overflow-y: auto;
  }
}

.tempo-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}

.tempo-btn {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: 0.65rem;
  border: 2px solid rgba(155, 126, 222, 0.45);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.tempo-btn.active {
  border-color: var(--gold);
  background: rgba(245, 200, 66, 0.15);
}

.tempo-label { margin-bottom: 0; }

.path-stars {
  grid-area: stars;
  display: flex;
  align-items: center;
  gap: 0.08em;
  width: 100%;
  line-height: 1;
  margin-top: 0.15rem;
}

.path-star {
  font-size: 1.28rem;
  color: rgba(255, 255, 255, 0.28);
}

.path-star.lit {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(245, 200, 66, 0.5);
}

.btn-retry-phrase {
  margin-top: 0.5rem;
  flex-shrink: 0;
}

/* Всплывающий итог поверх пианино */
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  pointer-events: auto;
}

.result-overlay.hidden {
  display: none !important;
}

.result-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 28, 0.72);
  backdrop-filter: blur(4px);
}

.result-card {
  position: relative;
  z-index: 1;
  width: min(100%, 28rem);
  padding: 1.1rem 1.2rem 1.25rem;
  background: var(--card);
  border-radius: 1rem;
  border: 2px solid rgba(245, 200, 66, 0.45);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.result-title {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  color: var(--gold);
}

.result-sub {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--hint);
  line-height: 1.35;
}

.result-rings {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.result-ring-wrap {
  position: relative;
  width: 6.5rem;
  height: 6.5rem;
}

.result-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 8;
}

.ring-fg {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: none;
}

.ring-notes { stroke: #60a5fa; }
.ring-timing { stroke: var(--gold); }

.ring-pct {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
  color: #fff;
  z-index: 2;
}

.ring-label {
  display: block;
  margin-top: -0.15rem;
  font-size: 0.75rem;
  color: var(--hint);
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
  min-height: 2.5rem;
}

.result-star {
  font-size: 2.4rem;
  color: rgba(255, 255, 255, 0.2);
  transition: color 0.35s ease, transform 0.35s ease;
}

.result-star.filled {
  color: var(--gold);
  transform: scale(1.08);
  text-shadow: 0 0 12px rgba(245, 200, 66, 0.55);
}

.result-star.empty {
  color: rgba(255, 255, 255, 0.15);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* До (C4) — ориентир скрипичного ключа */
.key.ref-do {
  box-shadow: inset 0 -4px 0 0 rgba(245, 200, 66, 0.85);
}

.key.white.ref-do {
  background: linear-gradient(180deg, #fffef8 0%, #fff8e0 100%);
}

.key.black.ref-do {
  box-shadow: inset 0 -3px 0 0 rgba(245, 200, 66, 0.9);
}

.key.mic-frame {
  box-shadow: 0 0 0 3px #60a5fa, 0 0 14px rgba(96, 165, 250, 0.55);
  z-index: 3;
}

.key.mic-octave {
  box-shadow: 0 0 0 3px #fbbf24, 0 0 12px rgba(251, 191, 36, 0.5);
  z-index: 3;
}

.key.black.mic-frame { box-shadow: 0 0 0 2px #60a5fa, 0 0 10px #60a5fa; }
.key.black.mic-octave { box-shadow: 0 0 0 2px #fbbf24; }
