:root {
  color-scheme: dark;
  --room: #12100e;
  --cabinet: #2a2019;
  --cabinet-deep: #1d1713;
  --cabinet-edge: #49382c;
  --roll: #171410;
  --roll-line: #40372f;
  --ivory: #f1ede3;
  --ivory-deep: #d8d1c3;
  --ink: #171410;
  --text: #f4f0e8;
  --muted: #bcb2a5;
  --dim: #847a6f;
  --brass: #c6a164;
  --brass-dark: #765b35;
  --felt: #9f3840;
  --felt-dark: #5f2328;
  --good: #76a99a;
  --miss: #d86d6d;
  --focus: #ffd98c;
  --header-height: 68px;
  --console-height: 86px;
  --keyboard-height: 178px;
  --transport-height: 72px;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "Noto Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--room);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

button,
select,
summary,
.piano-key {
  touch-action: manipulation;
}

button,
select {
  color: inherit;
}

button {
  border: 0;
}

button:not(:disabled),
select:not(:disabled),
summary {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 60;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--ivory);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  transform: translate(-50%, -160%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 1480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--cabinet-deep);
}

.app-header {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(148px, 1fr) auto minmax(148px, 1fr);
  align-items: center;
  height: var(--header-height);
  padding: 0 18px;
  border-bottom: 1px solid var(--cabinet-edge);
  background: var(--cabinet);
}

.header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 720;
  text-decoration: none;
  transition: color 180ms ease-out, background-color 180ms ease-out;
}

.header-button:hover {
  background: var(--cabinet-deep);
  color: var(--text);
}

.app-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-width: 0;
  text-align: left;
}

.app-identity h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.app-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 30px;
  height: 28px;
  padding: 4px;
  border-radius: 6px;
  background: var(--ivory);
}

.brand-mark i {
  display: block;
  width: 4px;
  height: 100%;
  background: var(--ink);
}

.brand-mark i:nth-child(2),
.brand-mark i:nth-child(4) {
  height: 62%;
  align-self: flex-start;
}

.settings {
  position: relative;
  justify-self: end;
}

.settings > summary {
  list-style: none;
}

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

.settings[open] > summary {
  background: var(--cabinet-deep);
  color: var(--text);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 12px 16px;
  width: min(340px, calc(100vw - 24px));
  padding: 16px;
  border: 1px solid var(--cabinet-edge);
  border-radius: var(--radius);
  background: var(--cabinet);
  box-shadow: 0 7px 8px rgb(0 0 0 / 0.28);
}

.settings-panel label,
.settings-version {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.settings-panel select,
.music-console select {
  min-height: 40px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--cabinet-edge);
  border-radius: 8px;
  background-color: var(--cabinet-deep);
  color: var(--text);
  font-size: 1rem;
}

.switch-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--dim);
  transition: background-color 180ms ease-out;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ivory);
  content: "";
  transition: transform 180ms ease-out;
}

.switch-row input:checked + .switch-track {
  background: var(--brass-dark);
}

.switch-row input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch-row input:focus-visible + .switch-track {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.settings-version {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  margin: 2px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--cabinet-edge);
}

.settings-version strong {
  color: var(--text);
}

.studio {
  display: grid;
  grid-template-rows: var(--console-height) minmax(340px, 1fr) var(--transport-height);
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
  background: var(--cabinet-deep);
}

.music-console {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 26px;
  min-width: 0;
  padding: 11px 22px;
  border-bottom: 1px solid var(--cabinet-edge);
  background: #211a15;
}

.song-picker {
  display: grid;
  grid-template-columns: auto minmax(210px, 1fr);
  align-items: center;
  gap: 4px 10px;
  min-width: 270px;
  max-width: 430px;
}

.song-picker label,
.tempo-control label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
}

.song-picker select {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 100%;
  font-weight: 750;
}

.song-credit {
  display: flex;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--dim);
  font-size: 0.67rem;
  white-space: nowrap;
}

.song-credit strong {
  color: var(--brass);
  font-weight: 780;
}

.song-credit span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tempo-control {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 3px 8px;
  flex: 0 0 auto;
}

.tempo-control select {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 88px;
  font-variant-numeric: tabular-nums;
}

