/* ===================================================================
   Three-Body Problem Simulator — Stylesheet
   Premium dark space theme with glassmorphism controls
   =================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #06060f;
    --bg-panel: rgba(12, 12, 30, 0.85);
    --bg-panel-hover: rgba(20, 20, 50, 0.9);
    --bg-input: rgba(20, 22, 45, 0.8);
    --border-subtle: rgba(80, 90, 160, 0.25);
    --border-focus: rgba(120, 140, 255, 0.5);
    --text-primary: #e0e4f0;
    --text-secondary: rgba(180, 190, 220, 0.7);
    --text-muted: rgba(140, 150, 200, 0.5);
    --accent-blue: #5b7bff;
    --accent-cyan: #4ecdc4;
    --accent-red: #ff6b6b;
    --accent-yellow: #ffe66d;
    --accent-gold: #f9d423;
    --glow-blue: rgba(91, 123, 255, 0.3);
    --glow-gold: rgba(249, 212, 35, 0.4);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* --- Config Panel (Sidebar) --- */
.config-panel {
    width: 340px;
    height: 100%;
    background: var(--bg-panel);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition:
        width var(--transition),
        min-width var(--transition),
        opacity var(--transition);
    position: relative;
    z-index: 10;
}

.config-panel.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    border-left: none;
}

/* --- Panel close button --- */
.panel-header {
    position: relative;
}
.panel-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    opacity: 0.6;
    z-index: 5;
}
.panel-close-btn:hover {
    opacity: 1;
}

.panel-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.panel-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #8b9cf7, #5b7bff, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.panel-header .subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.panel-scroll select,
.panel-scroll button,
.panel-scroll .toggle-switch,
.panel-scroll .object-row,
.panel-scroll .object-group-header {
    touch-action: manipulation;
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 20px;
    touch-action: manipulation;
    scrollbar-width: thin;
    scrollbar-color: rgba(80, 90, 160, 0.3) transparent;
}

.panel-scroll::-webkit-scrollbar {
    width: 5px;
}

.panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.panel-scroll::-webkit-scrollbar-thumb {
    background: rgba(80, 90, 160, 0.3);
    border-radius: 10px;
}

/* --- Sections --- */
.section {
    margin-bottom: 16px;
}

.section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* --- Preset Selector --- */
.preset-select-wrapper {
    position: relative;
}

#preset-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    transition: border-color var(--transition);
}

#preset-select:hover {
    border-color: var(--border-focus);
}

#preset-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--glow-blue);
}

#preset-select option {
    background: #14142e;
    color: var(--text-primary);
}

#preset-description {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.4;
    font-style: italic;
}

/* --- Body Config --- */
.body-config {
    background: rgba(15, 15, 40, 0.5);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: border-color var(--transition);
}

.body-config:hover {
    border-color: var(--border-focus);
}

.body-config-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.body-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.body-name-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    outline: none;
    width: 100%;
    padding: 2px 0;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition);
}

.body-name-input:focus {
    border-bottom-color: var(--accent-blue);
}

.config-grid {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 4px 8px;
    align-items: center;
}

.config-grid label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
    font-weight: 500;
    text-align: right;
}

.precision-input {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.precision-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--glow-blue);
}

/* --- DT input --- */
.dt-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dt-row label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
    font-weight: 500;
    white-space: nowrap;
}

#dt-input {
    flex: 1;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

#dt-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--glow-blue);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    white-space: nowrap;
    touch-action: manipulation;
}

