:root {
    --bg: #0f0c09;
    --panel: #1a1510;
    --panel-2: #221b14;
    --line: #3b3024;
    --line-soft: #2a2219;
    --text: #e9dcc3;
    --muted: #a3917a;
    --gold: #d6a647;
    --gold-bright: #f2d17f;
    --ember: #e0762c;
    --night: #26324f;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    background:
        radial-gradient(ellipse 80% 45% at 50% -10%, rgba(224, 118, 44, 0.16), transparent 70%),
        radial-gradient(ellipse 60% 40% at 50% 110%, rgba(38, 50, 79, 0.35), transparent 70%),
        linear-gradient(180deg, #15110c 0%, var(--bg) 60%);
    background-attachment: fixed;
    color: var(--text);
    font: 14px/1.35 "Averia Serif Libre", Georgia, "Times New Roman", serif;
}

a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: #fff1c9; text-decoration: underline; }

.page {
    max-width: 1560px;
    margin: 0 auto;
    padding: 14px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100vh;
}

/* ---------- Header ---------- */

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 28px;
    padding: 4px 4px 12px;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fbe7ae 0%, var(--gold) 55%, #9a6a24 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 12px rgba(224, 118, 44, 0.35)) drop-shadow(0 2px 0 rgba(0, 0, 0, 0.8));
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.04em;
}

.day-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.day-picker label {
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 13px;
}

input, button {
    font: inherit;
    color: var(--text);
    background: linear-gradient(180deg, #2b2219, #1c1611);
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.06), 0 1px 2px rgba(0, 0, 0, 0.6);
}

input {
    width: 84px;
    padding: 6px 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    background: #120e0a;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
}

input:focus, button:focus-visible {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(214, 166, 71, 0.25);
}

button {
    padding: 6px 14px;
    cursor: pointer;
}

button:hover { border-color: var(--gold); color: var(--gold-bright); }

button.nav {
    width: 32px;
    padding: 4px 0;
    font-size: 20px;
    line-height: 1;
}

#run {
    color: #1a1208;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: linear-gradient(180deg, #f0c56a, #b9832f);
    border-color: #7a5520;
}

#run:hover { background: linear-gradient(180deg, #ffd889, #cf953a); color: #1a1208; }

button.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 12px 2px 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.switch {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 8px;
    background: #120e0a;
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
    transition: background 0.2s;
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.2s, background 0.2s;
}

button.toggle[aria-pressed="true"] { color: var(--text); }

button.toggle[aria-pressed="true"] .switch { background: rgba(214, 166, 71, 0.35); border-color: #7a5520; }

button.toggle[aria-pressed="true"] .switch::after { transform: translateX(12px); background: var(--gold-bright); }

/* Day cycle legend */

.daycycle {
    position: relative;
    width: 420px;
    max-width: 100%;
    padding: 0 14px;
}

.cycle-bar {
    height: 6px;
    margin-top: 32px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.6);
    /* Night until 03:36 (15%), sunrise until 06:00 (25%), daylight until 18:00 (75%), sunset until 20:24 (85%). */
    background: linear-gradient(90deg,
        var(--night) 0%, var(--night) 15%,
        #5a3e4a 17%, #b8643a 20%, #eebd62 25%,
        #f5dc92 50%,
        #eebd62 75%, #b8583a 80%, #5a3a48 83%,
        var(--night) 85%, var(--night) 100%);
}

.cycle-marks {
    position: absolute;
    inset: 0 14px;
}

.mark {
    position: absolute;
    top: 0;
    left: var(--at);
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mark .ico { width: 28px; height: 28px; margin-bottom: 12px; }

.mark span {
    font-size: 11px;
    color: var(--muted);
}

/* ---------- Forecast table ---------- */

.panel {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 220, 160, 0.05),
        0 10px 30px rgba(0, 0, 0, 0.55);
}

.panel { min-width: 0; }

.scroll { --rail: 12px; position: relative; overflow-x: auto; padding-top: var(--rail); }

/* ---------- Live tracker ---------- */

.tracker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 16px;
    padding: 4px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent);
}

.tracker-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    min-height: 28px;
    font-size: 13px;
    color: var(--muted);
}

.tracker-status b { color: var(--gold-bright); font-weight: 700; }

/* Live numbers get a fixed width so the chips don't jitter as digits change. */
.num {
    display: inline-block;
    min-width: 4.8ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.num.since-num { min-width: 5.8ch; }

.num.clock-num { min-width: 4.8ch; text-align: left; }

.num.wind-num { min-width: 3.8ch; }

.now-clock {
    font-size: 17px;
    font-weight: 700;
    color: var(--gold-bright);
    letter-spacing: 0.04em;
}

.live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #6fd36a;
    box-shadow: 0 0 8px #6fd36a;
    animation: pulse 1.6s ease-in-out infinite;
}

