@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;900&display=swap');

:root {
    --color-blue: #00d2ff;
    --color-red: #ff2a5f;
    --color-yellow: #ffcc00;
    --color-green: #39ff14;
    --color-purple: #9d00ff;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: #0b0f19;
    /* Darker space background */
    font-family: 'Outfit', sans-serif;
    color: white;
}

body::before,
body::after {
    content: '';
    position: fixed;
    width: 70vw;
    height: 70vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    animation: drift 25s infinite alternate ease-in-out;
}

body::before {
    background: radial-gradient(circle, var(--color-purple), transparent 60%);
    top: -20%;
    left: -20%;
}

body::after {
    background: radial-gradient(circle, var(--color-green), var(--color-blue), transparent 60%);
    bottom: -20%;
    right: -20%;
    animation-delay: -12s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(15vw, 15vh) scale(1.3);
    }
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    animation: floatUp 10s linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
        transform: translateY(80vh) scale(1);
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-10vh) scale(0.5);
        opacity: 0;
    }
}

/* Games Container */
.games-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 20px 40px;
    gap: 30px;
    min-height: 100vh;
    box-sizing: border-box;
    width: 100%;
}

.glass-container {
    background: rgba(20, 25, 40, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(157, 0, 255, 0.2);
    border-radius: 24px;
    padding: 30px 40px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(57, 255, 20, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    position: relative;
    overflow: hidden;
    width: 380px;
}

.new-board-anim {
    animation: slideIn 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes slideIn {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.glass-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(57, 255, 20, 0.05), transparent);
    transform: skewX(-45deg);
    animation: shine 8s infinite;
}

@keyframes shine {
    0% {
        left: -150%;
    }

    100% {
        left: 150%;
    }
}

/* Global Controls */
.global-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 100;
}

.icon-btn {
    background: rgba(20, 25, 40, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(157, 0, 255, 0.4);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-blue);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.icon-btn:hover {
    box-shadow: 0 0 15px var(--color-blue);
    transform: scale(1.1);
    color: white;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.glass-panel {
    background: rgba(20, 25, 40, 0.85);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(57, 255, 20, 0.3);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    color: white;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 210, 255, 0.1);
    position: relative;
    font-size: 1.1rem;
    line-height: 1.6;
}

.glass-panel h2 {
    color: var(--color-green);
    margin-top: 0;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

.glass-panel ul {
    padding-left: 20px;
}

.glass-panel li {
    margin-bottom: 15px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.close-btn:hover {
    color: var(--color-red);
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: -10px;
}

.ufo-logo {
    width: 60px;
    height: 60px;
    animation: hoverUFO 3s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 15px var(--color-green));
}

@keyframes hoverUFO {
    0% {
        transform: translateY(0px) rotate(-8deg);
    }

    100% {
        transform: translateY(-12px) rotate(8deg);
    }
}

.title {
    margin: 10px 0 5px 0;
    font-size: 2.2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    background: linear-gradient(90deg, var(--color-green), var(--color-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
    line-height: 1.1;
}

.subtitle {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--color-blue);
    margin-bottom: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.4);
}

.status {
    font-size: 1.2rem;
    margin-bottom: 25px;
    font-weight: 700;
    letter-spacing: 2px;
    transition: color 0.3s ease;
    text-transform: uppercase;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 85px);
    grid-template-rows: repeat(3, 85px);
    gap: 12px;
    margin-bottom: 30px;
}

.cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.01);
}

.cell:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.cell:active {
    transform: scale(0.95);
}

.cell.x {
    color: var(--color-green);
    text-shadow: 0 0 15px var(--color-green), 0 0 30px var(--color-green);
    cursor: default;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.o {
    color: var(--color-purple);
    text-shadow: 0 0 15px var(--color-purple), 0 0 30px var(--color-purple);
    cursor: default;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.5) rotate(-30deg);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.cell.fading {
    opacity: 0.4;
    animation: pulseFade 1.5s infinite alternate;
    border-color: rgba(255, 255, 255, 0.5);
}

@keyframes pulseFade {
    0% {
        opacity: 0.2;
        transform: scale(0.95);
        box-shadow: inset 0 0 20px rgba(255, 42, 95, 0.5);
    }

    100% {
        opacity: 0.5;
        transform: scale(1);
        box-shadow: inset 0 0 50px rgba(255, 42, 95, 0.8);
    }
}

/* Invalid Click Feedback */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px) rotate(-2deg);
    }

    75% {
        transform: translateX(5px) rotate(2deg);
    }
}

.cell.invalid {
    animation: shake 0.3s cubic-bezier(.36, .07, .19, .97) both;
    border-color: var(--color-red) !important;
}

.cell.winning {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--color-yellow);
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.7);
    z-index: 2;
    animation: pulse 1.5s infinite alternate;
    opacity: 1 !important;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
    }

    100% {
        transform: scale(1.1);
        box-shadow: 0 0 50px rgba(255, 204, 0, 1);
        border-color: white;
    }
}

.controls {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    /* Just in case */
}

.reset-btn {
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.add-game-btn {
    background: linear-gradient(135deg, var(--color-green), #009944);
}

.add-game-btn:hover {
    box-shadow: 0 8px 25px rgba(57, 255, 20, 0.6) !important;
}

.remove-game-btn {
    background: linear-gradient(135deg, var(--color-red), #990022);
}

.remove-game-btn:hover {
    box-shadow: 0 8px 25px rgba(255, 42, 95, 0.6) !important;
}

.reset-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(157, 0, 255, 0.6);
}

.reset-btn:hover::after {
    opacity: 1;
}

.reset-btn:active {
    transform: translateY(2px);
}