:root {
  color-scheme: dark;
  --bg: #10130f;
  --surface: #191d17;
  --surface-raised: #22271f;
  --surface-soft: #151814;
  --text: #f4f1e7;
  --muted: #a6aa9c;
  --faint: #72786d;
  --line: #343a30;
  --line-strong: #4b5345;
  --accent: #d8e56d;
  --accent-hover: #e7f285;
  --accent-ink: #1b1e10;
  --warm: #e8b46b;
  --success: #7fd5a0;
  --danger: #ff8078;
  --radius-large: 30px;
  --radius: 20px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

html:has(body.game-mode),
body.game-mode {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -8%, rgba(216, 229, 109, 0.13), transparent 27rem),
    radial-gradient(circle at -8% 38%, rgba(232, 180, 107, 0.07), transparent 24rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  touch-action: manipulation;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.035em;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 4vw, 2.45rem);
  line-height: 1.05;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

main {
  width: min(calc(100% - 32px), 1040px);
  margin-inline: auto;
  min-height: 100vh;
}

html:has(body.home-view),
body.home-view {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body.home-view {
  background:
    radial-gradient(circle at 8% 92%, rgba(232, 180, 107, 0.1), transparent 28rem),
    radial-gradient(circle at 88% 4%, rgba(216, 229, 109, 0.16), transparent 31rem),
    var(--bg);
}

.home-view main {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
}

.home-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(250px, 0.82fr);
  gap: clamp(28px, 7vw, 92px);
  width: min(100%, 1120px);
  min-height: 100dvh;
  margin-inline: auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(32px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(32px, env(safe-area-inset-left));
  align-items: center;
  overflow: hidden;
}

.home-panel::before {
  position: absolute;
  top: 50%;
  left: clamp(24px, 5vw, 64px);
  width: clamp(210px, 35vw, 450px);
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgba(216, 229, 109, 0.08);
  border-radius: 50%;
  box-shadow:
    0 0 0 42px rgba(216, 229, 109, 0.018),
    0 0 0 94px rgba(216, 229, 109, 0.012);
  pointer-events: none;
  transform: translate(-48%, -18%);
}

.home-copy,
.home-actions {
  position: relative;
  z-index: 1;
}

.home-copy h1 {
  margin: 0;
  font-size: clamp(3.15rem, 8.2vw, 6.65rem);
  line-height: 0.82;
}

.home-copy h1 span {
  display: block;
}

.home-copy h1 span:last-child {
  color: var(--accent);
  font-style: italic;
}

.home-intro {
  max-width: 570px;
  margin: clamp(20px, 4vh, 34px) 0 0;
  color: var(--muted);
  font-size: clamp(0.94rem, 1.8vw, 1.13rem);
  line-height: 1.55;
}

.challenge-rule {
  display: flex;
  gap: clamp(8px, 1.8vw, 18px);
  margin: clamp(15px, 3.2vh, 27px) 0 0;
  align-items: center;
  flex-wrap: wrap;
}

.challenge-rule span {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
  font-size: clamp(0.68rem, 1.3vw, 0.79rem);
  white-space: nowrap;
}

.challenge-rule strong {
  color: var(--text);
  font-size: inherit;
  font-weight: 780;
}

.challenge-rule i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

.home-actions {
  padding-left: clamp(26px, 5vw, 64px);
  border-left: 1px solid var(--line);
}

.session-status {
  min-height: 20px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: clamp(0.72rem, 1.25vw, 0.82rem);
  line-height: 1.4;
}

.challenge-actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.quiet-button,
.icon-button,
.favorite-button {
  min-height: 46px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 780;
  border-radius: 999px;
  cursor: pointer;
}

.primary-button {
  color: var(--accent-ink);
  border: 0;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(216, 229, 109, 0.1);
}

.primary-button:hover {
  background: var(--accent-hover);
}

.quiet-button,
.icon-button,
.favorite-button {
  border: 1px solid var(--line);
  background: var(--surface-raised);
}

.quiet-button:hover,
.icon-button:hover,
.favorite-button:hover {
  border-color: var(--line-strong);
}

.wide-button {
  width: 100%;
  min-height: 55px;
}

.compact {
  min-height: 36px;
  padding-inline: 13px;
  font-size: 0.78rem;
}

.icon-button,
.favorite-button {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}

.favorite-button {
  color: var(--muted);
  font-size: 1.65rem;
}

.favorite-button.active,
.favorite-button[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(216, 229, 109, 0.5);
  background: rgba(216, 229, 109, 0.08);
}

.text-button {
  min-height: 36px;
  padding: 5px 8px;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 0.79rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.text-button:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

.free-mode-button {
  display: grid;
  min-height: 58px;
  padding: 9px 18px;
  place-content: center;
  gap: 2px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(25, 29, 23, 0.54);
  cursor: pointer;
}

.free-mode-button:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.free-mode-button span,
.free-mode-button small {
  display: block;
}

.free-mode-button span {
  font-weight: 780;
}

.free-mode-button small {
  color: var(--muted);
  font-size: 0.68rem;
}

.home-install {
  position: absolute;
  z-index: 3;
  top: max(16px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
}

.developer-access {
  position: absolute;
  z-index: 20;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
}

.developer-access > summary {
  display: grid;
  width: 38px;
  height: 34px;
  place-items: center;
  color: var(--faint);
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  list-style: none;
}

.developer-access > summary::-webkit-details-marker {
  display: none;
}

.developer-access > summary:hover,
.developer-access[open] > summary {
  color: var(--text);
  background: var(--surface-raised);
}

.developer-access-panel {
  position: absolute;
  right: 0;
  bottom: 42px;
  width: min(720px, calc(100vw - 36px));
  max-height: min(78vh, 560px);
  padding: 18px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 24, 20, 0.98);
  box-shadow: var(--shadow);
}

.developer-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setting-field {
  display: block;
}

.setting-field > span {
  display: flex;
  margin-bottom: 8px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

output {
  color: var(--text);
}

.developer-toggle {
  display: inline-flex;
  margin: 0;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  cursor: pointer;
}

.developer-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.developer-toggle span {
  font-size: 0.72rem;
}

.developer-lab {
  margin-top: 16px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(21, 24, 20, 0.68);
}

.developer-heading,
.mode-launchers,
.musician-picker-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.developer-heading {
  justify-content: space-between;
}

.developer-heading .eyebrow {
  margin-bottom: 3px;
}

.mode-launchers {
  margin-top: 16px;
  flex-wrap: wrap;
}

.musician-picker {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.musician-picker > summary {
  display: flex;
  min-height: 48px;
  padding: 0 14px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.musician-picker > summary strong {
  color: var(--muted);
  font-size: 0.7rem;
}

.musician-picker-content {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.musician-picker-actions {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.musician-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px 14px;
  max-height: 260px;
  overflow-y: auto;
}

.musician-option {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.musician-option input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

.musician-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.musician-option small {
  margin-left: auto;
  color: var(--faint);
}

.developer-settings {
  margin-top: 16px;
}

#rating-home-summary,
.selection-warning {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.selection-warning {
  color: var(--danger);
}

.favorites-panel {
  width: min(100%, 760px);
  margin-inline: auto;
  padding: 54px 0 40px;
}

.page-heading {
  display: flex;
  align-items: center;
  gap: 18px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 3.8rem);
}

.page-heading .eyebrow {
  margin-bottom: 3px;
}

.favorites-intro {
  margin: 22px 0 28px 62px;
  color: var(--muted);
  line-height: 1.55;
}

.favorites-list {
  display: grid;
  gap: 9px;
}

.favorite-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 78px;
  padding: 0 16px 0 20px;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(25, 29, 23, 0.72);
}

.favorite-row-main {
  min-width: 0;
  padding: 15px 0;
  color: var(--text);
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.favorite-row-main strong,
.favorite-row-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-row-main strong {
  margin-bottom: 4px;
}

.favorite-row-main span {
  color: var(--muted);
  font-size: 0.78rem;
}

.favorite-row-remove {
  width: 40px;
  height: 40px;
  color: var(--accent);
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

.empty-state {
  padding: 56px 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state > span {
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 2.5rem;
}

.empty-state strong {
  color: var(--text);
}

.empty-state p {
  margin: 8px 0 0;
  font-size: 0.82rem;
}

.exercise-panel {
  display: none;
}

.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: 22px;
  background: rgba(7, 9, 7, 0.78);
  backdrop-filter: blur(9px);
}

.modal-layer:not([hidden]) {
  display: grid;
  place-items: center;
}

.modal-card {
  width: min(100%, 450px);
  padding: clamp(28px, 6vw, 42px);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin-bottom: 16px;
  font-size: clamp(2.2rem, 8vw, 3.2rem);
}

.modal-card > p:not(.eyebrow) {
  margin-bottom: 26px;
  color: var(--muted);
  line-height: 1.55;
}

.install-card {
  text-align: left;
}

.install-card h2 {
  margin-bottom: 22px;
}

.install-steps {
  margin: 0 0 26px;
  padding-left: 1.35rem;
  color: var(--muted);
  line-height: 1.5;
}

.install-steps li {
  padding-left: 5px;
}

.install-steps li + li {
  margin-top: 9px;
}

.install-steps li::marker {
  color: var(--accent);
  font-weight: 800;
}

.install-steps strong {
  color: var(--text);
}

.modal-symbol {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;
  place-items: center;
  color: var(--accent-ink);
  border-radius: 18px;
  background: var(--accent);
  font-size: 1.65rem;
}

.success-symbol {
  color: #102016;
  background: var(--success);
}

.completed-phrases {
  display: grid;
  gap: 7px;
  margin: -4px 0 24px;
  text-align: left;
}

.completed-phrase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  min-height: 48px;
  padding: 5px 6px 5px 12px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}

.completed-phrase-copy {
  min-width: 0;
}

.completed-phrase strong,
.completed-phrase span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.completed-phrase strong {
  font-size: 0.82rem;
}

.completed-phrase span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.completed-phrase-favorite {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.completed-phrase-favorite:hover {
  color: var(--text);
  background: rgba(244, 241, 231, 0.05);
}

.completed-phrase-favorite.active,
.completed-phrase-favorite[aria-pressed="true"] {
  color: var(--accent);
  background: rgba(216, 229, 109, 0.08);
}

.completion-card > .text-button {
  margin-top: 8px;
}

.legacy-completion-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.legacy-completion-actions #completion-original,
.legacy-completion-actions #completion-exit {
  grid-column: 1 / -1;
}

.star-rating {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.star-rating button {
  width: 34px;
  height: 38px;
  padding: 0;
  color: var(--faint);
  border: 0;
  background: transparent;
  font-size: 1.45rem;
  cursor: pointer;
}

.star-rating button.selected {
  color: var(--accent);
}

.rotate-overlay {
  display: none;
}

body.game-mode {
  background:
    radial-gradient(circle at 50% -35%, rgba(216, 229, 109, 0.11), transparent 55%),
    var(--bg);
}

.game-mode .home-panel,
.game-mode .favorites-panel {
  display: none !important;
}

.game-mode main {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  max-width: none;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(9px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.game-mode .exercise-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(110px, 1fr) auto;
  grid-template-areas:
    "header"
    "progress"
    "source"
    "feedback"
    "piano"
    "controls";
  gap: clamp(6px, 1.2vh, 11px);
  width: 100%;
  height: 100%;
}

.game-header {
  grid-area: header;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 14px;
}

.game-heading {
  min-width: 0;
  text-align: center;
}

.game-heading .eyebrow {
  margin-bottom: 2px;
  font-size: clamp(0.58rem, 1.3vw, 0.68rem);
}

.game-heading h2 {
  overflow: hidden;
  font-family: inherit;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  font-weight: 760;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.challenge-progress {
  grid-area: progress;
  display: grid;
  grid-template-columns: auto minmax(160px, 360px);
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.progress-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(0.68rem, 1.65vw, 0.82rem);
}

.progress-copy strong {
  color: var(--text);
}

.progress-copy span {
  color: var(--muted);
}

.progress-dots {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}

.progress-dot {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-dot.complete {
  background: var(--accent);
}

.progress-dot.current {
  background: var(--text);
  box-shadow: 0 0 0 2px rgba(244, 241, 231, 0.08);
}

.sudden-death-mode .progress-dots {
  grid-template-columns: repeat(3, 1fr);
}

.sudden-death-mode .progress-dot.complete {
  background: var(--success);
}

.source-summary {
  grid-area: source;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.69rem, 1.75vw, 0.82rem);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-summary strong {
  color: var(--text);
  font-weight: 720;
}

.feedback {
  grid-area: feedback;
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.69rem, 1.75vw, 0.82rem);
  line-height: 1.15;
  text-align: center;
}

.feedback.success {
  color: var(--success);
}

.feedback.error {
  color: var(--danger);
}

.source-line {
  grid-area: progress;
  margin: 0;
  color: var(--muted);
  font-size: 0.67rem;
  text-align: center;
}

.source-line a {
  margin-left: 6px;
  color: var(--accent);
  white-space: nowrap;
}

.phrase-reference {
  display: inline-flex;
  margin-left: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.phrase-reference code {
  padding-left: 7px;
}

.phrase-reference button {
  min-height: 23px;
  padding: 0 7px;
  color: var(--accent);
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  font-size: 0.65rem;
}

.piano-shell {
  grid-area: piano;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.piano {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 110px;
  overflow: hidden;
  border: 1px solid #080a07;
  border-radius: 15px;
  background: #0a0b09;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.2);
  user-select: none;
}

.key {
  position: absolute;
  top: 0;
  padding: 0 0 9px;
  border-radius: 0 0 7px 7px;
  cursor: pointer;
  transition:
    background 80ms ease,
    transform 80ms ease;
}

.key.white {
  z-index: 1;
  bottom: 0;
  width: calc(100% / var(--white-key-count, 14));
  color: #4b4d47;
  border: 0;
  border-right: 1px solid #bbbcb4;
  background: linear-gradient(#fffef8, #d9d9d0);
}

.key.black {
  z-index: 2;
  width: calc(100% / var(--white-key-count, 14) * 0.62);
  height: 62%;
  color: #dadbd4;
  border: 1px solid #050604;
  background: linear-gradient(#30342d, #090b08 82%);
  box-shadow: 0 9px 14px rgba(0, 0, 0, 0.42);
}

.key.white.chunk-start {
  border-left: 2px solid #797c73;
}

.key span {
  position: absolute;
  right: 0;
  bottom: 7px;
  left: 0;
  font-size: 0.6rem;
  font-weight: 750;
}

.key:active,
.key.active {
  transform: translateY(3px);
}

.key.white.active {
  background: var(--accent);
}

.key.black.active {
  background: #7e892f;
}

.key.reference-key {
  box-shadow: inset 0 -7px 0 var(--warm);
}

.key.correct-key {
  background: var(--success);
}

.key.wrong-key {
  background: var(--danger);
}

.game-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 130px minmax(150px, 1fr);
  min-height: 46px;
  align-items: center;
  gap: 8px;
}

.game-speed-control {
  width: min(100%, 230px);
  justify-self: start;
}

.game-speed-control .setting-field {
  display: grid;
  grid-template-columns: auto minmax(82px, 1fr);
  align-items: center;
  gap: 10px;
}

.game-speed-control .setting-field > span {
  margin: 0;
  gap: 4px;
  font-size: clamp(0.62rem, 1.25vw, 0.72rem);
  white-space: nowrap;
}

.game-speed-control input[type="range"] {
  min-width: 0;
  margin: 0;
}

.replay-button {
  width: 130px;
  grid-column: 2;
}

.game-context-controls {
  display: flex;
  min-width: 0;
  grid-column: 3;
  align-items: center;
  justify-self: end;
  justify-content: flex-end;
  gap: 8px;
}

.game-context-controls .star-rating {
  margin: 0;
}

.developer-game-control {
  display: none;
}

.developer-mode.game-mode:not(.challenge-mode):not(.free-mode) .developer-game-control:not([hidden]) {
  display: flex;
}

.original-controls {
  align-items: center;
  gap: 7px;
}

.transpose-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.7rem;
}

.transpose-toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.rating-workspace {
  min-height: 0;
}

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

.quick-rating button {
  display: grid;
  min-height: 110px;
  place-content: center;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-raised);
  cursor: pointer;
}

.quick-rating strong,
.quick-rating span {
  display: block;
}

.quick-rating strong {
  color: var(--accent);
  font-size: 1.8rem;
}

.quick-rating span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.rating-report {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-raised);
}

.rating-report > strong,
.rating-report > span {
  display: block;
}

.rating-report > span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.rating-mode .exercise-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "header"
    "feedback"
    "rating"
    "source"
    "controls";
}

.rating-mode .challenge-progress,
.rating-mode .source-summary,
.rating-mode .piano-shell,
.rating-mode .favorite-button {
  display: none;
}

.rating-mode .rating-workspace:not([hidden]) {
  display: grid;
  grid-area: rating;
  grid-template-columns: minmax(0, 2fr) minmax(210px, 1fr);
  gap: 12px;
}

.rating-mode .source-line {
  display: block !important;
  grid-area: source;
}

@media (max-width: 760px) {
  main {
    width: min(calc(100% - 24px), 1040px);
  }

  .home-panel {
    grid-template-columns: minmax(0, 1.12fr) minmax(210px, 0.88fr);
    gap: clamp(20px, 5vw, 34px);
    padding-inline:
      max(22px, env(safe-area-inset-right))
      max(22px, env(safe-area-inset-left));
  }

  .challenge-rule {
    gap: 7px 11px;
  }

  .developer-settings {
    grid-template-columns: 1fr;
  }

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

  .favorites-panel {
    padding-top: 30px;
  }

  .favorites-intro {
    margin-left: 0;
  }
}

@media (orientation: portrait) {
  .home-view .rotate-overlay,
  .game-mode:not(.rating-mode) .rotate-overlay {
    position: fixed;
    z-index: 200;
    inset: 0;
    display: grid;
    padding: 24px;
    place-items: center;
    text-align: center;
    background: rgba(16, 19, 15, 0.985);
  }

  .rotate-overlay strong,
  .rotate-overlay p {
    display: block;
  }

  .rotate-overlay p {
    margin: 8px 0 18px;
    color: var(--muted);
  }

  .rotate-icon {
    display: block;
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 3rem;
  }

  .home-view .rotate-overlay .icon-button {
    display: none;
  }

  .rating-mode .rating-workspace:not([hidden]) {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 440px) and (orientation: landscape) {
  .home-panel {
    padding-block:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-bottom));
  }

  .home-copy h1 {
    font-size: clamp(2.65rem, 8.2vw, 4.2rem);
  }

  .home-intro {
    margin-top: 14px;
    font-size: clamp(0.78rem, 1.7vw, 0.94rem);
    line-height: 1.4;
  }

  .challenge-rule {
    margin-top: 12px;
  }

  .home-actions {
    padding-left: clamp(20px, 4vw, 34px);
  }

  .home-actions .wide-button,
  .free-mode-button {
    min-height: 48px;
  }

  .session-status {
    margin-bottom: 10px;
  }

  .game-mode .exercise-panel {
    grid-template-rows: auto auto auto auto minmax(90px, 1fr) auto;
    gap: 5px;
  }

  .game-header {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .game-header .icon-button,
  .game-header .favorite-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .challenge-progress {
    gap: 12px;
  }

  .game-controls,
  .game-controls button {
    min-height: 38px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .modal-layer {
    padding:
      max(10px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
    overflow-y: auto;
  }

  #ios-install-modal .install-card {
    max-height: calc(100dvh - 20px);
    padding: clamp(18px, 5vh, 28px) clamp(22px, 5vw, 36px);
    overflow-y: auto;
  }

  #ios-install-modal .install-card h2 {
    margin-bottom: 14px;
    font-size: clamp(2rem, 10vh, 2.7rem);
  }

  #ios-install-modal .install-steps {
    margin-bottom: 16px;
  }

  #sudden-death-modal .modal-card,
  #challenge-complete-modal .modal-card {
    width: min(100%, 850px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: clamp(14px, 4vh, 24px) clamp(18px, 4vw, 34px);
    overflow-y: auto;
    border-radius: clamp(20px, 4vw, 30px);
  }

  #sudden-death-modal .sudden-death-card {
    display: grid;
    grid-template-columns: minmax(105px, 0.48fr) minmax(0, 1.52fr);
    grid-template-areas:
      "symbol eyebrow"
      "symbol title"
      "symbol copy"
      "symbol action";
    column-gap: clamp(18px, 4vw, 36px);
    text-align: left;
  }

  #sudden-death-modal .modal-symbol {
    grid-area: symbol;
    width: clamp(64px, 20vh, 82px);
    height: clamp(64px, 20vh, 82px);
    margin: 0 auto;
    align-self: center;
    border-radius: 22px;
    font-size: clamp(1.7rem, 7vh, 2.2rem);
  }

  #sudden-death-modal .eyebrow {
    grid-area: eyebrow;
    margin-bottom: 3px;
    align-self: end;
  }

  #sudden-death-modal h2 {
    grid-area: title;
    margin: 0 0 9px;
    font-size: clamp(2rem, 11vh, 3rem);
  }

  #sudden-death-modal .modal-card > p:not(.eyebrow) {
    grid-area: copy;
    margin: 0 0 16px;
    font-size: clamp(0.78rem, 2.2vh, 0.92rem);
    line-height: 1.45;
  }

  #sudden-death-modal .primary-button {
    grid-area: action;
    min-height: 46px;
  }

  #challenge-complete-modal .completion-card {
    display: grid;
    grid-template-columns: minmax(145px, 0.65fr) minmax(0, 1.35fr);
    grid-template-areas:
      "symbol phrases"
      "eyebrow phrases"
      "title phrases"
      "copy phrases"
      "home action";
    column-gap: clamp(18px, 4vw, 34px);
    text-align: left;
  }

  #challenge-complete-modal .modal-symbol {
    grid-area: symbol;
    margin: 0 0 10px;
    justify-self: start;
  }

  #challenge-complete-modal .eyebrow {
    grid-area: eyebrow;
    margin-bottom: 3px;
    font-size: 0.62rem;
    letter-spacing: 0.13em;
    white-space: nowrap;
  }

  #challenge-complete-modal h2 {
    grid-area: title;
    margin: 0 0 9px;
    font-size: clamp(2rem, 10vh, 2.75rem);
  }

  #challenge-complete-modal .modal-card > p:not(.eyebrow) {
    grid-area: copy;
    margin: 0;
    font-size: clamp(0.76rem, 2.1vh, 0.88rem);
    line-height: 1.42;
  }

  #challenge-complete-modal .completed-phrases {
    grid-area: phrases;
    margin: 0;
    align-self: center;
  }

  #challenge-complete-modal .completed-phrase {
    min-height: 44px;
    padding-block: 3px;
  }

  #challenge-complete-modal #finish-new-challenge {
    grid-area: action;
    min-height: 46px;
    margin-top: 10px;
  }

  #challenge-complete-modal #finish-home {
    grid-area: home;
    min-height: 46px;
    margin-top: 10px;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
