:root {
  --midnight: #0b0b1e;
  --abyss: #120e26;
  --violet: #2a174d;
  --gold: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.38);
  --moon: #f5f5f7;
  --mist: #a6e3d7;
  --ember: #d88c9a;
  --ink: #070710;
  --panel: rgba(13, 12, 30, 0.74);
  --line: rgba(245, 245, 247, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--moon);
  background:
    radial-gradient(circle at 20% 10%, rgba(166, 227, 215, 0.08), transparent 32rem),
    radial-gradient(circle at 82% 14%, rgba(216, 140, 154, 0.08), transparent 28rem),
    linear-gradient(135deg, var(--midnight), var(--abyss) 58%, #080713);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  touch-action: manipulation;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.cosmos,
.cosmos::before,
.cosmos::after,
.sacred-lines {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.cosmos {
  z-index: 0;
  opacity: 0.9;
  background-image:
    radial-gradient(circle, rgba(245, 245, 247, 0.8) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(212, 175, 55, 0.9) 0 1px, transparent 1.3px),
    radial-gradient(circle, rgba(166, 227, 215, 0.58) 0 1px, transparent 1.2px);
  background-position:
    0 0,
    42px 72px,
    90px 24px;
  background-size:
    148px 148px,
    214px 214px,
    286px 286px;
  animation: star-drift 30s linear infinite;
}

.cosmos::before {
  content: "";
  background:
    radial-gradient(circle at 50% 20%, rgba(245, 245, 247, 0.16), transparent 13rem),
    radial-gradient(circle at 35% 70%, rgba(212, 175, 55, 0.1), transparent 18rem);
  mix-blend-mode: screen;
  opacity: 0.72;
}

.cosmos::after {
  content: "";
  background-image:
    radial-gradient(circle, rgba(245, 245, 247, 0.55) 0 1px, transparent 1.2px),
    radial-gradient(circle, rgba(212, 175, 55, 0.65) 0 1px, transparent 1.2px);
  background-position:
    24px 32px,
    80px 110px;
  background-size:
    340px 340px,
    460px 460px;
  animation: star-breathe 4.8s ease-in-out infinite alternate;
}

.sacred-lines {
  z-index: 1;
  opacity: 0.5;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(212, 175, 55, 0.08) 50%, transparent 50.2%),
    linear-gradient(0deg, transparent 49.8%, rgba(212, 175, 55, 0.07) 50%, transparent 50.2%),
    repeating-conic-gradient(from 45deg at 50% 42%, transparent 0deg 42deg, rgba(212, 175, 55, 0.055) 43deg 44deg, transparent 45deg 90deg);
  mask-image: radial-gradient(circle at 50% 35%, #000 0 29rem, transparent 48rem);
  animation: sacred-pulse 5.6s ease-in-out infinite;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  color: var(--moon);
  background: transparent;
  cursor: pointer;
  letter-spacing: 0;
  text-align: left;
}

.brand-sigil {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
  box-shadow: 0 0 28px rgba(212, 175, 55, 0.16);
}

.stage {
  min-height: calc(100vh - 116px);
  display: grid;
  align-items: center;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 430px);
  gap: clamp(32px, 7vw, 86px);
  align-items: center;
  padding: clamp(34px, 7vw, 78px) 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: rgba(212, 175, 55, 0.86);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-title {
  max-width: 780px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 9vw, 7.25rem);
  font-weight: 500;
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 660px;
  margin: 26px 0 0;
  color: rgba(245, 245, 247, 0.74);
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.9;
}

.hero-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero-actions {
  margin-top: 34px;
}

.mystic-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: linear-gradient(135deg, #f3da87, var(--gold) 48%, #b98b21);
  box-shadow:
    0 12px 34px rgba(212, 175, 55, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
  font-weight: 700;
  letter-spacing: 0;
  transition:
    transform 220ms ease,
    box-shadow 220ms ease,
    filter 220ms ease;
}

.mystic-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
  box-shadow:
    0 16px 48px rgba(212, 175, 55, 0.27),
    0 0 24px rgba(212, 175, 55, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.mystic-button:active {
  transform: translateY(0);
}

.mystic-button.secondary {
  color: var(--moon);
  background: rgba(245, 245, 247, 0.06);
  border-color: rgba(245, 245, 247, 0.16);
  box-shadow: inset 0 1px 0 rgba(245, 245, 247, 0.08);
}

.mystic-button.secondary:hover {
  border-color: rgba(212, 175, 55, 0.44);
  box-shadow:
    0 12px 34px rgba(212, 175, 55, 0.1),
    inset 0 1px 0 rgba(245, 245, 247, 0.12);
}

.mystic-button.ghost {
  min-height: 40px;
  color: rgba(245, 245, 247, 0.82);
  background: transparent;
  border-color: rgba(245, 245, 247, 0.13);
  box-shadow: none;
}

.mystic-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.hero-oracle {
  position: relative;
  min-height: 520px;
  display: grid;
  width: 100%;
  overflow: hidden;
  place-items: center;
}

.hero-oracle::before {
  content: "";
  position: absolute;
  width: min(88vw, 430px);
  aspect-ratio: 1;
  border: 1px solid rgba(212, 175, 55, 0.18);
  transform: rotate(45deg);
  animation: sacred-pulse 5s ease-in-out infinite;
}

.hero-oracle::after {
  content: "";
  position: absolute;
  width: min(78vw, 330px);
  aspect-ratio: 1;
  border: 1px solid rgba(245, 245, 247, 0.1);
  border-radius: 50%;
  animation: slow-spin 38s linear infinite;
}

.floating-card {
  position: absolute;
  width: clamp(118px, 17vw, 168px);
  aspect-ratio: 0.66;
  transform-style: preserve-3d;
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.42));
}

.floating-card:nth-child(1) {
  transform: translate(-74px, 12px) rotate(-12deg);
  animation: float-card-a 4.8s ease-in-out infinite;
}

.floating-card:nth-child(2) {
  transform: translate(58px, -30px) rotate(9deg);
  animation: float-card-b 5.4s ease-in-out infinite;
}

.floating-card:nth-child(3) {
  transform: translate(2px, 78px) rotate(0deg);
  animation: float-card-c 6s ease-in-out infinite;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 32px;
}

.mode-card,
.result-panel,
.ritual-panel {
  border: 1px solid rgba(245, 245, 247, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(245, 245, 247, 0.075), rgba(245, 245, 247, 0.025)),
    rgba(10, 10, 24, 0.52);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(245, 245, 247, 0.08);
  backdrop-filter: blur(18px);
}

.mode-card {
  min-height: 256px;
  padding: 24px;
  text-align: left;
  transition:
    transform 240ms ease,
    border-color 240ms ease,
    box-shadow 240ms ease;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow:
    0 28px 78px rgba(0, 0, 0, 0.34),
    0 0 38px rgba(212, 175, 55, 0.12),
    inset 0 1px 0 rgba(245, 245, 247, 0.11);
}

.mode-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.07);
}

