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

:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --accent-color: #f39c12;
    --danger-color: #e74c3c;
    --dark-color: #1a1a2e;
    --light-color: #ffffff;
    --text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    --box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    --glow: 0 0 10px rgba(46, 204, 113, 0.8);
}

body {
    overflow: hidden;
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: var(--dark-color);
    color: var(--light-color);
}

/* Telas de menu */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.9) 0%, rgba(22, 22, 38, 0.95) 100%);
    z-index: 100;
}

.screen-content {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    padding: 30px;
    max-width: 550px;
    text-align: center;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-title {
    font-size: 42px;
    margin-bottom: 20px;
    color: var(--primary-color);
    text-shadow: var(--text-shadow);
    font-weight: 700;
    letter-spacing: 1px;
}

.game-logo {
    max-width: 300px;
    max-height: 80px;
    margin-bottom: 20px;
    object-fit: contain;
}

.game-header-logo {
    max-height: 40px;
    max-width: 200px;
    object-fit: contain;
}

.game-description {
    font-size: 18px;
    margin-bottom: 25px;
}

.instructions {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 25px;
    text-align: left;
}

.instructions p {
    margin: 10px 0;
    font-size: 16px;
}

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

/* Botões */
.main-button {
    padding: 12px 30px;
    font-size: 18px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: var(--box-shadow);
    transition: all 0.2s ease;
    margin: 10px 0;
}

.main-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    background-color: #27ae60;
}

.secondary-button {
    padding: 10px 25px;
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    margin: 10px 0;
}

.secondary-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.icon-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: white;
    padding: 5px;
    transition: transform 0.2s;
}

.icon-button:hover {
    transform: scale(1.2);
}

/* Interface do jogo */
.game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    pointer-events: none;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.5));
    padding: 10px 20px;
}

.game-header h1 {
    color: white;
    font-size: 24px;
    text-shadow: var(--text-shadow);
    margin: 0;
}

.game-header button {
    pointer-events: auto;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

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

.stat-value {
    font-size: 28px;
    font-weight: bold;
    text-shadow: var(--text-shadow);
}

.stat-label {
    font-size: 14px;
    opacity: 0.8;
}

/* Barra de tempo */
.time-bar-container {
    padding: 5px 15px;
    background: rgba(0, 0, 0, 0.5);
}

.time-bar-label {
    font-size: 14px;
    margin-bottom: 3px;
}

.time-bar {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.time-bar-fill {
    height: 100%;
    width: 100%;
    background-color: var(--secondary-color);
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.5s ease;
}

/* Combo counter */
.combo-counter {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 20px;
    font-weight: bold;
    color: var(--accent-color);
    display: none;
    z-index: 5;
    box-shadow: var(--box-shadow);
}

/* Dica ao passar o mouse */
.hover-hint {
    position: fixed;
    transform: translate(-50%, -100%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    display: none;
    z-index: 5;
    pointer-events: none;
}

/* Container do jogo 3D */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Modais */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.modal-content {
    background-color: rgba(30, 30, 50, 0.9);
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--box-shadow);
    transform: translateY(0);
    animation: modal-appear 0.3s ease-out;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal h2 {
    font-size: 32px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.level-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
}

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

.level-stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--accent-color);
}

.level-stat-label {
    font-size: 14px;
    opacity: 0.8;
}

.big-score {
    font-size: 24px;
    margin: 20px 0;
}

/* Efeito de pontos */
.points-effect {
    position: fixed;
    color: #ffff00;
    font-size: 20px;
    font-weight: bold;
    z-index: 5;
    pointer-events: none;
    transform: translate(-50%, -50%);
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.7);
    opacity: 1;
}

.points-effect-animate {
    animation: points-fade 1.5s ease-out forwards;
}

/* Estilos para formulário de nome e leaderboard */
.name-input-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

#player-name {
    padding: 10px;
    border-radius: 20px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    width: 100%;
    max-width: 200px;
}

#player-name:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* INÍCIO DAS CORREÇÕES DO LEADERBOARD */
.leaderboard-container {
    max-height: 300px;
    margin: 15px 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.leaderboard-header {
    display: flex;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 0;
    font-weight: bold;
    color: var(--primary-color);
    border-bottom: 2px solid rgba(70, 70, 90, 0.5);
    z-index: 10;
}

.header-cell {
    text-align: center;
    padding: 0 5px;
}

.scrollable-table {
    overflow-y: auto;
    max-height: 250px;
    overflow-x: hidden; /* Impede rolagem horizontal */
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    color: white;
    table-layout: fixed;
}

/* Larguras das colunas mantidas em sincronização com o cabeçalho */
.leaderboard-table td:nth-child(1) {
    width: 15%;
    text-align: center;
}

.leaderboard-table td:nth-child(2) {
    width: 45%;
    padding-left: 5px;
    padding-right: 5px;
}

.leaderboard-table td:nth-child(3) {
    width: 25%;
    text-align: center;
}

.leaderboard-table td:nth-child(4) {
    width: 15%;
    text-align: center;
}

.leaderboard-table td {
    padding: 8px 5px;
    vertical-align: middle;
}

.leaderboard-table tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* CORREÇÕES PARA O ALINHAMENTO DOS NOMES DOS JOGADORES */
.player-name-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 5px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap; /* Impede quebra de linha */
    text-overflow: ellipsis; /* Adiciona "..." se o texto for longo demais */
}

