/* ==========================================================================
   PARTITURA: MAESTRO QUEST - ZERO-SCROLL DAW STUDIO SYSTEM
   ========================================================================== */

:root {
  --bg-dark-primary: #07030c;
  --bg-dark-secondary: #0f0819;
  --bg-glass: rgba(22, 12, 38, 0.85);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(139, 92, 246, 0.45);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --neon-indigo: #8b5cf6;
  --neon-amethyst: #a855f7;
  --neon-pink: #ec4899;
  --neon-cyan: #22d3ee;
  --neon-emerald: #10b981;
  --neon-amber: #fbbf24;
  --neon-red: #f43f5e;
  
  --shadow-glass: 0 10px 30px rgba(0, 0, 0, 0.65);
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

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

body {
  background: radial-gradient(circle at 50% 0%, #1e0e3b 0%, var(--bg-dark-primary) 80%);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  padding: 0;
  /* Evita rolagem desnecessária no desktop cortando espaços excessivos */
}

.maestro-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0.3rem 1rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Otimização de Header e Footer do site compartilhados */
.compact-header {
  margin-bottom: 0 !important;
  padding-bottom: 0.3rem !important;
}
.compact-footer {
  margin-top: 0.4rem !important;
  padding: 0.4rem 0 !important;
  font-size: 0.8rem;
}

.logo-icon {
  color: var(--neon-amber);
  filter: drop-shadow(0 0 6px var(--neon-amber));
  animation: floatClef 3s ease-in-out infinite;
}
@keyframes floatClef { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ==========================================================================
   1. HUD ULTRA-COMPACTA (BARRA ÚNICA NO TOPO)
   ========================================================================== */
.hud-strip {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  position: relative;
}

/* Fio LED na borda superior */
.hud-strip::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--neon-indigo), var(--neon-cyan), var(--neon-amber), var(--neon-pink));
  border-radius: 14px 14px 0 0;
}

.hud-left-rank {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.avatar-mini {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--neon-indigo), #3b82f6);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.6);
}

