
:root {
    --body-bg-color: #e0f2f7; /* Light Blue */
    --container-bg-color: #ffffff;
    --heading-color: #2c3e50; /* Dark Blue Gray */
    --status-text-color: #34495e; /* Medium Blue Gray */
    --game-board-bg-color: #3498db; /* Blue */
    --cell-bg-color: #ecf0f1; /* Light Gray */
    --cell-text-color: #2c3e50; /* Dark Blue Gray */
    --cell-hover-bg-color: #dbe2e6; /* Even Lighter Gray */
    --button-bg-color: #3498db; /* Blue */
    --button-text-color: white;
    --button-hover-bg-color: #2980b9; /* Darker Blue */
    --button-disabled-bg-color: #95a5a6; /* Gray for disabled state */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover-color: rgba(0, 0, 0, 0.15);
    --button-shadow-color: rgba(0, 0, 0, 0.2);
    --button-shadow-hover-color: rgba(0, 0, 0, 0.25);
    --button-shadow-active-color: rgba(0, 0, 0, 0.2);
}

body.dark-mode {
    --body-bg-color: #2c3e50; /* Darker Blue Gray */
    --container-bg-color: #34495e; /* Medium Dark Blue Gray */
    --heading-color: #ecf0f1; /* Light Gray */
    --status-text-color: #bdc3c7; /* Light Grayish Blue */
    --game-board-bg-color: #2980b9; /* Darker Blue */
    --cell-bg-color: #46627f; /* Slightly lighter than container */
    --cell-text-color: #ecf0f1; /* Light Gray */
    --cell-hover-bg-color: #5c7c99; /* Even lighter */
    --button-bg-color: #2ecc71; /* Green */
    --button-text-color: #2c3e50; /* Dark Blue Gray */
    --button-hover-bg-color: #27ae60; /* Darker Green */
    --button-disabled-bg-color: #6c7a89; /* Darker Gray for disabled */
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover-color: rgba(0, 0, 0, 0.4);
    --button-shadow-color: rgba(0, 0, 0, 0.3);
    --button-shadow-hover-color: rgba(0, 0, 0, 0.4);
    --button-shadow-active-color: rgba(0, 0, 0, 0.3);
}

body.sunset-mode {
    --body-bg-color: #ff6b6b; /* Coral Red */
    --container-bg-color: #ffe66d; /* Warm Yellow */
    --heading-color: #4d194d; /* Deep Purple */
    --status-text-color: #6a0572; /* Dark Purple */
    --game-board-bg-color: #ff8e53; /* Orange */
    --cell-bg-color: #ffeaa7; /* Light Yellow */
    --cell-text-color: #2d3436; /* Dark Gray */
    --cell-hover-bg-color: #fdcb6e; /* Golden Yellow */
    --button-bg-color: #fd79a8; /* Pink */
    --button-text-color: white;
    --button-hover-bg-color: #e84393; /* Darker Pink */
    --button-disabled-bg-color: #ddd; /* Light Gray */
    --shadow-color: rgba(0, 0, 0, 0.15);
    --shadow-hover-color: rgba(0, 0, 0, 0.2);
    --button-shadow-color: rgba(0, 0, 0, 0.2);
    --button-shadow-hover-color: rgba(0, 0, 0, 0.25);
    --button-shadow-active-color: rgba(0, 0, 0, 0.2);
}

body.forest-mode {
    --body-bg-color: #2d5016; /* Dark Forest Green */
    --container-bg-color: #68a063; /* Medium Green */
    --heading-color: #f1f8e9; /* Light Green White */
    --status-text-color: #c8e6c9; /* Light Green */
    --game-board-bg-color: #388e3c; /* Forest Green */
    --cell-bg-color: #a5d6a7; /* Light Forest Green */
    --cell-text-color: #1b5e20; /* Dark Green */
    --cell-hover-bg-color: #81c784; /* Medium Light Green */
    --button-bg-color: #8bc34a; /* Lime Green */
    --button-text-color: #1b5e20; /* Dark Green */
    --button-hover-bg-color: #689f38; /* Darker Lime */
    --button-disabled-bg-color: #757575; /* Gray */
    --shadow-color: rgba(0, 0, 0, 0.25);
    --shadow-hover-color: rgba(0, 0, 0, 0.3);
    --button-shadow-color: rgba(0, 0, 0, 0.25);
    --button-shadow-hover-color: rgba(0, 0, 0, 0.3);
    --button-shadow-active-color: rgba(0, 0, 0, 0.25);
}

