:root {
  --night: #0e0a18;
  --plum: #1d1330;
  --plum-2: #2a1c44;
  --veil: rgba(255, 244, 225, 0.045);
  --veil-2: rgba(255, 244, 225, 0.08);
  --line: rgba(217, 178, 111, 0.28);
  --gold: #d9b26f;
  --gold-hi: #f0d49a;
  --text: #efe6d6;
  --muted: #a99db9;
  --rose: #d295a8;
  --sage: #9fbfa6;
  --danger: #e59a8c;
  --radius: 14px;
  --display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --body: 'Jost', 'Avenir Next', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, var(--plum-2) 0%, var(--plum) 38%, var(--night) 75%) fixed, var(--night);
  color: var(--text);
  font: 300 17px/1.65 var(--body);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; border-radius: 6px; }

/* ── starfield ─────────────────────────────────────────────── */
.sky {
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 12%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 33% 64%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 44%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 82%, #fff5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 8% 76%, #f0d49a88 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 30%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 93% 88%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 46%, #fff5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 64% 54%, #f0d49a77 50%, transparent 51%);
  background-size: 420px 420px;
  animation: twinkle 7s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }

/* ── masthead ──────────────────────────────────────────────── */
.masthead { text-align: center; padding: 40px 16px 8px; }
.phases { display: flex; justify-content: center; gap: 12px; margin-bottom: 14px; }
.phase { width: 12px; height: 12px; border-radius: 50%; }
.p1 { box-shadow: inset -4px 0 0 0 var(--gold); }
.p2 { box-shadow: inset -7px 0 0 0 var(--gold); }
.p3 { background: var(--gold); box-shadow: 0 0 14px #d9b26f88; width: 14px; height: 14px; margin-top: -1px; }
.p4 { box-shadow: inset 7px 0 0 0 var(--gold); }
.p5 { box-shadow: inset 4px 0 0 0 var(--gold); }
h1 { margin: 0; font: 500 clamp(40px, 9vw, 64px)/1 var(--display); letter-spacing: .02em; }
.brand { color: var(--gold-hi); text-decoration: none; text-shadow: 0 0 30px #d9b26f40; }
.tagline { margin: 10px 0 0; font: italic 500 20px/1.3 var(--display); color: var(--muted); }

/* ── steps ─────────────────────────────────────────────────── */
.steps ol {
  list-style: none; display: flex; justify-content: center; flex-wrap: wrap;
  gap: 6px 18px; padding: 0 16px; margin: 22px auto 8px; font-size: 13px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.steps li { display: flex; align-items: center; gap: 7px; opacity: .55; }
.steps li span {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 11px; letter-spacing: 0;
}
.steps li.done { opacity: .85; }
.steps li.current { opacity: 1; color: var(--gold-hi); }
.steps li.current span { background: var(--gold); color: var(--night); border-color: var(--gold); }

main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 40px; outline: none; }

/* ── shared ────────────────────────────────────────────────── */
.view-title { text-align: center; margin: 22px 0 6px; font: 500 clamp(28px, 6vw, 38px)/1.15 var(--display); color: var(--text); }
.view-sub { text-align: center; margin: 0 auto 26px; max-width: 560px; color: var(--muted); }
.panel { background: var(--veil); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.ornament { display: flex; align-items: center; gap: 14px; justify-content: center; color: var(--gold); margin: 34px 0 16px; }
.ornament::before, .ornament::after { content: ''; height: 1px; flex: 0 1 120px; background: linear-gradient(90deg, transparent, var(--line)); }
.ornament::after { transform: scaleX(-1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 26px; border-radius: 999px; border: 1px solid var(--gold);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: var(--night);
  font-weight: 500; letter-spacing: .06em; transition: transform .15s ease, opacity .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--gold-hi); }
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 26px; }

/* ── step 1: spreads ───────────────────────────────────────── */
.spread-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.spread-choice {
  text-align: left; background: var(--veil); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: grid; gap: 10px; align-content: start; transition: border-color .2s, background .2s, transform .2s;
}
.spread-choice:hover { background: var(--veil-2); transform: translateY(-2px); }
.spread-choice[aria-pressed='true'] { border-color: var(--gold); background: var(--veil-2); box-shadow: 0 0 0 1px var(--gold) inset; }
.spread-choice h3 { margin: 0; font: 600 24px/1.1 var(--display); color: var(--gold-hi); }
.spread-choice p { margin: 0; color: var(--muted); font-size: 15px; }
.mini { display: grid; gap: 3px; justify-content: start; height: 104px; align-content: center; grid-auto-rows: 22px; }
.mini i { width: 14px; height: 22px; border: 1px solid var(--gold); border-radius: 3px; background: #d9b26f22; }
.mini i.rot { transform: rotate(90deg); }

/* ── step 2: board + deck ──────────────────────────────────── */
.board {
  display: grid; gap: 10px; justify-content: center; margin: 0 auto 8px;
  grid-template-columns: repeat(var(--cols), clamp(52px, calc((100vw - 32px - (var(--cols) - 1) * 10px) / var(--cols)), 118px));
}
.slot {
  position: relative; aspect-ratio: 300 / 504; border-radius: 9px;
  border: 1px dashed var(--line); background: var(--veil);
  display: grid; place-items: center; text-align: center; padding: 6px; color: var(--muted);
  font-size: 12px; line-height: 1.25;
}
.slot .num { display: block; font: 600 22px/1 var(--display); color: var(--gold); margin-bottom: 4px; }
.slot.next { border-color: var(--gold); border-style: solid; box-shadow: 0 0 18px #d9b26f33; color: var(--text); }
.slot.filled { border: none; padding: 0; background: none; }
.slot img, .card-img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; box-shadow: 0 6px 20px #0008; }
.slot button.card-btn { all: unset; display: block; width: 100%; height: 100%; cursor: pointer; border-radius: 9px; }
.reversed-img { transform: rotate(180deg); }
.slot.crossing { z-index: 2; }
.slot.crossing.filled img { transform: rotate(90deg) scale(.82); }
.slot.crossing.filled img.reversed-img { transform: rotate(270deg) scale(.82); }
.slot.crossing:not(.filled) { transform: rotate(90deg) scale(.82); }
.slot.crossing:not(.filled) > span { transform: rotate(-90deg); }

.placed-list { list-style: none; padding: 0; margin: 18px auto 0; max-width: 620px; display: grid; gap: 8px; }
.placed-list li {
  display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 10px; background: var(--veil); border: 1px solid transparent;
}
.placed-list li.empty { color: var(--muted); border: 1px dashed var(--line); background: none; }
.placed-list .n { font: 600 20px/1 var(--display); color: var(--gold); text-align: center; }
.placed-list .pos { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.placed-list .nm { font: 600 19px/1.2 var(--display); }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px;
  background: none; padding: 6px 12px 6px 6px; font-size: 13px; color: var(--muted); min-height: 36px;
}
.toggle::before {
  content: ''; width: 30px; height: 18px; border-radius: 999px; background: #ffffff1a;
  box-shadow: inset 2px 0 0 0 transparent; transition: background .2s;
  background-image: radial-gradient(circle at 9px 50%, var(--muted) 6px, transparent 7px);
}
.toggle[aria-pressed='true'] { color: var(--rose); border-color: var(--rose); }
.toggle[aria-pressed='true']::before { background-color: #d295a855; background-image: radial-gradient(circle at 21px 50%, var(--rose) 6px, transparent 7px); }
.remove { border: none; background: none; color: var(--muted); font-size: 22px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; }
.remove:hover { color: var(--danger); background: var(--veil); }

.deck-tools { position: sticky; top: 0; z-index: 5; padding: 12px 0; margin-top: 18px;
  background: rgba(14, 10, 24, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid var(--line); background: none; border-radius: 999px; padding: 6px 14px;
  font-size: 14px; color: var(--muted); min-height: 36px;
}
.tab[aria-selected='true'] { background: var(--gold); color: var(--night); border-color: var(--gold); }
.search {
  width: 100%; min-height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: #00000040; outline: none;
}
.search:focus { border-color: var(--gold); }
.search::placeholder { color: var(--muted); }
.hint { min-height: 1.6em; margin: 4px 0 0; font-size: 14px; color: var(--rose); text-align: center; }

.deck { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); margin-top: 6px; }
.deck-card {
  border: none; padding: 0; background: none; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.2;
  transition: transform .15s ease;
}
.deck-card img { aspect-ratio: 300 / 504; width: 100%; border-radius: 6px; margin-bottom: 5px; box-shadow: 0 3px 10px #0007; }
.deck-card:hover:not(:disabled) { transform: translateY(-3px); color: var(--text); }
.deck-card:disabled { opacity: .28; cursor: default; }
.deck-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 30px 0; }

.sticky-go {
  position: sticky; bottom: 0; z-index: 6; display: flex; justify-content: center; gap: 10px;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); margin-top: 18px;
  background: linear-gradient(0deg, var(--night) 70%, transparent);
}

/* ── step 3: topic ─────────────────────────────────────────── */
.topic-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 860px; margin: 0 auto; }
.topic-grid .topic { flex: 0 1 158px; }
.topic {
  border: 1px solid var(--line); background: var(--veil); border-radius: var(--radius); padding: 18px 14px;
  display: grid; gap: 4px; justify-items: center; text-align: center; transition: transform .2s, background .2s;
}
.topic:hover { transform: translateY(-2px); background: var(--veil-2); }
.topic .glyph { font-size: 28px; color: var(--gold); line-height: 1; font-family: var(--display); }
.topic strong { font: 600 22px/1.2 var(--display); }
.topic small { color: var(--muted); font-size: 13px; line-height: 1.35; }

/* ── step 4: reading ───────────────────────────────────────── */
.notice { text-align: center; font-size: 14px; color: var(--muted); margin: 0 auto 6px; max-width: 620px; }
.notice strong { color: var(--gold); font-weight: 500; }
.reveal { perspective: 900px; }
.reveal .slot.filled img { animation: flip .9s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i) * 140ms); }
@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } }
.reveal .slot.filled img.reversed-img { animation-name: flip-rev; }
@keyframes flip-rev { from { transform: rotate(180deg) rotateY(90deg); opacity: 0; } }
.reveal .slot.crossing.filled img { animation: none; }

