* {
  box-sizing: border-box;
}

*[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f1c2c, #928dab);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
}

.container {
  text-align: center;
  padding: 30px;
}

.top-nav {
  text-align: right;
  margin-bottom: 10px;
}

h1 {
  margin-bottom: 5px;
}

.hint {
  opacity: 0.85;
  margin-bottom: 25px;
}

.hint span {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: bold;
  letter-spacing: 2px;
}

.piano-wrapper {
  max-width: 92vw;
  overflow-x: auto;
  padding: 10px 0 20px;
}

.piano {
  position: relative;
  display: flex;
  justify-content: flex-start;
  user-select: none;
  width: max-content;
  margin: 0 auto;
}

.octave-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 15px;
}

.octave-controls button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

.octave-controls button:hover {
  background: rgba(255, 255, 255, 0.3);
}

#octave-label {
  opacity: 0.85;
  min-width: 160px;
}

.key {
  position: relative;
  flex-shrink: 0;
  border: 1px solid #333;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  font-size: 12px;
  font-weight: bold;
  transition: transform 0.05s ease, background 0.1s ease;
}

.key.bound {
  box-shadow: inset 0 0 0 3px #4caf50;
}

.key.white {
  width: 60px;
  height: 220px;
  background: #fff;
  color: #333;
  z-index: 1;
}

.key.black {
  width: 40px;
  height: 140px;
  background: #1a1a1a;
  color: #fff;
  position: absolute;
  z-index: 2;
  margin: 0 -20px;
}

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

.key.white.active {
  background: #ffe08a;
}

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

.controls {
  margin-top: 30px;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.controls label {
  font-weight: bold;
}

.controls select,
.controls input {
  padding: 5px;
  border-radius: 6px;
  border: none;
}

.controls button {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

.controls button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 13px;
  opacity: 0.75;
}

.practice-link {
  color: #ffe08a;
  font-weight: bold;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
}

.practice-link:hover {
  background: rgba(255, 255, 255, 0.3);
}

.practice-link.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Free-play workstation --------------------------------------------------- */

.free-play-page {
  align-items: flex-start;
  background: linear-gradient(135deg, #211d31 0%, #3a3452 52%, #77718e 100%);
  font-family: 'Avenir Next', 'Trebuchet MS', sans-serif;
}

.free-play-container {
  width: min(100%, 1260px);
  max-width: 1260px;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 58px) 40px;
  text-align: left;
}

.free-play-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.5px;
}

.eyebrow,
.section-label {
  margin: 0;
  color: #d9d3ed;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.8px;
}

.eyebrow {
  margin-bottom: 8px;
  color: #ffe08a;
}

.brand-subtitle {
  margin: 9px 0 0;
  color: #c9c3da;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.brand-subtitle span {
  padding: 0 7px;
  color: #ffe08a;
}

.game-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(22, 18, 37, 0.22);
  color: #f4f1fa;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.game-link:hover,
.game-link:focus-visible {
  border-color: rgba(255, 224, 138, 0.55);
  background: rgba(22, 18, 37, 0.42);
  transform: translateY(-1px);
}

.shortcut-strip {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 48px;
  margin-bottom: 16px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(17, 14, 30, 0.2);
  color: #eeeaf7;
}

.shortcut-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}

.shortcut-label {
  color: #bdb6d1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.shortcut-item strong {
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.6px;
}

.shortcut-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.16);
}

.keyboard-help {
  position: relative;
  margin-left: auto;
  color: #ffe08a;
  font-size: 12px;
  font-weight: 700;
}

.keyboard-help summary {
  cursor: pointer;
  list-style: none;
}

.keyboard-help summary::-webkit-details-marker {
  display: none;
}

.keyboard-help-popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 10px);
  right: 0;
  width: 230px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #29243c;
  box-shadow: 0 16px 35px rgba(9, 7, 18, 0.35);
  color: #e8e3f3;
  font-size: 12px;
  font-weight: 400;
}

.keyboard-help-popover p {
  margin: 5px 0;
}

.keyboard-help-popover strong {
  display: inline-block;
  width: 75px;
  color: #ffe08a;
}

.piano-stage {
  padding: 16px 16px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(17, 14, 30, 0.28);
  box-shadow: 0 18px 42px rgba(13, 9, 27, 0.2);
}

.stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px;
}

.stage-note {
  color: #aaa3be;
  font-size: 12px;
}

.free-play-page .octave-controls {
  width: fit-content;
  margin: 12px auto 8px;
  padding: 4px;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.free-play-page .octave-controls button {
  width: 34px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: #ffe08a;
  font-size: 16px;
}

.free-play-page .octave-controls button:hover,
.free-play-page .octave-controls button:focus-visible {
  background: rgba(255, 224, 138, 0.14);
}

.free-play-page #octave-label {
  min-width: 155px;
  color: #ebe7f5;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.free-play-page .piano-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px 0 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  scrollbar-color: rgba(255, 224, 138, 0.45) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.free-play-page .piano {
  margin: 0 auto;
}

