/* =========================================
   TETI ARENA - FOLHA DE ESTILOS (V1.0)
   ========================================= */

/* --- 1. DESTAQUE DO BOTÃO NA NAVBAR --- */
.nav-item.center-highlight {
    position: relative;
    top: -20px; /* Faz flutuar para fora da barra */
    overflow: visible;
}

.brain-icon-wrapper {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--teti-primary), #00acc1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 188, 212, 0.4);
    border: 4px solid var(--bg-card); /* Cria o efeito de recorte na barra */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-item.active .brain-icon-wrapper {
    transform: scale(1.1);
    background: linear-gradient(135deg, var(--teti-accent), #c2185b);
    box-shadow: 0 6px 15px rgba(233, 30, 99, 0.5);
}

.brain-icon-wrapper span {
    color: white;
    font-size: 28px;
}

/* --- 2. LAYOUT DO DASHBOARD (ARENA) --- */
#study-arena {
    padding-bottom: 80px; /* Espaço para a navbar */
    background-color: var(--bg-body);
}

.arena-header {
    background: var(--bg-card);
    padding: 10px 10px 2px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.arena-title {
    font-family: 'Labrada', serif;
    font-size: 21px;
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 12px;
}

/* Abas Superiores (Explorar, Meus Materiais, Batalhas) */
.arena-tabs {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    padding: 10px;
}
.arena-tabs::-webkit-scrollbar { display: none; }

.arena-tab-btn {
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    padding-bottom: 8px;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    cursor: pointer;
}

.arena-tab-btn.active {
    color: var(--teti-primary);
    border-bottom-color: var(--teti-primary);
}

/* --- 3. BOTÕES DE AÇÃO RÁPIDA (FAB EXPANDIDO) --- */
.quick-create-container {
    display: flex;
    gap: 12px;
    padding: 16px;
    overflow-x: auto;
}

.create-card {
    min-width: 100px;
    height: 100px;
    background: var(--bg-card);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.1s;
}
.create-card:active { transform: scale(0.95); }

.create-card i, .create-card span.material-icons-round {
    font-size: 28px;
    color: var(--teti-primary);
}

.create-card span.label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

/* --- 4. SEÇÕES DO FEED DE ESTUDOS --- */
.arena-section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 16px 10px 16px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Cards de Materiais (Questões, Flashcards) */
.material-card {
    background: var(--bg-card);
    margin: 0 16px 12px 16px;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    position: relative;
}

.mat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mat-tag {
    background: rgba(0, 188, 212, 0.1);
    color: var(--teti-primary-dark);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.mat-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
}

.mat-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    align-items: center;
}

.mat-stats {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.btn-play-mat {
    position: absolute;
    right: 16px;
    bottom: 16px;
    background: var(--teti-primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* =========================================
   FASE 2: CREATOR STUDIO (MODAL & EDITOR)
   ========================================= */

/* Modal de Tela Cheia */
.arena-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.arena-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.arena-modal-header {
    height: 60px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
}

.arena-modal-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
}

.arena-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Seleção de Fonte (Manual vs IA) */
.source-selection-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.source-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.source-card:active { transform: scale(0.98); }
.source-card.selected { border-color: var(--teti-primary); background: rgba(0, 188, 212, 0.05); }

.source-icon {
    width: 48px; height: 48px;
    background: var(--bg-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--teti-primary);
}

/* Formulário de Editor */
.arena-input-group { margin-bottom: 20px; }
.arena-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; }
.arena-input, .arena-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
}
.arena-textarea { resize: vertical; min-height: 80px; }

/* Builder de Questões */
.question-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    position: relative;
    border-left: 4px solid var(--teti-primary);
}

.q-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.q-number { font-weight: 900; color: var(--teti-primary); }

.alt-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 8px;
}

.alt-top { display: flex; align-items: center; gap: 10px; }
.radio-custom { transform: scale(1.2); cursor: pointer; }

/* Comentário Obrigatório */
.comment-box {
    margin-left: 30px; /* Alinha com o texto da alternativa */
    font-size: 13px;
    padding: 8px;
    border: 1px dashed var(--border-color);
    background: var(--bg-card);
    width: calc(100% - 30px);
}

