* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-hover: #222240;
    --border: #2a2a4a;
    --text: #e0e0f0;
    --text-dim: #7a7a9a;
    --x-color: #4fc3f7;
    --x-glow: rgba(79, 195, 247, 0.3);
    --o-color: #f06292;
    --o-glow: rgba(240, 98, 146, 0.3);
    --accent: #7c4dff;
    --accent-glow: rgba(124, 77, 255, 0.3);
    --win-gold: #ffd54f;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    text-align: center;
    max-width: 480px;
    width: 100%;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--x-color), var(--accent), var(--o-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.mode-btn {
    padding: 8px 24px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.mode-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Scoreboard */
.scoreboard {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.score-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 10px 24px;
    min-width: 90px;
    transition: all 0.3s ease;
}

.score-card.score-x {
    border-color: var(--x-color);
}

.score-card.score-x .score-label {
    color: var(--x-color);
}

.score-card.score-o {
    border-color: var(--o-color);
}

.score-card.score-o .score-label {
    color: var(--o-color);
}

.score-card.score-draw .score-label {
    color: var(--text-dim);
}

.score-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.score-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
}

/* Status */
.status {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 16px;
    min-height: 32px;
    line-height: 32px;
    color: var(--text-dim);
    transition: color 0.3s ease;
}

.status.win {
    color: var(--win-gold);
    text-shadow: 0 0 20px rgba(255, 213, 79, 0.4);
}

.status.draw {
    color: var(--text);
}

/* Board */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 360px;
    margin: 0 auto 24px;
    padding: 8px;
    background: var(--border);
    border-radius: 16px;
}

.cell {
    aspect-ratio: 1;
    background: var(--surface);
    border: none;
    border-radius: 12px;
    font-size: 3rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    position: relative;
}

.cell:hover:not(.taken):not(.game-over) {
    background: var(--surface-hover);
    transform: scale(1.03);
}

.cell.x {
    color: var(--x-color);
    text-shadow: 0 0 20px var(--x-glow);
}

.cell.o {
    color: var(--o-color);
    text-shadow: 0 0 20px var(--o-glow);
}

.cell.taken {
    cursor: not-allowed;
}

.cell.game-over {
    cursor: not-allowed;
}

.cell.win-cell {
    background: var(--surface-hover);
    animation: winPulse 0.6s ease infinite alternate;
}

.cell.win-cell.x {
    box-shadow: 0 0 24px var(--x-glow);
}

.cell.win-cell.o {
    box-shadow: 0 0 24px var(--o-glow);
}

@keyframes winPulse {
    from { transform: scale(1); }
    to { transform: scale(1.06); }
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.cell.animate {
    animation: popIn 0.3s ease forwards;
}

/* Buttons */
.buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-dim);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--text-dim);
    color: var(--text);
    transform: translateY(-2px);
}

/* Footer */
.footer {
    color: var(--text-dim);
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 400px) {
    h1 { font-size: 2rem; }
    .cell { font-size: 2.4rem; }
    .score-card { min-width: 75px; padding: 8px 16px; }
    .score-value { font-size: 1.4rem; }
}
