@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Dancing+Script:wght@400;700&display=swap');

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: 'Roboto', Arial, sans-serif;
}

.slider-container {
    width: 100%;
    margin: 0 auto;
    height: 20px;
    position: absolute;
    z-index: 20;
}

.piano-slider {
    position: relative;
    width: 100%;
    height: 20px;
    background: #ccc;
    margin-top: 19px;
}

.slider-window {
    position: absolute;
    top: 0;
    width: 84px;
    height: 20px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
    cursor: grab;
    box-sizing: border-box;
    touch-action: none;
    user-select: none;
    z-index: 25;
    pointer-events: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-arrow {
    width: 20px;
    height: 20px;
    background: rgba(200, 200, 200, 0.8);
    color: #333;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 26;
}

.slider-arrow:hover {
    background: rgba(180, 180, 180, 0.8);
}

.left-arrow {
    border-radius: 4px 0 0 4px;
}

.right-arrow {
    border-radius: 0 4px 4px 0;
}

#wrapPiano {
    position: absolute;
    width: 100%;
    height: 450px;
    margin: 10px auto 0;
    overflow: hidden;
    background: #f0f0f0;
    border: 5px solid black;
    box-shadow: 13px 19px 6px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    z-index: 10;
}

#piano {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: all;
    z-index: 10;
}

.key {
    stroke: #333;
    stroke-width: 1;
}

.key.white {
    /* Estilo básico para teclas brancas */
}

.white-c, .white-d, .white-e {
    filter: url(#white-shadow-2);
}

.white-f, .white-g {
    filter: url(#white-shadow-2);
}

.white-a, .white-b {
    filter: url(#white-shadow-3);
}

#control-bar {
    font-family: 'Roboto', Arial, sans-serif !important;
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    display: flex !important;
    gap: 10px !important;
    padding: 5px !important;
    background: rgba(240, 240, 240, 0.9) !important;
    border-radius: 4px !important;
    z-index: 30 !important;
}

#piano-config-buttons {
    font-family: 'Roboto', Arial, sans-serif;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 5px;
    background: rgba(240, 240, 240, 0.9);
    border-radius: 4px;
    z-index: 30;
    align-items: center;
}

#piano-config-buttons button {
    padding: 2px 6px;
    font-size: 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#piano-config-buttons button:hover {
    background: #555;
}

#instrumentSelect, #gameModeSelect, #languageSelect {
    font-family: 'Roboto', Arial, sans-serif !important;
    padding: 5px !important;
    display: block !important;
    border-radius: 4px;
    border: 1px solid #cbd5e0;
    background: #fff;
}

#feedback-bar {
    position: absolute;
    left: 45%; /* Deslocado ligeiramente para a esquerda */
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 32px;
    border-radius: 15px;
    font-size: 30px; /* Fonte aumentada para 30px */
    text-align: center;
    max-width: 80%; /* Reduzido para evitar overflow em telas grandes */
    width: auto;
    border: none;
    font-weight: 500;
    z-index: 30;
    overflow: hidden;
    font-family: 'Dancing Script', cursive;
    color: #3a3a6a;
    background-image: 
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><path fill="%23a5a8e6" opacity="0.7" d="M20,40 Q40,20 60,40 Q80,60 60,80 Q40,100 20,80 Q0,60 20,40 Z"/></svg>'),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><path fill="%23d4b8e6" opacity="0.5" d="M80,30 Q110,40 90,70 Q70,100 40,80 Q10,60 30,30 Q50,0 80,30 Z"/></svg>');
    background-size: 70% 90%, 90% 80%;
    background-position: left top, right center;
    background-repeat: no-repeat;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.7);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25); /* Sombra fixa da Opção 14 */
    animation: slideInFromLeft 0.5s ease-in-out; /* Animação de entrada */
}

#feedback-bar::before {
    content: '➜'; /* Seta da Breathing Arrow */
    font-size: 28px;
    color: #c0c0c0; /* Tom prata */
    margin-right: 12px;
    animation: breathe 2s infinite ease-in-out; /* Animação Breathing Arrow */
    -webkit-animation: breathe 2s infinite ease-in-out; /* Fallback para Safari */
}