.tempo-control output {
  color: var(--dim);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.67rem;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  min-width: 330px;
  margin: 0 0 0 auto;
}

.scoreboard div {
  min-width: 102px;
  padding: 2px 18px;
  border-left: 1px solid var(--cabinet-edge);
}

.scoreboard dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 720;
}

.scoreboard dd {
  margin: 3px 0 0;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.08rem;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.instrument {
  display: grid;
  grid-template-rows: minmax(190px, 1fr) var(--keyboard-height);
  min-height: 0;
  padding: 0 clamp(8px, 2.4vw, 34px);
  background: var(--cabinet);
}

.roll-housing {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--cabinet-edge);
  border-left: 1px solid var(--cabinet-edge);
  background: var(--roll);
}

.roll-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 44px;
  padding: 7px 15px;
  border-bottom: 1px solid var(--roll-line);
  background: #1b1713;
}

.song-now {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.mode-indicator {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--brass-dark);
  color: var(--ivory);
  font-size: 0.63rem;
  font-weight: 820;
}

.studio[data-mode="auto"] .mode-indicator {
  background: #3f7167;
}

.song-now strong {
  overflow: hidden;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-group {
  display: grid;
  grid-template-columns: auto minmax(100px, 200px) 38px;
  align-items: center;
  gap: 9px;
  min-width: 220px;
  color: var(--dim);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--roll-line);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--brass);
  transition: width 120ms linear;
}

.studio[data-mode="auto"] .progress-track span {
  background: var(--good);
}

.piano-roll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--roll);
}

.staff {
  position: absolute;
  top: 27%;
  right: 0;
  left: 0;
  z-index: 0;
  display: grid;
  gap: 13px;
  opacity: 0.68;
}

.staff i {
  display: block;
  height: 1px;
  background: var(--roll-line);
}

.lane-guides {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.lane-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #2e2822;
}

.lane-guide[data-edge="true"] {
  background: var(--roll-line);
}

.note-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.falling-note {
  --note-left: 50%;
  --note-width: 25px;
  --note-height: 34px;
  position: absolute;
  top: 0;
  left: var(--note-left);
  width: var(--note-width);
  height: var(--note-height);
  border-radius: 7px;
  background: var(--ivory);
  box-shadow: 0 3px 0 var(--ivory-deep);
  color: var(--ink);
  transform: translate3d(0, -140px, 0);
  will-change: transform;
}

.falling-note[data-accidental="true"] {
  background: var(--brass);
  box-shadow: 0 3px 0 var(--brass-dark);
}

.falling-note .note-name {
  position: absolute;
  right: 0;
  bottom: 5px;
  left: 0;
  overflow: hidden;
  font-size: 0.63rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyboard-deck[data-labels="false"] .note-name,
.studio[data-labels="false"] .falling-note .note-name {
  display: none;
}

.falling-note.is-perfect,
.falling-note.is-good,
.falling-note.is-auto {
  background: var(--good);
  box-shadow: 0 3px 0 #426e64;
}

.falling-note.is-missed {
  background: var(--miss);
  box-shadow: 0 3px 0 #814040;
  opacity: 0.62;
}

.falling-note.is-finished {
  opacity: 0;
  transition: opacity 160ms ease-out;
}

.strike-line {
  position: absolute;
  bottom: 17px;
  left: var(--track-left, 0);
  z-index: 6;
  width: var(--track-width, 100%);
  height: 3px;
  background: var(--felt);
  box-shadow: 0 2px 0 var(--felt-dark);
}

.strike-line span {
  position: absolute;
  right: 12px;
  bottom: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--felt);
}

.ready-copy,
.finish-copy {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 8;
  width: min(520px, calc(100% - 38px));
  color: var(--text);
  text-align: center;
  transform: translate(-50%, -52%);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

.ready-copy h2,
.finish-copy h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.25rem, 2.8vw, 2rem);
  font-weight: 820;
  letter-spacing: -0.025em;
  line-height: 1.12;
  text-wrap: balance;
}