.tracker.paused .live-dot { background: var(--muted); box-shadow: none; animation: none; }

@keyframes pulse { 50% { opacity: 0.35; } }

.chip {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.paused-chip { color: var(--ember); border-color: rgba(224, 118, 44, 0.5); }

.tracker-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

.tracker-buttons button { padding: 4px 12px; font-size: 13px; }

#start {
    color: #1a1208;
    font-weight: 700;
    background: linear-gradient(180deg, #f0c56a, #b9832f);
    border-color: #7a5520;
}

#start:hover { background: linear-gradient(180deg, #ffd889, #cf953a); }

button:disabled { opacity: 0.4; cursor: default; border-color: var(--line); color: var(--text); }

button.link {
    padding: 2px 8px;
    font-size: 12px;
    color: var(--gold-bright);
    background: transparent;
    border-color: rgba(214, 166, 71, 0.5);
    box-shadow: none;
}

#start.stop {
    color: var(--text);
    background: linear-gradient(180deg, #5a2a1c, #3a1a10);
    border-color: rgba(224, 118, 44, 0.6);
}

#start.stop:hover { color: #fff1c9; background: linear-gradient(180deg, #74361f, #4a2012); }

/* Current moment across the table. The layer is clipped to the table so the line never adds a scrollbar. */
.now-layer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

/* Strip above the table: click or drag in it to set the time. */
.time-rail {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--rail);
    cursor: ew-resize;
    pointer-events: auto;
    touch-action: none;
}

.scroll.tracking .time-rail { background: linear-gradient(180deg, transparent, rgba(111, 211, 106, 0.08)); }

.scroll:not(.tracking) .time-rail { display: none; }

#now-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px solid #6fd36a;
    box-shadow: 0 0 8px rgba(111, 211, 106, 0.8);
    transition: left 0.25s linear;
}

#now-line.dragging { transition: none; }

.now-handle {
    position: absolute;
    top: 0;
    left: -7px;
    width: 12px;
    height: var(--rail);
    background: linear-gradient(180deg, #b8f5b4, #56b951);
    clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%);
    cursor: ew-resize;
    pointer-events: auto;
    touch-action: none;
}

.now-handle:hover, #now-line.dragging .now-handle { background: #d6ffd3; }

#forecast th.time.now { box-shadow: inset 0 -3px 0 #6fd36a; }

#forecast td.past, #forecast th.time.past { filter: brightness(0.55) saturate(0.6); }

table {
    width: 100%;
    min-width: 1180px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

col.col-label { width: 150px; }

th, td {
    padding: 0;
    text-align: center;
    vertical-align: middle;
    font-weight: normal;
}

th.label {
    position: sticky;
    left: 0;
    z-index: 2;
    padding: 0 12px;
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--panel-2);
    border-right: 1px solid var(--line);
}

/* Time row */

.row-time th { height: 60px; border-bottom: 1px solid var(--line-soft); }

th.corner {
    color: var(--gold);
    font-size: 14px;
    text-transform: uppercase;
}

th.corner b {
    font-size: 22px;
    color: var(--gold-bright);
    margin-left: 4px;
}

th.time {
    display: table-cell;
    font-size: 12px;
    color: var(--text);
    border-left: 1px solid rgba(0, 0, 0, 0.35);
}

th.time .ico { display: block; width: 28px; height: 28px; margin: 0 auto -2px; }

th.time span { display: block; line-height: 1.15; }

th.time .since, .since-label {
    font-size: 10.5px;
    color: #9fd89b;
    opacity: 0.85;
}

.since-label { display: block; margin-top: 1px; text-transform: none; letter-spacing: 0; }

th.time.night { background: rgba(38, 50, 79, 0.45); color: #b9c3d8; }
th.time.dawn { background: rgba(201, 115, 58, 0.16); }
th.time.day { background: rgba(245, 220, 146, 0.08); }
th.time.dusk { background: rgba(201, 99, 58, 0.18); }
th.time.intro { background: rgba(110, 60, 150, 0.25); color: #d4c1ea; }

/* Wind direction row */

.row-direction td, .row-direction th { height: 62px; }

.compass {
    position: relative;
    display: block;
    width: 38px;
    height: 38px;
    margin: 2px auto 1px;
    border-radius: 50%;
    border: 1px solid rgba(214, 166, 71, 0.45);
    background: radial-gradient(circle, rgba(255, 220, 160, 0.07), rgba(0, 0, 0, 0.35) 70%);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.8);
}

/* North notch */
.compass::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 50%;
    margin-left: -3px;
    border: 3px solid transparent;
    border-bottom: 4px solid var(--ember);
    border-top: 0;
}

