:root {
  color-scheme: dark;
  --bg: #05050e;
  --panel: #101027;
  --panel-2: #171731;
  --line: #303052;
  --ink: #f6f4ff;
  --muted: #aaa8c5;
  --accent: #9b6cff;
  --accent-2: #32c8ff;
  --white-key: #f7f7fa;
  --white-key-end: #d7d8df;
  --black-key: #111119;
  --black-key-end: #272733;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    sans-serif;
}
button,
input {
  font: inherit;
}
.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  background: radial-gradient(circle at 50% 10%, #18143d 0, transparent 38%),
    var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: none;
  user-select: none;
}
.sound-gate {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 4, 14, 0.72);
  backdrop-filter: blur(12px);
  transition: opacity 0.2s ease;
}
.sound-gate.ready {
  opacity: 0;
  pointer-events: none;
}
.sound-start {
  min-width: 190px;
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px solid #9b6cff;
  border-radius: 28px;
  background: linear-gradient(145deg, #302269, #13132d);
  color: var(--ink);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.5), 0 0 35px rgba(155, 108, 255, 0.25);
}
.sound-start > span {
  font-size: 42px;
  color: var(--accent-2);
}
.sound-start strong {
  font-size: 18px;
}
.sound-start small {
  color: var(--muted);
}
.topbar {
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 clamp(14px, 3vw, 36px);
  border-bottom: 1px solid #252541;
  background: rgba(8, 8, 28, 0.78);
  backdrop-filter: blur(20px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.brand-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #6747df);
  box-shadow: 0 8px 24px rgba(155, 108, 255, 0.28);
}
.status {
  color: var(--muted);
  font-size: 13px;
}
.icon-button {
  justify-self: end;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 21px;
}
.controls {
  display: grid;
  grid-template-columns: minmax(130px, 170px) minmax(260px, 1fr)
    minmax(150px, 210px);
  gap: 12px;
  padding: 12px clamp(12px, 3vw, 34px);
  background: linear-gradient(180deg, #0d0d24, #09091b);
  border-bottom: 1px solid #282844;
}
.control {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #1a1a38, #111127);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}
button.control {
  cursor: pointer;
}
.control strong,
.control small {
  display: block;
}
.control strong {
  font-size: 14px;
}
.control small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.control-icon {
  font-size: 25px;
  color: var(--accent-2);
}
.sustain[aria-pressed="true"] {
  border-color: var(--accent);
  background: linear-gradient(180deg, #34256a, #1b1742);
  box-shadow: 0 0 24px rgba(155, 108, 255, 0.18);
}
.metronome-control {
  display: grid;
  grid-template-columns: 42px auto minmax(70px, 1fr);
  padding: 7px 12px;
}
.metronome-control button {
  width: 38px;
  height: 38px;
  border: 1px solid #4d4c6b;
  border-radius: 50%;
  background: #111126;
  color: var(--muted);
}
.metronome-control button[aria-pressed="true"] {
  border-color: #ff566f;
  background: #8c2034;
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 86, 111, 0.3);
}
.metronome-control label {
  min-width: 78px;
}
.metronome-control input {
  min-width: 70px;
}
.volume-control {
  padding: 0 16px;
}
.volume-control > span {
  color: var(--muted);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.keyboard-navigator {
  min-height: 66px;
  display: grid;
  grid-template-columns: 44px minmax(0, 720px) 44px;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 8px clamp(12px, 4vw, 46px);
  border-bottom: 1px solid #282844;
  background: #09091b;
}
.zoom-button {
  width: 42px;
  height: 42px;
  border: 1px solid #555475;
  border-radius: 50%;
  background: #111126;
  color: var(--ink);
  font-size: 25px;
}
.zoom-button:disabled {
  opacity: 0.3;
}
.overview {
  position: relative;
  height: 42px;
  overflow: hidden;
  border: 1px solid #3d3c5d;
  border-radius: 9px;
  background: #111126;
  touch-action: none;
}
.overview-keys {
  position: absolute;
  inset: 5px 8px;
  display: flex;
  opacity: 0.34;
}
.overview-white {
  flex: 1;
  border-right: 1px solid #090914;
  background: #d8d8e2;
}
.overview-black {
  position: absolute;
  z-index: 1;
  top: 0;
  width: calc(100% / 52 * 0.62);
  height: 60%;
  transform: translateX(-50%);
  background: #090913;
}
.overview-window {
  position: absolute;
  z-index: 2;
  top: 3px;
  bottom: 3px;
  border: 2px solid #b99cff;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 0 16px rgba(155, 108, 255, 0.38);
  pointer-events: none;
}
.piano-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #020207;
  padding-top: 4px;
}
.glow {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, #fb3aac, #9a65ff 48%, #32d3ff);
  box-shadow: 0 0 20px #8d5dff;
  pointer-events: none;
}
.keyboard {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  touch-action: none;
}
.key {
  border: 0;
  padding: 0;
  outline: none;
  touch-action: none;
}
.white-key {
  position: relative;
  flex: 1;
  height: 100%;
  min-width: 0;
  border-right: 2px solid #11111b;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(
    90deg,
    #d7d8df 0,
    #fff 12%,
    #f7f7fa 78%,
    #c8c9d1 100%
  );
  box-shadow: inset 0 -8px 12px rgba(30, 30, 45, 0.16);
  color: #4f4f5c;
}
.white-key.active {
  background: linear-gradient(180deg, #c6b7ff, #ece8ff 65%, #b39cff);
  box-shadow: inset 0 0 22px rgba(92, 55, 190, 0.35);
}
.key-label {
  position: absolute;
  left: 50%;
  bottom: clamp(12px, 4vh, 34px);
  transform: translateX(-50%);
  font-size: clamp(12px, 2vw, 18px);
  font-weight: 550;
  pointer-events: none;
}
.black-key {
  position: absolute;
  z-index: 2;
  top: 0;
  height: 61%;
  width: calc(100% / var(--white-count, 14) * 0.62);
  transform: translateX(-50%);
  border: 1px solid #3c3c4a;
  border-top: 0;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(90deg, #06060b, #272733 58%, #08080e);
  box-shadow:
    0 7px 9px rgba(0, 0, 0, 0.55),
    inset 0 -5px 4px rgba(255, 255, 255, 0.08);
}
.black-key.active {
  background: linear-gradient(180deg, #7752da, #362564);
  box-shadow:
    0 3px 5px rgba(0, 0, 0, 0.5),
    0 0 18px rgba(155, 108, 255, 0.5);
}
footer {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: #77758f;
  background: #05050e;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.install-hint {
  color: #9a92ba;
}
@media (max-width: 700px) {
  .topbar {
    height: 52px;
  }
  .status {
    display: none;
  }
  .controls {
    grid-template-columns: 90px minmax(190px, 1fr) 110px;
    padding: 8px;
    gap: 7px;
  }
  .control {
    min-height: 50px;
    border-radius: 11px;
  }
  .control strong {
    font-size: 12px;
  }
  .control-icon {
    display: none;
  }
  .volume-control {
    padding: 0 9px;
  }
  .volume-control > span {
    display: none;
  }
  .key-label {
    font-size: 12px;
    bottom: 12px;
  }
  footer {
    display: none;
  }
}
@media (min-width: 900px) {
  .key-label {
    font-size: 14px;
  }
  .controls {
    grid-template-columns: 160px minmax(300px, 1fr) 200px;
  }
}
@media (max-height: 500px) {
  .topbar {
    height: 44px;
  }
  .brand-icon {
    width: 30px;
    height: 30px;
  }
  .controls {
    grid-template-columns: 78px minmax(170px, 1fr) minmax(82px, 0.7fr);
    gap: 6px;
    padding: 6px max(6px, env(safe-area-inset-right)) 6px
      max(6px, env(safe-area-inset-left));
  }
  .control {
    min-height: 44px;
  }
  .metronome-control {
    grid-template-columns: 32px 50px minmax(48px, 1fr);
    gap: 5px;
    padding: 5px 7px;
  }
  .metronome-control button {
    width: 30px;
    height: 30px;
  }
  .metronome-control label {
    min-width: 0;
  }
  .metronome-control label strong {
    display: none;
  }
  .metronome-control input {
    min-width: 48px;
  }
  .volume-control {
    min-width: 0;
    padding: 0 6px;
  }
  .keyboard-navigator {
    min-height: 48px;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 7px;
    padding: 4px max(7px, env(safe-area-inset-right)) 4px
      max(7px, env(safe-area-inset-left));
  }
  .zoom-button {
    width: 34px;
    height: 34px;
  }
  .overview {
    height: 36px;
  }
  .key-label {
    bottom: 8px;
  }
  .black-key {
    height: 59%;
  }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 590px) {
  .controls {
    grid-template-columns: 70px minmax(158px, 1.1fr) minmax(74px, 0.65fr);
  }
  .brand > span:last-child {
    display: none;
  }
}
@media (orientation: portrait) and (max-width: 700px) {
  .controls {
    grid-template-columns: 1fr 1.7fr;
  }
  .metronome-control {
    grid-template-columns: 38px auto minmax(70px, 1fr);
  }
  .volume-control {
    grid-column: 1 / -1;
  }
  .volume-control {
    display: none;
  }
  .black-key {
    height: 58%;
  }
}
