@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(45deg, #ffffff 0%, #000000 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 1; }
    50% { transform: translateY(-20px) rotate(180deg); opacity: 0.5; }
}

.container {
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 
        0 8px 32px 0 rgba(31, 38, 135, 0.37),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    z-index: 10;
    max-width: 500px;
    width: 90%;
    transform: translateY(0);
    animation: slideIn 0.8s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 15px;
    background: linear-gradient(45deg, #fff, #100a12, #58ac97, #4ecdc4);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textGradient 3s ease-in-out infinite;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

@keyframes textGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    margin-bottom: 30px;
    opacity: 0.9;
    letter-spacing: 1px;
}

.game-modes {
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.mode-btn {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    border: none;
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    transition: all 0.4s ease;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-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;
}

.mode-btn:hover::before {
    left: 100%;
}

.mode-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(255, 107, 107, 0.4);
}

.mode-btn.active {
    background: linear-gradient(45deg, #10ac84, #00d2d3);
    box-shadow: 0 8px 25px rgba(16, 172, 132, 0.4);
    transform: scale(1.05);
}

.game-info {
    margin-bottom: 25px;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.current-player {
    font-size: 1.4rem;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.board-container {
    perspective: 1000px;
    margin-bottom: 30px;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 110px);
    grid-template-rows: repeat(3, 110px);
    gap: 8px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 25px;
    backdrop-filter: blur(15px);
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform-style: preserve-3d;
    animation: boardFloat 6s ease-in-out infinite;
}

@keyframes boardFloat {
    0%, 100% { transform: rotateX(0deg) rotateY(0deg); }
    25% { transform: rotateX(2deg) rotateY(1deg); }
    75% { transform: rotateX(-2deg) rotateY(-1deg); }
}

.cell {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    border: none;
    border-radius: 20px;
    font-size: 2.5rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #333;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: translateX(-100%) rotate(45deg);
    transition: transform 0.6s;
}

.cell:hover::before {
    transform: translateX(100%) rotate(45deg);
}

.cell:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.9));
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.cell:active {
    transform: translateY(-2px) scale(0.98);
}

.cell:disabled {
    cursor: not-allowed;
}

.cell.x {
    color: #ff6b6b;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
    animation: cellPop 0.5s ease-out;
}

.cell.o {
    color: #4ecdc4;
    text-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
    animation: cellPop 0.5s ease-out;
}

@keyframes cellPop {
    0% { transform: scale(0) rotate(180deg); }
    50% { transform: scale(1.3) rotate(90deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.winning-cell {
    background: linear-gradient(45deg, #ffd700, #ffed4a) !important;
    animation: winPulse 0.8s ease-in-out infinite alternate;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8) !important;
}

@keyframes winPulse {
    from { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
    to { 
        transform: scale(1.1) rotate(5deg);
        box-shadow: 0 0 50px rgba(255, 215, 0, 1);
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn {
    background: linear-gradient(45deg, #a55eea, #26de81);
    border: none;
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    transition: all 0.4s ease;
    box-shadow: 0 8px 25px rgba(165, 94, 234, 0.3);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.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;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(165, 94, 234, 0.4);
}

.score-section {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.score-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #ffd700;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
}

.score {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}

.score-item {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    padding: 15px 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 80px;
    transition: transform 0.3s ease;
}

.score-item:hover {
    transform: translateY(-3px);
}

.score-label {
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 0.8;
    margin-bottom: 5px;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 10% auto;
    padding: 40px;
    border-radius: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    color: white;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    animation: modalSlideIn 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: modalShine 2s ease-in-out infinite;
}

@keyframes modalShine {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 2.5rem;
    font-weight: 800;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.modal p {
    margin-bottom: 30px;
    font-size: 1.3rem;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.modal .btn {
    position: relative;
    z-index: 1;
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .board {
        grid-template-columns: repeat(3, 80px);
        grid-template-rows: repeat(3, 80px);
        gap: 6px;
        padding: 15px;
    }
    
    .cell {
        font-size: 2rem;
    }
    
    .mode-btn, .btn {
        padding: 12px 24px;
        font-size: 14px;
    }
}