/* Importar fontes (se não tiver no CSS global) */

:root {
    /* Cores do tema com melhor contraste */
    --primary: #2bd9e2;         
    --primary-light: #86f9ff;   
    --primary-dark: #1aa2a9;    
    --secondary: #9838f8;       
    --secondary-light: #cb96ff; 
    --secondary-dark: #631aab;  
    --tertiary: #FFD166;        
    --tertiary-light: #FFE199;  
    --tertiary-dark: #E5B74D;   
    --accent-1: #6A8EFF;        
    --accent-2: #e8dfff;        
    --accent-3: #FF6B6B;        
    --accent-3-light: #FF9E9E;  
    --accent-3-dark: #E74E4E;   
    /* --feedback-positivo: #41A739; */
    --feedback-positivo-light: #C4F8D3;
    /* --feedback-positivo-dark: #2E7A2E; */
    --feedback-negativo: #E74E4E;
    --feedback-negativo-light: #FFCECE;
    --feedback-negativo-dark: #C73838;
    --neutral-100: #FFFFFF;
    --neutral-200: #F7F7F7;
    --neutral-300: #ECECEC;
    --neutral-400: #E5E5E5;
    --neutral-500: #CCCCCC;
    --neutral-600: #AFAFAF;
    --neutral-700: #666666;
    --neutral-800: #333333;
    --neutral-900: #1A1A1A;
    
    /* Cores específicas do jogo com melhor contraste */
    --card-bg: #FFFFFF;
    --card-border: #E5E5E5;
    --card-shadow: rgba(0, 0, 0, 0.12);
    --text-primary: #1A1A1A;
    --text-secondary: #4A4A4A;
    --success: #41A739;
    --success-light: #C4F8D3;
    --error: #E74E4E;
    --error-light: #FFCECE;
}

/* Estilos base com fontes maiores */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

#mainmemoria {
    width: 100%;
    max-width: 1200px;
    margin: 20px auto 0 auto;
    text-align: center;
    font-size: 20px;
    perspective: 1000px;
    position: relative;
    padding: 0 20px;
}

