body {
  margin: 0;
  background: #091a1a;
  color: #e6fffb;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* Changed from center to allow scrolling if needed */
  min-height: 100vh;
  overflow-y: auto;
}

.controls-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
  margin-top: -10px; /* Pull up closer to keys */
  position: relative;
  z-index: 100;
}

.sustain-pedal {
  width: 90%;
  max-width: 400px;
  height: 60px;
  background: linear-gradient(to bottom, #444, #222);
  color: #ccc;
  border: 2px solid #555;
  border-radius: 8px;
  font-size: 18px;
  touch-action: none; /* Prevent zooming/scrolling while tapping */
  user-select: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: all 0.1s ease;
}

.sustain-pedal:active, .sustain-pedal.active {
  background: linear-gradient(to bottom, #2dd4bf, #0d9488);
  color: #0f2a2a;
  border-color: #5eead4;
  box-shadow: 0 0 15px rgba(45, 212, 191, 0.5), inset 0 2px 4px rgba(0,0,0,0.2);
  transform: translateY(2px);
}

.pedal-icon {
  font-size: 24px;
  transform: rotate(90deg); /* Make it look like a pedal */
}

.pedal-text {
  font-weight: bold;
}

.piano-wrapper {
  width: 100%;
  overflow-x: auto; /* Enable horizontal scroll for long keyboard */
  display: flex;
  justify-content: center; /* Center if it fits, start if it overflows */
  padding: 80px 0 20px 0;
}

.piano-container {
  padding: 20px;
  background: #0f2a2a;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: inline-block; /* Allow width to grow */
  min-width: min-content;
}

.keys {
  display: flex;
  position: relative;
  height: 200px; /* Fixed height container */
}

.key {
  cursor: pointer;
  position: relative;
  user-select: none;
  border-radius: 0 0 4px 4px;
  transition: all 0.1s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  flex-shrink: 0; /* Don't shrink keys */
}

.key.white {
  width: 50px; /* Slightly narrower to fit more keys */
  height: 200px;
  background: white;
  border: 1px solid #ccc;
  z-index: 1;
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 5px;
  font-weight: bold;
  font-size: 14px; /* Smaller font */
}

.key.white:active, .key.white.active {
  background: #eee;
  transform: translateY(2px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.key.black {
  width: 30px;
  height: 120px;
  background: #111;
  margin-left: -15px;
  margin-right: -15px;
  z-index: 2;
  border: 1px solid #000;
  pointer-events: auto; /* Ensure clicks register */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 5px;
  color: #eee;
  font-size: 10px;
}

.note-label {
  margin-top: 10px;
  font-size: 16px;
}

.staff-label {
  font-size: 10px;
  opacity: 0.8;
  margin-top: auto; /* Push to bottom along with key-label */
  margin-bottom: 2px;
}

.key-label {
  opacity: 0.7;
  font-size: 12px;
  margin-bottom: 10px;
}

.key.black .note-label {
  margin-top: 5px;
  font-size: 12px;
}

.key.black .staff-label {
  font-size: 9px;
  margin-bottom: 2px;
}

.key.black .key-label {
  margin-bottom: 5px;
  font-size: 10px;
}

.key.black .key-label {
  font-size: 10px;
}

.key.black:active, .key.black.active {
  background: #333;
  transform: translateY(2px);
}

.instructions-block {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  padding: 15px;
  background: rgba(15, 42, 42, 0.8);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: #e6fffb;
  box-sizing: border-box;
}

.instructions-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #2dd4bf;
  border-bottom: 1px solid rgba(45, 212, 191, 0.3);
  padding-bottom: 5px;
}

.instructions-content {
  font-size: 14px;
  line-height: 1.6;
}

.instruction-item {
  margin-bottom: 10px;
}

.instruction-item ul {
  margin: 5px 0;
  padding-left: 20px;
}

.instruction-item li {
  margin-bottom: 3px;
}

.instruction-item code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  color: #5eead4;
}

.ads-block {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding: 0 12px;
  box-sizing: border-box;
}

.ads-title {
  font-size: 10px;
  color: #555;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ad-slot {
  width: 100%;
  max-width: 300px;
  min-width: 300px;
  height: 250px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #2f4f4f;
  font-weight: bold;
  font-size: 18px;
  position: relative;
  overflow: hidden;
}

/* Scrollbar styling */
.piano-wrapper::-webkit-scrollbar {
  height: 8px;
}
.piano-wrapper::-webkit-scrollbar-track {
  background: #091a1a;
}
.piano-wrapper::-webkit-scrollbar-thumb {
  background: #2dd4bf;
  border-radius: 4px;
}

/* Autoplay Styles */
.autoplay-block {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  padding: 15px;
  background: rgba(15, 42, 42, 0.8);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: #e6fffb;
  box-sizing: border-box;
}

.autoplay-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #2dd4bf;
  border-bottom: 1px solid rgba(45, 212, 191, 0.3);
  padding-bottom: 5px;
}

.autoplay-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#scoreInput {
  width: 100%;
  height: 80px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #555;
  border-radius: 4px;
  color: #e6fffb;
  padding: 10px;
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
}

#scoreInput:focus {
  outline: none;
  border-color: #2dd4bf;
}

.autoplay-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.autoplay-buttons button {
  background: #0d9488;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

.autoplay-buttons button:hover {
  background: #14b8a6;
}

.autoplay-buttons button.stop-btn {
  background: #be123c;
}

.autoplay-buttons button.stop-btn:hover {
  background: #f43f5e;
}

.tempo-control {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 4px;
}

.tempo-control input[type="range"] {
  width: 100px;
}

.demo-songs {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 10px;
}

.demo-label {
  font-size: 14px;
  color: #999;
  margin-right: 5px;
}

.demo-btn {
  background: rgba(45, 212, 191, 0.2);
  border: 1px solid #2dd4bf;
  color: #2dd4bf;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.demo-btn:hover {
  background: #2dd4bf;
  color: #0f2a2a;
}

@media (max-width: 600px) {
  .piano-wrapper {
    justify-content: flex-start; /* Align start to allow scrolling on mobile */
    padding-left: 10px;
    padding-right: 10px;
  }
  .key.white {
    width: 40px;
    height: 160px;
    font-size: 12px;
  }
  .key.black {
    width: 24px;
    height: 100px;
    margin-left: -12px;
    margin-right: -12px;
  }
}
