html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: Arial, sans-serif;
  text-align: center;
  margin: 0;
  padding: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

header {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 15px;
  border-radius: 0 0 20px 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
}
header h1 {
  margin: 0 0 15px 0;
  font-size: 1.8rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
}
.config-btn {
  padding: 10px 20px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 0.95rem;
  backdrop-filter: blur(5px);
}
.config-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.midi-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(5px);
}
.midi-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #666;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  transition: all 0.3s;
}
.midi-light.connected {
  background-color: #4caf50;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
}
.midi-label {
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
/* Mode Selection */
.mode-selection {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.mode-label {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.mode-buttons {
  display: flex;
  gap: 10px;
}
.mode-btn {
  padding: 10px 20px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 0.95rem;
  backdrop-filter: blur(5px);
}
.mode-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.mode-btn.active {
  background-color: #3a8cf7;
  border-color: #3a8cf7;
  box-shadow: 0 4px 15px rgba(58, 140, 247, 0.5);
}

/* ============================================================
   DIFFICULTY BUTTON STYLES (Beginner/Intermediate/Pro)
   ============================================================ */
.difficulty-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.difficulty-label {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  font-size: 13px;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  width: 100%;
  text-align: center;
  margin-bottom: 4px;
}

/* Base difficulty button styles */
.difficulty-btn {
  padding: 10px 24px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1));
  color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(5px);
}

/* Hover effect for all buttons */
.difficulty-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  border-color: #4A90E2;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.15));
}

/* Active (selected) state - BLUE! */
.difficulty-btn.active {
  background: linear-gradient(to bottom, #5AA2F5, #4A90E2);
  color: #ffffff;
  border-color: #4A90E2;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.6),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  font-weight: 700;
}

/* Active button shimmer effect */
.difficulty-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

.difficulty-btn.active:hover::before {
  left: 100%;
}

/* Click/Active animation */
.difficulty-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Focus state for accessibility */
.difficulty-btn:focus {
  outline: 2px solid #4A90E2;
  outline-offset: 2px;
}

/* Checkmark on active button */
.difficulty-btn.active::after {
  content: '✓';
  margin-left: 8px;
  font-size: 12px;
  opacity: 0.9;
}

/* Level Navigation */
.level-nav-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
  justify-content: center;
}
.level-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 80%;
}
.level-nav::-webkit-scrollbar {
  display: none;
}
.level-nav-arrow {
  flex: 0 0 auto;
  font-size: 1.5rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.level-nav-arrow:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}
.level-nav-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}
.level-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 10px 15px;
  cursor: pointer;
  transition: all 0.3s;
  min-width: 80px;
  white-space: nowrap;
  font-weight: 600;
  backdrop-filter: blur(5px);
}
.level-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.level-btn.active {
  background-color: #3a8cf7;
  border-color: #3a8cf7;
  font-weight: bold;
  box-shadow: 0 4px 15px rgba(58, 140, 247, 0.5);
}
.level-btn.completed {
  background-color: #4caf50;
  border-color: #4caf50;
}
.level-btn.locked {
  background-color: rgba(150, 150, 150, 0.3);
  cursor: not-allowed;
  opacity: 0.5;
  border-color: rgba(100, 100, 100, 0.3);
}
.level-btn.locked:hover {
  background-color: rgba(150, 150, 150, 0.3);
  transform: none;
  box-shadow: none;
}
.trophy {
  margin-left: 8px;
  font-size: 1.2em;
}
/* Level Display */
#level-display {
  margin: 15px 0;
  font-size: 1.3rem;
  font-weight: bold;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
