* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#sky:active { cursor: grabbing; }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.42) 100%);
  z-index: 5;
}

/* --- POI markers (positioned from JS, hit-testing happens in JS) --- */
#markers {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}
/* zero-size anchor at the projected position; ring and label center on it
   independently, so the label length cannot shift the ring */
.poi {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 0.4s;
}
.poi .ring {
  position: absolute;
  left: -15px;
  top: -15px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(150,185,255,0.28), inset 0 0 9px rgba(150,185,255,0.16);
}
/* enjoy mode: while a card is open, other highlight markers step back;
   planet/moon labels (.body) stay — they belong to the object in focus */
body.card-open .poi:not(.body) {
  opacity: 0 !important;
  pointer-events: none;
}
.poi.field .ring {
  left: -21px;
  top: -21px;
  width: 42px;
  height: 42px;
  border-style: dashed;
  border-color: rgba(170,200,255,0.55);
  box-shadow: none;
}
.poi.field .label { top: 26px; }
.poi .label {
  position: absolute;
  top: 20px;
  left: 0;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.09em;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 1px 10px #000, 0 0 4px #000;
  white-space: nowrap;
  transition: opacity 0.3s;
}
.poi.nolabel .label { opacity: 0; }
.poi.seen .ring {
  border-color: rgba(255,255,255,0.26);
  box-shadow: none;
}
.poi.seen .label { color: rgba(255,255,255,0.55); }

/* --- boot / intro --- */
#boot {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 45;
  pointer-events: none;
  transition: opacity 1.4s ease;
}
#intro {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 46;
  pointer-events: none;
}
#intro-title {
  font-size: clamp(30px, 6.5vw, 56px);
  font-weight: 100;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  opacity: 0;
  transition: opacity 1.8s ease, letter-spacing 4s ease;
}
#intro.show #intro-title { opacity: 1; letter-spacing: 0.62em; }
#intro-sub {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.55);
  opacity: 0;
  transition: opacity 1.8s ease 0.5s;
}
#intro.show #intro-sub { opacity: 1; }
#intro.quick #intro-title { transition: opacity 0.9s ease, letter-spacing 2.4s ease; }
#intro.quick #intro-sub { transition: opacity 0.9s ease 0.25s; }
#intro.hide #intro-title, #intro.hide #intro-sub {
  opacity: 0;
  transition: opacity 2.2s ease;
}

#hint {
  position: fixed;
  bottom: calc(108px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12.5px;
  font-weight: 300;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.65);
  text-shadow: 0 1px 8px #000;
  opacity: 0;
  transition: opacity 1s;
  pointer-events: none;
  z-index: 20;
  max-width: min(78vw, 380px);
  text-align: center;
  line-height: 1.5;
}
#hint.show { opacity: 1; }
#hint.high { bottom: calc(300px + env(safe-area-inset-bottom)); }

#compass {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
#compass.show { opacity: 1; pointer-events: auto; }
#compass::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: -3px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 6px solid rgba(255,130,105,0.9);
}

/* --- tour buttons, bottom center --- */
#tours {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s;
}
#tours.show { opacity: 1; pointer-events: auto; }
#tours { gap: 0; }
#discover, #cat {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255,255,255,0.34);
  background: rgba(24,30,54,0.6);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: rgba(255,255,255,0.95);
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0.07em;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(140,170,255,0.2);
  transition: background 0.25s, transform 0.15s;
}
#cat {
  gap: 6px;
  padding: 0 13px 0 16px;
  border-radius: 23px 0 0 23px;
  border-right: none;
  color: rgba(255,255,255,0.7);
}
#cat svg { opacity: 0.6; }
#discover {
  border-radius: 0 23px 23px 0;
  border-left-color: rgba(255,255,255,0.18);
}
#discover:active { transform: scale(0.96); }
#discover .glyph { font-size: 17px; line-height: 1; }
#catmenu {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  background: rgba(10,14,27,0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  padding: 6px;
  z-index: 35;
  min-width: 180px;
}
#catmenu.show { display: flex; }
#catmenu button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.88);
  font-size: 13.5px;
  font-weight: 300;
  text-align: center;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 8px;
}
#catmenu button:hover { background: rgba(255,255,255,0.08); }
#catmenu button.active { color: #fff; background: rgba(140,170,255,0.16); }

