:root {
  color-scheme: dark;
  --ink: #08131a;
  --paper: #fff7df;
  --paper-soft: rgba(255, 247, 223, .72);
  --red: #ff3b2f;
  --cyan: #54f1dc;
  --night: #052537;
  --gutter: clamp(10px, 1.15vw, 20px);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  --display: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--ink);
}

body {
  min-height: 100dvh;
  color: var(--paper);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button, a { font: inherit; }

button {
  min-width: 44px;
  min-height: 44px;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 4px;
}

#app {
  position: relative;
  min-height: 100dvh;
  isolation: isolate;
}

#app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .09;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.mast {
  position: fixed;
  inset: var(--safe-top) max(18px, env(safe-area-inset-right)) auto max(18px, env(safe-area-inset-left));
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 16px;
  pointer-events: none;
}

.mast > * { pointer-events: auto; }

.back-link, .text-button {
  color: var(--paper);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .16em;
  font: 700 11px/1 var(--body);
  text-shadow: 0 2px 16px rgba(0, 0, 0, .35);
}

.back-link { justify-self: start; padding: 10px 0; }

.text-button {
  justify-self: end;
  border: 0;
  padding: 8px 0;
  background: transparent;
  cursor: pointer;
}

.run-meter {
  display: none;
  min-width: 170px;
  text-align: center;
}

.is-playing .run-meter { display: block; }

.run-meter__label {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 247, 223, .72);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 9px;
  font-weight: 800;
}

.run-meter__marks { display: flex; justify-content: center; gap: 6px; }

.run-meter__marks i {
  width: 27px;
  height: 3px;
  border-radius: 9px;
  background: rgba(255, 247, 223, .32);
  transition: background .35s ease, transform .35s ease;
}

.run-meter__marks i.is-complete {
  background: var(--paper);
  transform: scaleY(1.8);
}

.sky-stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--gutter) minmax(0, 1fr);
  min-height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  transition: grid-template-columns 1.1s cubic-bezier(.2, .75, .2, 1);
}

.sky-stage::before, .sky-stage::after {
  content: "";
  position: absolute;
  inset-block: 0;
  width: calc(50% - var(--gutter) / 2);
  z-index: -1;
  background-image: linear-gradient(rgba(5, 10, 18, .08), rgba(5, 10, 18, .08)), url("sky-atlas.webp");
  background-repeat: no-repeat;
  background-size: 200% 100%;
}

.sky-stage::before { left: 0; background-position: left center; }
.sky-stage::after { right: 0; background-position: right center; }

.landing-seam {
  grid-column: 2;
  background: var(--paper);
  box-shadow: 0 0 42px rgba(255, 247, 223, .82);
  transform-origin: center;
  transition: opacity .8s ease, transform 1.1s cubic-bezier(.2, .75, .2, 1), box-shadow .8s ease;
}

.sky {
  position: relative;
  min-width: 0;
  min-height: 100dvh;
  overflow: hidden;
  background-image: linear-gradient(rgba(3, 12, 20, .08), rgba(3, 12, 20, .17)), url("sky-atlas-play.webp");
  background-repeat: no-repeat;
  background-size: 200% 100%;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.sky--left { grid-column: 1; background-position: left center; }
.sky--right { grid-column: 3; background-position: right center; }

.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 40%, transparent 20%, rgba(1, 7, 12, .18) 100%);
}

.sky__side-label {
  position: absolute;
  z-index: 8;
  top: clamp(68px, 11vh, 110px);
  left: clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 247, 223, .68);
  text-transform: uppercase;
  letter-spacing: .18em;
  font: 800 10px/1 var(--body);
}

.sky--right .sky__side-label { right: clamp(18px, 4vw, 54px); left: auto; }

.sky__side-label::before {
  content: "";
  width: 20px;
  height: 1px;
  background: currentColor;
}

