:root {
  --ink: #07111b;
  --ink-raised: #0d1c2a;
  --ink-soft: #153044;
  --paper: #f5efe3;
  --mist: #aec0c4;
  --dim: #75909b;
  --brass: #d9a257;
  --brass-light: #ffe1a4;
  --coral: #f07653;
  --line: rgba(191, 221, 224, 0.16);
  --shadow: rgba(0, 5, 9, 0.46);
  color: var(--paper);
  font-family: "Avenir Next Condensed", "DIN Condensed", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(48, 108, 130, 0.22), transparent 34rem),
    radial-gradient(ellipse at 95% 70%, rgba(193, 103, 50, 0.13), transparent 38rem),
    linear-gradient(115deg, #06101a 0%, #091925 48%, #07121d 100%);
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: 0.34;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.22) .55px, transparent .65px);
  background-size: 5px 5px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--brass-light);
  outline-offset: 4px;
}

.simulator {
  width: min(1320px, calc(100% - 40px));
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 26px 0 22px;
}

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  min-height: 66px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 9px;
  color: var(--mist);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
}

.back-link span:first-child {
  display: grid;
  width: 26px;
  aspect-ratio: 1;
  place-items: center;
  color: var(--brass-light);
  border: 1px solid rgba(255, 220, 160, .31);
  border-radius: 50%;
  font-size: 15px;
  transition: transform 180ms ease, background 180ms ease;
}

.back-link:hover span:first-child { transform: translateX(-3px); background: rgba(255, 218, 151, .12); }

.brand-lockup { text-align: center; }
.brand-lockup p,
.section-kicker {
  margin: 0;
  color: var(--brass);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .2em;
}

.brand-lockup h1 {
  margin: 5px 0 0;
  color: var(--paper);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .12em;
}

.mode-switch {
  display: flex;
  justify-self: end;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 17, 27, .48);
}

.mode-button,
.tempo-control button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--dim);
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.mode-button:hover,
.tempo-control button:hover { color: var(--paper); }
.mode-button:active,
.tempo-control button:active { transform: scale(.96); }
.mode-button.is-selected,
.tempo-control button.is-selected { color: #301e0d; background: var(--brass-light); }

.studio-layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 70px);
  padding: clamp(28px, 5vw, 58px) 0 28px;
}

.side-rail {
  display: flex;
  flex-direction: column;
  min-height: 510px;
  padding-right: clamp(14px, 2vw, 26px);
  border-right: 1px solid var(--line);
}

.rail-mark { display: grid; gap: 9px; }
.rail-rule { display: block; width: 58px; height: 2px; background: var(--coral); }
.rail-mark p,
.rail-mark strong {
  margin: 0;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .16em;
}
.rail-mark p { color: var(--dim); }
.rail-mark strong { color: var(--brass-light); }

.practice-note {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  margin-top: 36px;
}

.note-index {
  color: var(--coral);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
}

.practice-note p {
  margin: -3px 0 0;
  color: var(--mist);
  font-size: 14px;
  line-height: 1.75;
}

.session-stats {
  display: grid;
  gap: 14px;
  margin: 36px 0 0;
}

.session-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(191, 221, 224, .11);
}
.session-stats dt { color: var(--dim); font-size: 12px; letter-spacing: .08em; }
.session-stats dd { margin: 0; color: var(--paper); font-family: "DIN Condensed", "Avenir Next Condensed", sans-serif; font-size: 23px; font-weight: 800; letter-spacing: .06em; }

.keyboard-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: auto 0 0;
  padding-top: 28px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .06em;
}
.keyboard-tip span { color: var(--brass); font-size: 16px; }

.play-zone { min-width: 0; }

.status-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 37px;
  margin-bottom: 9px;
}

