:root {
    color-scheme: light;
    font-family: system-ui, sans-serif;
    color: #1d3024;
    background: #090e0b;
    --accent: #346344;
}

*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; }

.layout {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    min-height: 100vh;
}

.intro {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(1.5rem, 2.5vw, 2.25rem);
    padding: clamp(1.25rem, 6.6vw, 6.5rem);
    padding-block-start: clamp(5rem, 30vh, 17.5rem);
    background: #e9ebe8;
    overflow-wrap: anywhere;
}

.intro h1 {
    margin: 0;
    font-size: clamp(3.75rem, 7vw, 6.75rem);
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
}

.text-baseline {
    display: inline-block;
    width: 0;
    height: 0;
}

.intro p {
    margin: 0;
    max-width: 29ch;
    line-height: 1.6;
    color: #455b4a;
}

.intro-links {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.25rem;
    row-gap: 0.375rem;
}

.intro-links a {
    color: inherit;
    padding-block: 0.375rem;
    text-decoration-color: var(--accent);
    text-underline-offset: 0.22em;
}

.intro-links a:hover { color: var(--accent); }

.experiment {
    position: relative;
    display: grid;
    align-content: center;
    overflow: clip;
    min-width: 0;
    padding: clamp(1.25rem, 4vw, 4rem);
    padding-block-end: 4.75rem;
    background: radial-gradient(ellipse at 50% 44%, #142725 0%, #0e1918 53%, #0b1412 100%);
    color-scheme: dark;
    color: #ecf5e9;
    --muted: #bed0bc;
    --line: #627d69;
    --accent: #a9d5ad;
}

button {
    min-width: 4.25rem;
    min-height: 2.25rem;
    padding: 0.25rem 0.625rem;
    border: 1px solid var(--line);
    border-radius: 2rem;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

button:hover:enabled { background: #2b4031; }
button:disabled { cursor: default; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.stage {
    position: relative;
    display: grid;
    place-items: center;
    pointer-events: none;
}

#halo {
    position: absolute;
    inset: 50% auto auto 50%;
    z-index: 0;
    height: 100%;
    width: auto;
    transform: translate(-50%, -50%) scale(1.46);
}

.starfield {
    position: absolute;
    inset: 0;
    overflow: clip;
    pointer-events: none;
}

.star-trail {
    position: absolute;
    height: 2px;
    border-radius: 1px;
    background: linear-gradient(90deg, transparent, #bce9db);
    transform-origin: left center;
    pointer-events: none;
}

.star-trail-front { z-index: 2; }
.star-trail[data-light-side] { background: linear-gradient(90deg, transparent, #222d27); }

.star {
    --star-ink: #def6eb;
    --star-glow: #b1e5d5;
    --star-spark: #dcf5e8;
    --star-spark-dim: #addbcf;
    --star-ring: #cbf6e9;
    position: absolute;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    transform: translate(-50%, -50%);
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
}

.star[data-light-side] {
    --star-ink: #131916;
    --star-glow: #1d2a2266;
    --star-spark: #26322c;
    --star-spark-dim: #4b5d52;
    --star-ring: #33463a;
}

.star[data-dragging] {
    z-index: 2;
    cursor: grabbing;
}

.star[data-launching] { pointer-events: none; }

.star:not([data-spent]) { animation: star-appear 650ms ease-out; }

.star:hover:enabled { background: transparent; }

.star::before, .star::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    width: var(--size, 2px);
    height: var(--size, 2px);
    border-radius: 50%;
    background: var(--star-ink);
    transform: translate(-50%, -50%);
}

.star::before {
    width: calc(var(--size, 2px) * var(--size-scale, 1));
    height: calc(var(--size, 2px) * var(--size-scale, 1));
    box-shadow: 0 0 6px var(--star-glow);
    animation: twinkle 4s var(--delay) ease-in-out infinite alternate;
}

.star:hover::before, .star:focus-visible::before,
.star[data-dragging]::before, .star[data-coasting]::before {
    animation: none;
    box-shadow: 0 0 9px 2px var(--star-glow);
}

.star::after { opacity: 0; }

.star[data-spent] { pointer-events: none; }
.star[data-spent]::before { visibility: hidden; }

.star[data-spent]::after {
    box-shadow: -5px -3px var(--star-spark), 5px -4px var(--star-spark-dim),
        4px 5px var(--star-spark), -4px 5px var(--star-spark-dim);
    animation: blink-out 240ms ease-out;
}

.star[data-spent="collision"] { z-index: 2; }

.star[data-spent="collision"]::before {
    width: 16px;
    height: 16px;
    visibility: visible;
    border: 1px solid var(--star-ring);
    background: transparent;
    box-shadow: none;
    animation: star-shock 420ms ease-out forwards;
}

.star[data-spent="collision"]::after {
    box-shadow: -9px -2px var(--star-spark), -6px -7px var(--star-spark-dim), 0 -10px var(--star-ink),
        7px -7px var(--star-spark), 10px 0 var(--star-ink), 6px 7px var(--star-spark-dim),
        0 10px var(--star-ink), -7px 7px var(--star-spark);
    animation: collision-burst 420ms ease-out;
}

@keyframes star-shock {
    from { opacity: 0.8; transform: translate(-50%, -50%) scale(0.4); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(2.6); }
}

@keyframes collision-burst {
    from { opacity: 1; transform: translate(-50%, -50%) scale(0.55); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(2.8); }
}

@keyframes star-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes twinkle {
    from { opacity: 0.28; transform: translate(-50%, -50%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
}

@keyframes blink-out {
    from { opacity: 1; transform: translate(-50%, -50%) scale(0.45); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

@media (prefers-reduced-motion: reduce) {
    .star:not([data-spent]) { animation: none; }
    .star::before { animation: none; opacity: 0.75; }
    .star[data-spent]::after { animation: none; }
}

#globe {
    position: relative;
    z-index: 1;
    display: block;
    width: min(100%, 38rem, max(17rem, 68vh));
    height: auto;
    aspect-ratio: 1;
    border-radius: 50%;
    filter: drop-shadow(0 18px 24px #0c1a12a8);
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
}

#globe[data-dragging] { cursor: grabbing; }

.controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    align-items: end;
    gap: clamp(0.625rem, 1.6vw, 1.5rem);
    min-width: 0;
    width: min(100%, 40rem);
    margin: clamp(3.25rem, 7.5vh, 4.75rem) auto 0;
    padding: 0;
    border: 0;
}

.setting { position: relative; }

.setting-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    column-gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
}

.value {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    font-weight: 400;
}

.setting input {
    appearance: none;
    display: block;
    width: 100%;
    height: 1.5rem;
    margin: 0.25rem 0 0;
    border-radius: 0.25rem;
    background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--line) var(--fill, 0%))
        center / 100% 0.25rem no-repeat;
    cursor: pointer;
}

.setting input::-webkit-slider-thumb {
    appearance: none;
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 50%;
    background: var(--accent);
}

.setting input::-moz-range-thumb {
    width: 0.875rem;
    height: 0.875rem;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
}

@media (forced-colors: active) {
    .setting input {
        appearance: auto;
        accent-color: auto;
    }

    .setting input::-webkit-slider-thumb { appearance: auto; }
}

.tooltip {
    position: absolute;
    inset-block-start: calc(100% + 0.375rem);
    inset-inline-start: 0;
    z-index: 1;
    width: max-content;
    max-width: 12rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #263f31;
    color: #ecf5e9;
    font-size: 0.75rem;
    line-height: 1.4;
    visibility: hidden;
}

.tooltip::before {
    content: "";
    position: absolute;
    inset: -0.4375rem 0 auto;
    height: 0.4375rem;
}

.setting:not([data-tip-dismissed]):is(:hover, :has(input:focus-visible)) .tooltip { visibility: visible; }
.controls:has(.setting:hover) .setting:not(:hover) .tooltip { visibility: hidden; }
#tick-length-tip { inset-inline: auto 0; }

@media (max-width: 47.5rem), (hover: none) and (pointer: coarse) and (max-height: 37.5rem) {
    .layout { display: block; }

    .intro {
        min-height: 100svh;
        justify-content: center;
        padding: clamp(1.5rem, 8vw, 4rem);
    }

    .intro h1 { font-size: clamp(3.75rem, 17vw, 6.75rem); }

    .experiment {
        min-height: 100svh;
        padding: 2.5rem clamp(1.25rem, 6vw, 3rem) 5rem;
    }

    #globe { touch-action: pan-y; }

    .controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: min(100%, 28rem);
        gap: 1.25rem 1rem;
        margin-top: 2.75rem;
    }

    #motion { justify-self: start; }
    .setting:nth-child(even) .tooltip { inset-inline: auto 0; }
}