.ready-copy > p:last-child,
.finish-copy > p:last-child {
  max-width: 54ch;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.ready-kicker {
  margin: 0;
  color: var(--brass);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.studio[data-phase="playing"] .ready-copy,
.studio[data-phase="paused"] .ready-copy,
.studio[data-phase="counting"] .ready-copy {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -45%);
}

.count-in {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 9;
  color: var(--ivory);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(3rem, 10vw, 7rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 5px 0 var(--cabinet-deep);
  transform: translate(-50%, -50%);
}

.hit-feedback {
  position: absolute;
  top: 24%;
  left: 50%;
  z-index: 10;
  color: var(--brass);
  font-size: clamp(1rem, 3vw, 1.55rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
}

.hit-feedback.is-visible {
  animation: feedback-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hit-feedback[data-kind="good"] {
  color: var(--good);
}

.hit-feedback[data-kind="miss"] {
  color: var(--miss);
}

@keyframes feedback-in {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.96);
  }
  24% {
    opacity: 1;
  }
  72% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -7px) scale(1);
  }
}

.keyboard-deck {
  position: relative;
  z-index: 15;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 8px 12px 12px;
  border: 1px solid var(--cabinet-edge);
  border-top: 6px solid #110e0c;
  background: #211915;
  box-shadow: 0 -5px 7px rgb(0 0 0 / 0.24);
}

.keyboard-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 20px;
  color: var(--brass);
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.keyboard-brand i {
  width: 22px;
  height: 1px;
  background: var(--brass-dark);
}

.keyboard-brand small {
  color: var(--dim);
  font-size: inherit;
}

.piano-keyboard {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  width: min(100%, 1120px);
  user-select: none;
  -webkit-user-select: none;
}

.white-keys,
.black-keys {
  position: absolute;
  inset: 0;
}

.white-keys {
  display: flex;
  gap: 2px;
}

.black-keys {
  pointer-events: none;
}

.black-keys .piano-key {
  pointer-events: auto;
}

.piano-key {
  position: relative;
  min-width: 0;
  overflow: hidden;
  transition: transform 90ms ease-out, background-color 90ms ease-out;
}

.piano-key.white-key {
  flex: 1;
  height: 100%;
  padding: 0;
  border-radius: 2px 2px 7px 7px;
  background: var(--ivory);
  box-shadow: inset 0 -4px 0 var(--ivory-deep), 0 3px 0 #0d0b09;
  color: var(--ink);
}

.piano-key.black-key {
  --black-key-width: 6.2%;
  position: absolute;
  top: 0;
  left: calc(var(--position) * 10% - var(--black-key-width) / 2);
  z-index: 4;
  width: var(--black-key-width);
  height: 62%;
  padding: 0;
  border: 2px solid #0c0a09;
  border-top: 0;
  border-radius: 0 0 5px 5px;
  background: #1a1715;
  box-shadow: inset 0 -5px 0 #0d0b0a, 0 4px 3px rgb(0 0 0 / 0.52);
  color: var(--ivory);
}

.piano-key.is-active.white-key {
  background: #dfc68f;
  box-shadow: inset 0 -1px 0 #b89b62, 0 1px 0 #0d0b09;
  transform: translateY(3px);
}

.piano-key.is-active.black-key {
  background: var(--brass-dark);
  box-shadow: inset 0 -2px 0 #3d2d1a, 0 2px 2px rgb(0 0 0 / 0.45);
  transform: translateY(3px);
}

.piano-key.is-expected::after {
  position: absolute;
  right: 50%;
  bottom: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--felt);
  content: "";
  transform: translateX(50%);
}

.key-copy {
  position: absolute;
  right: 2px;
  bottom: 8px;
  left: 2px;
  display: grid;
  gap: 2px;
  pointer-events: none;
  text-align: center;
}

.black-key .key-copy {
  bottom: 7px;
}

.key-copy .note-name {
  font-size: 0.61rem;
  font-weight: 820;
}

.key-copy kbd {
  color: var(--dim);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.54rem;
}

.black-key .key-copy kbd {
  color: var(--muted);
}

.transport {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 10px 18px;
  border-top: 1px solid var(--cabinet-edge);
  background: #211a15;
}

.main-actions,
.session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-action,
.secondary-action,
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 800;
  transition: transform 140ms ease-out, background-color 160ms ease-out,
    color 160ms ease-out;
}

.primary-action {
  background: var(--brass);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--brass-dark);
}

