/* ====== ESTILO GERAL (ESTÚDIO DARK) ====== */
body {
    margin: 0;
    background: linear-gradient(to bottom, #111, #333);
    height: 100vh;
    display: flex;
    flex-direction: column;
    color: white;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    overflow: hidden; /* Mantém tudo dentro da tela */
}

/* ====== TÍTULO / MENU SUPERIOR ====== */
h1 {
    text-align: center;
    color: white;
    background: linear-gradient(to right, #111, #1a1a1a);
    padding: 10px 0;
    margin: 0;
    font-family: 'Arial Black', sans-serif;
    letter-spacing: 2px;
    font-size: clamp(18px, 4vh, 28px); /* Tamanho adaptável */
    text-transform: uppercase;
    border-bottom: 2px solid #ffffff;
    flex-shrink: 0;
}

/* ====== ÁREA CENTRAL (PARTITURA) ====== */
#output {
    position: relative; /* Mudado de absolute para seguir o fluxo da página */
    margin: 20px 220px 20px 250px; /* Margens para não colidir com botões laterais */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    
    /* MUDANÇA AQUI: Altura fixa e scrolls */
    height: 45vh;   /* Define um 'teto' para a partitura (ex: 35% da altura da tela) */
    min-height: 350px; /* Garante tamanho mínimo em telas pequenas */
    
    overflow-x: auto; /* Scroll horizontal para as notas novas */
    overflow-y: hidden; /* Evita que o container cresça para baixo */
    
    display: flex;
    justify-content: flex-start;
    align-items: center;
    scroll-behavior: smooth; /* Movimento suave da 'câmera' follow */
    z-index: 5;
    transform: none; /* Removido o transform antigo */
    left: auto; /* Removido o left fixo antiga */
}

#output svg {
    height: 380px !important; 
    width: auto !important;
    transform-origin: left center;
}

/* ====== CONTROLES LATERAIS (FIXOS) ====== */
.controles-container {
    position: fixed;
    top: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    width: 180px;
}

.timbre-selector {
    position: fixed;
    top: 80px;
    left: 20px;
    background: rgba(0,0,0,0.8);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #444;
    z-index: 1000;
    width: 180px;
}

.instrucoes {
    position: fixed;
    top: 220px; /* Posicionado abaixo do timbre */
    left: 20px;
    width: 180px;
    font-size: 11px;
    color: #aaa;
    background: rgba(0,0,0,0.7);
    padding: 10px;
    border-radius: 8px;
    border-left: 3px solid #ffffff;
}

#status-oitava {
    position: fixed;
    bottom: 35vh; /* Logo acima do piano */
    left: 20px;
    background: #222;
    color: #ffffff;
    padding: 8px 15px;
    border-radius: 8px;
    border: 2px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    scale: 0.85;
    transform-origin: left bottom;
}

/* ====== CONTAINER DO PIANO (DINÂMICO) ====== */
#pianoTeclas {
    display: flex;
    padding: 10px 20px;
    background: #111;
    height: 25vh; /* Ocupa 25% da altura da tela, não importa o monitor */
    min-height: 160px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #ffffff #111;
    flex-shrink: 0; /* Não deixa o piano esmagar */
    position: fixed; 
    bottom: 0;
    left: 0;
    right: 0;
}

#pianoTeclas::-webkit-scrollbar { height: 8px; }
#pianoTeclas::-webkit-scrollbar-thumb { background: #ffffff; border-radius: 5px; }

/* ====== TECLAS ====== */
.oitava {
    display: flex;
    position: relative;
    flex-shrink: 0;
}

.white {
    background: linear-gradient(to bottom, #fff 70%, #eee 100%);
    width: 3.5vw; /* Largura proporcional à tela */
    min-width: 35px;
    height: 100%;
    margin-right: 2px; 
    border: 1px solid #bbb; 
    box-shadow: inset 0 -3px 5px #00000026; 
    cursor: pointer;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-size: 9px;
    color: rgba(0,0,0,0.3);
    transition: 0.1s;
    text-transform: uppercase
}

.black {
    background: linear-gradient(to bottom, #222, #000);
    width: 2.2vw; /* Largura proporcional à tela */
    min-width: 22px;
    height: 60%;
    position: absolute;
    z-index: 2;
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    border: 1px solid #000;
}

/* Posicionamento das pretas (proporcional) */
.c-sharp { left: 2.3vw; }
.d-sharp { left: 6.0vw; }
.f-sharp { left: 13.0vw; }
.g-sharp { left: 16.7vw; }
.a-sharp { left: 20.4vw; }

/* Ajuste fino para resoluções menores */
@media (max-width: 1200px) {
    .c-sharp { left: 25px; }
    .d-sharp { left: 65px; }
    .f-sharp { left: 140px; }
    .g-sharp { left: 180px; }
    .a-sharp { left: 220px; }
}

/* ====== ESTILOS DE BOTÕES E INTERAÇÃO ====== */
.controles-container input[type="button"],
.botoes-grupo input[type="button"] {
    width: 100%;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    color: white;
    background-color: #444040;
    transition: 0.2s;
}

.controles-container input[type="button"]:hover {
    transform: scale(1.03);
    filter: brightness(1.2);
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.active-key {
    background: #adaca5 !important;
    transform: translateY(3px);
    box-shadow: inset 0 5px 10px #0000004d;
}

#indicador-ritmo {
    width: 15px;
    height: 15px;
    background-color: #444;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
    border: 2px solid #222;
}

#indicador-ritmo.pulso {
    background-color: #ffffff; 
    box-shadow: 0 0 10px #ffffff;
}

#toggle-metronomo.ligado { background: linear-gradient(to bottom, #2ecc71, #27ae60) !important; }
#toggle-metronomo.desligado { background: linear-gradient(to bottom, #e74c3c, #c0392b) !important; }

/* ====== BOTÕES VOLTAR E TUTORIAL ====== */
#tutorial,
a[href="index.html"] {
    display: block;
    width: 100%;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    color: white;
    background-color: #444040;
    transition: 0.2s;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;

}

#tutorial:hover,
a[href="index.html"]:hover {
    transform: scale(1.03);
    filter: brightness(1.2);
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}
    

a[href="index.html"]::before {
    content: '← ';
}