body.ocean-mode {
    --body-bg-color: #0d47a1; /* Deep Blue */
    --container-bg-color: #1976d2; /* Blue */
    --heading-color: #e3f2fd; /* Very Light Blue */
    --status-text-color: #bbdefb; /* Light Blue */
    --game-board-bg-color: #1565c0; /* Medium Blue */
    --cell-bg-color: #64b5f6; /* Light Blue */
    --cell-text-color: #0d47a1; /* Deep Blue */
    --cell-hover-bg-color: #42a5f5; /* Slightly Darker Light Blue */
    --button-bg-color: #00acc1; /* Cyan */
    --button-text-color: white;
    --button-hover-bg-color: #0097a7; /* Darker Cyan */
    --button-disabled-bg-color: #90a4ae; /* Blue Gray */
    --shadow-color: rgba(0, 0, 0, 0.2);
    --shadow-hover-color: rgba(0, 0, 0, 0.25);
    --button-shadow-color: rgba(0, 0, 0, 0.25);
    --button-shadow-hover-color: rgba(0, 0, 0, 0.3);
    --button-shadow-active-color: rgba(0, 0, 0, 0.25);
}


body {
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--body-bg-color);
    margin: 0;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.hidden {
    display: none !important;
}

.choice-screen .button-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
}
.choice-screen .game-button {
    min-width: 150px;
}


.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem; /* 40px */
    background-color: var(--container-bg-color);
    border-radius: 1.5rem; /* 24px */
    box-shadow: 0 10px 20px var(--shadow-color);
    max-width: 90%;
    width: 450px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.container:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px var(--shadow-hover-color);
}

h1 {
    color: var(--heading-color);
    font-size: 2.5rem; /* 40px */
    margin-bottom: 1.5rem; /* 24px */
    text-align: center;
    font-weight: 700;
    word-break: break-word;
}
@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }
}


#gameStatus {
    color: var(--status-text-color);
    font-size: 1.5rem; /* 24px */
    margin-bottom: 1.5rem; /* 24px */
    text-align: center;
    font-weight: 500;
}
@media (max-width: 600px) {
    #gameStatus {
        font-size: 1.25rem;
    }
}

.keyboard-help {
    color: var(--status-text-color);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1rem;
    opacity: 0.7;
    font-style: italic;
}
@media (max-width: 600px) {
    .keyboard-help {
        font-size: 0.8rem;
    }
}

.game-board {
    display: grid;
    gap: 0.5rem; /* 8px */
    width: 300px; /* Base size, JS will adjust */
    height: 300px; /* Base size, JS will adjust */
    background-color: var(--game-board-bg-color);
    border-radius: 0.75rem; /* 12px */
    overflow: hidden; /* Crucial to clip the line within the board */
    margin-bottom: 2rem; /* 32px */
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1; /* Keep it square */
    position: relative; /* Allows absolute positioning of children */
}

/* Styles for when the game is over */
.game-board.game-over .cell {
    cursor: default;
    pointer-events: none;
}

.game-board.game-over .cell:hover {
    background-color: var(--cell-bg-color);
    transform: none;
}


.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--cell-bg-color);
    font-weight: 700;
    color: var(--cell-text-color);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 0.5rem; /* 8px */
    user-select: none;
    position: relative;
}

.cell:hover {
    background-color: var(--cell-hover-bg-color);
    transform: scale(1.02);
}

/* Keyboard focus styles */
.cell.focused {
    background-color: var(--cell-hover-bg-color);
    transform: scale(1.02);
    box-shadow: 0 0 0 3px var(--button-bg-color);
    z-index: 1;
}

.cell.focused:hover {
    transform: scale(1.05);
}

/* Hide default focus outline */
.cell:focus {
    outline: none;
}

.cell.x {
    color: #e74c3c; /* Red (remains constant for X) */
}

.cell.o {
    color: #2ecc71; /* Green (remains constant for O) */
}


.button-group {
    display: flex;
    gap: 1rem; /* Space between buttons */
    margin-top: 1rem;
    flex-wrap: wrap; /* Allows buttons to wrap on smaller screens */
    justify-content: center;
}

.game-button {
    display: block;
    padding: 0.75rem 1.5rem; /* 12px 24px */
    background-color: var(--button-bg-color);
    color: var(--button-text-color);
    border-radius: 0.75rem; /* 12px */
    border: none;
    font-size: 1.25rem; /* 20px */
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 5px 10px var(--button-shadow-color);
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    flex-grow: 1; /* Allows buttons to grow and fill space */
    max-width: 250px; /* Adjusted from 200px to 250px */
}

.game-button:hover {
    background-color: var(--button-hover-bg-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 15px var(--button-shadow-hover-color);
}

.game-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px var(--button-shadow-active-color);
}

.game-button:disabled {
    background-color: #95a5a6; /* Gray for disabled state */
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Responsive adjustments for buttons */
@media (max-width: 600px) {
    .button-group {
        flex-direction: column; /* Stack buttons vertically on small screens */
        align-items: center;
    }
    .game-button {
        width: 100%; /* Full width for stacked buttons */
        max-width: 250px; /* This was already 250px, ensuring consistency */
    }
}