:root {
    --grid-size: 4;
    --tile-size: 80px;
    --grid-gap: 5px;
    --board-width: calc(var(--grid-size) * var(--tile-size) + (var(--grid-size) - 1) * var(--grid-gap));
    --primary-color: #3f51b5; /* Indigo */
    --secondary-color: #ffc107; /* Amber */
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #e8eaf6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    user-select: none;
}

.game-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    text-align: center;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

/* --- Stats and Controls --- */

.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
    font-size: 1.1em;
    font-weight: bold;
}

#reset-button, #play-again-button {
    padding: 8px 15px;
    font-size: 1em;
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    transition: background-color 0.3s;
}

#reset-button:hover, #play-again-button:hover {
    background-color: #303f9f;
}


/* --- Puzzle Board --- */

.puzzle-board {
    width: var(--board-width);
    height: var(--board-width);
    display: grid;
    grid-template-columns: repeat(var(--grid-size), var(--tile-size));
    grid-template-rows: repeat(var(--grid-size), var(--tile-size));
    gap: var(--grid-gap);
    background-color: #c5cae9; /* Light board background */
    padding: var(--grid-gap);
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    background-color: var(--secondary-color);
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    font-weight: 900;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 1px solid #ffeb3b;
}

.tile:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
}

/* Style for the empty space (the 16th tile) */
.empty-tile {
    background-color: transparent;
    cursor: default;
    box-shadow: none;
    border: none;
    pointer-events: none; /* Ensure no interaction */
}

/* --- Win Message --- */

.hidden {
    display: none !important;
}

#win-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 50px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10;
    text-align: center;
    border: 5px solid var(--primary-color);
}

#win-message h2 {
    color: var(--primary-color);
    margin-top: 0;
}