/* Header do jogo com controles integrados */
.game-header {
    padding: 20px 25px;
    background-color: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 6px 20px var(--card-shadow);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.5s ease-out;
    border: 2px solid var(--neutral-300);
    gap: 20px;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.game-info {
    text-align: left;
    flex: 1;
    min-width: 0; /* Permite que o texto seja truncado se necessário */
}

#enunciado {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0;
    line-height: 1.4;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Contador de pontuação com fonte maior */
.score-counter {
    background: var(--success-light);
    color: var(--success);
    font-weight: 700;
    font-size: 28px;
    padding: 12px 20px;
    margin: 0;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(65, 167, 57, 0.25);
    animation: pulseScore 2s ease-in-out infinite;
    border: 2px solid var(--success);
}

@keyframes pulseScore {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.score-counter.highlight {
    animation: scoreHighlight 0.5s ease-out;
}

@keyframes scoreHighlight {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.score-icon {
    display: flex;
    align-items: center;
}

.score-icon .material-symbols-outlined {
    font-size: 28px;
    color: var(--success);
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 28;
    vertical-align: middle;
}

.score-number {
    display: inline-block;
    vertical-align: middle;
    color: var(--success);
    min-width: 28px;
    text-align: center;
    font-weight: 700;
}

/* Área da mensagem com fonte maior */
.game-message {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#message-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 12px 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    display: none;
    animation: messageAppear 0.3s ease-out;
    line-height: 1.5;
    letter-spacing: 0.3px;
}

@keyframes messageAppear {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#message-text.success {
    display: block;
    color: var(--success);
    background-color: var(--success-light);
    border-left: 4px solid var(--success);
    border: 2px solid var(--success);
}

#message-text.error {
    display: block;
    color: var(--error);
    background-color: var(--error-light);
    border-left: 4px solid var(--error);
    border: 2px solid var(--error);
}

.progress-container {
    height: 8px;
    background-color: var(--neutral-300);
    border-radius: 4px;
    width: 100%;
    max-width: 700px;
    overflow: hidden;
    display: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--success));
    width: 0%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Tabuleiro do jogo com melhor espaçamento */
.memory-board {
    text-align: center;
    margin: 0 auto 25px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 18px;
    perspective: 1000px;
    padding: 20px;
    /* background: var(--neutral-200); */
    border-radius: 20px;
    /* box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.08); */
}

/* Estilos das cartas com proporções melhoradas */
.carta-container {
    perspective: 1000px;
    margin: 8px;
    animation: cardAppear 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes cardAppear {
    to { opacity: 1; transform: translateY(0); }
}

.carta {
    width: 180px;
    height: 240px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    border-radius: 16px;
}

.carta-fundo, 
.carta-content {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    border-radius: 16px;
    overflow: hidden;
}

.carta-fundo {
    background-color: var(--card-bg);
    border: 3px solid var(--card-border);
    box-shadow: 0 6px 16px var(--card-shadow);
    z-index: 2;
    transform: rotateY(0deg);
}

.carta-fundo::before {
    content: '';
    width: calc(100% - 30px);
    height: calc(100% - 30px);
    position: absolute;
    top: 15px;
    left: 15px;
    border-radius: 12px;
    background-image: url(../imgs/fundo.svg);
    background-size: cover;
    background-position: center;
}

.carta-content {
    background-color: var(--card-bg);
    border: 3px solid var(--primary);
    box-shadow: 0 6px 16px var(--card-shadow);
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Virou a carta */
.virada {
    transform: rotateY(180deg);
}

/* Conteúdos da carta com fontes maiores */
.carta-texto {
    width: calc(100% - 30px);
    max-height: calc(100% - 30px);
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
    text-align: center;
    /* padding: 15px; */
    line-height: 1.3;
    letter-spacing: 0.5px;
    hyphens: auto;
}

.carta-imagem {
    width: calc(100% - 30px);
    height: calc(100% - 30px);
    border-radius: 12px;
    background-size: cover !important;
    background-position: center !important;
}

.carta-audio {
    width: 70px;
    height: 70px;
    background: url(../imgs/audio.svg) no-repeat center center;
    background-size: cover;
}

/* Animações de virar carta */
.virando1 {
    transform: rotateY(90deg);
}

.virando2 {
    transform: rotateY(180deg);
}

.virando2 .carta-fundo {
    transform: rotateY(180deg);
}

.virando2 .carta-content {
    transform: rotateY(0deg);
}

.virando3 {
    transform: rotateY(0deg);
}

/* Temporizador visual */
.tempo {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    text-align: left;
    transform: rotateY(180deg);
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.olho {
    width: 24px;
    height: 24px;
    background: url(../imgs/olho.svg);
    background-size: cover;
    display: inline-block;
    vertical-align: top;
}

.olho-anima {
    animation: eyeSpin 3s linear;
}

@keyframes eyeSpin {
    to { transform: rotateZ(360deg); }
}

.tempo-barra {
    height: 6px;
    background: var(--primary-light);
    border-radius: 3px;
    overflow: hidden;
    flex: 1;
}

.tempo-barra::after {
    content: '';
    display: block;
    height: 100%;
    width: 100%;
    background: var(--primary);
    animation: timeBar 3s linear forwards;
}

@keyframes timeBar {
    to { width: 0%; }
}

/* Indicador de acerto com tamanho maior */
.certinho {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: matchPulse 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    pointer-events: none;
    backface-visibility: hidden;
    font-size: 48px;
    color: var(--success);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.9);
}

.certinho::before {
    content: 'check_circle';
    font-family: 'Material Symbols Outlined';
    font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48;
}

@keyframes matchPulse {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Carta estática (par encontrado) com melhor contraste */
.carta-estatica {
    width: 180px;
    height: 240px;
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
    cursor: default;
    animation: cardCompleted 0.8s ease-out;
    pointer-events: none;
    opacity: 0.8;
    filter: brightness(1.1) saturate(0.9);
    border: 4px solid var(--success);
    box-shadow: 0 0 20px rgba(65, 167, 57, 0.4);
    border-radius: 16px;
}

/* Garantir que cartas estáticas sempre mostrem o conteúdo */
.carta-estatica.virada {
    transform: rotateY(180deg) scaleX(-0.95) !important;
}

@keyframes cardCompleted {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(0.95); }
}

/* Badge de completado maior */
.completado-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10;
    animation: badgeAppear 0.5s ease-out 0.5s both;
}

.completado-badge .material-symbols-outlined {
    font-size: 18px;
    font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 18;
}

@keyframes badgeAppear {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(-90deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Efeito de brilho sutil nas cartas completadas */
/* .carta-estatica::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.15) 50%, transparent 70%);
    border-radius: 16px;
    pointer-events: none;
    animation: completedShine 2s ease-in-out infinite;
} */

@keyframes completedShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Controles do jogo integrados ao header */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-shrink: 0;
}

.control-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: var(--neutral-200);
    color: var(--text-primary);
    border: 2px solid var(--neutral-400);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 0 var(--neutral-400);
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.control-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 0 var(--neutral-400);
    background-color: var(--neutral-300);
    border-color: var(--primary);
    color: var(--primary);
}

.control-button:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 var(--neutral-400);
}

/* Modal de ajuda com melhor tipografia */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    max-width: 550px;
    width: 90%;
    position: relative;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease-out;
    border: 2px solid var(--primary);
}

