/* ===== RESET E BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Comic Sans MS', 'Chalkboard SE', cursive, sans-serif;
    min-height: 100vh;
    background: #3A86FF;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

body::before {
    content: '½ ⅓ ¼ ⅕ ⅙ ⅛ ⅔ ¾ ⅖';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 5rem;
    color: rgba(255, 255, 255, 0.08);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    pointer-events: none;
    z-index: 0;
    transform: rotate(-5deg) scale(1.1);
}

#app {
    position: relative;
    z-index: 1;
    background: #B8F2E6;
    padding: 30px;
    border-radius: 40px;
    width: 95%;
    max-width: 1200px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    min-height: 85vh;
}

h1 {
    color: #C1121F;
    font-size: 2.8rem;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(193, 18, 31, 0.1);
}

/* ===== MENU ===== */
#menu {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 30px;
    margin-bottom: 20px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.config-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1e293b;
    font-weight: 600;
}

.config-group label {
    font-size: 0.95rem;
    color: #1e293b;
}

.config-group select,
.config-group input {
    padding: 10px 16px;
    border-radius: 12px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    background: white;
    color: #1e293b;
    font-size: 1rem;
}

.config-group input[type="number"] { width: 70px; }
#input-sala { width: 160px; }

/* ===== BOTÕES ===== */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

button:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(145deg, #f97316, #ea580c);
    color: white;
}
.btn-secondary {
    background: linear-gradient(145deg, #8b5cf6, #7c3aed);
    color: white;
}
.btn-success {
    background: linear-gradient(145deg, #22c55e, #16a34a);
    color: white;
}
.btn-danger {
    background: linear-gradient(145deg, #ef4444, #dc2626);
    color: white;
}
.btn-warning {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: white;
}

/* ===== STATUS ===== */
#status {
    color: #C1121F;
    font-weight: 600;
    min-height: 2rem;
    text-align: center;
}

/* ===== JOGO ===== */
#jogo {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 10px;
    flex: 1;
}

/* ===== INFO ===== */
#info {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.5);
    padding: 12px 20px;
    border-radius: 20px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

#info span {
    background: rgba(255, 255, 255, 0.6);
    padding: 4px 16px;
    border-radius: 20px;
}

/* ===== LATERAL ===== */
#lateral {
    flex: 0 0 180px;
    background: rgba(255, 255, 255, 0.4);
    padding: 15px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    max-height: 500px;
    overflow-y: auto;
}

#lateral h4 {
    color: #1e293b;
    margin-bottom: 12px;
    text-align: center;
}

#lista-jogadores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jogador-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1e293b;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    border-left: 3px solid transparent;
    transition: 0.2s;
}

.jogador-item.ativo {
    border-left-color: #f1c40f;
    background: rgba(241, 196, 15, 0.15);
}

/* ===== PRINCIPAL ===== */
#principal {
    flex: 1;
    min-width: 280px;
}

/* ===== TABULEIRO ===== */
#tabuleiro {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.monte {
    text-align: center;
    min-width: 140px;
}

.monte h4 {
    color: #1e293b;
    margin-bottom: 6px;
    font-size: 1rem;
}

.monte div {
    color: #1e293b;
    font-size: 1.2rem;
    font-weight: 600;
}

/* ===== MONTAGEM E MÃO ===== */
#area-montagem,
#area-mao {
    background: rgba(255, 255, 255, 0.3);
    padding: 15px;
    border-radius: 20px;
    margin-bottom: 15px;
    border: 2px dashed rgba(0, 0, 0, 0.06);
}

#area-montagem h4,
#area-mao h4 {
    color: #1e293b;
    margin-bottom: 10px;
    font-size: 1.1rem;
    text-align: center;
}

.slots {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 120px;
    justify-content: center;
    align-items: center;
}

.slot-vazio {
    width: 140px;
    min-height: 170px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.9rem;
    text-align: center;
    background: rgba(255,255,255,0.2);
}

/* ===== CARTAS (maiores e com fundo personalizado) ===== */
/* ===== CARTAS (tamanho aumentado e fundo com símbolos) ===== */
.carta {
    width: 190px;
    min-height: 266px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 12px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
    background: #ffffff; /* fundo branco */
    overflow: hidden;
}

/* Fundo com símbolos matemáticos transparentes */
.carta::before {
    content: '∫ ∑ π √ ∞ ± ÷ ×';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 4rem;
    color: rgba(0, 0, 0, 0.03);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    pointer-events: none;
    z-index: 0;
    transform: rotate(-5deg) scale(1.2);
}

.carta .valor {
    font-size: 1.2rem;
    font-weight: 700;
    z-index: 1;
    background: rgba(255,255,255,0.6);
    padding: 4px 12px;
    border-radius: 8px;
}
.carta .tipo {
    display: none; /* oculta o tipo (equacao, grafico, etc.) */
}