/* Text Wave para as palavras do feedback-bar */
#feedback-bar span {
    display: inline-block;
    margin-right: 0.2em; /* Espaço entre palavras */
    animation: textWave 4s ease-in-out infinite;
    animation-delay: calc(var(--char-index) * 0.2s); /* Atraso por palavra */
    -webkit-animation: textWave 4s ease-in-out infinite; /* Fallback para Safari */
    -webkit-animation-delay: calc(var(--char-index) * 0.2s); /* Fallback para Safari */
}

/* Animação de entrada suave da esquerda para a direita */
@keyframes slideInFromLeft {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%);
    }
}

/* Animação Breathing Arrow */
@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Animação Text Wave ajustada */
@keyframes textWave {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); } /* Deslocamento reduzido para suavidade */
}

#game-scoreboard {
    font-family: 'Roboto', Arial, sans-serif;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 9px;
    margin-bottom: 8px;
    z-index: 30;
    display: flex;
    gap: 2px;
    align-items: center;
    padding: 2px;
    width: 100%;
    max-width: 375px;
    box-sizing: border-box;
}

#game-scoreboard span {
    padding: 1px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-size: 14px;
}

#notes-played { background: #dbeafe; color: #1e40af; }
#hits { background: #dcfce7; color: #166534; }
#misses { background: #fee2e2; color: #991b1b; }
#attempts { background: #e5e7eb; color: #4b5563; }
#accuracy { background: #f3e8ff; color: #6b21a8; }
#timer { background: #fef9c3; color: #854d0e; }

#game-controls {
    font-family: 'Roboto', Arial, sans-serif;
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 30;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0;
    align-items: center !important;
    background: #000 !important;
    padding: 5px;
    border-radius: 4px;
    width: 100% !important;
    max-width: 720px !important;
    box-sizing: border-box;
    height: auto;
}

#game-controls:not(.active) {
    display: none !important;
}

#game-controls button {
    padding: 0;
    width: 40px;
    height: 40px;
    font-size: 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#play-btn { background: #4ade80; color: #000; }
#repeat-btn { background: #60a5fa; color: #000; }
#next-btn { background: #9ca3af; color: #000; }
#stop-btn { background: #f87171; color: #000; }
#settings-btn { background: #facc15; color: #000; }

#game-controls select {
    padding: 5px;
    font-size: 14px;
    background: #000;
    color: #fff;
    border-radius: 4px;
    height: 40px;
    width: 100px;
    flex-shrink: 0;
}

#version-link {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 12px;
    color: #333;
    text-decoration: none;
    padding: 3px 6px;
    background: rgba(240, 240, 240, 0.9);
    border-radius: 3px;
    z-index: 30;
    width: auto; /* Garantir largura limitada */
    box-sizing: border-box;
}

#version-link:hover {
    text-decoration: underline;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: #f0f0f0;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
    transition: left 0.3s ease-in-out;
    z-index: 100;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.side-menu.open {
    left: 0;
    z-index: 1000 !important;
}

.side-menu .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.side-menu h2 {
    margin: 0 0 20px;
    font-family: 'Roboto', Arial, sans-serif;
}

.side-menu-field {
    margin-bottom: 15px;
}

.side-menu-field label {
    display: block;
    margin-bottom: 5px;
    font-family: 'Roboto', Arial, sans-serif;
}

.side-menu-field select,
.side-menu-field input[type="number"],
.side-menu-field input[type="checkbox"] {
    width: 100%;
    padding: 5px;
    font-family: 'Roboto', Arial, sans-serif;
}

.side-menu-field.button-field {
    text-align: center;
}

.side-menu-field button {
    padding: 10px 20px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Roboto', Arial, sans-serif;
}

.side-menu-field button:hover {
    background: #555;
}

