/* styles.css - Repaginada Moderna */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Press+Start+2P&display=swap');

:root {
    /* Dimensões do Card */
    --card-size: 120px;
    --card-gap: 10px;

    /* Cores Primária e Secundária (Tons Modernos) */
    --primary-color: #4f46e5; /* Indigo Moderno */
    --primary-light: #818cf8;
    --primary-dark: #4338ca;
    --secondary-color: #10b981; /* Verde Moderno */
    --accent-color: #f59e0b;   /* Âmbar como destaque */

    /* Fundos */
    --background-light: #f9fafb;
    --background-lighter: #ffffff;
    --background-dark: #1f2937;
    --background-darker: #111827;
    --sidebar-bg: #ffffff;
    --sidebar-bg-dark: #374151;

    /* Textos */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #d1d5db;
    --text-dark: #f9fafb;

    /* Outros */
    --sidebar-width: 250px;
    --border-radius: 16px; /* Bordas mais arredondadas */
    --transition-speed: 0.3s;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-light);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1rem;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

body.dark-mode {
    background-color: var(--background-dark);
    color: var(--text-light);
}

/* Layout Principal */
.game-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 2rem);
}

/* Painel de Controle */
.control-panel {
    background: var(--sidebar-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    height: 100%;
    overflow-y: auto; /* Permitir rolagem se o conteúdo for muito longo */
}

.dark-mode .control-panel {
    background: var(--sidebar-bg-dark);
    box-shadow: var(--shadow-lg);
}

/* Cabeçalho do Jogo */
.game-header {
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb; /* Cor suave */
}

.dark-mode .game-header {
    border-bottom-color: #4b5563;
}

.game-header h1 {
    font-size: 1.4rem; /* Um pouco maior */
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    letter-spacing: 0.5px; /* Espaçamento entre letras opcional */
}

/* Timer */
.timer-container {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1); /* Fundo sutil */
    border-radius: 8px;
}

.dark-mode .timer-container {
     background: rgba(0, 0, 0, 0.2);
 }

.timer-container.show {
    display: flex;
}

.timer {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.1rem;
    color: var(--primary-color);
    background-color: var(--background-lighter);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.dark-mode .timer {
    background-color: var(--background-darker);
    color: var(--text-dark);
}

/* Animação de Piscar do Timer */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.timer.blink {
    animation: blink 1s infinite;
}

/* Seções do Painel */
.panel-section {
    padding: 0.8rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.dark-mode .panel-section {
    border-bottom-color: #4b5563;
}

.panel-section:last-child {
    border-bottom: none;
    margin-top: auto; /* Empurra para baixo */
}

.panel-section h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Seleção de Tema */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.theme-btn {
    aspect-ratio: 1;
    border: 2px solid transparent; /* Borda inicial transparente */
    border-radius: 8px;
    background: #f9fafb; /* Fundo padrão */
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    padding: 0.5rem;
    box-shadow: var(--shadow-sm); /* Sombra leve */
}

.theme-btn img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.theme-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-light); /* Borda ao passar o mouse */
    transform: translateY(-2px);
    box-shadow: var(--shadow-md); /* Sombra maior ao passar */
}

.theme-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

/* Seletores de Configuração */
.config-select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background: white;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: border-color var(--transition-speed) ease;
}

.config-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); /* Focus ring */
}

.dark-mode .config-select {
    background: #4b5563;
    border-color: #6b7280;
    color: white;
}

.dark-mode .config-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

/* Cartões dos Jogadores */
.players {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.player-card {
    background: #f3f4f6; /* Fundo padrão */
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    transition: all var(--transition-speed) ease;
    display: block;
    border: 2px solid transparent; /* Borda inicial */
    box-shadow: var(--shadow-sm);
}

.player-card.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-light);
    transform: scale(1.02); /* Leve aumento quando ativo */
    box-shadow: var(--shadow-md);
}

.dark-mode .player-card {
    background: #4b5563;
    color: #e5e7eb;
}

.dark-mode .player-card.active {
    background: var(--primary-dark);
    border-color: var(--primary-light);
}

.player-card i {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.score {
    font-size: 1.2rem;
    font-weight: 700; /* Mais negrito */
}

.player-label {
    font-size: 0.85rem;
    margin-top: 0.2rem;
    opacity: 0.9;
}

/* Botões de Controle */
.button-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap; /* Permitir quebra de linha se necessário */
}

