/* Reset básico de margin e padding */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Cor de fundo do corpo e fonte principal */
body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(120deg, #1e2a47, #535d8c);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    text-align: center;
    padding-top: 80px;
    font-size: 16px;
    line-height: 1.5;
}

/* Estilo do cabeçalho */
header {
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    text-align: center;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    margin: 0 auto;
}

header button {
    background-color: #ff4d4d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s;
    white-space: nowrap;
}

header button:hover {
    background-color: #e63939;
    transform: scale(1.05);
}

/* Container principal */
main {
    width: 95%;
    max-width: 900px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    margin-bottom: 30px;
    margin-top: 20px;
}

/* Estilo para seletores de nível */
.nivel-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.nivel-btn {
    padding: 6px 12px;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 0.9rem;
}

.nivel-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.nivel-btn.active {
    background-color: #ffcc00;
    color: #333;
    font-weight: bold;
}

/* Estilo do container de ranking */
#ranking-container {
    width: 100%;
    overflow-x: auto; /* Permite rolagem horizontal em telas pequenas */
}

#ranking-container h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Estilo da tabela */
#ranking-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    min-width: 300px; /* Garante um tamanho mínimo para a tabela */
}

#ranking-table th, 
#ranking-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#ranking-table th {
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: bold;
    white-space: nowrap; /* Evita quebra de linha nos cabeçalhos */
}

#ranking-table tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Estilo para os três primeiros lugares */
#ranking-table tr.first-place,
#ranking-table tr:nth-child(1) {
    background-color: rgba(255, 215, 0, 0.3); /* Ouro */
}

#ranking-table tr.second-place,
#ranking-table tr:nth-child(2) {
    background-color: rgba(192, 192, 192, 0.3); /* Prata */
}

#ranking-table tr.third-place,
#ranking-table tr:nth-child(3) {
    background-color: rgba(205, 127, 50, 0.3); /* Bronze */
}

/* Mensagens */
.loading, .error, .empty-ranking {
    padding: 15px;
    text-align: center;
}

.loading {
    color: #ffcc00;
}

.error {
    color: #ff6b6b;
}

.empty-ranking {
    color: #dddddd;
}

/* Footer */
footer {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 12px;
    text-align: center;
    margin-top: auto;
    font-size: 0.85rem;
}

/* Responsividade */
@media (max-width: 768px) {
    body {
        padding-top: 70px;
    }
    
    header {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    header button {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    main {
        padding: 15px;
        width: 96%;
    }
    
    .nivel-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .nivel-btn {
        width: 100%;
        padding: 8px 5px;
        font-size: 0.85rem;
    }
    
    #ranking-container h2 {
        font-size: 1.4rem;
    }
    
    #ranking-table th, 
    #ranking-table td {
        padding: 6px 4px;
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    header h1 {
        font-size: 1.2rem;
    }
    
    .nivel-selector {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Estilo compacto para tabela em telas muito pequenas */
    #ranking-table {
        font-size: 0.8rem;
    }
    
    #ranking-table th:nth-child(5),
    #ranking-table td:nth-child(5) {
        display: none; /* Esconde a coluna de data em telas muito pequenas */
    }
    
    /* Reduzir o espaçamento interno das células */
    #ranking-table th, 
    #ranking-table td {
        padding: 5px 3px;
    }
    
    /* Deixar texto de nível mais curto */
    #ranking-table td:nth-child(4)::before {
        content: "Nv.";
    }
    
    #ranking-table td:nth-child(4) {
        font-size: 0.75rem;
    }
    
    #ranking-table th:nth-child(4) {
        display: none;
    }
}

@media (max-width: 400px) {
    header {
        flex-direction: column;
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }
    
    body {
        padding-top: 85px;
    }
    
    .nivel-selector {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .nivel-btn {
        padding: 6px 2px;
        font-size: 0.75rem;
    }
    
    #ranking-table th:nth-child(3),
    #ranking-table td:nth-child(3) {
        white-space: nowrap;
    }
    
    main {
        padding: 10px;
    }
}

/* Estilos para dispositivos muito pequenos */
@media (max-width: 320px) {
    .nivel-selector {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #ranking-container h2 {
        font-size: 1.2rem;
    }
    
    #ranking-table {
        font-size: 0.7rem;
    }
}