.primary-action:hover:not(:disabled) {
  background: #d8b878;
}

.secondary-action {
  background: var(--good);
  color: #101a17;
  box-shadow: 0 3px 0 #426e64;
}

.secondary-action:hover:not(:disabled) {
  background: #8ebcaf;
}

.icon-action {
  padding-inline: 12px;
  background: var(--cabinet);
  color: var(--muted);
}

.icon-action:hover:not(:disabled) {
  background: #382b22;
  color: var(--text);
}

.primary-action:active:not(:disabled),
.secondary-action:active:not(:disabled),
.icon-action:active:not(:disabled) {
  transform: translateY(2px);
}

.record-action[aria-pressed="true"] {
  background: var(--felt-dark);
  color: var(--text);
}

.record-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--miss);
}

.record-action[aria-pressed="true"] .record-dot {
  animation: record-pulse 900ms ease-in-out infinite alternate;
}

@keyframes record-pulse {
  to {
    opacity: 0.42;
  }
}

.status-line {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1000px) {
  :root {
    --console-height: 94px;
    --transport-height: 118px;
  }

  .music-console {
    flex-wrap: wrap;
    gap: 7px 20px;
    padding-block: 8px;
  }

  .song-picker {
    flex: 1 1 320px;
  }

  .tempo-control {
    margin-left: auto;
  }

  .scoreboard {
    flex: 1 1 100%;
    justify-content: center;
    min-width: 0;
  }

  .scoreboard div {
    flex: 1;
    max-width: 160px;
    padding-block: 0;
    text-align: center;
  }

  .transport {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 7px 12px;
  }

  .status-line {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
  }

  .session-actions {
    justify-self: end;
  }
}

