:root {
    color-scheme: dark;
    --background: #020812;
    --panel: rgba(7, 22, 40, .83);
    --border: rgba(92, 179, 255, .22);
    --text: #eef7ff;
    --muted: #89a7bd;
    --accent: #59baff;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
}

canvas {
    position: fixed;
    inset: 0;
    display: block;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

header {
    position: fixed;
    top: 24px;
    left: 28px;
    right: 28px;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.eyebrow,
.panel-title {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .18em;
}

h1 {
    margin: 3px 0 0;
    font-size: clamp(28px, 4vw, 52px);
    letter-spacing: -.055em;
}

h1 span {
    color: var(--accent);
}

.clock {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#time {
    font-size: clamp(24px, 3vw, 38px);
    font-weight: 800;
}

.clock small {
    color: var(--muted);
}

.panel {
    position: fixed;
    z-index: 5;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    backdrop-filter: blur(15px);
}

#gpsPanel {
    left: 28px;
    bottom: 28px;
    width: 360px;
    padding: 17px;
}

.gps-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 13px 0;
}

#gpsDot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ff657c;
    box-shadow: 0 0 12px currentColor;
}

#gpsDot.online {
    background: #58e5a6;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.stats > div {
    padding: 10px;
    border-radius: 10px;
    background: rgba(255,255,255,.04);
}

.stats small {
    display: block;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: .1em;
}

.stats strong {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

#controls {
    right: 28px;
    bottom: 28px;
    display: flex;
    gap: 7px;
    padding: 9px;
}

button {
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 9px;
    padding: 9px 12px;
    color: var(--muted);
    background: rgba(255,255,255,.04);
    cursor: pointer;
}

button:hover,
button.active {
    color: white;
    border-color: var(--accent);
    background: rgba(89,186,255,.16);
}

#selected {
    top: 115px;
    right: 28px;
    width: 280px;
    padding: 18px;
}

#selected.hidden {
    display: none;
}

#selected h2 {
    margin: 10px 0;
}

#selectedDetails {
    color: var(--muted);
    line-height: 1.7;
}

#closeSelected {
    position: absolute;
    top: 7px;
    right: 7px;
    border: 0;
    font-size: 20px;
}

.instructions {
    position: fixed;
    left: 50%;
    bottom: 17px;
    z-index: 4;
    transform: translateX(-50%);
    color: rgba(190,215,235,.62);
    font-size: 12px;
    pointer-events: none;
}

body.night-vision {
    filter: sepia(1) saturate(8) hue-rotate(315deg);
}

@media (max-width: 720px) {
    #gpsPanel {
        left: 12px;
        bottom: 70px;
        width: calc(100% - 24px);
    }

    #controls {
        right: 12px;
        bottom: 12px;
        left: 12px;
        overflow-x: auto;
    }

    .instructions {
        display: none;
    }
}

h1 small {
    display: inline-block;
    margin-left: 9px;
    padding: 5px 8px;
    border: 1px solid rgba(89, 186, 255, .42);
    border-radius: 7px;
    color: #79caff;
    background: rgba(89, 186, 255, .10);
    font-size: 11px;
    letter-spacing: .15em;
    vertical-align: middle;
}


#timePanel {
    top: 125px;
    left: 28px;
    width: 350px;
    padding: 16px;
}

.time-field {
    display: block;
    margin-top: 13px;
}

.time-field > span {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
}

.time-field strong {
    color: var(--text);
}

#skyDateTime {
    width: 100%;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 9px;
    padding: 9px 10px;
    color: var(--text);
    background: rgba(255,255,255,.05);
    font: inherit;
    color-scheme: dark;
}

#timeSlider {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.time-actions {
    display: flex;
    gap: 7px;
    margin-top: 12px;
}

#simulatedTimeLabel {
    margin-top: 11px;
    color: #79caff;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
    #timePanel {
        top: 100px;
        left: 12px;
        width: calc(100% - 24px);
    }
}


#tonightPanel {
    top: 116px;
    right: 28px;
    width: 330px;
    padding: 17px;
}

.tonight-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}

#tonightWhen {
    margin-top: 4px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

#tonightLiveBadge {
    border: 1px solid rgba(88, 229, 166, .38);
    border-radius: 999px;
    padding: 5px 8px;
    color: #68e9ae;
    background: rgba(88, 229, 166, .10);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .13em;
}

