:root {
  --bone: #efe6d6;
  --brass: #d7bd86;
  --ink: #070408;
  --reading: "Oranienbaum", "Times New Roman", serif;
  --whisper: "Tenor Sans", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--bone);
}

body { -webkit-font-smoothing: antialiased; }

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 50% 18% at 50% 108%, rgba(48, 18, 32, .55), transparent 70%),
    radial-gradient(ellipse 36% 80% at 0% 50%, #07030a 0%, transparent 74%),
    radial-gradient(ellipse 36% 80% at 100% 50%, #07030a 0%, transparent 74%),
    radial-gradient(ellipse 80% 28% at 50% 0%, #10060f, transparent 72%),
    #030206;
}

.booth { position: absolute; inset: 0; pointer-events: none; z-index: 1; }

.valance {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: clamp(28px, 7vh, 78px);
  background: linear-gradient(180deg, #07030a 0%, rgba(7, 3, 10, .72) 46%, transparent 100%);
}

.curtain { display: none; }

#embers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.layout {
  position: relative;
  z-index: 3;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding:
    clamp(16px, 4vh, 36px)
    clamp(10px, 3vw, 32px)
    clamp(10px, 2.4vh, 28px);
}

.altar {
  min-height: 0;
  display: grid;
  place-items: center;
}

.orb-wrap {
  position: relative;
  width: min(82vw, 62vh, 560px);
  cursor: pointer;
  touch-action: none;
}

.orb-wrap:focus { outline: none; }
.orb-wrap:focus-visible .sphere {
  outline: 1px solid rgba(215, 189, 134, .9);
  outline-offset: 8px;
}

.ring-text {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132%;
  height: 132%;
  transform: translate(-50%, -50%);
  overflow: visible;
  pointer-events: none;
  z-index: 4;
}

.ring-text text {
  fill: rgba(214, 196, 232, .78);
  font-family: "Noto Sans Runic", "Segoe UI Historic", sans-serif;
  font-size: 17px;
}

.sphere {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.sphere::before {
  content: "";
  position: absolute;
  inset: -34%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle, rgba(124, 52, 168, .38) 0%, rgba(48, 12, 72, .12) 46%, transparent 68%);
}

.lens, .shell {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.lens { overflow: hidden; background: #14081c; }

#glass {
  display: block;
  width: 100%;
  height: 100%;
}

.incantation {
  position: absolute;
  pointer-events: none;
  left: 14%;
  right: 14%;
  top: 38%;
  margin: 0;
  text-align: center;
  font-family: var(--reading);
  font-style: italic;
  font-size: clamp(15px, 2.4vh, 28px);
  line-height: 1.25;
  color: #f7f3ea;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .85);
  opacity: 0;
  transition: opacity .45s ease;
}

.shell {
  pointer-events: none;
  background:
    radial-gradient(ellipse 8% 5% at 30% 24%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .2) 38%, transparent 70%),
    radial-gradient(ellipse 22% 13% at 33% 28%, rgba(255, 255, 255, .14), transparent 72%),
    radial-gradient(ellipse 12% 7% at 70% 80%, rgba(255, 248, 236, .12), transparent 70%);
}

.foot {
  width: 48%;
  margin: -1% auto 0;
  aspect-ratio: 4.2 / 1;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .55), transparent 72%);
}

.bottom {
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  min-height: clamp(52px, 12vh, 140px);
  padding: 0 clamp(8px, 4vw, 48px);
}

.whisper, .fortune { grid-area: 1 / 1; }

.whisper {
  margin: 0;
  max-width: 22em;
  text-align: center;
  font-family: var(--whisper);
  font-size: clamp(12px, 2.8vw, 18px);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(239, 230, 214, .88);
  transition: opacity .4s ease;
}

.fortune {
  max-width: 38rem;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .7s ease;
}

.fortune-text {
  margin: 0;
  max-width: 16em;
  font-family: var(--reading);
  font-size: clamp(28px, 5.2vh, 64px);
  line-height: 1.35;
  text-wrap: balance;
}

.stage.is-ritual .whisper,
.stage.is-reveal .whisper { opacity: 0; }
.stage.is-ritual .incantation { opacity: 1; }

.stage.is-reveal .altar {
  opacity: 0;
  visibility: hidden;
}
.stage.is-reveal .fortune {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: none;
  margin: 0;
  padding: clamp(28px, 10vh, 96px) clamp(22px, 8vw, 120px);
  background:
    radial-gradient(ellipse 48% 36% at 50% 46%, rgba(96, 32, 130, .3), transparent 70%),
    #030206;
  opacity: 1;
  visibility: visible;
  cursor: pointer;
}

.noscript {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 8vh;
  margin: 0;
  text-align: center;
  font-family: var(--reading);
}

.orb-wrap { transition: width 1s ease; }

@media (min-width: 980px) and (min-aspect-ratio: 1/1) {
  .curtain {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    width: min(24vw, 320px);
    background: linear-gradient(90deg, rgba(8, 3, 10, .72), transparent 80%);
    -webkit-mask-image: linear-gradient(90deg, #000 30%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 30%, transparent 100%);
  }
  .curtain-l { left: 0; }
  .curtain-r { right: 0; transform: scaleX(-1); }
  .whisper { font-size: 16px; letter-spacing: .28em; }
  .stage.is-reveal .fortune-text { font-size: clamp(36px, 4.6vh, 72px); }
}

@media (max-width: 520px) {
  .ring-text text { font-size: 14px; }
  .layout { padding-top: clamp(12px, 3vh, 24px); }
  .whisper { letter-spacing: .14em; }
}

@media (max-height: 700px) {
  .orb-wrap { width: min(70vw, 48vh, 420px); }
  .layout { padding-top: clamp(10px, 2vh, 20px); }
}

@media (prefers-reduced-motion: reduce) {
  .orb-wrap { transition: none; }
}