@media (max-width: 680px) {
  :root {
    --header-height: 58px;
    --console-height: 108px;
    --keyboard-height: 150px;
    --transport-height: 108px;
  }

  .app-header {
    grid-template-columns: 48px 1fr 48px;
    padding: 0 8px;
  }

  .header-button {
    width: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 1rem;
  }

  .header-button span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .app-identity {
    gap: 8px;
  }

  .app-identity h1 {
    font-size: 0.95rem;
  }

  .app-subtitle {
    max-width: 170px;
    overflow: hidden;
    font-size: 0.64rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-mark {
    width: 26px;
    height: 24px;
  }

  .settings-panel {
    position: fixed;
    top: calc(var(--header-height) - 2px);
    right: 8px;
  }

  .music-console {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 58px 34px;
    gap: 5px 10px;
    padding: 6px 9px;
  }

  .song-picker {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .song-picker label {
    display: none;
  }

  .song-picker select {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .song-credit {
    grid-row: 2;
  }

  .tempo-control {
    grid-template-columns: 1fr;
    align-self: stretch;
    margin: 0;
  }

  .tempo-control label,
  .tempo-control output {
    display: none;
  }

  .tempo-control select {
    grid-column: 1;
    grid-row: 1;
    min-width: 76px;
    height: 40px;
  }

  .scoreboard {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .scoreboard div {
    max-width: none;
    padding-inline: 8px;
  }

  .scoreboard dt {
    font-size: 0.6rem;
  }

  .scoreboard dd {
    margin-top: 1px;
    font-size: 0.9rem;
  }

  .instrument {
    padding-inline: 0;
  }

  .roll-housing {
    border-right: 0;
    border-left: 0;
  }

  .roll-header {
    min-height: 38px;
    padding: 5px 9px;
  }

  .song-now {
    gap: 7px;
  }

  .mode-indicator {
    font-size: 0.55rem;
  }

  .song-now strong {
    max-width: 115px;
    font-size: 0.74rem;
  }

  .progress-group {
    grid-template-columns: minmax(58px, 120px) 34px;
    min-width: 96px;
  }

  .progress-group > span:first-child {
    display: none;
  }

  .ready-copy > p:last-child {
    font-size: 0.76rem;
  }

  .keyboard-deck {
    padding: 5px 2px 8px;
  }

  .keyboard-brand {
    height: 17px;
  }

  .white-keys {
    gap: 1px;
  }

  .piano-key.black-key {
    --black-key-width: 6.7%;
  }

  .key-copy .note-name {
    font-size: 0.55rem;
  }

  .key-copy kbd {
    font-size: 0.48rem;
  }

  .transport {
    grid-template-columns: 1fr;
    grid-template-rows: 44px 32px 20px;
    gap: 2px;
    padding: 5px 8px;
  }

  .main-actions,
  .session-actions {
    width: 100%;
  }

  .main-actions {
    justify-content: center;
  }

  .session-actions {
    grid-row: 2;
    justify-self: stretch;
    justify-content: center;
  }

  .status-line {
    grid-column: 1;
    grid-row: 3;
    font-size: 0.65rem;
    text-align: center;
  }

  .primary-action,
  .secondary-action,
  .icon-action {
    min-height: 38px;
    padding-inline: 11px;
    font-size: 0.72rem;
  }

  .session-actions .icon-action {
    flex: 1;
    min-height: 30px;
    padding-inline: 5px;
    font-size: 0.65rem;
  }

  .session-actions .icon-action span:not([aria-hidden="true"]):not(.record-dot) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --header-height: 44px;
    --console-height: 50px;
    --keyboard-height: 88px;
    --transport-height: 52px;
  }

  .studio {
    grid-template-rows: var(--console-height) minmax(0, 1fr) var(--transport-height);
  }

  .instrument {
    grid-template-rows: minmax(0, 1fr) var(--keyboard-height);
  }

  .app-header {
    grid-template-columns: 48px 1fr 48px;
    padding-inline: 8px;
  }

  .header-button {
    width: 38px;
    min-height: 34px;
    padding: 0;
  }

  .header-button span:last-child,
  .app-subtitle,
  .brand-mark {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .app-identity h1 {
    font-size: 0.88rem;
  }

  .music-console {
    display: grid;
    grid-template-columns: minmax(190px, 1.1fr) auto minmax(260px, 1fr);
    grid-template-rows: 1fr;
    gap: 8px;
    padding: 5px 9px;
  }

  .song-picker {
    display: block;
    min-width: 0;
  }

  .song-picker label,
  .song-credit {
    display: none;
  }

  .song-picker select {
    width: 100%;
    min-height: 38px;
  }

  .tempo-control {
    display: block;
  }

  .tempo-control label,
  .tempo-control output {
    display: none;
  }

  .tempo-control select {
    min-height: 38px;
  }

  .scoreboard {
    grid-column: auto;
    grid-row: auto;
  }

  .scoreboard div {
    padding-inline: 10px;
  }

  .scoreboard dt {
    font-size: 0.55rem;
  }

  .scoreboard dd {
    margin-top: 0;
    font-size: 0.82rem;
  }

  .roll-header {
    min-height: 28px;
    padding: 3px 8px;
  }

  .mode-indicator,
  .progress-group > span:first-child {
    display: none;
  }

  .progress-group {
    grid-template-columns: minmax(80px, 130px) 32px;
    min-width: 115px;
  }

  .ready-copy h2,
  .finish-copy h2 {
    margin: 2px 0 3px;
    font-size: 1rem;
  }

  .ready-copy > p:last-child,
  .finish-copy > p:last-child,
  .ready-kicker {
    display: none;
  }

  .staff {
    top: 17%;
    gap: 7px;
  }

  .strike-line {
    bottom: 10px;
  }

  .keyboard-deck {
    padding: 2px 3px 5px;
  }

  .keyboard-brand {
    height: 12px;
  }

  .key-copy {
    bottom: 4px;
  }

  .key-copy .note-name {
    font-size: 0.48rem;
  }

  .key-copy kbd {
    display: none;
  }

  .transport {
    display: flex;
    gap: 8px;
    padding: 5px 9px;
  }

  .main-actions {
    flex: 0 0 auto;
  }

  .session-actions {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .status-line {
    flex: 1;
    font-size: 0.62rem;
    text-align: left;
  }

  .primary-action,
  .secondary-action,
  .icon-action,
  .session-actions .icon-action {
    min-height: 36px;
    padding-inline: 9px;
    font-size: 0.68rem;
  }

  .session-actions .icon-action span:not([aria-hidden="true"]):not(.record-dot) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

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

  .falling-note {
    will-change: auto;
  }
}
