* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007bff;
    --secondary-color: #ff6b6b;
    --text-color: #333;
    --bg-color: #f0f2f5;
    --board-color: #333;
}

[data-theme="dark"] {
    --primary-color: #4dabf7;
    --secondary-color: #ff8787;
    --text-color: #fff;
    --bg-color: #1a1a1a;
    --board-color: #fff;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.container {
    text-align: center;
    padding: 20px;
    max-width: 400px;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 2rem;
}

#theme-select {
    padding: 5px;
    border-radius: 5px;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--primary-color);
}

.status {
    margin: 15px 0;
    font-size: 1.2rem;
    font-weight: bold;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    width: 100%;
    aspect-ratio: 1;
    max-width: 300px;
    margin: 0 auto;
}

.game-board.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.cell {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.cell:not(:nth-child(3n)):before {
    content: '';
    position: absolute;
    right: -2.5px;
    width: 2px;
    height: 100%;
    background: var(--board-color);
}

.cell:not(:nth-last-child(-n+3)):after {
    content: '';
    position: absolute;
    bottom: -2.5px;
    width: 100%;
    height: 2px;
    background: var(--board-color);
}

.cell.x {
    color: var(--primary-color);
    animation: pop 0.3s ease;
}

.cell.o {
    color: var(--secondary-color);
    animation: pop 0.3s ease;
}

.cell:hover:not(.x):not(.o) {
    transform: scale(1.05);
}

#reset-btn {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#reset-btn:hover {
    transform: scale(1.05);
}

@keyframes pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

#confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0.8;
    animation: fall 2s linear forwards;
}

@keyframes fall {
    0% { transform: translateY(-100vh) rotate(0deg); }
    100% { transform: translateY(100vh) rotate(720deg); }
}

.rain-drop {
    position: absolute;
    width: 2px;
    height: 20px;
    background: #4dabf7;
    opacity: 0.7;
    animation: rain 1s linear forwards;
}

@keyframes rain {
    0% { transform: translateY(-100vh); }
    100% { transform: translateY(100vh); }
}

.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.popup-content {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.popup-content h2 {
    margin-bottom: 15px;
}

.popup-content button {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.popup-content button:hover {
    transform: scale(1.05);
}

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    .cell { font-size: 2rem; }
    .status { font-size: 1rem; }
}