#tonightLiveBadge.simulated {
    border-color: rgba(255, 199, 104, .42);
    color: #ffd080;
    background: rgba(255, 190, 88, .10);
}

.tonight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.tonight-card {
    min-width: 0;
    min-height: 84px;
    padding: 11px;
    border: 1px solid rgba(255,255,255,.055);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
}

.tonight-card.tonight-wide {
    grid-column: 1 / -1;
    min-height: 88px;
}

.tonight-card small {
    display: block;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .11em;
}

.tonight-card strong {
    display: block;
    overflow: hidden;
    margin-top: 7px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tonight-card span {
    display: block;
    overflow: hidden;
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.25;
    text-overflow: ellipsis;
}

#tonightStatus {
    color: #78caff;
    font-size: 19px;
}

#selected {
    top: 555px;
}

@media (max-height: 850px) and (min-width: 721px) {
    #tonightPanel {
        top: 105px;
        max-height: calc(100vh - 195px);
        overflow-y: auto;
    }

    .tonight-card {
        min-height: 72px;
    }
}

@media (max-width: 1050px) {
    #tonightPanel {
        right: 18px;
        width: 300px;
    }
}

@media (max-width: 720px) {
    #tonightPanel {
        top: auto;
        right: 12px;
        bottom: 72px;
        left: 12px;
        width: auto;
        max-height: 42vh;
        overflow-y: auto;
    }

    .tonight-grid {
        grid-template-columns: 1fr 1fr;
    }

    #selected {
        top: 90px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}


#mobilePanelButtons {
    display: none;
}

canvas {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (max-width: 720px) {
    html,
    body {
        width: 100%;
        height: 100%;
        min-height: 100dvh;
        overscroll-behavior: none;
    }

    header {
        top: max(10px, env(safe-area-inset-top));
        left: 12px;
        right: 12px;
        align-items: flex-start;
    }

    header .eyebrow {
        font-size: 8px;
    }

    header h1 {
        max-width: 58vw;
        margin-top: 3px;
        font-size: 25px;
        line-height: .95;
    }

    .clock {
        max-width: 38vw;
    }

    #time {
        font-size: 20px;
    }

    .clock small {
        display: block;
        margin-top: 3px;
        font-size: 9px;
    }

    #mobilePanelButtons {
        position: fixed;
        right: 8px;
        bottom: calc(66px + env(safe-area-inset-bottom));
        left: 8px;
        z-index: 20;
        display: flex;
        justify-content: center;
        gap: 7px;
        pointer-events: none;
    }

    #mobilePanelButtons button {
        min-height: 38px;
        padding: 8px 15px;
        border-color: rgba(89,186,255,.35);
        color: #b9ddf8;
        background: rgba(7,22,40,.91);
        box-shadow: 0 8px 25px rgba(0,0,0,.28);
        pointer-events: auto;
    }

    #mobilePanelButtons button.active {
        color: white;
        border-color: var(--accent);
        background: rgba(36,125,190,.88);
    }

    #gpsPanel,
    #timePanel,
    #tonightPanel {
        position: fixed;
        top: 82px;
        right: 10px;
        bottom: auto;
        left: 10px;
        z-index: 18;
        display: none;
        width: auto;
        max-height: calc(100dvh - 210px);
        overflow-y: auto;
        padding: 14px;
    }

    #gpsPanel.mobile-open,
    #timePanel.mobile-open,
    #tonightPanel.mobile-open {
        display: block;
    }

    #tonightPanel {
        max-height: calc(100dvh - 210px);
    }

    #controls {
        right: 7px;
        bottom: max(7px, env(safe-area-inset-bottom));
        left: 7px;
        z-index: 21;
        display: flex;
        gap: 5px;
        width: auto;
        padding: 6px;
        overflow-x: auto;
        border-radius: 13px;
        scrollbar-width: none;
        white-space: nowrap;
    }

    #controls::-webkit-scrollbar {
        display: none;
    }

    #controls button {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 8px 11px;
        font-size: 12px;
    }

    #selected {
        top: 82px;
        right: 10px;
        left: 10px;
        z-index: 25;
        width: auto;
        max-height: calc(100dvh - 170px);
        overflow-y: auto;
    }

    .instructions {
        top: auto;
        bottom: 117px;
        width: 100%;
        font-size: 10px;
        text-align: center;
    }

    .tonight-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tonight-card {
        min-height: 72px;
    }
}
