/* Estilos específicos para a página do quebra-cabeça */

header {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.timer {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
    min-width: 150px;
}

.pieces-selector, .piece-type-selector {
    display: flex;
    align-items: center;
    margin-right: 15px;
}

.pieces-selector label, .piece-type-selector label {
    margin-right: 10px;
    margin-bottom: 0;
}

.pieces-selector select, .piece-type-selector select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f8f8f8;
}

/* Container do quebra-cabeça */
.puzzle-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.puzzle-wrapper {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 20px;
}

/* Imagem original */
.original-image {
    width: 20%;
    max-width: 280px;
    border: 1px solid #ddd;
    margin-right: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    overflow: hidden;
}

.original-image img {
    width: 100%;
    display: block;
    image-rendering: -webkit-optimize-contrast; /* Melhora nitidez em Chrome/Safari */
    image-rendering: crisp-edges; /* Melhora nitidez em Firefox */
}

/* Área do quebra-cabeça */
.puzzle-board {
    width: 900px;
    height: 1200px;
    border: 2px solid #3498db;
    position: relative;
    background-color: #eee;
    background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0),
                      linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0);
    background-size: 60px 60px;
    background-position: 0 0, 30px 30px;
    transition: all 0.3s;
    overflow: hidden;
    flex-grow: 1;
    max-width: 80%;
    margin: 0 auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* Peças do quebra-cabeça */
.puzzle-piece {
    position: absolute;
    cursor: move;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s, transform 0.1s;
    background-position: center;
    background-size: cover;
    will-change: transform; /* Otimização de performance */
    transform: translateZ(0); /* Força aceleração de hardware */
    overflow: visible !important;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.puzzle-piece:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.puzzle-piece.dragging {
    opacity: 0.8;
    z-index: 100;
    transform: scale(1.05);
}

.puzzle-piece.correct-position {
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.7);
    border: 2px solid rgba(40, 167, 69, 0.7);
}

/* Classe para usar quando a peça tem formato de quebra-cabeça */
.puzzle-piece-irregular {
    position: absolute;
    cursor: move;
    transition: box-shadow 0.3s, transform 0.1s;
    background-color: transparent;
    background-position: center;
    background-size: cover;
    box-shadow: none;
    will-change: transform;
    transform: translateZ(0);
    overflow: visible !important;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.puzzle-piece-irregular:hover {
    z-index: 10;
}

.puzzle-piece-irregular.dragging {
    opacity: 0.8;
    z-index: 100;
}

.puzzle-piece-irregular.correct-position {
    /* Sem borda visível, pois isso afetaria a forma recortada */
    filter: brightness(1.05);
}

/* Canvas da peça - renderiza o formato real */
.piece-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none; /* O evento de clique passa para o div pai */
}

/* Controles do jogo */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.status-message {
    text-align: center;
    padding: 10px;
    margin-top: 10px;
    border-radius: 5px;
    font-weight: 600;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

.status-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Modal de parabéns */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.modal h2 {
    color: #28a745;
    font-size: 2rem;
    margin-bottom: 20px;
}

/* Responsividade */
@media screen and (max-width: 1600px) {
    .puzzle-board {
        width: 750px;
        height: 1000px;
    }
}

@media screen and (max-width: 1200px) {
    .puzzle-board {
        width: 600px;
        height: 800px;
    }
}

@media screen and (max-width: 992px) {
    .puzzle-wrapper {
        flex-direction: column;
        align-items: center;
    }
    
    .original-image {
        margin-right: 0;
        margin-bottom: 20px;
        max-width: 300px;
        width: 100%;
    }
    
    .puzzle-board {
        width: 100%;
        max-width: 800px;
        height: 0;
        padding-bottom: 133%; /* Para manter proporção retangular 3:4 */
    }
}

@media screen and (max-width: 768px) {
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-controls {
        flex-wrap: wrap;
    }
    
    .btn {
        margin-bottom: 5px;
    }
}

/* Estilos para peças de quebra-cabeça com formato irregular */
.piece-tab-top {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 75%, 75% 75%, 
        75% 100%, 50% 75%, 25% 100%, 25% 75%, 
        0% 75%
    );
}

.piece-tab-right {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 100%, 0% 100%, 
        0% 75%, 25% 75%, 50% 50%, 25% 25%, 
        0% 25%
    );
}

.piece-tab-bottom {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 100%, 0% 100%, 
        0% 25%, 25% 25%, 50% 0%, 75% 25%, 
        100% 25%
    );
}

.piece-tab-left {
    clip-path: polygon(
        25% 0%, 100% 0%, 100% 100%, 25% 100%, 
        0% 75%, 25% 50%, 0% 25%
    );
}

/* Combinações de abas */
.piece-tab-top-right {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 100%, 75% 100%, 
        75% 75%, 50% 100%, 25% 75%, 0% 75%
    );
}

.piece-tab-right-bottom {
    clip-path: polygon(
        0% 0%, 75% 0%, 100% 25%, 75% 50%, 
        100% 75%, 100% 100%, 0% 100%
    );
}

.piece-tab-bottom-left {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 100%, 0% 100%, 
        0% 25%, 25% 25%, 50% 0%, 75% 25%
    );
}

.piece-tab-left-top {
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 75%, 75% 75%, 
        75% 100%, 50% 75%, 25% 100%, 0% 100%
    );
} 