:root {
    --space-bg: #0b0d17;
    --panel-bg: rgba(255, 255, 255, 0.1);
    --accent-color: #ffd700;
    --text-color: #ffffff;
    --moon-color: #f0f0f0;
    --shadow-color: #1a1a1a;
}

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

body {
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    background-color: var(--space-bg);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    background-image:
        radial-gradient(white, rgba(255, 255, 255, .2) 2px, transparent 3px),
        radial-gradient(white, rgba(255, 255, 255, .15) 1px, transparent 2px),
        radial-gradient(white, rgba(255, 255, 255, .1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
}

.container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

h2 {
    font-size: 1.2rem;
    margin: 0;
    color: #a0a0ff;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.toggle-switch input {
    display: none;
}

.toggle-switch .slider {
    width: 36px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
}

.toggle-switch .slider:before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.slider {
    background-color: var(--accent-color);
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(16px);
}

.main-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .main-display {
        grid-template-columns: 1fr;
    }
}

.simulation-panel,
.view-panel {
    background: var(--panel-bg);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Space View Simulation */
.space-view {
    position: relative;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sun-direction {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    z-index: 10;
}

.sun-icon {
    font-size: 3rem;
    display: block;
}

.sun-rays {
    width: 100px;
    height: 200px;
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to left, rgba(255, 215, 0, 0.2), transparent);
    pointer-events: none;
}

.orbit-system {
    position: relative;
    width: 200px;
    height: 200px;
}

.orbit-lines {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

.earth {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    z-index: 5;
}

.moon-orbit {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.moon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin-top: -15px;
    margin-left: -15px;
    background: var(--moon-color);
    border-radius: 50%;
    /* Start at right side (New Moon position relative to sun on right) */
    /* Wait, if sun is on right, New Moon is between Earth and Sun. So Moon should be on right. */
    /* We will control rotation via JS */
}

/* The moon in space view always has its right side lit (facing sun) */
.moon-lit-side {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: #fff;
    border-radius: 0 15px 15px 0;
}

.moon-shadow-side {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: #333;
    border-radius: 15px 0 0 15px;
}

.observer-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 20;
    /* Will be rotated by JS */
}

.observer-icon {
    position: absolute;
    top: -15px;
    /* Adjust based on Earth size */
    left: -5px;
    font-size: 1.5rem;
    transform: translateY(-25px);
    /* Push to surface (Earth is ~3rem = 48px, radius 24px) */
    /* Earth font-size is 3rem. 1rem ~ 16px. 3rem = 48px. Radius = 24px. */
    /* translate Y -24px puts it on top edge. */
}

.field-of-view {
    position: absolute;
    bottom: 24px;
    /* Start from center (radius) */
    left: -50px;
    /* Center horizontally */
    width: 100px;
    height: 150px;
    background: linear-gradient(to top, rgba(255, 0, 0, 0.3), transparent);
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
    transform-origin: bottom center;
    pointer-events: none;
    /* It points UP from the center. */
    /* Since observer is at -24px (Top), this cone should point UP from there? */
    /* Actually, let's make it start from the observer. */
    bottom: 25px;
    /* On surface */
}

/* Earth View */
.earth-view {
    height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.sky {
    width: 200px;
    height: 200px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.moon-phase {
    width: 150px;
    height: 150px;
    background: var(--moon-color);
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* We will use a clever CSS trick for phases or just SVG/Canvas. 
   Let's use the mask/shadow overlay method for simplicity and performance.
   Actually, a simple way is using a 'cover' div that moves.
   
   Better approach for smooth phases:
   Use a background color for the moon (lit) and an overlay for the shadow.
*/

.moon-disc {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    /* Lit color */
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
}

.moon-shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.85);
    mix-blend-mode: multiply;
    /* This will be manipulated by JS to create phases */
    opacity: 0;
    /* Hidden by default, we'll use a different technique in JS or here */
}

/* 
   Alternative Pure CSS Phase technique:
   We need two halves.
*/
.moon-phase {
    background-color: #333;
    /* Shadow color base */
}

.phase-name {
    margin-top: 20px;
    font-size: 1.5rem;
    color: var(--accent-color);
}

/* Controls */
.controls {
    background: var(--panel-bg);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(10px);
}

.slider-container {
    margin-bottom: 20px;
}

.slider-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--accent-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#resetBtn {
    font-size: 1rem;
    width: auto;
    padding: 0 15px;
    border-radius: 20px;
    background: rgba(255, 215, 0, 0.2);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

#resetBtn:hover {
    background: rgba(255, 215, 0, 0.4);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.nav-btn:active {
    transform: scale(0.9);
}

input[type=range] {
    width: 100%;
    max-width: 500px;
    height: 10px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.explanation-box {
    margin-top: 20px;
}

#explanationText {
    font-size: 1.2rem;
    margin-bottom: 20px;
    min-height: 3em;
}

.btn-primary {
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary:active {
    transform: scale(0.95);
}