:root {
    /* Light Mode Colors */
    --bg-color: #f0f2f5;
    --text-color: #333;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.5);
    --primary-color: #4a90e2;
    --secondary-color: #7ed321;
    --accent-color: #f5a623;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --cell-bg: rgba(255, 255, 255, 0.2);
    --player-x: #4a90e2;
    --player-o: #f5a623;
}

body.dark-mode {
    --bg-color: #1a1c20;
    --text-color: #f0f2f5;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary-color: #5da4f5;
    --secondary-color: #92e63a;
    --accent-color: #ffb740;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --cell-bg: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Animated Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary-color);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: var(--accent-color);
    top: 40%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(50px, 100px) scale(1.1); }
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.logo span {
    color: var(--primary-color);
}

#theme-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    transition: transform 0.2s;
}

#theme-toggle:hover {
    transform: scale(1.1);
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.scoreboard {
    display: flex;
    padding: 20px;
    justify-content: space-around;
    align-items: center;
}

.player-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.player-label {
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
}

.score-divider {
    width: 1px;
    height: 40px;
    background: var(--glass-border);
}

.status-indicator {
    padding: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Game Board */
.game-container {
    display: flex;
    justify-content: center;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    padding: 15px;
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
}

.cell {
    background: var(--cell-bg);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: 700;
    transition: all 0.2s ease;
    user-select: none;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
}

body.dark-mode .cell:hover {
    background: rgba(255, 255, 255, 0.1);
}

.cell.x { color: var(--player-x); }
.cell.o { color: var(--player-o); }

.cell.x::before { content: 'X'; animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.cell.o::before { content: 'O'; animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

@keyframes pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Winning Line Overlay (Conceptual) */
#winning-line {
    position: absolute;
    background: var(--accent-color);
    border-radius: 10px;
    z-index: 2;
    pointer-events: none;
    display: none;
    transition: all 0.5s ease;
}

/* Controls */
.controls-bottom {
    display: flex;
    gap: 15px;
}

.btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.secondary {
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
}

.btn:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(0);
}

/* History */
.history {
    padding: 20px;
}

.history h3 {
    margin-bottom: 10px;
    font-size: 1rem;
}

#history-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

.history-item:last-child {
    border-bottom: none;
}

.empty-msg {
    opacity: 0.6;
    font-style: italic;
    font-size: 0.9rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

footer {
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: 10px;
}

/* Mobile Responsiveness */
@media (max-width: 400px) {
    .container { padding: 10px; }
    .cell { font-size: 2rem; }
    .score-value { font-size: 1.5rem; }
}
