:root {
    --bg-color: #2c3e50;
    --container-color: #34495e;
    --text-color: #ecf0f1;
    --x-color: #3498db;
    --o-color: #f1c40f;
    --win-color: #16a085;
    --btn-color: #e74c3c;
    --btn-hover-color: #c0392b;
    --active-player-bg: #4a627a;
}

body.light-mode {
    --bg-color: #ecf0f1;
    --container-color: #ffffff;
    --text-color: #2c3e50;
    --x-color: #2980b9;
    --o-color: #f39c12;
    --win-color: #1abc9c;
    --btn-color: #e74c3c;
    --btn-hover-color: #c0392b;
    --active-player-bg: #bdc3c7;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    text-align: center;
    background-color: var(--container-color);
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    transition: background-color 0.3s;
}

.header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
}

h1 {
    font-size: 2.5rem;
    margin: 0;
}

.theme-btn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.selection-container h2, .selection-container h3 {
    margin: 15px 0 10px;
}

.options-group {
    margin-bottom: 20px;
}

.btn {
    background-color: var(--x-color);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    margin: 5px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn.active, .btn:focus {
    outline: 2px solid var(--o-color);
}

.scoreboard {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
}

.score-box {
    padding: 10px 20px;
    border-radius: 10px;
    transition: background-color 0.3s;
}

.score-box.active {
    background-color: var(--active-player-bg);
}

.score-box span {
    display: block;
    font-size: 1.2rem;
}

.score-box span:last-child {
    font-size: 1.5rem;
    font-weight: bold;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
    gap: 10px;
    margin: 20px auto;
}

.cell {
    background-color: var(--bg-color);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4.5rem;
    font-weight: bold;
}

.cell.x { color: var(--x-color); }
.cell.o { color: var(--o-color); }

.cell.win {
    background-color: var(--win-color);
}

.cell .symbol {
    animation: scaleUp 0.3s ease-in-out;
}

@keyframes scaleUp {
    from { transform: scale(0.2); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.status {
    font-size: 1.2rem;
    height: 30px;
}

.restart-btn {
    background-color: var(--btn-color);
    color: #fff;
    border: none;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 10px;
}

.restart-btn:hover { background-color: var(--btn-hover-color); }

.game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.hidden { display: none; }