:root {
  --ink: #ece6da;
  --muted: #9a958c;
  --faint: #5f5b55;
  --gold: #e0b35a;
  --gold-2: #f2c46b;
  --blue: #9cc7ff;
  --est: #5fd0e0;
  --bg: #050507;
  --card: rgba(14, 13, 12, 0.78);
  --line: rgba(236, 230, 218, 0.12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; -webkit-user-select: none; user-select: none; }
.touch-only { display: none; }
@media (hover: none) { .touch-only { display: inline; } p.touch-only { display: block; } .hover-only { display: none; } }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.kicker { font: 500 11.5px/1.2 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin: 0 0 10px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: 0.005em; }

#gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 60%, #15120d 0%, #050507 70%); transition: opacity 1.2s ease; }
#gate.gone { opacity: 0; pointer-events: none; }
.gate-inner { max-width: 620px; max-height: 100%; overflow: auto; padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); text-align: center; }
#gate h1 { font-size: clamp(44px, 7vw, 84px); line-height: 1.02; margin-bottom: 18px; }
.lede { font-family: var(--serif); font-size: 18px; line-height: 1.55; color: #d9d2c4; }
.gate-buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 26px 0 18px; }
.gate-buttons button { padding: 12px 22px; border-radius: 999px; border: 1px solid var(--gold); background: var(--gold); color: #1a1408; font-weight: 600; }
.gate-buttons button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.gate-buttons button:disabled { opacity: 0.4; cursor: progress; }

#top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); background: linear-gradient(to bottom, rgba(5,5,7,0.85), rgba(5,5,7,0)); pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { font-family: var(--serif); font-size: 16px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand em { color: var(--gold); font-style: normal; }
.brand .disc { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle, #1a1208 0 12%, #e9c271 14% 40%, #b88b3c 42% 100%); box-shadow: 0 0 10px rgba(224, 179, 90, 0.5); }
#chapters { display: flex; gap: 2px; margin: 0 auto; flex-wrap: nowrap; justify-content: center; }
#chapters button { white-space: nowrap; flex: none; }
.tools { flex: none; }
/* set by fitHeader() in main.js, one step at a time until the header fits */
#top.c1 #chapters button:not(.on) .t { display: none; }
#top.c2 .brand, #top.c2 .next .t { display: none; }
#top.c3 #chapters button .t, #top.c3 .next .lead { display: none; }
#top.c3 #chapters button .n { margin-right: 0; }
#top.c3 .next { padding: 4px; }
#top.c4 #chapters button { padding: 6px 7px; }
#top.c4 #t-help { display: none; }
#top.c4 { gap: 8px; }
#chapters button { background: none; border: 0; padding: 6px 11px; border-radius: 999px; color: var(--muted); font-size: 13px; }
#chapters button .n { font-family: var(--mono); font-size: 10.5px; margin-right: 6px; color: var(--faint); }
#chapters button { transition: color 0.25s, background 0.25s; }
#chapters button:hover { color: var(--ink); background: rgba(236, 230, 218, 0.05); }
#chapters button.on { color: var(--ink); background: rgba(236, 230, 218, 0.08); }
.next { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 999px; border: 1px solid var(--gold); background: rgba(224, 179, 90, 0.12); color: var(--gold-2); font-size: 12.5px; white-space: nowrap; transition: background 0.3s, color 0.3s, box-shadow 0.3s; }
.next .lead { font-weight: 600; }
.next .t { color: var(--ink); }
.next .arr { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: #1a1408; font-size: 12px; transition: transform 0.3s; }
.next:hover { background: rgba(224, 179, 90, 0.22); }
.next:hover .arr { transform: translateX(2px); }
.next.ready { animation: beckon 2.4s ease-in-out infinite; }
.next.ready .arr { animation: nudge 2.4s ease-in-out infinite; }
@keyframes beckon { 0%, 100% { box-shadow: 0 0 0 0 rgba(224, 179, 90, 0); } 40% { box-shadow: 0 0 0 6px rgba(224, 179, 90, 0.18), 0 0 22px rgba(224, 179, 90, 0.35); } }
@keyframes nudge { 0%, 100% { transform: none; } 40% { transform: translateX(3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
#fade { position: fixed; inset: 0; z-index: 9; background: #030304; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
#fade.on { opacity: 1; }
#record-ui, #cover-ui, #time-ui, .dock, .dock-note, .card, .page { animation: fadein 0.7s ease 0.15s both; }
#chapters button.on .n { color: var(--gold); }
.tools { display: flex; gap: 6px; }
.chip { background: rgba(236, 230, 218, 0.06); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--ink); }
.chip.on { border-color: var(--gold); color: var(--gold-2); background: rgba(224, 179, 90, 0.1); }

.overlay { position: fixed; z-index: 10; }
/* wide screens: the numbers on the left, the spacecraft framed in the space to their right */
#hero { left: max(clamp(18px, 6vw, 90px), env(safe-area-inset-left)); top: var(--hdr, 60px); bottom: 24px; width: min(640px, 44vw); display: flex; flex-direction: column; justify-content: center; pointer-events: none; }
#hero > * { animation: rise 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
#hero > :nth-child(2) { animation-delay: 0.12s; }
#hero > :nth-child(3) { animation-delay: 0.3s; }
#hero > :nth-child(4) { animation-delay: 0.48s; }
#hero > :nth-child(5) { animation-delay: 0.62s; }
#hero h2 { font-size: clamp(32px, min(6vw, 9vh), 76px); line-height: 1; margin-bottom: clamp(12px, 3vh, 26px); }
.big-numbers { display: flex; flex-wrap: wrap; gap: 8px clamp(16px, 2.4vw, 34px); margin-bottom: clamp(10px, 2.4vh, 22px); }
.big-numbers div { display: flex; flex-direction: column; }
.big-numbers .label { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.big-numbers .num { font: 400 clamp(17px, min(2.6vw, 4.6vh), 34px)/1.2 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.big-numbers .unit { font-size: 11.5px; color: var(--faint); font-family: var(--mono); }
#hero .lede { max-width: 560px; font-size: clamp(14px, min(1.6vw, 2.7vh), 18px); }

.card { position: fixed; z-index: 15; background: var(--card); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px 18px; }
#panel { right: max(18px, env(safe-area-inset-right)); top: calc(var(--hdr, 60px) + 10px); width: min(380px, calc(100vw - 36px)); max-height: calc(100% - var(--hdr, 60px) - 130px); overflow: auto; overscroll-behavior: contain; }
#panel h3 { font-size: 26px; line-height: 1.15; margin-bottom: 8px; }
#panel .dims { font: 12.5px/1.5 var(--mono); color: var(--gold-2); margin: 0 0 10px; }
#panel p { margin: 0 0 12px; }
#panel .sources { font-size: 12px; color: var(--muted); }
#panel .sources a { color: var(--muted); }
#panel .fid { display: inline-block; font: 10.5px/1 var(--mono); padding: 3px 7px; border-radius: 4px; margin-left: 8px; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.06em; }
#panel .fid.sourced { background: rgba(224, 179, 90, 0.16); color: var(--gold-2); }
#panel .fid.estimated { background: rgba(95, 208, 224, 0.14); color: var(--est); }
#p-status { display: flex; gap: 8px; margin-bottom: 12px; }
#p-status span { font: 12px/1 var(--mono); padding: 5px 8px; border-radius: 6px; background: rgba(236, 230, 218, 0.06); }
#p-status span b { font-weight: 500; color: var(--muted); margin-right: 6px; }
.close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 22px; color: var(--muted); }
.binary { font: 12px/1.4 var(--mono); word-break: break-all; color: var(--gold-2); }

.dock { position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); bottom: max(22px, env(safe-area-inset-bottom)); display: flex; gap: 8px; max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none; }
.dock .chip { flex: none; white-space: nowrap; }
.dock-note { position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 40px); margin: 0; width: max-content; max-width: min(620px, calc(100vw - 32px)); text-align: center; font-size: 12.5px; color: var(--muted); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
.lbl { position: absolute; transform: translate(-50%, -100%); font-size: 11.5px; white-space: nowrap; color: var(--ink); pointer-events: auto; cursor: pointer; padding: 3px 8px 3px 16px; border-radius: 999px; background: rgba(10, 10, 10, 0.55); border: 1px solid var(--line); transition: opacity 0.25s; }
.lbl::before { content: ""; position: absolute; left: 6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--gold); }
.lbl.estimated::before { background: var(--est); }
.lbl.on { border-color: var(--gold); }
.lbl.jl { transform: translate(10px, -50%); background: none; border: 0; padding: 0 0 0 4px; color: var(--muted); pointer-events: none; }
.lbl.jl::before { display: none; }
.lbl.jl.craft { color: var(--ink); font-weight: 500; }

#record-ui { right: max(18px, env(safe-area-inset-right)); top: calc(var(--hdr, 60px) + 10px); bottom: max(18px, env(safe-area-inset-bottom)); width: min(420px, 46vw); display: flex; flex-direction: column; }
#record-list { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; white-space: nowrap; }
.tab { background: rgba(14, 13, 12, 0.7); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--muted); }
.tab.on { color: var(--ink); border-color: var(--gold); }
#record-list { flex: 1; overflow: auto; background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 14px; padding: 6px 0; }
.row { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 9px 16px; border-bottom: 1px solid rgba(236, 230, 218, 0.05); }
.row:last-child { border-bottom: 0; }
.row .t { font: 12px/1.6 var(--mono); color: var(--faint); }
.row .h { font-weight: 500; }
.row .o { font-family: var(--serif); color: #d9d2c4; font-size: 14.5px; }
.row .e { color: var(--muted); font-size: 13px; }
#record-src { margin: 8px 4px 0; }

#cover-ui { left: 50%; transform: translateX(-50%); bottom: max(22px, env(safe-area-inset-bottom)); width: min(640px, calc(100vw - 32px)); text-align: center; pointer-events: none; }

#time-ui { left: max(18px, env(safe-area-inset-left)); right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); }
.readouts { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.ro { background: var(--card); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; font: 12.5px/1.5 var(--mono); color: var(--muted); }
.ro .who { display: block; font: 500 11px/1.4 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; }
.ro.v1 .who { color: var(--gold-2); }
.ro.v2 .who { color: var(--blue); }
.ro b { color: var(--ink); font-weight: 400; }
.scrub { display: flex; align-items: center; gap: 12px; background: var(--card); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px 8px 10px; }
.scrub .date { font: 14px/1 var(--mono); min-width: 104px; text-align: center; }
.scrub input[type=range] { flex: 1; min-width: 0; accent-color: var(--gold); touch-action: pan-x; }
.scrub .chip { flex: none; white-space: nowrap; }
#events { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
#events button { background: rgba(14, 13, 12, 0.65); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-size: 11.5px; color: var(--muted); }
#events button.v1 { border-color: rgba(242, 196, 107, 0.35); }
#events button.v2 { border-color: rgba(156, 199, 255, 0.35); }
#events button.on { color: var(--ink); background: rgba(236, 230, 218, 0.1); }
.event-card { position: fixed; left: max(18px, env(safe-area-inset-left)); top: calc(var(--hdr, 60px) + 10px); max-width: min(420px, calc(100vw - 36px)); margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.5; color: #e5dfd2; text-shadow: 0 1px 12px #000; }
.event-card .d { display: block; font: 500 11.5px/1.2 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }

/* left, width and bottom are set by layout() in main.js to fit the free part of the screen */
#captions { position: fixed; z-index: 14; left: 14px; width: calc(100% - 28px); bottom: 34px; text-align: center; pointer-events: none; transition: bottom 0.5s ease, left 0.5s ease, width 0.5s ease; }
body[data-ch="made"] #captions { z-index: 35; }
#cap { margin: 0; font-family: var(--serif); font-size: clamp(17px, 1.6vw, 21px); line-height: 1.5; color: rgba(236, 230, 218, 0.42); text-shadow: 0 1px 14px #000, 0 0 3px #000, 0 0 1px #000; transition: opacity 0.4s; }
#cap.in { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
#cap .w { transition: color 0.18s; }
#cap .w.on { color: #f6f0e3; }

.page { position: fixed; inset: 0; z-index: 30; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: rgba(5, 5, 7, 0.94); padding: calc(var(--hdr, 60px) + 24px) max(clamp(16px, 8vw, 120px), env(safe-area-inset-right)) 160px max(clamp(16px, 8vw, 120px), env(safe-area-inset-left)); }
.page h2 { font-size: clamp(36px, 4.4vw, 58px); margin-bottom: 14px; }
.page h3 { font-size: 24px; margin: 38px 0 12px; }
.page .lede { max-width: 760px; }
.page table { width: 100%; border-collapse: collapse; font-size: 13px; }
.page th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px 10px; }
.page td { border-bottom: 1px solid rgba(236, 230, 218, 0.06); padding: 8px 10px; vertical-align: top; }
.page td.m { font-family: var(--mono); white-space: nowrap; }
.page td.r { text-align: right; font-family: var(--mono); }
.page a { color: var(--gold-2); }
.page .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px 40px; }
.page ol { padding-left: 20px; }
.page li { margin-bottom: 6px; }
.page .total { font: 15px var(--mono); color: var(--gold-2); }

#help { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 40px)); max-height: calc(100% - 40px); overflow: auto; z-index: 40; }
#help h3 { margin-bottom: 10px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; }
}
@media (max-height: 760px) {
  #hero .muted.small { display: none; }
}
@media (max-height: 520px) {
  #hero .st { display: none; }
  .ro { padding: 6px 10px; font-size: 11.5px; }
}
/* tall or narrow screens: the spacecraft above, the numbers docked at the bottom */
@media (max-aspect-ratio: 5/4), (max-width: 639px) {
  #hero { left: 0; right: 0; top: auto; bottom: 0; width: auto; padding: 56px max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: linear-gradient(to top, rgba(5, 5, 7, 0.92) 60%, rgba(5, 5, 7, 0)); }
  #hero h2 { font-size: clamp(30px, 9vw, 56px); margin-bottom: 12px; }
  .big-numbers { gap: 6px 18px; margin-bottom: 10px; }
  .big-numbers .label { font-size: 10px; letter-spacing: 0.06em; }
  .big-numbers .num { font-size: clamp(15px, 4.3vw, 26px); }
  #hero .lede { font-size: clamp(14px, 3.6vw, 17px); max-width: 640px; }
  #hero .st, #hero .muted.small { display: none; }
  #record-ui { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); width: auto; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); height: min(44%, 440px); }
  #record-src { display: none; }
  #panel { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); width: auto; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); max-height: 46%; }
  .event-card { font-size: 15px; right: max(18px, env(safe-area-inset-right)); }
}
@media (max-width: 760px) {
  .ro { font-size: 11px; padding: 7px 10px; }
  #events { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #events button { flex: none; white-space: nowrap; }
  .scrub { gap: 8px; }
  .scrub .date { min-width: 84px; font-size: 12.5px; }
  .page table { display: block; overflow-x: auto; }
  .card { padding: 16px 18px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; }
}
html.still #gate { display: none; }
html.still *, html.still *::before, html.still *::after { animation: none !important; transition: none !important; }
