/* =========================
   PUZZLE BOARD
========================= */

.puzzle-board {

    width: 100%;

    max-width: 650px;

    margin: 20px auto;

    aspect-ratio: 1;

    display: grid;

    overflow: hidden;

    background: #eef2ff;

    border: 3px solid #6366f1;

    border-radius: 16px;

}


/* =========================
   PUZZLE SLOTS
========================= */

.puzzle-slot {

    position: relative;

    border: 1px dashed
        rgba(99, 102, 241, 0.25);

    min-width: 0;

    min-height: 0;

}


/* =========================
   PUZZLE PIECES
========================= */

.puzzle-piece {

    width: 100%;

    aspect-ratio: 1;

    cursor: grab;

    background-repeat: no-repeat;

    background-color: white;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;

}


.puzzle-piece:hover {

    transform: scale(1.03);

    box-shadow:
        0 5px 15px
        rgba(0, 0, 0, 0.15);

}


.puzzle-piece:active {

    cursor: grabbing;

}


/* =========================
   AVAILABLE PIECES
========================= */

.pieces-container {

    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(90px, 1fr)
        );

    gap: 12px;

    margin-top: 20px;

    min-height: 120px;

}


.pieces-container
.puzzle-piece {

    border-radius: 10px;

    border: 2px solid white;

    box-shadow:
        0 4px 10px
        rgba(0, 0, 0, 0.12);

}

/* =========================================
   DESKTOP GAME LAYOUT
========================================= */

.jigsaw-game-layout {

    display: grid;

    grid-template-columns:
        240px
        minmax(450px, 1fr)
        260px;

    gap: 24px;

    align-items: start;

}


/* =========================================
   LEFT CONTROL PANEL
========================================= */

.controls-panel {

    background: white;

    border-radius: 18px;

    padding: 24px;

    border: 1px solid
        rgba(99, 102, 241, 0.12);

    box-shadow:
        0 8px 25px
        rgba(0, 0, 0, 0.06);

}

.controls-panel h5 {

    margin-bottom: 22px;

    font-weight: 700;

}


/* =========================================
   CENTER PUZZLE
========================================= */

.puzzle-section {

    text-align: center;

    min-width: 0;

}

.puzzle-section-header {

    display: flex;

    justify-content: center;

    margin-bottom: 15px;

}

.puzzle-section-header h5 {

    margin-bottom: 4px;

    font-weight: 700;

}

.puzzle-section-header small {

    color: #6b7280;

}


/* Make puzzle fit viewport */

.puzzle-board {

    width: 100%;

    max-width: 580px;

    aspect-ratio: 1 / 1;

    margin: 0 auto;

    display: grid;

    overflow: hidden;

    background: #eef2ff;

    border: 3px solid #6366f1;

    border-radius: 16px;

}


/* =========================================
   RIGHT PIECES PANEL
========================================= */

.pieces-panel {

    background: white;

    border-radius: 18px;

    padding: 20px;

    border: 1px solid
        rgba(99, 102, 241, 0.12);

    box-shadow:
        0 8px 25px
        rgba(0, 0, 0, 0.06);

    min-height: 500px;

}


.pieces-panel h5 {

    font-weight: 700;

    margin-bottom: 5px;

}


/* =========================================
   PIECES GRID
========================================= */

.pieces-container {

    display: grid;

    grid-template-columns:
        repeat(
            2,
            1fr
        );

    gap: 10px;

    margin-top: 20px;

    max-height: 60vh;

    overflow-y: auto;

    padding-right: 5px;

}


/* Prevent pieces from becoming huge */

.pieces-container
.puzzle-piece {

    width: 100%;

    aspect-ratio: 1;

    border-radius: 10px;

}


/* =========================================
   RESPONSIVE TABLET
========================================= */

@media (max-width: 1100px) {

    .jigsaw-game-layout {

        grid-template-columns:
            200px
            minmax(400px, 1fr);

    }


    .pieces-panel {

        grid-column:
            1 / -1;

    }


    .pieces-container {

        grid-template-columns:
            repeat(
                auto-fill,
                minmax(100px, 1fr)
            );

        max-height: none;

    }

}


/* =========================================
   MOBILE
========================================= */

@media (max-width: 768px) {

    .jigsaw-game-layout {

        grid-template-columns:
            1fr;

    }


    .controls-panel,
    .pieces-panel {

        width: 100%;

    }


    .pieces-container {

        grid-template-columns:
            repeat(
                3,
                1fr
            );

        max-height: none;

    }


    .puzzle-board {

        width: 100%;

    }

}

.start-competition-button {

    width: 280px;

    height: 50px;

    border: none;

    border-radius: 11px;

    background: #6366f1;

    color: white;

    font-size: 14px;

    font-weight: 800;

    cursor: pointer;

}

.start-competition-button:disabled {

    opacity: .45;

    cursor: not-allowed;

}


.countdown-overlay {

    position: fixed;

    inset: 0;

    z-index: 9999;

    background:
        rgba(15, 23, 42, .82);

    display: flex;

    align-items: center;

    justify-content: center;

}


#countdownNumber {

    font-size: 120px;

    font-weight: 900;

    color: white;

    animation:
        countdownPulse .8s ease-in-out;

}


@keyframes countdownPulse {

    0% {

        transform: scale(.5);

        opacity: 0;

    }

    50% {

        transform: scale(1.15);

        opacity: 1;

    }

    100% {

        transform: scale(1);

        opacity: 1;

    }

}