.compass .arrow {
    position: absolute;
    inset: 4px;
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.9));
}

.dir-text {
    display: block;
    font-size: 10.5px;
    color: var(--muted);
    white-space: nowrap;
}

/* Global wind strength row */

.row-strength td, .row-strength th {
    height: 46px;
    border-bottom: 2px solid var(--line);
}

td.strength {
    font-size: 12px;
    background: hsl(var(--h) 60% 45% / calc(0.04 + 0.2 * var(--v)));
}

td.strength .gust { display: block; width: 56px; height: 56px; margin: -15px auto -17px; }

/* Biomes */

tbody.biome th.biome-label {
    color: var(--text);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    border-left: 4px solid var(--biome);
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--biome) 20%, transparent), transparent 85%),
        var(--panel-2);
}

tbody.biome th.biome-label > * { vertical-align: middle; }

.biome-ico {
    width: 28px;
    height: 28px;
    margin-right: 8px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8));
}

tbody.biome th.biome-label span { color: color-mix(in srgb, var(--biome) 55%, var(--text)); }

.row-weather td { height: 35px; }

td.weather {
    position: relative;
    padding: 0 4px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--biome) 24%, transparent), color-mix(in srgb, var(--biome) 14%, transparent));
    box-shadow: inset 0 2px 0 color-mix(in srgb, var(--biome) 50%, transparent);
}

.wx {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
}

.wx .ico { flex: none; width: 40px; height: 40px; margin: -3px 0; }

.wx-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    color: color-mix(in srgb, var(--biome) 35%, var(--text));
}

td.weather.narrow .wx-name { display: none; }

/* Start time of each weather period, in the top-left corner. */
.wx-time {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 10px;
    line-height: 1;
    color: color-mix(in srgb, var(--biome) 30%, var(--text));
    opacity: 0.75;
}

td.weather.narrow .wx-time, td.weather.short .wx-time { display: none; }

/* Divider running through the whole table wherever the weather changes. */
#forecast .wx-start {
    border-left: 2px solid rgba(242, 209, 127, 0.75);
}

.row-wind td {
    height: 23px;
    padding: 2px 5px 3px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--biome) 10%, transparent);
}

.pct {
    display: block;
    font-size: 11.5px;
    line-height: 1.1;
    color: color-mix(in srgb, var(--biome) 30%, var(--text));
}

.bar {
    display: block;
    height: 3px;
    margin-top: 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.bar i {
    display: block;
    height: 100%;
    background: hsl(var(--h) 70% 55%);
}

tbody.biome:last-child td, tbody.biome:last-child th { border-bottom: 0; }

tbody.biome:hover td { filter: brightness(1.15); }

/* ---------- Facts ---------- */

.facts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
}

.fact {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 12px 2px 4px;
    font-size: 12.5px;
    color: var(--muted);
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 3px;
}

.fact img { width: 30px; height: 30px; margin: -3px 0; }

.fact b { color: var(--gold-bright); font-weight: 700; }

/* ---------- Footer ---------- */

.credits {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 12px;
    margin-top: auto;
    padding: 8px 0 4px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.credits strong { color: var(--text); font-weight: 700; }

.credits .sep { color: var(--gold); opacity: 0.6; }

/* Short screens (laptops): tighten rows so the whole day fits without scrolling. */
@media (max-height: 900px) {
    .page { padding-top: 6px; padding-bottom: 4px; gap: 6px; }
    .subtitle { display: none; }
    .topbar { padding-bottom: 8px; }
    h1 { font-size: 26px; }
    .row-time th { height: 47px; }
    th.time .ico { width: 24px; height: 24px; }
    .row-direction td, .row-direction th { height: 46px; }
    .compass { width: 32px; height: 32px; }
    .compass .arrow { inset: 3px; width: 24px; height: 24px; }
    .row-strength td, .row-strength th { height: 36px; }
    td.strength .gust { width: 48px; height: 48px; margin: -13px auto -15px; }
    .row-weather td { height: 27px; }
    .wx .ico { width: 34px; height: 34px; }
    .row-wind td { height: 21px; padding-top: 1px; padding-bottom: 2px; }
    .fact { font-size: 12px; }
    .fact img { width: 26px; height: 26px; }
    .credits { padding-top: 4px; }
}

@media (max-width: 720px) {
    .topbar { justify-content: center; text-align: center; }
    h1 { font-size: 24px; }
    .credits .sep { display: none; }
    .credits span { flex-basis: 100%; }
}
