body {
  --key-width-white: 70px;
  --key-width-black: calc(var(--key-width-white) / 1.5);
  margin: 0;
  font-family: sans-serif;
  background: #333;
  display: flex;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.piano-container {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #222 0%, #111 100%);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7),
    inset 0 2px 6px rgba(255, 255, 255, 0.1);
  transition: background 0.5s, border-color 0.5s, box-shadow 0.5s;
  position: relative;
}

body.piano-mode .piano-container {
  background: linear-gradient(180deg, #4a2b12 0%, #2e1a0b 100%);
  border-color: #5a3720;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8),
    inset 0 2px 6px rgba(255, 255, 255, 0.15);
}

.piano-container::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, #d9a066, #b76b2b, #d9a066);
  box-shadow: 0 0 12px rgba(215, 140, 70, 0.7);
  opacity: 1;
  transition: opacity 0.4s, background 0.3s, box-shadow 0.3s;
  pointer-events: none;
}

body.synth-mode .piano-container::after {
  background: linear-gradient(90deg, #0ff, #08f, #0ff);
  box-shadow: 0 0 12px #0ff;
}

.piano-controls {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 0;
  min-height: 50px;
  width: 100vw;
  background: linear-gradient(180deg, #333, #111);
  border-bottom: 2px solid #555;
  font-family: "Orbitron", sans-serif;
}

.switch-container {
  display: flex;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 32px;
  margin: 0 8px;
  -webkit-tap-highlight-color: transparent;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}

.slider {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 32px;
  background: linear-gradient(90deg, #2196f3 0%, #0ff 100%);
  box-shadow: 0 0 12px rgba(0, 170, 255, 0.18);
  transition: background 0.25s, box-shadow 0.25s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 4px;
  bottom: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  transition: transform 0.25s, background 0.25s;
}

.switch input:checked + .slider {
  background: linear-gradient(90deg, #5a3720 0%, #2e1a0b 100%);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.switch input:checked + .slider::before {
  transform: translateX(32px);
}

.switch input:focus + .slider {
  outline: none;
  box-shadow: 0 0 10px rgba(0, 170, 255, 0.12);
}

.scroll-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #555;
  background: #222;
  color: #fff;
  cursor: pointer;
  margin: 0 6px;
}

.scroll-btn:hover {
  background: #444;
  border-color: #0ff;
  box-shadow: 0 0 8px #0ff;
}

.scroll-btn {
  background: #222;
  color: #fff;
  border: 2px solid #555;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin: 0 6px;
  font-size: 1.2em;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  display: none;
  align-items: center;
  justify-content: center;
}

.scroll-btn:hover {
  background: #444;
  border-color: #0ff;
  box-shadow: 0 0 8px #0ff;
}

.switch-label {
  color: #fff;
  margin: 0 12px;
}

.keyboard-wrapper {
  display: flex;
  width: 100%;
  height: 70vh;
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
}
.keyboard-wrapper::-webkit-scrollbar {
  height: 0;
}

.keyboard {
  display: flex;
  height: 100%;
  width: max-content;
}

.key-group {
  position: relative;
  display: flex;
}

.white-key {
  width: var(--key-width-white);
  height: 100%;
  background: #fff;
  border: 1px solid #000;
  box-sizing: border-box;
  z-index: 1;
}
.black-key {
  width: var(--key-width-black);
  height: 60%;
  background: #000;
  position: absolute;
  top: 0;
  left: var(--key-width-black);
  z-index: 2;
}

.white-key.active {
  background: #ddd;
}
.black-key.active {
  background: #555;
}

@media (max-height: 500px) {
  .keyboard-wrapper {
    height: 60vh;
  }
}
@media (max-height: 350px) {
  .keyboard-wrapper {
    height: 55vh;
  }
}
@media (min-height: 900px) {
  .keyboard-wrapper {
    height: 75vh;
  }
}

.key-size-selector {
  display: flex;
  margin-left: 12px;
  border: 2px solid #555;
  border-radius: 8px;
  overflow: hidden;
}
.key-size-selector button {
  background: #222;
  color: #fff;
  border: none;
  padding: 6px 12px;
  font-size: 0.9em;
  cursor: pointer;
}
.key-size-selector button:hover {
  background: #333;
}
.key-size-selector button.active {
  background: #0ff;
  color: #000;
  font-weight: bold;
}
body.piano-mode .key-size-selector button.active {
  background: #5a3720;
  color: #fff;
}
