*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #121212;
  color: #ffffff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  padding: 32px 0 20px;
  text-align: center;
}

header h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #ffffff;
}

.version {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
  letter-spacing: 1px;
}

#update-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #27ae60;
  color: #fff;
  text-align: center;
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

#update-banner.visible {
  display: flex;
}

#btn-update {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 8px;
}

main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8px 16px;
}

.pad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 900px;
  width: 94vw;
}

.pad {
  aspect-ratio: 1;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, filter 0.08s ease, box-shadow 0.08s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

.pad::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
  border-radius: 18px;
}

.pad:hover {
  filter: brightness(1.1);
}

.pad.active {
  transform: scale(0.92);
  filter: brightness(1.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.key-label {
  font-size: 44px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.95);
  text-transform: uppercase;
  line-height: 1;
}

.sound-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Row 1: Reds/Oranges */
.pad[data-key="1"] { background-color: #e74c3c; }
.pad[data-key="2"] { background-color: #e67e22; }
.pad[data-key="3"] { background-color: #f39c12; }
.pad[data-key="4"] { background-color: #d35400; }

/* Row 2: Blues/Teals */
.pad[data-key="Q"] { background-color: #3498db; }
.pad[data-key="W"] { background-color: #2980b9; }
.pad[data-key="E"] { background-color: #1abc9c; }
.pad[data-key="R"] { background-color: #16a085; }

/* Row 3: Purples/Pinks */
.pad[data-key="A"] { background-color: #9b59b6; }
.pad[data-key="S"] { background-color: #8e44ad; }
.pad[data-key="D"] { background-color: #e91e63; }
.pad[data-key="F"] { background-color: #c0392b; }

/* Row 4: Greens/Cyans */
.pad[data-key="Z"] { background-color: #27ae60; }
.pad[data-key="X"] { background-color: #2ecc71; }
.pad[data-key="C"] { background-color: #00bcd4; }
.pad[data-key="V"] { background-color: #009688; }

/* Controls bar */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 16px 12px;
  width: 94vw;
  max-width: 900px;
}

.bank-toggle {
  display: flex;
  gap: 4px;
  background: #1e1e1e;
  border-radius: 8px;
  padding: 3px;
}

.bank-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.bank-btn.active {
  background: #ffffff;
  color: #121212;
}

.seq-controls {
  display: flex;
  gap: 8px;
}

.seq-btn {
  background: #1e1e1e;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seq-btn:active {
  transform: scale(0.95);
}

#btn-rec.seq-active {
  background: #e74c3c;
  color: #fff;
  animation: recording-pulse 0.8s ease-in-out infinite;
}

#btn-play.seq-active {
  background: #27ae60;
  color: #fff;
}

/* Empty pad (bank B) */
.pad.empty {
  opacity: 0.35;
}

.pad.empty .sound-label {
  font-style: italic;
}

/* Recording state */
@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7); }
  50% { box-shadow: 0 0 0 12px rgba(255, 0, 0, 0); }
}

.pad.recording {
  animation: recording-pulse 0.8s ease-in-out infinite;
  outline: 3px solid #ff0000;
  outline-offset: -3px;
  filter: brightness(0.7);
}

.pad.record-error {
  outline: 3px solid #ffcc00;
  outline-offset: -3px;
}

/* Responsive: 4 cols -> 3 cols -> 2 cols */
@media (max-width: 700px) {
  header {
    padding: 20px 0 12px;
  }

  header h1 {
    font-size: 24px;
    letter-spacing: 4px;
  }

  .controls {
    gap: 16px;
  }

  .bank-btn {
    padding: 5px 12px;
    font-size: 12px;
  }

  .seq-btn {
    padding: 6px 10px;
    font-size: 10px;
  }

  .pad-grid {
    gap: 12px;
  }

  .key-label {
    font-size: 36px;
  }

  .sound-label {
    font-size: 11px;
    margin-top: 8px;
  }
}

@media (max-width: 480px) {
  .pad-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 96vw;
  }

  .key-label {
    font-size: 32px;
  }

  .sound-label {
    font-size: 10px;
  }
}

@media (max-width: 340px) {
  .pad-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .key-label {
    font-size: 30px;
  }

  .sound-label {
    font-size: 9px;
  }
}
