/* ================== RESET BÁSICO ================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove o irritante flash azul/cinza em botões ao tocar no mobile */
}

:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --secondary: #3b82f6;
    --secondary-hover: #2563eb;
    
    --danger: #ef4444;
    --success: #22c55e;
    
    --font-main: 'Poppins', sans-serif;
}

body {
    font-family: var(--font-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at top right, #1e1b4b, var(--bg-dark));
    user-select: none; /* Bloqueia o usuário de selecionar texto acidentalmente clicando rápido demais no jogo */
}

#app-container {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ================== GERENCIAMENTO DE TELAS ================== */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-card);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 2px 0 rgba(255,255,255,0.05);
    text-align: center;
    
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    position: absolute;
    /* Redefinido no media query */
}

.screen.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
    visibility: hidden;
    pointer-events: none;
}

/* ================== TIPOGRAFIA ================== */
h1.logo {
    color: var(--primary);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
}

h2 {
    margin-bottom: 10px;
    font-weight: 600;
}

.highlight-text {
    color: var(--primary);
    font-weight: bold;
}

/* ================== INPUTS & BOTÕES ================== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

.input-label {
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    margin-bottom: -5px;
}

input[type="text"] {
    width: 100%;
    border-radius: 12px;
    border: 2px solid #334155;
    background-color: var(--bg-dark);
    color: white;
    font-family: inherit;
    text-align: center;
    transition: border-color 0.3s, box-shadow 0.3s;
    user-select: auto; /* Reativa a seleção estritamente dentro da caixa de digitação */
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.btn {
    font-weight: 800;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s ease;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:active:not(:disabled) {
    transform: scale(0.96);
}

.btn-primary {
    background-color: var(--primary);
    color: #1e293b;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.btn-secondary {
    background-color: var(--secondary);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 10px;
    box-shadow: none;
}

.btn-text:hover {
    color: white;
}

/* ================== GRIDS ================== */
.categories-grid, .options-grid {
    display: grid;
    width: 100%;
}

.btn-category, .btn-option {
    background-color: #334155;
    color: white;
    border-radius: 16px;
    font-weight: 600;
    border: 2px solid transparent;
    text-transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-category:hover, .btn-option:hover {
    background-color: #475569;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

/* ================== TELA DE JOGO ================== */
.game-header {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: var(--bg-dark);
    border-radius: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.stat.progress {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    letter-spacing: 2px;
    font-weight: 800;
}

.stat {
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat.timer {
    color: var(--danger);
    transition: transform 0.1s ease;
}

.timer-anim {
    animation: pulseTimer 1s infinite;
}

@keyframes pulseTimer {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); color: #ff0000; }
    100% { transform: scale(1); }
}

/* ================== DESIGN DA CARTA CENTRAL ================== */
.card-container {
    width: 100%;
    position: relative;
    aspect-ratio: 3 / 4; 
    background-image: url('assets/images/card-bg.jpg');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 20px rgba(168, 85, 247, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-category-field {
    position: absolute;
    top: 13%; /* Subindo levemente para o centro perfeito do banner */
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    text-align: center;
    color: #fff;
    font-size: 1.15rem; /* Aumentando a fonte */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(168, 85, 247, 0.8);
}

.card-question-field {
    position: absolute;
    top: 29%; /* Descendo levemente para respeitar o topo da borda interna */
    left: 50%;
    transform: translateX(-50%);
    width: 70%; /* Largura restrita para evitar vazar as laterais do fluido roxo */
    height: 44%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

#question-text {
    line-height: 1.3;
    color: #fff;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 1);
    word-break: break-word;
}

/* ================== TELA DE FIM DE JOGO ================== */
.gameover-title {
    color: var(--danger);
    font-weight: 800;
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.highlight-score {
    color: var(--primary);
    font-weight: 800;
    display: block;
    margin-top: 10px;
}

.ranking-container {
    background-color: var(--bg-dark);
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
}

.ranking-container h3 {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #334155;
}

#ranking-list {
    list-style: none;
    text-align: left;
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--text-main);
}

#ranking-list li:first-child {
    color: var(--primary);
    font-weight: 800;
}

/* ================== EFEITOS ESPECIAIS ================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #0f172a;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--primary);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--primary);
}

.btn-option.correct {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.7) !important;
    animation: correctPulse 0.4s ease;
    color: white;
}

.btn-option.wrong {
    background-color: var(--danger) !important;
    border-color: var(--danger) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.7) !important;
    animation: shake 0.4s ease;
    color: white;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    width: 10px;
    height: 10px;
    animation: floatUp 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    z-index: 100;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-120px) scale(0); opacity: 0; }
}


/* =======================================================
   RESPONSIVIDADE RIGOROSA (DESKTOP, NOTEBOOK, CELULAR)
   ======================================================= */

/* DESKTOP (1920x1080px e telas grandes >= 1367px) */
@media (min-width: 1367px) {
    #app-container {
        max-width: 800px;
        padding: 40px;
    }
    .screen {
        top: 40px; bottom: 40px; left: 40px; right: 40px;
        padding: 40px;
    }
    h1.logo { font-size: 3.5rem; }
    .subtitle { font-size: 1.3rem; }
    h2 { font-size: 2.2rem; }
    
    .input-group { gap: 20px; }
    input[type="text"] { padding: 22px; font-size: 1.4rem; }
    .btn { padding: 22px 30px; font-size: 1.3rem; }
    .input-label { font-size: 1.2rem; }
    
    .categories-grid, .options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-top: 30px;
    }
    .btn-category { padding: 25px 15px; font-size: 1.3rem; }
    .btn-option { padding: 20px 15px; font-size: 1.1rem; }
    
    .game-header { padding: 20px 30px; margin-bottom: 20px; }
    .stat.progress { font-size: 1.1rem; padding-bottom: 15px; }
    .stat { font-size: 1.4rem; }
    
    .card-container { max-width: 380px; min-height: 450px; margin: 15px auto; }
    .card-category-field { font-size: 1.3rem; }
    #question-text { font-size: 1.5rem; }
    
    .gameover-title { font-size: 4rem; }
    .highlight-score { font-size: 4.5rem; }
    .ranking-container { padding: 30px; margin: 30px 0; }
}

/* NOTEBOOK (1366x768px e similares, 768px a 1366px) */
@media (min-width: 768px) and (max-width: 1366px) {
    #app-container {
        max-width: 600px;
        padding: 20px;
    }
    .screen {
        top: 20px; bottom: 20px; left: 20px; right: 20px;
        padding: 25px;
    }
    h1.logo { font-size: 2.8rem; }
    .subtitle { font-size: 1.1rem; }
    h2 { font-size: 1.8rem; }
    
    .input-group { gap: 15px; }
    input[type="text"] { padding: 18px; font-size: 1.2rem; }
    .btn { padding: 16px 24px; font-size: 1.1rem; }
    .input-label { font-size: 1.1rem; }
    
    .categories-grid, .options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-top: 20px;
    }
    .btn-category { padding: 20px 10px; font-size: 1.1rem; }
    .btn-option { padding: 15px 10px; font-size: 1rem; }
    
    .game-header { padding: 15px 20px; margin-bottom: 10px; }
    .stat.progress { font-size: 0.95rem; padding-bottom: 10px; }
    .stat { font-size: 1.1rem; }
    
    .card-container { max-width: 280px; min-height: 350px; margin: 5px auto; }
    .card-category-field { font-size: 1.05rem; }
    #question-text { font-size: 1.2rem; }
    
    .gameover-title { font-size: 3rem; }
    .highlight-score { font-size: 3.5rem; }
    .ranking-container { padding: 20px; margin: 20px 0; }
}