/* Cores por tipo (mantidas para identificar, mas sem o texto) */
.carta.tipo-equacao { border-color: #3b82f6; background: #f0f7ff; }
.carta.tipo-grafico { border-color: #22c55e; background: #f0fdf4; }
.carta.tipo-solucao { border-color: #f59e0b; background: #fffbeb; }
.carta.tipo-classificacao { border-color: #8b5cf6; background: #f5f3ff; }

/* SVG dentro da carta (gráfico) */
.carta svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    z-index: 1;
    position: relative;
}

/* Responsivo: cartas menores em telas pequenas */
@media (max-width: 800px) {
    .carta {
        width: 120px;
        min-height: 160px;
        padding: 8px;
    }
    .carta .valor {
        font-size: 1.1rem;
    }
}

.carta.virada {
    background: #1e293b;
    color: transparent;
    border-color: #475569;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.carta.virada .valor, .carta.virada .tipo { display: none; }
.carta.virada::before { content: '🂠'; font-size: 3.5rem; color: #94a3b8; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

.carta.minha-carta {
    cursor: pointer;
    transition: 0.2s;
}
.carta.minha-carta:hover { transform: scale(1.04); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12); }
.carta.selecionada { border-color: #ef4444 !important; box-shadow: 0 0 0 3px #ef4444; }

/* ===== CHAT ===== */
#chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    max-height: 400px;
    background: #1e293b;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    z-index: 500;
    overflow: hidden;
    transition: all 0.3s ease;
}
#chat-container.minimizado { max-height: 40px; }
#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #0f172a;
    color: #f1c40f;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}
#chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #0f172a;
}
#chat-messages .msg {
    padding: 6px 10px;
    border-radius: 12px;
    background: #2d3748;
    color: #e2e8f0;
    font-size: 0.85rem;
    word-wrap: break-word;
    max-width: 90%;
    align-self: flex-start;
}
#chat-messages .msg .nome {
    font-weight: 700;
    color: #f1c40f;
    margin-right: 6px;
}
#chat-messages .msg .hora {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-left: 6px;
}
#chat-messages .msg.sistema {
    background: #334155;
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    align-self: center;
    max-width: 80%;
}
#chat-input-area {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: #0f172a;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
#chat-input {
    flex: 1;
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid #334155;
    background: #2d3748;
    color: #f1f5f9;
    font-size: 0.9rem;
    outline: none;
}
#chat-input:focus { border-color: #f1c40f; }
#btn-enviar-chat {
    background: #f1c40f;
    color: #0f172a;
    border: none;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}
#btn-enviar-chat:hover { background: #f39c12; }

/* ===== MODAIS ===== */
#modal-nome, #modal-vitoria, #modal-regras {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
#modal-nome.hidden, #modal-vitoria.hidden, #modal-regras.hidden { display: none; }
#modal-content, #vitoria-content, #modal-regras-content {
    background: white;
    padding: 35px 40px;
    border-radius: 30px;
    max-width: 520px;
    width: 90%;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.08);
}
#modal-regras-content h2 { color: #1e293b; margin-bottom: 20px; }
.regras-texto { color: #1e293b; font-size: 0.95rem; line-height: 1.6; text-align: left; }
.regras-texto p { margin-bottom: 12px; }
.regras-texto strong { color: #2563eb; }

#modal-content h2, #vitoria-content h2 { color: #1e293b; margin-bottom: 20px; }
#modal-content input {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    font-size: 1.1rem;
    margin-bottom: 15px;
}
#modal-content button { width: 100%; padding: 14px; font-size: 1.1rem; }

.confetes { font-size: 3rem; margin: 20px 0; animation: confetes 1.5s infinite alternate; }
@keyframes confetes {
    0% { transform: rotate(-3deg) scale(1); }
    100% { transform: rotate(3deg) scale(1.1); }
}

/* ===== RODAPÉ ===== */
footer {
    width: 100%;
    text-align: center;
    padding: 15px 0 5px 0;
    margin-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}
footer .assinatura {
    font-weight: 700;
    color: #C1121F;
    font-size: 1.1rem;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}
footer small {
    color: #1e293b;
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 800px) {
    #app { padding: 20px; min-height: 90vh; }
    h1 { font-size: 2.2rem; }
    #jogo { flex-direction: column; }
    #lateral { flex: 1; max-height: 200px; }
    #tabuleiro { flex-direction: column; align-items: center; gap: 15px; }
    .carta { width: 110px; min-height: 140px; }
    .carta .valor { font-size: 1.1rem; }
    .slot-vazio { width: 110px; min-height: 140px; }
    footer .assinatura { font-size: 0.9rem; }
    footer small { font-size: 0.7rem; }
}

@media (max-width: 600px) {
    #chat-container { width: 250px; right: 10px; bottom: 10px; }
    .carta { width: 90px; min-height: 120px; }
    .carta .valor { font-size: 0.9rem; }
    .slot-vazio { width: 90px; min-height: 120px; }
}

/* Carta ampliada no modal */
.carta-ampliada {
    width: 400px !important;
    min-height: 500px !important;
    background: #ffffff !important;
    border-radius: 20px !important;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5) !important;
    padding: 20px !important;
}
.carta-ampliada .valor {
    font-size: 2.5rem !important;
}
.carta-ampliada svg {
    width: 100% !important;
    height: auto !important;
}

.carta-descarte {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border: 2px solid #f1c40f;
}
.carta-descarte svg {
    max-width: 100%;
    height: auto;
}
/* Cursor de pointer para cartas clicáveis */
.carta.minha-carta {
    cursor: pointer;
}
.carta.minha-carta:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transition: 0.2s;
}
.carta.compativel {
    box-shadow: 0 0 0 3px #22c55e, 0 8px 20px rgba(34, 197, 94, 0.3);
}
