:root {
  --void: #03040a;
  --text: #eef1fb;
  --soft: #aab1c8;
  --line: rgba(220, 230, 255, 0.16);
  --ember: #ff7a3d;
  --magenta: #ff4fa8;
  --violet: #a878ff;
  --teal: #2fe0cf;
  --spectrum: linear-gradient(90deg, var(--ember), var(--magenta) 35%, var(--violet) 65%, var(--teal));
  --display: 'Unbounded', system-ui, sans-serif;
  --sans: 'Sora', system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--void); color: var(--text);
  font-family: var(--sans); font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 1px solid var(--teal); outline-offset: 4px; }

#space { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.labels { position: fixed !important; inset: 0; pointer-events: none; }

/* ---------- veil + flash ---------- */
#veil {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--void);
  font-size: 0.72rem; letter-spacing: 0.4em; text-transform: uppercase; color: var(--soft);
  transition: opacity 1.8s ease;
}
#veil span { animation: breathe 2.2s ease-in-out infinite; }
body.ready #veil { opacity: 0; pointer-events: none; }
@keyframes breathe { 50% { opacity: 0.35; } }

#flash {
  position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95), rgba(140, 220, 255, 0.4) 30%, rgba(168, 120, 255, 0.15) 55%, rgba(0,0,0,0) 75%);
  mix-blend-mode: screen;
}