.screen-heading {
  max-width: 780px;
  margin: 0 auto;
  text-align: center;
}

.screen-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  font-weight: 500;
  line-height: 1.03;
}

.screen-heading p {
  max-width: 650px;
  margin: 16px auto 0;
  color: rgba(245, 245, 247, 0.68);
  line-height: 1.8;
}

.ritual-panel {
  margin-top: 28px;
  padding: clamp(18px, 3vw, 28px);
}

.spread-area {
  display: grid;
  grid-template-columns: repeat(var(--slot-count), minmax(0, 1fr));
  gap: clamp(12px, 3vw, 24px);
  width: min(760px, 100%);
  margin: 0 auto 28px;
  align-items: start;
}

.oracle-slot {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 0;
}

.slot-card {
  width: clamp(116px, 21vw, 172px);
  aspect-ratio: 0.66;
  border: 1px dashed rgba(212, 175, 55, 0.28);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: rgba(245, 245, 247, 0.42);
  background: rgba(245, 245, 247, 0.035);
}

.slot-label {
  min-height: 24px;
  color: rgba(212, 175, 55, 0.82);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-align: center;
}

.deck-wrap {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.deck-fan {
  position: relative;
  width: min(920px, 100%);
  height: 242px;
}

.deck-card {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: clamp(74px, 10vw, 104px);
  aspect-ratio: 0.66;
  border: 0;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  background: transparent;
  transform:
    translateX(calc(-50% + var(--x)))
    translateY(var(--y))
    rotate(var(--rot));
  transform-origin: 50% 120%;
  transition:
    transform 260ms ease,
    filter 260ms ease,
    opacity 220ms ease;
  animation: shuffle-in 950ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: var(--delay);
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.28));
}

.deck-card:hover,
.deck-card:focus-visible {
  z-index: 20;
  outline: 0;
  transform:
    translateX(calc(-50% + var(--x)))
    translateY(calc(var(--y) - 18px))
    rotate(var(--rot))
    scale(1.055);
  filter:
    drop-shadow(0 20px 28px rgba(0, 0, 0, 0.38))
    drop-shadow(0 0 16px rgba(212, 175, 55, 0.42));
}

.deck-card.picked {
  pointer-events: none;
  opacity: 0;
}

.moving-card {
  z-index: 999;
  pointer-events: none;
  transform-origin: top left;
}

.tarot-card,
.oracle-card {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  perspective: 1100px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  transform-style: preserve-3d;
  transition: transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
}

.oracle-card.is-revealed .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.46);
  border-radius: 8px;
  backface-visibility: hidden;
  background: #0b0b1e;
}

