@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&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: radial-gradient(circle at 20% 30%, #0f0f1c 0%, #070813 45%, #05050f 100%);
    color: #d0d8ff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: repeating-linear-gradient(0deg, rgba(58, 76, 160, 0.2), rgba(58, 76, 160, 0.2) 1px, transparent 1px, transparent 4px),
                      repeating-linear-gradient(90deg, rgba(58, 76, 160, 0.2), rgba(58, 76, 160, 0.2) 1px, transparent 1px, transparent 4px);
    pointer-events: none;
    z-index: 0;
}


@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: linear-gradient(160deg, rgba(12, 18, 45, 0.92), rgba(20, 28, 62, 0.88));
    backdrop-filter: blur(18px);
    border-radius: 24px;
    padding: 40px;
    box-shadow:
        0 0 40px rgba(37, 116, 255, 0.35),
        inset 0 0 18px rgba(51, 108, 255, 0.35);
    border: 1px solid rgba(71, 121, 255, 0.25);
    position: relative;
    z-index: 10;
    max-width: 540px;
    width: 92%;
    transform: translateY(0);
    animation: slideIn 0.67s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.2rem;
    font-weight: 900;
    margin-bottom: 12px;
    color: #72ebff;
    text-shadow: 0 0 25px rgba(128, 255, 255, 0.5), 0 0 45px rgba(0, 156, 255, 0.3);
    letter-spacing: 1px;
    border-bottom: 2px solid rgba(114, 235, 255, 0.4);
    padding-bottom: 8px;
}

.subtitle {
    font-family: 'Poppins', sans-serif;
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 28px;
    color: #b2dfff;
    opacity: 0.95;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(45, 120, 220, 0.4);
}


.game-modes {
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.mode-btn {
    background: linear-gradient(140deg, rgba(56, 255, 234, 0.92), rgba(24, 91, 255, 0.85));
    border: 1px solid rgba(86, 204, 255, 0.9);
    color: #ffffff;
    padding: 14px 30px;
    border-radius: 28px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 0 18px rgba(20, 156, 255, 0.55), 0 6px 22px rgba(6, 24, 95, 0.45);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: left 0.45s ease;
}

.mode-btn:hover::before {
    left: 100%;
}

.mode-btn:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 0 28px rgba(35, 197, 255, 0.75), 0 8px 26px rgba(2, 12, 48, 0.5);
}

.mode-btn.active {
    background: linear-gradient(135deg, rgba(104, 229, 255, 0.95), rgba(8, 146, 255, 0.95));
    box-shadow: 0 0 30px rgba(41, 227, 255, 0.9), 0 0 12px rgba(22, 137, 210, 0.8);
    transform: translateY(-1px) 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, minmax(70px, 1fr));
    grid-template-rows: repeat(3, minmax(70px, 1fr));
    gap: 8px;
    width: min(360px, 90vw);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background: linear-gradient(160deg, rgba(7, 12, 26, 0.9), rgba(13, 21, 49, 0.85));
    padding: 10px;
    border-radius: 20px;
    backdrop-filter: blur(12px);
    box-shadow:
        0 0 30px rgba(40, 189, 255, 0.5),
        inset 0 0 14px rgba(11, 45, 94, 0.8);
    transform-style: preserve-3d;
    animation: boardFloat 7s ease-in-out infinite;
}

@keyframes boardFloat {
    0%, 100% { transform: rotateX(0deg) rotateY(0deg) scale(1); }
    25% { transform: rotateX(1.5deg) rotateY(1.5deg) scale(1.01); }
    75% { transform: rotateX(-1.5deg) rotateY(-1.5deg) scale(1.01); }
}

.cell {
    background: linear-gradient(145deg, rgba(14, 20, 41, 0.95), rgba(30, 36, 68, 0.95));
    border: 1px solid rgba(56, 175, 255, 0.5);
    border-radius: 18px;
    font-size: clamp(1.25rem, 5vw, 2.5rem);
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    color: #9be4ff;
    box-shadow:
        0 0 12px rgba(95, 224, 255, 0.45),
        inset 0 0 3px rgba(0, 101, 176, 0.65);
    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(97, 241, 255, 0.2), transparent);
    transform: translateX(-100%) rotate(45deg);
    transition: transform 0.45s;
}

.cell:hover::before {
    transform: translateX(100%) rotate(45deg);
}

.cell:hover {
    background: linear-gradient(145deg, rgba(25, 57, 120, 0.95), rgba(17, 34, 78, 0.95));
    transform: translateY(-6px) scale(1.04);
    box-shadow: 0 0 22px rgba(38, 198, 255, 0.75), 0 10px 26px rgba(0, 16, 50, 0.72);
}

.cell:active {
    transform: translateY(-1px) scale(0.97);
}

.cell:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.cell.x {
    color: #ff4f7d;
    text-shadow: 0 0 22px rgba(255, 99, 151, 0.9), 0 0 35px rgba(255, 52, 89, 0.7);
    animation: cellPop 0.36s ease-out;
}

.cell.o {
    color: #4ee3ff;
    text-shadow: 0 0 22px rgba(77, 202, 255, 0.9), 0 0 35px rgba(24, 170, 255, 0.66);
    animation: cellPop 0.36s 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, rgba(62, 245, 255, 0.9), rgba(19, 93, 255, 0.95)) !important;
    animation: winPulse 0.8s ease-in-out infinite alternate;
    box-shadow: 0 0 28px rgba(50, 255, 255, 0.95) !important;
    border: 1px solid rgba(75, 228, 255, 0.9) !important;
}

@keyframes winPulse {
    from {
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 28px rgba(46, 186, 255, 0.95);
    }
    to {
        transform: scale(1.12) rotate(3deg);
        box-shadow: 0 0 55px rgba(9, 198, 255, 1);
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn {
    background: linear-gradient(140deg, rgba(17, 217, 255, 0.95), rgba(10, 80, 210, 0.95));
    border: 1px solid rgba(102, 218, 255, 0.9);
    color: #e5fcff;
    padding: 14px 30px;
    border-radius: 26px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 0 26px rgba(21, 189, 255, 0.7), 0 8px 24px rgba(6, 26, 67, 0.6);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -110%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: left 0.35s ease;
}

.btn:hover::before {
    left: 110%;
}

.btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 0 34px rgba(20, 200, 255, 0.9), 0 12px 28px rgba(6, 20, 60, 0.65);
}

.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;
    }
}