/* CELULAR VERTICAL (390x844px e menores, até 767px) */
@media (max-width: 767px) {
    #app-container {
        max-width: 100%;
        padding: 5px;
    }
    .screen {
        top: 5px; bottom: 5px; left: 5px; right: 5px;
        padding: 15px 10px;
        border-radius: 18px;
    }
    h1.logo { font-size: 2.2rem; margin-bottom: 10px; }
    .subtitle { font-size: 0.95rem; margin-bottom: 25px; }
    h2 { font-size: 1.5rem; }
    
    .input-group { gap: 12px; max-width: 100%; }
    input[type="text"] { padding: 15px; font-size: 1.1rem; border-radius: 10px; }
    
    /* Botões otimizados para touch em celular (min-height garantido e mais padding) */
    .btn { padding: 18px 20px; font-size: 1.1rem; min-height: 55px; border-radius: 10px; }
    .input-label { font-size: 1rem; }
    
    /* Pilha vertical nas categorias e alternativas para facilitar toque sem esbarrar nas outras */
    .categories-grid, .options-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 15px;
    }
    .btn-category { padding: 15px 10px; font-size: 1.05rem; min-height: 60px; }
    .btn-option { padding: 15px 10px; font-size: 0.95rem; text-align: center; min-height: 55px; }
    
    .game-header { padding: 8px 12px; margin-bottom: 5px; border-radius: 12px; }
    .stat.progress { font-size: 0.8rem; padding-bottom: 5px; }
    .stat-row { margin-top: 3px; }
    .stat { font-size: 0.9rem; }
    
    /* A carta é reduzida estrategicamente para não jogar as alternativas para fora da tela de 844px */
    .card-container { max-width: 200px; min-height: 250px; margin: 0 auto; }
    .card-category-field { font-size: 0.85rem; top: 13%; width: 65%; }
    .card-question-field { top: 29%; height: 44%; width: 70%; }
    #question-text { font-size: 0.95rem; line-height: 1.3; word-break: break-word; }
    
    .gameover-title { font-size: 2.2rem; }
    .highlight-score { font-size: 2.8rem; margin-top: 5px; }
    .ranking-container { padding: 15px; margin: 15px 0; }
    .ranking-container h3 { font-size: 0.9rem; padding-bottom: 5px; margin-bottom: 10px; }
    #ranking-list li { padding: 8px 0; font-size: 0.9rem; }
}
