@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&display=swap');

:root {
    --laranja: #ff9800;
    --btn-vermelho: #ff7675;
    --btn-verde: #2ecc71;
    --azul-tile: #6c5ce7;
    --cinza-escuro: #2c3e50;
    --amarelo-sol: #ffdb58;
}

body {
    font-family: 'Fredoka', sans-serif;
    margin: 0;
    overflow: hidden;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}


/* Efeito de Tremida na Tela */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.shake {
    animation: shake 0.4s;
    animation-iteration-count: 1;
}

header {
    background: rgba(255, 255, 255, 0.95); 
    width: 100%; 
    padding: 12px 20px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    z-index: 100; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
    box-sizing: border-box;
    flex-wrap: wrap;
    gap: 10px;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pontos-display { font-size: 1.4rem; font-weight: bold; color: var(--laranja); }
.acertos-display { font-size: 1.4rem; font-weight: bold; color: var(--btn-verde); }
.recorde-display { font-size: 1.4rem; font-weight: bold; color: var(--cinza-escuro); }
.recorde-valor { color: var(--azul-tile); }

.btn-header {
    cursor: pointer; 
    padding: 10px 22px; 
    border-radius: 50px; 
    border: none;
    color: white; 
    font-weight: bold; 
    font-family: 'Fredoka';
    font-size: 0.9rem; 
    text-decoration: none;
    display: inline-block; 
    transition: 0.1s;
}

.btn-header:active { 
    transform: translateY(6px); 
}

/* Modais */
.modal-overlay {
    position: fixed; 
    inset: 0; 
    background: rgba(44, 62, 80, 0.95);
    display: flex; 
    flex-direction: column;
    align-items: center; 
    justify-content: center; 
    z-index: 2000;
}

.menu-caixa {
    background: white; 
    padding: 30px; 
    border-radius: 35px;
    border: 8px solid var(--laranja); 
    width: 90%; 
    max-width: 600px;
    text-align: center; 
    box-sizing: border-box; 
    max-height: 90svh; 
    overflow-y: auto;
}

/* NOVO DESIGN: Personalização da Cobrinha */
.custom-cobrinha {
    background: #f1f2f6;
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    border-left: 5px solid var(--laranja);
}
.custom-cobrinha h3 {
    margin: 0 0 10px 0;
    color: var(--cinza-escuro);
    font-size: 1.1rem;
    text-align: center;
}
.paleta-cores {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}
.btn-cor {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.1);
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0,0,0,0.1);
    transition: 0.1s;
}
.btn-cor:active {
    transform: translateY(3px);
    box-shadow: 0 0px 0 rgba(0,0,0,0.1);
}
.btn-cor.selecionado {
    border: 4px solid var(--cinza-escuro);
    transform: scale(1.15);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}


.regras-box {
    background: #f1f2f6; 
    border-radius: 15px; 
    padding: 15px;
    margin: 15px 0; 
    text-align: left; 
    font-size: 0.9rem; 
    color: #555;
    border-left: 5px solid var(--azul-tile);
}

.btn-modo {
    width: 100%; 
    padding: 15px; 
    margin: 10px 0; 
    border: none;
    border-radius: 20px; 
    font-size: 1.4rem; 
    font-family: 'Fredoka';
    cursor: pointer; 
    transition: 0.1s; 
    color: white; 
    font-weight: bold;
    box-shadow: 0 6px 0 rgba(0,0,0,0.2);
}

.btn-modo:active { 
    transform: translateY(6px); 
    box-shadow: 0 0px 0 rgba(0,0,0,0.2); 
}

#canvas-container {
    position: relative; 
    z-index: 10; 
    margin-top: 15px;
    width: min(72vmin, 640px); 
    border: 8px solid white;
    border-radius: 20px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    background: rgba(0,0,0,0.2); 
    box-sizing: border-box;
}

#canvas-container.acerto { 
    animation: acertoGlow 360ms ease-out; 
}

@keyframes acertoGlow {
    0%   { transform: scale(1);   box-shadow: 0 10px 30px rgba(0,0,0,0.10); }
    45%  { transform: scale(1.02); box-shadow: 0 12px 38px rgba(0,0,0,0.20); }
    100% { transform: scale(1);   box-shadow: 0 10px 30px rgba(0,0,0,0.10); }
}

canvas {
    background-color: rgba(0,0,0,0.3); 
    display: block;
    border-radius: 12px; 
    width: 100%; 
    height: auto;
    aspect-ratio: 1 / 1; 
    touch-action: none;
}

#contagem-tela {
    position: absolute; 
    inset: 0; 
    display: none;
    align-items: center; 
    justify-content: center; 
    z-index: 15; 
    pointer-events: none;
}

#contagem-texto {
    font-size: 8rem; 
    font-weight: bold; 
    color: white;
    text-shadow: 0 0 20px rgba(0,0,0,0.5); 
    animation: pulseContagem 0.5s ease-out;
}

