:root {
  color-scheme: dark;
  --bg: #0e1422;
  --panel: #151d2e;
  --panel-light: #1a263c;
  --ink: #f4eadc;
  --muted: #c1b9ae;
  --gold: #e0b880;
  --bright: #f3d5a4;
  --rule: #756046;
  --hairline: #524537;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 20px; }
body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column;
  color: var(--ink); font-family: var(--sans);
  background: radial-gradient(ellipse at 55% -15%, #26324a, transparent 54rem), var(--bg);
}
main { flex: 1; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--bright); outline-offset: 4px;
}
.wrap { width: min(100% - clamp(32px, 9vw, 144px), 1190px); margin-inline: auto; }
.skip { position: fixed; z-index: 5; top: 10px; left: 10px; transform: translateY(-150%); background: var(--bright); color: var(--bg); padding: 10px; }
.skip:focus { transform: translateY(0); }
.masthead { min-height: 75px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #66554070; }
.brand { display: inline-flex; gap: 9px; align-items: center; font: 600 1.17rem var(--serif); letter-spacing: .12em; }
.brand-moon { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--rule); border-radius: 50%; color: var(--bright); font: 23px/1 Georgia, serif; }
.top-link, .text-button { color: var(--muted); font-size: .88rem; }
.top-link { padding: 12px 2px; }
.top-link:hover, .text-button:hover { color: var(--bright); }
.hero {
  position: relative; isolation: isolate; margin-top: 21px; border-radius: 5px; overflow: hidden;
  min-height: clamp(345px, 36vw, 438px); display: flex; align-items: center;
  border: 1px solid var(--rule);
  background: #10121b url("./assets/reading-room.webp") 57% 57% / cover no-repeat;
}
.hero::before {
  position: absolute; content: ""; z-index: -1; inset: 0;
  background: linear-gradient(90deg, #0a101bea 0%, #0b1120b0 33%, transparent 76%);
}
.hero-copy { padding: 28px clamp(27px, 7vw, 85px); }
.hero h1, .session-header h1 { font: 650 clamp(3rem, 7.2vw, 6.15rem)/1.14 var(--serif); letter-spacing: .075em; margin: 0; }
.hero p { color: #e1d4bf; font-size: clamp(.95rem, 2vw, 1.15rem); margin: 18px 0 27px; line-height: 1.8; }
.primary {
  min-height: 45px; padding: 10px 17px; display: inline-flex; justify-content: space-between; align-items: center; gap: 1.2em;
  background: var(--gold); color: #151929; border: 1px solid transparent; border-radius: 3px; font-weight: 650; font-size: .91rem;
}
.primary:hover { background: var(--bright); }
.spreads { padding-block: 30px 35px; }
.section-head, .table-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.section-head { margin-bottom: 16px; }
.section-head h2, .table-head h2, .results h2, .results h3, .setup-preview h2 { font: 650 clamp(1.45rem, 3.1vw, 2.15rem)/1.2 var(--serif); margin: 0; letter-spacing: .065em; }
.section-head p, .table-head p, .session-header p, .results-head p, .details-head p { margin: 0; line-height: 1.65; color: var(--muted); font-size: .89rem; }
.spread-grid { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.spread-picker {
  display: flex; flex-direction: column; align-items: stretch; text-align: left;
  padding: 13px; min-height: 182px;
  border: 1px solid var(--hairline); border-radius: 4px; color: var(--ink); background: linear-gradient(145deg, #1b2337, #131b2b 82%);
  transition: border-color .22s, background-color .22s, transform .22s;
}
.spread-picker:hover { border-color: var(--gold); transform: translateY(-3px); background: #1c2941; }
.spread-picker .diagram { position: relative; display: block; width: 64px; height: 66px; color: var(--gold); margin: 4px auto 10px; }
.diagram i {
  position: absolute; display: block; width: 15px; height: 22px; top: 50%; left: 50%;
  transform: translate(calc(-50% + var(--x, 0px)), calc(-50% + var(--y, 0px))) rotate(var(--rotation, 0deg));
  border: 1px solid var(--gold); border-radius: 2px; background: #19243a;
}
.diagram i::after { content: "·"; font: 17px/1 Georgia, serif; position: absolute; inset: 0; display: grid; place-items: center; color: #c29d6c; }
.diagram[data-spread="cross"] i { width: 10px; height: 14px; }
.diagram[data-spread="cross"] i::after { font-size: 11px; }
.diagram[data-spread="daily"] i { width: 27px; height: 40px; }
.diagram[data-spread="daily"] i::after { content: "☾"; }
.spread-name { font: 650 1.1rem var(--serif); letter-spacing: .05em; }
.spread-caption { margin-top: 5px; color: var(--muted); font-size: .79rem; line-height: 1.55; }
.spread-meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 12px; color: var(--gold); font-size: .76rem; }
.site-footer { border-top: 1px solid #66554070; min-height: 62px; padding-block: 12px; display: flex; align-items: center; justify-content: space-between; gap: 15px; color: var(--muted); font-size: .77rem; line-height: 1.6; }
.site-footer span:first-child { white-space: nowrap; font-family: var(--serif); color: var(--gold); }
.session { padding-bottom: 40px; }
.text-button { padding: 8px 4px; min-height: 44px; border: 0; background: transparent; white-space: nowrap; }
.back-button { margin-top: 9px; }
.session-header { display: flex; justify-content: space-between; align-items: end; gap: 15px; padding-block: 12px 22px; border-bottom: 1px solid var(--hairline); margin-bottom: 20px; }
.session-header h1 { font-size: clamp(2.25rem, 7.5vw, 4.2rem); }
.session-header p { margin-top: 10px; max-width: 60ch; }
.setup { display: grid; grid-template-columns: 1.35fr 1fr; gap: 15px; }
.question-form, .setup-preview, .table-panel, .results {
  border-radius: 4px; border: 1px solid var(--hairline); background: var(--panel);
  padding: clamp(16px, 3.4vw, 30px);
}
.question-form { display: flex; flex-direction: column; align-items: flex-start; gap: 15px; }
.field { width: 100%; }
.field label { display: block; font-size: .9rem; margin-bottom: 7px; }
.field small { color: var(--muted); margin-left: 7px; }
.field textarea, .field input {
  width: 100%; background: #101725; color: var(--ink); border: 1px solid #807058; border-radius: 3px;
  padding: 10px; min-height: 44px; line-height: 1.6; overflow-wrap: anywhere;
}
.field ::placeholder { color: #aba7a3; }
.field textarea { resize: vertical; }
.options { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 10px; }
.toggle { display: flex; min-height: 38px; align-items: center; gap: 8px; font-size: .9rem; }
.toggle input { accent-color: var(--gold); width: 18px; height: 18px; margin: 0; }
.setup-preview h2 { font-size: 1.35rem; }
.setup-preview ol { margin: 10px 0 0; padding-left: 1.5em; columns: 1; }
.setup-preview li { padding: 3px 0 4px 3px; color: var(--muted); font-size: .84rem; line-height: 1.55; break-inside: avoid; }
.setup-preview li::marker { color: var(--gold); }
.setup-preview strong { display: block; color: var(--ink); font-weight: 550; }
.reading-question { padding-left: 12px; border-left: 2px solid var(--rule); line-height: 1.55; color: var(--bright); overflow-wrap: anywhere; white-space: pre-wrap; }
.table-head { align-items: start; }
.table-head p { margin-top: 8px; }
.count { color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .88rem; }
.jump-button { margin-top: 7px; color: var(--gold); }
.fan { display: grid; grid-template-columns: repeat(auto-fit, minmax(47px, 1fr)); gap: 8px; max-width: 832px; margin: 18px auto 0; }
.fan-button {
  width: 100%; max-width: 80px; aspect-ratio: .66; position: relative; justify-self: center;
  border: 1px solid var(--rule); padding: 0; border-radius: 4px; overflow: hidden; color: var(--bright);
  background: radial-gradient(ellipse, #263756, #131d31 71%);
  transition: transform .19s, border-color .19s;
}
.fan-button::before, .fan-button::after { content: ""; position: absolute; pointer-events: none; }
.fan-button::before { inset: 6px; border: 1px solid #a38a65; border-radius: 3px; }
.fan-button::after { width: 56%; aspect-ratio: 1; border: 1px solid #b7976b; border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.fan-button > span {
  position: absolute; inset: 0; display: grid; place-items: center; font: clamp(1.05rem, 3.2vw, 1.7rem) Georgia, serif;
}
.fan-button:hover:enabled { transform: translateY(-4px); border-color: var(--bright); }
.fan-button:disabled { opacity: .25; cursor: default; }
.fan:has(> :only-child) { grid-template-columns: minmax(70px,100px); justify-content: center; }
.fan:has(> :only-child) .fan-button { max-width: 100px; }
.spread-board {
  margin-top: 18px; border: 1px solid var(--hairline); padding: clamp(10px, 2.8vw, 24px);
  background: radial-gradient(ellipse at 45% 32%, #263451, #151e30 77%);
  border-radius: 4px; display: grid; align-items: start; justify-content: center;
  gap: clamp(5px, 1.8vw, 19px);
  grid-template-columns: repeat(var(--columns, 3), minmax(0, 112px));
}
.spread-board[data-spread="cross"] { grid-template-columns: repeat(5, minmax(0, 112px)); }
.slot { min-width: 0; margin: 0; text-align: center; grid-area: var(--row) / var(--column); }
.slot.focus { outline: 1px solid #e6b97970; outline-offset: 3px; border-radius: 3px; }
.card-face, .card-empty {
  width: 100%; max-width: 112px; aspect-ratio: .65; position: relative; border-radius: 4px;
  margin-inline: auto; overflow: hidden;
}
.card-empty { display: grid; place-items: center; border: 1px dashed #b89c7085; color: #c3ad8b; font: 1.2rem Georgia, serif; background: #151f314c; }
.card-face {
  display: grid; grid-template-rows: 1fr auto 2.4fr 1fr;
  align-items: center; justify-items: center; padding: 4% 6%; gap: 0;
  color: #23314c; background: radial-gradient(ellipse, #fff1d3, #e7cda2 78%);
  border: 1px solid #b5915d; box-shadow: 0 3px 9px #090d18aa;
  animation: reveal .29s ease-out both;
}
.card-face::before {
  position: absolute; content: ""; inset: 4%; border: 1px solid currentColor; opacity: .36; border-radius: 2px; pointer-events: none;
}
.card-face[data-tone="wands"] { color: #7c3826; background: radial-gradient(ellipse, #fff0d7, #e6bd91 80%); }
.card-face[data-tone="cups"] { color: #285370; background: radial-gradient(ellipse, #f4f0d7, #c6d7d8 80%); }
.card-face[data-tone="swords"] { color: #41385a; background: radial-gradient(ellipse, #f1e9dc, #c9c7d6 80%); }
.card-face[data-tone="coins"] { color: #4c5330; background: radial-gradient(ellipse, #f8efd8, #d5d7a4 80%); }
.card-index { font: 600 clamp(.49rem, 1.8vw, .69rem)/1 Georgia, serif; letter-spacing: .1em; }
.card-name { max-width: 100%; font: 750 clamp(.48rem, 1.8vw, .79rem)/1.05 var(--serif); white-space: nowrap; }
.card-art { position: relative; align-self: stretch; place-self: stretch; display: grid; place-items: center; font: clamp(1.08rem, 4.3vw, 2.8rem)/1 Georgia, "Segoe UI Symbol", serif; }
.card-art::before {
  position: absolute; content: ""; width: 73%; max-height: 88%; aspect-ratio: 1;
  border: 1px solid currentColor; border-radius: 50%; opacity: .25; pointer-events: none;
}
.card-art.pips { display: flex; flex-flow: row wrap; align-content: center; justify-content: center; font-size: clamp(.43rem, 1.9vw, .92rem); gap: .05em .14em; padding-inline: 12%; }
.card-art.pips > span { width: 25%; }
.card-face.reversed .card-art { transform: rotate(180deg); }
.orientation { font-size: clamp(.5rem, 1.6vw, .69rem); min-height: 1em; line-height: 1; }
.slot figcaption { padding-top: 6px; font-size: clamp(.57rem, 1.7vw, .75rem); line-height: 1.42; color: var(--muted); overflow-wrap: anywhere; }
.slot figcaption b { color: var(--gold); font-weight: 550; }
.results { margin-top: 18px; }
.results-head p, .details-head p { margin-top: 7px; overflow-wrap: anywhere; }
.summary { display: grid; gap: 10px; margin-top: 16px; }
.summary-item { padding: 12px 15px; border-left: 2px solid var(--gold); background: var(--panel-light); }
.summary-item h3 { font-size: 1rem; color: var(--bright); overflow-wrap: anywhere; }
.summary-item p { margin: 7px 0 0; font-size: .91rem; line-height: 1.75; overflow-wrap: anywhere; }
.details-head { margin-top: 25px; }
.details-head h3 { font-size: 1.3rem; }
.details { margin-top: 10px; }
.details details { border-bottom: 1px solid var(--hairline); }
.details summary { line-height: 1.55; padding: 12px 4px; cursor: pointer; color: var(--bright); overflow-wrap: anywhere; }
.details details p { margin: 0 0 13px; font-size: .9rem; line-height: 1.7; }
.result-actions { display: flex; gap: 12px; margin-top: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes reveal {
  from { opacity: .3; transform: scale(.94) rotateY(-28deg); }
  to { opacity: 1; transform: scale(1) rotateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 850px) {
  .spread-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .masthead { min-height: 62px; }
  .hero { min-height: 365px; background-position: 63% 45%; align-items: end; }
  .hero::before { background: linear-gradient(0deg, #0b111cf9 0%, #0c131b9d 54%, #10172731 100%), linear-gradient(90deg, #0a101ba8, transparent); }
  .hero-copy { padding: 25px 20px; }
  .hero p { margin: 12px 0 17px; }
  .section-head { align-items: start; flex-direction: column; gap: 6px; }
  .spread-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spread-picker { min-height: 156px; padding: 10px; }
  .spread-picker .diagram { margin-bottom: 4px; height: 59px; }
  .spreads { padding-block: 25px; }
  .setup { grid-template-columns: 1fr; }
  .setup-preview ol { columns: 2; }
  .fan { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 5px; }
  .fan:has(> :nth-child(13)) { grid-template-columns: repeat(5, 1fr); }
  .fan:has(> :nth-child(9)):not(:has(> :nth-child(13))) { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 360px) {
  .wrap { width: calc(100% - 24px); }
  .hero { min-height: 322px; }
  .hero h1 { font-size: 2.55rem; }
  .options { grid-template-columns: 1fr; }
  .card-name { letter-spacing: -.06em; }
}
#summary[data-comparison="true"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#summary[data-comparison="true"] > :first-child, #summary[data-comparison="true"] > :last-child { grid-column: 1 / -1; }
@media (max-width: 480px) {
  #summary[data-comparison="true"] { grid-template-columns: 1fr; }
  .spread-board[data-spread="cross"] .card-face { aspect-ratio: .59; }
  .spread-board[data-spread="cross"] .card-name { font-size: .49rem; }
}
