:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #667085;
  --line: #d9e1e7;
  --paper: #ffffff;
  --soft: #f4f7f9;
  --mint: #b8ead9;
  --mint-strong: #20a982;
  --coral: #ff9a82;
  --coral-strong: #e85d48;
  --sun: #ffd66b;
  --sky: #9dd7ff;
  --blue: #2676c7;
  --button-soft: #eef7ff;
  --success-soft: #f0fbf7;
  --prompt-a: #fff7d6;
  --prompt-b: #e9fbff;
  --review-soft: #fff4d8;
  --key-white: #fffdf9;
  --key-black: #23262d;
  --shadow: 0 8px 22px rgba(32, 36, 42, 0.08);
  --android-inset-top: 0px;
  --android-inset-right: 0px;
  --android-inset-bottom: 0px;
  --android-inset-left: 0px;
  --system-top-inset: max(env(safe-area-inset-top, 0px), var(--android-inset-top));
  --system-right-inset: max(env(safe-area-inset-right, 0px), var(--android-inset-right));
  --system-bottom-inset: max(env(safe-area-inset-bottom, 0px), var(--android-inset-bottom));
  --system-left-inset: max(env(safe-area-inset-left, 0px), var(--android-inset-left));
  --keyboard-label-zone: 64px;
}

body[data-theme="pop"] {
  --ink: #25142f;
  --muted: #785d85;
  --line: #f1b7d3;
  --paper: #fff8fc;
  --soft: #fff0f7;
  --mint: #76ffd8;
  --mint-strong: #00b894;
  --coral: #ff6b8a;
  --coral-strong: #ff2e72;
  --sun: #ffe45c;
  --sky: #36d1ff;
  --blue: #8a35ff;
  --button-soft: #f0e5ff;
  --success-soft: #e9fff7;
  --prompt-a: #fff05a;
  --prompt-b: #ffecf6;
  --review-soft: #fff1b6;
  --key-white: #fffaf0;
  background: #fff1f8;
}

body[data-theme="rainbow"] {
  --ink: #17212f;
  --muted: #5d6b7b;
  --line: #cbd9ff;
  --paper: #ffffff;
  --soft: #f0f7ff;
  --mint: #8cffc1;
  --mint-strong: #00a76f;
  --coral: #ff7b54;
  --coral-strong: #ff3d3d;
  --sun: #ffe74a;
  --sky: #7ed7ff;
  --blue: #255cff;
  --button-soft: #e8f0ff;
  --success-soft: #e7fff0;
  --prompt-a: #fff7a8;
  --prompt-b: #ddf3ff;
  --review-soft: #fff1cf;
  --key-white: #fffefa;
  background: #eef6ff;
}

body[data-theme="night"] {
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --line: #334155;
  --paper: #111827;
  --soft: #1f2937;
  --mint: #2dd4bf;
  --mint-strong: #14b8a6;
  --coral: #fb7185;
  --coral-strong: #f43f5e;
  --sun: #fde047;
  --sky: #38bdf8;
  --blue: #60a5fa;
  --button-soft: #172554;
  --success-soft: #14372f;
  --prompt-a: #1f2937;
  --prompt-b: #0f766e;
  --review-soft: #3a2f0b;
  --key-white: #f8fafc;
  --key-black: #020617;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  background: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  /* Landscape-locked app served with viewport-fit=cover: keep content clear
     of the notch (left/right in landscape) and the gesture bar. Zero where
     the platform provides no insets. */
  padding: var(--system-top-inset) var(--system-right-inset)
    var(--system-bottom-inset) var(--system-left-inset);
  color: var(--ink);
  font-family:
    Pretendard,
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    system-ui,
    sans-serif;
  background: #f7fafc;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: 2.45rem;
}

h2 {
  font-size: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 8px;
}

.stats div {
  min-width: 64px;
  padding: 10px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(32, 36, 42, 0.06);
}

.stats span {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
}

.stats small {
  color: var(--muted);
  font-weight: 700;
}

.quick-panel,
.practice-hero,
.composer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 16px;
}

.quick-panel {
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.2fr) minmax(240px, 0.85fr);
  margin-bottom: 16px;
}

.lesson-panel,
.control-panel,
.quick-card,
.mistake-panel,
.parent-report-panel,
.level-panel,
.finger-panel,
.composer-panel,
.mission-panel,
.piano-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lesson-panel,
.control-panel,
.quick-card,
.mistake-panel,
.parent-report-panel,
.level-panel,
.finger-panel,
.composer-panel,
.mission-panel,
.piano-section {
  padding: 16px;
}

.quick-card {
  display: grid;
  align-content: space-between;
  gap: 14px;
  min-height: 144px;
}

.quick-card h2 {
  margin-top: 4px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: 690px;
  overflow: auto;
}