@media (min-width: 600px) {
    .side-menu {
        width: 300px;
    }

    #control-bar, #piano-config-buttons, #game-scoreboard, #game-controls, #feedback-bar {
        max-width: 600px;
    }

    #game-controls {
        gap: 0;
        max-width: 720px;
    }

    #game-scoreboard {
        gap: 4px;
        padding: 4px;
    }

    #game-scoreboard span {
        padding: 2px;
        font-size: 19.6px;
        line-height: 28px;
    }

    #game-controls button {
        width: 48px;
        height: 48px;
        font-size: 19.2px;
        margin-left: 30px;
    }

    #game-controls select {
        height: 48px;
        font-size: 16.8px;
        width: 120px;
        margin-right: 30px;
    }

    #wrapPiano {
        margin-top: 20px;
    }
}

@media (max-width: 600px) {
    #feedback-bar {
        font-size: 24px;
        padding: 12px 16px;
        max-width: 95%;
        width: 95%;
        white-space: nowrap; /* Restaurado para manter texto em uma linha */
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #feedback-bar::before {
        font-size: 22px;
        margin-right: 8px;
        animation-duration: 2s; /* Manter duração da animação */
    }
    #feedback-bar span {
        margin-right: 0.1em; /* Menor margem em telas pequenas */
    }

    #game-scoreboard {
        display: flex;
        gap: 8px; /* Reduzido para liberar espaço */
        padding: 4px; /* Reduzido para liberar espaço */
        justify-content: space-between; /* Distribuir elementos uniformemente */
        width: 100%; /* Ocupar toda a largura do viewport */
        max-width: none; /* Remover limitação de largura */
        flex-wrap: nowrap; /* Forçar uma linha */
        align-items: center; /* Alinhar verticalmente */
    }

    #game-scoreboard span {
        padding: 2px; /* Mantido para área */
        font-size: 18px; /* Reduzido para evitar cortes */
        line-height: 24px; /* Ajustado para fonte menor */
        flex: 0 0 auto; /* Ajustar ao conteúdo */
        text-align: center; /* Centralizar texto */
        min-width: 0; /* Evitar overflow */
        white-space: nowrap; /* Impedir quebra de linha no texto */
        overflow: visible; /* Permitir texto completo */
    }

    #game-scoreboard span:first-child {
        margin-left: 8px; /* Reduzido para liberar espaço */
    }

    #game-scoreboard span:last-child {
        margin-right: 8px; /* Reduzido para liberar espaço */
    }

    #game-controls {
        gap: 10px; /* Aumentado para maior separação */
        justify-content: space-between; /* Distribuir botões uniformemente */
        width: 100%; /* Ocupar toda a largura do viewport */
        max-width: none; /* Remover limitação de largura */
        padding: 8px 12px; /* Margens externas de 12px */
        background: #000 !important; /* Preservar fundo preto */
        box-sizing: border-box;
    }

    #game-controls button {
        width: 48px; /* Aumentado para melhor toque */
        height: 48px;
        font-size: 19.2px; /* Aumento de ~20% (de 16px para 19.2px) */
    }

    #game-controls select {
        height: 48px;
        font-size: 16.8px; /* Aumento de ~20% (de 14px para 16.8px) */
        width: 120px;
    }

    #version-link {
        top: auto !important;
        bottom: 10px !important; /* Posicionar abaixo do piano */
        right: 10px !important;
        width: auto !important; /* Garantir largura limitada */
        box-sizing: border-box;
    }
}

@media (max-width: 400px) {
    #feedback-bar {
        font-size: 20px;
        padding: 10px 12px;
        max-width: 100%;
        width: 100%;
        left: 50%;
        transform: translateX(-50%);
    }
    #feedback-bar::before {
        font-size: 18px;
    }

    #game-scoreboard span {
        font-size: 16px; /* Reduzido para telas muito pequenas */
        line-height: 22px; /* Ajustado para fonte menor */
    }
}

.slider-container {
    pointer-events: none;
}

.slider-window:active {
    pointer-events: auto;
}