.free-play-page .key {
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.free-play-page .key:hover {
  filter: brightness(1.05);
}

.free-play-page .key.white {
  border-color: #c9c8d1;
  background: linear-gradient(180deg, #fff 0%, #f0eef3 100%);
  box-shadow: inset 0 -8px 12px rgba(82, 72, 103, 0.08);
}

.free-play-page .key.black {
  border-color: #0f0d18;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, #393442 0%, #121018 80%);
  box-shadow: 0 5px 8px rgba(8, 5, 16, 0.4);
}

.free-play-page .key.bound {
  box-shadow: inset 0 -4px 0 #4caf50, inset 0 0 0 2px rgba(76, 175, 80, 0.55);
}

.free-play-page .key.white.active {
  background: #ffe08a;
  box-shadow: inset 0 -7px 0 rgba(178, 132, 23, 0.22);
}

.free-play-page .key.black.active {
  background: #80600d;
}

.free-play-page .controls {
  margin-top: 14px;
  gap: 18px;
}

.instrument-bar,
.song-card {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(17, 14, 30, 0.22);
}

.instrument-bar {
  justify-content: space-between;
  padding: 12px 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 11px;
}

.free-play-page .control-group label {
  color: #ded9ec;
  font-size: 13px;
  font-weight: 700;
}

.free-play-page select {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: #302a47;
  color: #fff;
  font: inherit;
  font-size: 13px;
}

.free-play-page select:focus-visible,
.free-play-page input:focus-visible,
.free-play-page button:focus-visible,
.free-play-page a:focus-visible,
.free-play-page summary:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: 3px;
}

.free-play-page #instrument {
  min-width: 220px;
  padding: 6px 10px;
}

.volume-control {
  min-width: 250px;
}

.free-play-page #volume {
  width: 175px;
  accent-color: #ffe08a;
}

.song-card {
  margin-top: 14px;
  padding: 16px;
}

.song-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.song-caption {
  margin: 4px 0 0;
  color: #aaa3be;
  font-size: 12px;
}

.song-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.12);
}

.song-controls {
  justify-content: flex-start;
  margin: 0;
}

.free-play-page #song-select {
  flex: 1 1 280px;
  min-width: 180px;
  padding: 7px 10px;
}

.free-play-page .song-controls button,
.free-play-page .song-controls .practice-link {
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.free-play-page .song-controls button:hover,
.free-play-page .song-controls .practice-link:hover {
  transform: translateY(-1px);
}

.secondary-action {
  background: rgba(255, 224, 138, 0.16) !important;
  border-color: rgba(255, 224, 138, 0.35) !important;
  color: #ffe08a !important;
}

.secondary-action:hover {
  background: rgba(255, 224, 138, 0.25) !important;
}

.quiet-action {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #d4cfe0 !important;
}

.primary-action {
  background: #ffe08a !important;
  color: #2c263d !important;
}

.primary-action:hover {
  background: #ffebae !important;
}

.free-play-page .status {
  margin: 10px 2px 0;
  color: #c9c3da;
  font-size: 12px;
  text-align: left;
}

@media (max-width: 700px) {
  .free-play-container {
    padding: 22px 12px 28px;
  }

  .free-play-header {
    align-items: flex-end;
    margin-bottom: 18px;
  }

  .brand-block h1 {
    font-size: 30px;
  }

  .game-link {
    padding: 8px 10px;
  }

  .game-link span {
    display: none;
  }

  .shortcut-strip {
    gap: 10px;
    padding: 8px 10px;
  }

  .shortcut-item {
    display: block;
    min-width: 0;
  }

  .shortcut-item strong {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    overflow-wrap: anywhere;
  }

  .shortcut-divider {
    height: 30px;
  }

  .keyboard-help {
    font-size: 0;
    flex-shrink: 0;
  }

  .keyboard-help summary {
    font-size: 0;
    width: 18px;
    overflow: hidden;
  }

  .keyboard-help .help-text {
    display: none;
  }

  .keyboard-help .help-icon {
    color: #ffe08a;
    font-size: 18px;
  }

  .piano-stage {
    padding: 13px 10px 9px;
  }

  .stage-note {
    display: none;
  }

  .instrument-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 11px;
  }

  .control-group,
  .volume-control {
    min-width: 0;
    width: 100%;
    justify-content: space-between;
  }

  .free-play-page #instrument,
  .free-play-page #volume {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .song-controls {
    align-items: stretch;
  }

  .free-play-page #song-select {
    flex-basis: 100%;
  }

  .free-play-page .song-controls button,
  .free-play-page .song-controls .practice-link {
    flex: 1;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .free-play-page .game-link,
  .free-play-page .song-controls button,
  .free-play-page .song-controls .practice-link,
  .free-play-page .key {
    transition: none;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .free-play-container {
    padding: 14px 18px 24px;
  }

  .free-play-header {
    align-items: center;
    margin-bottom: 12px;
  }

  .brand-block h1 {
    font-size: 30px;
  }

  .brand-subtitle {
    margin-top: 4px;
  }

  .eyebrow {
    margin-bottom: 4px;
  }

  .shortcut-strip {
    min-height: 40px;
    margin-bottom: 10px;
    padding: 6px 10px;
  }

  .piano-stage {
    padding: 10px 12px 7px;
  }

  .free-play-page .octave-controls {
    margin: 7px auto 5px;
  }

  .free-play-page .piano-wrapper {
    padding: 6px 0 9px;
  }

  .free-play-page .instrument-bar {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
  }

  .free-play-page .song-card {
    margin-top: 9px;
    padding: 10px 12px;
  }

  .song-card-heading {
    margin-bottom: 7px;
  }
}


