@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;900&display=swap');

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: #0b0b1a; /* Deep space dark color */
    background-image: radial-gradient(circle at 50% 50%, #1a1a3a 0%, #0b0b1a 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent scrolling */
}

/* --- Container for fixed iPhone 14 Pro view --- */
.game-wrapper {
    width: 393px;
    height: 852px;
    position: relative;
    background-color: #0a0a14;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 20px rgba(100, 100, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 8px solid #1a1a2e; /* Subtle phone-like border */
    border-radius: 40px; /* iPhone-like rounded corners */
    transform-origin: center center;
}

/* Responsive scaling to fit any screen */
@media (max-width: 410px), (max-height: 870px) {
    .game-wrapper {
        transform: scale(min(calc(100vw / 410), calc(100vh / 870)));
    }
}

/* Base stars anim for background */
.stars {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    background: transparent url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><circle cx="40" cy="40" r="1" fill="white" opacity="0.5"/><circle cx="150" cy="80" r="1.5" fill="white" opacity="0.8"/><circle cx="90" cy="160" r="1" fill="white" opacity="0.3"/></svg>') repeat;
    z-index: 0;
    animation: drift 60s linear infinite;
}

@keyframes drift {
    from { background-position: 0 0; }
    to { background-position: -200px 200px; }
}

/* --- Start Screen --- */
.start-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 20px;
}

.logo-container {
    margin-bottom: 40px;
    animation: floatLogo 4s ease-in-out infinite;
    text-align: center;
}

@keyframes floatLogo {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.logo-text {
    font-size: 3rem;
    font-weight: 900;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4), 0 0 30px rgba(0, 200, 255, 0.6);
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

.logo-sub {
    font-size: 1.2rem;
    color: #a0a0c0;
    letter-spacing: 2px;
}

.start-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 30px;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(118, 75, 162, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 40px;
}

.start-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 25px rgba(118, 75, 162, 0.6);
}

.start-btn:active {
    transform: translateY(2px);
}

/* --- Game Screen UI --- */
.game-header {
    height: 100px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(10,10,20,0.9) 0%, rgba(10,10,20,0) 100%);
}

.score-panel {
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 0.9rem;
    color: #a0a0c0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.next-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.next-label {
    font-size: 0.9rem;
    color: #a0a0c0;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.next-container {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Gravity Indicator */
.gravity-hud {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 40, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(100, 150, 255, 0.3);
    padding: 5px 15px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.gravity-icon {
    font-size: 1.2rem;
    color: #4facfe;
    transition: transform 0.3s;
}

.gravity-icon.up { transform: rotate(180deg); color: #ff5e62; }

.gravity-text {
    font-size: 0.9rem;
    font-weight: 700;
}

/* Game Area */
.game-area {
    flex: 1;
    position: relative;
    width: 100%;
}

/* The actual canvas used by matter js */
#game-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 1; /* behind dom items */
    pointer-events: none; /* Let DOM receive clicks or canvas? Matter runner needs canvas clicks? Actually we capture clicks on the wrapper */
}

/* Where we spawn actual DOM planets */
#dom-layer {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 2; /* above canvas */
    pointer-events: none;
    overflow: hidden;
}

/* Game Over line */
.danger-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,0,0,0.8), transparent);
    z-index: 5;
}
.danger-line.top { top: 100px; }
.danger-line.bottom { bottom: 100px; }
.danger-line::before {
    content: "DANGER";
    position: absolute;
    right: 10px;
    top: -20px;
    font-size: 0.8rem;
    color: rgba(255, 0, 0, 0.8);
    font-weight: bold;
    letter-spacing: 2px;
}

/* Planets CSS (From Original + Modifications for absolute positioning) */
.planet {
    position: absolute;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform-origin: center center;
    will-change: transform, left, top;
}

.moon    { width: 30px;  height: 30px;  background-image: url("../img/moon.svg"); }
.pluto   { width: 40px;  height: 40px;  background-image: url("../img/pluto.svg"); }
.mercury { width: 50px;  height: 50px;  background-image: url("../img/mercury.svg"); }
.mars    { width: 60px;  height: 60px;  background-image: url("../img/mars.svg"); }
.venus   { width: 80px;  height: 80px;  background-image: url("../img/venus.svg"); }
.earth   { width: 100px; height: 100px; background-image: url("../img/earth.svg"); }
.neptune { width: 120px; height: 120px; background-image: url("../img/neptune.svg"); }
.uranus  { width: 140px; height: 140px; background-image: url("../img/uranus.svg"); }
.uranus::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 200px; height: 47px;
    background-image: url("../img/uranus-ring.svg"); /* Changed from uranus_ring to uranus-ring based on list_dir */
}
.saturn  { width: 160px; height: 160px; background-image: url("../img/saturn.svg"); }
.saturn::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 262px; height: 59px;
    background-image: url("../img/saturn-ring.svg"); /* Changed from saturn_ring to saturn-ring */
}
.jupiter { width: 200px; height: 200px; background-image: url("../img/jupiter.svg"); }
.sun     { width: 260px; height: 260px; background-image: url("../img/sun.svg"); }

/* Indicator - half transparent */
.planet.indicator {
    opacity: 0.5;
    z-index: 10;
}

/* Popups / Overlays */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.popup {
    background: rgba(20, 20, 35, 0.9);
    border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.05);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.active .popup {
    transform: scale(1);
}

.popup h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.popup p {
    font-size: 1.2rem;
    color: #a0a0c0;
    margin-bottom: 30px;
}

.popup .final-score {
    font-size: 3rem;
    font-weight: 900;
    color: white;
    margin: 10px 0;
}

/* Blinking line check */
.blinking {
    animation: blinkGlow 0.4s infinite alternate;
}
@keyframes blinkGlow {
    from { filter: drop-shadow(0 0 5px red); }
    to { filter: drop-shadow(0 0 20px red) brightness(1.5); }
}

/* countdown */
.countdown-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px;
    font-weight: 900;
    color: #ff0844;
    text-shadow: 0 0 20px rgba(255,0,0,0.8);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
}
.countdown-text.active {
    animation: popIn 1s infinite cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}