.status-message {
  margin: 0;
  overflow: hidden;
  color: var(--mist);
  font-size: 13px;
  letter-spacing: .04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.judgement {
  min-width: 82px;
  margin: 0;
  color: var(--brass-light);
  font-family: "DIN Condensed", "Avenir Next Condensed", sans-serif;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .1em;
  text-align: right;
  transition: opacity 180ms ease, color 180ms ease;
}
.judgement.is-perfect { color: var(--brass-light); }
.judgement.is-great { color: #b9f0e1; }
.judgement.is-good { color: var(--mist); }
.judgement.is-miss,
.judgement.is-wrong { color: var(--coral); }

.rhythm-stage {
  position: relative;
  isolation: isolate;
  height: clamp(300px, 39vw, 410px);
  min-height: 300px;
  overflow: hidden;
  border-top: 1px solid rgba(191, 221, 224, .23);
  border-bottom: 1px solid rgba(191, 221, 224, .23);
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.024) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 100%, rgba(185, 105, 58, .18), transparent 43%),
    rgba(4, 16, 26, .58);
  background-size: 12.5% 100%, 100% 52px, auto, auto;
}

.rhythm-stage::before,
.rhythm-stage::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  content: "";
  pointer-events: none;
}
.rhythm-stage::before { background: linear-gradient(90deg, rgba(5, 14, 21, .64), transparent 8%, transparent 92%, rgba(5, 14, 21, .64)); }
.rhythm-stage::after { background: linear-gradient(180deg, rgba(7,17,27,.84), transparent 20%, transparent 76%, rgba(7,17,27,.72)); }

.stage-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -48%;
  width: 54%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(240, 118, 83, .24);
  filter: blur(25px);
  pointer-events: none;
}

.lane-grid,
.lane-names {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  pointer-events: none;
}
.lane { border-right: 1px solid rgba(191, 221, 224, .10); }
.lane:first-child { border-left: 1px solid rgba(191, 221, 224, .10); }
.lane.is-hit { background: rgba(255, 211, 136, .12); box-shadow: inset 0 0 38px rgba(255, 189, 97, .16); }
.lane.is-wrong { background: rgba(240, 118, 83, .14); }

.free-instruction {
  position: absolute;
  z-index: 3;
  top: 34%;
  left: 10%;
  right: 10%;
  display: grid;
  gap: 8px;
  place-items: center;
  color: var(--mist);
  text-align: center;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}
.free-instruction span { color: var(--brass); font-size: 10px; font-weight: 850; letter-spacing: .22em; }
.free-instruction strong { font-size: clamp(22px, 4vw, 39px); font-weight: 750; letter-spacing: .08em; }

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

.falling-note {
  --note-color: #d9a257;
  position: absolute;
  top: 0;
  left: calc((var(--lane) + .5) * 12.5%);
  width: min(9.5%, 58px);
  min-width: 22px;
  height: calc(22px + var(--tail, 0px));
  transform: translate(-50%, -80px);
  border: 1px solid var(--note-color);
  border-radius: 9px 9px 4px 4px;
  opacity: 0;
  background: var(--note-color);
  box-shadow: 0 0 20px rgba(255, 198, 112, .35), inset 0 1px rgba(255,255,255,.58);
  border: 1px solid color-mix(in srgb, var(--note-color) 84%, white);
  background: linear-gradient(180deg, color-mix(in srgb, var(--note-color) 95%, white), var(--note-color));
  box-shadow: 0 0 20px color-mix(in srgb, var(--note-color) 45%, transparent), inset 0 1px rgba(255,255,255,.58);
  will-change: transform, opacity;
}
.falling-note::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  height: 2px;
  content: "";
  border-radius: 999px;
  background: rgba(18, 39, 48, .4);
}
.falling-note.is-visible { opacity: 1; }
.falling-note.is-hit { opacity: 0; transition: opacity 130ms ease; }
.falling-note.is-hidden { opacity: 0; }

.judgement-line {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 62px;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 220, 159, .82) 9%, rgba(255, 220, 159, .82) 91%, transparent);
  box-shadow: 0 0 18px rgba(255, 193, 99, .54);
}
.judgement-line i {
  position: absolute;
  top: -3px;
  left: 0;
  width: 100%;
  height: 8px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1px), rgba(255, 220, 159, .28) calc(12.5% - 1px) 12.5%);
}

