:root {
  color-scheme: dark;
  --ink: #f7f3ff;
  --muted: rgba(239, 232, 255, .72);
  --panel: rgba(12, 7, 26, .58);
  --line: rgba(255, 255, 255, .14);
  --violet: #9f7aea;
  --cyan: #58e6d9;
  --max: 1180px;
  --moon-core: #f3df9b;
  --moon-edge: #b69245;
  --moon-glow: rgba(243, 223, 155, .22);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: #070513;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { font: inherit; }

.globe-page {
  position: relative;
  min-height: 100svh;
  isolation: isolate;
  overflow: clip;
  background:
    radial-gradient(circle at 50% 36%, rgba(84, 43, 151, .26), transparent 34rem),
    linear-gradient(180deg, #070513 0%, #090718 58%, #05040c 100%);
}
.sky { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.nebula { position: absolute; width: 55vw; height: 55vw; border-radius: 50%; filter: blur(70px); opacity: .24; transition: background .5s ease; }
.nebula-one { left: -20vw; top: -15vw; background: #51349b; }
.nebula-two { right: -18vw; bottom: -24vw; background: #087e88; }
.stars { position: absolute; inset: 0; background-repeat: repeat; opacity: .48; }
.stars-small { background-image: radial-gradient(circle, rgba(255,255,255,.72) 0 1px, transparent 1.5px); background-size: 67px 67px; }
.stars-large { background-image: radial-gradient(circle, rgba(165,215,255,.8) 0 1px, transparent 2px); background-size: 157px 139px; transform: translate(21px, 37px); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  width: 100%;
  padding: .85rem max(1rem, calc((100vw - var(--max)) / 2));
  background: rgba(9, 9, 11, .84);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(167, 139, 250, .2);
}
.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: #fff;
  text-decoration: none;
  font-weight: 720;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.brand img {
  display: block;
  width: 42px;
  height: 42px;
  filter: drop-shadow(0 0 18px rgba(159,122,234,.45));
}
.site-nav {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav .notes-link {
  white-space: nowrap;
  padding: .45rem .65rem;
  border: 0;
  border-radius: 999px;
  color: rgba(239, 232, 255, .72);
  background: transparent;
  text-decoration: none;
  font-size: .88rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  transition: background .18s ease, color .18s ease;
}
.site-nav .notes-link:hover {
  color: #f7f3ff;
  background: rgba(124, 58, 237, .16);
  transform: none;
}
.site-nav .notes-link:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}
.reset, .autospin, .large-mode, .world-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: rgba(255,255,255,.82);
  background: rgba(10, 7, 22, .6);
  backdrop-filter: blur(14px);
  text-decoration: none;
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}
.reset:hover, .autospin:hover, .large-mode:hover, .world-button:hover { color: #fff; border-color: rgba(159,122,234,.72); background: rgba(91,59,154,.25); transform: translateY(-1px); }
.reset:focus-visible, .autospin:focus-visible, .large-mode:focus-visible, .world-button:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.autospin.is-active, .large-mode.is-active { color: #fff; border-color: rgba(88,230,217,.62); background: rgba(17,117,112,.28); box-shadow: 0 0 20px rgba(88,230,217,.12); }

.globe-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) 0 36px;
  display: grid;
  grid-template-columns: minmax(250px, .7fr) minmax(480px, 1.4fr);
  align-items: center;
  gap: clamp(24px, 5vw, 72px);
}
.intro { position: relative; z-index: 3; }
.eyebrow { margin: 0 0 .7rem; color: var(--cyan); font-size: .76rem; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(3.1rem, 8vw, 7rem); line-height: .86; letter-spacing: -.065em; text-wrap: balance; }
.intro > p:not(.eyebrow):not(.active-world-line) { max-width: 36rem; margin: 1.35rem 0 0; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.2rem); line-height: 1.65; }
.active-world-line { margin: 1.25rem 0 0; color: rgba(255,255,255,.58); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.active-world-line strong { color: #fff; }

.viewer-column {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 14px;
}

.world-switch {
  position: relative;
  z-index: 4;
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 22px;
  background: rgba(6,4,15,.68);
  box-shadow: 0 16px 45px rgba(0,0,0,.2);
  backdrop-filter: blur(14px);
}
.world-switch-label {
  padding-inline: 4px;
  color: rgba(255,255,255,.54);
  font-size: .66rem;
  font-weight: 760;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.world-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 9px;
}
.world-button {
  min-width: 0;
  min-height: 38px;
  padding: .52rem .76rem;
  cursor: pointer;
  font-size: .69rem;
  font-weight: 760;
  letter-spacing: .035em;
  white-space: nowrap;
}
.world-button.is-active { color: #fff; border-color: rgba(88,230,217,.72); background: rgba(17,117,112,.34); box-shadow: 0 0 18px rgba(88,230,217,.14); }

.viewer-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 420px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: clamp(24px, 4vw, 44px);
  background:
    radial-gradient(circle at 50% 48%, rgba(72, 50, 132, .2), transparent 44%),
    radial-gradient(circle at 18% 16%, rgba(83, 133, 255, .1), transparent 30%),
    radial-gradient(circle at 82% 74%, rgba(112, 76, 190, .1), transparent 34%),
    linear-gradient(180deg, #050816 0%, #050612 56%, #02030a 100%);
  box-shadow: inset 0 0 90px rgba(106, 73, 182, .1), 0 35px 100px rgba(0,0,0,.38);
  overflow: hidden;
  touch-action: none;
}
.viewer-wrap::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: clamp(30px, 7%, 72px);
  right: clamp(24px, 9%, 92px);
  width: clamp(105px, 19vw, 188px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: .48;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.72) 0 3%, transparent 4%),
    radial-gradient(circle at 68% 40%, rgba(24,20,36,.16) 0 8%, transparent 9%),
    radial-gradient(circle at 42% 70%, rgba(24,20,36,.12) 0 6%, transparent 7%),
    radial-gradient(circle at 50% 50%, var(--moon-core) 0 53%, var(--moon-edge) 77%, transparent 78%);
  box-shadow: 0 0 34px var(--moon-glow), 0 0 92px var(--moon-glow);
  filter: saturate(.92);
  transition: background .55s ease, box-shadow .55s ease;
  pointer-events: none;
}
.viewer-wrap::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 18%;
  left: -28%;
  width: clamp(100px, 15vw, 180px);
  height: 2px;
  opacity: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.28) 42%, rgba(255,255,255,.96) 78%, transparent 100%);
  filter: drop-shadow(0 0 6px rgba(180, 212, 255, .72));
  animation: crossing-star 22s linear infinite;
  pointer-events: none;
}
.viewer-wrap {
  background-image:
    radial-gradient(circle, rgba(255,255,255,.62) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(159,205,255,.48) 0 1px, transparent 1.8px),
    radial-gradient(circle at 50% 48%, rgba(72, 50, 132, .2), transparent 44%),
    radial-gradient(circle at 18% 16%, rgba(83, 133, 255, .1), transparent 30%),
    radial-gradient(circle at 82% 74%, rgba(112, 76, 190, .1), transparent 34%),
    linear-gradient(180deg, #050816 0%, #050612 56%, #02030a 100%);
  background-size: 74px 74px, 163px 149px, auto, auto, auto, auto;
  background-position: 0 0, 31px 47px, 0 0, 0 0, 0 0, 0 0;
}
@keyframes crossing-star {
  0%, 28% { left: -28%; top: 18%; opacity: 0; transform: rotate(17deg); }
  30% { left: -28%; top: 18%; opacity: 0; transform: rotate(17deg); }
  31% { opacity: .92; }
  36% { left: 122%; top: 47%; opacity: 0; transform: rotate(17deg); }
  37%, 69% { left: 122%; top: 47%; opacity: 0; transform: rotate(17deg); }
  70% { left: 122%; top: 23%; opacity: 0; transform: rotate(-17deg); background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.96) 22%, rgba(255,255,255,.28) 58%, transparent 100%); }
  71% { opacity: .92; }
  76% { left: -28%; top: 49%; opacity: 0; transform: rotate(-17deg); background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.96) 22%, rgba(255,255,255,.28) 58%, transparent 100%); }
  77%, 100% { left: -28%; top: 49%; opacity: 0; transform: rotate(-17deg); }
}
.viewer-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}
#globe { position: relative; z-index: 2; width: 100%; height: 100%; display: block; cursor: grab; image-rendering: auto; }
#globe:active { cursor: grabbing; }