/* Botões de Ação */
.btn-add-q {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--border-color);
    background: none;
    color: var(--teti-primary);
    font-weight: 700;
    border-radius: 12px;
    margin-bottom: 40px;
    cursor: pointer;
}

.btn-publish {
    background: var(--teti-primary);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    border: none;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s;
}
.btn-publish.ready { opacity: 1; pointer-events: all; cursor: pointer; }

/* --- FASE 3: UPLOAD IA & LOADING --- */
.upload-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    background: var(--bg-hover);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.upload-drop-zone:hover, .upload-drop-zone.dragover {
    border-color: var(--teti-primary);
    background: rgba(0, 188, 212, 0.05);
}

.ai-loading-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}
/* Suporte para Dark Mode no loading */
@media (prefers-color-scheme: dark) {
    .ai-loading-overlay { background: rgba(0, 0, 0, 0.8); }
}

.pulsing-brain {
    font-size: 48px;
    color: var(--teti-primary);
    animation: pulse-brain 1.5s infinite;
    margin-bottom: 16px;
}

@keyframes pulse-brain {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* =========================================
   FASE 3: PLAYER (MODO JOGAR)
   ========================================= */

/* Overlay de Jogo (Fundo) */
.game-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body);
    z-index: 3000; /* Acima de tudo */
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.game-overlay.open { opacity: 1; pointer-events: all; }

/* Barra de Topo do Jogo */
.game-header {
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.game-progress-track {
    flex: 1;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    margin: 0 16px;
    overflow: hidden;
}
.game-progress-fill {
    height: 100%;
    background: var(--teti-primary);
    width: 0%;
    transition: width 0.3s;
}

/* Área da Questão */
.game-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px; /* Limite para não ficar esticado no PC */
    margin: 0 auto;
    width: 100%;
}

.game-question-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Alternativas Jogáveis */
.game-alt-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-size: 15px;
    color: var(--text-main);
}

.game-alt-btn:active { transform: scale(0.98); }

/* Estados da Alternativa */
.game-alt-btn.correct {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
    color: #2e7d32;
}
.game-alt-btn.wrong {
    background: rgba(244, 67, 54, 0.1);
    border-color: #f44336;
    color: #c62828;
}
/* Quando erra, mostra a correta também */
.game-alt-btn.reveal-correct {
    border-color: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

/* Caixa de Comentário/Feedback */
.game-feedback-box {
    margin-top: 20px;
    padding: 16px;
    border-radius: 12px;
    background: var(--bg-hover);
    border-left: 4px solid var(--teti-primary);
    animation: slideUp 0.3s ease;
}
.game-feedback-title { font-weight: 900; margin-bottom: 8px; display: block; }
.game-feedback-text { font-size: 14px; line-height: 1.5; }

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

/* Botão Próximo (Flutuante embaixo) */
.game-footer {
    padding: 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}
.btn-game-next {
    background: var(--text-main);
    color: var(--bg-card);
    padding: 12px 32px;
    border-radius: 30px;
    font-weight: 700;
    border: none;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Tela de Resultado */
.result-container {
    text-align: center;
    padding: 40px 20px;
    animation: fadeIn 0.5s;
}
.result-score { font-size: 64px; font-weight: 900; color: var(--teti-primary); line-height: 1; margin: 20px 0; }
.result-stars { display: flex; justify-content: center; gap: 8px; margin: 30px 0; }
.star-btn { font-size: 32px; color: var(--border-color); cursor: pointer; background: none; border: none; transition: color 0.2s; }
.star-btn.active { color: #ffb74d; }

/* --- CORREÇÃO DE UI DO PLAYER (FASE 4) --- */

/* O jogo deve ficar SOBRE a navbar do rodapé */
.game-overlay {
    z-index: 9999 !important; /* Força ficar acima de tudo */
    padding-bottom: 0; /* Remove padding extra se houver */
}

/* Área de rolagem com espaço para não esconder o botão atrás do footer */
.game-body {
    padding-bottom: 100px !important; /* Garante que o conteúdo não fique atrás do botão Próxima */
}

/* Footer do jogo fixo e visível */
.game-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom)); /* Respeita iPhones novos */
    z-index: 10000;
}

