/* style.css */
:root {
    --primary-color: #007bff; /* Azul tema */
    --secondary-color: #f8f9fa; /* Fundo claro */
    --piece-border: #333;
    --slot-bg: #e9ecef;
    --board-size: 400px; /* Tamanho base do tabuleiro, ajuste conforme necessário */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: var(--secondary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 5px;
}

main {
    width: 100%;
    max-width: 900px; /* Ajuste para caber tudo confortavelmente */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-controls {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap; /* Para melhor ajuste em telas menores */
    justify-content: center; /* Centraliza os controles */
}

.game-controls label {
    font-weight: bold;
}

.game-controls select,
.game-controls button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}

.game-controls button {
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.game-controls button:hover {
    background-color: #0056b3;
}

#puzzle-area {
    display: flex;
    flex-wrap: wrap; /* Para telas menores, o pieces-container pode ir para baixo */
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    width: 100%;
}

#puzzle-board {
    width: var(--board-size);
    height: var(--board-size);
    display: grid;
    border: 2px solid var(--piece-border);
    background-color: #fff; /* Fundo branco para o tabuleiro em si */
    position: relative; 
}

.puzzle-slot {
    width: 100%; 
    height: 100%;
    border: 1px dashed #aaa;
    background-color: var(--slot-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

.puzzle-slot.over { /* Classe para feedback de arrastar sobre */
    background-color: #d0e0ff;
    border-style: solid;
}

#pieces-container {
    width: var(--board-size);
    min-height: var(--board-size); 
    padding: 10px;
    border: 2px dashed var(--primary-color);
    background-color: #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start; 
    gap: 5px;
}

.puzzle-piece {
    border: 1px solid var(--piece-border);
    cursor: grab;
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
    touch-action: none; /* Essencial para interações de toque suaves, previne scroll/zoom na peça */
    /* As dimensões (width/height) são definidas via JS */
}

/* Estilo para a peça quando está sendo ativamente movida pelo mouse (HTML5 D&D) */
.puzzle-piece:active {
    cursor: grabbing;
    /* Efeitos de transform/box-shadow podem ser gerenciados pela API D&D ou classes JS
       para evitar conflitos com a lógica de toque. */
    z-index: 1000; /* Garante que a peça fique acima das outras */
}

/* Estilo para a peça quando está sendo arrastada por toque */
.puzzle-piece.dragging-touch {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0,0,0,0.6);
    opacity: 0.85;
    /* z-index e position:fixed são aplicados via JS */
}

#preview-area {
    margin-top: 20px;
    text-align: center;
}

#preview-image {
    max-width: 100%;
    height: auto; /* Mantém a proporção */
    max-height: 200px; /* Limita a altura da pré-visualização */
    border: 1px solid #ccc;
    border-radius: 4px;
}

#message-area {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid transparent; /* Borda base */
    border-radius: 4px;
    text-align: center;
    font-size: 1.2em;
    width: 100%;
    max-width: 600px;
}

footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    width: 100%;
    max-width: 900px;
    font-size: 0.9em;
    color: #555;
}

footer p {
    margin-bottom: 5px;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsividade */
@media (max-width: 768px) {
    :root {
        --board-size: 300px; /* Reduz o tabuleiro em telas menores */
    }
    #puzzle-area {
        flex-direction: column;
        align-items: center;
    }
    #pieces-container {
        width: 100%;
        max-width: var(--board-size); /* Mantém a mesma largura do tabuleiro */
        min-height: 150px; /* Ajusta altura mínima do container de peças */
    }
    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }
    header h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    :root {
        --board-size: 240px; /* Ainda menor para celulares */
    }
    header h1 {
        font-size: 1.8em;
    }
    .game-controls select,
    .game-controls button {
        font-size: 0.9em; /* Reduz um pouco a fonte nos controles */
    }
    #preview-image {
        max-height: 150px;
    }
}