.card-back {
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 0 0 1px rgba(245, 245, 247, 0.08),
    inset 0 0 46px rgba(212, 175, 55, 0.12);
  background:
    linear-gradient(155deg, rgba(212, 175, 55, 0.1), transparent 26%),
    radial-gradient(circle at 50% 38%, rgba(212, 175, 55, 0.16), transparent 42%),
    linear-gradient(160deg, #171235, #080715 64%, #171126);
}

.card-back::before,
.card-back::after {
  content: "";
  position: absolute;
  inset: 9%;
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: 6px;
}

.card-back::after {
  inset: 15%;
  border-color: rgba(245, 245, 247, 0.12);
  transform: rotate(45deg);
}

.back-sigil {
  position: relative;
  z-index: 1;
  width: 72%;
  color: var(--gold);
  filter: drop-shadow(0 0 9px rgba(212, 175, 55, 0.28));
}

.back-sigil line,
.back-sigil circle,
.back-sigil path,
.back-sigil polygon {
  vector-effect: non-scaling-stroke;
}

.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #f8f1db, #ddcfa6);
}

.card-front img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-front.reversed img {
  transform: rotate(180deg);
}

.oracle-card {
  filter:
    drop-shadow(0 24px 30px rgba(0, 0, 0, 0.34))
    drop-shadow(0 0 18px rgba(212, 175, 55, 0.13));
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 24px;
  align-items: start;
  margin-top: 28px;
}

.reading-spread {
  --slot-count: 1;
  margin: 0;
}

.reading-spread.three {
  --slot-count: 3;
}

.result-panel {
  padding: clamp(20px, 3vw, 28px);
}

.reading-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 4vw, 2.55rem);
  font-weight: 500;
}

.oracle-text {
  min-height: 220px;
  margin-top: 18px;
  color: rgba(245, 245, 247, 0.82);
  font-size: 1rem;
  line-height: 1.95;
  white-space: pre-wrap;
}

.oracle-text::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1.08em;
  margin-left: 3px;
  vertical-align: -0.17em;
  background: var(--gold);
  animation: cursor-blink 850ms steps(2, start) infinite;
}

.is-typed .oracle-text::after {
  display: none;
}

.mini-note {
  color: rgba(245, 245, 247, 0.56);
  font-size: 0.84rem;
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(340px, calc(100vw - 36px));
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--moon);
  background: rgba(8, 8, 19, 0.86);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
  animation: toast-rise 260ms ease both;
}

@keyframes star-drift {
  from {
    background-position:
      0 0,
      42px 72px,
      90px 24px;
  }
  to {
    background-position:
      148px 148px,
      256px 286px,
      376px 310px;
  }
}

@keyframes star-breathe {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 0.8;
  }
}

@keyframes sacred-pulse {
  0%,
  100% {
    opacity: 0.34;
  }
  50% {
    opacity: 0.68;
  }
}

@keyframes slow-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes float-card-a {
  50% {
    transform: translate(-78px, -8px) rotate(-8deg);
  }
}

@keyframes float-card-b {
  50% {
    transform: translate(64px, -48px) rotate(13deg);
  }
}

@keyframes float-card-c {
  50% {
    transform: translate(4px, 58px) rotate(-3deg);
  }
}

@keyframes shuffle-in {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px) rotate(0deg) scale(0.9);
  }
  46% {
    opacity: 1;
    transform: translateX(calc(-50% + var(--shuffle-x))) translateY(-42px) rotate(var(--shuffle-rot)) scale(1.04);
  }
  100% {
    opacity: 1;
    transform:
      translateX(calc(-50% + var(--x)))
      translateY(var(--y))
      rotate(var(--rot));
  }
}

@keyframes cursor-blink {
  50% {
    opacity: 0;
  }
}

@keyframes toast-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .hero-oracle {
    min-height: 410px;
    order: -1;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .result-grid {
    gap: 18px;
  }

  .reading-spread {
    width: 100%;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .stage {
    min-height: calc(100vh - 86px);
  }

  .hero-title {
    font-size: clamp(2.75rem, 17vw, 4.7rem);
  }

  .hero-copy {
    line-height: 1.72;
  }

  .hero-oracle {
    min-height: 330px;
  }

  .floating-card {
    width: 112px;
  }

  .mode-card {
    min-height: 220px;
    padding: 20px;
  }

  .spread-area {
    gap: 10px;
  }

  .slot-card {
    width: clamp(86px, 29vw, 124px);
  }

  .deck-wrap {
    min-height: 230px;
  }

  .deck-fan {
    height: 222px;
  }

  .deck-card {
    width: clamp(58px, 16vw, 76px);
    bottom: 28px;
  }

  .reading-spread.three {
    gap: 7px;
  }

  .reading-spread.three .slot-label {
    font-size: 0.72rem;
  }

  .action-row,
  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .mystic-button {
    width: 100%;
  }
}

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