/* ---------- wordmark ---------- */
.wordmark {
  margin: 0;
  font-family: var(--display); font-weight: 300; letter-spacing: 0.34em;
  background: var(--spectrum);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- threshold ---------- */
#threshold { position: fixed; inset: 0; z-index: 5; overflow: hidden; will-change: transform, opacity; }
#threshold[hidden] { display: none; }
#t-stage { position: absolute; left: 0; top: 0; will-change: transform; }
#t-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
#threshold::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(3,4,10,.72), rgba(3,4,10,.15) 30%, rgba(3,4,10,0) 60%, rgba(3,4,10,.45));
}
/* painted planets come alive: a halo that pulses in each planet's color, and the planet itself breathing */
.t-aura {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle closest-side, rgba(0,0,0,0) 62%, var(--c) 72%, rgba(0,0,0,0) 100%);
  mix-blend-mode: screen; opacity: 0.2;
  animation: aura var(--dur) ease-in-out var(--delay) infinite alternate;
  transition: opacity 0.6s ease;
}
.t-aura.hot { animation-play-state: paused; opacity: 0.95; }
@keyframes aura {
  from { opacity: 0.12; transform: scale(0.97); }
  to { opacity: 0.6; transform: scale(1.07); }
}
.t-orb {
  position: absolute; border-radius: 50%; overflow: hidden; pointer-events: none;
  -webkit-mask: radial-gradient(circle, #000 84%, transparent 100%);
  mask: radial-gradient(circle, #000 84%, transparent 100%);
  transition: filter 0.6s ease;
}
.t-orb img {
  position: absolute; max-width: none; display: block; user-select: none;
  animation: breathe-orb var(--dur) ease-in-out var(--delay) infinite alternate;
}
.t-orb.hot { filter: brightness(1.18) saturate(1.15); }
@keyframes breathe-orb {
  from { transform: scale(1) rotate(0deg); filter: brightness(1); }
  to { transform: scale(1.045) rotate(var(--turn)); filter: brightness(1.12); }
}
.t-sky { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.t-spot { position: absolute; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.t-spot::before {
  content: ''; position: absolute; inset: -4%; border-radius: 50%; opacity: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55), 0 0 60px 8px rgba(140, 220, 255, 0.35), inset 0 0 60px rgba(168, 120, 255, 0.35);
  transition: opacity 0.6s ease, transform 0.8s var(--ease);
}
.t-spot:hover::before, .t-spot:focus-visible::before { opacity: 1; transform: scale(1.03); }
.t-spot:focus-visible { outline: none; }

.t-copy {
  position: absolute; left: 0; right: 0; top: max(5vh, 24px); z-index: 2;
  padding: 0 16px; text-align: center; pointer-events: none;
}
.t-copy > * { pointer-events: auto; opacity: 0; transform: translateY(12px); transition: opacity 1.6s ease, transform 1.8s var(--ease); }
body.ready .t-copy > * { opacity: 1; transform: none; }
body.ready .t-copy > :nth-child(2) { transition-delay: 0.5s; }
body.ready .t-copy > :nth-child(3) { transition-delay: 1s; }
.t-copy .wordmark { font-size: clamp(1.7rem, 4.6vw, 3.6rem); padding-left: 0.34em; filter: drop-shadow(0 2px 18px rgba(0,0,0,.7)); }
.t-line { margin: 0.7rem 0 1.4rem; font-size: clamp(0.95rem, 1.6vw, 1.15rem); letter-spacing: 0.08em; color: var(--text); text-shadow: 0 1px 14px #000; }
#step-in, .pill, #c-cta {
  position: relative; border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(6, 8, 18, 0.55); backdrop-filter: blur(8px);
  text-transform: uppercase;
}
#step-in::before, .pill::before, #c-cta::before { /* spectrum hairline border */
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--spectrum);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
#step-in { padding: 0.95rem 2.6rem; font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.34em; transition: box-shadow 0.6s, background 0.6s; }
#step-in:hover { background: rgba(20, 16, 40, 0.7); box-shadow: 0 0 40px rgba(168, 120, 255, 0.45), 0 0 80px rgba(47, 224, 207, 0.2); }
body.entering .t-copy { opacity: 0; transition: opacity 0.5s; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 20px 16px;
  pointer-events: none; opacity: 0; transition: opacity 1.2s ease;
}
body.in-system .hud { opacity: 1; }
body.in-system .hud > * { pointer-events: auto; }
.wordmark-sm { border: 0; padding: 0; cursor: pointer; font-size: 0.78rem; letter-spacing: 0.42em; background-color: transparent; }
.pill { padding: 0.45rem 1rem; font-size: 0.62rem; letter-spacing: 0.24em; color: var(--soft); }
.pill:hover { color: var(--text); }

#hint {
  position: fixed; left: 0; right: 0; bottom: max(3.5vh, 16px); z-index: 4;
  margin: 0; padding: 0 16px; text-align: center; pointer-events: none;
  font-size: 0.78rem; letter-spacing: 0.16em; color: var(--soft);
  opacity: 0; transition: opacity 1.2s ease;
}
body.in-system:not(.focused) #hint { opacity: 1; }

/* ---------- planet labels ---------- */
.label {
  --accent: #fff;
  background: none; border: 0; padding: 6px 10px; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.9s ease;
}
body.in-system:not(.focused) .label { opacity: 1; pointer-events: auto; }
.label-inner { display: flex; flex-direction: column; align-items: center; gap: 3px; transition: transform 0.5s var(--ease); }
.l-name {
  font-family: var(--display); font-weight: 400; font-size: 0.7rem; letter-spacing: 0.24em; text-transform: uppercase; white-space: nowrap;
  color: var(--text); text-shadow: 0 0 12px #000, 0 0 3px #000;
}
.l-tag { font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase; white-space: nowrap; color: var(--accent); text-shadow: 0 0 10px #000; }
.label.is-sealed .l-name { color: var(--soft); }
.label.is-sealed .l-tag { opacity: 0.7; }
.label.hot .label-inner { transform: scale(1.1); }
.label.hot .l-name { color: #fff; text-shadow: 0 0 14px var(--accent), 0 0 3px #000; }
.label-you .l-name { font-size: 0.82rem; }

/* ---------- realm card ---------- */
#card {
  --accent: #fff;
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 12;
  width: min(470px, 100%);
  padding: clamp(24px, 6vh, 60px) 40px;
  display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(90deg, rgba(3,4,10,0), rgba(3,4,10,.72) 20%, rgba(3,4,10,.92));
  opacity: 0; transform: translateX(40px); pointer-events: none;
  transition: opacity 0.9s ease, transform 1.1s var(--ease);
}
#card.open { opacity: 1; transform: none; pointer-events: auto; }
#c-back {
  align-self: flex-start; margin-bottom: 1.8rem; padding: 0.3rem 0;
  border: 0; background: none; cursor: pointer;
  font-size: 0.66rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--soft);
}
#c-back:hover { color: var(--text); }
#c-eyebrow { margin: 0 0 0.7rem; font-size: 0.64rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent); }
#c-title {
  margin: 0; font-family: var(--display); font-weight: 300; text-transform: uppercase;
  font-size: clamp(1.5rem, 3vw, 2.2rem); letter-spacing: 0.12em; line-height: 1.15;
}
#c-title::after { content: ''; display: block; width: 44px; height: 2px; margin-top: 1rem; border-radius: 2px; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
#c-line { margin: 1.1rem 0 0.6rem; font-size: 1.12rem; font-weight: 400; line-height: 1.45; color: #fff; }
#c-body { margin: 0; font-size: 0.92rem; line-height: 1.75; color: #c9cfdf; }
#c-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1.4rem; }
#c-chips[hidden] { display: none; }
.chip {
  padding: 0.5rem 0.95rem; border-radius: 999px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-size: 0.7rem; letter-spacing: 0.12em; color: #fff;
  transition: background 0.4s, box-shadow 0.5s;
}
.chip:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 45%, transparent); }
#c-cta {
  align-self: flex-start; margin-top: 1.6rem; padding: 0.85rem 1.7rem;
  font-family: var(--display); font-size: 0.62rem; letter-spacing: 0.24em; color: #fff;
  transition: box-shadow 0.6s, background 0.6s;
}
#c-cta[hidden] { display: none; }
#c-cta::after { content: '  →'; }
#c-cta:hover { background: color-mix(in srgb, var(--accent) 22%, rgba(6,8,18,.6)); box-shadow: 0 0 34px color-mix(in srgb, var(--accent) 50%, transparent); }
.c-content { display: flex; flex-direction: column; }

