/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #1b2530 0%, #051625 100%);
  min-height: 100vh;
  color: #333;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Controls Section */
#controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  background: linear-gradient(45deg, rgba(30, 30, 30, 0.95) 0%, rgb(20, 21, 21) 100%);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  margin-bottom: 30px;
  flex-wrap: wrap;
  border: 1px solid #444;
}

/* Buttons */
.btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:hover {
  transform: scale(1.05);
  background: linear-gradient(45deg, #5a6fd8, #6b4a9c);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn:active {
  transform: translateY(0);
}

#play {
  background: transparent;
  color: green;
  border: 2px solid rgb(4, 103, 4);
}

#play:hover {
  background: linear-gradient(45deg, #429745, #2b672e);
  color: white;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

#clearBtn {
  background: transparent;
  color: #f44336;
  border: 2px solid #f44336;
}

#clearBtn:hover {
  background: linear-gradient(45deg, #f44336, #863434);
  color: white;
  box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

#randomBtn {
  background: transparent;
  color: purple;
  border: 2px solid purple;
}

#randomBtn:hover {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Form Elements */
label {
  font-weight: 600;
  color: #ccc;
  font-size: 14px;
}

.tempo-input {
  border: 2px solid #555;
  border-radius: 6px;
  font-size: 14px;
  width: 200px;
  text-align: center;
  transition: border-color 0.3s ease;
  background: #222;
  color: #fff;
}

.tempo-value {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
  min-width: 40px;
  text-align: center;
  background: transparent;
  padding: 4px 8px;
  border-radius: 4px;
}

.wave-select {
  padding: 8px 12px;
  border: 2px solid #555;
  border-radius: 6px;
  font-size: 14px;
  background: #222;
  color: #fff;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.wave-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Dividers */
.divider {
  color: #888;
  font-weight: bold;
  font-size: 18px;
}

/* Grid Container - Darker */
.grid {
  background: linear-gradient(45deg, rgba(30, 30, 30, 0.95) 0%, rgb(20, 21, 21) 100%);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border: 1px solid #333;
}

/* Grid Layout */
.grid-layout {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 10px;
  min-height: 400px;
}

/* Left Labels Side */
.left-labels-side {
  display: grid;
  grid-template-rows: 40px 1fr;
  gap: 10px;
}

/* Ruler Spacer */
.ruler-spacer {
  background: rgba(40, 40, 40, 0.8);
  border-radius: 4px;
  border: 1px solid #444;
}

/* Row Labels Container */
.row-labels {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
}

/* Individual Row Label */
.row-label {
  background: rgba(50, 50, 50, 0.9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #555;
  min-height: 40px;
}

/* Grid Lines Container */
.grid-lines {
  display: grid;
  grid-template-rows: 40px 1fr;
  gap: 10px;
}

/* Ruler Styles */
.ruler {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 6px;
  background: rgba(25, 25, 25, 0.9);
}

.ruler-cell {
  background: rgba(45, 45, 45, 0.9);
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid #555;
  min-height: 24px;
  transition: all 0.2s ease;
}

.ruler-cell.beat {
  background: rgba(102, 126, 234, 0.3);
  color: #fff;
  border-color: #667eea;
  font-weight: 700;
}

.ruler-cell:hover {
  background: rgba(60, 60, 60, 0.9);
  border-color: #777;
}

.ruler-cell.beat:hover {
  background: rgba(102, 126, 234, 0.5);
  border-color: #667eea;
}

/* Grid Cells Container */
.grid-cells {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  background: rgba(15, 15, 15, 0.9);
  border-radius: 6px;
}

.grid-cell {
  background: rgba(60, 60, 60, 0.8);
  border: 1px solid #666;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
  position: relative;
}

.grid-cell:hover {
  background: rgba(80, 80, 80, 0.9);
  border-color: #888;
  transform: scale(1.02);
}

.grid-cell.active {
  background: linear-gradient(45deg, #667eea, #764ba2);
  border-color: #667eea;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.grid-cell.playing {
  animation: pulse 0.3s ease-in-out;
}

/* Beat columns highlighting - Dynamic */
.grid-cell.beat-column {
  border-right: 3px solid #667eea;
}

/* Highlighted cells - New */
.grid-cell.highlight {
    border: 3px solid #764ba2 !important;
}

.ruler-cell.highlight {
    border: 3px solid #764ba2 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .title {
    font-size: 2rem;
  }
  
  #controls {
    flex-direction: column;
    gap: 10px;
  }
  
  .grid-layout {
    grid-template-columns: 50px 1fr;
  }
  
  .row-label {
    font-size: 10px;
    min-height: 30px;
  }
  
  .grid-cells {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(16, 1fr);
    gap: 2px;
    padding: 6px;
  }
  
  .grid-cell {
    min-height: 30px;
  }
  
  .ruler {
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 6px;
  }
  
  .ruler-cell {
    font-size: 10px;
    min-height: 20px;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 1.5rem;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 12px;
  }
  
  .grid-layout {
    grid-template-columns: 40px 1fr;
  }
  
  .grid-cells {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(32, 1fr);
  }
  
  .ruler {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .grid-cell {
    min-height: 25px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus indicators for keyboard navigation */
.btn:focus,
.tempo-input:focus,
.wave-select:focus,
.grid-cell:focus {
  outline: 3px solid #667eea;
  outline-offset: 2px;
}