:root {
  --bg: #02040a;
  --ink: #e2ebff;
  --dim: #8fa3c6;
  --faint: #5b6c8c;
  --accent: #6fd3ff;
  --warn: #ffb36b;
  --bad: #ff6b6b;
  --good: #6dffa0;
  --line: rgba(111, 211, 255, 0.35);
  --glass: rgba(6, 13, 28, 0.66);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); }
a { color: var(--accent); }

.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 10px;
}
h1 {
  font-weight: 200; font-size: clamp(30px, 4.4vw, 58px); letter-spacing: 0.14em; text-transform: uppercase;
  margin: 0; line-height: 1.05; text-shadow: 0 0 28px rgba(111, 211, 255, 0.35);
}
.sub { font-family: var(--mono); color: var(--dim); font-size: 13px; letter-spacing: 0.16em; margin: 12px 0 0; }

/* ---------- home: the 3D scene ---------- */
body.home { overflow: hidden; height: 100vh; height: 100dvh; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hud-title {
  position: fixed; top: clamp(18px, 5vh, 56px); left: clamp(16px, 4.5vw, 64px);
  pointer-events: none; max-width: calc(100vw - 32px);
}
.fleet { position: fixed; inset: 0; pointer-events: none; }
/* Which part of the Earth we orbit (view.js): one HUD line, label and choice on one
   baseline; the choice is a plain select without a box, underlined like a link. */
.view-pick {
  display: inline-flex; align-items: baseline; gap: 12px; margin: 0 0 16px;
  pointer-events: auto; font-family: var(--mono); font-size: 12px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--dim); max-width: 100%;
}
.view-pick[hidden], .no-webgl .view-pick { display: none; }
.view-lead { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.view-lead::before {   /* a live beacon */
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 8px var(--good); animation: beacon 2.4s ease-in-out infinite;
}
@keyframes beacon { 50% { opacity: 0.35; } }
.view-pick select {
  appearance: none; -webkit-appearance: none; cursor: pointer; min-width: 0;
  field-sizing: content;   /* as wide as the chosen name (older browsers: the longest) */
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--ink);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236fd3ff' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 0 center / 10px 6px;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 0 20px 3px 0; margin: 0; text-overflow: ellipsis;
  text-shadow: 0 0 14px rgba(111, 211, 255, 0.35);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.view-pick select:hover, .view-pick select:focus-visible { outline: none; color: #fff; border-bottom-color: var(--accent); }
.view-pick option { background: #050b18; color: var(--ink); text-transform: none; letter-spacing: normal; }
@media (max-width: 480px) { .view-pick { flex-wrap: wrap; row-gap: 6px; font-size: 11px; } }
@media (prefers-reduced-motion: reduce) { .view-lead::before { animation: none; } }
.credit {
  position: fixed; right: 12px; bottom: 8px; margin: 0; pointer-events: none;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--ink); opacity: 0.45;
  text-shadow: 0 0 4px #000;
}
.no-webgl .credit { display: none; }
/* The sound switch (bottom left; the credit is bottom right). */
.sound {
  position: fixed; left: 12px; bottom: 8px; display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dim); background: rgba(2, 6, 16, 0.55); border: 1px solid rgba(143, 163, 198, 0.3);
  border-radius: 3px; padding: 6px 10px 6px 8px; box-shadow: none; cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.sound[hidden] { display: none; }
.sound:hover, .sound:focus-visible { color: var(--ink); border-color: var(--accent); box-shadow: none; transform: none; }
.sound svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound .spk { fill: currentColor; stroke: none; }
.sound .waves { display: none; }
.sound[aria-pressed="true"] { color: var(--accent); }
.sound[aria-pressed="true"] .waves { display: inline; }
.sound[aria-pressed="true"] .mute { display: none; }
.no-webgl .sound { display: none; }
/* On, but the browser waits for a first click before the page may make sound. */
.sound.waiting { color: var(--ink); border-color: rgba(111, 211, 255, 0.6); animation: sound-wait 1.6s ease-in-out infinite; }
@keyframes sound-wait { 50% { border-color: rgba(111, 211, 255, 0.15); color: var(--dim); } }
/* Narrow screens: just the icon, so it keeps clear of the credit (screen readers still
   read the text). */
@media (max-width: 480px) {
  .sound { padding: 6px 8px; }
  .sound .txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.ship-label {
  position: absolute; left: 0; top: 0; transform: translate(-9999px, -9999px);
  pointer-events: auto; text-decoration: none; color: var(--ink); text-align: center;
  font-family: var(--mono); padding: 8px 16px 8px; white-space: nowrap;
  text-shadow: 0 0 3px #000, 0 0 8px #000, 0 0 16px rgba(0, 0, 0, 0.8);
  opacity: 0.72; transition: opacity 0.3s ease;
}
.ship-label::before {
  content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 5px;
  background: var(--line); transition: background 0.3s ease, height 0.3s ease;
}
.ship-label .name {
  display: block; font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase; padding-left: 0.3em;
  transition: font-size 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ship-label .desc {
  display: block; font-size: 11px; color: var(--dim); letter-spacing: 0.14em; margin-top: 4px;
  opacity: 0; transform: translateY(-4px); transition: opacity 0.3s ease, transform 0.3s ease;
}
.ship-label.active, .ship-label:focus-visible { opacity: 1; }
/* Hover: the name lights up as a red neon tube, with a short flicker as it switches on. */
.ship-label.active::before, .ship-label:focus-visible::before {
  background: #ff3a4e; height: 8px; box-shadow: 0 0 6px #ff2038, 0 0 14px #ff1030;
}
/* ...and grows by 75% (a font size, so the line below moves down with it). */
.ship-label.active .name, .ship-label:focus-visible .name {
  font-size: calc(13px * 1.75);
  color: #fff1f2;
  text-shadow: 0 0 1px #fff, 0 0 4px #ff4a5c, 0 0 9px #ff2a40, 0 0 18px #ff1832, 0 0 34px #ff0a28, 0 0 60px #ff0020;
  animation: neon-on 0.55s linear 1;
}
.ship-label.active .desc, .ship-label:focus-visible .desc {
  opacity: 1; transform: none; color: #ffc2c8; text-shadow: 0 0 6px rgba(255, 40, 64, 0.7), 0 0 2px #000;
}
@keyframes neon-on {
  0% { opacity: 0.25; } 8% { opacity: 1; } 16% { opacity: 0.35; } 26% { opacity: 1; }
  40% { opacity: 0.6; } 48% { opacity: 1; } 100% { opacity: 1; }
}
.ship-label:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.ship-label.gone { opacity: 0; }

/* Leaving for another page (main.js, launch): "<Name> loading…" while that page loads
   in a frame behind the scene; after the warp flash the frame takes over the window. */
.leaving {
  position: fixed; left: 0; right: 0; bottom: 14vh; margin: 0; text-align: center; pointer-events: none;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.32em; text-transform: uppercase; color: var(--ink);
  text-shadow: 0 0 4px #000, 0 0 12px #000;
}
.leaving .dots { animation: blink 1.1s steps(2, start) infinite; }
.next-page { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; z-index: -1; background: var(--bg); }
.next-page.shown { z-index: 20; }
.arrived .fade { z-index: 30; background: #d9f1ff; transition: opacity 0.6s ease-out; }
.arrived #scene, .arrived .fleet, .arrived .hud-title, .arrived .sound, .arrived .credit { visibility: hidden; }

.fade { display: none; }
.js .fade { display: block; position: fixed; inset: 0; background: #000; pointer-events: none; transition: opacity 1.8s ease; }
.ready .fade { opacity: 0; }
.warp .fade { opacity: 1; background: #d9f1ff; transition: opacity 0.3s ease-in; }

.no-webgl body.home {
  background:
    radial-gradient(140% 60% at 50% 125%, #2f7bff 0%, #0b2a6e 22%, rgba(2, 4, 10, 0) 45%),
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 70% 20%, #cfe, transparent),
    radial-gradient(1px 1px at 40% 60%, #fff, transparent),
    radial-gradient(1px 1px at 85% 55%, #fed, transparent),
    var(--bg);
}
.no-webgl #scene { display: none; }
.no-webgl .fleet {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 120px 16px 40px;
}
.no-webgl .ship-label {
  position: static; transform: none; opacity: 1; min-width: 240px;
  border: 1px solid var(--line); background: var(--glass); padding: 16px 20px;
}
.no-webgl .ship-label::before { display: none; }
.no-webgl .ship-label .desc { opacity: 1; transform: none; }

/* ---------- inner pages ---------- */
body.page { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
.starfield { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.horizon {
  position: fixed; left: -30vw; right: -30vw; bottom: -118vw; height: 130vw; border-radius: 50%; z-index: 0;
  background: radial-gradient(closest-side, #0b1a3a 92%, #2a6bff 98.5%, rgba(120, 190, 255, 0.9) 99.3%, rgba(40, 110, 255, 0) 100%);
  box-shadow: 0 -10px 80px rgba(60, 140, 255, 0.35);
  pointer-events: none;
}
.page main {
  position: relative; z-index: 1; width: min(720px, calc(100vw - 32px));
  margin: clamp(24px, 8vh, 96px) auto 160px; padding: clamp(22px, 4vw, 44px);
  background: var(--glass); border: 1px solid var(--line); border-radius: 4px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 60px rgba(30, 90, 200, 0.18);
}
.page main.wide { width: min(1040px, calc(100vw - 32px)); }
.back {
  display: inline-block; font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--dim); text-decoration: none; margin-bottom: 28px;
}
.back:hover, .back:focus-visible { color: var(--accent); }
.page h1 { font-size: clamp(28px, 4vw, 44px); }
.lead { color: var(--dim); line-height: 1.6; margin: 14px 0 28px; }

form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
label .opt { text-transform: none; letter-spacing: 0.05em; color: var(--faint); }
input, textarea {
  width: 100%; font: 16px/1.5 var(--sans); color: var(--ink); background: rgba(2, 6, 16, 0.75);
  border: 1px solid rgba(143, 163, 198, 0.3); border-radius: 3px; padding: 11px 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
textarea { min-height: 170px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 211, 255, 0.15); }
.field-error input, .field-error textarea { border-color: var(--bad); }
.field-msg { font-family: var(--sans); text-transform: none; letter-spacing: 0; color: var(--bad); font-size: 13px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

button, .btn {
  justify-self: start; font-family: var(--mono); font-size: 13px; letter-spacing: 0.24em; text-transform: uppercase;
  color: #02121c; background: var(--accent); border: 0; border-radius: 3px; padding: 13px 26px; cursor: pointer;
  box-shadow: 0 0 24px rgba(111, 211, 255, 0.35); transition: box-shadow 0.2s ease, transform 0.2s ease;
}
button:hover, button:focus-visible { box-shadow: 0 0 36px rgba(111, 211, 255, 0.7); transform: translateY(-1px); }
button.ghost { background: transparent; color: var(--dim); border: 1px solid rgba(143, 163, 198, 0.35); box-shadow: none; }
button.ghost:hover { color: var(--ink); border-color: var(--accent); }

.notice { border-left: 3px solid var(--accent); background: rgba(111, 211, 255, 0.08); padding: 14px 16px; margin: 0 0 24px; line-height: 1.55; }
.notice.good { border-color: var(--good); background: rgba(109, 255, 160, 0.08); }
.notice.warn { border-color: var(--warn); background: rgba(255, 179, 107, 0.08); }
.notice.bad { border-color: var(--bad); background: rgba(255, 107, 107, 0.08); }
code, .mono { font-family: var(--mono); }
.hash { display: block; word-break: break-all; background: rgba(2, 6, 16, 0.9); padding: 12px; margin-top: 10px; border: 1px solid var(--line); user-select: all; }

/* portal */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.topbar .back { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin: 26px 0 40px; }
.card {
  display: block; padding: 20px 18px; text-decoration: none; color: var(--ink);
  border: 1px solid rgba(143, 163, 198, 0.25); border-radius: 4px; background: rgba(2, 8, 20, 0.6);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
a.card:hover, a.card:focus-visible { border-color: var(--accent); box-shadow: 0 0 28px rgba(111, 211, 255, 0.25); transform: translateY(-2px); }
.card .t { display: block; font-family: var(--mono); letter-spacing: 0.22em; text-transform: uppercase; font-size: 14px; }
.card .n { display: block; color: var(--dim); font-size: 13px; margin-top: 8px; }
.card.off { opacity: 0.45; }
h2 { font-family: var(--mono); font-weight: 400; font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent); margin: 0; }
.inbox { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.inbox details { border: 1px solid rgba(143, 163, 198, 0.2); border-radius: 3px; background: rgba(2, 8, 20, 0.55); }
.inbox summary { cursor: pointer; padding: 12px 14px; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.inbox summary .when { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.inbox summary .who { color: var(--ink); }
.inbox summary .what { color: var(--dim); }
.inbox .body { padding: 0 14px 14px; white-space: pre-wrap; line-height: 1.55; color: var(--ink); }
.inbox .meta { padding: 0 14px 10px; font-family: var(--mono); font-size: 12px; color: var(--dim); }
.empty { color: var(--faint); font-family: var(--mono); font-size: 13px; margin-top: 14px; }

/* ---------- contact: a glass panel above Mars ---------- */
body.mars { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
.comms {
  position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; padding: 20px 16px 72px;
}
.comms .back { align-self: flex-start; margin: 0 0 4vh clamp(0px, 3vw, 40px); text-shadow: 0 0 6px #000; }
.glass {
  width: min(500px, 100%); margin-top: clamp(0px, 4vh, 60px);
  padding: clamp(22px, 3.6vw, 36px);
  background: rgba(14, 18, 34, 0.32); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 16px;
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.glass .eyebrow { color: #f2c29b; letter-spacing: 0.26em; font-size: 11px; }
.glass h1 { font-size: clamp(26px, 3.4vw, 38px); text-shadow: 0 0 24px rgba(255, 170, 120, 0.3); margin-bottom: 22px; }
.glass form { gap: 16px; }
.glass .field { display: grid; gap: 7px; }
.glass label { color: #d9c6b8; font-size: 11px; }
.glass input, .glass textarea {
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 9px;
  color: #fff8f2;
}
.glass textarea { min-height: 140px; }
.glass input:focus, .glass textarea:focus { border-color: #f2c29b; box-shadow: 0 0 0 3px rgba(242, 194, 155, 0.18); }
.glass [aria-invalid="true"] { border-color: var(--bad); }
.glass button {
  justify-self: end; background: #f6e9dc; color: #2a160a; border-radius: 9px; padding: 12px 30px;
  box-shadow: 0 0 22px rgba(255, 190, 140, 0.3);
}
.glass button:hover, .glass button:focus-visible { box-shadow: 0 0 34px rgba(255, 190, 140, 0.6); }
.glass button:disabled { opacity: 0.7; cursor: progress; transform: none; }
.glass .notice { border-radius: 0 8px 8px 0; }
.no-webgl body.mars {
  background: radial-gradient(150% 70% at 50% 130%, #b5653a 0%, #5a2a16 25%, rgba(2, 4, 10, 0) 48%), var(--bg);
}

/* ---------- inner pages with a 3D background (the portal: Saturn) ---------- */
.scene-page main {
  background: rgba(12, 14, 26, 0.34); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 16px;
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  margin-top: clamp(16px, 6vh, 72px);
}
.scene-page .eyebrow { color: #f0d9a8; }
.scene-page h1 { text-shadow: 0 0 24px rgba(255, 220, 160, 0.3); }
.scene-page input, .scene-page textarea { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.16); border-radius: 9px; }
.scene-page .card { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.14); border-radius: 12px; }
/* While the scene loads: only "Portal loading…"; then everything at once. Without
   JavaScript (no "js" class) or without WebGL the page shows straight away. */
.scene-loader { display: none; }
.js .loads-scene .scene-loader {
  display: flex; position: fixed; inset: 0; z-index: 2; align-items: center; justify-content: center; margin: 0;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.32em; text-transform: uppercase; color: #f0d9a8;
}
.loads-scene .scene-loader .dots { animation: blink 1.1s steps(2, start) infinite; }
.js .loads-scene #scene, .js .loads-scene main, .js .loads-scene .credit { visibility: hidden; }
.scene-loaded .loads-scene #scene, .scene-loaded .loads-scene main, .scene-loaded .loads-scene .credit,
.no-webgl .loads-scene main, .no-webgl .loads-scene .credit { visibility: visible; }
.scene-loaded .loads-scene .scene-loader, .no-webgl .loads-scene .scene-loader { display: none; }
.no-webgl body.scene-page {
  background: radial-gradient(160% 60% at 50% 120%, #9a7a4a 0%, #3b2c18 22%, rgba(2, 4, 10, 0) 46%), var(--bg);
}

/* coming soon */
.signal { font-family: var(--mono); color: var(--dim); letter-spacing: 0.1em; line-height: 1.8; }
.blink { animation: blink 1.4s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .js .fade { transition: none; }
  .ship-label.active .name { animation: none; }
  .ship-label .name { transition: none; }
  .blink, .sound.waiting { animation: none; }
}