.control-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.control-group summary {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
}

.control-group summary::-webkit-details-marker {
  display: none;
}

.control-group summary::after {
  content: "+";
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: var(--blue);
  background: var(--button-soft);
  border-radius: 8px;
  font-weight: 900;
}

.control-group[open] summary::after {
  content: "-";
}

.control-group summary span {
  display: block;
  font-weight: 900;
}

.control-group summary small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
}

.control-group > :not(summary) {
  margin: 0 12px 12px;
}

.control-panel .composer-grid {
  grid-template-columns: 1fr;
}

.panel-head,
.keyboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.prompt-card {
  min-width: 0;
  min-height: 238px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(135deg, var(--prompt-a), var(--prompt-b));
  border: 1px solid #d8ecf2;
  border-radius: 8px;
}

.prompt-card.correct {
  animation: pop 320ms ease;
}

.prompt-card.miss {
  animation: nudge 260ms ease;
}

.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
}

.badge.right {
  background: var(--mint);
}

.badge.left {
  background: var(--sky);
}

.badge.both {
  background: var(--sun);
}

.badge.neutral {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(32, 36, 42, 0.08);
}

#fingerBadge {
  border-color: color-mix(in srgb, var(--finger-color, var(--sun)) 60%, transparent);
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--finger-color, var(--sun)) 32%, transparent);
}

.target-notes {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 96px;
  align-items: center;
}

.target-note {
  position: relative;
  min-width: 98px;
  max-width: 170px;
  min-height: 132px;
  padding: 12px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid transparent;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 10px 20px rgba(32, 36, 42, 0.1);
}

.finger-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: #111318;
  background: var(--finger-color);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 900;
  box-shadow: 0 8px 14px rgba(32, 36, 42, 0.14);
}

.target-note.done {
  border-color: var(--mint-strong);
}

body.color-notes .target-note {
  background: color-mix(in srgb, var(--note-color) 16%, var(--paper));
  border-color: color-mix(in srgb, var(--note-color) 60%, transparent);
}

body.color-notes .target-note strong {
  color: var(--note-color);
}

.target-note strong {
  display: block;
  font-size: 3.6rem;
  line-height: 1;
}

.target-note span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 800;
}

.target-note span b,
.target-note span small {
  display: block;
}

.target-note .note-code {
  margin-top: 2px;
  color: color-mix(in srgb, var(--muted) 78%, transparent);
  font-size: 0.78rem;
  font-weight: 800;
}

.hand-visualizer {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  min-height: 132px;
}

.hand-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(32, 36, 42, 0.08);
  border-radius: 8px;
}

.hand-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hand-title strong {
  color: var(--ink);
}

.hand-title span {
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 900;
}

.hand-shape {
  position: relative;
  min-height: 86px;
  display: grid;
  grid-template-columns: repeat(5, minmax(32px, 1fr));
  align-items: end;
  gap: 6px;
  padding: 0 8px 22px;
}

.hand-finger {
  position: relative;
  min-height: 50px;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 2px;
  padding: 7px 3px 6px;
  color: #111318;
  background: color-mix(in srgb, var(--finger-color) 34%, #ffffff);
  border: 2px solid color-mix(in srgb, var(--finger-color) 54%, transparent);
  border-radius: 999px 999px 14px 14px;
  font-weight: 900;
  transform-origin: bottom center;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
  z-index: 2;
}

.hand-finger small {
  color: rgba(17, 19, 24, 0.7);
  font-size: 0.68rem;
  font-weight: 900;
}

.hand-finger.active {
  background: var(--finger-color);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--finger-color) 24%, transparent);
  transform: translateY(-10px) scale(1.08);
}

.finger-1 {
  min-height: 46px;
}

.finger-2,
.finger-4 {
  min-height: 62px;
}

.finger-3 {
  min-height: 74px;
}

.finger-5 {
  min-height: 52px;
}

.hand-card.left .finger-1,
.hand-card.right .finger-5 {
  transform: rotate(8deg);
}

.hand-card.left .finger-5,
.hand-card.right .finger-1 {
  transform: rotate(-8deg);
}

.hand-card.left .hand-finger.active,
.hand-card.right .hand-finger.active {
  transform: translateY(-10px) scale(1.08);
}

.hand-palm {
  position: absolute;
  right: 20px;
  bottom: 0;
  left: 20px;
  height: 42px;
  background: color-mix(in srgb, var(--paper) 82%, var(--sun));
  border: 2px solid rgba(32, 36, 42, 0.08);
  border-radius: 999px 999px 18px 18px;
  z-index: 1;
}

.rhythm-panel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(32, 36, 42, 0.08);
  border-radius: 8px;
}

.rhythm-panel strong,
.rhythm-panel span {
  display: block;
}