.btn:hover {
    background: var(--bg-panel-hover);
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: linear-gradient(135deg, #4a5eff, #5b7bff);
    border-color: rgba(91, 123, 255, 0.5);
    color: #fff;
    font-weight: 600;
}

.btn.primary:hover {
    background: linear-gradient(135deg, #5b6bff, #6b8bff);
    box-shadow: 0 4px 16px var(--glow-blue);
}

.btn.playing {
    background: linear-gradient(135deg, #ff4757, #ff6b6b);
    border-color: rgba(255, 71, 87, 0.5);
}

.btn.active {
    background: rgba(91, 123, 255, 0.2);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.btn-apply-wrapper {
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

/* --- Sliders --- */
.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.slider-row label {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 72px;
    white-space: nowrap;
}

.slider-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(60, 70, 130, 0.4);
    border-radius: 2px;
    outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 0 8px var(--glow-blue);
    transition: transform 0.15s ease;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--accent-cyan);
    min-width: 48px;
    text-align: right;
}

/* --- Controls Bar (overlay on canvas) --- */
.controls-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    width: max-content;
    max-width: 95%;
    background: var(--bg-panel);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    z-index: 20;
    touch-action: manipulation;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.controls-bar .divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
}

/* --- Toggle panel button --- */
.btn-toggle-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 30;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 18px;
    border-radius: var(--radius-sm);
}

/* --- Precision Modal --- */
.precision-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.precision-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #8b9cf7, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
    margin-bottom: 16px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.precision-body {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(10, 10, 25, 0.5);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.precision-body h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.precision-row {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
    align-items: baseline;
}

.precision-label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
    min-width: 32px;
    font-weight: 500;
}

.precision-value {
    font-size: 10px;
    color: var(--accent-cyan);
    font-family: "JetBrains Mono", monospace;
    word-break: break-all;
    line-height: 1.4;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--accent-cyan);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    color: var(--accent-red);
    border-color: rgba(255, 107, 107, 0.3);
}

/* --- Tab Bar --- */
.tab-bar {
    display: flex;
    align-items: center;
    background: rgba(8, 8, 20, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 12px;
    height: 44px;
    z-index: 100;
    flex-shrink: 0;
    gap: 4px;
    backdrop-filter: blur(20px);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border-radius: 6px 6px 0 0;
    touch-action: manipulation;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(91, 123, 255, 0.05);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-blue);
    background: rgba(91, 123, 255, 0.1);
}

.tab-icon {
    font-size: 15px;
}

/* --- Tab Content --- */
.tab-content {
    display: none;
    width: 100%;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* Full height for tab containers */
html, body {
    display: flex;
    flex-direction: column;
}

#solar-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* --- Solar System Specific Styles --- */
.date-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.date-controls input[type="date"],
.date-controls input[type="time"] {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition);
    color-scheme: dark;
}

.date-controls input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--glow-blue);
}

/* Planet Info Panel */
.planet-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.planet-info-header .body-dot {
    width: 14px;
    height: 14px;
}

.planet-info-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.btn-track-inline {
    background: rgba(100, 200, 255, 0.1);
    border: 1px solid rgba(100, 200, 255, 0.3);
    color: rgba(100, 200, 255, 0.9);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-track-inline:hover {
    background: rgba(100, 200, 255, 0.25);
    border-color: rgba(100, 200, 255, 0.6);
}

.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    align-items: baseline;
}

.info-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.info-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: var(--accent-cyan);
}

.info-placeholder {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    padding: 12px 0;
}

.info-moons-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 12px;
    margin-bottom: 6px;
}

.info-moons-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.moon-chip {
    font-size: 10px;
    padding: 3px 8px;
    border: 1px solid rgba(150, 160, 200, 0.3);
    border-radius: 20px;
    color: var(--text-secondary);
    background: rgba(15, 15, 40, 0.5);
}

/* Object List with toggles */
.object-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.object-group {
    margin-bottom: 4px;
}

.object-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    transition: background 0.15s;
}

.object-group-header:hover {
    background: rgba(100, 120, 200, 0.1);
}

.object-group-header .group-chevron {
    font-size: 8px;
    transition: transform 0.2s;
    color: var(--text-secondary);
    opacity: 0.6;
}

.object-group.collapsed .group-chevron {
    transform: rotate(-90deg);
}

.object-group.collapsed .object-group-items {
    display: none;
}

.object-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.object-row:hover {
    background: rgba(100, 120, 200, 0.1);
}

.object-row.moon-row {
    padding-left: 22px;
    font-size: 10px;
    color: var(--text-secondary);
}

.object-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.object-row .object-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* iOS-style toggle switch */
.toggle-switch {
    position: relative;
    width: 28px;
    height: 16px;
    flex-shrink: 0;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(80, 90, 120, 0.4);
    border-radius: 16px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background: rgba(200, 210, 230, 0.8);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(100, 140, 255, 0.6);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(12px);
    background: #fff;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .config-panel {
        position: absolute;
        right: 0;
        top: 0;
        width: 300px;
        height: 100%;
        z-index: 50;
    }

    .controls-bar {
        bottom: 12px;
        padding: 6px 12px;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .tab-bar {
        height: 40px;
        padding: 0 8px;
    }

    .tab-btn {
        padding: 6px 14px;
        font-size: 12px;
    }
}