/* Garante que o avatar tenha tamanho fixo e não encolha */
.player-avatar, 
.default-avatar {
    flex-shrink: 0; /* Impede que o avatar encolha */
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
}

.player-avatar {
    object-fit: cover;
}

.default-avatar {
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
}

/* Nome do jogador: adicione esta classe para os spans dos nomes */
.player-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 38px); /* 30px do avatar + 8px da margem */
}

.player-name-cell:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}
/* FIM DAS CORREÇÕES DO LEADERBOARD */

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

.rank-1, .rank-2, .rank-3 {
    font-weight: bold;
}

.rank-1 {
    color: gold;
}

.rank-2 {
    color: silver;
}

.rank-3 {
    color: #cd7f32; /* Bronze */
}

/* Animações */
@keyframes modal-appear {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes points-fade {
    0% { transform: translate(-50%, -50%); opacity: 1; }
    50% { transform: translate(-50%, -100px); opacity: 1; }
    100% { transform: translate(-50%, -150px); opacity: 0; }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}

.pulse-animation {
    animation: pulse 1.5s infinite;
}

/* Responsividade */
@media (max-width: 768px) {
    .game-title {
        font-size: 32px;
    }
    
    .game-info {
        gap: 15px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .modal-content {
        padding: 20px;
        max-width: 90%;
    }
    
    .level-stat-value {
        font-size: 24px;
    }
}

.header-buttons {
    display: flex;
    gap: 10px;
}


#leaderboard-button {
    color: gold;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

#leaderboard-button:hover {
    transform: scale(1.2);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}


.profile-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
}

.profile-image-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.profile-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-placeholder {
    font-size: 30px;
    color: rgba(255, 255, 255, 0.5);
}

.profile-image-label {
    padding: 8px 15px;
    background-color: rgba(50, 50, 70, 0.7); /* Cor mais escura e consistente */
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    color: white;
    border: none;
}

.profile-image-label:hover {
    background-color: rgba(70, 70, 90, 0.8);
}

.image-tip {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 5px;
}

.comment-container {
    margin: 15px 0;
    width: 100%;
}

#player-comment {
    width: 100%;
    height: 80px;
    padding: 10px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    resize: none;
}

#player-comment:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Estilos para botões da câmera */
.profile-image-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

/* Estilos para o modal de webcam */
.webcam-container {
    width: 100%;
    max-width: 400px;
    height: 300px;
    overflow: hidden;
    border-radius: 10px;
    margin: 15px 0;
    background: #000;
}

#webcam, #canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.webcam-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

/* Estilos para o modal de detalhes do jogador */
.player-detail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
    gap: 20px;
}

.player-detail-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.player-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-detail-info {
    display: flex;
    gap: 30px;
}

.detail-label {
    font-size: 16px;
    opacity: 0.8;
    margin-bottom: 5px;
}

.detail-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent-color);
}

.player-comment-container {
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
}

.player-comment-container h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.player-comment {
    font-style: italic;
    line-height: 1.5;
}

.detail-avatar {
    width: 150px;
    height: 150px;
    font-size: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    border-radius: 50%;
    margin: 0 auto;
}

/* Ajustes para os botões no modal de nível completo */
#level-complete .modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#level-complete .buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 250px;
    margin-top: 10px;
}

#submit-score-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    transition: all 0.2s ease;
}

#submit-score-btn:hover {
    background-color: #e67e00;
    transform: translateY(-2px);
}

/* Estilos para botões de reinício */
.leaderboard-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.skip-score-container {
    margin-top: 15px;
    text-align: center;
}

#quick-retry-button, #skip-score-button {
    background-color: rgba(60, 60, 80, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#quick-retry-button:hover, #skip-score-button:hover {
    background-color: rgba(80, 80, 100, 0.9);
    transform: translateY(-1px);
}

/* Estilos para pesquisa e paginação */
.search-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
    align-items: center;
}

#leaderboard-search, #in-game-search {
    padding: 8px 12px;
    border-radius: 15px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    flex: 1;
    max-width: 200px;
}

#leaderboard-search:focus, #in-game-search:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.search-btn {
    padding: 8px 12px;
    border-radius: 15px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    min-width: 40px;
}

.search-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0 5px 0;
    gap: 15px;
}

.pagination-btn {
    padding: 8px 15px;
    border-radius: 15px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    min-width: 80px;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#page-info, #in-game-page-info {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: bold;
    text-align: center;
    min-width: 100px;
}

.pagination-info {
    text-align: center;
    margin-bottom: 10px;
}

#results-info, #in-game-results-info {
    font-size: 12px;
    opacity: 0.7;
}

/* Responsividade para pesquisa e paginação */
@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        gap: 8px;
    }
    
    #leaderboard-search, #in-game-search {
        max-width: 100%;
        width: 100%;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .pagination-btn {
        min-width: 60px;
        padding: 6px 12px;
    }
}