:root {
  --bg: #050505;
  --panel: #121212;
  --panel-2: #1c1c1c;
  --line: #353535;
  --text: #ededed;
  --muted: #9b9b9b;
  --accent: #f2f2f2;
  --pass: #4cd18a;
  --fail: #ff6b6b;
  --warn: #ffcc4d;
  --panel-w: 360px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* our display rules must not override `hidden` */

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

#globe { position: absolute; inset: 0 var(--panel-w) 0 0; }

#panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: var(--panel-w);
  overflow-y: auto;
  padding: 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

h1 { font-size: 18px; margin: 0 0 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
section { padding: 14px 0; border-top: 1px solid var(--line); }
header { padding-bottom: 12px; }

.hint, .muted { color: var(--muted); }
.small { font-size: 12px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tile { background: var(--panel-2); border-radius: 6px; padding: 8px; }
.tile .k { font-size: 11px; color: var(--muted); }
.tile .v { font-size: 16px; font-weight: 600; }

label { display: block; margin: 8px 0; font-size: 12px; color: var(--muted); }
select, input, button {
  display: block; width: 100%; margin-top: 4px;
  padding: 7px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: inherit;
}
button { cursor: pointer; background: var(--accent); color: #0a0a0a; border: 0; font-weight: 600; margin-top: 10px; }
button:disabled { opacity: .4; cursor: default; }

.window-btn { display: inline-block; width: auto; margin: 4px 4px 0 0; padding: 4px 8px; background: var(--panel-2); color: var(--accent); border: 1px solid var(--line); font-weight: 500; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; color: #0a0a0a; }
.badge.pass { background: var(--pass); }
.badge.fail { background: var(--fail); }

.checks, .compare { list-style: none; margin: 0; padding: 0; }
.checks li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.checks li::before { content: "✗ "; color: var(--fail); font-weight: 700; }
.checks li.ok::before { content: "✓ "; color: var(--pass); }
.checks b { text-transform: capitalize; }

.compare li { padding: 8px; margin-bottom: 4px; border-radius: 6px; background: var(--panel-2); cursor: pointer; border-left: 4px solid var(--line); }
.compare li.active { outline: 1px solid var(--accent); }

.error { color: var(--fail); }

a { color: var(--accent); }

/* Map layer switcher over the globe */
.overlay {
  background: rgba(14, 14, 14, .85); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px;
}

/* Left column over the globe: layer switcher + compared sites */
#left-col {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  max-height: calc(100% - 150px);        /* leave room for the legend */
}
#layers { width: min(300px, calc(100vw - var(--panel-w) - 24px)); }
#compare-panel {
  background: rgba(14, 14, 14, .45); backdrop-filter: blur(3px);
  overflow-y: auto; min-height: 0; flex: 0 1 auto;
}
/* Comparison chart: one row per site, one column per value */
#compare-panel { width: max-content; max-width: calc(100vw - var(--panel-w) - 24px); }
.table-wrap { overflow-x: auto; }
.compare-table { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.compare-table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11px;
  padding: 4px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: rgba(14, 14, 14, .7);
}
.compare-table td { padding: 5px 8px; border-bottom: 1px solid rgba(90, 90, 90, .6); vertical-align: top; }
.compare-table td .muted { font-size: 11px; }
.compare-table tbody tr { cursor: pointer; background: rgba(22, 29, 45, .35); }
.compare-table tbody tr:hover { background: rgba(90, 90, 90, .7); }
.compare-table tbody tr.active { background: rgba(255, 255, 255, .1); outline: 1px solid var(--accent); }
.compare-table .site-cell { border-left: 4px solid var(--line); }
.compare-table td.good { color: var(--pass); font-weight: 600; }
.compare-table td.warn { color: var(--warn); font-weight: 600; }
.compare-table td.bad { color: var(--fail); font-weight: 600; }
.period-modes { display: flex; gap: 14px; }
.period-modes .check { margin: 0 0 4px; }

#compare-panel .compare li {
  background: rgba(22, 29, 45, .6); border-left-width: 4px; margin-bottom: 6px; font-size: 12px;
}
#compare-panel .compare li:hover { background: rgba(90, 90, 90, .75); }
.compare li .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.compare li .remove, .compare-table .remove {
  width: auto; margin: 0; padding: 0 6px; background: transparent; color: var(--muted);
  border: 0; font-size: 14px; line-height: 1;
}
.compare li .remove:hover, .compare-table .remove:hover { color: var(--fail); }
.summary { margin-top: 6px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
.summary .k { color: var(--muted); }

/* Stat colour legend, bottom left */
#legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; line-height: 1.7; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.swatch.good, .dot.good { background: var(--pass); }
.swatch.warn, .dot.warn { background: var(--warn); }
.swatch.bad, .dot.bad { background: var(--fail); }
.swatch.ice-ok { background: rgb(120, 205, 255); }
.swatch.outlined { outline: 2px solid #fff; outline-offset: 1px; }
.dot.none { background: var(--line); }

/* Rated stat tiles */
.tile { border-left: 3px solid transparent; }
.tile.good { border-left-color: var(--pass); }
.tile.good .v { color: var(--pass); }
.tile.warn { border-left-color: var(--warn); }
.tile.warn .v { color: var(--warn); }
.tile.bad { border-left-color: var(--fail); }
.tile.bad .v { color: var(--fail); }
.overlay-title { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.check { display: flex; gap: 6px; align-items: center; margin: 8px 0 0; }
.check input { width: auto; margin: 0; display: inline; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.chip {
  display: inline-block; width: auto; margin: 0 4px 4px 0; padding: 3px 9px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; font-weight: 500; font-size: 12px;
}
.chips .chip { margin: 0; }
.chip.on { background: var(--accent); color: #0a0a0a; border-color: var(--accent); }

.site-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.site-list li { padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.site-list li:hover { background: var(--panel-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

.coord-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 10px; }
.coord-form input, .coord-form button { margin: 0; }
.coord-form button { padding: 7px 12px; }

.sky-now { background: var(--panel-2); border-radius: 6px; padding: 8px; margin: 8px 0; font-size: 13px; }
.sky-now:empty { display: none; }
.links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tile .sub { font-size: 11px; color: var(--muted); }
.badge.level { background: #c9b6ff; }
.site-terrain { margin-top: 6px; line-height: 1.6; }
button.secondary { background: var(--panel-2); color: var(--accent); border: 1px solid var(--accent); font-weight: 600; }
#sky-caption { margin-top: 6px; max-width: 300px; }

/* Sun & Earth markers on the globe (globe.gl HTML layer) */
.sky-marker {
  display: flex; flex-direction: column; align-items: center; transform: translate(-50%, -50%);
  pointer-events: none; transition: opacity .2s; text-shadow: 0 0 6px #000;
}
.sky-marker .glyph { font-size: 30px; line-height: 1; }
.sky-marker.sun .glyph { filter: drop-shadow(0 0 12px #ffd76a); font-size: 38px; }
.sky-marker .tag { font-size: 11px; color: var(--text); background: rgba(14, 14, 14, .7); padding: 0 5px; border-radius: 6px; margin-top: 2px; }

/* ---- 3D site view overlay ---- */
#view3d {
  position: fixed; inset: 0; z-index: 10; background: #000;
  display: grid; grid-template-rows: auto 1fr auto;
}
#view3d[hidden] { display: none; }
.v3d-top, .v3d-bottom {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 12px; background: var(--panel); border-color: var(--line); border-style: solid; border-width: 0;
}
.v3d-top { justify-content: space-between; border-bottom-width: 1px; }
.v3d-bottom { border-top-width: 1px; }
.v3d-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.v3d-tools .check { margin: 0; }
#v3d-canvas { position: relative; min-height: 0; overflow: hidden; }
#v3d-canvas canvas { display: block; }
#v3d-hud {
  position: absolute; top: 64px; left: 12px; z-index: 11; width: 270px;
  background: rgba(14, 14, 14, .85); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.6; pointer-events: none;
}
#v3d-hud .big { font-size: 15px; font-weight: 600; }
#v3d-hud hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
#v3d-hud .warn { color: var(--fail); font-weight: 600; }
#v3d-hud .ok { color: var(--pass); }
#v3d-play, #v3d-speed { width: auto; margin: 0; }
#v3d-play { min-width: 92px; }
#v3d-scrub { flex: 1 1 260px; margin: 0; padding: 0; accent-color: var(--accent); }
#v3d-note { flex-basis: 100%; }

@media (max-width: 700px) {
  #v3d-hud { top: auto; bottom: 120px; width: auto; right: 12px; font-size: 12px; }
  :root { --panel-w: 100%; }
  #globe { inset: 0 0 50% 0; }
  #panel { top: 50%; width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  #left-col { width: calc(100% - 24px); max-height: calc(100% - 24px); }
  #layers, #compare-panel { width: 100%; max-width: 100%; }
  #compare-panel { max-height: 30vh; }
  #legend { display: none; }                 /* not enough room; colours still show on the tiles */
}

/* ===== Landing page (mission requirements) ===== */
#landing {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .55), rgba(0, 0, 0, .92));
  overflow-y: auto;
}
#landing[hidden] { display: none; }
.landing-card {
  width: min(640px, 100%); background: rgba(14, 14, 14, .94); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.landing-card h1 { font-size: 24px; margin-bottom: 6px; }
.landing-card label { color: var(--text); font-size: 13px; }
.landing-card button[type=submit] { font-size: 15px; padding: 10px; }
button.linklike {
  background: none; border: 0; color: var(--accent); font-weight: 500; text-align: center; margin-top: 8px;
}
button.linklike:hover { text-decoration: underline; }

/* ===== Collapsible panels ===== */
.overlay-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.overlay-head .overlay-title { margin: 0; }
.collapse-btn {
  width: auto; margin: 0; padding: 0 4px; background: none; border: 0; color: var(--muted);
  font-size: 14px; line-height: 1; transition: transform .15s;
}
.collapse-btn:hover { color: var(--text); }
.collapsible .collapse-body { margin-top: 6px; }
.collapsible.collapsed .collapse-body { display: none; }
.collapsible.collapsed .collapse-btn { transform: rotate(-90deg); }

/* Right panel: slides away; the arrow stays on screen */
#panel { transition: transform .2s ease; overflow: visible; display: flex; flex-direction: column; padding: 0; }
#panel > header, #panel > nav, #panel > .tab-body, #panel > #loading, #panel > #error { padding-left: 16px; padding-right: 16px; }
#panel > header { padding-top: 14px; }
#panel-toggle {
  position: absolute; left: -26px; top: 12px; width: 26px; height: 40px; margin: 0; padding: 0;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-right: 0;
  border-radius: 8px 0 0 8px; font-size: 12px;
}
#panel-toggle:hover { color: var(--text); }
body.panel-collapsed #panel { transform: translateX(100%); }
body.panel-collapsed #globe { right: 0; }
#globe { transition: right .2s ease; }

.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.period-bar .check { margin: 0; }
.period-bar input[type=date] { width: auto; margin: 0; padding: 3px 6px; font-size: 12px; }
.period-dates { display: flex; align-items: center; gap: 4px; white-space: nowrap; flex-basis: 100%; }
#period-end-wrap { display: inline-flex; align-items: center; gap: 4px; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-top: 10px; }
.tab {
  width: auto; margin: 0; padding: 7px 12px; background: none; color: var(--muted); border: 0;
  border-bottom: 2px solid transparent; border-radius: 0; font-weight: 600; font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { font-size: 11px; color: var(--muted); }
.tab-body { flex: 1 1 auto; overflow-y: auto; padding-top: 12px; padding-bottom: 16px; min-height: 0; }
.tab-body:not(.on) { display: none; }
.tab-body section { padding: 12px 0; }
.tab-body section:first-of-type { border-top: 0; padding-top: 0; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn-row button { margin-top: 10px; }

/* ===== Search results ===== */
#search-summary p { margin: 4px 0; }
.region-list { list-style: none; margin: 10px 0 0; padding: 0; counter-reset: region; }
.region-list li {
  counter-increment: region; padding: 8px 10px 8px 34px; margin-bottom: 6px; position: relative;
  background: var(--panel-2); border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.region-list li::before {
  content: counter(region); position: absolute; left: 10px; top: 8px; font-weight: 700; color: var(--accent);
}
.region-list li:hover { border-color: var(--accent); }
.region-list li.dim { opacity: .55; }
.region-list .stats { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 12px; }
.region-list .good { color: var(--pass); } .region-list .warn { color: var(--warn); } .region-list .bad { color: var(--fail); }
.region-list .add { width: auto; margin: 0; padding: 1px 8px; font-size: 11px; position: absolute; right: 8px; top: 7px; }

/* ===== Vertical comparison table: rows = values, columns = sites ===== */
.compare-table.vertical { white-space: normal; width: 100%; }
.compare-table.vertical th, .compare-table.vertical td { padding: 6px 6px; }
.compare-table.vertical thead th { vertical-align: bottom; min-width: 86px; background: var(--panel); }
.compare-table.vertical thead th.site-head { cursor: pointer; border-top: 3px solid var(--line); }
.compare-table.vertical thead th.site-head.active { color: var(--accent); }
.compare-table.vertical tbody th { color: var(--muted); font-weight: 500; text-align: left; white-space: nowrap; }
.compare-table.vertical tbody tr { cursor: default; background: none; }
.compare-table.vertical tbody tr:nth-child(odd) { background: rgba(22, 29, 45, .5); }
.compare-table.vertical tbody tr:hover { background: rgba(90, 90, 90, .5); }
.compare-table.vertical td.active-col { background: rgba(124, 196, 255, .08); }

@media (max-width: 700px) {
  #panel-toggle { left: auto; right: 12px; top: -30px; height: 28px; width: 40px; border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: 0; transform: rotate(0); }
  body.panel-collapsed #panel { transform: translateY(100%); }
  body.panel-collapsed #globe { bottom: 0; }
  .btn-row { grid-template-columns: 1fr; }
}

/* ===== Intro screen ===== */
#intro {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; cursor: pointer; outline: none;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, .65) 100%);
  transition: opacity .7s ease;
}
#intro.leaving { opacity: 0; pointer-events: none; }
#intro[hidden] { display: none; }
.intro-title {
  margin: 0; font-size: clamp(56px, 12vw, 140px); font-weight: 200; letter-spacing: .32em;
  padding-left: .32em;                      /* balance the letter-spacing on the right */
  color: #f2f4fa; text-shadow: 0 0 40px rgba(180, 200, 255, .35);
  opacity: 0; filter: blur(12px); animation: intro-title 3.2s ease-out .4s forwards;
}
.intro-sub {
  margin: 0; font-size: 15px; letter-spacing: .25em; text-transform: uppercase; color: #dfe5f2;
  text-shadow: 0 0 12px rgba(0, 0, 0, .9);
  opacity: 0; animation: intro-sub 1.2s ease 3.2s forwards, intro-pulse 2.4s ease-in-out 4.4s infinite;
}
@keyframes intro-title { to { opacity: 1; filter: blur(0); } }
@keyframes intro-sub { to { opacity: 1; } }
@keyframes intro-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ===== Before the requirements are entered: only the Moon (and the forms) show ===== */
#left-col, #legend, #panel { transition: opacity 1s ease, transform .2s ease; }
body.intro-mode #left-col, body.intro-mode #legend, body.intro-mode #panel {
  opacity: 0; pointer-events: none;
}
#landing {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .15) 20%, rgba(0, 0, 0, .7) 100%);
  animation: landing-in .6s ease;
}
@keyframes landing-in { from { opacity: 0; } to { opacity: 1; } }
.landing-card { background: rgba(14, 14, 14, .74); backdrop-filter: blur(10px); }

/* ===== Start screen: two big choices ===== */
#choice {
  position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .1) 20%, rgba(0, 0, 0, .7) 100%);
  animation: landing-in .6s ease;
}
.choice-wrap { width: min(720px, 100%); text-align: center; }
.choice-wrap h2 {
  margin: 0 0 22px; font-weight: 300; font-size: clamp(22px, 4vw, 32px); letter-spacing: .04em;
  color: #f2f4fa; text-shadow: 0 0 18px rgba(0, 0, 0, .9);
}
.choice-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.choice-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0; padding: 26px 22px;
  background: rgba(14, 14, 14, .74); backdrop-filter: blur(10px); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; font-weight: 400; font-size: 14px; line-height: 1.4;
  transition: border-color .15s, transform .15s, background .15s;
}
.choice-card b { font-size: 19px; font-weight: 600; color: #fff; }
.choice-card span:last-child { color: var(--muted); }
.choice-card:hover, .choice-card:focus-visible {
  border-color: var(--accent); background: rgba(30, 30, 30, .85); transform: translateY(-2px); outline: none;
}
@media (max-width: 560px) { .choice-buttons { grid-template-columns: 1fr; } }
.landing-links { display: flex; justify-content: space-between; gap: 12px; }

/* ===== More translucent menus (the Moon shows through) ===== */
#globe { inset: 0 !important; }            /* full screen, behind the panel too */
#panel { background: rgba(14, 14, 14, .6); backdrop-filter: blur(8px); border-left-color: rgba(90, 90, 90, .6); }
#panel-toggle { background: rgba(14, 14, 14, .6); backdrop-filter: blur(8px); }
.overlay { background: rgba(14, 14, 14, .5); backdrop-filter: blur(6px); border-color: rgba(90, 90, 90, .6); }
.tile, .sky-now, .region-list li, select, input, .site-list li:hover { background: rgba(22, 29, 45, .55); }
.compare-table.vertical thead th { background: rgba(14, 14, 14, .6); }
#v3d-hud { background: rgba(14, 14, 14, .6); backdrop-filter: blur(6px); }
#panel { z-index: 5; }                      /* above the globe's Sun/Earth marker layer */
#left-col, #legend { z-index: 4; }

.region-list .stats .ice-ok { color: rgb(140, 210, 255); }

/* ===== Grand type for the opening screens (Cinzel: classical Roman capitals) ===== */
:root {
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --display-sub: 'Cormorant Garamond', Georgia, serif;
}
.intro-title {
  font-family: var(--display); font-weight: 400; letter-spacing: .28em; padding-left: .28em;
  font-size: clamp(54px, 11vw, 136px);
  text-shadow: 0 0 50px rgba(190, 210, 255, .35), 0 2px 18px rgba(0, 0, 0, .8);
}
.intro-sub { font-family: var(--display); font-size: 14px; letter-spacing: .42em; }
.choice-wrap h2 {
  font-family: var(--display); font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
  font-size: clamp(20px, 3.4vw, 30px);
}
.choice-card b { font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: .08em; }
.choice-card span:last-child { font-family: var(--display-sub); font-size: 17px; line-height: 1.35; }
.landing-card h1 {
  font-family: var(--display); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  font-size: clamp(20px, 3.2vw, 27px); margin-bottom: 8px;
}
.landing-card > p.muted:first-of-type { font-family: var(--display-sub); font-size: 17px; line-height: 1.4; }
.landing-card button[type=submit] { font-family: var(--display); letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
/* Title emerges as the light reaches the Moon (shadow reveal in web/app.js, ~5.6 s) */
.intro-title { animation: none; opacity: 0; }    /* faded in by the shadow reveal (web/app.js), in sync with the light */
.intro-sub { animation: intro-sub 1.2s ease 5.4s forwards, intro-pulse 2.4s ease-in-out 6.6s infinite; }

/* ===== Opening screens: the Earth on the left, the Moon shifted right ===== */
#intro-earth {
  position: fixed; z-index: 15; pointer-events: none;
  /* Seen from the Moon, Earth is about 2° across (~4 % of this view). It is drawn larger for
     artistic effect, but stays still, far behind the Moon (no parallax). */
  left: 14vw; top: 32%; width: max(14vmin, 70px); aspect-ratio: 1; transform: translate(-50%, -50%);
  opacity: 1; transition: opacity 1.1s ease;
}
#intro-earth canvas { width: 100%; height: 100%; display: block; }
body:not(.intro-mode) #intro-earth { opacity: 0; }
/* The globe canvas is 38vw wider than the screen while it's shifted right, so the starfield
   still reaches the left edge; it returns to normal size after the zoom-out (revealApp). */
#globe { transition: transform 1.6s cubic-bezier(.4, 0, .2, 1); }
body.globe-wide #globe { left: -19vw !important; right: -19vw !important; }
body.intro-mode #globe { transform: translateX(19vw); }
@media (max-width: 760px) {
  #intro-earth { left: 16vw; top: 15%; width: max(16vmin, 56px); }
}

/* ===== 3D view: site plan panel (solar array, comms hub, routes, ice) ===== */
#v3d-plan {
  position: absolute; top: 64px; right: 12px; z-index: 11; width: 310px; max-height: calc(100% - 200px); overflow-y: auto;
  background: rgba(14, 14, 14, .88); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.5;
}
#v3d-plan h3 { margin: 0 0 6px; font-size: 14px; }
#v3d-plan .row { margin: 6px 0; }
#v3d-plan .row b { color: #fff; }
#v3d-plan .k-solar { color: #ffd23f; } #v3d-plan .k-comms { color: #c39bff; }
#v3d-plan .k-route { color: #fff; } #v3d-plan .k-ice { color: #7fd0ff; }
#v3d-plan .rough { color: var(--warn); }
@media (max-width: 700px) { #v3d-plan { top: auto; bottom: 120px; left: 12px; width: auto; max-height: 40vh; } }

/* ===== Monochrome frosted glass: black / grey / white menus (colour only on data and status) ===== */
#panel, #panel-toggle { background: rgba(14, 14, 14, .55); backdrop-filter: blur(16px) saturate(110%); -webkit-backdrop-filter: blur(16px) saturate(110%); }
.overlay, #v3d-hud, #v3d-plan, .landing-card, .choice-card {
  background: rgba(14, 14, 14, .5); backdrop-filter: blur(16px) saturate(110%); -webkit-backdrop-filter: blur(16px) saturate(110%);
  border-color: rgba(255, 255, 255, .12);
}
.choice-card:hover, .choice-card:focus-visible { background: rgba(40, 40, 40, .6); border-color: rgba(255, 255, 255, .6); }
#panel { border-left-color: rgba(255, 255, 255, .1); }
.v3d-top, .v3d-bottom { background: rgba(14, 14, 14, .72); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
select, input { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.tile, .sky-now, .region-list li, .compare li { background: rgba(255, 255, 255, .05); }
.region-list li:hover { border-color: rgba(255, 255, 255, .5); }
button.secondary { background: transparent; color: #f2f2f2; border-color: rgba(255, 255, 255, .45); }
.chip { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .16); }
.chip.on { background: #f2f2f2; color: #0a0a0a; border-color: #f2f2f2; }

/* ===== Stat tiles filled by viability (fill = --fill, colour = rating) ===== */
.tile { --tile-c: rgba(255, 255, 255, .08); position: relative; cursor: help;
  background: linear-gradient(to right, var(--tile-c) var(--fill, 0%), rgba(255, 255, 255, .04) var(--fill, 0%)) !important; }
.tile.good { --tile-c: rgba(76, 209, 138, .32); }
.tile.warn { --tile-c: rgba(255, 204, 77, .30); }
.tile.bad  { --tile-c: rgba(255, 107, 107, .30); }
.tile:focus-visible { outline: 1px solid rgba(255, 255, 255, .6); }
.info-i {
  display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%; margin-left: 3px;
  border: 1px solid rgba(255, 255, 255, .45); color: rgba(255, 255, 255, .75);
  font: italic 600 9px/1 Georgia, serif; vertical-align: 1px; cursor: help;
}
/* ===== Floating explanation tooltip ([data-tip] anywhere) ===== */
#tip {
  position: fixed; z-index: 100; max-width: 320px; padding: 9px 11px; pointer-events: none;
  background: rgba(10, 10, 10, .86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 8px; color: #ededed;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
#tip.on { opacity: 1; transform: none; }
#tip b { color: #fff; }

/* ===== Pole markers (globe): home-plate badge pointing at the pole ===== */
.pole-marker {
  pointer-events: none; transition: opacity .2s;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .8));
}
/* globe.gl centres the marker on the pole; shift the badge half its height so its tip is there */
.pole-marker.north .pole-badge { transform: translateY(-50%); }   /* badge above, tip down at the pole */
.pole-marker.south .pole-badge { transform: translateY(50%); }    /* badge below, tip up at the pole */
.pole-badge {
  --plate: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%);
  display: block; width: 26px; height: 32px; padding: 1.5px;
  background: rgba(255, 255, 255, .85); clip-path: var(--plate);     /* the white edge */
}
.pole-marker.south .pole-badge { --plate: polygon(50% 0, 100% 42%, 100% 100%, 0 100%, 0 42%); }
.pole-letter {
  display: grid; place-items: center; width: 100%; height: 100%; clip-path: var(--plate);
  background: rgba(12, 12, 12, .82); color: #f4f4f4;
  font-family: var(--display); font-size: 13px; font-weight: 600; line-height: 1;
  padding-bottom: 7px; box-sizing: border-box;
}
.pole-marker.south .pole-letter { padding: 7px 0 0; }

/* ===== Period stepping ===== */
.period-step { display: inline-flex; gap: 3px; margin-left: 4px; }
.period-step .chip { padding: 2px 6px; font-size: 11px; margin: 0; }

/* ===== Sky & horizon panel (web/skycharts.js) ===== */
.sky-panel { margin: 12px 0 4px; }
.sky-panel:empty { display: none; }
.sky-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sky-head .sky-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.sky-head .chip { margin: 0; padding: 2px 8px; font-size: 11px; }
.sky-slider { width: 100%; margin: 2px 0 4px; padding: 0; accent-color: #f2f2f2; }
.sky-readout { font-size: 12px; line-height: 1.55; margin-bottom: 6px; }
.sky-readout .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.sky-readout .ok { color: var(--pass); } .sky-readout .warn { color: var(--warn); }
.sky-cap { font-size: 11px; color: var(--text); margin: 6px 0 1px; }
.sky-svg { display: block; width: 100%; touch-action: none; cursor: ew-resize; overflow: visible; }
.sky-svg.pano { cursor: default; }
.sky-svg .ax { stroke: rgba(255, 255, 255, .35); }
.sky-svg .axt { fill: rgba(255, 255, 255, .6); font-size: 9.5px; font-family: system-ui, sans-serif; }
.sky-svg .axt.strong { fill: #fff; font-family: var(--display); font-weight: 600; font-size: 10.5px; }
.sky-svg .grid { stroke: rgba(255, 255, 255, .07); }
.sky-svg .grid0 { stroke: rgba(255, 255, 255, .3); stroke-dasharray: 2 3; }
.sky-svg .pano-sky { fill: rgba(255, 255, 255, .02); }
.sky-svg .pano-terrain { fill: rgba(150, 150, 150, .55); stroke: rgba(230, 230, 230, .8); stroke-width: 1; }
.sky-svg .pano-path { fill: none; stroke-width: 1.6; }
.sky-svg .dot-sun { fill: #ffd23f; stroke: #fff; stroke-width: 1; filter: drop-shadow(0 0 5px #ffd23f); }
.sky-svg .dot-earth { fill: #6fb6ff; stroke: #fff; stroke-width: 1; }
.sky-svg .hidden { fill: transparent; stroke-dasharray: 2 2; filter: none; }
.sky-svg .bar-bg { fill: rgba(255, 255, 255, .05); }
.sky-svg .cursor { stroke: #fff; stroke-width: 1; stroke-opacity: .8; }

#sky-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .55); }
#sky-modal[hidden] { display: none; }
.sky-modal-card {
  width: min(1500px, 100%); max-height: 100%; overflow-y: auto; padding: 14px 20px 18px;
  background: rgba(14, 14, 14, .72); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px;
}
.sky-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sky-modal-head .chip { margin: 0; }
#sky-panel-big .sky-readout { font-size: 13.5px; }
#sky-panel-big .sky-cap { font-size: 12px; }
#sky-panel-big .sky-svg .axt { font-size: 11px; }

/* ===== Insights: best dates, nearby ===== */
details.insight { margin: 10px 0; padding: 8px 10px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 8px; background: rgba(255, 255, 255, .03); }
details.insight > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details.insight .row3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 6px; margin-top: 8px; }
details.insight label { font-size: 11px; }
.date-strip { display: flex; gap: 1px; height: 30px; align-items: flex-end; margin: 8px 0 2px; cursor: pointer; }
.date-strip span { flex: 1; min-width: 1px; border-radius: 1px 1px 0 0; }
.date-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.date-picks { list-style: none; padding: 0; margin: 6px 0 0; }
.date-picks li { padding: 5px 6px; margin: 3px 0; border-radius: 6px; background: rgba(255, 255, 255, .05); cursor: pointer; }
.date-picks li:hover { background: rgba(255, 255, 255, .12); }
.nearby-grids { display: flex; gap: 10px; margin: 8px 0 4px; }
.nearby-grids figure { margin: 0; flex: 1; }
.nearby-grids figcaption { font-size: 11px; margin-bottom: 3px; }
.nearby-grid { display: grid; gap: 1px; aspect-ratio: 1; }
.nearby-grid span { border-radius: 2px; cursor: pointer; position: relative; }
.nearby-grid span.centre { outline: 2px solid #ff2bd6; outline-offset: -2px; }
.nearby-grid span.best { outline: 2px solid #fff; outline-offset: -2px; }

/* ===== Learn tab + start screen link ===== */
.learn-card { margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); }
.learn-card h3 { margin: 0 0 4px; font-family: var(--display); font-size: 14px; letter-spacing: .04em; }
.learn-card p { margin: 0; font-size: 12.5px; line-height: 1.55; color: #d8d8d8; }
#share-btn { display: block; margin: 8px 0 0; text-align: left; padding: 0; color: #e8e8e8; }
.tabs .tab { padding-left: 6px; padding-right: 6px; }

/* ===== Why this site was recommended ===== */
.why-box p { margin: 6px 0 4px; font-size: 12.5px; }
.why-box ul { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.5; color: #d8d8d8; }

/* ===== Full view: the charts as a dashboard ===== */
.sky-panel.large {
  display: grid; gap: 14px 22px; align-items: start;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  grid-template-areas:
    "head   head"
    "slider slider"
    "pano   readout"
    "elev   power"
    "elev   bars";
}
.sky-panel.large .sky-block { min-width: 0; padding: 10px 12px; border-radius: 10px;
  background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .08); }
.sky-panel.large .sky-head { margin: 0; font-size: 15px; }
.sky-panel.large .sky-time .sky-slider { margin: 0; }
.sky-panel.large .sky-readout { font-size: 14px; line-height: 1.75; }
.sky-panel.large .sky-cap { font-size: 12.5px; margin: 0 0 4px; }
.sky-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: #cfcfcf; }
.sky-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.sky-legend i.terr { background: rgba(150, 150, 150, .55); border-top: 1px solid #e6e6e6; }
@media (max-width: 900px) {
  .sky-panel.large { grid-template-columns: 1fr; grid-template-areas: "head" "slider" "readout" "pano" "elev" "bars" "power"; }
}
.sky-svg.pano { cursor: zoom-in; }
.sky-panel.large .sky-svg.pano { cursor: default; }
.sky-svg.pano { overflow: hidden; }   /* paths below the panorama's range stay inside it */

/* ===== Search results: header row, "Why this site?" link ===== */
.region-list li .r-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.region-list li .r-title { min-width: 0; overflow-wrap: anywhere; }
.region-list .add { position: static; flex: none; }
.why-link {
  display: inline-block; width: auto; margin: 6px 0 0; padding: 0; background: none; border: 0;
  color: #f2f2f2; font-size: 12px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.why-link::after { content: " ›"; text-decoration: none; }
.why-link[aria-expanded="true"]::after { content: " ‹"; }
.why-link:hover { color: #fff; }
.why-text { margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, .06); font-size: 12px; cursor: default; }
.why-text p { margin: 0 0 4px; }
.why-text ul { margin: 0; padding-left: 18px; line-height: 1.5; color: #d8d8d8; }

/* ===== Clear pop-out control for the charts ===== */
.expand-btn, .expand-line {
  display: inline-flex; align-items: center; gap: 6px; width: auto; margin: 0; cursor: pointer;
  background: #f2f2f2; color: #0a0a0a; border: 0; border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600;
}
.expand-btn svg, .expand-line svg { width: 13px; height: 13px; }
.expand-btn:hover, .expand-line:hover { background: #fff; }
.expand-line {
  display: flex; justify-content: center; width: 100%; margin-top: 10px; padding: 7px 10px;
  background: transparent; color: #f2f2f2; border: 1px dashed rgba(255, 255, 255, .4); border-radius: 8px;
}
.expand-line:hover { background: rgba(255, 255, 255, .08); border-style: solid; }

/* ===== Learning in explore mode ===== */
.learn-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.learn-tools .chip { margin: 0; }
.learn-tab-tools { margin: 10px 0 4px; }
#learnbox { margin-top: 8px; width: min(300px, calc(100vw - var(--panel-w) - 24px)); }
#learnbox .timelapse { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#tl-slider { flex: 1 1 100%; margin: 2px 0 0; padding: 0; accent-color: #f2f2f2; }
#tl-date { flex-basis: 100%; line-height: 1.45; }
body.intro-mode #learnbox { opacity: 0; pointer-events: none; }

#tour {
  position: fixed; z-index: 30; bottom: 20px; left: calc((100% - var(--panel-w)) / 2); transform: translateX(-50%);
  width: min(460px, calc(100vw - var(--panel-w) - 32px)); padding: 14px 16px 12px;
  background: rgba(12, 12, 12, .72); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
#tour[hidden] { display: none; }
#tour .tour-step { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
#tour .tour-title { margin: 4px 0 6px; font-family: var(--display); font-size: 19px; letter-spacing: .04em; }
#tour .tour-text { margin: 0 0 8px; font-size: 13.5px; line-height: 1.55; }
#tour .tour-look { margin: 0 0 10px; font-size: 12.5px; color: #d6d6d6; padding: 6px 9px; border-left: 2px solid #ff2bd6; background: rgba(255, 255, 255, .04); }
#tour .tour-nav { display: flex; gap: 6px; }
#tour .tour-nav .chip { margin: 0; }
#tour #tour-exit { margin-left: auto; }
@media (max-width: 700px) {
  #tour { top: 12px; bottom: auto; left: 50%; width: calc(100vw - 24px); }
}

#versus-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .55); }
#versus-modal[hidden] { display: none; }
.versus-summary { margin: 4px 0 10px; line-height: 1.55; color: #e2e2e2; }
.versus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.versus-col { min-width: 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .08); }
.versus-name { margin: 0 0 4px; font-family: var(--display); font-size: 16px; letter-spacing: .04em; }
.versus-facts { font-size: 12.5px; line-height: 1.6; color: #d8d8d8; }
@media (max-width: 800px) { .versus-grid { grid-template-columns: 1fr; } }

/* The tour card and the colour legend share the bottom of the screen: hide the legend during the tour */
#legend { transition: opacity .3s ease; }
body.touring #legend { opacity: 0; pointer-events: none; }

/* ===== Modes: Explore-only items (guided tour, Learn tab) ===== */
body:not(.mode-explore) .explore-only { display: none !important; }
.mode-line { margin: -2px 0 6px; }
.mode-line .linklike { display: inline; width: auto; margin: 0; padding: 0; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; color: #e8e8e8; }

/* Start screen: who each mode is for */
.choice-card .choice-for {
  font-family: var(--display); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase;
  color: #e6e6e6; opacity: .85; margin-top: -2px;
}

/* Title wipe, in step with the shadow sweeping off the Moon (--wipe is set by the reveal) */
.intro-title {
  --wipe: -12%;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--wipe) - 10%), transparent calc(var(--wipe) + 10%));
          mask-image: linear-gradient(90deg, #000 calc(var(--wipe) - 10%), transparent calc(var(--wipe) + 10%));
}