.rhythm-panel strong {
  font-size: 1.05rem;
  font-weight: 900;
}

.rhythm-panel strong.timing-perfect {
  color: var(--mint-strong);
}

.rhythm-panel strong.timing-early {
  color: var(--coral-strong);
}

.rhythm-panel strong.timing-late {
  color: var(--blue);
}

.rhythm-panel strong.timing-ready {
  color: var(--ink);
}

.rhythm-panel div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.timing-score {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.timing-score span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

.timing-score b {
  color: var(--blue);
}

body.metronome-flash .prompt-card {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--sun) 70%, transparent);
}

.coach-text {
  min-height: 28px;
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(32, 36, 42, 0.08);
  border-radius: 999px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--mint-strong), var(--blue));
  border-radius: inherit;
  transition: width 220ms ease;
}

.action-row,
.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.practice-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, auto)) minmax(220px, 0.8fr) minmax(280px, 1.2fr);
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.option-toggle,
.tempo-presets button,
.loop-controls button {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--button-soft);
  border: 2px solid transparent;
  border-radius: 8px;
  font-weight: 900;
}

.option-toggle.active,
.tempo-presets button.active,
.loop-controls button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.option-toggle:disabled,
.tempo-presets button:disabled,
.loop-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.tempo-presets,
.loop-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.tempo-presets span,
.loop-controls span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.loop-controls span {
  min-width: 116px;
  color: var(--blue);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  padding: 10px 15px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  color: #fff;
  background: var(--blue);
}

.secondary-button {
  color: var(--ink);
  background: var(--sun);
}

.secondary-button.active-input {
  color: #fff;
  background: var(--mint-strong);
}

.ghost-button {
  color: var(--blue);
  background: var(--button-soft);
}

.input-feedback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  margin-top: 12px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.input-feedback strong,
.input-feedback span {
  display: block;
}

.input-feedback span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.detected-note {
  min-width: 74px;
  padding: 10px;
  color: #fff;
  background: #20242a;
  border-radius: 8px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
}

.song-list,
.level-list {
  display: grid;
  gap: 10px;
}

.control-panel .song-list {
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}

.song-button,
.level-button {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px;
  color: var(--ink);
  background: var(--soft);
  border: 2px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.song-button.active,
.level-button.active {
  background: var(--success-soft);
  border-color: var(--mint-strong);
}

.song-mark,
.level-number {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--paper);
  border-radius: 8px;
  font-weight: 900;
}

.song-button strong,
.level-button strong {
  display: block;
  margin-bottom: 3px;
}

.song-button span,
.level-button span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.song-range {
  color: var(--blue);
  font-weight: 900;
}

.piano-section {
  margin: 16px 0;
}

.tempo-control {
  display: grid;
  grid-template-columns: auto minmax(110px, 190px) 44px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.tempo-control input {
  accent-color: var(--blue);
}

.learning-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
}

.learning-main {
  min-height: 74px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border: 2px solid var(--blue);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lesson-pill {
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 6px 10px;
  color: var(--ink);
  background: var(--button-soft);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 900;
}

.lesson-pill.right {
  background: var(--mint);
}

.lesson-pill.left {
  background: var(--sky);
}

.lesson-pill.both {
  background: var(--sun);
}

#lessonNoteName {
  color: var(--note-color, var(--blue));
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1;
  font-weight: 1000;
}

#lessonFinger {
  min-width: 0;
  color: var(--ink);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 900;
}

.lesson-next {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 4px;
  -webkit-overflow-scrolling: touch;
}

.lesson-next-note {
  min-width: 64px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 10px;
  color: var(--ink);
  background: color-mix(in srgb, var(--note-color) 12%, var(--paper));
  border: 2px solid color-mix(in srgb, var(--note-color) 42%, var(--line));
  border-radius: 8px;
  font-weight: 900;
}

.lesson-next-note.current {
  color: #111318;
  background: color-mix(in srgb, var(--note-color) 36%, var(--sun));
  border-color: var(--note-color);
}

.lesson-next-note small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.keyboard-scroll {
  min-width: 0;
  overflow-x: auto;
  padding: 8px 0 2px;
  -webkit-overflow-scrolling: touch;
}

.keyboard {
  position: relative;
  min-width: 1080px;
  height: clamp(220px, 37vw, 340px);
  display: flex;
  align-items: stretch;
  padding: 0 2px;
  user-select: none;
  touch-action: manipulation;
}

.white-key,
.black-key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border-radius: 0 0 8px 8px;
  transition:
    transform 90ms ease,
    background 90ms ease,
    box-shadow 90ms ease;
}

.white-key {
  flex: 1 0 0;
  min-width: 46px;
  padding: 0 4px 14px;
  color: var(--ink);
  background: var(--key-white);
  border: 1px solid #bfc8d2;
  box-shadow: inset 0 -10px 18px rgba(32, 36, 42, 0.08);
  z-index: 1;
}