.level-title-mini { font-weight: 800; font-size: 0.95rem; color: #fff; }

.xp-bar-mini {
  width: 150px; height: 16px;
  background: rgba(0,0,0,0.6);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.xp-bar-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: linear-gradient(90deg, #6366f1, var(--neon-cyan));
  border-radius: 8px;
  transition: width 0.5s ease;
}

.xp-text-mini {
  position: relative; z-index: 2; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000;
}

.hud-right-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill-mini {
  background: rgba(10, 5, 20, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 0.3rem 0.65rem;
  font-size: 0.84rem;
  display: flex; align-items: center; gap: 0.35rem;
}

.pill-mini strong { font-family: var(--font-mono); color: #fff; font-size: 0.9rem; }

.combo-pill.active {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(15, 8, 26, 0.9));
  border-color: var(--neon-amber);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
}

.btn-trophies-mini {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  border-radius: 10px;
  padding: 0.35rem 0.8rem;
  color: #fff; font-weight: 800; font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
  transition: transform 0.2s;
}
.btn-trophies-mini:hover { transform: scale(1.05); }

/* ==========================================================================
   2. DECK DE CONTROLE DE MODOS & MÓDULO SONORO (ECONOMIA VERTICAL)
   ========================================================================== */
.control-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: rgba(15, 8, 28, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 0.5rem 0.8rem;
}

.mode-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: rgba(28, 16, 48, 0.6);
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover { color: #fff; background: rgba(45, 25, 75, 0.8); }
.tab-btn.active {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45);
}

.deck-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.neon-select.compact-sel {
  background: #170b2c;
  color: #f8fafc;
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  min-height: var(--touch-target);
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
}
.clef-selector { border-color: var(--neon-amber); }

.toggle-btn-mini {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid var(--neon-indigo);
  color: #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-btn-mini:hover { background: rgba(139, 92, 246, 0.4); }

.guide-toggle { background: rgba(16, 185, 129, 0.2); border-color: var(--neon-emerald); }
.guide-toggle:hover, .guide-toggle.active-guide { background: rgba(16, 185, 129, 0.45); box-shadow: 0 0 12px rgba(16,185,129,0.5); }

/* --- TOOLBARS COMPACTAS DOS MODOS --- */
.compact-toolbar {
  background: rgba(20, 10, 36, 0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 0.5rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.scale-selector-row { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.scale-picker { flex: 1; min-width: 200px; }
.scale-direction-btns { display: flex; gap: 0.4rem; }
.theory-card-mini { font-size: 0.82rem; color: #cbd5e1; background: rgba(255,255,255,0.03); padding: 0.35rem 0.7rem; border-left: 3px solid var(--neon-amber); border-radius: 4px; }
.arcade-hud-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.timer-digits { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 800; color: var(--neon-cyan); }

.action-btn-mini {
  background: var(--neon-emerald); color: #000; border: none; border-radius: 8px; padding: 0.4rem 0.9rem; font-weight: 800; font-size: 0.85rem; cursor: pointer; box-shadow: 0 2px 10px rgba(16,185,129,0.4);
}
.glow-btn-alt { background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff; }
.pulse-btn { background: linear-gradient(135deg, var(--neon-cyan), #0284c7); color: #fff; }

.hidden { display: none !important; }

/* ==========================================================================
   3. ÁREA DE TRABALHO STUDIO WORKSPACE (PARTITURA + TECLADO AO VIVO)
   ========================================================================== */
/* Itens de flex têm `min-width: auto` por padrão, ou seja, não encolhem abaixo do próprio
   conteúdo. Como a pauta é um SVG de 680px, essa cadeia inteira travava em ~750px e estourava
   a tela no celular. Zerar o min-width em cada nível é o que libera o encolhimento. */
.studio-workspace {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  max-width: 100%;
}

.staff-display-card {
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 16px;
  padding: 0.75rem 1.1rem;
  box-shadow: var(--shadow-glass);
  transition: all 0.4s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.staff-display-card.mode-bass-clef {
  border-color: rgba(168, 85, 247, 0.55);
  background: linear-gradient(160deg, rgba(32, 14, 52, 0.9), rgba(15, 7, 26, 0.95));
}
.staff-display-card.mode-treble-clef {
  border-color: rgba(34, 211, 238, 0.45);
}

.staff-header-mini {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.staff-header-mini > * {
  min-width: 0;
}

.clef-badge {
  font-weight: 800; font-size: 0.78rem; padding: 0.25rem 0.7rem; border-radius: 8px; text-transform: uppercase;
}
.treble-badge { background: linear-gradient(135deg, #0284c7, var(--neon-cyan)); color: #fff; }
.bass-badge { background: linear-gradient(135deg, #7c3aed, var(--neon-amethyst)); color: #fff; }

.instruction-span { font-size: 0.88rem; font-weight: 700; color: var(--text-muted); }

.staff-svg-wrapper {
  background: #080311;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem;
  display: flex; justify-content: center;
  box-shadow: inset 0 4px 15px rgba(0,0,0,0.8);
  min-width: 0;
  max-width: 100%;
}

#staff-canvas {
  width: 100%;
  min-width: 0;
  max-width: 680px;
  height: auto;
  max-height: 155px; /* Altura cirúrgica para evitar scroll vertical! */
  overflow: visible;
}

.feedback-bar-integrated {
  background: rgba(10, 5, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 700; font-size: 0.96rem;
  transition: all 0.25s;
}

.feedback-bar-integrated.success { background: rgba(16, 185, 129, 0.18); color: #34d399; border-color: rgba(16,185,129,0.5); }
.feedback-bar-integrated.error { background: rgba(244, 63, 94, 0.18); color: #fb7185; border-color: rgba(244,63,94,0.5); }
.feedback-bar-integrated.feedback-pop { animation: feedbackPop 0.42s ease; }
@keyframes feedbackPop {
  0% { transform: scale(0.96); filter: brightness(1.2); }
  55% { transform: scale(1.03); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Brilho estático na pauta — sem scale/translate (confunde leitura de linha/espaço) */
.clef-mark { filter: drop-shadow(0 0 8px var(--neon-cyan)); }
.mode-bass-clef .clef-mark { filter: drop-shadow(0 0 10px var(--neon-amethyst)); }

.note-glow { filter: drop-shadow(0 0 10px var(--neon-cyan)); }
.mode-bass-clef .note-glow { filter: drop-shadow(0 0 12px var(--neon-amethyst)); }

/* Feedback de acerto: só intensifica o glow, sem mexer a posição da nota */
.note-hit-anim { animation: noteHitFlash 0.55s ease; }
@keyframes noteHitFlash {
  0%, 100% { filter: drop-shadow(0 0 10px var(--neon-cyan)); opacity: 1; }
  35% { filter: drop-shadow(0 0 28px var(--neon-emerald)) drop-shadow(0 0 12px #fff); opacity: 1; }
  70% { filter: drop-shadow(0 0 18px var(--neon-emerald)); }
}

.staff-shake { animation: staffShake 0.4s ease; }
@keyframes staffShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ==========================================================================
   4. CONSOLE DE SYNTH & TECLADO VIRTUAL DE ALTA DENSIDADE
   ========================================================================== */
.synth-console {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.trigger-pads-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}
@media (max-width: 620px) { .trigger-pads-row { grid-template-columns: repeat(4, 1fr); } }

.trigger-pad {
  background: rgba(25, 14, 44, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 0.45rem 0.3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: all 0.18s;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}
.pad-names { font-size: 0.95rem; }
.note-name { font-weight: 800; }
.note-cifra { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-muted); }
.note-octave-hint { font-size: 0.68rem; margin-top: 2px; font-weight: 700; color: var(--neon-cyan); }

.trigger-pad:hover, .trigger-pad.active-hit {
  transform: translateY(-2px);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 16px var(--neon-cyan);
  background: rgba(34, 211, 238, 0.2);
}

.trigger-pad.active-hit {
  animation: padHitFlash 0.35s ease;
}
@keyframes padHitFlash {
  0% { transform: scale(0.94) translateY(0); filter: brightness(1.35); }
  100% { transform: translateY(-2px); filter: brightness(1); }
}

.virtual-keyboard-deck {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 0.65rem 1rem 0.8rem 1rem;
  box-shadow: var(--shadow-glass);
}

.keyboard-top-info {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.zone-badges-group { display: flex; gap: 0.5rem; }
.zone-badge { font-size: 0.75rem; padding: 0.2rem 0.55rem; border-radius: 6px; font-weight: 700; opacity: 0.5; }
.left-hand-zone { background: rgba(168, 85, 247, 0.2); color: var(--neon-amethyst); border: 1px solid rgba(168, 85, 247, 0.4); }
.right-hand-zone { background: rgba(34, 211, 238, 0.2); color: var(--neon-cyan); border: 1px solid rgba(34, 211, 238, 0.4); }
.zone-badge.active-zone { opacity: 1; transform: scale(1.05); box-shadow: 0 0 8px currentColor; }

.kb-shortcut-hint { font-size: 0.78rem; color: var(--neon-amber); }

.piano-wrapper-compact {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.piano-keyboard {
  display: flex;
  position: relative;
  height: 126px; /* Altura perfeitamente otimizada! */
  background: #06020c;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 4px;
  box-shadow: inset 0 3px 10px #000, 0 6px 20px rgba(0,0,0,0.6);
  user-select: none;
}

.white-key {
  width: 37px;
  height: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 82%, #cbd5e1 100%);
  border: 1px solid #64748b;
  border-radius: 0 0 7px 7px;
  position: relative;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding-bottom: 6px;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 800; color: #1e293b;
  z-index: 1; transition: background 0.08s, transform 0.05s;
}

.white-key:hover { background: #f1f5f9; }
.white-key.active-key {
  background: linear-gradient(180deg, var(--neon-cyan) 0%, #0284c7 100%);
  color: #fff; transform: translateY(3px); box-shadow: 0 0 16px var(--neon-cyan);
}

.mode-bass-clef .white-key.active-key {
  background: linear-gradient(180deg, var(--neon-amethyst) 0%, #7c3aed 100%);
  box-shadow: 0 0 16px var(--neon-amethyst);
}

.black-key {
  width: 22px; height: 62%;
  background: linear-gradient(180deg, #1e293b 0%, #090e1a 100%);
  border: 1px solid #020617; border-radius: 0 0 5px 5px;
  position: absolute; top: 4px; z-index: 2; cursor: pointer;
  box-shadow: 2px 4px 6px rgba(0,0,0,0.7);
}

.black-key.active-key {
  background: linear-gradient(180deg, var(--neon-pink) 0%, #be185d 100%);
  transform: translateY(2px); box-shadow: 0 0 15px var(--neon-pink);
}

.white-key[data-pitch="C4"] {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 85%, #f59e0b 100%);
  color: #92400e; border-color: #d97706;
}

/* --- MODAL E TOASTS --- */
.modal-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(4, 2, 10, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 1rem;
}
.glass-modal { background: #120920; border: 1px solid rgba(255,255,255,0.2); border-radius: 20px; width: 100%; max-width: 600px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.85); }
.modal-header { padding: 1.1rem 1.4rem; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 1.25rem; color: var(--neon-amber); }
.close-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 1.3rem; overflow-y: auto; flex: 1; }
.modal-desc { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.1rem; }
.stats-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; margin-bottom: 1.3rem; }
.stat-box { background: rgba(6, 3, 13, 0.8); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 0.7rem; text-align: center; }
.box-num { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 800; color: var(--neon-cyan); display: block; }
.box-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.8rem; }
.badge-card { background: rgba(22, 13, 38, 0.7); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 0.85rem; display: flex; align-items: center; gap: 0.9rem; }
.badge-card.unlocked { border-color: rgba(251,191,36,0.6); background: rgba(36,20,60,0.9); }
.badge-card.locked { opacity: 0.45; filter: grayscale(1); }
.badge-icon { font-size: 2rem; width: 48px; height: 48px; background: rgba(0,0,0,0.3); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.badge-info h3 { font-size: 0.95rem; font-weight: 800; color: #fff; }
.badge-info p { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.modal-footer { padding: 0.9rem 1.4rem; border-top: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: flex-end; }

.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 3000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast-msg { background: #100820; border: 2px solid var(--neon-amber); color: #fff; padding: 0.85rem 1.3rem; border-radius: 12px; box-shadow: 0 8px 25px rgba(0,0,0,0.7); font-weight: 800; animation: slideIn 0.3s forwards; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.floating-xp { position: absolute; font-family: var(--font-mono); font-weight: 800; font-size: 1.3rem; color: var(--neon-emerald); pointer-events: none; text-shadow: 0 0 8px var(--neon-emerald); z-index: 500; animation: floatUp 1s forwards; }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-38px) scale(1.3); } }
/* --- lab-responsive-pass --- */
@media (max-width: 768px) {
    .maestro-container {
        padding-inline: max(1rem, env(safe-area-inset-left, 0px)) max(1rem, env(safe-area-inset-right, 0px));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
        max-width: 100%;
    }
    .xp-bar-mini { width: min(150px, 40vw); }
    .stats-summary-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-btn,
    .toggle-btn-mini,
    .btn-trophies-mini,
    .trigger-pad { min-height: 44px; }
    .close-btn { min-width: 44px; min-height: 44px; }
    .hud-strip { flex-wrap: wrap; gap: 0.5rem; }
}
