body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align items to the top */
    min-height: 100vh;
    background-color: #f0f0f0;
    margin: 0;
    padding-top: 20px;
    overscroll-behavior-y: contain;
    touch-action: manipulation;
}

#game-container {
    text-align: center;
    width: 100%;
    max-width: 95vmin; /* Use viewport units for responsiveness */
}

#settings, #status-display, #controls, #special-move-controls {
    margin-bottom: 15px;
}

#status-display div {
    margin: 5px 0;
}

/* Style for coordinate display */
#coords-display {
    display: inline-block; /* Keep it on the same line */
    min-width: 50px;      /* Give it some space */
    font-style: italic;
    color: #555;
}


.message {
    color: #e74c3c; /* Red message color */
    font-weight: bold;
    min-height: 1.2em; /* Prevent layout shift */
}

#game-board-container {
    width: 100%;
    aspect-ratio: 1 / 1; /* Maintain square shape */
    margin: 10px auto;
    position: relative; /* Needed for absolute positioning of entities */
    overflow: hidden;
    border: 2px solid #333;
    /* Darker background color will show through the grid gaps, forming the lines */
    background-color: #555; /* Dark grey for grid lines */
    box-sizing: border-box;
    cursor: crosshair; /* Indicate hover interaction */
}

#game-board {
    display: grid;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    grid-template-rows: repeat(var(--grid-size), 1fr);
    /* The gap between grid cells. The container's background shows here. */
    grid-gap: 1px; /* Adjust gap size if needed */
    /* Make the cells themselves have a light background */
    background-color: #f8f8f8; /* Light grey/off-white for cells */
}

/* Target Cell Style */
.target-cell {
    position: absolute;
    background-color: #2ecc71; /* Green */
    opacity: 0.6; /* Slightly transparent */
    z-index: 1; /* Behind entities */
    box-sizing: border-box;
    /* Size set by JS */
}


/* Base Entity Styles */
.entity {
    position: absolute;
    /* Size calculated relative to grid cell, accounting for the gap */
    width: calc(100% / var(--grid-size) - 1px);
    height: calc(100% / var(--grid-size) - 1px);
    border-radius: 50%; /* Make them circles */
    transition: top 0.1s linear, left 0.1s linear; /* Smooth movement */
    z-index: 10; /* Above target cell and grid */
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white; /* Default text color */
    font-size: clamp(6px, calc(18 / var(--grid-size) * 1vw), 12px); /* Responsive font */
    box-sizing: border-box;
    line-height: 1;
    overflow: hidden;
    user-select: none;
    border: 1px solid rgba(0, 0, 0, 0.2); /* Subtle border for definition */
}

/* Specific Entity Colors */
.player { background-color: #3498db; /* Blue */ }
.past   { background-color: #e74c3c; /* Red */ }

/* Mirror Styles - Using specific classes */
.mirror { /* Base class for potential shared mirror styles */
    opacity: 0.85;
}
.player-mirror {
    background-color: #87CEFA; /* Light Sky Blue */
    border: 1px solid #5cacee; /* Slightly darker border */
}
.past-mirror {
    background-color: #F08080; /* Light Coral (Light Red) */
    border: 1px solid #cd5c5c; /* Slightly darker border */
}

/* Jester Style (Color set dynamically by JS) */
.jester {
     /* background-color: #9b59b6; /* REMOVED - Set via element.style */
     border: 1px solid #8e44ad; /* Keep purple border */
     color: #ffffff; /* Default to white text */
}


/* Controls */
#controls button, #special-move-controls button {
    font-size: clamp(1em, 4vw, 1.5em);
    margin: 2px;
    min-width: 35px;
    min-height: 35px;
    padding: 5px;
    cursor: pointer;
    touch-action: manipulation;
}

/* Overlay styles */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none; /* Hidden by default */
    justify-content: center; align-items: center;
    z-index: 100;
}
.overlay-content {
    background-color: white; padding: 20px; border-radius: 10px;
    text-align: center; box-shadow: 0 0 15px rgba(0,0,0,0.5);
    max-width: 80%;
}
.overlay-content h2 { margin-top: 0; margin-bottom: 15px; color: #333; font-size: 1.2em; }
.overlay-content button {
    padding: 10px 20px; font-size: 1em; margin-top: 15px; cursor: pointer;
    background-color: #3498db; color: white; border: none; border-radius: 5px;
}

/* Responsive adjustments */
@media (max-width: 400px) {
    #status-display div { font-size: 0.9em; }
    .overlay-content { padding: 15px; }
    .overlay-content h2 { font-size: 1.1em; }
}