.key-color {
  width: 22px;
  height: 8px;
  margin-bottom: auto;
  background: transparent;
  border-radius: 999px;
}

body.color-notes .white-key .key-color,
body.color-notes .black-key .key-color {
  background: var(--note-color);
}

body.color-notes .white-key {
  border-top: 5px solid var(--note-color);
}

body.color-notes .white-key.expected,
body.color-notes .white-key.active {
  background: color-mix(in srgb, var(--note-color) 30%, var(--key-white));
}

.black-key {
  position: absolute;
  top: 0;
  width: 30px;
  height: max(44px, min(50%, calc(100% - var(--keyboard-label-zone) - 4px)));
  padding-bottom: 8px;
  color: #fff;
  background: var(--key-black);
  border: 1px solid #16181d;
  box-shadow: 0 7px 14px rgba(32, 36, 42, 0.28);
  z-index: 3;
}

body.color-notes .black-key {
  background: linear-gradient(180deg, var(--note-color), var(--key-black) 62%);
}

body.color-notes .black-key.expected,
body.color-notes .black-key.active {
  background: var(--note-color);
}

.white-key.finger-target::before,
.black-key.finger-target::before {
  content: attr(data-finger);
  position: absolute;
  top: 12px;
  left: 50%;
  min-width: 38px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  color: #111318;
  background: var(--finger-color);
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
  transform: translateX(-50%);
  box-shadow: 0 8px 14px rgba(32, 36, 42, 0.16);
  z-index: 4;
}

.white-key.finger-target::after,
.black-key.finger-target::after {
  content: attr(data-cue);
  position: absolute;
  top: 46px;
  left: 50%;
  width: var(--cue-width, 128px);
  min-width: 92px;
  max-width: 150px;
  box-sizing: border-box;
  padding: 6px 8px;
  color: #111318;
  background: color-mix(in srgb, var(--finger-color) 42%, #ffffff);
  border: 2px solid var(--finger-color);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 1000;
  line-height: 1.15;
  text-align: center;
  transform: translateX(calc(-50% + var(--cue-offset, 0px)));
  box-shadow: 0 10px 16px rgba(32, 36, 42, 0.18);
  pointer-events: none;
  z-index: 5;
}

.black-key.finger-target::before {
  top: 8px;
}

.black-key.finger-target::after {
  top: calc(100% + 7px);
}

.white-key.active,
.white-key.expected {
  background: var(--mint);
}

.black-key.active,
.black-key.expected {
  background: var(--blue);
}

.white-key.pressed,
.black-key.pressed {
  transform: translateY(4px);
}

.key-name {
  font-size: 0.98rem;
  font-weight: 900;
}

.key-labels {
  position: relative;
  z-index: 6;
  min-height: 44px;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
}

.key-note {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.black-key .key-labels {
  z-index: 2;
  min-height: 0;
  gap: 0;
}

.black-key .key-name {
  font-size: 0.82rem;
}

.black-key .key-note {
  font-size: 0.62rem;
}

.black-key .key-note {
  color: rgba(255, 255, 255, 0.72);
}

.stage-panel {
  min-width: 0;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stage-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage-tabs button {
  min-height: 38px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  font-weight: 900;
}

.stage-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.sheet-window {
  min-width: 0;
  position: relative;
  overflow-x: auto;
  min-height: 124px;
  padding: 16px 0;
  background:
    linear-gradient(#e8edf2 1px, transparent 1px) 0 34px / 100% 22px,
    var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  scroll-behavior: smooth;
}

.play-cursor {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: 4px;
  background: var(--coral-strong);
  border-radius: 999px;
  z-index: 2;
}

.sheet-track {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  min-width: 100%;
  padding: 10px max(22px, 45vw);
}

.sheet-note {
  width: 58px;
  min-height: 70px;
  display: grid;
  place-items: center;
  gap: 4px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(32, 36, 42, 0.08);
  font-weight: 900;
}

.sheet-note.current {
  background: var(--sun);
  border-color: #f2bd31;
}

.sheet-note.done {
  background: var(--success-soft);
  border-color: var(--mint-strong);
}

.sheet-note.looped {
  border-color: color-mix(in srgb, var(--note-color) 68%, var(--blue));
}

body.color-notes .sheet-note.current {
  background: color-mix(in srgb, var(--note-color) 28%, var(--sun));
}

.sheet-note small {
  color: var(--muted);
  font-weight: 800;
}

.finger-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.finger-guide div {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--soft);
  border-radius: 8px;
}

.finger-guide strong {
  color: var(--blue);
}

.finger-guide span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 9px;
  background: color-mix(in srgb, var(--finger-color) 18%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--finger-color) 55%, var(--line));
  border-radius: 8px;
  font-weight: 800;
}

.sequence-preview,
.generated-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.settings-panel {
  display: grid;
  gap: 16px;
}

.setting-block {
  display: grid;
  gap: 10px;
}

.setting-block strong {
  color: var(--blue);
}

.theme-grid,
.sound-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.theme-grid button,
.sound-grid button {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--soft);
  border: 2px solid transparent;
  border-radius: 8px;
  font-weight: 900;
  text-align: left;
}

