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

body {
    font-family: 'Arial', sans-serif;
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Container do vídeo de fundo */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

#bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    
    /* Efeitos no vídeo */
    filter: brightness(0.4) contrast(1.1);
}

/* Overlay para melhorar legibilidade */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
}

.game-container {
    text-align: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

h1 {
    color: #036a12;
    margin-bottom: 20px;
    font-size: 3em;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
}

.game-wrapper {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
}

.game-board {
    border: 3px solid #ff6b6b;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
}

.board-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 30px 30px; /* Tamanho do bloco */
}

#board {
    display: block;
    background-color: rgba(15, 52, 96, 0.8);
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 150px;
}

.next-piece, .score-board, .controls {
    background: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.next-piece h3 {
    margin-bottom: 10px;
    color: #036a12;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

#next-piece {
    background-color: rgba(15, 52, 96, 0.7);
    border-radius: 5px;
}

.score-board div {
    margin: 10px 0;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

button {
    padding: 12px 20px;
    background: #036a12;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

button:hover {
    background: rgba(255, 82, 82, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* Estilos para o botão de reiniciar */
#restart-btn {
    background: rgba(76, 175, 80, 0.9);
}

#restart-btn:hover {
    background: rgba(56, 142, 60, 1);
}

/* Mensagem de Game Over */
.game-over-message {
    background: rgba(244, 67, 54, 0.9);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.game-over-message h3 {
    color: white;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.game-over-message p {
    margin-bottom: 15px;
    font-size: 1.1em;
}

#restart-after-gameover {
    background: rgba(255, 255, 255, 0.9);
    color: #f44336;
    font-weight: bold;
}

#restart-after-gameover:hover {
    background: white;
    transform: translateY(-2px);
}

.hidden {
    display: none !important;
}

/* Efeito de shake quando game over */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

/* Modal de Game Over Centralizado */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.game-over-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 3px solid #ff6b6b;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 107, 107, 0.3);
    animation: slideIn 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

.game-over-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    animation: rainbowBorder 3s linear infinite;
}

.game-over-header h2 {
    color: #ff6b6b;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(255, 107, 107, 0.5);
    animation: pulse 2s infinite;
}

.game-over-body {
    margin: 25px 0;
}

.final-stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat:last-child {
    border-bottom: none;
}

.stat-label {
    color: #4ecdc4;
    font-weight: bold;
    text-align: left;
}

.stat-value {
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    background: rgba(255, 107, 107, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    min-width: 60px;
}

.game-over-message p {
    color: #96ceb4;
    font-size: 1.1em;
    margin: 15px 0;
    font-style: italic;
}

.game-over-footer {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.restart-btn {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 160px;
}

.restart-btn:hover {
    background: linear-gradient(135deg, #ff5252, #ff7b7b);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 120px;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.2);
}

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes rainbowBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Efeito de shake no game over */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

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

.hidden {
    display: none !important;
}

/* Responsividade */
@media (max-width: 768px) {
    .game-over-content {
        margin: 20px;
        padding: 20px;
    }
    
    .game-over-footer {
        flex-direction: column;
    }
    
    .restart-btn, .close-btn {
        min-width: auto;
    }
}

/* === REGRAS PARA TELAS PEQUENAS (Mobile) === */
@media only screen and (max-width: 768px) {
    .game-wrapper {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .game-board {
        order: 2; /* Coloca o tabuleiro depois do painel lateral */
    }

    .side-panel {
        order: 1;
        width: 100%;
        max-width: 300px;
    }

    .controls {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }

    .controls button {
        flex: 1;
        min-width: 120px;
    }
}

/* === AJUSTES GLOBAIS PARA O CANVAS === */
#board {
    display: block;
    max-width: 100%; /* Impede que o canvas ultrapasse a tela */
    height: auto;
}