:root {
    --primary: #6c5ce7;
    --secondary: #a29bfe;
    --accent: #fd79a8;
    --bg-dark: #1e272e;
    --bg-darker: #0f1418;
    --text-light: #f5f6fa;
    --text-lighter: #ffffff;
    --x-color: #ff7675;
    --o-color: #55efc4;
    --x-bg: rgba(255, 118, 117, 0.1);
    --o-bg: rgba(85, 239, 196, 0.1);
    --cell-bg: #2d3436;
    --modal-bg: #2d3436;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background-color: var(--bg-darker);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(253, 121, 168, 0.15) 0%, transparent 50%);
    overflow-y: auto;
}

#wd{
    display: none;
}

/* Menu Screen Styles */
.menu-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
}

.menu-screen.active {
    opacity: 1;
    pointer-events: all;
}

.menu-screen:not(.active) {
    opacity: 0;
    pointer-events: none;
}

.menu-container {
    background-color: var(--bg-dark);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.menu-container h1 {
    margin-bottom: 30px;
    font-size: 2.2rem;
    font-weight: 700;
    color: #f8f8f8;
        background: linear-gradient(135deg, var(--primary), var(--accent));

}


#ox{
    margin-bottom: 25px;
        font-weight: 700;
color: #c938a9;
text-shadow: 0 2px 2px rgb(190, 100, 190);
}

.game-mode-selection #h2 {
    margin-bottom: 20px;
    color: var(--text-light);
    font-weight: 600;
}

.mode-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.mode-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background-color: var(--primary);
    color: white;
}

.start-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

.start-btn:hover {
    transform: translateY(-3px);
}

/* Game Screen Styles */
.container {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-dark);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: auto;
    display: none;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.back-to-menu {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

.current-player {
    font-size: 1rem;
    font-weight: 600;
}

.current-player.x-turn {
    color: var(--x-color);
}

.current-player.o-turn {
    color: var(--o-color);
}

.game-info {
    margin-bottom: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.score {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.score div {
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 50px;
}

.score-x {
    background-color: var(--x-color);
    color: var(--bg-darker);
}

.score-o {
    background-color: var(--o-color);
    color: var(--bg-darker);
}

.score-ties {
    background-color: var(--secondary);
    color: var(--bg-darker);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
    aspect-ratio: 1/1;
    max-height: 55vh;
}

.cell {
    background-color: var(--cell-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cell.x {
    color: var(--x-color);
    background-color: var(--x-bg);
}

.cell.o {
    color: var(--o-color);
    background-color: var(--o-bg);
}

.cell.win.x {
    box-shadow: 0 0 12px rgba(255, 118, 117, 0.5);
}

.cell.win.o {
    box-shadow: 0 0 12px rgba(85, 239, 196, 0.5);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.controls button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.restart {
    background-color: var(--primary);
    color: white;
}

.restart:hover {
    background-color: #5a4bd1;
}

.new-game {
    background-color: var(--accent);
    color: white;
}

.new-game:hover {
    background-color: #fc68a0;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--modal-bg);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    max-width: 300px;
    width: 90%;
    animation: modalFadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal h2 {
    margin-bottom: 12px;
    color: var(--text-lighter);
    font-size: 1.3rem;
    font-weight: 700;
}

.modal p {
    font-size: 0.9rem;
    margin-bottom: 15px;
    color: var(--text-light);
}

.modal button {
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.modal button:hover {
    transform: translateY(-2px);
}

/* Selection indicators */
.cell.x.selected {
    animation: xPulse 0.5s ease-out;
}

.cell.o.selected {
    animation: oPulse 0.5s ease-out;
}

@keyframes xPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px var(--x-color); }
    100% { transform: scale(1); }
}

@keyframes oPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px var(--o-color); }
    100% { transform: scale(1); }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .menu-container {
        padding: 20px;
    }
    
    .menu-container h1 {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }
    
    .game-mode-selection h2 {
        font-size: 1.1rem;
    }
    
    .mode-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .start-btn {
        padding: 10px 25px;
    }
    
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        max-width: 100%;
    }

    .cell {
        font-size: 2.2rem;
    }

    .controls {
        flex-direction: column;
        gap: 8px;
    }

    .controls button {
        width: 100%;
        padding: 8px;
    }
    
    .game-board {
        max-height: 50vh;
        gap: 6px;
    }
    
    .modal-content {
        padding: 15px;
    }
    
    .modal h2 {
        font-size: 1.1rem;
    }
    
    .modal p {
        font-size: 0.8rem;
    }
}