*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --ink: #12071f;
  --paper: #f4ebff;
  --bone: #f7edff;
  --gold: #d9b8ff;
  --green: #9c7bd0;
  --moss: #1a0a2e;
  --plum: #2a1248;
  --blue: #0d1b3e;
  --rust: #5a3090;
  --line: rgba(201, 160, 255, 0.23);
  --muted: rgba(232, 213, 255, 0.72);
  --dim: #a07acc;
  --glow: rgba(201, 160, 255, 0.42);
  --glow-soft: rgba(201, 160, 255, 0.16);
  --shadow: rgba(0, 0, 0, 0.42);
}

html {
  min-height: 100%;
  background: #111;
  --scroll-shift: 0px;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--bone);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 28% 12%, rgba(103, 169, 255, 0.16), transparent 24%),
    radial-gradient(circle at 78% 22%, rgba(201, 160, 255, 0.2), transparent 28%),
    linear-gradient(135deg, #09122d 0%, var(--moss) 43%, #261244 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  margin: 0 auto;
}

.celestial-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.celestial-bg::before {
  content: "";
  position: absolute;
  inset: -18%;
  transform: translate3d(0, calc(var(--scroll-shift) * -0.16), 0);
  background:
    radial-gradient(ellipse at 16% 28%, rgba(103, 169, 255, 0.18), transparent 34%),
    radial-gradient(ellipse at 82% 12%, rgba(217, 184, 255, 0.2), transparent 30%),
    radial-gradient(ellipse at 56% 78%, rgba(255, 207, 138, 0.08), transparent 32%);
}

.star-field {
  position: absolute;
  inset: -12%;
  opacity: 0.86;
  background-repeat: repeat;
  will-change: transform;
}

.star-field-near {
  transform: translate3d(0, calc(var(--scroll-shift) * -0.32), 0);
  background-image:
    radial-gradient(circle, rgba(255, 250, 241, 0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(217, 184, 255, 0.72) 0 1px, transparent 1.6px);
  background-size: 104px 122px, 171px 149px;
  background-position: 18px 22px, 74px 51px;
}

.star-field-far {
  transform: translate3d(0, calc(var(--scroll-shift) * -0.12), 0);
  background-image:
    radial-gradient(circle, rgba(255, 250, 241, 0.56) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(103, 169, 255, 0.5) 0 1px, transparent 1.5px);
  background-size: 73px 91px, 139px 163px;
  background-position: 8px 12px, 46px 83px;
}

.planet {
  position: absolute;
  border-radius: 50%;
  box-shadow: inset -18px -18px 30px rgba(0, 0, 0, 0.3), 0 0 34px rgba(201, 160, 255, 0.16);
  will-change: transform;
}

.planet-amethyst {
  width: clamp(82px, 9vw, 138px);
  aspect-ratio: 1;
  top: 17%;
  right: 8%;
  transform: translate3d(0, calc(var(--scroll-shift) * -0.24), 0);
  background:
    linear-gradient(145deg, rgba(247, 237, 255, 0.8), transparent 28%),
    repeating-linear-gradient(18deg, rgba(255,255,255,0.12) 0 7px, transparent 7px 16px),
    linear-gradient(135deg, #815fc6, #331c64 58%, #160a2b);
}

.planet-copper {
  width: clamp(48px, 5vw, 78px);
  aspect-ratio: 1;
  top: 62%;
  left: 9%;
  transform: translate3d(0, calc(var(--scroll-shift) * -0.42), 0);
  background:
    linear-gradient(145deg, rgba(255, 237, 210, 0.74), transparent 30%),
    repeating-linear-gradient(-12deg, rgba(70, 32, 80, 0.24) 0 5px, transparent 5px 12px),
    linear-gradient(135deg, #d6a568, #7f4d7b 62%, #23113d);
}

.planet-ice {
  width: clamp(38px, 4vw, 64px);
  aspect-ratio: 1;
  top: 42%;
  right: 22%;
  transform: translate3d(0, calc(var(--scroll-shift) * -0.55), 0);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), transparent 30%),
    linear-gradient(135deg, #9ec7ff, #7b6fc9 55%, #251753);
}

.planet-ringed {
  width: clamp(68px, 7vw, 112px);
  aspect-ratio: 1;
  left: 64%;
  top: 78%;
  transform: translate3d(0, calc(var(--scroll-shift) * -0.2), 0);
  background:
    linear-gradient(145deg, rgba(255, 245, 219, 0.78), transparent 30%),
    linear-gradient(135deg, #c9a0ff, #6d4f9f 54%, #1a0a2e);
}

.planet-ringed::before {
  content: "";
  position: absolute;
  left: -42%;
  top: 42%;
  width: 184%;
  height: 20%;
  border: 2px solid rgba(244, 235, 255, 0.45);
  border-left-color: rgba(103, 169, 255, 0.32);
  border-right-color: rgba(255, 207, 138, 0.32);
  border-radius: 50%;
  transform: rotate(-14deg);
}

.hero {
  min-height: 62vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 36px;
  align-items: center;
  padding: 56px clamp(18px, 5vw, 72px) 24px;
}

.hero-copy {
  max-width: 760px;
}

.back-link {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-decoration: none;
  font-size: 0.72rem;
}

h1,
h2,
h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  margin: 0;
  color: var(--bone);
}

h1 {
  font-size: clamp(4rem, 11vw, 9.5rem);
  line-height: 0.86;
  max-width: 820px;
  color: var(--bone);
  text-shadow: 0 0 24px var(--glow), 0 0 52px var(--glow-soft);
}

h2 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.96;
}

h3 {
  font-size: 1.55rem;
}

p {
  color: var(--muted);
}

.hero p {
  max-width: 630px;
  font-size: 1.08rem;
}

.moon-orbit {
  position: relative;
  min-height: 430px;
  border-radius: 50%;
  border: 1px solid rgba(255, 250, 241, 0.15);
}

.moon-orbit::before {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 250, 241, 0.22);
}