/* Baskets Layout */
.baskets-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  padding: 20px;
  margin: 20px 0;
}
.basket {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  min-width: 180px;
}
.basket-label {
  font-size: 1.4rem;
  font-weight: bold;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  margin-bottom: 10px;
  letter-spacing: 2px;
}
/* Drum Circles */
.drum-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border: 4px solid rgba(255, 255, 255, 0.4);
}
.drum-circle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}
.drum-circle:active {
  transform: scale(0.95);
}
.drum-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.drum-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 10;
}
/* Pattern Display */
.pattern-container {
  margin: 30px auto;
  padding: 20px;
  max-width: 90%;
}
.pattern {
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 15px;
}
/* Music Notation Container - Guitar Hero Style */
.music-notation-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto 20px;
  padding: 15px;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  height: 300px;
}
.notation-scroll-container {
  width: 100%;
  height: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
}
.notation-scroll-container::-webkit-scrollbar {
  display: none;
}
.notation-content {
  display: inline-block;
  height: 200px;
  position: relative;
}
.notation-content svg {
  display: block;
  height: 200px;
}
/* Letters container - scrolls with notation */
.letters-container {
  position: absolute;
  top: 210px;
  left: 0;
  height: 120px;
  pointer-events: none;
}
/* Individual scrolling letters */
.scroll-letter {
  position: absolute;
  font-size: 2rem;
  font-weight: bold;
  color: #333;
  transform: translateX(-50%);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.scroll-letter.past {
  font-size: 1.5rem;
  color: #cccccc;
  opacity: 0.6;
}
.scroll-letter.active {
  font-size: 3.5rem;
  color: #3a8cf7;
  text-shadow: 0 0 15px rgba(58, 140, 247, 0.6);
  transform: translateX(-50%) scale(1.1);
}
.scroll-letter.upcoming {
  font-size: 2rem;
  color: #333;
}
/* Playhead - vertical line that stays fixed */
.playhead {
  position: absolute;
  left: 50%;
  top: 15px;
  width: 3px;
  height: 270px;
  background: linear-gradient(
    to bottom,
    rgba(58, 140, 247, 0) 0%,
    rgba(58, 140, 247, 0.8) 10%,
    rgba(58, 140, 247, 1) 50%,
    rgba(58, 140, 247, 0.8) 90%,
    rgba(58, 140, 247, 0) 100%
  );
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(58, 140, 247, 0.5);
  transform: translateX(-50%);
}
.playhead::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #3a8cf7;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(58, 140, 247, 0.8);
}
.sticking-guide {
  font-size: 0.9rem;
  color: #666;
  margin-top: 10px;
  font-style: italic;
}
@keyframes error-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}
.pattern.error-shake {
  animation: error-shake 0.5s;
}
/* Feedback */
#feedback {
  margin-top: 15px;
  font-size: 1.5rem;
  font-weight: bold;
  min-height: 40px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
#feedback.success {
  color: #4caf50;
}
#feedback.error {
  color: #f44336;
}
#bpm-display {
  margin-top: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}
/* Achievements */
.achievement-display {
  margin: 20px auto;
  padding: 15px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  max-width: 500px;
  backdrop-filter: blur(10px);
}
.achievement-header {
  font-size: 1.3rem;
  font-weight: bold;
  color: white;
  margin-bottom: 10px;
}
.achievement-grid {
  display: flex;
  justify-content: space-around;
  gap: 15px;
  margin: 10px 0;
}
.achievement-item {
  font-size: 1.5rem;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}
.achievement-item span {
  display: block;
  font-size: 0.9rem;
  margin-top: 5px;
  color: white;
}
.achievement-bronze {
  color: #cd7f32;
}
.achievement-silver {
  color: #c0c0c0;
}
.achievement-gold {
  color: #ffd700;
}
.current-achievement {
  margin-top: 15px;
  font-size: 1.2rem;
  color: white;
  font-weight: bold;
}
.achievement-icon {
  font-size: 2.5rem;
  margin-top: 10px;
}
.achievement-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 20px auto;
  max-width: 500px;
}
.achievement-actions .action-btn {
  padding: 12px 24px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 0.95rem;
  backdrop-filter: blur(5px);
}
.achievement-actions .action-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.achievement-actions .action-btn.danger {
  border-color: rgba(244, 67, 54, 0.5);
}
.achievement-actions .action-btn.danger:hover {
  background-color: rgba(244, 67, 54, 0.3);
  border-color: rgba(244, 67, 54, 0.8);
}
/* Level Notification */
.level-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(76, 175, 80, 0.95);
  color: white;
  padding: 30px 40px;
  border-radius: 20px;
  font-size: 1.3rem;
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  max-width: 80%;
}
.level-notification.show {
  opacity: 1;
}
/* Controls Info */
.controls-info {
  margin: 30px auto 20px;
  padding: 15px 25px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  font-size: 1rem;
  display: inline-block;
  color: white;
  backdrop-filter: blur(10px);
}
.controls-info p {
  margin: 5px 0;
}
.key {
  display: inline-block;
  padding: 4px 10px;
  margin: 0 4px;
  background-color: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  font-family: monospace;
  font-weight: bold;
  color: white;
}
/* ========================================
   MIDI CONFIGURATION PANEL
   ======================================== */
