:root {
  color-scheme: dark;
  --bg: #050812;
  --panel: rgba(12, 15, 34, 0.78);
  --panel-2: rgba(9, 12, 27, 0.68);
  --panel-border: rgba(221, 183, 96, 0.28);
  --gold: #d8b46b;
  --gold-light: #f4dfaa;
  --violet: #9e7cff;
  --violet-soft: rgba(158, 124, 255, 0.18);
  --text: #f6f0e6;
  --muted: #c5bfd6;
  --muted-2: #8f8aa7;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(rgba(4, 6, 16, 0.38), rgba(4, 6, 16, 0.7)),
    url("assets/ritual_table_bg.webp?v=1147") center top / cover no-repeat fixed,
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 10%, rgba(127, 91, 255, 0.18), transparent 28%),
    radial-gradient(circle at 85% 40%, rgba(215, 179, 102, 0.13), transparent 28%);
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  position: relative;
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 20px 14px 30px;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
}

.hero-panel {
  text-align: center;
  padding: 20px 20px 18px;
  margin-bottom: 14px;
}
.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.34em;
  font-size: 12px;
  color: var(--gold);
}
.eyebrow.small { font-size: 10px; margin-bottom: 6px; }
h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 500;
}
.subtitle {
  max-width: 520px;
  margin: 12px auto 0;
  color: var(--muted);
  line-height: 1.5;
}

.setup-panel, .interpretation-panel { padding: 18px; }
.reading-meta {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.reading-meta p { margin: 0; }
#questionPreview { color: var(--muted); line-height: 1.45; }
.section-head h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-weight: 500;
}
.section-head p {
  margin: 6px 0 0;
  color: var(--muted-2);
  font-size: 14px;
}
.section-gap { margin-top: 18px; }
.compact { margin-bottom: 12px; }
label {
  display: block;
  color: var(--gold-light);
  margin: 16px 0 8px;
  font-size: 14px;
}
textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.11);
  background: rgba(7, 10, 26, 0.66);
  color: var(--text);
  padding: 14px;
  outline: none;
}
textarea:focus {
  border-color: rgba(158,124,255,0.7);
  box-shadow: 0 0 0 3px rgba(158,124,255,0.12);
}
.guide-block {
  margin-top: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  padding: 12px 14px;
}
.guide-block summary {
  color: var(--gold-light);
  cursor: pointer;
  font-weight: 600;
}
.guide-block ul {
  margin: 10px 0 0 18px;
  padding: 0;
  color: var(--muted);
  line-height: 1.55;
}
.examples { margin-top: 14px; }
.examples-title {
  display: block;
  color: var(--gold-light);
  font-size: 14px;
  margin-bottom: 10px;
}
.example-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.example-chip {
  border: 1px solid rgba(216,180,107,0.25);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}