/* --- search, top left --- */
#searchbtn {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  top: calc(16px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#searchbtn.show { opacity: 1; pointer-events: auto; }
#searchwrap {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  top: calc(16px + env(safe-area-inset-top));
  width: min(400px, calc(100vw - 32px));
  display: none;
  z-index: 40;
}
#searchwrap.show { display: block; }
#searchin {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(10,14,27,0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: #fff;
  font-size: 15px;
  font-weight: 300;
  outline: none;
}
#searchin::placeholder { color: rgba(255,255,255,0.35); }
#searchres {
  margin-top: 8px;
  background: rgba(10,14,27,0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  overflow: hidden;
}
#searchres:empty { display: none; }
#searchres button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 300;
  text-align: left;
  padding: 11px 16px;
  cursor: pointer;
}
#searchres button:hover { background: rgba(255,255,255,0.08); }
#searchres .sub {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}
#layers {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  top: calc(184px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  z-index: 30;
  opacity: 0;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
#layers.show { opacity: 1; transition: opacity 1.2s; }
#layers.active {
  background: rgba(120,40,30,0.55);
  border-color: rgba(255,150,120,0.6);
  color: #ffd9cc;
  box-shadow: 0 0 18px rgba(255,120,80,0.3);
}

#hstbtn, #jwstbtn {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.75);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, background 0.3s;
}
#hstbtn, #jwstbtn { display: flex; align-items: center; justify-content: center; }
#hstbtn { top: calc(240px + env(safe-area-inset-top)); }
#jwstbtn { top: calc(296px + env(safe-area-inset-top)); }
#hstbtn.avail, #jwstbtn.avail { opacity: 1; pointer-events: auto; }
#hstbtn.active, #jwstbtn.active {
  background: rgba(60,90,180,0.55);
  border-color: rgba(140,180,255,0.7);
  color: #fff;
  box-shadow: 0 0 16px rgba(120,160,255,0.35);
}

#share {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  top: calc(72px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  z-index: 30;
  padding: 0;
  line-height: 0;
}
#share svg { vertical-align: middle; }

#sharemenu {
  position: fixed;
  right: calc(70px + env(safe-area-inset-right));
  top: calc(72px + env(safe-area-inset-top));
  display: none;
  flex-direction: column;
  background: rgba(10,14,27,0.8);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  padding: 6px;
  z-index: 35;
}
#sharemenu.show { display: flex; }

#sharemenu button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.88);
  font-size: 13px;
  font-weight: 300;
  text-align: right;
  padding: 9px 12px;
  cursor: pointer;
  border-radius: 8px;
}
#sharemenu button:hover { background: rgba(255,255,255,0.08); }

#horizon {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  top: calc(128px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  z-index: 30;
  padding: 0;
  line-height: 0;
}
#horizon svg { vertical-align: middle; }
#horizon.active {
  background: rgba(30,70,130,0.55);
  border-color: rgba(140,190,255,0.6);
  color: #d5e8ff;
  box-shadow: 0 0 18px rgba(120,170,255,0.3);
}

.cardinal {
  position: absolute;
  left: 0;
  top: 0;
  margin: -9px 0 0 -6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(160,200,255,0.9);
  text-shadow: 0 1px 8px #000;
  opacity: 0;
  transition: opacity 0.4s;
  will-change: transform;
}

.conlabel {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 300;
  font-style: italic;
  letter-spacing: 0.14em;
  color: rgba(150,170,230,0.9);
  text-shadow: 0 1px 6px #000;
  opacity: 0;
  transition: opacity 0.5s;
  white-space: nowrap;
  will-change: transform;
}

.moonlabel {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, 0);
  font-size: 9.5px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: rgba(255,225,170,0.85);
  text-shadow: 0 1px 6px #000;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  will-change: transform;
}

#timelapse {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  bottom: calc(34px + env(safe-area-inset-bottom));
  padding: 8px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(18,22,40,0.45);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.8);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  cursor: pointer;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