.modal.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.modal-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 18px;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--neutral-600);
    transition: color 0.2s ease;
    font-weight: 700;
}

.close-button:hover {
    color: var(--text-primary);
}

/* Partículas para celebração */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFall 1.5s ease-in forwards;
}

@keyframes particleFall {
    0% { transform: translateY(0); opacity: 0.8; }
    100% { transform: translateY(500px); opacity: 0; }
}

/* Celebração */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 900;
    display: none;
    overflow: hidden;
}

.celebration.show {
    display: block;
}

/* Responsividade melhorada */
@media only screen and (max-width: 768px) {
    #mainmemoria {
        padding: 0 15px;
    }
    
    .game-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 18px 20px;
    }
    
    .game-info {
        text-align: center;
        order: 1;
    }
    
    #enunciado {
        font-size: 20px;
    }
    
    .game-controls {
        order: 2;
        justify-content: center;
        gap: 10px;
    }
    
    .control-button {
        padding: 8px 14px;
        font-size: 15px;
        gap: 5px;
    }
    
    .score-counter {
        align-self: center;
        font-size: 24px;
        padding: 10px 16px;
        order: 3;
    }
    
    .carta-container {
        margin: 6px;
    }
    
    .carta, .carta-estatica {
        width: 140px;
        height: 185px;
    }
    
    .carta-texto {
        font-size: 18px;
        padding: 12px;
    }
    

    
    .completado-badge {
        width: 24px;
        height: 24px;
        top: -8px;
        right: -8px;
    }
    
    .completado-badge .material-symbols-outlined {
        font-size: 16px;
        font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 16;
    }
    
    .memory-board {
        gap: 15px;
        padding: 15px;
    }
    
    #miolo {
        height: initial !important;
        margin-bottom: 40px;
    }
}

/* Para dispositivos muito pequenos */
@media only screen and (max-width: 320px) {
    .game-header {
        padding: 15px;
        gap: 12px;
    }
    
    .carta, .carta-estatica {
        width: 105px;
        height: 140px;
    }
    
    .carta-texto {
        font-size: 16px;
        padding: 10px;
    }
    
    .score-counter {
        font-size: 22px;
        padding: 8px 14px;
    }
    
    #enunciado {
        font-size: 18px;
    }
    
    .control-button {
        padding: 6px 12px;
        font-size: 14px;
        gap: 4px;
    }
    
    .control-button span {
        display: none; /* Mostrar apenas ícones em telas muito pequenas */
    }
    
    .completado-badge {
        width: 20px;
        height: 20px;
        top: -6px;
        right: -6px;
    }
    
    .completado-badge .material-symbols-outlined {
        font-size: 14px;
        font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 14;
    }
}

/* Animações para acessibilidade */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}