:root {
    --grid-size: 3; /* Defines the number of rows/columns */
    --puzzle-width: 300px; /* Total width/height of the puzzle container */
    --tile-size: calc(var(--puzzle-width) / var(--grid-size));
}

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

#game-container {
    text-align: center;
    background-color: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #007bff;
    margin-bottom: 20px;
}

/* --- Puzzle Grid Container --- */
#puzzle-grid {
    width: var(--puzzle-width);
    height: var(--puzzle-width);
    margin: 0 auto 20px;
    border: 3px solid #333;
    display: grid;
    /* Sets up 3 equal columns */
    grid-template-columns: repeat(var(--grid-size), 1fr); 
    grid-template-rows: repeat(var(--grid-size), 1fr);
}

/* --- Tile Styling --- */
.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    border: 1px solid #aaa;
    box-sizing: border-box;
    cursor: pointer;
    /* Ensures the image fills the entire 300x300 area, ready to be positioned */
    background-size: var(--puzzle-width) var(--puzzle-width); 
    transition: transform 0.3s ease, box-shadow 0.2s;
}

.tile:hover:not(.empty-tile) {
    box-shadow: inset 0 0 10px rgba(0, 123, 255, 0.5);
}

/* --- Empty Tile Styling --- */
.empty-tile {
    background-image: none !important;
    background-color: #333; /* Dark background for the missing piece */
    cursor: default;
}

/* --- Status and Controls --- */
#status-area {
    margin-bottom: 20px;
    min-height: 20px;
}

#message {
    font-style: italic;
    color: #555;
}

#reset-button {
    padding: 10px 20px;
    font-size: 1em;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#reset-button:hover {
    background-color: #1e7e34;
}