@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg-deep: #050505;
    --primary-accent: #6366f1;
    --secondary-accent: #ec4899;
    --glass-bg: rgba(20, 20, 24, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --clr-root: #ff4757;
    --clr-third: #3742fa;
    --clr-fifth: #2ed573;

    --fret-metal: linear-gradient(180deg, #555, #ccc 40%, #999 60%, #555);
    --string-gold: linear-gradient(90deg, #4a3b2a, #d4af37, #ffecb3, #b8860b, #4a3b2a);
    --string-silver: linear-gradient(90deg, #222, #999, #eee, #777, #222);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { background-color: var(--bg-deep); color: white; font-family: 'Inter', sans-serif; height: 100vh; overflow: hidden; }

/* AMBIENTE */
.ambient-glow {
    position: fixed; top: -20%; left: -20%; width: 140%; height: 140%;
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #000000 70%);
    z-index: -1; pointer-events: none;
}
.app-container { display: flex; flex-direction: column; height: 100vh; }

/* HEADER */
.control-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 10px 15px;
    z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.logo-mark {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12px;
}
h1 { font-size: 16px; font-weight: 700; }
h1 span { color: var(--primary-accent); }

.controls-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.control-group { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 9px; text-transform: uppercase; color: #888; font-weight: 700; letter-spacing: 0.5px; }

select {
    appearance: none; -webkit-appearance: none;
    background: #18181b;
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee; padding: 8px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 500; width: 100%;
}

/* --- DIAPASÓN Y SCROLL --- */
.fretboard-container {
    flex: 1; display: flex; flex-direction: column; 
    justify-content: center; 
    overflow: hidden; position: relative;
    padding-bottom: 20px;
}

.fretboard-scroll {
    width: 100%; overflow-x: auto; 
    padding: 20px 0; 
    scrollbar-width: none;
    display: flex; flex-direction: column;
    align-items: flex-start; 
}
.fretboard-scroll::-webkit-scrollbar { display: none; }
.fretboard-scroll.ebony { background: transparent; }

/* EL MÁSTIL */
.fretboard {
    display: flex; flex-direction: column; position: relative;
    min-width: max-content;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    background: #111;
    margin-left: 20px; 
}

/* Cuerdas */
.string { height: 42px; display: flex; position: relative; align-items: center; z-index: 1;}
.string::after { content: ''; position: absolute; width: 100%; z-index: 2; pointer-events: none; box-shadow: 0 2px 4px rgba(0,0,0,0.5);}

#string-5::after { height: 4.5px; background: var(--string-gold); } 
#string-4::after { height: 3.8px; background: var(--string-gold); } 
#string-3::after { height: 3.0px; background: var(--string-gold); } 
#string-2::after { height: 2.2px; background: var(--string-silver); } 
#string-1::after { height: 1.5px; background: var(--string-silver); } 
#string-0::after { height: 1.0px; background: var(--string-silver); } 

/* --- TRASTES (Estructura Base) --- */
.fret {
    width: 65px; min-width: 65px;
    height: 100%;
    /* Borde real de metal */
    border-right: 3px solid transparent; 
    border-image: var(--fret-metal) 1;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.fret:nth-child(n+12) { min-width: 55px; width: 55px; }

/* --- CEJUELA (TRASTE 0) MEJORADA --- */
.fret:first-child {
    background: #e3ddd5; /* Color Hueso */
    min-width: 35px; width: 35px;
    
    /* Borde derecho de 5px */
    border-right: 5px solid #222; 
    border-image: none;
    
    z-index: 2;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}

/* NOTAS EN LA CEJUELA: "Por encima" (Z-Index alto) */
.fret:first-child .note { 
    border: 2px solid #555; 
    color: white; 
    transform: scale(0.9);
    z-index: 20; /* Se asegura de estar CAPA SUPERIOR */
    box-shadow: 0 4px 6px rgba(0,0,0,0.4); /* Sombra para que flote */
}
.fret:first-child .note.active { 
    border-color: transparent; 
    transform: scale(1); 
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* --- NÚMEROS DE TRASTE (ALINEACIÓN MATEMÁTICA) --- */
.fret-numbers-row {
    display: flex; margin-top: 10px; min-width: max-content;
    margin-left: 20px; /* Igual que el diapasón */
}

.fret-number {
    display: flex; justify-content: center; 
    font-size: 11px; color: #666; font-weight: 700;
    
    width: 65px; min-width: 65px;
    
    /* TRUCO DE ALINEACIÓN: Borde transparente idéntico al de los trastes */
    /* Esto obliga al número a centrarse en el mismo espacio exacto */
    border-right: 3px solid transparent; 
    box-sizing: border-box;
}

/* Ajuste para trastes agudos */
.fret-number:nth-child(n+13) { 
    min-width: 55px; width: 55px; 
}

/* HUECO DEL 0 (Invisible pero ocupa espacio) */
.fret-number:first-child {
    min-width: 35px; width: 35px;
    /* Borde transparente idéntico a la cejuela */
    border-right: 5px solid transparent; 
}

.fret-number.key-fret { color: var(--primary-accent); font-size: 13px; }

/* --- CONTROLES DE NAVEGACIÓN --- */
.nav-controls {
    display: flex; justify-content: center; align-items: center; gap: 20px;
    padding: 15px; margin-top: 5px;
}
.nav-arrow {
    background: rgba(255,255,255,0.08); 
    border: 1px solid rgba(255,255,255,0.1);
    color: white; width: 50px; height: 40px; 
    border-radius: 20px; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}
.nav-arrow:active { background: var(--primary-accent); border-color: transparent; }
.nav-label { font-size: 10px; text-transform: uppercase; color: #555; letter-spacing: 2px; }

/* NOTAS */
.note {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,0.15);
    z-index: 10; font-size: 11px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transform: scale(0); transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.note.active { opacity: 1; transform: scale(1); color: white; }
.interval-1P { background: var(--clr-root); box-shadow: 0 0 15px var(--clr-root); }
.interval-3M { background: var(--clr-third); }

/* MODO ZURDO FIX */
.fretboard-container.lefty-mode .fretboard-scroll { transform: scaleX(-1); }
.lefty-mode .note { transform: scaleX(-1); } 
.lefty-mode .fret-numbers-row { transform: scaleX(-1); flex-direction: row-reverse; }
.lefty-mode .fret-number { transform: scaleX(1); }

/* FOOTER */
.bottom-bar {
    background: #111; padding: 10px 15px;
    display: flex; justify-content: space-between; align-items: center;
    border-top: 1px solid #333; gap: 10px;
}
#play-btn {
    background: linear-gradient(90deg, var(--primary-accent), var(--secondary-accent));
    border: none; padding: 10px 20px; border-radius: 30px;
    color: white; font-weight: bold; font-size: 12px;
}
#play-btn:disabled { opacity: 0.5; }
#metro-btn {
    background: #222; border: 1px solid #444; color: #aaa;
    min-width: 50px; width: auto; padding: 0 10px;
    height: 36px; border-radius: 8px; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
#metro-btn.active { background: #333; border-color: var(--secondary-accent); color: white; }
.settings-group { display: flex; gap: 5px; }
.icon-btn { background: #222; border: 1px solid #333; color: white; padding: 8px; border-radius: 6px; font-size: 11px; }

.string.vibrating::after { animation: strVib 0.1s linear infinite; }
@keyframes strVib { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(1px); } }