.count-in {
  position: absolute;
  z-index: 6;
  top: 37%;
  right: 0;
  left: 0;
  color: var(--brass-light);
  font-family: "DIN Condensed", "Avenir Next Condensed", sans-serif;
  font-size: clamp(58px, 11vw, 108px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: .8;
  text-align: center;
  text-shadow: 0 0 35px rgba(255, 182, 87, .42);
  pointer-events: none;
}

.lane-names { top: auto; height: 42px; align-items: center; }
.lane-names span { display: grid; place-items: center; color: rgba(224, 242, 239, .67); font-size: 10px; font-weight: 850; letter-spacing: .05em; }

.harmonica-dock {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 156px;
  margin-top: -1px;
  border-bottom: 1px solid var(--line);
}

.harmonica-body {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  padding: 10px 0;
  border: 1px solid rgba(255, 225, 166, .34);
  border-radius: 12px;
  background: linear-gradient(180deg, #d9a35b, #7d4d22 48%, #c28b45 52%, #ebc172);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .34), inset 0 1px rgba(255,255,255,.62), inset 0 -2px rgba(64,35,15,.5);
}
.harmonica-cap { height: 7px; border-radius: 999px; background: linear-gradient(90deg, rgba(255,236,190,.32), rgba(78,47,20,.32), rgba(255,236,190,.28)); }
.reed-plate {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0;
  padding: 6px 0;
  border: 1px solid rgba(73,45,21,.42);
  border-radius: 5px;
  background: linear-gradient(180deg, #382515, #9a6634 50%, #382515);
}
.harp-hole {
  position: relative;
  display: block;
  min-width: 0;
  height: 44px;
  margin: 0 clamp(2px, .5vw, 5.5px);
  overflow: hidden;
  border: 1px solid rgba(255,230,184,.28);
  border-radius: 3px;
  background: linear-gradient(90deg, #0e1518, #394143 50%, #0b1011);
  box-shadow: inset 2px 0 4px rgba(0,0,0,.8), inset -2px 0 3px rgba(255,243,205,.15);
  transition: transform 100ms ease, box-shadow 120ms ease, background 120ms ease;
}
.harp-hole::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 45%;
  width: 1px;
  content: "";
  background: rgba(255, 239, 206, .22);
}
.harp-hole.is-active {
  transform: translateY(1px);
  background: linear-gradient(90deg, #442615, #f3c16d 50%, #5d3519);
  box-shadow: 0 0 16px rgba(255, 188, 86, .74), inset 0 0 7px rgba(255,248,219,.44);
}

.breath-waves {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 50%;
  display: flex;
  gap: 9px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 160ms ease;
}
.breath-waves i { display: block; width: 22px; height: 1px; background: var(--brass-light); box-shadow: 0 0 12px var(--brass); }
.harmonica-dock.is-breathing .breath-waves { opacity: .78; animation: breathe 700ms ease-in-out infinite alternate; }

.now-playing {
  position: absolute;
  z-index: 3;
  bottom: 8px;
  left: 0;
  max-width: calc(100% - 8px);
  overflow: hidden;
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 0;
  color: var(--mist);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.now-playing span { color: var(--dim); font-size: 9px; font-weight: 850; letter-spacing: .16em; }

.control-deck {
  margin-left: calc(218px + clamp(24px, 4vw, 70px));
  padding: 30px 0 0;
}
.deck-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.deck-heading h2 { margin: 7px 0 0; color: var(--paper); font-size: clamp(22px, 3vw, 32px); font-weight: 760; letter-spacing: .04em; }

.tempo-control {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 17, 27, .44);
}
.tempo-control span { padding: 0 8px 0 10px; color: var(--dim); font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.tempo-control button { min-width: 35px; padding: 0 9px; }

.key-rack {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0;
  margin-top: 22px;
}

.sound-console {
  margin-top: 22px;
  padding: 16px 18px 14px;
  border: 1px solid rgba(255, 220, 159, .24);
  border-radius: 12px;
  background:
    linear-gradient(100deg, rgba(217, 162, 87, .11), transparent 46%),
    rgba(8, 25, 37, .72);
}
.sound-console-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sound-console-heading strong { color: var(--mist); font-size: 12px; font-weight: 800; letter-spacing: .07em; }
.sound-control-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.5fr; gap: 12px; margin-top: 14px; }
.sound-field { display: grid; gap: 8px; min-width: 0; }
.sound-field > span,
.sound-field > label > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--mist); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.sound-field output { color: var(--brass-light); font-family: "DIN Condensed", "Avenir Next Condensed", sans-serif; font-size: 13px; font-weight: 900; letter-spacing: .06em; }
.sound-volume input { width: 100%; margin: 2px 0 0; accent-color: var(--brass-light); cursor: pointer; }
.pitch-control > div,
.sample-field > div { display: flex; align-items: center; min-height: 35px; }
.pitch-control > div { gap: 7px; }
.pitch-control button,
.sound-download,
.sample-upload {
  display: inline-grid;
  min-width: 32px;
  min-height: 32px;
  place-items: center;
  padding: 0 9px;
  color: var(--paper);
  border: 1px solid rgba(255, 220, 159, .26);
  border-radius: 7px;
  background: rgba(255, 255, 255, .045);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.pitch-control button:hover,
.sound-download:hover,
.sample-upload:hover { color: #28190c; border-color: var(--brass-light); background: var(--brass-light); }
.pitch-control output { min-width: 64px; text-align: center; white-space: nowrap; }
.sound-field select {
  width: 100%;
  min-height: 35px;
  padding: 0 27px 0 10px;
  color: var(--paper);
  border: 1px solid rgba(255, 220, 159, .26);
  border-radius: 7px;
  outline: none;
  background: rgba(255, 255, 255, .045);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}
.sound-field select:focus { border-color: var(--brass-light); }
.sample-field > div { gap: 7px; }
.sample-upload { flex: 1; min-width: 0; white-space: nowrap; }
.sample-field input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.sound-download { flex: 0 0 auto; font-size: 10px; white-space: nowrap; }
.sample-status { margin: 12px 0 0; color: var(--dim); font-size: 11px; line-height: 1.45; letter-spacing: .03em; }

.harp-key {
  --key-color: var(--brass);
  position: relative;
  display: grid;
  min-height: 112px;
  margin: 0 clamp(2px, .5vw, 5.5px);
  padding: 13px 6px 11px;
  overflow: hidden;
  color: #17130d;
  border: 1px solid rgba(255, 227, 172, .64);
  border-radius: 10px;
  background: linear-gradient(150deg, #f6cf83 0%, var(--key-color) 49%, #a96c2b 100%);
  box-shadow: 0 7px 0 #492a11, 0 12px 18px rgba(0,0,0,.25), inset 0 1px rgba(255,255,255,.8);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: transform 95ms ease, filter 120ms ease, box-shadow 95ms ease;
}
.harp-key::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  content: "";
  opacity: .72;
  background: rgba(73,42,17,.55);
}
.harp-key:hover { filter: brightness(1.07); }
.harp-key.is-active,
.harp-key:active { transform: translateY(6px); box-shadow: 0 1px 0 #492a11, 0 4px 9px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.42); }
.harp-key.is-active { filter: saturate(1.13) brightness(1.1); }
.harp-key .key-name { align-self: start; color: rgba(42,25,10,.78); font-family: "DIN Condensed", "Avenir Next Condensed", sans-serif; font-size: clamp(21px, 3vw, 30px); font-weight: 900; line-height: .85; }
.harp-key .key-tone { align-self: center; font-size: clamp(14px, 2vw, 19px); font-weight: 900; letter-spacing: .04em; }
.harp-key .key-note { align-self: end; color: rgba(59,32,13,.72); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.key-0 { --key-color: #dca05d; }.key-1 { --key-color: #dcad5d; }.key-2 { --key-color: #e2be70; }.key-3 { --key-color: #d99854; }.key-4 { --key-color: #e3a657; }.key-5 { --key-color: #dfb160; }.key-6 { --key-color: #d88e50; }.key-7 { --key-color: #f0c36e; }

.round-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 25px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.round-copy span { color: var(--brass); font-size: 10px; font-weight: 850; letter-spacing: .16em; }
.round-copy p { margin: 5px 0 0; color: var(--mist); font-size: 13px; }
.start-round,
.restart-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 46px;
  padding: 0 20px;
  color: #2d1b0c;
  border: 1px solid var(--brass-light);
  border-radius: 999px;
  background: var(--brass-light);
  box-shadow: 0 9px 20px rgba(0,0,0,.22);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .07em;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.start-round:hover,
.restart-round:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 13px 24px rgba(0,0,0,.28); }
.start-round:active,
.restart-round:active { transform: translateY(1px); }
.start-round[disabled] { opacity: .62; cursor: wait; transform: none; }

.result-sheet {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
  padding: 17px 18px;
  border: 1px solid rgba(255, 220, 159, .35);
  border-radius: 12px;
  background: linear-gradient(105deg, rgba(205,147,71,.22), rgba(14,39,51,.64));
}
.result-sheet[hidden] { display: none; }
.result-sheet div { display: grid; gap: 2px; }
.result-sheet div span,
.result-sheet div small { color: var(--mist); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.result-sheet div strong { color: var(--brass-light); font-family: "DIN Condensed", "Avenir Next Condensed", sans-serif; font-size: 33px; line-height: .8; letter-spacing: .08em; }
.result-sheet p { margin: 0; color: var(--paper); font-size: 13px; line-height: 1.55; }

.footer-note {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 38px;
  padding-top: 16px;
  border-top: 1px solid rgba(191, 221, 224, .1);
  color: var(--dim);
  font-size: 11px;
  letter-spacing: .03em;
}
.footer-note p { margin: 0; }

.simulator[data-mode="free"] .rhythm-only { display: none; }
.simulator[data-mode="rhythm"] .free-instruction { opacity: 0; transform: translateY(-8px); }
.simulator[data-mode="rhythm"] .rhythm-stage { background-color: rgba(4, 16, 26, .75); }

@keyframes breathe {
  from { transform: translate(-50%, 2px) scaleX(.78); }
  to { transform: translate(-50%, -3px) scaleX(1.12); }
}

@media (max-width: 840px) {
  .simulator { width: min(100% - 28px, 1320px); padding-top: 18px; }
  .studio-layout { grid-template-columns: 1fr; gap: 18px; padding-top: 28px; }
  .side-rail { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; min-height: 0; padding: 0 0 17px; border-right: 0; border-bottom: 1px solid var(--line); }
  .practice-note { margin: 0; padding-left: 23px; }
  .session-stats { grid-template-columns: repeat(3, auto); gap: 12px; margin: 0; padding-left: 20px; }
  .session-stats div { display: grid; gap: 3px; padding: 0; border: 0; }
  .keyboard-tip { display: none; }
  .harmonica-dock { min-height: 138px; }
  .control-deck { margin-left: 0; }
}

@media (max-width: 620px) {
  .simulator { width: min(100% - 20px, 1320px); }
  .site-header { grid-template-columns: 1fr auto; gap: 13px; padding-bottom: 17px; }
  .brand-lockup { order: -1; grid-column: 1 / -1; text-align: left; }
  .brand-lockup h1 { font-size: 18px; }
  .mode-button { padding: 0 10px; }
  .side-rail { grid-template-columns: 1fr; gap: 15px; }
  .practice-note { padding: 0; }
  .session-stats { padding: 0; }
  .status-strip { grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
  .status-strip .judgement { grid-column: 2; grid-row: 2; min-height: 18px; text-align: left; }
  .rhythm-stage { height: min(61vw, 352px); min-height: 254px; }
  .harmonica-dock { min-height: 121px; }
  .harmonica-body { padding: 8px 0; }
  .reed-plate { gap: 0; padding: 4px 0; }
  .harp-hole { margin: 0 2px; }
  .harp-hole { height: 35px; }
  .now-playing { bottom: 5px; font-size: 10px; }
  .deck-heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .key-rack { gap: 0; margin-top: 17px; }
  .harp-key { min-height: 90px; margin: 0 2px; padding: 10px 3px 8px; border-radius: 7px; }
  .sound-control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sound-volume { grid-column: 1 / -1; }
  .harp-key .key-name { font-size: 23px; }.harp-key .key-tone { font-size: 13px; }.harp-key .key-note { font-size: 8px; }
  .round-actions { align-items: stretch; flex-direction: column; gap: 13px; }
  .start-round { width: 100%; }
  .result-sheet { grid-template-columns: auto 1fr; gap: 13px; }
  .result-sheet .restart-round { grid-column: 1 / -1; width: 100%; }
  .footer-note { align-items: flex-start; flex-direction: column; gap: 8px; margin-top: 27px; }
}

@media (max-width: 390px) {
  .mode-button { padding: 0 8px; font-size: 11px; }
  .rhythm-stage { min-height: 235px; }
  .harp-key { min-height: 82px; }
  .harp-key .key-note { display: none; }
  .sound-console { padding: 14px 12px 12px; }
  .sound-console-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .sound-control-grid { grid-template-columns: 1fr; }
  .sound-volume { grid-column: auto; }
}

/* Portrait remains the default. This only compacts short, naturally rotated phones. */
@media (orientation: landscape) and (max-height: 620px) and (max-width: 960px) {
  .simulator {
    width: min(100% - 32px, 1160px);
    padding: 12px 0 14px;
  }

  .site-header {
    min-height: 44px;
    padding-bottom: 12px;
  }

  .brand-lockup p { font-size: 8px; }
  .brand-lockup h1 { margin-top: 3px; font-size: 16px; }
  .back-link { font-size: 10px; }
  .back-link span:first-child { width: 22px; font-size: 13px; }
  .mode-switch { padding: 3px; }

  .studio-layout {
    grid-template-columns: 154px minmax(0, 1fr);
    gap: 20px;
    padding: 17px 0 14px;
  }

  .side-rail { min-height: 0; padding-right: 14px; }
  .rail-mark { gap: 5px; }
  .rail-mark p,
  .rail-mark strong { font-size: 9px; }
  .practice-note { grid-template-columns: 20px minmax(0, 1fr); gap: 6px; margin-top: 17px; }
  .practice-note p { font-size: 11px; line-height: 1.5; }
  .session-stats { gap: 8px; margin-top: 16px; }
  .session-stats div { padding-bottom: 5px; }
  .session-stats dt { font-size: 10px; }
  .session-stats dd { font-size: 17px; }
  .keyboard-tip { padding-top: 12px; font-size: 9px; }

  .status-strip { min-height: 29px; margin-bottom: 5px; }
  .status-message { font-size: 11px; }
  .judgement { font-size: 15px; }
  .rhythm-stage { height: 220px; min-height: 220px; }
  .free-instruction { top: 29%; }
  .free-instruction strong { font-size: 24px; }
  .harmonica-dock { min-height: 98px; }
  .harmonica-body { padding: 7px 0; }
  .reed-plate { padding: 4px 0; }
  .harp-hole { height: 29px; }
  .now-playing { bottom: 3px; font-size: 10px; }

  .control-deck { padding-top: 17px; }
  .control-deck { margin-left: 174px; }
  .deck-heading h2 { font-size: 21px; }
  .key-rack { margin-top: 12px; }
  .harp-key { min-height: 72px; padding: 8px 3px 6px; }
  .harp-key .key-name { font-size: 21px; }
  .harp-key .key-tone { font-size: 12px; }
  .harp-key .key-note { font-size: 8px; }
  .round-actions { margin-top: 15px; padding-top: 12px; }
  .footer-note { margin-top: 20px; padding-top: 10px; }
}

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