.spread-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.spread-option, .secondary, .ghost {
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.11);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  padding: 12px 14px;
}
.spread-option {
  min-height: 82px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.spread-option strong {
  color: var(--text);
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 500;
}
.spread-option span {
  color: var(--muted-2);
  font-size: 12px;
}
.spread-option.active {
  color: var(--text);
  border-color: var(--gold);
  background: rgba(216,180,107,0.12);
  box-shadow: inset 0 0 0 1px rgba(243,216,155,0.08);
}
.spread-option.active span { color: var(--gold-light); }
.limit-note {
  margin: 14px 2px -2px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.primary {
  width: 100%;
  margin-top: 18px;
  border: 0;
  border-radius: 16px;
  padding: 15px 18px;
  color: #171326;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 12px 30px rgba(216,180,107,0.22);
}
.secondary {
  width: 100%;
  margin-top: 10px;
}
.ghost { white-space: nowrap; }

.reading-shell.hidden, .hidden { display: none; }

.table-stage {
  position: relative;
  min-height: 530px;
  border-radius: 26px;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(216,180,107,0.22);
  background:
    linear-gradient(rgba(5,8,18,0.12), rgba(5,8,18,0.08)),
    url("assets/ritual_table_bg.webp?v=1147") center center / cover no-repeat;
}
.table-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(3,4,10,0.1) 0%, rgba(3,4,10,0.08) 40%, rgba(3,4,10,0.18) 100%);
}
.cards-stage {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  width: min(94%, 680px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-end;
  gap: 38px 10px;
  z-index: 2;
}
.cards-stage.spread-1 .tarot-card-wrap { width: min(48vw, 170px); }
.cards-stage.spread-3 .tarot-card-wrap { width: min(27vw, 148px); }
.cards-stage.spread-5 .tarot-card-wrap,
.cards-stage.spread-6 .tarot-card-wrap {
  flex: 0 0 calc((100% - 24px) / 3);
  max-width: 126px;
}
.tarot-card-wrap {
  position: relative;
  perspective: 1200px;
  padding-bottom: 31px;
}
.tarot-card {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  cursor: pointer;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(243,216,155,0.4);
  background: #100d21;
  transition: transform .28s ease, box-shadow .28s ease;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.42));
  -webkit-tap-highlight-color: transparent;
}
.tarot-card.is-revealing {
  transform: translateY(-3px) scale(.985);
  cursor: progress;
}
.tarot-card.is-revealed,
.tarot-card.is-image-error {
  transform: translateY(-6px);
  box-shadow: 0 0 0 1px rgba(243,216,155,0.2);
}
.tarot-card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 1;
  transform: scale(1);
  transition: opacity .18s ease, transform .24s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.tarot-card.is-revealing .tarot-card-image {
  opacity: .42;
  transform: scale(.975);
}
.tarot-card-image-error {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--gold-light);
  background: linear-gradient(145deg, #17102f, #080b1c);
}
.tarot-card.is-image-error .tarot-card-image {
  display: none;
}
.tarot-card.is-image-error .tarot-card-image-error {
  display: grid;
}
.reading-question {
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  color: #f4e7c4;
  background: rgba(216,180,107,0.08);
}
.card-position-label {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--gold-light);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.table-stage.large-spread { min-height: 700px; }
.table-hint {
  position: absolute;
  left: 50%;
  bottom: 1.4%;
  transform: translateX(-50%);
  z-index: 2;
  width: min(92%, 580px);
  text-align: center;
  font-size: 13px;
  color: #ece4cf;
  background: rgba(6,8,18,0.52);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 10px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.steps {
  display: grid;
  gap: 12px;
}
.step-card {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--panel-2);
  padding: 14px;
  animation: fadeUp .35s ease both;
}
.step-title {
  margin: 0 0 8px;
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-size: 20px;
}
.step-subtitle {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--violet);
  font-size: 13px;
}
.step-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}
.summary-box {
  margin-top: 14px;
  border-radius: 16px;
  border: 1px solid rgba(216,180,107,0.22);
  background: rgba(216,180,107,0.08);
  padding: 14px;
  color: var(--text);
  line-height: 1.6;
}
.footer-note {
  text-align: center;
  padding: 14px 10px 0;
  color: rgba(255,255,255,0.72);
  font-size: 12px;
}

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

@media (max-width: 640px) {
  .app-shell { padding: 14px 10px 26px; }
  .spread-grid { grid-template-columns: 1fr; }
  .spread-option { min-height: 68px; }
  .table-stage { min-height: 520px; }
  .table-stage.large-spread { min-height: 690px; }
  .cards-stage { bottom: 9%; gap: 32px 7px; }
  .cards-stage.spread-3 .tarot-card-wrap { width: min(29vw, 122px); }
  .cards-stage.spread-5 .tarot-card-wrap,
  .cards-stage.spread-6 .tarot-card-wrap {
    flex-basis: calc((100% - 14px) / 3);
    max-width: 108px;
  }
  .cards-stage.spread-1 .tarot-card-wrap { width: min(50vw, 160px); }
  .card-position-label { font-size: 10px; line-height: 1.15; }
  .reading-meta { flex-direction: column; align-items: stretch; }
}