.theme-grid button.active,
.sound-grid button.active {
  background: var(--success-soft);
  border-color: var(--blue);
}

.theme-swatch {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 2px solid rgba(32, 36, 42, 0.12);
  border-radius: 8px;
}

.theme-swatch.clear {
  background: linear-gradient(135deg, #9dd7ff 0 50%, #ffd66b 50% 100%);
}

.theme-swatch.pop {
  background: linear-gradient(135deg, #ff2e72 0 50%, #8a35ff 50% 100%);
}

.theme-swatch.rainbow {
  background: linear-gradient(135deg, #255cff 0 33%, #00a76f 33% 66%, #ffe74a 66% 100%);
}

.theme-swatch.night {
  background: linear-gradient(135deg, #0f172a 0 50%, #60a5fa 50% 100%);
}

.volume-control {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.volume-control input {
  accent-color: var(--blue);
}

.note-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

.note-chip.current {
  background: var(--sun);
  border-color: #f2bd31;
}

body.color-notes .note-chip {
  background: color-mix(in srgb, var(--note-color) 12%, var(--soft));
  border-color: color-mix(in srgb, var(--note-color) 42%, var(--line));
}

body.color-notes .note-chip.current {
  background: color-mix(in srgb, var(--note-color) 34%, var(--sun));
}

.note-chip small {
  color: var(--muted);
  font-weight: 800;
}

.mission-panel {
  margin: 0;
}

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

.daily-practice {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.daily-practice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.daily-practice-head strong,
.daily-practice-head span {
  display: block;
}

.daily-practice-head span {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 800;
}

.sticker-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.sticker-chip {
  min-height: 40px;
  display: inline-grid;
  grid-template-columns: auto;
  align-content: center;
  padding: 7px 10px;
  color: #2f2100;
  background: linear-gradient(135deg, var(--sun), #fff4bd);
  border: 1px solid #efc74a;
  border-radius: 8px;
  font-weight: 900;
}

.sticker-chip small {
  color: #725b14;
  font-size: 0.72rem;
  font-weight: 800;
}

.mission-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mission-card strong {
  color: var(--ink);
}

.mission-card span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.mistake-panel {
  display: grid;
  gap: 12px;
}

.parent-report-panel {
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
}

.parent-report-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.parent-report-card {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.parent-report-card span,
.parent-report-card small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.parent-report-card strong {
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.1;
}

.mistake-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.review-chip,
.empty-state {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 900;
}

.review-chip {
  color: var(--ink);
  background: var(--review-soft);
  border: 1px solid #f0cd79;
}

.review-chip small,
.empty-state {
  color: var(--muted);
  font-weight: 800;
}

.empty-state {
  background: var(--soft);
  border: 1px dashed var(--line);
}

.mission-bar {
  height: 10px;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.mission-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--mint-strong));
}

.composer-panel {
  margin-bottom: 20px;
}

.composer-form,
.composer-result {
  min-width: 0;
}

.composer-form {
  display: grid;
  gap: 8px;
}

.composer-form label {
  color: var(--ink);
  font-weight: 900;
}

.composer-form input,
.composer-form textarea {
  width: 100%;
  padding: 12px;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.composer-form textarea {
  resize: vertical;
}

.composer-result {
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.composer-result strong {
  display: block;
  margin-bottom: 8px;
  color: var(--blue);
}

#customHint {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

body.focus-mode .quick-panel,
body.focus-mode .control-panel {
  display: none;
}

body.focus-mode .practice-hero {
  grid-template-columns: 1fr;
}

body.focus-mode .lesson-panel,
body.focus-mode .piano-section {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}

body.focus-mode .prompt-card {
  min-height: 320px;
}

body.focus-mode .target-note strong {
  font-size: 4.5rem;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.012);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes nudge {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-6px);
  }
  70% {
    transform: translateX(6px);
  }
}

@media (max-width: 900px) {
  .quick-panel,
  .practice-hero,
  .composer-grid {
    grid-template-columns: 1fr;
  }

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

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

  .tempo-presets,
  .loop-controls {
    grid-column: 1 / -1;
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .panel-head,
  .keyboard-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .practice-hero {
    display: contents;
  }

  .lesson-panel {
    order: 1;
  }

  .piano-section {
    order: 2;
  }

  .quick-panel {
    order: 3;
  }

  .control-panel {
    order: 4;
  }

  h1 {
    font-size: 2rem;
  }

  .target-note strong {
    font-size: 2.75rem;
  }

  .song-list {
    grid-template-columns: 1fr;
  }

  .quick-panel {
    gap: 10px;
  }

  .control-panel {
    max-height: none;
    overflow: visible;
  }

  .prompt-card {
    min-height: 220px;
    padding: 14px;
  }

  .target-note {
    min-width: 82px;
    min-height: 118px;
    flex: 1 1 82px;
  }

  .keyboard {
    min-width: 920px;
    height: 250px;
  }

  .tempo-control {
    grid-template-columns: auto minmax(120px, 1fr) 44px;
  }

  .learning-strip {
    grid-template-columns: 1fr;
  }

  .learning-main {
    grid-template-columns: auto minmax(0, auto) minmax(0, 1fr);
  }

  .finger-guide {
    grid-template-columns: 1fr;
  }

  .input-feedback,
  .mission-list {
    grid-template-columns: 1fr;
  }

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

  .rhythm-panel,
  .parent-report-list {
    grid-template-columns: 1fr;
  }

  .timing-score {
    justify-content: stretch;
  }

  .timing-score span {
    flex: 1 1 88px;
    justify-content: center;
  }

  .view-play .rhythm-panel,
  .view-play .stage-panel,
  .view-play .option-toggle,
  .view-play .play-tools-link,
  .view-play .keyboard-toolbar {
    display: none;
  }

  .view-play .compact-tools-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .view-play .compact-extra-tools {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .view-play.compact-tools-open .compact-extra-tools {
    display: grid;
  }

  .view-play.compact-tools-open .option-toggle,
  .view-play.compact-tools-open .play-tools-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
  }

  .view-play .prompt-card {
    gap: 10px;
  }

  .view-play .play-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .view-play .piano-dock {
    margin-top: 0;
  }

  .tempo-presets,
  .loop-controls {
    grid-column: auto;
  }

  .loop-controls span {
    width: 100%;
  }

  .daily-practice-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stage-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stage-tabs {
    justify-content: stretch;
  }

  .stage-tabs button {
    flex: 1 1 0;
  }
}

/* ============================================================
   화면 전환 (메인 메뉴 → 세부 기능 → 되돌아가기)
   ============================================================ */
.view {
  display: none;
}
.view.active {
  display: block;
  animation: view-in 180ms ease;
}
.view-play.active {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.view-head h2 {
  margin: 0;
  flex: 1;
  font-size: 1.4rem;
}
.view-head .ghost-button {
  flex: 0 0 auto;
}
.back-button {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}
.back-button:active {
  transform: translateY(1px);
}
.view-body {
  display: grid;
  gap: 16px;
}

/* ============================================================
   메인 메뉴
   ============================================================ */
.play-hero {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 10px 0 18px;
  padding: 24px 22px;
  border: none;
  border-radius: 26px;
  background: linear-gradient(135deg, var(--coral), var(--blue));
  color: #fff;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.play-hero:active {
  transform: translateY(2px);
}
.play-hero-icon {
  flex: 0 0 auto;
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
  font-size: 1.9rem;
}
.play-hero-text {
  display: grid;
  gap: 4px;
}
.play-hero-text strong {
  font-size: 2.1rem;
  line-height: 1.05;
}
.play-hero-text span {
  font-size: 1rem;
  font-weight: 700;
  opacity: 0.94;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.menu-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 116px;
  padding: 18px 16px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.menu-card:active {
  transform: translateY(2px);
}
.menu-emoji {
  font-size: 2rem;
}
.menu-name {
  font-size: 1.2rem;
  font-weight: 900;
}
.menu-card small {
  color: var(--muted);
  font-weight: 700;
}

/* ============================================================
   연주하기 화면 (가이드 위 / 건반 아래)
   ============================================================ */
.play-guide {
  min-width: 0;
  display: grid;
  gap: 14px;
}
.piano-dock {
  min-width: 0;
  margin-top: 4px;
}
.play-actions {
  flex-wrap: wrap;
  align-items: center;
}
.compact-tools-button {
  display: none;
}
.compact-extra-tools {
  display: contents;
}
.play-tools-link {
  margin-left: auto;
}

/* 도구/진짜피아노 화면 블록 */
.tool-block {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

/* ============================================================
   가이드 계이름 색 = 건반 색 매칭
   (무대 트랙의 모든 타일이 해당 건반과 같은 --note-color 를 보여줌)
   ============================================================ */
body.color-notes .sheet-note {
  border-top: 7px solid var(--note-color);
}
body.color-notes .sheet-note:not(.current):not(.done) {
  background: color-mix(in srgb, var(--note-color) 16%, var(--paper));
}
body.color-notes .sheet-note.current {
  background: color-mix(in srgb, var(--note-color) 40%, var(--paper));
  border-color: var(--note-color);
}

/* ============================================================
   건반 오른손 손가락 번호 (엄지 = 1)
   ============================================================ */
.key-finger {
  margin-top: 10px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--key-finger-color, #ff5f7e);
  color: #111318;
  font-size: 0.82rem;
  font-weight: 900;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 5px rgba(32, 36, 42, 0.22);
}

/* ============================================================
   반응형 / 접근성
   ============================================================ */
@media (max-width: 540px) {
  .play-hero-text strong {
    font-size: 1.8rem;
  }
  .menu-card {
    min-height: 104px;
  }
  .view-head h2 {
    font-size: 1.2rem;
  }
}

.section-title {
  margin-bottom: 4px;
}

/* 밤하늘 테마: 밝은 반투명 표면을 어둡게 바꿔 흰 글자가 보이게 한다 */
body[data-theme="night"] .badge.neutral,
body[data-theme="night"] .rhythm-panel,
body[data-theme="night"] .hand-card {
  background: color-mix(in srgb, var(--paper) 80%, #000);
  border-color: rgba(255, 255, 255, 0.16);
}

/* OS 동작 최소화 설정 존중: 박자 플래시·튕김·손가락 애니메이션을 끈다 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  body.metronome-flash .prompt-card {
    box-shadow: var(--shadow);
  }
}

/* ============================================================
   가로 모드 (안드로이드 가로 고정)
   연주 화면: 계이름(왼쪽) + 건반(오른쪽)을 페이지 스크롤 없이
   한 화면에 동시에. "위(계이름)가 안 보여 못 친다" 문제 해결.
   ============================================================ */
@media (orientation: landscape) {
  .app-shell {
    padding: 8px 12px;
  }

  /* 헤더(상단) / 가이드(좌) / 건반(우) 3구역 그리드 */
  .view-play.active {
    display: grid;
    grid-template-columns: minmax(250px, 38%) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "head head"
      "guide piano";
    gap: 8px 12px;
    height: calc(100vh - 16px - var(--system-bottom-inset));
    height: calc(100svh - 16px - var(--system-bottom-inset));
    overflow: hidden;
  }
  .view-play .view-head {
    grid-area: head;
    margin-bottom: 0;
  }
  .view-play .play-guide {
    grid-area: guide;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
  }
  .view-play .piano-dock {
    grid-area: piano;
    min-height: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .view-play .piano-dock .keyboard-toolbar {
    flex-direction: row;
    align-items: center;
    margin-bottom: 6px;
  }
  /* 건반이 오른쪽 칸 높이를 꽉 채우게 */
  .view-play .piano-dock .keyboard-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: stretch;
    overflow-y: hidden;
    padding: 4px 0 max(12px, var(--system-bottom-inset));
  }
  .view-play .piano-dock .keyboard {
    height: 100%;
  }

  /* 좁은 가이드 칸에 맞춰 카드/시각화 컴팩트 */
  .view-play .prompt-card {
    justify-content: flex-start;
    min-height: 260px;
    padding: 12px;
    gap: 10px;
  }
  .view-play .target-notes {
    flex: 0 0 auto;
    min-height: 0;
  }
  .view-play .target-note strong {
    font-size: 2.6rem;
  }
  .view-play .hand-visualizer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    min-height: 86px;
    gap: 8px;
  }
  .view-play .hand-card {
    gap: 6px;
    padding: 8px;
  }
  .view-play .hand-title {
    font-size: 0.85rem;
  }
  .view-play .hand-shape {
    min-height: 58px;
    gap: 4px;
    padding: 0 6px 16px;
  }
  .view-play .hand-finger {
    min-height: 34px;
    padding: 5px 2px 4px;
  }
  .view-play .hand-finger small {
    display: none;
  }
  .view-play .hand-palm {
    right: 16px;
    left: 16px;
    height: 24px;
  }
  .view-play .stage-panel {
    margin-top: 8px;
    padding-top: 10px;
  }

  .view-play .play-actions {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .view-play .play-actions button {
    min-width: 0;
    padding-right: 10px;
    padding-left: 10px;
    white-space: nowrap;
  }

  .view-play .play-tools-link {
    margin-left: 0;
  }

  /* 홈: 가로 폭 활용 — 메뉴 3열, 히어로 축소 */
  .menu-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .menu-card {
    min-height: 96px;
  }
  .play-hero {
    margin: 6px 0 12px;
    padding: 16px 18px;
  }
  .play-hero-icon {
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
  }
  .play-hero-text strong {
    font-size: 1.7rem;
  }
  .topbar {
    margin-bottom: 10px;
  }
}

@media (orientation: landscape) and (max-height: 430px) {
  .view-play .play-guide {
    align-content: start;
    grid-auto-rows: max-content;
  }

  .view-play .prompt-card {
    min-height: 0;
    padding: 10px;
    gap: 8px;
  }

  .view-play .prompt-meta {
    gap: 6px;
  }

  .view-play .target-notes {
    flex: 0 0 auto;
    gap: 8px;
    min-height: 0;
  }

  .view-play .target-note {
    min-width: 88px;
    min-height: 108px;
    padding: 10px;
  }

  .view-play .target-note strong {
    font-size: 2.25rem;
  }

  .view-play .hand-visualizer {
    min-height: 68px;
  }

  .view-play .coach-text {
    min-height: 0;
    font-size: 0.84rem;
  }

  .view-play .progress-track {
    height: 8px;
  }

  .view-play .coach-text,
  .view-play .progress-track {
    flex: 0 0 auto;
  }

  .view-play .rhythm-panel,
  .view-play .stage-panel,
  .view-play .option-toggle,
  .view-play .play-tools-link {
    display: none;
  }

  .view-play .compact-tools-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .view-play .compact-extra-tools {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .view-play.compact-tools-open .compact-extra-tools {
    display: grid;
  }

  .view-play.compact-tools-open .option-toggle,
  .view-play.compact-tools-open .play-tools-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
  }

  .view-play .play-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .view-play .play-actions button {
    min-height: 40px;
    padding: 7px 8px;
  }
}

@media (orientation: landscape) and (max-height: 340px) {
  .view-play.active {
    grid-template-rows: minmax(38px, auto) minmax(0, 1fr);
    gap: 6px 10px;
    height: calc(100vh - 24px - var(--system-bottom-inset));
    height: calc(100svh - 24px - var(--system-bottom-inset));
  }

  .view-play .play-guide {
    gap: 6px;
  }

  .view-play .view-head {
    gap: 8px;
  }

  .view-play .view-head h2 {
    font-size: 1.05rem;
  }

  .view-play .back-button,
  .view-play .view-head .ghost-button {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 0.9rem;
  }

  .view-play .piano-dock .keyboard-toolbar {
    display: none;
  }

  .view-play .learning-strip {
    grid-template-columns: minmax(170px, 0.9fr) minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 6px;
  }

  .view-play .learning-main {
    min-height: 54px;
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 6px;
    padding: 7px 8px;
  }

  .view-play .lesson-pill {
    min-height: 28px;
    padding: 4px 7px;
    font-size: 0.76rem;
  }

  .view-play #lessonNoteName {
    font-size: 1.85rem;
  }

  .view-play #lessonFinger {
    font-size: 0.82rem;
  }

  .view-play .lesson-next-note {
    min-width: 52px;
    padding: 6px 7px;
  }

  .view-play .piano-dock .keyboard-scroll {
    padding-top: 0;
  }

  .view-play .piano-dock .keyboard {
    --keyboard-label-zone: 60px;
  }

  .view-play .white-key {
    padding-bottom: 18px;
  }

  .view-play .black-key {
    height: max(34px, min(44%, calc(100% - var(--keyboard-label-zone) - 6px)));
    padding-bottom: 8px;
  }

  .view-play .black-key .key-note {
    display: none;
  }

  .view-play .key-finger {
    margin-top: 6px;
  }

  .view-play .key-name {
    font-size: 0.9rem;
  }

  .view-play .key-note {
    font-size: 0.68rem;
  }

  .view-play .target-note strong {
    font-size: 2.2rem;
  }

  .view-play .prompt-card {
    min-height: 0;
    padding: 8px 10px;
    gap: 6px;
  }

  .view-play .badge {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 0.82rem;
  }

  .view-play .target-note {
    min-width: 76px;
    min-height: 78px;
    padding: 7px;
  }

  .view-play .target-note strong {
    font-size: 1.95rem;
  }

  .view-play .target-note span {
    margin-top: 2px;
    font-size: 0.82rem;
  }

  .view-play .target-note .note-code {
    display: none;
  }

  .view-play .finger-dot {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
  }

  .view-play .hand-visualizer {
    min-height: 50px;
    gap: 6px;
  }

  .view-play .hand-card {
    padding: 6px;
    gap: 0;
  }

  .view-play .hand-title {
    display: none;
  }

  .view-play .hand-shape {
    min-height: 42px;
    padding: 0 5px 10px;
  }

  .view-play .hand-finger {
    min-height: 28px;
    padding: 4px 2px 3px;
  }

  .view-play .hand-palm {
    height: 18px;
  }

  .view-play .coach-text {
    min-height: 0;
    font-size: 0.8rem;
    line-height: 1.2;
  }

  .view-play .progress-track {
    display: none;
  }

  .view-play .play-actions {
    margin-top: 0;
  }
}
