:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.7);
    --border-color: #30363d;
    --text-color: #e6edf3;
    --x-color: #58a6ff;
    --o-color: #ff7b72;
    --accent: #bc8cff;
    --hover-bg: rgba(255, 255, 255, 0.05);
    --win-bg: rgba(88, 166, 255, 0.15);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: radial-gradient(circle at top right, rgba(88, 166, 255, 0.1), transparent 40%),
                      radial-gradient(circle at bottom left, rgba(188, 140, 255, 0.1), transparent 40%);
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: var(--panel-bg);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    width: 90%;
    max-width: 500px;
}

header {
    width: 100%;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--x-color), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(188, 140, 255, 0.3);
}

.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.mode-toggle button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.mode-toggle button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 15px rgba(188, 140, 255, 0.4);
}

.scoreboard {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 1.5rem;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    min-width: 100px;
}

.x-score {
    border-bottom: 3px solid var(--x-color);
}

.o-score {
    border-bottom: 3px solid var(--o-color);
}

.player-label {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-card span:last-child {
    font-size: 1.5rem;
    font-weight: 800;
}

.turn-indicator {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    display: inline-block;
    transition: color 0.3s ease;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 10px;
    background: var(--border-color);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.cell {
    width: 90px;
    height: 90px;
    background: var(--panel-bg);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

@media (max-width: 400px) {
    .cell {
        width: 75px;
        height: 75px;
        font-size: 2.8rem;
    }
}

.cell:hover:not(.filled) {
    background: var(--hover-bg);
    transform: scale(0.98);
}

.cell.filled {
    cursor: default;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.x {
    color: var(--x-color);
    text-shadow: 0 0 15px rgba(88, 166, 255, 0.4);
}

.cell.o {
    color: var(--o-color);
    text-shadow: 0 0 15px rgba(255, 123, 114, 0.4);
}

.cell.winning-cell {
    background: var(--win-bg);
    animation: highlightWin 1s infinite alternate;
}

.btn {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    background: var(--hover-bg);
}

.btn.primary {
    background: linear-gradient(135deg, var(--x-color), var(--accent));
    border: none;
    color: #fff;
}

.btn.primary:hover {
    box-shadow: 0 0 20px rgba(188, 140, 255, 0.4);
    transform: translateY(-2px);
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

#modal-message {
    font-size: 2rem;
    margin-bottom: 2rem;
    font-weight: 800;
}

/* Animations */
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes highlightWin {
    0% { box-shadow: inset 0 0 0 transparent; }
    100% { box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.2); }
}