/* --- Scrollbar for modal --- */
.modal-content::-webkit-scrollbar {
    width: 5px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(80, 90, 160, 0.3);
    border-radius: 10px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.body-config {
    animation: fadeIn 0.3s ease forwards;
}

.body-config:nth-child(2) {
    animation-delay: 0.05s;
}
.body-config:nth-child(3) {
    animation-delay: 0.1s;
}

/* Eclipse Finder */
.eclipse-controls {
    margin-bottom: 8px;
}

.eclipse-range-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.eclipse-range-row label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.eclipse-range-row select {
    flex: 1;
    background: rgba(100, 120, 200, 0.1);
    border: 1px solid rgba(100, 120, 200, 0.2);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.eclipse-results {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.eclipse-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: rgba(100, 120, 200, 0.06);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border: 1px solid transparent;
}

.eclipse-item:hover {
    background: rgba(100, 120, 200, 0.15);
    border-color: rgba(100, 120, 200, 0.25);
    transform: translateX(2px);
}

.eclipse-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    min-width: 52px;
    text-align: center;
}

.eclipse-badge.total {
    background: rgba(255, 80, 80, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 80, 80, 0.3);
}

.eclipse-badge.annular {
    background: rgba(255, 170, 50, 0.2);
    color: #ffaa33;
    border: 1px solid rgba(255, 170, 50, 0.3);
}

.eclipse-badge.partial {
    background: rgba(100, 160, 255, 0.2);
    color: #6baaff;
    border: 1px solid rgba(100, 160, 255, 0.3);
}

.eclipse-date {
    font-size: 12px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.eclipse-time {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: auto;
}

.eclipse-searching {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 11px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

/* ─── Cockpit Simulation ─── */

.drive-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drive-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(100, 120, 200, 0.06);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.drive-item:hover {
    background: rgba(100, 120, 200, 0.12);
    border-color: rgba(100, 120, 200, 0.2);
}

.drive-item.active {
    background: rgba(60, 120, 255, 0.15);
    border-color: rgba(60, 120, 255, 0.4);
    box-shadow: 0 0 8px rgba(60, 120, 255, 0.15);
}

.drive-icon {
    font-size: 18px;
    width: 26px;
    text-align: center;
}

.drive-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.drive-subtitle {
    font-size: 9px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.drive-max {
    font-size: 9px;
    color: var(--accent);
    margin-left: auto;
    font-family: "Courier New", monospace;
    opacity: 0.7;
}

.cockpit-speed-info {
    margin-top: 8px;
    padding: 8px;
    background: rgba(100, 120, 200, 0.06);
    border-radius: 6px;
    font-family: "Courier New", monospace;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.cockpit-physics-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.physics-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    background: rgba(100, 120, 200, 0.06);
    border-radius: 4px;
    font-size: 11px;
}

.physics-label {
    color: var(--text-secondary);
}

.physics-value {
    font-family: "Courier New", monospace;
    color: var(--accent);
    font-weight: 600;
}

.cockpit-drive-info {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.cockpit-drive-info .drive-desc-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

/* ===================================================================
   Video Game Intro & Main Menu Overlays
   =================================================================== */

.fs-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
    overflow: hidden;
}

.fs-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* --- Typography for Game Logo --- */
.game-logo {
    font-family: 'Inter', sans-serif;
    font-size: 8vw;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    margin: 0;
    line-height: 1;
    display: flex;
    gap: 0.2em;
    animation: text-pulse 3s infinite alternate;
}

.game-logo.small {
    font-size: 4vw;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.logo-accent {
    color: var(--accent-gold);
    text-shadow: 0 0 30px var(--glow-gold);
}

@keyframes text-pulse {
    0% { transform: scale(1); text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
    100% { transform: scale(1.02); text-shadow: 0 0 40px rgba(255, 255, 255, 0.8); }
}

/* --- Loading Screen Specifics --- */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.loading-bar-container {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.loading-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    box-shadow: 0 0 20px var(--accent-cyan);
    animation: loading 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.loading-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-cyan);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    animation: blink 1s infinite step-end;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* --- Main Menu Specifics --- */
#main-menu {
    background: var(--bg-primary);
    background-image: radial-gradient(circle at 50% 10%, rgba(91, 123, 255, 0.08) 0%, transparent 50%);
    z-index: 9998; /* Below loading screen */
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 2rem;
}

.menu-version {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.1em;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    margin-top: 2rem;
}

.menu-btn {
    background: rgba(20, 22, 45, 0.6);
    border: 1px solid rgba(91, 123, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    text-align: left;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: skewX(-20deg);
    transition: all 0.5s ease;
}

.menu-btn:hover {
    background: rgba(91, 123, 255, 0.15);
    border-color: var(--accent-blue);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 20px var(--glow-blue);
}

.menu-btn:hover::before {
    left: 200%;
}

.menu-btn:active {
    transform: translateY(1px) scale(0.98);
}

.btn-icon {
    font-size: 2.5rem;
    color: var(--accent-cyan);
    text-shadow: 0 0 15px rgba(78, 205, 196, 0.5);
    transition: transform 0.3s ease;
}

.menu-btn:hover .btn-icon {
    transform: scale(1.1) rotate(5deg);
    color: #fff;
}

.btn-text {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.btn-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.1em;
}

.btn-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.menu-btn:hover .btn-sub {
    color: var(--text-secondary);
}

/* --- Quality Tier Toggle (Phase 6) --- */

.quality-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border, rgba(100, 120, 180, 0.3));
    border-radius: 6px;
    overflow: hidden;
}

.quality-btn {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border, rgba(100, 120, 180, 0.3));
    color: var(--text-dim, rgba(170, 185, 210, 0.65));
    font-size: 0.75em;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.quality-btn:last-child { border-right: none; }
.quality-btn:hover { background: rgba(100, 120, 180, 0.15); }

.quality-btn.active {
    background: rgba(100, 140, 255, 0.2);
    color: var(--text, rgba(220, 230, 255, 0.9));
    font-weight: bold;
}

.detected-tier-label {
    margin-top: 6px;
    font-size: 0.75em;
    color: var(--text-dim, rgba(170, 185, 210, 0.45));
    text-align: center;
}

/* --- Calibration Splash (Phase 6) --- */

.calibration-content {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
}

.calibration-title {
    font-size: 1.2em;
    letter-spacing: 2px;
    color: #88aaff;
    font-family: 'JetBrains Mono', monospace;
}

.calibration-sub {
    margin-top: 8px;
    font-size: 0.8em;
    color: rgba(100, 110, 140, 0.8);
}

.calibration-warning {
    margin-top: 12px;
    font-size: 0.75em;
    color: rgba(255, 180, 80, 0.9);
}

/* --- Prevent browser default touch gestures on canvases --- */
#canvas, #solar-canvas, #stellar-canvas, #stellar-overlay, #cockpit-canvas {
    touch-action: none;
}

/* --- Phone breakpoint --- */
@media (max-width: 480px) {
    /* Disable text selection on mobile */
    * {
        -webkit-user-select: none;
        user-select: none;
    }
    input, textarea {
        -webkit-user-select: text;
        user-select: text;
    }

    /* Config panel: full-width drawer, collapsed by default on mobile */
    .config-panel {
        position: absolute;
        right: 0;
        top: 0;
        width: 100% !important;
        max-width: 100vw;
        height: 100%;
        z-index: 50;
    }

    .config-panel:not(.collapsed) {
        width: 0 !important;
        min-width: 0;
        opacity: 0;
        pointer-events: none;
        border-left: none;
    }

    .config-panel.mobile-open {
        width: 100% !important;
        min-width: unset;
        opacity: 1;
        pointer-events: auto;
        border-left: 1px solid var(--border-subtle);
    }

    .panel-header {
        padding: 12px 16px 10px;
    }

    .panel-close-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        opacity: 0.8;
        touch-action: manipulation;
    }

    /* Tab bar: icon-only */
    .tab-bar {
        height: 36px;
        padding: 0 4px;
        gap: 2px;
    }

    .tab-btn {
        padding: 6px 10px;
        font-size: 0;
        gap: 0;
    }

    .tab-icon {
        font-size: 18px;
    }

    /* Controls bar: compact, always visible */
    .controls-bar {
        bottom: 8px;
        padding: 5px 8px;
        gap: 4px;
        max-width: 98%;
        transform: translateX(-50%);
        opacity: 1;
        pointer-events: auto;
    }

    .controls-bar .btn {
        padding: 5px 7px;
        font-size: 10px;
    }

    .controls-bar .divider {
        height: 18px;
    }

    /* Solar controls: horizontal scroll */
    #tab-solar .controls-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        max-width: 96%;
        scrollbar-width: none;
    }

    #tab-solar .controls-bar::-webkit-scrollbar {
        display: none;
    }

    /* Toast: above controls bar */
    .toast {
        bottom: 60px;
        font-size: 12px;
        padding: 8px 16px;
    }

    /* Main menu: compact */
    .menu-content {
        padding: 1rem;
    }

    .game-logo.small {
        font-size: 6vw;
        margin-bottom: 1rem;
    }

    .menu-buttons {
        gap: 1rem;
        margin-top: 1rem;
    }

    .menu-btn {
        padding: 0.8rem 1rem;
        gap: 1rem;
    }

    .btn-icon {
        font-size: 1.8rem;
    }

    .btn-title {
        font-size: 1.1rem;
    }

    .btn-sub {
        font-size: 0.7rem;
    }

    /* Larger tap target for panel toggle */
    .btn-toggle-panel {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    /* Modal: full-width */
    .modal-content {
        width: 96%;
        max-width: 96vw;
        padding: 16px;
    }

    /* Sliders: tighter */
    .slider-row label {
        min-width: 56px;
        font-size: 10px;
    }

    .slider-value {
        min-width: 40px;
        font-size: 10px;
    }
}

/* ===================================================================
   Earth Globe — Layer panel & Cesium overrides
   =================================================================== */

/* Hide Cesium's default UI chrome */
#earth-globe-container .cesium-viewer-bottom,
#earth-globe-container .cesium-viewer-toolbar,
#earth-globe-container .cesium-viewer-animationContainer,
#earth-globe-container .cesium-viewer-timelineContainer,
#earth-globe-container .cesium-viewer-fullscreenContainer {
    display: none !important;
}

