:root {
  --bg: #0b0c13;
  --bg-deep: #05060a;
  --surface: rgba(24, 25, 34, 0.78);
  --surface-strong: #171821;
  --text: #fbf7ed;
  --text-muted: #c3bdaf;
  --gold: #d9b86c;
  --gold-bright: #f1d99a;
  --gold-dark: #8d6b2b;
  --line: rgba(233, 210, 153, 0.2);
  --focus: #f5d98e;
  --radius-card: 22px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--bg-deep);
  overscroll-behavior: none;
}

html.is-wiping,
body.is-wiping {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overflow-x: clip;
  background:
    radial-gradient(circle at 50% 20%, rgba(74, 66, 101, 0.3), transparent 36rem),
    linear-gradient(180deg, #10111b 0%, var(--bg) 48%, var(--bg-deep) 100%);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  contain: paint;
  pointer-events: none;
}

.ambient::before,
.ambient::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.ambient::before {
  inset: -28%;
  background:
    conic-gradient(from 210deg at 48% 42%, transparent 0 25%, rgba(102, 78, 148, 0.2) 34%, transparent 44% 68%, rgba(183, 138, 57, 0.12) 76%, transparent 86%),
    radial-gradient(ellipse at 52% 35%, rgba(94, 75, 139, 0.2), transparent 44%);
  filter: blur(48px);
  opacity: 0.68;
  animation: ambient-current 24s ease-in-out infinite alternate;
}

.ambient::after {
  width: 75vw;
  height: 55vh;
  right: -22vw;
  bottom: -16vh;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(197, 153, 69, 0.12), rgba(80, 60, 115, 0.07) 45%, transparent 72%);
  filter: blur(42px);
  animation: ambient-breathe 13s ease-in-out infinite alternate;
}

.ambient__halo {
  position: absolute;
  width: 20rem;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.18;
  animation: halo-drift 14s ease-in-out infinite alternate;
}

.ambient__halo--one {
  top: -8rem;
  left: -9rem;
  background: #6e5e9f;
}

.ambient__halo--two {
  right: -10rem;
  bottom: -8rem;
  background: #806531;
  animation-delay: -7s;
}

.ambient__stars {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image:
    radial-gradient(circle, rgba(255, 246, 215, 0.8) 0 0.7px, transparent 0.9px),
    radial-gradient(circle, rgba(255, 246, 215, 0.4) 0 0.6px, transparent 0.8px);
  background-position: 0 0, 38px 57px;
  background-size: 91px 91px, 127px 127px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
  animation: stars-drift 18s ease-in-out infinite alternate;
}

.app-shell {
  position: relative;
  z-index: 10;
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(28px, env(safe-area-inset-top))
    clamp(16px, 5vw, 40px)
    max(32px, env(safe-area-inset-bottom));
}

.ritual {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 24px;
}

.ritual__header {
  width: min(100%, 540px);
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-bright);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.035em;
}

h1 {
  font-size: clamp(2.35rem, 10vw, 4.25rem);
  line-height: 0.96;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.42);
}

.ritual__copy {
  max-width: 38ch;
  margin: 14px auto 0;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.loading {
  display: flex;
  min-height: 400px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.loading__orb {
  width: 14px;
  height: 14px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--gold);
  animation: loading-pulse 1.5s ease-in-out infinite;
}

.card-stage {
  position: relative;
  display: grid;
  width: 100%;
  justify-items: center;
  gap: 14px;
  margin-top: -12px;
  padding: 4px 0 2px;
  isolation: isolate;
}

.aura {
  position: absolute;
  z-index: -1;
  top: 8%;
  width: min(82vw, 400px);
  aspect-ratio: 0.82;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230, 196, 116, 0.19), rgba(96, 76, 131, 0.09) 45%, transparent 72%);
  filter: blur(22px);
  transform: scale(0.95);
  transition: transform 900ms var(--ease-out), opacity 900ms var(--ease-out);
}

.card-stage.is-revealed .aura {
  opacity: 0.92;
  transform: scale(1.12);
}

.fog-surface {
  position: relative;
  display: grid;
  width: 100%;
  max-width: 430px;
  padding: clamp(22px, 6vw, 34px);
  place-items: center;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

.card-frame {
  position: relative;
  z-index: 10;
  width: min(67vw, 292px);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid rgba(247, 224, 166, 0.5);
  border-radius: var(--radius-card);
  background: #171820;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.62),
    0 0 0 6px rgba(15, 15, 22, 0.78),
    0 0 42px rgba(213, 175, 92, 0.15);
  user-select: none;
  -webkit-user-select: none;
}

.card-frame::after {
  content: "";
  position: absolute;
  z-index: 30;
  inset: 8px;
  border: 1px solid rgba(255, 236, 189, 0.3);
  border-radius: calc(var(--radius-card) - 8px);
  pointer-events: none;
}

.card-photo,
.card-vignette {
  position: absolute;
  inset: 0;
}

.card-photo {
  z-index: 10;
  overflow: hidden;
  background: #202129;
}

.card-photo img {
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  object-fit: cover;
  filter: saturate(1.12) contrast(1.06) brightness(1.03);
  transform: scale(1.01);
  transform-origin: center;
}

.card-vignette {
  z-index: 15;
  background:
    linear-gradient(180deg, rgba(255, 239, 196, 0.06), transparent 20%, transparent 75%, rgba(15, 10, 4, 0.18)),
    radial-gradient(circle at 50% 42%, transparent 58%, rgba(8, 8, 12, 0.24) 100%);
  pointer-events: none;
}

.fog-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(136vw, 600px);
  height: min(136vw, 600px);
  cursor: grab;
  opacity: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transform: translate(-50%, -50%);
  transition: opacity 850ms var(--ease-out), filter 850ms var(--ease-out);
}