.config-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
  z-index: 1998;
}
.config-overlay.show {
  opacity: 1;
  visibility: visible;
}
.midi-config-panel {
  position: fixed;
  top: 0;
  right: -450px;
  width: 450px;
  max-width: 90vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
  z-index: 1999;
  transition: right 0.3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.midi-config-panel.show {
  right: 0;
}
.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.3);
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}
.config-header h2 {
  margin: 0;
  color: white;
  font-size: 1.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.close-btn {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.close-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}
.config-content {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}
.midi-device-info {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  backdrop-filter: blur(5px);
}
.midi-device-info h3 {
  margin: 0 0 10px 0;
  color: white;
  font-size: 1.1rem;
}
#midi-device-name {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  font-style: italic;
}
.config-section {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  backdrop-filter: blur(5px);
}
.config-section h3 {
  margin: 0 0 5px 0;
  color: white;
  font-size: 1.1rem;
}
.config-note {
  margin: 0 0 15px 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  font-style: italic;
}
.midi-mapping-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}
.mapping-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mapping-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 8px;
}
.arrow-symbol {
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.2rem;
  font-weight: bold;
  min-width: 20px;
}
.mapping-label {
  color: white;
  font-weight: bold;
  font-size: 1rem;
  min-width: 35px;
}
.learn-btn {
  padding: 8px 15px;
  background-color: rgba(58, 140, 247, 0.8);
  color: white;
  border: 2px solid rgba(58, 140, 247, 1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 70px;
}
.learn-btn:hover {
  background-color: rgba(58, 140, 247, 1);
  transform: translateY(-2px);
}
.learn-btn.learning {
  background-color: #ff9800;
  border-color: #ff9800;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}
.mapping-display {
  flex: 1;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  padding: 5px 10px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.mapping-display.mapped {
  color: #4caf50;
  font-weight: bold;
}
.sound-select {
  flex: 1;
  min-width: 150px;
  padding: 6px 10px;
  background-color: rgba(255, 255, 255, 0.9);
  color: #333;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}
.sound-select:hover {
  background-color: rgba(255, 255, 255, 1);
  border-color: #3a8cf7;
}
.sound-select:focus {
  outline: none;
  border-color: #3a8cf7;
  box-shadow: 0 0 5px rgba(58, 140, 247, 0.5);
}
.test-sound-btn {
  padding: 6px 12px;
  background-color: rgba(76, 175, 80, 0.7);
  color: white;
  border: 1px solid rgba(76, 175, 80, 1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1rem;
  min-width: 40px;
}
.test-sound-btn:hover {
  background-color: rgba(76, 175, 80, 0.9);
  transform: scale(1.1);
}
.test-sound-btn:active {
  transform: scale(0.95);
}
.clear-btn {
  padding: 6px 12px;
  background-color: rgba(244, 67, 54, 0.7);
  color: white;
  border: 1px solid rgba(244, 67, 54, 1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.8rem;
}
.clear-btn:hover {
  background-color: rgba(244, 67, 54, 0.9);
}
.config-status {
  margin: 15px 0;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
  min-height: 20px;
}
.config-status.success {
  background-color: rgba(76, 175, 80, 0.3);
  color: #4caf50;
  border: 2px solid rgba(76, 175, 80, 0.5);
}
.config-status.error {
  background-color: rgba(244, 67, 54, 0.3);
  color: #f44336;
  border: 2px solid rgba(244, 67, 54, 0.5);
}
.config-status.warning {
  background-color: rgba(255, 152, 0, 0.3);
  color: #ff9800;
  border: 2px solid rgba(255, 152, 0, 0.5);
}
.config-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.action-btn {
  flex: 1;
  padding: 12px 20px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 0.95rem;
}
.action-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}
.action-btn.primary {
  background-color: #4caf50;
  border-color: #4caf50;
}
.action-btn.primary:hover {
  background-color: #45a049;
}

/* ============================================================
   METRONOME MODE
   ============================================================ */

/* ── Top-level selector (No Metronome / Metronome Mode) ────── */
.metronome-mode-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
}

/* PLAY header label */
.play-header {
  font-size: 1.05rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Small persistent beat indicator */
.metro-beat-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
}

.metro-beat-label {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.metro-beat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background 0.04s, box-shadow 0.04s;
}

.metro-beat-dot.beat {
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.95);
  animation: dot-fade 0.18s ease-out forwards;
}

.metro-beat-dot.accent {
  background: #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.95);
  animation: dot-fade 0.18s ease-out forwards;
}

@keyframes dot-fade {
  0%   { opacity: 1; }
  100% { opacity: 0.25; }
}

/* ── Mini beep/flash type toggle buttons ──────────────────── */
.metro-type-mini {
  display: flex;
  gap: 3px;
  align-items: center;
  margin-left: 6px;
}

.metro-type-mini-btn {
  padding: 2px 6px;
  font-size: 0.72rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.metro-type-mini-btn.active {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.5);
  color: #fff;
}

.metro-type-mini-btn:hover:not(.active) {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.85);
}

.metronome-mode-btn {
  padding: 8px 20px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(5px);
}

.metronome-mode-btn.active {
  background: #2196F3;
  border-color: #2196F3;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(33, 150, 243, 0.5);
}

.metronome-mode-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* ── Metronome sub-panel ──────────────────────────────────── */
.metronome-sub-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 12px;
}

/* "Choose Your Speed" section heading */
.metro-speed-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-align: center;
  margin-bottom: 10px;
}

