/* Puzzle Page Styles */

.puzzle-container {
    max-width: 1200px;
    margin: 80px auto 4rem;
    /* Account for navbar */
    padding: 0 20px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    text-align: center;
}

/* Sections visibility */
section.hidden {
    display: none;
}

section.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Selection Screen */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.puzzle-thumb {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.puzzle-thumb:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.puzzle-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    aspect-ratio: 1 / 1;
    /* Force square thumbnails */
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.game-area {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    align-items: flex-start;
}

#puzzle-board {
    width: 500px;
    height: 500px;
    background: #eee;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Default 3x3 */
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    border: 5px solid #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.tile {
    /* Background image set via JS */
    cursor: pointer;
    background-size: 500px 500px;
    /* Must match board size */
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.5);
    user-select: none;
}

.tile:hover {
    opacity: 0.9;
}

.tile.empty {
    background: #fff;
    cursor: default;
    border: none;
}

#reference-image {
    width: 200px;
    text-align: center;
}

#reference-image img {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#reference-image p {
    margin-bottom: 10px;
    font-weight: bold;
    color: #666;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn-primary {
    background: #000;
    color: #fff;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: #ddd;
    color: #333;
}

.btn-secondary:hover {
    background: #ccc;
}

.timer {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: monospace;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    #puzzle-board {
        width: 350px;
        height: 350px;
    }

    .tile {
        background-size: 350px 350px;
    }

    .game-area {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 400px) {
    #puzzle-board {
        width: 300px;
        height: 300px;
    }

    .tile {
        background-size: 300px 300px;
    }
}