/* --- Start Screen --- */
       /* --- Start Screen --- */
		#start-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            
            /* --- NUEVO FONDO --- */
            background-color: var(--bg-color); /* Color por si la imagen tarda en cargar */
        background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('texturas/start.png');
            background-size: cover; /* Hace que la imagen cubra toda la pantalla sin deformarse */
            background-position: center; /* Centra la imagen */
            background-repeat: no-repeat; /* Evita que la imagen se repita como un mosaico */
            
            z-index: 9999;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: opacity 0.5s ease, visibility 0.5s ease;
        }

        .start-title {
            font-size: 3.5rem;
            color: var(--white-key);
            margin-bottom: 10px;
            text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
            text-align: center;
        }

        .start-subtitle {
            font-size: 1.2rem;
            color: var(--text-color);
            opacity: 0.8;
            margin-bottom: 40px;
            text-align: center;
        }

        .start-btn {
            background-color: var(--accent);
            color: white;
            font-size: 1.5rem;
            padding: 15px 40px;
            border: none;
            border-radius: 30px;
            cursor: pointer;
            font-weight: bold;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
            transition: transform 0.2s, background-color 0.2s;
            animation: pulse-start 2s infinite;
        }

        .start-btn:hover {
            background-color: #2980b9;
            transform: scale(1.05);
        }

        @keyframes pulse-start {
            0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7); }
            70% { box-shadow: 0 0 0 20px rgba(52, 152, 219, 0); }
            100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
        }
		
        :root {
            --bg-color: #2c3e50;
            --piano-bg: #1a1a1a;
            --white-key: #fdfdfd;
            --black-key: #111;
            --accent: #3498db;
            --success: #2ecc71;
            --error: #e74c3c;
            --warning: #f1c40f;
            --text-color: #ecf0f1;
            --panel-bg: rgba(0,0,0,0.25);
            --avatar-bg: #e67e22;
            --record-color: #e74c3c;
            --midi-color: #9b59b6;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
/* Establece la imagen de fondo */
  background-image: url('texturas/piano.png');

  /* Opcional: Controla cómo se muestra la imagen */
  background-repeat: no-repeat;  /* Para que la imagen no se repita */
  background-size: cover;        /* Para que la imagen cubra todo el fondo, ajustando su tamaño */
  background-position: center;   /* Para centrar la imagen en la pantalla */            color: var(--text-color);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-evenly; /* Reparte el espacio equitativamente */
            height: 100vh; /* Fija la altura exactamente al 100% de tu pantalla */
            width: 100vw;
            margin: 0;
            padding: 0; /* Quitamos el padding inferior que forzaba el scroll */
            user-select: none;
            overflow: hidden; /* ⛔ BLOQUEA EL SCROLL TOTALMENTE */
        }

        h1 {
            margin: 10px 0;
            font-size: 1.8rem;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
            text-align: center;
        }

        /* --- Controls & Layout --- */
        .top-panel {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 15px;
            width: 95%;
            max-width: 900px;
            margin-bottom: 20px;
        }

        .control-group {
            background: var(--panel-bg);
            padding: 10px 20px;
            border-radius: 15px;
            display: flex;
            gap: 15px;
            align-items: center;
            flex-wrap: wrap;
            justify-content: center;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            position: relative;
        }

        .mode-selector button {
            background: transparent;
            border: 2px solid var(--accent);
            color: var(--text-color);
            padding: 8px 16px;
            border-radius: 15px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.2s;
        }

        .mode-selector button.active {
            background: var(--accent);
            color: white;
            transform: scale(1.05);
        }

        .action-btn {
            background-color: var(--accent);
            border: none;
            color: white;
            padding: 10px 20px;
            border-radius: 8px;
            font-size: 1rem;
            cursor: pointer;
            transition: transform 0.1s, background-color 0.2s;
            font-weight: bold;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .action-btn:active { transform: scale(0.95); }
        .action-btn:hover { background-color: #2980b9; }

        .action-btn.stop { background-color: var(--error); }
        .action-btn.stop:hover { background-color: #c0392b; }
        
        .action-btn.toggle-active { 
            background-color: var(--success); 
            box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
        }
        
        .input-toggle-btn {
            background-color: #8e44ad;
        }
        .input-toggle-btn:hover { background-color: #9b59b6; }

        /* Recording Button */
        .record-btn {
            background-color: var(--record-color);
            border-radius: 50%;
            width: 50px;
            height: 50px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            box-shadow: 0 0 10px rgba(0,0,0,0.3);
            border: 3px solid white;
        }
        .record-btn:hover { background-color: #c0392b; }
        .record-btn.recording {
            animation: pulse-red 1.5s infinite;
            background-color: #c0392b;
            border-color: #ff9999;
        }

        /* MIDI Buttons */
        .midi-btn { background-color: var(--midi-color); }
        .midi-btn:hover { background-color: #8e44ad; }
        
        @keyframes pulse-red {
            0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); transform: scale(1); }
            70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); transform: scale(1.1); }
            100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); transform: scale(1); }
        }

        /* Recordings & MIDI List */
        .list-container {
            width: 90%;
            max-width: 600px;
            margin-top: 10px;
            display: none; 
            flex-direction: column;
            gap: 10px;
        }
        
        .list-header {
            font-size: 0.9rem;
            opacity: 0.8;
            margin-bottom: 5px;
            border-bottom: 1px solid rgba(255,255,255,0.2);
            padding-bottom: 5px;
        }

        .list-item {
            background: rgba(255, 255, 255, 0.1);
            padding: 10px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }
        .list-info {
            font-size: 0.9rem;
            flex-grow: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .list-controls {
            display: flex;
            gap: 5px;
        }
        .icon-btn {
            background: transparent;
            border: 1px solid rgba(255,255,255,0.3);
            color: white;
            border-radius: 5px;
            cursor: pointer;
            padding: 5px 10px;
        }
        .icon-btn:hover { background: rgba(255,255,255,0.2); }
        .icon-btn.play { color: var(--success); border-color: var(--success); }
        .icon-btn.play:hover { background: rgba(46, 204, 113, 0.2); }
        
        .icon-btn.stop-midi { color: var(--warning); border-color: var(--warning); }
        .icon-btn.stop-midi:hover { background: rgba(241, 196, 15, 0.2); }

        .icon-btn.delete { color: #e74c3c; border-color: #e74c3c; }
        .icon-btn.delete:hover { background: rgba(231, 76, 60, 0.2); }

        select, input[type="range"] {
            padding: 5px;
            border-radius: 5px;
            border: none;
            font-size: 1rem;
            color: #2c3e50;
        }

        label { font-size: 0.9rem; font-weight: bold; }

        .beat-indicator {
            width: 15px;
            height: 15px;
            border-radius: 50%;
            background-color: #555;
            transition: background-color 0.1s;
        }
        .beat-indicator.active {
            background-color: var(--warning);
            box-shadow: 0 0 10px var(--warning);
        }

        /* --- Theory / Avatar Section --- */
        .theory-container {
            display: flex;
            align-items: flex-start;
            gap: 20px;
            background: white;
            border-radius: 20px;
            padding: 20px;
            margin-bottom: 20px;
            max-width: 600px;
            width: 90%;
            color: #333;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
            min-height: 120px;
            transition: all 0.3s;
        }

        .avatar {
            width: 80px;
            height: 80px;
            min-width: 80px;
            background: var(--avatar-bg);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 4px solid #d35400;
            overflow: hidden;
            position: relative;
        }
        
        .avatar svg {
            width: 70%;
            height: 70%;
        }

        .speech-bubble {
            position: relative;
            background: #ecf0f1;
            border-radius: 15px;
            padding: 15px;
            flex-grow: 1;
            font-size: 1.1rem;
            line-height: 1.4;
            border: 2px solid #bdc3c7;
        }

        .speech-bubble:after {
            content: '';
            position: absolute;
            left: 0;
            top: 30px;
            width: 0;
            height: 0;
            border: 10px solid transparent;
            border-right-color: #bdc3c7;
            border-left: 0;
            margin-top: -10px;
            margin-left: -12px;
        }

        .lesson-nav {
            margin-top: 10px;
            display: flex;
            gap: 10px;
        }

        .lesson-btn {
            background: var(--accent);
            color: white;
            border: none;
            padding: 5px 15px;
            border-radius: 15px;
            cursor: pointer;
            font-size: 0.9rem;
        }

/* --- Sheet Music Display --- */
        .sheet-music-container {
            background: var(--panel-bg); /* Usa el mismo fondo translúcido elegante */
            border: 2px solid rgba(255, 255, 255, 0.1); /* Borde sutil */
            box-shadow: 0 8px 25px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.3); /* Efecto de profundidad */
            padding: 20px;
            border-radius: 15px;
            margin-bottom: 20px;
            width: 90%;
            max-width: 600px;
            height: 100px;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            position: relative;
        }

        /* --- Game Info --- */
        .game-info {
            font-size: 1.3rem;
            margin-bottom: 15px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 20px;
            width: 100%;
        }

        .target-note {
            font-weight: bold;
            color: var(--accent);
            background: white;
            padding: 5px 15px;
            border-radius: 20px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }

        /* --- Piano Styles --- */
        .piano-container {
            background-color: var(--piano-bg);
            padding: 10px 10px 10px 10px; /* Reducimos el espacio vacío superior */
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            position: relative;
            overflow-x: auto;
            max-width: 95vw;
            display: flex;
            justify-content: center;
            margin-bottom: 10px; /* Lo despegamos del borde inferior */
            
            /* Ocultar barra de scroll en Firefox y Edge */
            scrollbar-width: none; 
            -ms-overflow-style: none;
        }

        /* Ocultar barra de scroll en Chrome/Safari/Opera */
        .piano-container::-webkit-scrollbar {
            display: none;
        }

        .piano {
            display: flex;
            position: relative;
            height: 142px;
            min-width: min-content; 
        }

        .key {
            position: absolute;
            cursor: pointer;
            border-radius: 0 0 5px 5px;
            transition: background-color 0.1s;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            padding-bottom: 10px;
            font-weight: bold;
            font-size: 0.9rem;
            user-select: none;
            box-sizing: border-box;
        }

        .key.white {
            width: 50px;
            height: 140px;
            background-color: var(--white-key);
            border: 1px solid #999;
            border-top: none;
            color: #333;
            z-index: 1;
        }

        .key.white:active, .key.white.active, .key.white.midi-active {
            background: linear-gradient(to bottom, #fff 0%, #ccc 100%);
            transform: translateY(2px);
        }

        .key.black {
            width: 32px;
            height: 80px;
            background-color: var(--black-key);
            color: white;
            z-index: 2;
            border-radius: 0 0 3px 3px;
            box-shadow: 2px 2px 5px rgba(0,0,0,0.4);
        }

        .key.black:active, .key.black.active, .key.black.midi-active {
            background-color: #000;
            transform: translateY(2px);
        }
        
        .midi-active {
            background-color: var(--warning) !important;
            border-bottom: 5px solid #d35400 !important;
        }

        .key span {
            pointer-events: none;
            opacity: 0.7;
        }
        
        .key-keyboard-label {
            font-size: 0.8rem;
            color: var(--accent);
            font-weight: 900;
            margin-bottom: 20px;
        }

        /* --- Animations & Feedback --- */
        .correct { background-color: var(--success) !important; transition: background-color 0.2s; }
        .wrong { background-color: var(--error) !important; transition: background-color 0.2s; }
        .highlight-scale { background-color: #3498db !important; color: white !important;} 
        .highlight-theory { background-color: #9b59b6 !important; color: white !important;}
        .key.white.highlight-scale { background: #85c1e9 !important; }
        .key.black.highlight-scale { background: #3498db !important; }
        .key.white.highlight-theory { background: #d7bde2 !important; }

        .notification {
            position: absolute;
            top: 30%;
            font-size: 3rem;
            font-weight: bold;
            text-shadow: 0 0 10px rgba(0,0,0,0.5);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.5s, transform 0.5s;
            z-index: 20;
            width: 100%;
            text-align: center;
        }
        
        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-5px); }
        }
        .avatar-talking { animation: bounce 0.5s infinite; }

        /* --- Media Queries --- */
        @media (max-width: 600px) {
            .key.white { width: 36px; height: 160px; font-size: 0.7rem; }
            .key.black { width: 22px; height: 100px; font-size: 0.6rem; }
            .piano { height: 170px; }
            .sheet-music-container { height: 100px; padding: 10px; }
            .theory-container { padding: 10px; gap: 10px; font-size: 0.9rem; }
            .avatar { width: 50px; height: 50px; min-width: 50px; }
            .speech-bubble { padding: 10px; font-size: 0.95rem; }
            h1 { font-size: 1.4rem; }
            .control-group { gap: 8px; padding: 10px; }
            .record-btn { width: 40px; height: 40px; font-size: 1.2rem; }
        }
		/* --- Estilos del Marcador --- */
        .score-row {
            display: flex;
            justify-content: space-between;
            background: #ecf0f1;
            margin: 5px 0;
            padding: 10px 15px;
            border-radius: 8px;
            font-weight: bold;
            color: #2c3e50;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .score-row.first { background: #f1c40f; color: #fff; text-shadow: 1px 1px 2px rgba(0,0,0,0.3); }
        .score-row.second { background: #bdc3c7; color: #fff; text-shadow: 1px 1px 2px rgba(0,0,0,0.3); }
        .score-row.third { background: #cd7f32; color: #fff; text-shadow: 1px 1px 2px rgba(0,0,0,0.3); }
/* --- Visor MIDI (Estilo Synthesia) --- */
        #midi-visualizer {
            background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.1) 100%);
            border-radius: 10px 10px 0 0;
            box-shadow: inset 0 5px 15px rgba(0,0,0,0.5);
            margin-bottom: 2px;
            transition: opacity 0.3s;
        }
		/* --- Estilos del Menú Desplegable de Controles --- */
        .dropdown-panel {
            position: absolute;
            top: 50px;
            right: 0;
            background: rgba(30, 40, 50, 0.95); /* Fondo oscuro translúcido */
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
            min-width: 220px;
            flex-direction: column;
            backdrop-filter: blur(10px);
            animation: fadeIn 0.2s ease;
        }

        .dropdown-panel button, .dropdown-panel select {
            width: 100%; /* Hace que todos los botones midan lo mismo en el menú */
            margin: 0;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
		/* --- Sistema de Partículas (Chispas) --- */
        .spark-particle {
            position: absolute;
            bottom: 20px; /* Salen cerca de la parte inferior de la tecla */
            left: 50%;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            pointer-events: none; /* Para que no estorben si haces clic rápido */
            z-index: 100;
            animation: spark-explode 0.6s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
        }

        @keyframes spark-explode {
            0% {
                transform: translateX(-50%) translate(0, 0) scale(1);
                opacity: 1;
            }
            100% {
                /* Las variables --tx y --ty las inyectaremos con JavaScript */
                transform: translateX(-50%) translate(var(--tx), var(--ty)) scale(0);
                opacity: 0;
            }
        }