#c-enter {
  align-self: flex-start; margin-top: 1.4rem; padding: 0.95rem 1.9rem;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #05060c;
  font-family: var(--display); font-size: 0.66rem; letter-spacing: 0.24em; text-transform: uppercase; font-weight: 500;
  box-shadow: 0 0 36px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: box-shadow 0.6s, transform 0.5s var(--ease);
}
#c-enter[hidden] { display: none; }
#c-enter::after { content: '  →'; }
#c-enter:hover { transform: translateY(-2px); box-shadow: 0 0 60px color-mix(in srgb, var(--accent) 75%, transparent); }

/* ---------- world surface ---------- */
#world-view { --accent: #fff; position: fixed; inset: 0; z-index: 9; overflow: hidden; background: var(--void); touch-action: none; cursor: grab; }
#world-view[hidden] { display: none; }
#world-view:active { cursor: grabbing; }
#w-stage { position: absolute; left: 0; top: 0; will-change: transform; }
#w-img, #w-sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
#w-sky { pointer-events: none; }
/* tall-only world on a wide screen: the scene stands as a portal, its own light spilling around it */
#w-backdrop { display: none; position: absolute; inset: -8%; background: var(--backdrop) center / cover no-repeat; filter: blur(46px) saturate(1.35) brightness(0.55); }
#world-view.portal { cursor: auto; }
#world-view.portal #w-backdrop { display: block; }
#world-view.portal #w-stage {
  -webkit-mask: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
  mask: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
}
#world-view::after { /* shade under the text so it stays readable on any world */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(3,4,10,.78), rgba(3,4,10,.35) 38%, rgba(3,4,10,0) 60%),
    linear-gradient(0deg, rgba(3,4,10,.55), rgba(3,4,10,0) 35%);
}
body.in-world .hud { z-index: 11; }
body.in-world #sound, body.in-world .wordmark-sm { pointer-events: auto; }
.w-panel {
  position: absolute; left: max(28px, 4vw); bottom: max(28px, 7vh); z-index: 2;
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - max(28px, 7vh) - 76px); /* never slide under the top bar */
  overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; cursor: auto;
}
.w-panel::-webkit-scrollbar { display: none; }
.w-panel > * { animation: rise 1.1s var(--ease) both; }
.w-panel > :nth-child(2) { animation-delay: 0.5s; }
.w-panel > :nth-child(3) { animation-delay: 0.65s; }
.w-panel > :nth-child(4) { animation-delay: 0.8s; }
.w-panel > :nth-child(5) { animation-delay: 0.95s; }
.w-panel > :nth-child(n+6) { animation-delay: 1.1s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
#w-back { align-self: flex-start; margin-bottom: 1.6rem; color: var(--text); }
#w-eyebrow { margin: 0 0 0.6rem; font-size: 0.66rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--accent); text-shadow: 0 1px 10px #000; }
#w-title {
  margin: 0; font-family: var(--display); font-weight: 300; text-transform: uppercase;
  font-size: clamp(2rem, 5.4vw, 4.2rem); letter-spacing: 0.1em; line-height: 1.05;
  text-shadow: 0 2px 30px rgba(0,0,0,.6), 0 0 40px color-mix(in srgb, var(--accent) 35%, transparent);
}
#w-personal {
  align-self: flex-start; margin: 1rem 0 0; padding: 0.45rem 0.95rem; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 22%, rgba(3,4,10,.55)); border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  backdrop-filter: blur(8px); font-size: 0.8rem; letter-spacing: 0.06em; color: #fff;
}
#w-personal[hidden] { display: none; }
.label.is-mine .l-tag { color: #ffc23a; }
#w-line { margin: 1rem 0 0.5rem; font-size: clamp(1.05rem, 1.8vw, 1.3rem); font-weight: 400; color: #fff; text-shadow: 0 1px 14px #000; }
#w-body { margin: 0; max-width: 34rem; font-size: 0.95rem; line-height: 1.75; color: #d7dcea; text-shadow: 0 1px 10px #000; }
#w-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1.4rem; }
#w-chips .chip { --accent: inherit; backdrop-filter: blur(8px); background: color-mix(in srgb, var(--accent) 14%, rgba(3,4,10,.5)); }
#w-chips .chip.on { background: var(--accent); color: #05060c; border-color: var(--accent); }
#w-detail {
  margin-top: 1rem; padding: 1.1rem 1.3rem; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: rgba(3, 4, 10, 0.62); backdrop-filter: blur(12px);
}
#w-detail[hidden] { display: none; }
#w-d-title { margin: 0; font-family: var(--display); font-weight: 300; font-size: 1rem; letter-spacing: 0.16em; text-transform: uppercase; }
#w-d-line { margin: 0.5rem 0 0.4rem; color: var(--accent); font-weight: 400; }
#w-d-body { margin: 0; font-size: 0.9rem; line-height: 1.7; color: #d7dcea; }
#w-cta {
  align-self: flex-start; margin-top: 1.5rem; padding: 0.95rem 1.9rem;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #05060c;
  font-family: var(--display); font-size: 0.66rem; letter-spacing: 0.24em; text-transform: uppercase; font-weight: 500;
  box-shadow: 0 0 36px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: box-shadow 0.6s, transform 0.5s var(--ease);
}
#w-cta[hidden] { display: none; }
#w-cta::after { content: '  →'; }
#w-cta:hover { transform: translateY(-2px); box-shadow: 0 0 60px color-mix(in srgb, var(--accent) 75%, transparent); }
@media (max-width: 760px) {
  #world-view::after { background: linear-gradient(0deg, rgba(3,4,10,.9), rgba(3,4,10,.55) 45%, rgba(3,4,10,0) 75%); }
  .w-panel { left: 16px; right: 16px; width: auto; bottom: max(16px, env(safe-area-inset-bottom)); max-height: min(70vh, calc(100% - 90px)); }
  #w-back { margin-bottom: 1rem; }
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: max(70px, calc(env(safe-area-inset-top) + 60px)); z-index: 20;
  max-width: calc(100% - 32px); padding: 0.7rem 1.2rem;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(6, 8, 18, 0.9);
  font-size: 0.85rem; letter-spacing: 0.04em; text-align: center;
  opacity: 0; transform: translate(-50%, -8px); pointer-events: none;
  transition: opacity 0.5s, transform 0.7s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; margin: 0; background: var(--void); }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .hud { padding-left: 16px; padding-right: 16px; }
  .l-name { font-size: 0.58rem; letter-spacing: 0.18em; }
  .l-tag { display: none; }
  #card {
    top: auto; height: auto; max-height: 58vh; overflow-y: auto; width: 100%;
    padding: 30px 16px calc(22px + env(safe-area-inset-bottom));
    justify-content: flex-start;
    background: linear-gradient(180deg, rgba(3,4,10,0), rgba(3,4,10,.9) 14%, rgba(3,4,10,.97));
    transform: translateY(40px);
    scrollbar-width: none;
  }
  #card::-webkit-scrollbar { display: none; }
  #c-back { margin-bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.3s !important; transition-delay: 0s !important; }
}