.icon-btn {
    width: 44px; /* Ligeiramente maior */
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
    font-size: 1.1rem; /* Ligeiramente maior */
    box-shadow: var(--shadow-sm);
}

.icon-btn img {
    max-width: 70%; /* Ajuste do tamanho da imagem */
    max-height: 70%;
    display: block;
}

.icon-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md); /* Sombra maior ao passar */
}

.dark-mode .icon-btn {
    background: #4b5563;
    color: #e5e7eb;
}

/* Tabuleiro */
.game-board {
    background: var(--background-lighter);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: repeat(auto-fit, var(--card-size));
    gap: var(--card-gap);
    align-content: center;
    justify-content: center;
    height: fit-content;
    margin: auto;
    overflow: auto;
    max-height: 100%;
}

.dark-mode .game-board {
    background: var(--background-darker);
}

/* Cartas */
.card {
    width: var(--card-size);
    height: var(--card-size);
    position: relative;
    transform-style: preserve-3d;
    transition: transform var(--transition-speed) ease;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 10px; /* Bordas mais arredondadas */
    box-shadow: var(--shadow-md);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.correct {
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); /* Brilho verde */
}

.card.wrong {
    border-color: #ef4444; /* Vermelho */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); /* Brilho vermelho */
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px; /* Internamente */
    background-color: white;
    overflow: hidden;
}

.card-front {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light)); /* Gradiente moderno */
    color: white;
    font-size: 2.5rem; /* Maior símbolo ? */
    font-weight: bold;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1); /* Sombra interna sutil */
}

