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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #030305;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: #e0e0e5;
}

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

canvas:active {
    cursor: grabbing;
}

#ui-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 340px;
    padding: 20px;
    z-index: 10;
    pointer-events: auto;
    background: rgba(10, 10, 15, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.language-switch {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
}

.language-switch button {
    width: auto;
    min-width: 34px;
    margin-bottom: 0;
    padding: 5px 7px;
    color: #9fb4c0;
    background: #263238;
    font-size: 10px;
}

.language-switch button.active {
    color: #030305;
    background: #4fc3f7;
}

#inspector-panel {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 300px;
    padding: 20px;
    z-index: 10;
    display: none;
    pointer-events: auto;
    background: rgba(15, 20, 30, 0.9);
    border: 1px solid rgba(79, 195, 247, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    transition: opacity 0.2s;
}

.floating-panel {
    position: absolute;
    left: 20px;
    bottom: 20px;
    z-index: 10;
    pointer-events: auto;
    background: rgba(15, 20, 30, 0.9);
    border: 1px solid rgba(79, 195, 247, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.floating-panel.collapsed {
    display: none;
}

#travel-chart-panel {
    width: 492px;
    padding: 14px 16px 16px;
}

#travel-chart-panel h2 {
    margin-bottom: 8px;
    color: #fff;
    font-size: 14px;
}

#travel-chart-canvas {
    width: 460px;
    height: 220px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    cursor: default;
}

#travel-chart-stats {
    margin-top: 6px;
    font-size: 11px;
    color: #9fb4c0;
}

#settings-panel {
    top: 20px;
    right: 20px;
    bottom: auto;
    left: auto;
    width: 320px;
    max-height: calc(100vh - 40px);
    padding: 14px 16px 16px;
    overflow-y: auto;
}

#settings-title {
    margin-bottom: 10px;
    color: #fff;
    font-size: 14px;
}

.setting-row {
    margin-bottom: 12px;
}

.setting-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.setting-label {
    color: #8fa7b3;
    font-size: 11px;
}

.setting-value {
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.setting-row input[type="range"] {
    margin-bottom: 0;
}

.setting-derived {
    margin-top: 3px;
    color: #9ad7f5;
    font-size: 10px;
    font-style: italic;
}

.settings-hint {
    margin: 6px 0 10px;
    color: #9fb4c0;
    font-size: 10px;
    font-style: italic;
}

#inspector-panel h2 {
    margin-bottom: 5px;
    color: #fff;
    font-size: 18px;
}

.inspector-row,
.inspector-flavor {
    margin-bottom: 8px;
    color: #ccc;
    font-size: 13px;
}

.inspector-label {
    color: #8fa7b3;
}

.inspector-flavor {
    margin-top: 10px;
    color: #9ad7f5;
    font-style: italic;
}

.badge {
    display: inline-block;
    margin-right: 5px;
    margin-bottom: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

#wiki-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    color: #000;
    background: #fff;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    transition: background 0.2s;
}

#wiki-btn:hover {
    background: #ccc;
}

h1 {
    margin-bottom: 0;
    padding-bottom: 0;
    color: #4fc3f7;
    font-size: 16px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.stat-value {
    color: #fff;
    font-weight: bold;
}

.stat-value.year {
    color: #ffb74d;
    font-size: 16px;
}

.stat-habitable {
    color: #66bb6a;
}

.stat-technical {
    color: #9e9e9e;
}

.stat-lost {
    color: #ef5350;
}

.stat-launched {
    color: #4fc3f7;
}

.control-group {
    margin-top: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
    font-size: 12px;
    text-transform: uppercase;
}

input[type="range"] {
    width: 100%;
    margin-bottom: 15px;
    accent-color: #4fc3f7;
    background: #222;
}

button {
    width: 100%;
    margin-bottom: 8px;
    padding: 10px;
    color: white;
    background: #1565c0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: background 0.2s;
}

button:hover {
    background: #1e88e5;
}

button.secondary {
    background: #37474f;
}

button.secondary:hover {
    background: #455a64;
}

#legend {
    margin-top: 15px;
    padding-top: 10px;
    color: #888;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.legend-color {
    width: 10px;
    height: 10px;
    margin-right: 8px;
    border-radius: 50%;
}

.legend-line {
    width: 18px;
    height: 3px;
    margin-right: 8px;
    border-radius: 2px;
}

.class-m {
    background: #ff5252;
}

.class-k {
    background: #ffcc80;
}

.class-g {
    background: #fff59d;
}

.class-af {
    background: #81d4fa;
}

.legend-habitable {
    border: 1.5px solid #66bb6a;
}

.legend-technical {
    border: 1.5px solid #9e9e9e;
}

.legend-wreck {
    position: relative;
    background: transparent;
}

.legend-wreck::before,
.legend-wreck::after {
    position: absolute;
    top: 4px;
    left: -1px;
    width: 12px;
    height: 2px;
    background: #9e9e9e;
    content: "";
}

.legend-wreck::before {
    transform: rotate(45deg);
}

.legend-wreck::after {
    transform: rotate(-45deg);
}

.legend-trade-ship {
    background: #ffd54f;
}

.legend-partial-link {
    background: rgba(255, 213, 79, 0.35);
}

.legend-trade-route {
    background: rgba(255, 213, 79, 0.75);
}

.legend-binary {
    border: 1.5px solid #81d4fa;
    background: radial-gradient(circle at 72% 30%, #81d4fa 0 2px, transparent 2.5px);
}

.controls-hint {
    margin-top: 10px;
    color: #4fc3f7;
    font-size: 11px;
    font-style: italic;
    text-align: center;
}

@media (max-width: 720px) {
    #ui-panel {
        top: 10px;
        left: 10px;
        width: min(340px, calc(100vw - 20px));
        padding: 14px;
    }

    #inspector-panel {
        right: 10px;
        bottom: 10px;
        width: min(300px, calc(100vw - 20px));
        padding: 14px;
    }

    .floating-panel {
        left: 10px;
        bottom: 10px;
    }

    #travel-chart-panel {
        width: min(492px, calc(100vw - 20px));
    }

    #settings-panel {
        top: 10px;
        right: 10px;
        width: min(320px, calc(100vw - 20px));
    }

    #travel-chart-canvas {
        width: 100%;
        height: auto;
    }
}
