:root {
    --bg-color: #050510;
    --text-color: #e0e0ff;
    --accent-color: #4a90e2;
    --panel-bg: rgba(10, 15, 30, 0.7);
    --panel-border: rgba(100, 150, 255, 0.2);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden; /* Prevent scrolling */
    width: 100vw;
    height: 100vh;
}

.hidden {
    display: none !important;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Clicks go through */
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn.hidden {
    display: none !important;
}

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

h1 {
    font-size: 1.5rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    margin: 0;
    font-weight: 600;
    pointer-events: auto;
}

.toggle-container {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    padding: 5px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
}

/* Level Dropdown */
.level-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    padding: 5px 15px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    pointer-events: auto;
}

.level-container label {
    font-size: 0.9rem;
    color: #ccc;
}

#level-select {
    background: transparent;
    color: white;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    font-weight: bold;
}

#level-select option {
    background: #111;
    color: white;
}

.toggle-container button {
    background: transparent;
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.toggle-container button.active {
    background: var(--accent-color);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5);
}

#info-panel {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 350px;
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 25px;
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#info-panel.hidden {
    transform: translateY(150%);
    opacity: 0;
    pointer-events: none;
}

#info-title {
    margin-top: 0;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-weight: 600;
}

.info-content p {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 0.95rem;
}

#btn-close-info {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

#btn-close-info:hover {
    background: rgba(255, 255, 255, 0.2);
}

#moon-legend {
    position: absolute;
    bottom: 40px;
    right: 40px;
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    pointer-events: auto;
    transition: opacity 0.3s;
}

#moon-legend.hidden {
    opacity: 0;
    pointer-events: none;
}

#moon-legend h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

#moon-legend p {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 15px;
}

#phase-list {
    list-style: none;
}

#phase-list li {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    border: 1px solid #fff;
    flex-shrink: 0;
}

.dot.newmoon { background: transparent; }
.dot.waxing { background: linear-gradient(90deg, transparent 50%, #fff 50%); }
.dot.fullmoon { background: #fff; }
.dot.waning { background: linear-gradient(90deg, #fff 50%, transparent 50%); }

#size-comparison-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    z-index: 10;
}

#size-comparison-overlay.hidden {
    display: none;
}

.nav-btn {
    font-size: 3.5rem;
    color: white;
    cursor: pointer;
    pointer-events: auto;
    padding: 20px 40px;
    margin: 0 50px;
    transition: transform 0.2s, color 0.2s;
    user-select: none;
}

.nav-btn:hover {
    color: var(--accent-color);
    transform: scale(1.2);
}

.size-info {
    text-align: center;
    pointer-events: auto;
}

.size-info h2 {
    font-size: clamp(1.5rem, 5vw, 3rem);
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(0,0,0,0.8);
    font-weight: 700;
}

.size-info p {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    color: #ddd;
    margin: 5px 0;
}

.size-desc-text {
    font-size: clamp(0.8rem, 2.5vw, 1rem) !important;
    color: #bbb !important;
    margin-top: 10px !important;
    line-height: 1.4;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.planet-label {
    color: #ffffff;
    font-family: 'Inter', 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 500;
    padding: 6px 12px;
    background: rgba(10, 15, 30, 0.75);
    border: 1px solid rgba(100, 150, 255, 0.3);
    border-radius: 6px;
    pointer-events: none;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 1.5s ease-in; /* Removed transform transition to fix stacking issue */
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    margin-top: -30px; 
}
.planet-label.visible {
    opacity: 1;
}
.planet-label::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, rgba(100, 150, 255, 0.8), transparent);
    transform: translateX(-50%);
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
        gap: 15px;
    }
    
    .header-right {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .toggle-container, .level-container {
        width: 100%;
        justify-content: space-between;
    }

    #size-comparison-overlay {
        padding-bottom: 70px;
    }

    .size-info {
        padding-bottom: 70px;
    }

    #btn-jump-universe {
        top: 70px;
        left: 20px;
        padding: 5px 12px;
        font-size: 13px;
    }
    
    #btn-sidebar-toggle {
        top: 70px;
        left: 20px;
    }
    
    .sidebar-panel {
        top: 60px;
        left: 10px;
        width: 220px;
        padding-top: 55px; /* keep button inside */
    }

    #planet-list li, #finale-list li {
        font-size: clamp(12px, 3.5vw, 14px);
        padding: 8px 10px;
    }
    #info-panel {
        left: 20px;
        right: 20px;
        bottom: 20px;
        width: calc(100% - 40px);
    }
    #moon-legend {
        left: 20px;
        right: 20px;
        bottom: 20px;
        width: calc(100% - 40px);
    }
}

/* Shared Sidebar Styles */
.sidebar-panel {
    position: absolute;
    left: 40px;
    top: 70px;
    width: 250px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 15px;
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 50;
}

.sidebar-panel.hidden {
    opacity: 0;
    transform: translateX(-150px);
    pointer-events: none;
}

.sidebar-panel.collapsed {
    overflow-y: hidden;
}

.sidebar-panel h3 {
    margin: 0;
    margin-left: 10px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 10px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.sidebar-header:hover {
    opacity: 0.8;
}

#planet-list {
    transition: max-height 0.3s ease-out, opacity 0.3s, margin 0.3s;
    max-height: 1500px;
    overflow: hidden;
    opacity: 1;
}

#planet-list.collapsed, #finale-list.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

#planet-list, #finale-list {
    list-style: none;
}

#planet-list li, #finale-list li {
    padding: 10px 15px;
    margin-bottom: 5px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#planet-list li:hover, #finale-list li:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.02);
}

/* Absolute Positioning for Toggles */
#btn-jump-universe {
    position: absolute;
    top: 80px;  /* 70px parent + 10px inside padding basically aligns it */
    left: 50px;
    z-index: 101;
}


/* Time Controls */
#time-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--panel-border);
    border-radius: 30px;
    padding: 10px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s, transform 0.3s;
}

#time-controls.hidden {
    opacity: 0;
    transform: translate(-50%, 50px);
    pointer-events: none;
}

.time-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    transition: color 0.2s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
}

.time-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--accent-color);
    transform: scale(1.1);
}

.time-btn svg {
    transition: fill 0.2s;
}

#time-scale-display {
    font-family: monospace;
    font-size: 1.1rem;
    width: 60px;
    text-align: center;
    font-weight: bold;
}

/* Jump Universe Button specific styling (shared absolute position handled above) */
#btn-jump-universe {
    padding: 8px 16px;
    background: rgba(74, 144, 226, 0.2);
    border: 1px solid var(--accent-color);
    color: white;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    pointer-events: auto;
    font-weight: 500;
}

#btn-jump-universe:hover {
    background: var(--accent-color);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5);
    transform: scale(1.05);
}

.clickable-planet {
    cursor: pointer;
}
