body {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #ff9a9e, #fad0c4, #fad0c4);
    background-size: 200% 200%;
    animation: gradientAnim 15s ease infinite;
    font-family: Arial, sans-serif;
    color: white;
    overflow: hidden;
}

#menu {
    text-align: center;
    animation: fadeIn 1s;
}

#menu h1 {
    font-size: 3em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}

#menu button {
    display: block;
    margin: 10px auto;
    padding: 10px 20px;
    font-size: 1.5em;
    background: linear-gradient(to right, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

#menu button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

#menu button:active {
    transform: scale(0.95);
}

.hidden {
    display: none;
}

#game {
    text-align: center;
    animation: fadeIn 1s;
}

#header {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    max-width: 320px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#score {
    font-size: 1.2em;
    font-weight: bold;
}

#score.update {
    animation: scoreUpdate 0.5s ease-in-out;
}

button {
    padding: 5px 10px;
    background: linear-gradient(to right, #2196F3, #1E88E5);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

button:hover {
    transform: scale(1.05);
}

button:active {
    transform: scale(0.95);
}

#board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-gap: 10px;
    margin: 0 auto;
}

.cell {
    width: 100px;
    height: 100px;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    font-weight: bold;
    cursor: pointer;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.2s;
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
    background-color: rgba(255, 255, 255, 1);
}

.cell.x::before {
    content: 'X';
    color: #FF5722;
    animation: placeAnim 0.6s ease-out;
}

.cell.o::before {
    content: 'O';
    color: #2196F3;
    animation: placeAnim 0.6s ease-out;
}

.cell.win {
    animation: winAnim 1s infinite alternate ease-in-out;
}

#back-to-menu {
    margin-top: 20px;
    background: linear-gradient(to right, #f44336, #e53935);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes placeAnim {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(360deg); opacity: 1; }
    100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

@keyframes winAnim {
    from { background-color: rgba(255, 255, 255, 0.8); transform: scale(1); }
    to { background-color: #FFD700; transform: scale(1.1); }
}

@keyframes gradientAnim {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes scoreUpdate {
    0% { transform: scale(1); color: white; }
    50% { transform: scale(1.3); color: #FFD700; }
    100% { transform: scale(1); color: white; }
}

@media (orientation: landscape) {
    #board {
        grid-template-columns: repeat(3, 80px);
    }
    .cell {
        width: 80px;
        height: 80px;
        font-size: 3em;
    }
}