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

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

/* Animated background particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-30px) rotate(120deg); }
    66% { transform: translateY(15px) rotate(240deg); }
}

h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
    text-align: center;
    margin-bottom: 2rem;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
}

.game {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 15px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 25px 45px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: gameAppear 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes gameAppear {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.box {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 15px;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.box::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transition: left 0.5s;
}

.box:hover::before {
    left: 100%;
}

.box:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.2),
        0 0 20px rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 1);
}

.box:active {
    transform: translateY(-2px) scale(1.02);
}

.box:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.box.x-mark {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    animation: markAppear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.box.o-mark {
    color: #4ecdc4;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
    animation: markAppear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes markAppear {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(90deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.winning-line {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    animation: winningGlow 1s ease-in-out infinite alternate;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
}

@keyframes winningGlow {
    0% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.8); }
    100% { box-shadow: 0 0 35px rgba(255, 215, 0, 1), 0 0 50px rgba(255, 215, 0, 0.5); }
}

#reset, #new {
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 1rem;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

#reset::before, #new::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;
}

#reset:hover::before, #new:hover::before {
    left: 100%;
}

#reset:hover, #new:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
    background: linear-gradient(45deg, #7c8cff, #8a5cb8);
}

#reset:active, #new:active {
    transform: translateY(-1px);
}

.msg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 2rem;
    z-index: 1000;
    animation: modalAppear 0.5s ease-out;
}

@keyframes modalAppear {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    100% {
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

#msg {
    color: #fff;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 700;
    text-align: center;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 2s ease-in-out infinite, messageAppear 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
}

@keyframes messageAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.hide {
    display: none !important;
}

/* Turn indicator */
.turn-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    padding: 15px 25px;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    animation: indicatorPulse 2s ease-in-out infinite;
}

@keyframes indicatorPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.turn-x {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.turn-o {
    color: #4ecdc4;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

/* Score board */
.scoreboard {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.score-item {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
    min-width: 120px;
}

.score-x { color: #ff6b6b; }
.score-o { color: #4ecdc4; }
.score-draw { color: #ffd700; }

/* Responsive design */
@media (max-width: 768px) {
    .game {
        padding: 15px;
        gap: 10px;
    }
    
    .box {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    .turn-indicator, .scoreboard {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        margin: 10px;
    }
    
    h1 {
        margin-bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .box {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
    
    .game {
        gap: 8px;
        padding: 12px;
    }
}

/* Sound effect visual feedback */
.box.clicked {
    animation: clickFeedback 0.3s ease-out;
}

@keyframes clickFeedback {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Confetti animation for winner */
.confetti {
    position: fixed;
    top: -10px;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    animation: confetti-fall 3s linear infinite;
}

.confetti:nth-child(2n) { background: #4ecdc4; animation-delay: 0.5s; }
.confetti:nth-child(3n) { background: #ffd700; animation-delay: 1s; }
.confetti:nth-child(4n) { background: #45b7d1; animation-delay: 1.5s; }

@keyframes confetti-fall {
    0% {
        transform: translateX(-50%) translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}