:root {
  --primary: #6a11cb;
  --secondary: #2575fc;
  --background: #1a1a1a;
  --text: #ffffff;
  --grid-line: #444444;
  --inactive: #3a3a3a;
  --active: #ff9500;
  --playing: #2ecc71;
  --selected: #e67e22;
  --accent: #8e44ad;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--background);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem;
}

h1 {
  margin-bottom: 1rem;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 2.5rem;
}

.container {
  width: 100%;
  max-width: 1000px;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

button {
  background: linear-gradient(to right, var(--primary), var(--secondary));
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
}

button:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

button.stop {
  background: #e74c3c;
}

.tempo-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #333;
  padding: 0.5rem;
  border-radius: 4px;
}

label {
  font-weight: bold;
}

input[type="range"] {
  cursor: pointer;
}

.tempo-value {
  min-width: 50px;
  background: #444;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-align: center;
}

.sequencer {
  display: grid;
  grid-template-columns: 100px repeat(16, 1fr);
  gap: 4px;
  margin-bottom: 2rem;
  background: #222;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.sound-name {
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-weight: bold;
  background: #333;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.sound-name:hover {
  background: #444;
}

.step {
  aspect-ratio: 1/1;
  background-color: var(--inactive);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.step:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.step.active {
  background-color: var(--active);
  box-shadow: 0 0 10px var(--active);
}

.step.playing {
  background-color: var(--playing);
  box-shadow: 0 0 10px var(--playing);
}

.row-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 100px repeat(16, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.beat-number {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 0.8rem;
  background: #333;
  border-radius: 4px;
}

.beat-number:first-child {
  background: transparent;
}

.beat-number.quarter {
  background: #444;
}

.instructions {
  background: #333;
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.instructions h3 {
  margin-bottom: 0.5rem;
  color: var(--active);
}

.instructions ul {
  padding-left: 1.5rem;
}

.sound-settings {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.sound-options {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

select {
  padding: 0.5rem;
  border-radius: 4px;
  background: #333;
  color: white;
  border: 1px solid #555;
}

/* Estilos para efectos */
.effects-panel {
  background: #222;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.effects-title {
  margin-bottom: 1rem;
  color: var(--active);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.effects-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.effects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.effect-unit {
  background: #333;
  padding: 1rem;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.effect-unit.disabled {
  opacity: 0.5;
  filter: grayscale(1);
}

.effect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.effect-name {
  font-weight: bold;
  color: var(--secondary);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--active);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.effect-controls {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.control-value {
  font-family: monospace;
  background: #444;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
}

@media (max-width: 768px) {
  .sequencer {
      grid-template-columns: 80px repeat(16, 1fr);
  }
  .row-header {
      grid-template-columns: 80px repeat(16, 1fr);
  }
  .beat-number {
      font-size: 0.7rem;
  }
}

/* Estilos para patrones */
.pattern-controls {
  margin-bottom: 1rem;
  background: #222;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pattern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.pattern-header h3 {
  color: var(--active);
  margin: 0;
}

.pattern-buttons {
  display: flex;
  gap: 0.5rem;
}

.pattern-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.pattern-item {
  background: #333;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pattern-item:hover {
  background: #444;
}

.pattern-item.active {
  background: var(--selected);
  color: white;
  font-weight: bold;
}

/* Estilos para controles ADSR */
.adsr-panel {
  background: #222;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.adsr-title {
  margin-bottom: 1rem;
  color: var(--accent);
}

.adsr-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.adsr-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.adsr-label {
  font-weight: bold;
  font-size: 0.8rem;
  color: var(--secondary);
}

.adsr-slider {
  width: 100%;
}

.adsr-value {
  font-family: monospace;
  background: #444;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* Estilos para visualizador de forma de onda */
.waveform-container {
  background: #222;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  height: 150px;
  position: relative;
}

.waveform-title {
  margin-bottom: 0.5rem;
  color: var(--active);
}

#waveform-canvas {
  width: 100%;
  height: 100px;
  background: #333;
  border-radius: 4px;
}

.time-signature {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.swing-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#swing-value {
  min-width: 40px;
  background: #444;
  padding: 0.25rem;
  border-radius: 4px;
  text-align: center;
  font-size: 0.8rem;
}

@media (max-width: 576px) {
  .sequencer {
      grid-template-columns: 60px repeat(8, 1fr);
  }
  .row-header {
      grid-template-columns: 60px repeat(8, 1fr);
  }
  .beat-number:nth-child(n+10) {
      display: none;
  }
  .step:nth-child(n+10) {
      display: none;
  }
}

/* Estilos para el overlay de orientación */
#orientation-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--background);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
}

#orientation-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.rotate-icon {
  width: 100px;
  height: 100px;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  border-radius: 15px;
  position: relative;
  margin-bottom: 2rem;
  animation: rotate 1.5s infinite ease-in-out;
}

.rotate-icon:before {
  content: "📱";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 50px;
}

.rotate-message {
  font-size: 1.5rem;
  text-align: center;
  max-width: 80%;
  line-height: 1.5;
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}

@media (max-width: 920px) and (orientation: portrait) {
  #orientation-overlay {
      opacity: 1;
      pointer-events: all;
  }
  
  .container {
      opacity: 0;
      pointer-events: none;
  }
}