/* Melhoria na visualização dos Comentários Detalhados */
.game-feedback-box {
    margin-top: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--teti-primary);
    border-radius: 8px;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.feedback-header {
    padding: 12px 16px;
    background: var(--bg-hover);
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
}

.alt-explanation-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-color);
}
.alt-explanation-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.expl-letter { font-weight: 700; margin-right: 6px; }
.expl-correct { color: #2e7d32; }
.expl-wrong { color: #c62828; }

/* --- PLAYER V2: ALTERNATIVAS COM EXPANSÃO --- */

.game-alt-btn {
    display: flex;
    flex-direction: column; /* Muda para coluna para aceitar o comentário embaixo */
    align-items: flex-start;
    width: 100%;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    position: relative;
}

/* O conteúdo principal (Letra + Texto) */
.alt-main-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    font-size: 15px;
    color: var(--text-main);
    line-height: 1.5;
}

/* A área de explicação (Oculta por padrão) */
.alt-explanation-content {
    display: none; /* Escondido */
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(0,0,0,0.1);
    font-size: 13px;
    color: var(--text-main);
    width: 100%;
    animation: fadeIn 0.3s;
}

/* Quando revelado */
.game-alt-btn.show-feedback .alt-explanation-content {
    display: block;
}

/* Estilos de Estado */
.game-alt-btn.correct {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
}
.game-alt-btn.wrong {
    background: rgba(244, 67, 54, 0.1);
    border-color: #f44336;
}
/* Estilo para a correta quando o usuário erra (Mostra borda verde) */
.game-alt-btn.reveal-correct {
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Badge de Certo/Errado dentro da explicação */
.expl-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 4px;
    text-transform: uppercase;
}
.expl-badge.c { background: #e8f5e9; color: #2e7d32; }
.expl-badge.e { background: #ffebee; color: #c62828; }

/* --- FASE 5: RANKINGS E ESCASSEZ --- */

/* Badge de "Concluído" no Card */
.mat-completed-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(76, 175, 80, 0.9);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 5;
}

/* Botão de Ranking no Card (Pequeno troféu) */
.btn-card-rank {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 8px; /* Espaço para o botão Play */
}
.btn-card-rank:active { transform: scale(0.9); }

/* Container de Ações no Rodapé do Card */
.mat-actions {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
}

/* =========================================
   MODAL DE RANKING (CORRIGIDO)
   ========================================= */

.ranking-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Fundo um pouco mais escuro */
    z-index: 5000;
    display: flex;
    align-items: flex-end; /* Mobile: vem de baixo */
    opacity: 0; 
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}
.ranking-modal-overlay.open { opacity: 1; pointer-events: all; }

.ranking-sheet {
    background: var(--bg-card);
    width: 100%;
    max-height: 70vh; /* Limita a altura a 85% da tela */
    height: auto;     /* Altura automática baseada no conteúdo */
    border-radius: 24px 24px 0 0;
    padding: 0;       /* Remove padding do container pai */
    display: flex;
    flex-direction: column;
    animation: slideUpModal 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    overflow: hidden; /* Garante que filhos não vazem as bordas arredondadas */
}

/* Header do Modal (Fixo) */
.ranking-header-area {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    flex-shrink: 0; /* Não encolhe */
}

/* Corpo da Lista (Rolagem) */
#internal-ranking-body {
    flex: 1; 
    overflow-y: auto; /* Cria a barra de rolagem quando atinge o limite do pai */
    
    padding: 10px 0 50px 0; 
    min-height: 0; 
    
    /* IMPORTANTE: Impede que o scroll "vaze" para a página de trás */
    overscroll-behavior: contain; 
    
    /* Scroll suave no iOS */
    -webkit-overflow-scrolling: touch;

    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

#internal-ranking-body::-webkit-scrollbar { width: 6px; }
#internal-ranking-body::-webkit-scrollbar-thumb { 
    background-color: var(--border-color); 
    border-radius: 3px; 
}

/* Ajustes Desktop */
@media (min-width: 768px) {
    .ranking-modal-overlay { align-items: center; justify-content: center; }
    .ranking-sheet { 
        width: 480px; 
        border-radius: 24px; 
        max-height: 80vh;
        box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    }
}

@keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Lista do Ranking */
.rank-row {
    display: flex;
    align-items: center;
    padding: 12px 12px;
    border-bottom: 1px solid var(--border-color);
}
.rank-pos { width: 30px; font-weight: 900; font-size: 16px; color: var(--text-muted); text-align: center; }
.rank-pos.top-1 { color: #FFD700; font-size: 20px; } /* Ouro */
.rank-pos.top-2 { color: #C0C0C0; font-size: 18px; } /* Prata */
.rank-pos.top-3 { color: #CD7F32; font-size: 18px; } /* Bronze */

.rank-user-info { flex: 1; margin-left: 10px; }
.rank-name { font-weight: 700; font-size: 14px; color: var(--text-main); }
.rank-meta { font-size: 11px; color: var(--text-muted); }

.rank-score-box { text-align: right; }
.rank-points { font-weight: 900; color: var(--teti-primary); font-size: 15px; }
.rank-time { font-size: 10px; color: var(--text-muted); }

/* Botão Banco de Erros */
.btn-error-bank {
    background: #ffebee;
    color: #c62828;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin: 10px 16px;
}

/* Correção de Layout do Card */
.mat-actions {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px; /* Espaço entre os botões */
    z-index: 10;
}

/* Ajuste dos botões redondos */
.btn-card-rank, .btn-play-mat, .btn-delete-mat {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: transform 0.1s;
}
.btn-play-mat {
    background: var(--teti-primary);
    color: white;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.btn-delete-mat {
    color: #f44336;
    border-color: #ffcdd2;
    background: #ffebee;
}
.btn-card-rank:active, .btn-play-mat:active, .btn-delete-mat:active { 
    transform: scale(0.95); 
}

/* Estatísticas mais limpas */
.mat-stats {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px; /* Fonte menor para caber */
}

/* =========================================
   CARDS DE MATERIAL (CORREÇÃO DE LAYOUT)
   ========================================= */

.material-card {
    background: var(--bg-card);
    margin: 0 16px 12px 16px;
    border-radius: 12px;
    padding: 16px;
    /* RESERVA ESPAÇO PARA OS BOTÕES NO RODAPÉ NÃO FICAREM EM CIMA DO TEXTO */
    padding-bottom: 60px; 
    border: 1px solid var(--border-color);
    position: relative;
    transition: transform 0.1s;
}

.mat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mat-tag {
    background: rgba(0, 188, 212, 0.1);
    color: var(--teti-primary-dark);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.mat-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
    line-height: 1.3;
}

.mat-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Stats (Estrelas, Plays) */
.mat-stats {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Badge "Feito" */
.mat-completed-badge {
    position: absolute;
    top: -8px; /* Flutua um pouco pra fora */
    right: 12px;
    background: #4caf50;
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 5;
}

/* --- BOTÕES DE AÇÃO (FIXED) --- */
.mat-actions {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px; /* Garante separação entre os botões */
    z-index: 10;
}

.btn-card-action {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-card-action:active { transform: scale(0.9); }

/* Cores específicas */
.btn-action-play {
    background: var(--teti-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 188, 212, 0.3);
}

.btn-action-delete {
    background: #ffebee;
    color: #f44336;
    border-color: #ffcdd2;
}

.btn-action-rank {
    color: var(--text-muted);
}

.btn-action-disabled {
    background: #e0e0e0;
    color: #9e9e9e;
    cursor: not-allowed;
    border: none;
}

/* Badge de Certo/Errado dentro da explicação */
.expl-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 10px;
    margin-bottom: 6px;
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.expl-badge.c { 
    background: #e8f5e9; 
    color: #2e7d32; 
    border: 1px solid #a5d6a7;
}
.expl-badge.e { 
    background: #ffebee; 
    color: #c62828; 
    border: 1px solid #ef9a9a;
}

/* Ajuste para o texto da explicação não colar na badge */
.alt-explanation-content {
    display: none;
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-hover); /* Fundo sutil para separar da alternativa */
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-main);
    width: 100%;
    line-height: 1.5;
    animation: fadeIn 0.3s;
}

/* Destaque para os Pontos na Tela Final */
.result-points-text {
    margin-top: 10px;
    font-size: 16px;
    font-weight: 800;
    color: var(--teti-primary);
    background: rgba(0, 188, 212, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
}

/* --- MELHORIA 1: BANCO DE ERROS (BADGE ESTILOSO) --- */
.error-bank-container {
    display: flex;
    justify-content: flex-end;
    padding: 10px 16px 0 16px;
}

.btn-error-bank-pill {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.btn-error-bank-pill:active { transform: scale(0.95); }
.btn-error-bank-pill:hover { background: #ffcdd2; }

.error-count-badge {
    background: #c62828;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* --- MELHORIA 2: AUTOR NO CARD --- */
.mat-author-info {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    max-width: 50%; /* Não invadir os botões de ação */
}

.mat-author-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.mat-author-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- MELHORIA 3: AVATAR NO RANKING INTERNO --- */
.rank-avatar-internal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-left: 10px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

/* --- FASE 4: FONTES DE BANCO DE DADOS --- */
.source-icon.it { background: linear-gradient(135deg, #2196f3, #1976d2); color: white; }
.source-icon.news { background: linear-gradient(135deg, #ff9800, #f57c00); color: white; }

/* Ajuste para selects específicos */
.arena-select-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* --- NOVOS ESTILOS: METADADOS DO CARD (FONTE & DIFICULDADE) --- */

/* Badge da Fonte (Pequeno ícone ao lado do tipo) */
.mat-source-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 22px; /* Mesma altura visual da tag de tipo */
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    cursor: help;
}

/* Badge de Dificuldade (Canto Superior Direito) */
.mat-diff-dot {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: fit-content;
}

/* Cores da Dificuldade */
.diff-norm   { background: #eceff1; color: #546e7a; } /* Padrão/Cinza */
.diff-easy   { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; } /* Verde */
.diff-med    { background: #fff3e0; color: #ef6c00; border: 1px solid #ffe0b2; } /* Laranja */
.diff-hard   { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; } /* Vermelho */
.diff-expert { background: #f3e5f5; color: #7b1fa2; border: 1px solid #e1bee7; box-shadow: 0 2px 5px rgba(123, 31, 162, 0.15); } /* Roxo */

/* Ajuste no Header para alinhar tudo */
.mat-header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Centraliza verticalmente */
    margin-bottom: 8px;
}

/* --- FILTROS E BUSCA (UI/UX) --- */

/* Botão de Filtro no Header */
.btn-filter-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%; /* Redondo para ficar moderno */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.btn-filter-toggle.active {
    background: var(--teti-primary);
    color: white;
    border-color: var(--teti-primary);
    box-shadow: 0 4px 10px rgba(0, 188, 212, 0.3);
}

/* Indicador de "Filtros Ativos" (Bolinha vermelha) */
.filter-badge-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #ff5252;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    display: none;
}
.btn-filter-toggle.active .filter-badge-indicator { display: block; }

/* Grid de Chips no Modal */
.filter-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin: 16px 0 8px 0;
    text-transform: uppercase;
}

.filter-chips-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-chip:active { transform: scale(0.95); }

/* Estados Selecionados */
.filter-chip.selected {
    background: rgba(0, 188, 212, 0.1);
    color: var(--teti-primary-dark);
    border-color: var(--teti-primary);
    font-weight: 600;
}

/* Chips Específicos para Avaliação (Estrelas) */
.filter-chip.star-chip { color: #ffb74d; background: #fff3e0; }
.filter-chip.star-chip.selected { background: #ffb74d; color: white; border-color: #ffa726; }

/* Input de Busca de Criador */
.creator-search-box {
    display: flex;
    align-items: center;
    background: var(--bg-hover);
    padding: 0 12px;
    border-radius: 12px;
    margin-top: 8px;
    border: 1px solid var(--border-color);
}
.creator-search-input {
    flex: 1;
    border: none;
    background: none;
    padding: 12px 0;
    outline: none;
    font-size: 14px;
    color: var(--text-main);
}

.filter-footer {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    margin-bottom: 70px;
    border-top: 1px solid var(--border-color);
}