:root {
    --bg-color: #02020a;
    --card-bg: #101025;
    --neon-cyan: #00f2ff;
    --neon-pink: #ff007f;
    --neon-purple: #bc13fe;
    --neon-yellow: #fefe33;
    --text: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    background: radial-gradient(circle at center, #0a0a25 0%, #02020a 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* STARS */
#stars-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0.5;
    animation: twinkle var(--duration, 2s) infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* HUD */
#hud {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    z-index: 10;
}

.hud-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #8fa3c2;
    margin-bottom: 5px;
}

#moves, #matches, #timer {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--neon-cyan);
}

/* GAME BOARD */
#game-board {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* More columns to reduce rows */
    grid-gap: 8px;
    perspective: 1000px;
    margin-bottom: 10px;
    z-index: 10;
    max-height: 70vh; /* Constraint height */
}

@media (min-width: 450px) {
    #game-board {
        grid-gap: 12px;
    }
}

/* CARD */
.memory-card {
    position: relative;
    width: 100%;
    height: 100%; /* Use full height of grid cell */
    min-height: 80px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.card-face {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.card-back {
    background: linear-gradient(135deg, #1a1a3a 0%, #050510 100%);
    background-image: 
        radial-gradient(circle at 30% 30%, rgba(0, 242, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 70% 70%, rgba(254, 254, 51, 0.05) 0%, transparent 40%);
    color: var(--neon-purple);
    font-size: 2rem;
}

.card-back::after {
    content: '★';
    opacity: 0.3;
}

.card-front {
    background: var(--card-bg);
    transform: rotateY(180deg);
    border-color: var(--neon-cyan);
}

.planet-emoji {
    font-size: 1.8rem;
    margin-bottom: 3px;
}

.planet-name {
    font-size: 0.7rem;
    font-weight: 900;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* OVERLAYS */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(2, 2, 10, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
    z-index: 1000;
}

.hidden { display: none !important; }

h1 {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(to right, var(--neon-cyan), var(--neon-purple));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 20px;
}

.victory-text {
    background: linear-gradient(to right, var(--neon-cyan), var(--neon-yellow));
    -webkit-background-clip: text;
    background-clip: text;
}

.main-btn {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 900;
    border: none;
    border-radius: 30px;
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 20px var(--neon-cyan);
    cursor: pointer;
    transition: transform 0.2s;
}

.main-btn:hover { transform: scale(1.1); }

#final-stats {
    margin: 20px 0;
    font-size: 1.2rem;
    color: var(--neon-yellow);
}
