/* Container */
#fifteen-puzzle-container {
    max-width: 900px;
    margin: 40px auto;
    font-family: Arial, sans-serif;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    gap: 30px;

    flex-wrap: wrap; /* prevents squishing */
}

/* Main puzzle area */
.puzzle-main {
    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 12px;
    flex: 1;
    min-width: 280px;
}

/* Stats across top (FORCED ROW) */
.puzzle-stats {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;

    gap: 20px;

    width: 100%;
    max-width: 420px;

    font-size: 20px;
    font-weight: bold;

    margin-bottom: 10px;
}

/* Sidebar */
.puzzle-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

/* Buttons */
.puzzle-buttons button,
.puzzle-levels button {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;

    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

/* Main buttons */
.puzzle-buttons button {
    background: linear-gradient(145deg,#13c96a,#0e9e53);
    color: white;
}

.puzzle-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Level buttons */
.puzzle-levels button {
    background: #0e9e53;
    color: #fff;
}

.puzzle-levels button:hover {
    background: #0b7a40;
}

.puzzle-levels button.active-level {
    background: #ffffff;
    color: #0e9e53;
    font-weight: 700;
    box-shadow: 0 0 0 2px #0e9e53 inset;
}

/* ========================= */
/* RESPONSIVE PUZZLE BOARD   */
/* ========================= */

.puzzle-board {
    width: min(90vw, 420px);   /* scales with screen */
    aspect-ratio: 1 / 1;       /* keeps perfect square */

    background: #621ebc;
    border: 3px solid #621ebc;
    border-radius: 12px;
    box-shadow:
    inset 0 6px 14px rgba(0,0,0,0.25),
    0 6px 18px rgba(0,0,0,0.2);

    position: relative;
    overflow: hidden;

    flex-shrink: 0;
}

/* Tiles */
.puzzle-tile {
    position: absolute;

    width: 25%;
    height: 25%;

    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: clamp(24px, 6vw, 40px); /* responsive text */
    font-weight: 900;

    background: linear-gradient(145deg,#ffffff,#eaeaea);
    border-radius: 10px;
    border: 2px solid #0e9e53;

    box-shadow:
        4px 4px 8px rgba(0,0,0,0.2),
        -4px -4px 8px rgba(255,255,255,0.7);

    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    cursor: pointer;

    user-select: none;

    transition: transform 0.22s cubic-bezier(.22,.61,.36,1),
                box-shadow 0.2s ease;

    will-change: transform;
}

.puzzle-tile:hover {
    box-shadow:
        6px 6px 12px rgba(0,0,0,0.25),
        -6px -6px 12px rgba(255,255,255,0.8);
}

/* Focus */
button:focus {
    outline: 2px solid #0e9e53;
    outline-offset: 2px;
}

/* Game message */
.game-message {
    margin-top: 15px;
    font-size: 20px;
    font-weight: bold;
    color: #0e9e53;
}

/* ========================= */
/* MOBILE                    */
/* ========================= */

@media (max-width: 768px) {
    #fifteen-puzzle-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .puzzle-stats {
        justify-content: space-around;
        max-width: 100%;
        font-size: 18px;
    }

    .puzzle-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .puzzle-board {
        width: min(90vw, 320px);
    }

    .puzzle-buttons button,
    .puzzle-levels button {
        font-size: 14px;
        padding: 8px 12px;
    }
}