.card-readings { display: grid; gap: 16px; }
.card-reading { display: grid; grid-template-columns: 92px 1fr; gap: 18px; align-items: start; }
.card-reading .card-img { width: 92px; height: auto; aspect-ratio: 300 / 504; object-fit: cover; }
.card-reading .pos { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.card-reading .prompt { font-style: italic; text-transform: none; letter-spacing: 0; color: var(--muted); font-family: var(--display); font-size: 16px; }
.card-reading h3 { margin: 2px 0 6px; font: 600 26px/1.15 var(--display); }
.card-reading h3 em { font-size: 17px; color: var(--rose); font-weight: 500; }
.card-reading p { margin: 8px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.advice-line { color: var(--gold-hi); font-style: italic; font-family: var(--display); font-size: 19px; line-height: 1.4; }

.links { display: grid; gap: 12px; }
.link { padding: 14px 18px; border-left: 2px solid var(--gold); background: var(--veil); border-radius: 0 10px 10px 0; }
.link.dignity { border-left-color: var(--sage); }
.link h4 { margin: 0 0 4px; font: 600 19px/1.25 var(--display); color: var(--gold-hi); }
.link.dignity h4 { color: var(--sage); }
.link p { margin: 0; }

.message {
  position: relative; text-align: center; padding: 34px 24px; border-radius: 18px;
  border: 1px solid var(--gold); background: radial-gradient(ellipse at top, #d9b26f1f, transparent 70%), var(--veil);
  box-shadow: 0 0 60px #d9b26f1a;
}
.message h3 { margin: 0 0 14px; font: 500 30px/1.15 var(--display); color: var(--gold-hi); }
.message p { max-width: 640px; margin: 0 auto 14px; font-size: 18px; }
.message .final { font: italic 500 22px/1.45 var(--display); color: var(--gold-hi); margin-bottom: 0; }

h2.section { text-align: center; margin: 0 0 16px; font: 500 28px/1.2 var(--display); color: var(--text); }

/* ── footer ────────────────────────────────────────────────── */
.footer { max-width: 760px; margin: 30px auto 0; padding: 28px 16px 40px; text-align: center; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.footer strong { color: var(--gold); font-weight: 500; }
.credit { font-size: 12.5px; opacity: .8; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .board { gap: 7px; }
  .card-reading { grid-template-columns: 70px 1fr; gap: 14px; }
  .card-reading .card-img { width: 70px; }
  .placed-list li { grid-template-columns: 24px 1fr auto auto; gap: 6px; padding: 8px; }
  .toggle { padding-right: 9px; font-size: 12px; }
  .message { padding: 26px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