.fog-canvas.is-dissolving {
  opacity: 0;
  filter: blur(14px);
  pointer-events: none;
}

.gesture-hint {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #fffaf0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  transition: opacity 280ms ease;
}

.gesture-hint svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  animation: hand-guide 2.1s ease-in-out 2;
}

.gesture-hint.is-hidden {
  opacity: 0;
}

.progress {
  position: relative;
  z-index: 30;
  width: min(64vw, 240px);
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-bright));
  box-shadow: 0 0 12px rgba(235, 203, 123, 0.7);
  transition: width 180ms ease-out;
}

.text-button,
.primary-button,
.secondary-button {
  min-height: 48px;
  border: 0;
  cursor: pointer;
}

.text-button {
  position: relative;
  z-index: 30;
  padding: 10px 16px;
  color: var(--text-muted);
  background: transparent;
  text-decoration: underline;
  text-decoration-color: rgba(217, 184, 108, 0.38);
  text-underline-offset: 5px;
}

.text-button:hover,
.text-button:active {
  color: var(--text);
}

.reading {
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 10px auto 0;
  justify-self: stretch;
  border-top: 1px solid var(--line);
  padding: 30px clamp(8px, 3vw, 18px) 12px;
  text-align: center;
  animation: reading-enter 650ms var(--ease-out) both;
}

.reading__heading {
  text-align: center;
}

.reading h2 {
  color: var(--gold-bright);
  font-size: clamp(2.1rem, 10vw, 3.7rem);
  line-height: 1;
}

.reading__keywords {
  margin: 12px auto 0;
  color: var(--text-muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.45;
}

.reading__body {
  margin-top: 26px;
}

.reading__body > p {
  max-width: 100%;
  margin: 0;
  color: #e7e1d5;
  font-size: 1rem;
  line-height: 1.68;
  overflow-wrap: anywhere;
  word-break: normal;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 24px;
  padding: 13px 22px;
  border: 1px solid rgba(247, 222, 157, 0.55);
  border-radius: 14px;
  color: #17120a;
  font-weight: 750;
  background: linear-gradient(135deg, #f1d99a, #c99f4c);
  box-shadow: 0 12px 34px rgba(185, 139, 55, 0.18);
  text-decoration: none;
  transition: filter 180ms ease, transform 180ms ease;
}

.primary-button:hover {
  filter: brightness(1.05);
}

.primary-button:active {
  transform: scale(0.985);
}

.access-gate {
  width: min(100%, 520px);
  margin-top: 18px;
  padding: 30px clamp(12px, 4vw, 22px) 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.access-gate h2 {
  color: var(--gold-bright);
  font-size: clamp(2rem, 9vw, 3.25rem);
  line-height: 1.05;
}

.access-gate p {
  max-width: 38ch;
  margin: 16px auto 0;
  color: #e7e1d5;
  line-height: 1.65;
}

.access-gate .primary-button {
  margin-top: 24px;
}

.secondary-button {
  width: 100%;
  margin-top: 12px;
  padding: 12px 20px;
  border: 1px solid rgba(247, 222, 157, 0.45);
  border-radius: 14px;
  color: var(--gold-bright);
  background: rgba(22, 22, 31, 0.72);
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.access-gate .text-button {
  margin-top: 8px;
}

noscript {
  display: block;
  padding: 24px;
  color: white;
  text-align: center;
}

@keyframes loading-pulse {
  50% { opacity: 0.35; transform: scale(0.75); }
}

@keyframes halo-drift {
  to { transform: translate3d(32px, 22px, 0) scale(1.08); }
}

@keyframes ambient-current {
  from { transform: translate3d(-3%, -2%, 0) rotate(-4deg) scale(0.96); }
  to { transform: translate3d(4%, 3%, 0) rotate(7deg) scale(1.06); }
}

@keyframes ambient-breathe {
  from { opacity: 0.45; transform: translate3d(0, 2%, 0) scale(0.92); }
  to { opacity: 0.9; transform: translate3d(-8%, -5%, 0) scale(1.12); }
}

@keyframes stars-drift {
  from { transform: translate3d(-6px, -8px, 0) scale(1.02); opacity: 0.22; }
  to { transform: translate3d(8px, 12px, 0) scale(1.05); opacity: 0.34; }
}

@keyframes hand-guide {
  0%, 100% { transform: translateX(-12px); opacity: 0.72; }
  50% { transform: translateX(12px); opacity: 1; }
}

@keyframes reading-enter {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 44px;
  }

  .ritual {
    gap: 30px;
  }

  .card-frame {
    width: 306px;
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  .app-shell {
    width: min(100%, 980px);
    padding-top: 16px;
  }

  .ritual {
    grid-template-columns: minmax(220px, 0.8fr) minmax(220px, 1fr);
    align-items: center;
  }

  .ritual__header {
    text-align: left;
  }

  .ritual__copy {
    margin-left: 0;
  }

  .card-stage,
  .loading {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .card-frame {
    width: min(38vh, 250px);
  }

  .fog-surface {
    width: min(50vw, 340px);
    padding: 24px 36px;
  }

  .reading {
    grid-column: 1 / -1;
  }
}

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