:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --background-color: #f8f9fa;
    --text-color: #2b2d42;
    --cell-color: #ffffff;
    --border-color: #e9ecef;
    --hover-color: #f1f1f1;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --modal-bg: rgba(0, 0, 0, 0.7);
    --accent-color: #f72585;
    --x-color: #4361ee;
    --o-color: #f72585;
    --mode-active: #4361ee;
    --mode-inactive: #adb5bd;
    --success-color: #4cc9f0;
    --warning-color: #f8961e;
}

[data-theme="dark"] {
    --primary-color: #4895ef;
    --secondary-color: #4361ee;
    --background-color: #121212;
    --text-color: #f8f9fa;
    --cell-color: #1e1e1e;
    --border-color: #333;
    --hover-color: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --mode-active: #4895ef;
    --mode-inactive: #495057;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.game-header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.x-color {
    color: var(--x-color);
}

.o-color {
    color: var(--o-color);
}

.theme-switch button {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--primary-color);
    padding: 0.5rem;
    border-radius: 50%;
    width: 2.8rem;
    height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.theme-switch button:hover {
    background-color: var(--hover-color);
    transform: rotate(15deg);
}

.game-container {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.mode-selector {
    display: flex;
    gap: 0.5rem;
}

.mode-btn {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 8px;
    background-color: var(--mode-inactive);
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px var(--shadow-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-btn.active {
    background-color: var(--mode-active);
    color: white;
}

.mode-btn:hover:not(.active) {
    background-color: var(--hover-color);
}

.difficulty-selector select {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background-color: var(--cell-color);
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
}

.difficulty-selector select:hover {
    border-color: var(--primary-color);
}

.game-info {
    margin-bottom: 1.5rem;
    text-align: center;
}

.player-turn {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.scoreboard {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.score {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    background-color: var(--cell-color);
    box-shadow: 0 2px 5px var(--shadow-color);
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

.game-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-width: 500px;
    width: 100%;
    aspect-ratio: 1/1;
}

.cell {
    background-color: var(--cell-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: bold;
    cursor: pointer;
    aspect-ratio: 1/1;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 6px var(--shadow-color);
    position: relative;
    overflow: hidden;
}

.cell:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 10px var(--shadow-color);
}

.cell.x {
    color: var(--x-color);
}

.cell.o {
    color: var(--o-color);
}

.cell.win {
    animation: pulse 1s infinite alternate;
    background-color: rgba(76, 201, 240, 0.1);
}

@keyframes pulse {
    from {
        box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.4);
    }
    to {
        box-shadow: 0 0 0 10px rgba(76, 201, 240, 0);
    }
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px var(--shadow-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    background-color: var(--secondary-color);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.game-footer {
    margin-top: auto;
    text-align: center;
    padding: 1rem;
    color: var(--text-color);
    opacity: 0.8;
    font-size: 0.9rem;
}

.author-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.author-link:hover {
    text-decoration: underline;
    opacity: 1;
}

.game-footer i {
    color: var(--accent-color);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 100;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--background-color);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 5px 15px var(--shadow-color);
    max-width: 400px;
    width: 90%;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.bot-thinking {
    position: relative;
}

.bot-thinking::after {
    content: "AI is thinking...";
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    animation: fadeInOut 1.5s infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    .game-title {
        font-size: 2rem;
    }

    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .mode-selector {
        justify-content: center;
    }

    .difficulty-selector {
        width: 100%;
    }

    .difficulty-selector select {
        width: 100%;
    }

    .game-board {
        gap: 0.8rem;
    }

    .cell {
        font-size: 3rem;
    }

    .player-turn {
        font-size: 1.2rem;
    }

    .scoreboard {
        gap: 0.8rem;
    }

    .score {
        padding: 0.5rem 0.8rem;
        min-width: 70px;
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .modal-content h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 400px) {
    .game-title {
        font-size: 1.8rem;
    }

    .mode-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .cell {
        font-size: 2.5rem;
    }
}