#earth-globe-container .cesium-widget canvas {
    border-radius: 0;
}

#earth-globe-container {
    background: var(--bg-primary);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#earth-globe-container .cesium-viewer,
#earth-globe-container .cesium-viewer-cesiumWidgetContainer,
#earth-globe-container .cesium-widget,
#earth-globe-container .cesium-widget canvas {
    width: 100% !important;
    height: 100% !important;
}

#tab-earth .canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1;
}

/* Layer toggle rows */
.earth-layer-toggles {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.earth-layer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.earth-layer-row:hover {
    background: rgba(91, 123, 255, 0.06);
}

.earth-layer-icon {
    font-size: 14px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.earth-layer-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
}

.earth-layer-row .toggle-switch {
    margin-left: auto;
}

/* Earth controls bar date/time */
.earth-bar-datetime {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent-cyan);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Earthquake legend */
.earth-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Satellite orbit mode buttons */
.sat-orbit-modes {
    display: flex;
    gap: 4px;
}
.sat-orbit-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid rgba(91, 123, 255, 0.2);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.sat-orbit-btn:hover {
    background: rgba(91, 123, 255, 0.1);
    color: var(--text-primary);
}
.sat-orbit-btn.active {
    background: rgba(91, 123, 255, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

/* Satellite group sections */
.sat-loading {
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px 0;
}
.sat-group {
    margin-bottom: 4px;
}
.sat-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}
.sat-group-header:hover {
    background: rgba(91, 123, 255, 0.06);
}
.sat-group-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sat-group-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
}
.sat-group-count {
    font-size: 10px;
    color: var(--text-muted);
    margin-right: 4px;
}
.sat-group-expand {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.sat-group.open .sat-group-expand {
    transform: rotate(90deg);
}
.sat-group-toggle {
    margin-left: auto;
}
.sat-group-list {
    display: none;
    max-height: 200px;
    overflow-y: auto;
    padding: 2px 0 2px 14px;
}
.sat-group.open .sat-group-list {
    display: block;
}
.sat-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.sat-item:hover {
    background: rgba(91, 123, 255, 0.08);
}
.sat-item-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.sat-item-info {
    flex: 1;
    min-width: 0;
}
.sat-item-name {
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sat-item-desc {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sat-group-list::-webkit-scrollbar {
    width: 4px;
}
.sat-group-list::-webkit-scrollbar-thumb {
    background: rgba(91, 123, 255, 0.2);
    border-radius: 2px;
}