.receiver {
  position: absolute;
  z-index: 10;
  top: calc(var(--gate-y, .5) * 100%);
  width: clamp(72px, 10vw, 118px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: var(--paper);
  background: transparent;
  transform: translateY(-50%);
  cursor: ns-resize;
  transition: top .18s cubic-bezier(.2, .75, .25, 1), opacity .25s ease;
  filter: drop-shadow(0 0 22px rgba(255, 247, 223, .32));
}

.sky--left .receiver { left: clamp(12px, 3.5vw, 48px); }
.sky--right .receiver { right: clamp(12px, 3.5vw, 48px); }

.receiver::before, .receiver::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.receiver::before {
  inset: 8%;
  border: 2px solid currentColor;
  box-shadow: inset 0 0 0 10px rgba(255, 247, 223, .06), 0 0 0 1px rgba(8, 19, 26, .28);
}

.receiver::after {
  inset: 38%;
  background: currentColor;
  box-shadow: 0 -25px 0 -4px currentColor, 0 25px 0 -4px currentColor, -25px 0 0 -4px currentColor, 25px 0 0 -4px currentColor;
}

.receiver.is-inactive { opacity: .24; pointer-events: none; }
.receiver.is-caught { animation: catch-bloom .8s ease-out both; }
.receiver.is-missed { animation: miss-shake .55s ease-out both; color: var(--red); }

.gate-line {
  position: absolute;
  z-index: 4;
  top: calc(var(--gate-y, .5) * 100%);
  width: 32%;
  height: 1px;
  opacity: .5;
  pointer-events: none;
  background: linear-gradient(90deg, currentColor, transparent);
  color: var(--paper);
  transition: top .18s cubic-bezier(.2, .75, .25, 1);
}

.sky--left .gate-line { left: 0; }
.sky--right .gate-line { right: 0; transform: scaleX(-1); }

.comet {
  position: absolute;
  z-index: 7;
  left: calc(var(--comet-x, 20) * 1%);
  top: calc(var(--comet-y, 50) * 1%);
  width: clamp(12px, 1.5vw, 21px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.55);
  background: var(--paper);
  box-shadow: 0 0 8px #fff, 0 0 24px rgba(84, 241, 220, .95), 0 0 62px rgba(84, 241, 220, .55);
}

.comet::after {
  content: "";
  position: absolute;
  top: 44%;
  right: 45%;
  width: clamp(72px, 12vw, 170px);
  height: 2px;
  transform-origin: right center;
  transform: rotate(var(--tail-angle, 0deg));
  background: linear-gradient(90deg, transparent, rgba(255, 247, 223, .25), var(--paper));
  filter: drop-shadow(0 0 4px rgba(84, 241, 220, .8));
}

.comet.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.flight-trace {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.flight-trace path {
  fill: none;
  stroke: rgba(255, 247, 223, .5);
  stroke-width: .22;
  stroke-dasharray: .7 1.3;
  vector-effect: non-scaling-stroke;
}

.earned-route {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.earned-route path {
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  filter: drop-shadow(0 0 5px rgba(84, 241, 220, .72)) drop-shadow(0 0 18px rgba(84, 241, 220, .38));
  transition: opacity .35s ease;
}

.earned-route path.is-earned {
  opacity: .88;
  animation: earn-route 1.1s cubic-bezier(.25, .8, .2, 1) forwards;
}

.release {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: max(32px, calc(var(--safe-bottom) + 12px));
  width: min(330px, calc(100% - 36px));
  min-height: 58px;
  border: 1px solid rgba(255, 247, 223, .75);
  border-radius: 999px;
  padding: 13px 24px;
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
  transform: translateX(-50%);
  box-shadow: 0 13px 35px rgba(0, 0, 0, .2);
  text-transform: uppercase;
  letter-spacing: .14em;
  font: 900 11px/1 var(--body);
  transition: transform .2s ease, background .2s ease;
}

.release:hover { transform: translateX(-50%) translateY(-3px); }
.release[hidden] { display: none; }

.sky__prompt {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: max(36px, calc(var(--safe-bottom) + 14px));
  width: min(390px, calc(100% - 32px));
  margin: 0;
  color: var(--paper);
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
  font: 650 13px/1.45 var(--body);
}

.sky__prompt strong {
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 10px;
}

.handoff-flash {
  position: absolute;
  z-index: 6;
  top: calc(var(--handoff-y, .5) * 100%);
  width: 2px;
  height: 2px;
  border-radius: 50%;
  opacity: 0;
  background: var(--paper);
  transform: translateY(-50%);
  pointer-events: none;
}

.sky--left .handoff-flash { right: 0; }
.sky--right .handoff-flash { left: 0; }
.handoff-flash.is-active { animation: seam-flash 1s ease-out both; }

.brief {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(24px, calc(var(--safe-bottom) + 8px));
  width: min(520px, calc(100% - 32px));
  padding: 22px 24px 20px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .32);
  transform: translateX(-50%);
}

.brief__kicker {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: .17em;
  font: 900 10px/1 var(--body);
}

.brief__line { margin: 0; font: 900 clamp(24px, 4vw, 42px)/.98 var(--display); letter-spacing: -.04em; }
.brief__instruction { margin: 14px 0 18px; max-width: 38ch; font-size: 13px; line-height: 1.45; }

.brief__dismiss {
  width: 100%;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--paper);
  background: var(--ink);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .14em;
  font: 900 10px/1 var(--body);
}

.landing {
  position: relative;
  z-index: 15;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100dvh;
  padding: clamp(82px, 12vh, 120px) max(22px, 5vw) max(24px, calc(var(--safe-bottom) + 6px));
}

.landing__copy {
  width: min(1050px, 100%);
  margin-inline: auto;
}

.eyebrow, .landing__note {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .17em;
  font: 800 10px/1.2 var(--body);
  text-shadow: 0 2px 20px rgba(0, 0, 0, .4);
}

.landing h1 {
  display: grid;
  margin: clamp(18px, 4vh, 40px) 0 14px;
  text-transform: uppercase;
  font: 1000 clamp(54px, 11.5vw, 168px)/.76 var(--display);
  letter-spacing: -.075em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .18);
}

