* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

main {
    animation: fadeIn 0.8s ease-out;
}

h1 {
    color: white;
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.02em;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
}

.game {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 15px;
    width: 360px;
    height: 360px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.box {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    border: none;
    border-radius: 15px;
    font-size: 3rem;
    font-weight: 700;
    color: #333;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.box::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.box:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    background: linear-gradient(145deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.8));
}

.box:hover::before {
    left: 100%;
}

.box:active {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.box:disabled {
    cursor: not-allowed;
    opacity: 0.85;
}

.box:disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* X and O styling */
.box:not(:disabled):nth-child(odd) {
    color: #667eea;
}

.box:not(:disabled):nth-child(even) {
    color: #764ba2;
}

.box[disabled] {
    animation: placeMark 0.3s ease-out;
}

#reset-btn, #new-btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

#reset-btn::before, #new-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

#reset-btn:hover, #new-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

#reset-btn:hover::before, #new-btn:hover::before {
    left: 100%;
}

#reset-btn:active, #new-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.msg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 2rem;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

#msg {
    color: white;
    font-size: 4rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: bounceIn 0.6s ease-out;
}

.hide {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes placeMark {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    h1 {
        font-size: 2.5rem;
        margin-bottom: 1.5rem;
    }
    
    .game {
        width: 300px;
        height: 300px;
        gap: 12px;
        padding: 20px;
    }
    
    .box {
        font-size: 2.5rem;
        border-radius: 12px;
    }
    
    #reset-btn, #new-btn {
        padding: 0.875rem 2rem;
        font-size: 1rem;
    }
    
    #msg {
        font-size: 3rem;
    }
}

@media (max-width: 380px) {
    .game {
        width: 280px;
        height: 280px;
        gap: 10px;
        padding: 15px;
    }
    
    .box {
        font-size: 2.2rem;
    }
}