:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a8a5e6;
    --background-color: #f9f9f9;
    --cell-size: 100px;
}

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

body {
    font-family: 'Quicksand', sans-serif;
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    text-align: center;
    padding: 2rem;
    position: relative;
}

.title {
    font-family: 'Fredoka One', cursive;
    color: var(--primary-color);
    font-size: 3.5rem;
    margin-bottom: 2rem;
    text-shadow: 3px 3px 0px var(--secondary-color);
}

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

/* Settings Button */
.settings-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
}

.settings-button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Settings Menu */
.settings-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.settings-menu.hidden {
    opacity: 0;
    pointer-events: none;
}

.settings-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    width: 90%;
    max-width: 400px;
}

.settings-content h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-family: 'Fredoka One', cursive;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.setting-item label {
    font-weight: 700;
    color: var(--primary-color);
}

.setting-item input[type="color"] {
    width: 50px;
    height: 50px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.setting-item input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-family: 'Quicksand', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.setting-item input[type="text"]:focus {
    border-color: var(--secondary-color);
}

.close-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
    padding: 0.5rem;
    line-height: 1;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.scoreboard-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.scoreboard {
    display: flex;
    gap: 2rem;
    background: white;
    padding: 1rem 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.score-item {
    text-align: center;
    min-width: 100px;
}

.score-item h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.score-item span {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, var(--cell-size));
    grid-template-rows: repeat(3, var(--cell-size));
    gap: 10px;
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cell {
    background: var(--background-color);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.cell:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

.cell.player-x {
    color: #2ecc71;
}

.cell.computer-o {
    color: #e74c3c;
}

.button-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#reset-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#reset-button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Game Over Popover */
.game-over-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-over-popup.show {
    opacity: 1;
    pointer-events: auto;
}

.game-over-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border-top: 6px solid;
}

.game-over-content.player-win {
    border-color: #2ecc71;
}

.game-over-content.computer-win {
    border-color: #e74c3c;
}

.game-over-content.draw {
    border-color: #f1c40f;
}

.game-over-content h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.game-over-content.player-win h2 {
    color: #2ecc71;
}

.game-over-content.computer-win h2 {
    color: #e74c3c;
}

.game-over-content.draw h2 {
    color: #f1c40f;
}

/* Move reset button styles to be more generic since it will be used in popover */
.action-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.action-button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Two Player Toggle Styles */
.toggle-container {
    display: flex;
    align-items: center;
}

.toggle-container input[type="checkbox"] {
    display: none;
}

.toggle-label {
    position: relative;
    padding-left: 50px;
    cursor: pointer;
    font-weight: 700;
    color: var(--primary-color);
}

.toggle-label:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 20px;
    background-color: #ddd;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.toggle-label:after {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
}

input[type="checkbox"]:checked + .toggle-label:before {
    background-color: var(--primary-color);
}

input[type="checkbox"]:checked + .toggle-label:after {
    left: 22px;
}

.player-two-setting.hidden {
    display: none;
}

/* Update scoreboard for two-player mode */
.score-item.player-two {
    color: #e74c3c;
}

.turn-indicator {
    font-family: 'Fredoka One', cursive;
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 1rem 0;
    text-shadow: 2px 2px 0px var(--secondary-color);
}

@media (max-width: 600px) {
    :root {
        --cell-size: 80px;
    }

    .container {
        padding: 1rem;
    }

    .title {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .scoreboard {
        gap: 0.5rem;
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .score-item {
        min-width: 70px;
    }

    .score-item h3 {
        font-size: 0.9rem;
    }

    .score-item span {
        font-size: 1.2rem;
    }

    .game-board {
        padding: 10px;
        gap: 5px;
    }

    .cell {
        font-size: 2.5rem;
    }

    .button-container {
        gap: 0.5rem;
    }

    #reset-button {
        padding: 0.6rem 1.2rem;
        font-size: 1rem;
    }

    .settings-button {
        width: 40px;
        height: 40px;
        padding: 0.6rem;
    }

    .game-over-content h2 {
        font-size: 1.5rem;
    }

    .action-button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 350px) {
    :root {
        --cell-size: 60px;
    }

    .title {
        font-size: 1.8rem;
    }

    .score-item {
        min-width: 60px;
    }

    .cell {
        font-size: 2rem;
    }
}