* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  background: linear-gradient(180deg, #1b1d23 0%, #0e0f12 100%);
  color: #f5f5f7;
}

.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  padding: 0.6rem 1rem;
}

.app-header h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-header nav a {
  color: #9a9ba3;
  text-decoration: none;
  font-size: 0.85rem;
}

.app-header nav a:hover,
.app-header nav a:focus-visible {
  color: #f5f5f7;
}

.app-header .subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #8d8e96;
}

.app-header .subtitle kbd {
  font-family: inherit;
  border: 1px solid #4a4b52;
  border-radius: 0.25rem;
  padding: 0 0.3rem;
  background: #26272c;
  color: #d3d4da;
}

.piano-wrap {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  padding: 0 0.6rem 0.6rem;
}

.piano {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  width: 100%;
}

.white-keys {
  display: flex;
  width: 100%;
  gap: 3px;
}

.key {
  border: none;
  font: inherit;
  color: inherit;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.key.white {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 0.9rem;
  background: linear-gradient(180deg, #fff 0%, #f1f1f3 88%, #e2e2e6 100%);
  border: 1px solid #cfcfd4;
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow:
    inset 0 -3px 4px rgb(0 0 0 / 8%),
    0 2px 3px rgb(0 0 0 / 30%);
  color: #33343a;
  transition:
    transform 60ms ease,
    box-shadow 60ms ease,
    background 60ms ease;
}

.key.white .key-label {
  font-size: clamp(0.6rem, 1.3vw, 0.9rem);
  font-weight: 600;
  opacity: 0.5;
}

.key.white .note-label {
  font-size: clamp(0.85rem, 2.2vw, 1.35rem);
  font-weight: 700;
  margin-top: 0.15rem;
}

.key.white.is-pressed {
  background: linear-gradient(180deg, #dbe4ff 0%, #c3d0fb 100%);
  box-shadow: inset 0 2px 6px rgb(0 0 0 / 30%);
  transform: translateY(3px);
}

.black-keys {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.key.black {
  position: absolute;
  top: 0;
  width: 6.4%;
  height: 58%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 0.6rem;
  background: linear-gradient(180deg, #3d3d41 0%, #1b1b1d 82%, #000 100%);
  border: 1px solid #000;
  border-radius: 0 0 0.4rem 0.4rem;
  box-shadow:
    0 3px 4px rgb(0 0 0 / 55%),
    inset 0 -2px 3px rgb(255 255 255 / 6%);
  color: #e8e8ea;
  pointer-events: auto;
  z-index: 2;
  transition:
    transform 60ms ease,
    box-shadow 60ms ease,
    background 60ms ease;
}

.key.black .key-label {
  font-size: clamp(0.5rem, 1vw, 0.7rem);
  opacity: 0.65;
}

.key.black .note-label {
  font-size: clamp(0.55rem, 1.2vw, 0.8rem);
  margin-top: 0.1rem;
}

.key.black.is-pressed {
  background: linear-gradient(180deg, #58585f 0%, #2c2c30 100%);
  transform: translateX(-50%) translateY(3px);
  box-shadow: 0 1px 2px rgb(0 0 0 / 60%);
}

.key:focus-visible {
  outline: 3px solid #6ea8fe;
  outline-offset: 2px;
}

@media (width <= 30rem) {
  .app-header {
    padding: 0.5rem 0.75rem;
  }

  .app-header .subtitle {
    flex-basis: 100%;
  }
}