.moon-orbit span {
  position: absolute;
  width: 72px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--bone);
  box-shadow: 0 0 45px var(--glow);
}

.moon-orbit span:nth-child(1) { left: 12%; top: 52%; }
.moon-orbit span:nth-child(2) { left: 44%; top: 9%; background: linear-gradient(90deg, var(--bone) 50%, #1a0a2e 50%); }
.moon-orbit span:nth-child(3) { right: 12%; top: 50%; background: #12071f; border: 2px solid var(--bone); }
.moon-orbit span:nth-child(4) { left: 43%; bottom: 8%; background: linear-gradient(270deg, var(--bone) 50%, #1a0a2e 50%); }

.chart-panel,
.reading-stage,
.explorer,
.history {
  margin: 24px clamp(14px, 4vw, 48px);
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--line);
  background: rgba(18, 7, 31, 0.66);
  backdrop-filter: blur(20px);
}

.panel-heading,
.stage-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.panel-heading p,
.stage-toolbar p {
  max-width: 620px;
  margin: 8px 0 0;
}

.section-toggle {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.section-toggle::after {
  content: " +";
  color: var(--gold);
}

.section-toggle[aria-expanded="true"]::after {
  content: " -";
}

.chart-panel.is-collapsed .panel-heading,
.explorer.is-collapsed .panel-heading,
.history.is-collapsed .panel-heading {
  margin-bottom: 0;
}

.chart-content[hidden],
.explorer-content[hidden],
.history-content[hidden] {
  display: none;
}

.chart-content > p {
  max-width: 620px;
  margin: 0 0 18px;
  color: var(--muted);
}

.history-content {
  display: grid;
  gap: 14px;
}

.history-content > .secondary-btn {
  justify-self: start;
}

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

.birth-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(201, 160, 255, 0.08);
}

label {
  display: grid;
  gap: 6px;
  color: rgba(255, 250, 241, 0.78);
  font-size: 0.82rem;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 250, 241, 0.22);
  background: rgba(13, 27, 62, 0.36);
  color: var(--bone);
  padding: 10px 11px;
  border-radius: 6px;
}

select {
  width: 100%;
  border: 1px solid rgba(255, 250, 241, 0.22);
  background: rgba(31, 16, 56, 0.78);
  color: var(--bone);
  padding: 10px 11px;
  border-radius: 6px;
}

input::placeholder {
  color: rgba(255, 250, 241, 0.38);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-row.compact {
  grid-template-columns: max-content;
  align-items: end;
}

.primary-btn,
.secondary-btn,
.spread-btn {
  min-height: 42px;
  border: 1px solid rgba(255, 250, 241, 0.28);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--bone);
}

.primary-btn {
  background: linear-gradient(135deg, #5a3090, #c9a0ff);
  color: #140821;
  font-weight: 700;
  border: none;
  box-shadow: 0 0 22px rgba(201, 160, 255, 0.2);
}

.secondary-btn,
.spread-btn {
  background: rgba(255, 250, 241, 0.08);
}

.spread-options {
  display: grid;
  gap: 8px;
  width: min(100%, 520px);
}

.spread-option {
  display: grid;
  grid-template-columns: minmax(150px, 190px) 1fr;
  align-items: center;
  gap: 10px;
}

.spread-option span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.spread-btn.active {
  background: var(--bone);
  color: var(--ink);
  box-shadow: 0 0 18px rgba(201, 160, 255, 0.2);
}

.chart-summary,
.comparison {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-summary strong,
.comparison strong {
  color: var(--bone);
}

.comparison {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.deck-arc {
  position: relative;
  height: clamp(420px, 58vw, 660px);
  overflow: hidden;
  border-radius: 10px;
  background:
    linear-gradient(to bottom, rgba(201, 160, 255, 0.12), rgba(201, 160, 255, 0.03)),
    radial-gradient(ellipse at 50% 80%, rgba(201, 160, 255, 0.18), transparent 42%);
  border: 1px solid var(--line);
}

.arc-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(54px, 7.6vw, 102px);
  aspect-ratio: 7 / 10;
  transform:
    translate(calc(var(--x) * 1px), calc(var(--y) * 1px))
    translate(-50%, -50%)
    rotate(var(--rot));
  border: 1px solid rgba(255, 250, 241, 0.2);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  background: #0e0e0e;
  box-shadow: 0 16px 28px var(--shadow);
}

.arc-card img,
.result-card img,
.deck-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.arc-card:hover {
  z-index: 10;
  transform:
    translate(calc(var(--x) * 1px), calc((var(--y) - 18) * 1px))
    translate(-50%, -50%)
    rotate(var(--rot));
}

.arc-card.is-drawn {
  z-index: 8;
  border-color: rgba(244, 235, 255, 0.88);
  box-shadow: 0 0 0 2px rgba(201, 160, 255, 0.35), 0 18px 34px var(--shadow);
}

.draw-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: -4px 0 18px;
}

.draw-hint {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
}

.reading-output {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 380px));
  justify-content: center;
  gap: 18px;
  margin-top: 22px;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(201, 160, 255, 0.08);
}

.result-card figure {
  margin: 0;
  aspect-ratio: 7 / 10;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 14px 24px var(--shadow);
}

.result-card-body {
  display: grid;
  gap: 8px;
}

.result-card h3 {
  margin-bottom: 4px;
}

.position-label,
.tagline {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
}

.result-card p {
  margin: 9px 0;
  line-height: 1.58;
}

.card-meaning,
.card-tailor {
  font-size: 0.98rem;
}

.card-question {
  margin: 12px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  background: rgba(201, 160, 255, 0.1);
  color: var(--bone);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.24rem;
  line-height: 1.28;
}

.card-question span {
  display: block;
  margin-bottom: 5px;
  color: var(--dim);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.reading-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.reading-actions[hidden] {
  display: none;
}

.current-spread {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 250, 241, 0.18);
  border-radius: 6px;
  padding: 8px 11px;
  color: var(--gold);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.speak-btn,
.restart-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.speak-btn {
  min-width: 92px;
}

.restart-btn {
  width: 38px;
  padding: 8px;
}

.speak-icon,
.speak-icon svg,
.restart-icon,
.restart-icon svg {
  display: block;
  width: 16px;
  height: 16px;
}

.speak-icon svg,
.restart-icon svg {
  fill: currentColor;
}

.speak-btn[data-state="playing"] {
  background: rgba(244, 235, 255, 0.18);
  border-color: rgba(244, 235, 255, 0.52);
}

.speak-btn[data-state="loading"] {
  cursor: progress;
}

.voice-picker {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.voice-picker span {
  color: var(--dim);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.voice-picker select {
  min-height: 38px;
  border: 1px solid rgba(255, 250, 241, 0.28);
  border-radius: 6px;
  background: rgba(255, 250, 241, 0.08);
  color: var(--bone);
  padding: 8px 10px;
  font: inherit;
}

.speech-status {
  min-height: 1.4em;
  margin: 10px auto 0;
  max-width: 620px;
  color: var(--gold);
  font-size: 0.86rem;
  text-align: center;
}

.generated-reading {
  max-width: 820px;
  margin: 18px auto 0;
}

.generated-reading article {
  border: 1px solid var(--line);
  background: rgba(201, 160, 255, 0.1);
  padding: clamp(16px, 3vw, 24px);
}

.generated-reading p {
  margin: 12px 0 0;
  color: rgba(247, 237, 255, 0.86);
  line-height: 1.55;
  font-size: clamp(1.02rem, 1.4vw, 1.14rem);
}

.generated-reading p:first-of-type {
  margin-top: 0;
}

.generated-reading strong {
  color: #fff8c9;
  font-weight: 700;
}

.reading-line {
  padding-left: 14px;
  border-left: 2px solid rgba(255, 248, 201, 0.5);
}

.reading-message {
  color: rgba(255, 248, 201, 0.9);
}

#card-search {
  max-width: 420px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.deck-card {
  border: 1px solid var(--line);
  background: rgba(201, 160, 255, 0.08);
  padding: 10px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.deck-card:hover,
.deck-card:focus-visible {
  border-color: rgba(244, 235, 255, 0.72);
  background: rgba(201, 160, 255, 0.14);
  outline: none;
  transform: translateY(-2px);
}

.deck-card.is-drawn {
  border-color: rgba(244, 235, 255, 0.88);
  box-shadow: inset 0 0 0 1px rgba(201, 160, 255, 0.36);
}

.deck-card figure {
  margin: 0 0 10px;
  aspect-ratio: 7 / 10;
  overflow: hidden;
  border-radius: 6px;
}

.deck-card h3 {
  font-size: 1.22rem;
}

.deck-card p {
  font-size: 0.84rem;
  margin: 6px 0 0;
}

.deck-question {
  margin-top: 8px;
  padding: 9px 10px;
  border-left: 2px solid var(--gold);
  background: rgba(201, 160, 255, 0.1);
  color: var(--bone);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.02rem;
  line-height: 1.24;
}

.deck-question span {
  display: block;
  margin-bottom: 4px;
  color: var(--dim);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-entry {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(201, 160, 255, 0.08);
}

.history-entry strong {
  color: var(--gold);
}

#yt-player {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  border: 0;
  pointer-events: none;
}

#music-controls {
  position: fixed;
  right: 1.75rem;
  bottom: 1.75rem;
  z-index: 200;
  display: flex;
  gap: 0.5rem;
}

.music-btn {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 160, 255, 0.28);
  border-radius: 50%;
  background: rgba(201, 160, 255, 0.08);
  color: var(--gold);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  backdrop-filter: blur(12px);
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.music-btn:hover {
  background: rgba(201, 160, 255, 0.18);
  border-color: rgba(201, 160, 255, 0.5);
}

.music-btn.is-ducked {
  opacity: 0.68;
}

.site-footer {
  margin: 0 clamp(14px, 4vw, 48px) 34px;
}

.site-footer a {
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--bone);
}

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

  .moon-orbit {
    min-height: 300px;
  }

  .panel-heading,
  .stage-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .spread-options {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .hero {
    padding-top: 36px;
  }

  .planet-amethyst {
    right: -18px;
  }

  .planet-ringed {
    left: 58%;
  }

  .field-row,
  .field-row.compact {
    grid-template-columns: 1fr;
  }

  .spread-option {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .result-card {
    max-width: 360px;
    margin: 0 auto;
  }

  .result-card figure {
    width: 100%;
  }
}