.loading {
  position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; gap: 14px; justify-items: center;
  color: rgba(255,255,255,.76); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(5,4,13,.42); transition: opacity .35s ease, visibility .35s ease;
}
.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading.has-error { padding: 24px; text-align: center; color: #ffd6e7; }
.loading-orbit { width: 44px; height: 44px; border: 2px solid rgba(255,255,255,.14); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { position: absolute; z-index: 4; left: 18px; bottom: 18px; width: max-content; max-width: calc(100% - 410px); padding: .56rem .85rem; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; color: rgba(255,255,255,.66); background: rgba(6,4,15,.6); backdrop-filter: blur(12px); font-size: .72rem; transition: opacity .3s ease; }
.hint.is-hidden { opacity: 0; pointer-events: none; }
.viewer-controls { position: absolute; right: 18px; bottom: 18px; z-index: 4; display: flex; gap: 8px; align-items: center; }
.reset, .autospin, .large-mode { padding: .58rem .78rem; font-size: .72rem; cursor: pointer; }
.fallback { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }

.viewer-wrap:fullscreen .viewer-controls { right: 24px; bottom: 24px; }
.viewer-wrap:fullscreen .hint { left: 24px; bottom: 24px; }

body[data-world="original"], body[data-world="kudosquest"] {
  --moon-core: #f3df9b;
  --moon-edge: #b69245;
  --moon-glow: rgba(243, 223, 155, .22);
}
body[data-world="lava"] {
  --moon-core: #ff6b3d;
  --moon-edge: #8b1f0e;
  --moon-glow: rgba(255, 92, 45, .28);
}
body[data-world="candy"] {
  --moon-core: #ff9ed8;
  --moon-edge: #b44d91;
  --moon-glow: rgba(255, 158, 216, .28);
}
body[data-world="frozen"] {
  --moon-core: #a8ecff;
  --moon-edge: #4f91b8;
  --moon-glow: rgba(133, 224, 255, .3);
}
body[data-world="toxic"] {
  --moon-core: #9cff45;
  --moon-edge: #3d7c13;
  --moon-glow: rgba(145, 255, 55, .28);
}
body[data-world="jungle"] {
  --moon-core: #9bcf9a;
  --moon-edge: #3f6c45;
  --moon-glow: rgba(118, 196, 126, .22);
}
body[data-world="desert"] {
  --moon-core: #f4c35a;
  --moon-edge: #9a6921;
  --moon-glow: rgba(244, 195, 90, .26);
}
body[data-world="neon"] {
  --moon-core: #7a41ff;
  --moon-edge: #2d126e;
  --moon-glow: rgba(122, 65, 255, .3);
}
body[data-world="haunted"] {
  --moon-core: #f7f7ff;
  --moon-edge: #9a9aaa;
  --moon-glow: rgba(255, 255, 255, .22);
}
body[data-world="crystal"] {
  --moon-core: #c9a7ff;
  --moon-edge: #7550a6;
  --moon-glow: rgba(201, 167, 255, .28);
}
body[data-world="ocean"] {
  --moon-core: #7ff0c1;
  --moon-edge: #247b70;
  --moon-glow: rgba(93, 238, 190, .28);
}

body[data-world="lava"] .nebula-one { background: #9b2e08; }
body[data-world="lava"] .nebula-two { background: #dc5a00; }
body[data-world="candy"] .nebula-one { background: #c84cb2; }
body[data-world="candy"] .nebula-two { background: #6c7cf5; }
body[data-world="frozen"] .nebula-one { background: #2368be; }
body[data-world="frozen"] .nebula-two { background: #34d5e8; }
body[data-world="toxic"] .nebula-one { background: #6f2a91; }
body[data-world="toxic"] .nebula-two { background: #72d700; }
body[data-world="jungle"] .nebula-one { background: #126f3b; }
body[data-world="jungle"] .nebula-two { background: #00a2a5; }
body[data-world="desert"] .nebula-one { background: #9b5a18; }
body[data-world="desert"] .nebula-two { background: #d8982b; }
body[data-world="neon"] .nebula-one { background: #c025d5; }
body[data-world="neon"] .nebula-two { background: #00bfe8; }
body[data-world="haunted"] .nebula-one { background: #37306d; }
body[data-world="haunted"] .nebula-two { background: #166c68; }
body[data-world="crystal"] .nebula-one { background: #8d54d9; }
body[data-world="crystal"] .nebula-two { background: #21a6c8; }
body[data-world="ocean"] .nebula-one { background: #0b4d94; }
body[data-world="ocean"] .nebula-two { background: #008f9a; }

@media (max-width: 950px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .site-nav { width: 100%; }
}
@media (max-width: 860px) {
  .globe-shell { grid-template-columns: 1fr; padding-top: 12px; text-align: center; }
  .intro > p:not(.eyebrow) { margin-inline: auto; }
  .viewer-column { width: min(100%, 720px); margin-inline: auto; }
  .viewer-wrap { min-height: 0; }
  .world-switch-label { text-align: left; }
}
@media (max-width: 620px) {
  .topbar { padding: .7rem .65rem; }
  .brand span { font-size: .85rem; }
  .site-nav .notes-link { padding: .4rem .52rem; font-size: .78rem; }
  .globe-shell { width: min(100% - 20px, 1180px); padding-bottom: 16px; }
  .world-switch { padding: 10px; border-radius: 18px; }
  .world-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .world-button { font-size: .66rem; padding: .48rem .58rem; }
  .viewer-wrap { border-radius: 24px; }
  .viewer-wrap::before { top: 5%; right: 5%; width: clamp(96px, 28vw, 138px); opacity: .42; }
  .hint { display: none; }
  .viewer-controls { right: 12px; bottom: 12px; left: 12px; justify-content: flex-end; flex-wrap: wrap; }
  .reset, .autospin, .large-mode { font-size: .66rem; padding: .52rem .64rem; }
}
@media (prefers-reduced-motion: reduce) {
  .loading-orbit { animation-duration: 2.4s; }
  .viewer-wrap::after { animation: none; opacity: 0; }
  .site-nav .notes-link, .reset, .autospin, .large-mode, .world-button, .nebula, .viewer-wrap::before { transition: none; }
}
