/* Musical Canvas: Singing Brushes — Stylesheet */

:root {
  --m-bg-dark: #0a0f1d;
  --m-bg-card: rgba(19, 27, 46, 0.88);
  --m-gold: #f59e0b;
  --m-cyan: #06b6d4;
  --m-red: #ef4444;
  --m-purple: #8b5cf6;
  --m-board-w: min(84vw, 780px);
  --m-board-h: min(72vh, 520px);
}

body {
  background: radial-gradient(circle at 50% 30%, #172038 0%, #080c18 100%);
  color: #f8fafc;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

.instruction-banner {
  cursor: pointer;
}

.musical-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  height: calc(100vh - 110px);
  max-height: calc(100vh - 110px);
  padding: 8px 16px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Toolbar */
.music-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--m-bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  z-index: 10;
  max-height: 94%;
  overflow-y: auto;
  scrollbar-width: thin;
}

.toolbar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  margin: 2px 0;
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Singing Brushes Buttons */
.brushes-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brush-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  color: #f8fafc;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

.brush-btn .tool-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.brush-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.brush-btn:active {
  transform: scale(0.94);
}

/* Specific Brush Highlights */
.brush-btn[data-brush="bells"].active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(251, 191, 36, 0.18));
  border-color: #fbbf24;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.45);
}

.brush-btn[data-brush="flute"].active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.28), rgba(59, 130, 246, 0.18));
  border-color: #22d3ee;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.45);
}

.brush-btn[data-brush="drums"].active {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.28), rgba(249, 115, 22, 0.18));
  border-color: #f87171;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.45);
}

.brush-btn[data-brush="harp"].active {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.28), rgba(139, 92, 246, 0.25));
  border-color: #c084fc;
  box-shadow: 0 0 16px rgba(192, 132, 252, 0.45);
}

/* Size Buttons */
.size-section {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 16px;
}

.size-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.size-dot {
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.size-dot.sm { width: 8px; height: 8px; }
.size-dot.md { width: 15px; height: 15px; }
.size-dot.lg { width: 22px; height: 22px; }

.size-btn.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
  transform: scale(1.1);
}

/* Scanner & Tempo Controls */
.scan-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: 2px solid #34d399;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scan-play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.55);
}

.scan-play-btn.playing {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fbbf24;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
  animation: pulse-scan-btn 1.4s infinite ease-in-out;
}

@keyframes pulse-scan-btn {
  0%, 100% { box-shadow: 0 0 14px rgba(245, 158, 11, 0.5); }
  50% { box-shadow: 0 0 26px rgba(251, 191, 36, 0.85); }
}

.tempo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tempo-btn.fast {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fbbf24;
}

/* Action Buttons (Undo, Clear, Save) */
.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  color: #f8fafc;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-2px);
}

.save-btn {
  grid-column: span 2;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-color: #60a5fa;
}

.save-btn:hover {
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.6);
}

/* Center Stage: Musical Canvas Board */
.music-board-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.board-frame {
  position: relative;
  width: var(--m-board-w);
  height: var(--m-board-h);
  background: #060914;
  border-radius: 28px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(99, 102, 241, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  touch-action: none;
}

.art-canvas,
.fx-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.fx-canvas {
  pointer-events: none;
  z-index: 3;
}

/* Vertical Scanner Beam */
.scan-laser {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: #ffffff;
  box-shadow:
    0 0 8px #38bdf8,
    0 0 20px #818cf8,
    0 0 36px #c084fc;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: translateX(-50%);
}

.scan-laser.active {
  opacity: 1;
}

.scan-glow-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 16px #38bdf8, 0 0 28px #818cf8;
}

/* Pitch Guides */
.pitch-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
  box-sizing: border-box;
}

.guide-line {
  position: relative;
  width: 100%;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.guide-badge {
  position: absolute;
  right: 0;
  top: -12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.32);
  letter-spacing: 0.04em;
}

/* Feedback Toast Theme */
.feedback-toast {
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  border: 1px solid var(--m-cyan);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(6, 182, 212, 0.4);
}

/* Responsive Layout */
@media (max-width: 820px) and (orientation: portrait), (max-width: 540px) {
  .musical-field {
    flex-direction: column-reverse;
    gap: 8px;
    height: calc(100vh - 96px);
    max-height: calc(100vh - 96px);
    padding: 4px 8px;
  }

  .music-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 8px;
    max-height: 38vh;
    border-radius: 18px;
  }

  .tool-section {
    flex-direction: row;
    align-items: center;
  }

  .toolbar-divider {
    width: 1px;
    height: 28px;
    margin: 0 2px;
  }

  .brushes-section {
    flex-direction: row;
    gap: 4px;
  }

  .brush-btn {
    min-height: 42px;
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .brush-btn .tool-label {
    display: none;
  }

  .action-buttons {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .save-btn {
    grid-column: span 1;
  }

  :root {
    --m-board-w: 94vw;
    --m-board-h: 52vh;
  }
}

@media (max-width: 520px) {
  .scan-play-btn .tool-label,
  .tempo-btn .tool-label {
    display: none;
  }

  .scan-play-btn,
  .tempo-btn {
    padding: 6px 10px;
    min-height: 42px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --m-board-w: min(70vw, 560px);
    --m-board-h: min(76vh, 320px);
  }

  .musical-field {
    flex-direction: row;
    gap: 8px;
    height: calc(100vh - 84px);
    max-height: calc(100vh - 84px);
    padding: 2px 8px;
  }

  .music-toolbar {
    flex-direction: column;
    padding: 6px;
    gap: 4px;
    max-height: 96%;
  }

  .brush-btn {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 0.78rem;
    gap: 6px;
  }

  .size-section {
    padding: 2px 6px;
  }

  .size-btn {
    width: 30px;
    height: 30px;
  }

  .scan-play-btn {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 0.82rem;
  }

  .tempo-btn {
    min-height: 32px;
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .action-btn {
    min-height: 36px;
    font-size: 1.1rem;
  }
}