.card-back {
    transform: rotateY(180deg);
    padding: 5px;
    background-color: var(--background-lighter);
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* --- MODAIS --- */
/* Estilo base para todos os modais */
.modal {
    display: none; /* Oculto por padrão */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Fundo escuro semi-transparente */
    backdrop-filter: blur(4px); /* Efeito de vidro fosco (opcional, melhora aparência) */
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Garante que fique acima de todos os outros elementos */
    opacity: 0; /* Começa invisível */
    transition: opacity var(--transition-speed) ease; /* Transição suave para fade-in/out */
}

/* Mostra o modal quando a classe 'show' é adicionada */
.modal.show {
    display: flex; /* Usa flexbox para centralizar */
    opacity: 1; /* Torna visível */
    animation: fadeIn 0.3s ease-out; /* Animação de entrada */
}

/* Conteúdo interno do modal */
.modal-content {
    background: var(--background-lighter, white); /* Usa variável ou branco padrão */
    padding: 2rem;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    position: relative; /* Permite posicionamento absoluto do botão de fechar */
    transform: scale(0.9); /* Começa menor */
    opacity: 0; /* Começa invisível */
    animation: modalPop 0.3s ease-out forwards; /* Animação de "pop-in" */
    box-shadow: var(--shadow-lg); /* Sombra para destaque */
    max-height: 90vh; /* Limita a altura */
    overflow-y: auto; /* Permite rolagem se o conteúdo for muito longo */
}

/* Estilo para o conteúdo do modal no modo escuro */
.dark-mode .modal-content {
    background: var(--background-darker, #2d3748); /* Usa variável ou cor escura padrão */
    color: var(--text-light, #fff); /* Usa variável ou branco padrão */
}

/* Botão de fechar (X) */
.btn-close {
    position: absolute;
    top: 1rem; /* Distância do topo */
    right: 1rem; /* Distância da direita */
    background: none;
    border: none;
    font-size: 1.5rem; /* Tamanho do ícone X */
    cursor: pointer;
    color: inherit; /* Herda a cor do texto */
    opacity: 0.7; /* Um pouco transparente */
    transition: opacity var(--transition-speed) ease; /* Transição suave */
    z-index: 1001; /* Garante que o botão de fechar fique acima do conteúdo */
}

.btn-close:hover {
    opacity: 1; /* Fica opaco ao passar o mouse */
}

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Estilos específicos para o conteúdo dentro dos modais */
.victory-content {
    text-align: center;
    padding: 1rem; /* Ajuste de padding */
}

.victory-header h3 {
    font-family: 'Press Start 2P', cursive;
    color: var(--primary-color);
    font-size: 1.4rem; /* Tamanho ajustado */
    margin-bottom: 1rem;
}

.victory-message {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--text-secondary, #666); /* Usa variável ou cor padrão */
}

.dark-mode .victory-message {
    color: var(--text-light, #fff); /* Cor no modo escuro */
}

.victory-scores {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f3f4f6; /* Fundo sutil */
    border-radius: 8px;
}

.dark-mode .victory-scores {
    background: #4b5563; /* Fundo sutil no modo escuro */
}

.victory-scores .player-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: 6px;
    background: white; /* Fundo do item */
    font-size: 1rem;
}

.dark-mode .victory-scores .player-score {
    background: #374151; /* Fundo do item no modo escuro */
}

.victory-scores .player-score.winner {
    background: var(--primary-color); /* Destaque para o vencedor */
    color: white;
    font-weight: 600;
}

/* Estatísticas */
.victory-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Duas colunas */
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-item h3 {
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.5rem;
}

.dark-mode .stat-item h3 {
    color: #cbd5e0; /* Cor no modo escuro */
}

.stat-value {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.3rem; /* Tamanho ajustado */
    color: var(--primary-color);
}

/* Botões dentro dos modais */
.victory-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem; /* Espaçamento entre botões */
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.9rem 1.8rem; /* Padding ajustado */
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-weight: 500;
    flex: 1; /* Botões ocupam espaço igual */
    max-width: 200px; /* Limita largura máxima */
}

.primary-btn:hover {
    background: var(--primary-dark, #2563eb); /* Usa variável ou cor escura padrão */
    transform: translateY(-2px);
    box-shadow: var(--shadow-md); /* Sombra ao passar o mouse */
}

/* Estilos para o modal de compartilhamento */
.share-options {
    display: flex;
    flex-direction: column; /* Organiza botões em coluna */
    gap: 10px; /* Espaçamento entre botões */
    margin: 1.5rem 0; /* Margem acima e abaixo */
}

.share-options .primary-btn {
    max-width: 100%; /* Botões ocupam toda a largura disponível */
}

/* --- RESPONSIVIDADE --- */
@media (max-width: 1200px) {
    :root {
        --card-size: 100px;
        --card-gap: 8px;
    }
}

@media (max-width: 768px) {
    .game-container {
        grid-template-columns: 1fr;
        height: auto;
        gap: 1rem;
        max-height: 100vh;
        overflow-y: auto;
    }

    .control-panel {
        height: auto;
        order: 2;
        padding: 1rem;
    }

    .game-board {
        order: 1;
        height: auto;
        max-height: 50vh; /* Reduzido para dar espaço no celular */
        padding: 1rem;
    }

    :root {
        --card-size: min(80px, 20vw);
        --card-gap: 6px;
        --sidebar-width: auto; /* Flexibilidade na largura do sidebar */
    }

    .theme-selector {
        grid-template-columns: repeat(4, 1fr);
    }

    .victory-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .button-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .game-header h1 {
        font-size: 1.1rem;
    }

    .modal-content {
        max-width: 95%;
        padding: 1.5rem;
    }

    .primary-btn {
        padding: 0.8rem 1.2rem;
        font-size: 0.95rem;
        max-width: 100%; /* Botão ocupa toda a largura em mobile */
    }
}

@media (max-width: 480px) {
    :root {
        --card-size: min(65px, 22vw); /* Um pouco maior para melhor toque */
        --card-gap: 5px;
    }

    .theme-selector {
        grid-template-columns: repeat(3, 1fr); /* Menos colunas */
    }

    .game-board {
        padding: 0.75rem;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .game-header h1 {
        font-size: 1rem;
    }

    .modal-content {
        padding: 1.25rem;
        width: 95%;
    }

    .victory-content {
        padding: 1rem;
    }

    .victory-header h3 {
        font-size: 1.1rem;
        margin-bottom: 0.8rem;
    }

    .victory-message {
        font-size: 0.95rem;
    }

    .panel-section h3 {
        font-size: 0.9rem;
    }

    .config-select {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
}

/* Ajuste para dispositivos em paisagem com altura limitada */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        grid-template-columns: 180px 1fr;
        gap: 0.5rem;
    }
    :root {
        --sidebar-width: 180px;
        --card-size: min(60px, 15vh);
    }

    .game-board {
        max-height: 85vh;
    }

    .control-panel {
        font-size: 0.9rem;
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .panel-section {
        padding: 0.5rem 0;
    }
}