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

body {
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f2f5 0%, #e6e9f0 100%);
    padding: 20px;
}

h1 {
    color: #1a1a1a;
    margin-bottom: 30px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
    color: #333;
    margin-bottom: 20px;
}

.screen {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 500px;
    width: 100%;
    transform: translateY(0);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.screen[style*='display: none'] {
    transform: translateY(20px);
    opacity: 0;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(145deg, #007bff, #0056b3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    background: linear-gradient(145deg, #0056b3, #004494);
}

button:active {
    transform: translateY(0);
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px auto;
    max-width: 300px;
    perspective: 1000px;
}

.cell {
    aspect-ratio: 1;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cell:hover {
    background: #f8f9fa;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.cell.x::before,
.cell.x::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 4px;
    background-color: #dc3545;
    border-radius: 2px;
}

.cell.x.animate::before {
    transform: rotate(45deg);
    animation: drawX1 0.3s ease forwards;
}

.cell.x.animate::after {
    transform: rotate(-45deg);
    animation: drawX2 0.3s ease forwards;
}

.cell.x::before {
    transform: rotate(45deg) scale(1);
}

.cell.x::after {
    transform: rotate(-45deg) scale(1);
}

.cell.o::before {
    content: '';
    position: absolute;
    width: 60%;
    height: 60%;
    border: 4px solid #28a745;
    border-radius: 50%;
}

.cell.o.animate::before {
    animation: drawO 0.3s ease forwards;
}

.cell.o::before {
    transform: scale(1);
    opacity: 1;
}

@keyframes drawX1 {
    from {
        transform: rotate(45deg) scale(0);
    }
    to {
        transform: rotate(45deg) scale(1);
    }
}

@keyframes drawX2 {
    from {
        transform: rotate(-45deg) scale(0);
    }
    to {
        transform: rotate(-45deg) scale(1);
    }
}

@keyframes drawO {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#status {
    font-size: 1.5rem;
    margin-top: 20px;
    font-weight: bold;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

#status.show {
    opacity: 1;
    transform: translateY(0);
}

#status.x {
    color: #dc3545;
}

#status.o {
    color: #28a745;
}

/* Add winning animation */
@keyframes winner {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.cell.winner {
    animation: winner 0.5s ease infinite;
}
