@import url('https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css');
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&family=Rubik+Mono+One&display=swap');
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css");
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css');
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css');



/********** General Styles **********/
body {
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #091021 0%, #04040a 45%, #000000 100%);
    position: relative;
    overflow-x: hidden;
}

/* Milky Way band and nebula */
body::after {
    content: "";
    position: fixed;
    left: 50%;
    top: 50%;
    width: 2200px;
    height: 640px;
    transform: translate(-50%, -50%) rotate(-14deg);
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0.95;
    margin: 0;
    padding: 0;
    height: 100vh;
    background: url('../pics/nebula.png') no-repeat center center fixed;
    background-size: cover;
    overflow-x: hidden;
    filter: blur(36px) saturate(160%);
    animation: nebulaSwirl 32s ease-in-out infinite;
}

/* layered stars */
body::before {
    margin: 0;
    padding: 0;
    height: 100vh;
    background: url('../pics/nebula.png') no-repeat center center fixed;
    background-size: cover;
    overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {

    body::before,
    body::after {
        animation: none;
    }
}

.game-wrapper {
    max-width: 950px;
    margin: 0 auto;
}

/* Login overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.6);
    z-index: 1500;
}

.login-card {
    background: #0b1220;
    /* solid, opaque background */
    color: #f8fafc;
    padding: 1.25rem;
    border-radius: 12px;
    width: 340px;
    max-width: calc(100% - 32px);
    box-shadow: 0 10px 40px rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.glass-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* This should be the grid for the game board, which will contain the cards. I want to make it a 4x4 grid, so I will use the CSS grid layout to achieve this. I will also add some gap between the cards to make it look nicer. */
.game-board {
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), minmax(0, var(--cardWidth, 140px)));
    gap: 0.9rem;
    justify-content: center;
    width: 100%;
}

.memory-card {
    aspect-ratio: 1 / 1;
    /* This will make the card a square, regardless of the content inside it. */
    perspective: 1000px;
    /* This will give the card a 3D effect when it is flipped. */
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
    will-change: transform;
}

.memory-card:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.45);
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.68s cubic-bezier(.2, .85, .32, 1);
    transform-style: preserve-3d;
    will-change: transform;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    user-select: none;
    font-size: 1.6rem;
    font-weight: 700;
    box-shadow: 0 0.5rem rgba(0, 0, 0, 0.2);
}

.memory-front {
    background: linear-gradient(135deg, #6b7280, #1e293b);
    color: #212529;
}

.memory-back {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #f8f9fa;
    transform: rotateY(180deg);
}

.memory-card.matched .memory-back {
    background: linear-gradient(135deg, #10b981, #1e293b);
    color: #212529;
}

.memory-card.matched {
    animation: match-pop 560ms cubic-bezier(.2, .9, .3, 1);
}

@keyframes match-pop {
    0% {
        transform: scale(1);
        box-shadow: 0 8px 18px rgba(16, 185, 129, 0.08);
    }

    50% {
        transform: scale(1.06);
        box-shadow: 0 14px 38px rgba(16, 185, 129, 0.18);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 8px 18px rgba(16, 185, 129, 0.08);
    }
}

#message {
    min-height: 2rem;
}

@media (max-width: 768px) {
    .game-board {
        gap: 0.65rem;
    }

    .memory-face {
        font-size: 1.25rem;
    }
}


@media (max-width: 575.98px) {
    .game-board {
        gap: 0.5rem;
    }

    .memory-face {
        font-size: 1rem;
    }
}