:root {
    --color-bg-start: #020024;
    --color-bg-mid: #090979;
    --color-bg-end: #002d3a;
    --color-player: #00e5ff;
    --color-planet-1: #ff6a00;
    --color-planet-2: #d900ff;
    --color-planet-3: #00ff88;
    --color-item: #ffffff;
    --color-text: #ffffff;
    --color-particle: #ffeb3b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
    background: #000000;
    color: var(--color-text);
}

/* Space background layer */
#space-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: radial-gradient(ellipse at bottom, #0a0a1a 0%, #000000 100%);
    overflow: hidden;
    will-change: contents;
    transform: translateZ(0); /* Force GPU acceleration */
}

/* Stars - optimized for performance */
.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    will-change: opacity, transform;
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden; /* Optimize rendering */
}

.star-small {
    width: 1px;
    height: 1px;
    box-shadow: 0 0 1px white;
}

.star-medium {
    width: 2px;
    height: 2px;
    box-shadow: 0 0 2px white;
}

.star-large {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 3px white;
}

/* Distant planets - optimized */
.distant-planet {
    position: absolute;
    border-radius: 50%;
    opacity: 0.3;
    will-change: transform;
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden;
}

.distant-planet-1 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle at 30% 30%, #4a4a6a, #2a2a4a);
    top: 10%;
    left: 15%;
    animation: float 20s infinite ease-in-out;
}

.distant-planet-2 {
    width: 150px;
    height: 150px;
    background: radial-gradient(circle at 40% 40%, #6a4a4a, #4a2a2a);
    top: 60%;
    right: 20%;
    animation: float 25s infinite ease-in-out reverse;
}

.distant-planet-3 {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at 50% 50%, #4a6a4a, #2a4a2a);
    bottom: 15%;
    left: 70%;
    animation: float 30s infinite ease-in-out;
}

/* Animations - optimized */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1) translateZ(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) translateZ(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) translateZ(0);
    }
    33% {
        transform: translate(15px, -15px) translateZ(0);
    }
    66% {
        transform: translate(-15px, 15px) translateZ(0);
    }
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* Disable tap highlight on mobile */
    z-index: 1;
}

#game-world {
    position: absolute;
    /* We will center the world, so 0,0 is the middle of the screen */
    top: 50%;
    left: 50%;
    width: 1px;
    height: 1px;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Smooth camera movement */
    will-change: transform;
}

.planet {
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    transform-origin: center center;
    box-shadow: 
        0 0 20px rgba(255, 255, 255, 0.1),
        inset -8px -8px 25px rgba(0, 0, 0, 0.35),
        inset 8px 8px 25px rgba(255, 255, 255, 0.08);
    /* Thêm overflow: hidden để giữ marker bên trong */
    overflow: hidden;
    /* Add texture with fewer radial gradients for better performance */
    background-image: 
        radial-gradient(circle at 30% 40%, rgba(0, 0, 0, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(0, 0, 0, 0.2) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 35%);
    background-blend-mode: multiply, multiply, screen;
}

/* Thêm marker để hiển thị vòng quay */
.planet::before {
    content: '';
    position: absolute;
    width: 30%; /* 30% kích thước hành tinh */
    height: 30%; /* 30% kích thước hành tinh */
    background: rgba(0, 0, 0, 0.3); /* Đốm đen (miệng núi lửa) */
    border-radius: 50%;
    /* Đặt lệch tâm */
    top: 20%;
    left: 20%;
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.7),
        inset 2px 2px 5px rgba(255, 255, 255, 0.1),
        0 0 5px rgba(0, 0, 0, 0.5);
}

/* Additional crater marker */
.planet::after {
    content: '';
    position: absolute;
    width: 15%;
    height: 15%;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    top: 65%;
    right: 25%;
    box-shadow: 
        inset 0 0 8px rgba(0, 0, 0, 0.6),
        inset 1px 1px 3px rgba(255, 255, 255, 0.08);
}

/* Planet craters - deep impact craters (simplified for performance) */
.planet-crater {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.25) 40%, transparent 70%);
    box-shadow: 
        inset 0 0 12px rgba(0, 0, 0, 0.7),
        inset 2px 2px 6px rgba(255, 255, 255, 0.08);
    pointer-events: none;
    z-index: 1;
    will-change: transform;
    transform: translateZ(0); /* GPU acceleration */
}

/* Planet highlights - raised areas/ridges (simplified for performance) */
.planet-highlight {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.04) 50%, transparent 80%);
    box-shadow: 
        inset -2px -2px 6px rgba(0, 0, 0, 0.25),
        inset 2px 2px 6px rgba(255, 255, 255, 0.15);
    pointer-events: none;
    z-index: 1;
    will-change: transform;
    transform: translateZ(0); /* GPU acceleration */
}

#player {
    position: absolute;
    width: 24px;
    height: 24px;
    /* Center the SVG */
    margin-left: -12px;
    margin-top: -12px;
    will-change: transform;
    transform-origin: 50% 50%;
    z-index: 10;
}

#player-svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 0 5px var(--color-player));
}

.orbit-item {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--color-item);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-item);
    margin-left: -5px;
    margin-top: -5px;
    will-change: transform;
    z-index: 5;
}

.particle {
    position: absolute;
    background: var(--color-particle);
    border-radius: 50%;
    animation: particle-effect 0.7s ease-out forwards;
    will-change: transform, opacity;
    z-index: 20;
}

/* Smoke trail - light effect */
.smoke-trail {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(200, 200, 200, 0.3) 40%, rgba(150, 150, 150, 0.2) 60%, transparent 80%);
    pointer-events: none;
    z-index: 8;
    will-change: transform, opacity;
    transform: translateZ(0); /* GPU acceleration */
    backface-visibility: hidden;
}

/* Particle animation: burst out and fade */
@keyframes particle-effect {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0) translate(var(--tx), var(--ty));
        opacity: 0;
    }
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through to the game */
    z-index: 100;
}

#score-display {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 4rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    opacity: 0.8;
}

#game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    padding: 30px 40px;
    text-align: center;
    display: none; /* Hidden by default */
    pointer-events: all; /* Enable interaction */
    flex-direction: column;
    gap: 15px;
}

#game-over-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 0;
}

#game-over-screen p {
    font-size: 1.2rem;
    margin: 5px 0;
}

#retry-button {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    background: var(--color-player);
    color: var(--color-bg-start);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    margin-top: 10px;
    box-shadow: 0 5px 0 #008f9e;
}

#retry-button:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #008f9e;
}