.landing h1 span:last-child { justify-self: end; }

.dek {
  max-width: 36ch;
  margin: 0 0 0 auto;
  font: 650 clamp(16px, 2vw, 22px)/1.28 var(--body);
  text-shadow: 0 2px 20px rgba(0, 0, 0, .46);
}

.mode-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  width: min(780px, 100%);
  margin: clamp(28px, 5vh, 60px) auto 14px;
  background: rgba(255, 247, 223, .55);
  border: 1px solid rgba(255, 247, 223, .62);
}

.mode-card {
  position: relative;
  display: grid;
  min-height: 112px;
  border: 0;
  padding: 22px 22px 18px 64px;
  color: var(--paper);
  text-align: left;
  background: rgba(5, 18, 27, .78);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.mode-card:hover { color: var(--ink); background: var(--paper); }
.mode-card strong { align-self: end; font-size: 16px; }
.mode-card small { align-self: start; margin-top: 5px; opacity: .72; font-size: 11px; line-height: 1.35; }

.mode-card__number {
  position: absolute;
  top: 22px;
  left: 20px;
  opacity: .7;
  font: 900 10px/1 var(--body);
}

.landing__note { text-align: center; opacity: .78; }

.toast {
  position: fixed;
  z-index: 50;
  top: max(68px, calc(var(--safe-top) + 42px));
  left: 50%;
  max-width: calc(100% - 32px);
  border: 1px solid rgba(255, 247, 223, .45);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--paper);
  background: rgba(8, 19, 26, .88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  text-align: center;
  font-size: 12px;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.finale {
  position: absolute;
  z-index: 18;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.sky-stage.is-joined {
  grid-template-columns: minmax(0, 1fr) 0 minmax(0, 1fr);
}

.sky-stage.is-joined .landing-seam {
  opacity: 0;
  transform: scaleX(0);
  box-shadow: 0 0 110px 30px rgba(84, 241, 220, .48);
}

.sky-stage.is-joined .receiver,
.sky-stage.is-joined .gate-line,
.sky-stage.is-joined .flight-trace,
.sky-stage.is-joined .sky__prompt,
.sky-stage.is-joined .sky__side-label {
  opacity: 0;
  pointer-events: none;
}

.sky-stage.is-joined .earned-route path.is-earned {
  opacity: 1;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(255, 247, 223, .95)) drop-shadow(0 0 28px rgba(84, 241, 220, .8));
}

.finale::before, .finale::after {
  content: "";
  position: absolute;
  left: -12%;
  width: 124%;
  height: 34%;
  border-radius: 50%;
  border: clamp(16px, 4vw, 56px) solid transparent;
  opacity: .82;
  filter: blur(2px) drop-shadow(0 0 20px rgba(84, 241, 220, .3));
  transform: rotate(-7deg);
}

.finale::before {
  top: 12%;
  border-top-color: rgba(84, 241, 220, .9);
  border-left-color: rgba(255, 247, 223, .22);
  animation: aurora-in 1.8s cubic-bezier(.2, .7, .2, 1) both;
}

.finale::after {
  top: 22%;
  border-top-color: rgba(255, 247, 223, .7);
  transform: rotate(-3deg) scale(.94);
  animation: aurora-in 2.2s .12s cubic-bezier(.2, .7, .2, 1) both;
}

.finale__copy {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0 4vw;
  margin: 0;
  color: var(--paper);
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 4px 36px rgba(0, 0, 0, .5);
  font: 1000 clamp(50px, 10vw, 150px)/.78 var(--display);
  letter-spacing: -.07em;
  animation: finale-copy 1.2s .55s both;
}

.finale__comet {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 57%;
  width: clamp(18px, 2vw, 30px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--paper);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px #fff, 0 0 34px 16px rgba(84, 241, 220, .7), 0 0 100px 38px rgba(84, 241, 220, .36);
  animation: final-comet 1.8s ease-in-out infinite alternate;
}

.finale__sub {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(36px, calc(var(--safe-bottom) + 12px));
  width: min(520px, calc(100% - 36px));
  margin: 0;
  text-align: center;
  transform: translateX(-50%);
  text-transform: uppercase;
  letter-spacing: .16em;
  font: 800 10px/1.5 var(--body);
  animation: finale-copy 1s 1.15s both;
}

.finale__restart {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(70px, calc(var(--safe-bottom) + 48px));
  min-width: 150px;
  border: 1px solid rgba(255, 247, 223, .72);
  border-radius: 999px;
  color: var(--paper);
  background: rgba(8, 19, 26, .42);
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .14em;
  font: 900 10px/1 var(--body);
  backdrop-filter: blur(10px);
  animation: finale-copy 1s 1.35s both;
}

.is-pair .sky-stage { display: block; background: var(--ink); }
.is-pair .sky-stage::before, .is-pair .sky-stage::after { display: none; }
.is-pair .sky { position: absolute; inset: 0; width: 100%; min-height: 100dvh; }
.is-pair .sky--left, .is-pair .sky--right { background-size: 200% 100%; }
.is-pair .sky[hidden] { display: none; }
.is-pair .receiver { width: clamp(84px, 15vw, 138px); }
.is-pair .finale__copy { font-size: clamp(60px, 15vw, 180px); }
.is-pair .finale__copy {
  position: absolute;
  left: 0;
  width: 200vw;
  padding-inline: 5vw;
  font-size: clamp(64px, 13vw, 180px);
}
.is-pair.view-right .finale__copy { left: -100vw; }
.is-pair.view-left .finale__comet { left: 100%; }
.is-pair.view-right .finale__comet { left: 0; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[hidden] { display: none !important; }

@keyframes seam-flash {
  0% { opacity: 0; box-shadow: 0 0 0 0 rgba(255, 247, 223, .9); }
  20% { opacity: 1; box-shadow: 0 0 40px 18px rgba(255, 247, 223, .78); }
  100% { opacity: 0; box-shadow: 0 0 120px 75px rgba(84, 241, 220, 0); }
}

@keyframes catch-bloom {
  0% { transform: translateY(-50%) scale(1); }
  45% { transform: translateY(-50%) scale(1.32); filter: drop-shadow(0 0 50px rgba(255, 247, 223, .95)); }
  100% { transform: translateY(-50%) scale(1); }
}

@keyframes miss-shake {
  0%, 100% { transform: translate(0, -50%); }
  25% { transform: translate(-9px, -50%); }
  60% { transform: translate(7px, -50%); }
}

@keyframes aurora-in {
  from { opacity: 0; transform: translateY(25vh) rotate(-11deg) scale(.72); }
}

@keyframes finale-copy {
  from { opacity: 0; transform: translateY(26px); filter: blur(10px); }
}

@keyframes earn-route {
  from { opacity: 0; filter: blur(8px) drop-shadow(0 0 25px rgba(84, 241, 220, .9)); }
}

@keyframes final-comet {
  to { transform: translate(-50%, -50%) scale(1.18); }
}

@media (max-width: 720px) {
  :root { --gutter: 8px; }
  .mast { grid-template-columns: auto 1fr auto; }
  .run-meter { min-width: 112px; }
  .run-meter__label { display: none; }
  .run-meter__marks i { width: 18px; }
  .landing { padding-inline: 18px; }
  .landing h1 { font-size: clamp(56px, 20vw, 104px); line-height: .8; }
  .landing h1 span:last-child { justify-self: start; margin-left: 7vw; }
  .dek { max-width: 29ch; font-size: 15px; }
  .mode-choices { grid-template-columns: 1fr; width: min(440px, 100%); }
  .mode-card { min-height: 90px; padding-top: 17px; padding-bottom: 15px; }
  .mode-card--pair { display: none; }
  .landing__note { font-size: 8px; }
  .sky__side-label { top: 72px; left: 12px; font-size: 8px; letter-spacing: .12em; }
  .sky--right .sky__side-label { left: auto; right: 12px; }
  .receiver { width: 70px; }
  .sky--left .receiver { left: 3px; }
  .sky--right .receiver { right: 3px; }
  .gate-line { width: 44%; }
  .sky__prompt { bottom: max(24px, var(--safe-bottom)); width: calc(100% - 14px); font-size: 10px; }
  .release { min-height: 52px; width: calc(100% - 18px); padding-inline: 8px; font-size: 9px; }
  .finale__copy { font-size: clamp(43px, 15vw, 80px); }
  .finale__sub { bottom: max(21px, var(--safe-bottom)); font-size: 8px; }
  .finale__restart { bottom: max(53px, calc(var(--safe-bottom) + 34px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .comet::after { width: 54px; }
}