@keyframes pulseContagem { 
    0% { transform: scale(2); opacity: 0; } 
    100% { transform: scale(1); opacity: 1; } 
}

.game-ui { 
    z-index: 10; 
    text-align: center; 
    color: #2d3436; 
    margin-top: 15px; 
    width: 100%; 
    max-width: 640px; 
}

.display-alvo { 
    font-size: 3rem; 
    margin: 0; 
    color: var(--cinza-escuro); 
    font-weight: bold; 
}

.progresso-linha { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 15px; 
    margin-top: 5px; 
}

.btn-repetir {
    width: 50px; 
    height: 50px; 
    border-radius: 14px; 
    border: none;
    background: white; 
    cursor: pointer; 
    box-shadow: 0 4px 0 rgba(0,0,0,0.12);
    font-size: 1.5rem; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: 0.1s;
}

.btn-repetir:active { 
    transform: translateY(4px); 
    box-shadow: 0 0px 0 rgba(0,0,0,0.12); 
}

.progresso-texto { 
    font-size: 2.5rem; 
    font-weight: bold; 
    color: var(--azul-tile); 
}

.controles-fixos {
    position: fixed; 
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    z-index: 2100;
}

.btn-circular { 
    width: 60px; 
    height: 60px; 
    border-radius: 50%; 
    border: none; 
    background: white; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.5rem; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    transition: 0.1s;
}

.btn-circular:active { transform: translateY(4px); }
.btn-circular.ativo { background: var(--btn-verde); color: white; }

.dpad-container {
    display: none; 
    position: fixed; 
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: calc(20px + env(safe-area-inset-left)); 
    width: 140px; 
    height: 140px; 
    z-index: 2100;
}

.dpad-btn {
    position: absolute; 
    width: 45px; 
    height: 45px; 
    background: rgba(255, 255, 255, 0.85);
    border: 3px solid var(--laranja); 
    border-radius: 12px; 
    font-size: 1.5rem; 
    color: var(--cinza-escuro);
    display: flex; 
    justify-content: center; 
    align-items: center; 
    user-select: none; 
    touch-action: manipulation;
    box-shadow: 0 4px 0 var(--laranja); 
    transition: 0.1s; 
    font-weight: bold;
}

.dpad-btn:active { 
    transform: translateY(4px); 
    box-shadow: 0 0px 0 var(--laranja); 
    background: var(--laranja); 
    color: white; 
}

.dpad-btn.up { top: 0; left: 47px; }
.dpad-btn.down { bottom: 0; left: 47px; }
.dpad-btn.left { top: 47px; left: 0; }
.dpad-btn.right { top: 47px; right: 0; }

@media (max-width: 768px){
    .dpad-container { display: block; }
}

@media (max-width: 480px){
    header { 
        padding: 10px 15px; 
        flex-direction: column; 
        gap: 10px; 
    }
    .status-header {
        justify-content: center;
        gap: 15px;
    }
    .btn-header { padding: 8px 14px; font-size: 0.85rem;}
    #canvas-container { margin-top: 10px; border-width: 6px; width: min(94vw, 420px); }
    
    .pontos-display, .acertos-display, .recorde-display { font-size: 1.1rem; }
    .display-alvo { font-size: 2.2rem; }
    .progresso-texto { font-size: 1.8rem; }
    .btn-circular { width: 52px; height: 52px; font-size: 1.35rem; }
    .btn-repetir { width: 44px; height: 44px; }
}

@media (max-height: 700px) {
    .menu-caixa { padding: 15px; border-width: 5px; }
    .menu-caixa h1 { font-size: 1.6rem !important; }
    .custom-cobrinha { padding: 8px; margin: 8px 0; }
    .custom-cobrinha h3 { font-size: 0.9rem !important; margin-bottom: 5px; margin-top: 5px !important; }
    .btn-cor { width: 28px; height: 28px; }
    .regras-box { padding: 8px; margin: 8px 0; font-size: 0.8rem; line-height: 1.2; }
    .btn-modo { padding: 8px; font-size: 1.1rem; margin: 5px 0; }
    #canvas-container { margin-top: 5px; border-width: 4px; }
    .game-ui { margin-top: 5px; z-index: 10; }
    .display-alvo { font-size: 1.6rem; }
    .progresso-linha { margin-top: 0px; }
    .progresso-texto { font-size: 1.4rem; background: rgba(255,255,255,0.9); padding: 2px 10px; border-radius: 10px; }
    .btn-repetir { width: 40px; height: 40px; font-size: 1.2rem; }
    .dpad-container { bottom: 5px; left: 5px; transform: scale(0.8); transform-origin: bottom left; }
    .controles-fixos { bottom: 5px; right: 5px; transform: scale(0.8); transform-origin: bottom right; }
}