/* ── Settings rows ─────────────────────────────────────────── */
.metro-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metro-bpm-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metro-bpm-label {
  min-width: 76px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.metro-bpm-row label {
  min-width: 80px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
}

.metro-slider {
  flex: 1;
  accent-color: #2196F3;
  cursor: pointer;
}

.metro-type-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.metro-type-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.metro-type-opt {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.metro-start-btn {
  align-self: center;
  padding: 10px 36px;
  border-radius: 22px;
  border: 2px solid #2e7d32;
  background: #4CAF50;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.55);
}

.metro-start-btn:hover {
  background: #43a047;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.7);
  transform: translateY(-1px);
}

.metro-start-btn.running {
  border-color: #f44336;
  color: #f44336;
}

.metro-start-btn.running:hover {
  background: #f44336;
  color: #fff;
}

/* ── Centre-line indicator ─────────────────────────────────── */
.metronome-center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: transparent;
  pointer-events: none;
  border-radius: 2px;
  z-index: 10;
}

@keyframes beatFlash {
  0%   { background: rgba(33, 150, 243, 0.9); }
  100% { background: rgba(33, 150, 243, 0);   }
}

@keyframes accentFlash {
  0%   { background: rgba(255, 165, 0, 1);  }
  100% { background: rgba(255, 165, 0, 0);  }
}

.metronome-center-line.beat-flash {
  animation: beatFlash 0.18s ease-out forwards;
}

.metronome-center-line.accent-flash {
  animation: accentFlash 0.18s ease-out forwards;
}

/* ── Hit result flashes (correct green / error red) ─────────── */
@keyframes hitCorrect {
  0%   { background: #4CAF50; box-shadow: 0 0 12px 2px rgba(76,175,80,0.85); }
  100% { background: transparent; box-shadow: none; }
}
@keyframes hitCorrectAccent {
  0%   { background: #00e676; box-shadow: 0 0 28px 6px rgba(0,230,118,1), 0 0 50px 12px rgba(0,230,118,0.5); }
  100% { background: transparent; box-shadow: none; }
}
@keyframes hitError {
  0%   { background: #f44336; box-shadow: 0 0 12px 2px rgba(244,67,54,0.85); }
  100% { background: transparent; box-shadow: none; }
}

.metronome-center-line.hit-correct {
  animation: hitCorrect 0.32s ease-out forwards;
}
.metronome-center-line.hit-correct-accent {
  width: 5px;
  animation: hitCorrectAccent 0.38s ease-out forwards;
}
.metronome-center-line.hit-error {
  animation: hitError 0.32s ease-out forwards;
}
.metronome-center-line.hit-error-accent {
  animation: hitError 0.32s ease-out forwards;
}

/* Notation wrapper flash */
@keyframes notationFlash {
  0%   { background-color: rgba(33, 150, 243, 0.12); }
  100% { background-color: transparent; }
}

@keyframes notationFlashAccent {
  0%   { background-color: rgba(255, 165, 0, 0.18); }
  100% { background-color: transparent; }
}

.music-notation-wrapper.metro-flash {
  animation: notationFlash 0.2s ease-out forwards;
}

.music-notation-wrapper.metro-flash-accent {
  animation: notationFlashAccent 0.2s ease-out forwards;
}

/* ── Count-in display ──────────────────────────────────────── */
.metro-count-in {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px rgba(33, 150, 243, 0.8);
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  user-select: none;
}

.metro-count-in.show {
  opacity: 1;
}

@keyframes countInPop {
  0%   { transform: translate(-50%, -50%) scale(1.6); opacity: 1; }
  60%  { transform: translate(-50%, -50%) scale(0.95); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1);    opacity: 0.7; }
}

.metro-count-in.pop {
  animation: countInPop 0.25s ease-out forwards;
}

/* ── Start button wrap (sits just above the pattern) ────────── */
.metro-start-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

/* ── Medal buttons (challenge mode) ─────────────────────────── */
.metro-medal-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.metro-medal-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.4;
  min-width: 80px;
}

.metro-medal-btn small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  opacity: 0.8;
}

.metro-medal-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.metro-medal-btn[data-medal="bronze"].active   { background: rgba(205, 127,  50, 0.35); border-color: #cd7f32; }
.metro-medal-btn[data-medal="silver"].active   { background: rgba(192, 192, 192, 0.35); border-color: #c0c0c0; }
.metro-medal-btn[data-medal="gold"].active     { background: rgba(255, 215,   0, 0.35); border-color: #ffd700; }
.metro-medal-btn[data-medal="platinum"].active { background: rgba(100, 200, 255, 0.35); border-color: #64c8ff; }

@media (max-width: 480px) {
  .metro-medal-btn {
    min-width: 64px;
    padding: 8px 8px;
    font-size: 0.78rem;
  }
}

/* ── Completion stats card (slides in over the notation) ────── */
.metro-stats-card {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 18, 30, 0.97);
  transform: translateX(100%);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 30;
  border-radius: inherit;
}

.metro-stats-card.slide-in {
  transform: translateX(0);
}

.metro-stats-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 32px;
}

.metro-stats-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.metro-stats-row {
  display: flex;
  gap: 16px;
  align-items: baseline;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
}

.metro-stats-row strong {
  font-size: 1.15rem;
  color: #fff;
}

.metro-stats-btn {
  margin-top: 8px;
  padding: 9px 28px;
  border-radius: 20px;
  border: 2px solid #4CAF50;
  background: transparent;
  color: #4CAF50;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.metro-stats-btn:hover {
  background: #4CAF50;
  color: #000;
}

.metro-stats-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.metro-stats-btn-next {
  border-color: #2196F3;
  color: #2196F3;
}

.metro-stats-btn-next:hover {
  background: #2196F3;
  color: #fff;
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ======================================== */
/* Small phones (portrait) - up to 480px */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  header h1 {
    font-size: 1.3rem;
  }

  .level-btn {
    min-width: 60px;
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .baskets-row {
    gap: 20px;
    padding: 15px 10px;
  }

  .basket {
    min-width: 140px;
    padding: 15px;
    gap: 12px;
  }

  .basket-label {
    font-size: 1.1rem;
  }

  .drum-circle {
    width: 70px;
    height: 70px;
  }

  .pattern {
    padding: 15px;
  }

  .music-notation-wrapper {
    height: 250px;
    padding: 10px;
  }

  .letters-container {
    top: 180px;
  }

  .scroll-letter {
    font-size: 1.5rem;
  }

  .scroll-letter.past {
    font-size: 1.2rem;
  }

  .scroll-letter.active {
    font-size: 2.5rem;
  }

  .scroll-letter.upcoming {
    font-size: 1.5rem;
  }

  .playhead {
    height: 220px;
  }

  #feedback {
    font-size: 1.2rem;
  }

  #level-display {
    font-size: 1rem;
  }

  .achievement-display {
    padding: 12px;
  }

  .achievement-grid {
    gap: 10px;
  }

  .achievement-item {
    font-size: 1.2rem;
    padding: 8px;
  }

  .controls-info {
    font-size: 0.85rem;
    padding: 12px 18px;
  }

  .mode-label {
    font-size: 0.85rem;
  }

  .mode-btn {
    padding: 8px 15px;
    font-size: 0.85rem;
  }

  .difficulty-container {
    gap: 8px;
    padding: 12px;
  }

  .difficulty-label {
    width: 100%;
    text-align: center;
    margin-bottom: 5px;
    font-size: 0.8rem;
  }

  .difficulty-btn {
    padding: 8px 18px;
    font-size: 14px;
  }

  .header-controls {
    flex-direction: column;
    gap: 8px;
  }

  .config-btn {
    padding: 8px 15px;
    font-size: 0.85rem;
  }

  .midi-config-panel {
    width: 100%;
    max-width: 100vw;
  }

  .config-header h2 {
    font-size: 1.2rem;
  }

  .midi-mapping-row {
    flex-wrap: wrap;
  }

  .mapping-display {
    flex: 1 1 100%;
    margin-top: 5px;
  }
}
/* Medium phones & small tablets (portrait) - 481px to 768px */
@media (min-width: 481px) and (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }

  .baskets-row {
    gap: 30px;
  }

  .basket {
    min-width: 160px;
    padding: 18px;
  }

  .drum-circle {
    width: 85px;
    height: 85px;
  }

  .scroll-letter {
    font-size: 1.8rem;
  }

  .scroll-letter.active {
    font-size: 3rem;
  }
}
/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
  header {
    padding: 10px;
    margin-bottom: 10px;
  }

  header h1 {
    font-size: 1.2rem;
    margin-bottom: 8px;
  }

  #level-display {
    font-size: 1rem;
    margin: 10px 0;
  }

  .baskets-row {
    margin: 10px 0;
    padding: 10px;
    gap: 25px;
  }

  .basket {
    padding: 12px;
    gap: 10px;
  }

  .drum-circle {
    width: 70px;
    height: 70px;
  }

  .pattern {
    padding: 12px;
  }

  .music-notation-wrapper {
    height: 220px;
    padding: 10px;
  }

  .letters-container {
    top: 150px;
  }

  .scroll-letter {
    font-size: 1.3rem;
  }

  .scroll-letter.active {
    font-size: 2.2rem;
  }

  .pattern-container {
    margin: 15px auto;
  }

  .achievement-display {
    padding: 10px;
    margin: 15px auto;
  }

  .controls-info {
    font-size: 0.8rem;
    padding: 8px 15px;
    margin: 15px auto 10px;
  }

  .mode-selection {
    margin-top: 8px;
    gap: 5px;
  }

  .mode-label {
    font-size: 0.85rem;
  }

  .mode-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}