#timelapse.show { opacity: 1; pointer-events: auto; }
#timelapse.active {
  background: rgba(120,90,20,0.55);
  border-color: rgba(255,210,120,0.6);
  color: #ffe9c2;
}

.poi.body .ring {
  border-color: rgba(255,210,130,0.65);
  box-shadow: 0 0 14px rgba(255,190,90,0.3), inset 0 0 9px rgba(255,190,90,0.18);
}
.poi.body .label { color: rgba(255,225,170,0.92); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(150,185,255,0.0); }
  50% { box-shadow: 0 0 26px 4px rgba(150,185,255,0.35); }
}
#discover.pulse { animation: pulse 2.6s ease-in-out 3; }

/* --- object card --- */
#card {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 26px));
  transform: translate(-50%, 26px);
  opacity: 0;
  pointer-events: none;
  background: rgba(10,14,27,0.62);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px;
  padding: 12px 18px 15px;
  z-index: 25;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.35s;
}
#card.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#card .grabber {
  width: 34px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.22);
  margin: 0 auto 10px;
}
/* in-flow action row (used by the Sun's live views) */
#card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
#card-actions:empty { display: none; }
#card-actions button.mini {
  width: auto;
  height: 28px;
  padding: 0 11px;
  border-radius: 14px;
  font-size: 9.5px;
}
#card-actions button {
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}
#card-actions button.active {
  background: rgba(60,90,180,0.55);
  border-color: rgba(140,180,255,0.7);
  color: #fff;
  box-shadow: 0 0 16px rgba(120,160,255,0.35);
}
#card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.04em;
}
#card .meta {
  margin-top: 3px;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.55);
}
#card-coords {
  margin-top: 3px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.38);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#card-coords:empty { display: none; }
#card p {
  margin: 9px 0 0;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.55;
  color: rgba(255,255,255,0.88);
}
#card { max-height: 46vh; overflow-y: auto; }
/* wide screens: dock the card left so it never covers the object */
@media (min-width: 1000px) {
  #card {
    left: 26px;
    width: 390px;
    max-height: 64vh;
    transform: translate(0, 26px);
  }
  #card.show { transform: none; }
}
#card-wiki {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 300;
  line-height: 1.55;
  color: rgba(255,255,255,0.72);
}
#card-wiki a {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  color: rgba(150,185,255,0.75);
  text-decoration: none;
}
#card-more {
  margin-top: 10px;
  padding: 0;
  background: none;
  border: none;
  color: rgba(150,185,255,0.8);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  cursor: pointer;
}

/* --- attribution + credits --- */
#attrib {
  position: fixed;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.4);
  z-index: 20;
  cursor: pointer;
}
#brand {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  z-index: 20;
}
#brand:hover { color: rgba(255,255,255,0.7); }

#credits {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 40px));
  background: rgba(10,14,27,0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  padding: 18px 20px;
  z-index: 60;
  display: none;
  cursor: pointer;
}
#credits.show { display: block; }
#credits h3 { margin: 0 0 8px; font-weight: 400; font-size: 15px; }
#credits p { margin: 0 0 8px; font-size: 12.5px; font-weight: 300; line-height: 1.5; color: rgba(255,255,255,0.8); }
#credits .dim { color: rgba(255,255,255,0.4); font-size: 11px; }
#credits a, #credits a:visited {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.35);
  text-underline-offset: 2px;
}

/* --- offline --- */
#offline {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  background: #000;
  text-align: center;
  padding: 30px;
}
#offline.show { display: flex; }
#offline h3 { font-weight: 300; letter-spacing: 0.08em; }
#offline p { font-size: 13.5px; font-weight: 300; color: rgba(255,255,255,0.7); max-width: 340px; line-height: 1.6; }

#debug {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 8px;
  font: 10px/1.5 ui-monospace, monospace;
  color: #8f8;
  z-index: 80;
  white-space: pre;
  pointer-events: none;
  display: none;
  text-shadow: 0 1px 2px #000;
}
#debug.show { display: block; }