/* Very small screens */
@media (max-width: 360px) {
  .baskets-row {
    gap: 15px;
    padding: 10px 5px;
  }

  .basket {
    min-width: 120px;
    padding: 12px;
  }

  .basket-label {
    font-size: 1rem;
  }

  .drum-circle {
    width: 60px;
    height: 60px;
  }

  .pattern {
    padding: 12px;
  }

  .music-notation-wrapper {
    height: 220px;
    padding: 8px;
  }

  .letters-container {
    top: 150px;
  }

  .scroll-letter {
    font-size: 1.2rem;
  }

  .scroll-letter.past {
    font-size: 1rem;
  }

  .scroll-letter.active {
    font-size: 2.2rem;
  }

  .scroll-letter.upcoming {
    font-size: 1.2rem;
  }
}
/* Large screens / Desktop */
@media (min-width: 1025px) {
  .baskets-row {
    gap: 60px;
  }

  .basket {
    min-width: 200px;
    padding: 25px;
  }

  .drum-circle {
    width: 110px;
    height: 110px;
  }
}
/* Ultra-wide screens */
@media (min-width: 1600px) {
  body {
    font-size: 18px;
  }

  .baskets-row {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
  }

  .pattern-container {
    max-width: 1200px;
  }
}

/* ── Accent feedback hint (MIDI velocity messages) ──────────── */
.accent-hint {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9999;
  white-space: nowrap;
}
.accent-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.accent-hint--good {
  background: rgba(0, 230, 118, 0.18);
  border: 1.5px solid #00e676;
  color: #00e676;
  box-shadow: 0 0 16px 2px rgba(0, 230, 118, 0.35);
}
.accent-hint--missed {
  background: rgba(255, 87, 34, 0.15);
  border: 1.5px solid #ff5722;
  color: #ff8a65;
  box-shadow: 0 0 12px 2px rgba(255, 87, 34, 0.25);
}
