:root {
  color-scheme: dark;
  --ink: #f6efe0;
  --muted: #c9baa4;
  --soft: #998a75;
  --faint: rgba(246, 239, 224, 0.12);
  --line: rgba(246, 239, 224, 0.18);
  --gold: #d8b56c;
  --gold-strong: #f0d083;
  --jade: #69b6a5;
  --coral: #c96f57;
  --night: #0b1014;
  --surface: rgba(15, 23, 25, 0.78);
  --surface-strong: rgba(20, 30, 33, 0.94);
  --surface-soft: rgba(246, 239, 224, 0.055);
  --panel: rgba(15, 23, 25, 0.82);
  --panel-strong: rgba(20, 30, 33, 0.96);
  --ring: rgba(216, 181, 108, 0.42);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 16px 42px rgba(0, 0, 0, 0.28);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(216, 181, 108, 0.18), transparent 46%),
    linear-gradient(135deg, rgba(105, 182, 165, 0.12), transparent 32%),
    linear-gradient(90deg, rgba(216, 181, 108, 0.045) 1px, transparent 1px),
    linear-gradient(145deg, #07090d 0%, #0b1517 48%, #160f0d 100%);
  background-size: auto, auto, 72px 72px, auto;
  font-family: "PingFang SC", "Noto Serif SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 38%, rgba(246, 239, 224, 0.045) 48%, transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 22%);
  mix-blend-mode: screen;
  opacity: 0.54;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.76;
}

button:active {
  transform: translateY(1px) scale(0.985);
}

.app-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 58px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 280px);
  gap: clamp(28px, 5vw, 58px);
  align-items: center;
  min-height: 360px;
  padding: 28px 0 24px;
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 12%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(216, 181, 108, 0.44), rgba(105, 182, 165, 0.2), transparent);
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: none;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  margin-bottom: 10px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  letter-spacing: 0;
  text-wrap: balance;
}

.hero-text {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.78;
}

.hero-metrics {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  width: min(100% - 36px, 650px);
  margin-top: 26px;
  overflow: hidden;
  border: 1px solid rgba(216, 181, 108, 0.2);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(216, 181, 108, 0.09), transparent 42%),
    rgba(13, 24, 24, 0.54);
  box-shadow: inset 0 1px 0 rgba(246, 239, 224, 0.07);
}

.hero-metrics::before {
  content: "";
  position: absolute;
  inset: 0 14px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216, 181, 108, 0.58), transparent);
}

.hero-metrics span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 54px;
  border-right: 1px solid rgba(246, 239, 224, 0.08);
  color: #d7cab5;
  padding: 0 18px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.hero-metrics span:last-child {
  border-right: 0;
}

.hero-metrics strong {
  display: inline-block;
  flex: 0 0 auto;
  color: var(--gold);
  font-size: clamp(1.18rem, 2.5vw, 1.55rem);
  line-height: 1;
}

.hero-card {
  position: relative;
  justify-self: center;
  width: min(100%, 245px);
  transform: rotate(3deg);
  animation: hero-card-drift 7.5s var(--ease-out-quart) infinite alternate;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: -18px;
  border: 1px solid rgba(216, 181, 108, 0.22);
  border-radius: 18px;
  transform: rotate(-5deg);
  opacity: 0.75;
}

.hero-card img,
.card-art,
.library-card img {
  display: block;
  width: 100%;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hero-card img {
  position: relative;
  z-index: 1;
}

.control-panel,
.spread-section,
.ritual-section,
.library-section,
.history-section {
  margin-top: 26px;
}

.control-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 0.92fr);
  grid-template-areas:
    "intent modes"
    "intent actions";
  gap: 14px 18px;
  align-items: end;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(216, 181, 108, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(216, 181, 108, 0.1), transparent 38%),
    var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.control-panel::before {
  content: "";
  position: absolute;
  inset: 0 18px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216, 181, 108, 0.64), rgba(105, 182, 165, 0.28), transparent);
}

.intention-box {
  display: grid;
  gap: 8px;
  grid-area: intent;
}

label {
  color: var(--gold);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
}

textarea {
  width: 100%;
  resize: vertical;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  line-height: 1.65;
  transition: border-color 0.2s var(--ease-out-quart), box-shadow 0.2s var(--ease-out-quart), background 0.2s var(--ease-out-quart);
}

textarea:focus {
  border-color: rgba(216, 181, 108, 0.68);
  background: rgba(255, 255, 255, 0.075);
  box-shadow: 0 0 0 3px rgba(216, 181, 108, 0.12), 0 10px 30px rgba(0, 0, 0, 0.18);
}

textarea::placeholder {
  color: rgba(246, 239, 224, 0.5);
}

.mode-row,
.action-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-row {
  grid-area: modes;
  align-self: end;
  justify-content: flex-start;
  margin-bottom: 0;
}

.action-row {
  grid-area: actions;
  align-self: start;
}

.mode-button,
.filter-button,
.ghost-button,
.secondary-button,
.primary-button {
  position: relative;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  padding: 0 18px;
  overflow: hidden;
  transition:
    transform 0.18s var(--ease-out-quart),
    border-color 0.18s var(--ease-out-quart),
    background 0.18s var(--ease-out-quart),
    box-shadow 0.18s var(--ease-out-quart),
    color 0.18s var(--ease-out-quart);
}

.mode-button.active,
.filter-button.active {
  color: #16110b;
  background: linear-gradient(135deg, var(--gold-strong), var(--gold));
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(216, 181, 108, 0.16);
}

.primary-button {
  min-width: 144px;
  border-color: transparent;
  color: #0f1514;
  background: linear-gradient(135deg, var(--gold), #efcf82);
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(216, 181, 108, 0.18);
}

.primary-button::after {
  content: "";
  position: absolute;
  inset: -1px;
  background: linear-gradient(115deg, transparent 0 34%, rgba(255, 255, 255, 0.5) 45%, transparent 58%);
  transform: translateX(-120%);
  opacity: 0;
}

.primary-button.is-drawing::after {
  animation: button-sheen 0.52s var(--ease-out-quint);
}

.ghost-button:hover,
.secondary-button:hover,
.mode-button:hover,
.filter-button:hover,
.primary-button:hover {
  border-color: rgba(216, 181, 108, 0.58);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.section-heading {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-top: 12px;
}

.section-heading::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: min(110px, 34%);
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(105, 182, 165, 0.48), transparent);
}

.section-heading p:last-child {
  color: var(--muted);
  line-height: 1.7;
}

.compact {
  margin-bottom: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  perspective: 1400px;
}

.card-grid.single-reading {
  grid-template-columns: minmax(0, 1fr);
}

.reading-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(246, 239, 224, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(150deg, rgba(105, 182, 165, 0.1), transparent 40%),
    rgba(19, 27, 31, 0.9);
  box-shadow: var(--shadow-soft);
  transition: transform 0.28s var(--ease-out-quart), border-color 0.28s var(--ease-out-quart), box-shadow 0.28s var(--ease-out-quart);
}

.reading-card::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(216, 181, 108, 0.14), transparent 24%, transparent 72%, rgba(105, 182, 165, 0.1));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease-out-quart);
}

.reading-card:hover {
  border-color: rgba(216, 181, 108, 0.38);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  transform: translateY(-3px);
}

.reading-card:hover::before {
  opacity: 1;
}

.reading-card-inner {
  display: grid;
  grid-template-columns: minmax(118px, 36%) 1fr;
  gap: 16px;
  height: 100%;
  padding: 14px;
}

.single-reading .reading-card {
  max-width: 100%;
}

.single-reading .reading-card-inner {
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 24px;
}

.single-reading .card-art {
  max-height: 520px;
  object-fit: contain;
}

.single-reading .card-copy {
  padding: 8px 18px 8px 0;
}

.single-reading .card-copy h3 {
  font-size: clamp(2.6rem, 5vw, 4.4rem);
}

.single-reading .meaning {
  max-width: 760px;
  font-size: 1.06rem;
  line-height: 1.9;
}

.image-button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: transparent;
  padding: 0;
  text-align: left;
  transition: transform 0.22s var(--ease-out-quart), filter 0.22s var(--ease-out-quart);
}

.image-button:hover {
  transform: translateY(-2px) rotate(-0.5deg);
  filter: saturate(1.06) brightness(1.04);
}

.image-button:focus-visible,
.library-card:focus-visible,
button:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

.card-copy {
  min-width: 0;
  padding: 4px 6px 4px 0;
}

.slot-label {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  border: 1px solid rgba(105, 182, 165, 0.22);
  border-radius: 999px;
  color: #8fd2c3;
  background: rgba(105, 182, 165, 0.08);
  padding: 4px 9px;
  font-size: 0.82rem;
}

.card-copy h3 {
  margin: 0 0 10px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 1.72rem;
}

.meta {
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 700;
}

.meaning {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.keywords span {
  position: relative;
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(240, 208, 131, 0.68);
  border-radius: 3px;
  padding: 4px 10px;
  color: rgba(255, 225, 142, 0.94);
  background:
    linear-gradient(180deg, rgba(216, 181, 108, 0.12), rgba(216, 181, 108, 0.035)),
    rgba(3, 8, 9, 0.18);
  box-shadow:
    0 0 0 1px rgba(5, 9, 9, 0.56) inset,
    0 0 22px rgba(216, 181, 108, 0.12);
  font-size: 0.8rem;
}

.keywords span::before {
  content: "";
  position: absolute;
  inset: -1px auto -1px -70%;
  width: 44%;
  background: linear-gradient(90deg, transparent, rgba(255, 232, 156, 0.42), transparent);
  transform: skewX(-18deg);
  animation: keyword-glint 4.8s var(--ease-out-quart) infinite;
}

.keywords span:nth-child(2)::before {
  animation-delay: 0.22s;
}

.keywords span:nth-child(3)::before {
  animation-delay: 0.44s;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.ghost-link,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 0.22s var(--ease-out-quart), border-color 0.22s var(--ease-out-quart), box-shadow 0.22s var(--ease-out-quart);
}

.ghost-link {
  border: 1px solid rgba(216, 181, 108, 0.28);
  background: rgba(255, 255, 255, 0.05);
}

.primary-link {
  border: 1px solid rgba(216, 181, 108, 0.68);
  color: #0f1514;
  background: linear-gradient(135deg, var(--gold), #efcf82);
  box-shadow: 0 14px 34px rgba(216, 181, 108, 0.18);
}

.ghost-link:hover,
.primary-link:hover {
  transform: translateY(-2px);
  border-color: rgba(216, 181, 108, 0.62);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
}

body[data-page="draw"] .hero-draw-link,
body[data-page="meaning"] .hero-meaning-link,
body[data-page="draw"] .library-section,
body[data-page="draw"] .history-section,
body[data-page="meaning"] .ritual-section,
body[data-page="meaning"] .control-panel,
body[data-page="meaning"] .library-section,
body[data-page="meaning"] .history-section {
  display: none;
}

.card-grid.selection-mode {
  display: block;
  perspective: none;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: clamp(10px, 1.7vw, 18px);
  border: 1px solid rgba(216, 181, 108, 0.16);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 181, 108, 0.16), transparent 38%),
    linear-gradient(145deg, rgba(105, 182, 165, 0.08), transparent 48%),
    rgba(12, 18, 23, 0.72);
  padding: clamp(16px, 3vw, 28px);
  box-shadow: var(--shadow-soft);
}

.deck-card {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(246, 239, 224, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px;
  aspect-ratio: 0.62;
  cursor: pointer;
  overflow: hidden;
  transform: translateY(0) rotate(var(--tilt, 0deg));
  animation: deck-rise 0.5s var(--ease-out-quint) both;
  animation-delay: calc(min(var(--i, 0), 10) * 38ms);
  transition: transform 0.28s var(--ease-out-quart), border-color 0.28s var(--ease-out-quart), box-shadow 0.28s var(--ease-out-quart), filter 0.28s var(--ease-out-quart);
}

.deck-card::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(216, 181, 108, 0.18);
  border-radius: 10px;
  pointer-events: none;
}

.deck-card img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
  filter: saturate(0.9) brightness(0.9);
}

.deck-card:hover:not(:disabled) {
  transform: translateY(-10px) rotate(var(--tilt, 0deg));
  border-color: rgba(216, 181, 108, 0.58);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  filter: brightness(1.04);
}

.deck-card.is-picked {
  border-color: rgba(216, 181, 108, 0.7);
  box-shadow: 0 20px 48px rgba(216, 181, 108, 0.14);
  transform: translateY(-14px) rotate(var(--tilt, 0deg));
}

.deck-card:disabled {
  cursor: default;
}

.deck-card:not(.is-picked):disabled {
  opacity: 0.5;
  filter: saturate(0.6);
}

.deck-card-number {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #0f1514;
  background: var(--gold);
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.reading-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

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

body[data-page="meaning"] .hero {
  min-height: 430px;
}

body[data-page="meaning"] .card-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}

.reading-card.meaning-view .reading-card-inner {
  grid-template-columns: minmax(190px, 290px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  padding: clamp(16px, 2.4vw, 26px);
}

.reading-card.meaning-view .card-art {
  max-height: 430px;
  object-fit: contain;
}

.meaning-rows {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.meaning-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 14px;
  border-top: 1px solid rgba(246, 239, 224, 0.1);
  padding-top: 13px;
}

.meaning-row strong {
  color: var(--gold);
  font-size: 0.88rem;
}

.meaning-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.78;
}

.empty-state {
  border: 1px solid rgba(216, 181, 108, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  padding: clamp(18px, 3vw, 28px);
}

.empty-state h3 {
  margin: 0 0 8px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.empty-state p {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.76;
}

@media (max-width: 620px) {
  .selection-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 14px;
  }

  .deck-card {
    padding: 5px;
    border-radius: 10px;
  }

  .deck-card::after {
    inset: 6px;
    border-radius: 8px;
  }

  .deck-card-number {
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    font-size: 0.82rem;
  }

  .reading-card.meaning-view .reading-card-inner,
  .meaning-row {
    grid-template-columns: 1fr;
  }

  .reading-card.meaning-view .card-art {
    max-width: min(100%, 240px);
    justify-self: center;
  }
}

.guide {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(216, 181, 108, 0.22);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(216, 181, 108, 0.1), transparent 34%),
    var(--panel);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.ritual-section {
  width: 100%;
}

.ritual-section .guide {
  margin: 0;
  padding: 0;
}

.guide::before {
  content: "";
  position: absolute;
  inset: 0 18px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216, 181, 108, 0.64), rgba(105, 182, 165, 0.28), transparent);
}

.guide::after {
  content: "";
  position: absolute;
  right: -42px;
  top: -42px;
  width: 120px;
  height: 120px;
  border: 1px solid rgba(216, 181, 108, 0.14);
  border-radius: 50%;
}

.ritual-toggle {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 20px 28px 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s var(--ease-out-quart);
}

.ritual-toggle:hover {
  background: rgba(246, 239, 224, 0.035);
}

.ritual-toggle .eyebrow {
  display: block;
  margin: 0 0 8px;
}

.ritual-toggle strong {
  display: block;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(1.35rem, 2.35vw, 1.95rem);
  line-height: 1.08;
}

.toggle-icon {
  flex: 0 0 auto;
  margin-top: 8px;
  border: 1px solid rgba(246, 239, 224, 0.18);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--gold);
  font-size: 0.84rem;
  letter-spacing: 0;
  transition: color 0.2s var(--ease-out-quart), border-color 0.2s var(--ease-out-quart), transform 0.24s var(--ease-out-quart);
}

.ritual-toggle:hover .toggle-icon {
  border-color: rgba(216, 181, 108, 0.45);
  transform: translateY(-1px);
}

.ritual-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  padding: 0 28px 22px;
  transition: grid-template-rows 0.3s var(--ease-out-quart), opacity 0.22s var(--ease-out-quart), padding 0.3s var(--ease-out-quart);
}

.ritual-content > ol {
  overflow: hidden;
}

.guide.is-collapsed .ritual-content {
  grid-template-rows: 0fr;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.guide.is-collapsed .ritual-toggle {
  padding-bottom: 20px;
}

.guide ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 22px;
  margin: 10px 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
}

.guide li::marker {
  color: var(--gold);
}

.secondary-button {
  margin-top: 12px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
  margin-top: 14px;
  perspective: 1400px;
}

.library-card {
  position: relative;
  display: block;
  aspect-ratio: 0.55;
  min-height: 338px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  padding: 0;
  text-align: left;
  perspective: 1100px;
  animation: library-in 0.42s var(--ease-out-quint) both;
  animation-delay: calc(min(var(--i, 0), 9) * 36ms);
  transition: transform 0.22s var(--ease-out-quart);
}

.library-card:hover {
  transform: translateY(-4px);
}

.library-card:hover .library-face {
  border-color: rgba(216, 181, 108, 0.38);
}

.library-card-flip {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  transition: transform 0.62s var(--ease-out-quint);
}

.library-card.is-flipped .library-card-flip {
  transform: rotateY(180deg);
}

.library-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(105, 182, 165, 0.08), transparent 42%),
    rgba(255, 255, 255, 0.05);
  backface-visibility: hidden;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.25);
  transition: border-color 0.22s var(--ease-out-quart), box-shadow 0.22s var(--ease-out-quart);
}

.library-card:hover .library-face {
  box-shadow: 0 22px 62px rgba(0, 0, 0, 0.36);
}

.library-front {
  padding: 10px;
}

.library-front img {
  height: calc(100% - 58px);
  object-fit: contain;
  object-position: center;
  background: rgba(0, 0, 0, 0.26);
  transition: transform 0.32s var(--ease-out-quart), filter 0.32s var(--ease-out-quart);
}

.library-card:hover .library-front img {
  transform: scale(1.015);
  filter: saturate(1.05) brightness(1.04);
}

.library-caption {
  display: grid;
  gap: 3px;
  padding: 10px 2px 0;
}

.library-caption strong {
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.library-caption span {
  color: var(--muted);
  font-size: 0.82rem;
}

.library-back {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  transform: rotateY(180deg);
  background:
    linear-gradient(rgba(11, 16, 20, 0.86), rgba(11, 16, 20, 0.91)),
    url("../cards/image23.webp") center / cover;
}

.back-orbit {
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(216, 181, 108, 0.2);
  border-radius: 14px;
  pointer-events: none;
  transform: scale(0.96);
  transition: transform 0.45s var(--ease-out-quint), border-color 0.45s var(--ease-out-quint);
}

.library-card.is-flipped .back-orbit {
  border-color: rgba(216, 181, 108, 0.36);
  transform: scale(1);
}

.back-group {
  position: relative;
  color: var(--jade);
  font-size: 0.78rem;
}

.library-back strong {
  position: relative;
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 1.6rem;
  letter-spacing: 0;
}

.back-meaning {
  position: relative;
  color: #d6c9b3;
  font-size: 0.78rem;
  line-height: 1.68;
}

.back-keywords {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.back-keywords em {
  border: 1px solid rgba(216, 181, 108, 0.28);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.72rem;
  font-style: normal;
  padding: 4px 7px;
}

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

.small-button {
  min-height: 38px;
  padding: 0 14px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 14px;
  color: var(--muted);
  line-height: 1.7;
  animation: panel-reveal 0.28s var(--ease-out-quint) both;
}

.history-item strong {
  color: var(--ink);
}

.empty {
  color: var(--muted);
  border: 1px solid rgba(246, 239, 224, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
}

.card-dialog {
  width: min(1280px, calc(100vw - clamp(22px, 4vw, 56px)));
  height: auto;
  height: fit-content;
  max-height: calc(100dvh - clamp(24px, 6vh, 72px));
  min-height: 0;
  overflow: hidden;
  padding: 0;
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 0.22s var(--ease-out-quart), transform 0.22s var(--ease-out-quart);
}

.card-dialog::backdrop {
  background: rgba(2, 5, 7, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.22s var(--ease-out-quart), backdrop-filter 0.22s var(--ease-out-quart);
}

.card-dialog[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.card-dialog[open]::backdrop {
  opacity: 1;
}

.spread-picker-dialog {
  width: min(92vw, 430px);
  border: 1px solid rgba(240, 208, 131, 0.42);
  border-radius: 10px;
  color: #f6efe0;
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 181, 108, 0.16), transparent 34%),
    linear-gradient(145deg, #111f1c, #060b0a 64%, #160c08);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(5, 9, 9, 0.8) inset;
  padding: 0;
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
}

.spread-picker-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.spread-picker-body {
  position: relative;
  padding: 24px 20px 20px;
  color: #f6efe0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 44%),
    rgba(4, 11, 10, 0.64);
  border-radius: inherit;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.42);
}

.spread-picker-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(240, 208, 131, 0.28);
  border-radius: 50%;
  color: #f6efe0;
  background: rgba(255, 255, 255, 0.08);
}

.spread-picker-kicker {
  margin: 0 0 8px;
  color: #f0d083;
  font-size: 0.84rem;
  font-weight: 800;
}

.spread-picker-body h2 {
  margin: 0 0 8px;
  color: #f0d083;
  font-size: clamp(1.8rem, 8vw, 2.45rem);
}

.spread-picker-body > p:not(.spread-picker-kicker) {
  margin-bottom: 16px;
  color: rgba(246, 239, 224, 0.78);
  line-height: 1.62;
}

.spread-picker-options {
  display: grid;
  gap: 10px;
}

.spread-picker-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(216, 181, 108, 0.28);
  border-radius: 7px;
  color: #f6efe0;
  background:
    linear-gradient(90deg, rgba(216, 181, 108, 0.09), rgba(255, 255, 255, 0.025)),
    rgba(0, 0, 0, 0.16);
  padding: 14px 15px;
  text-align: left;
}

.spread-picker-option strong {
  color: #f6efe0;
  font-size: 1.08rem;
}

.spread-picker-option span {
  color: rgba(240, 208, 131, 0.88);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.spread-picker-option small {
  grid-column: 1 / -1;
  color: rgba(246, 239, 224, 0.72);
  font-size: 0.84rem;
  line-height: 1.45;
}

.spread-picker-option.is-active {
  border-color: rgba(240, 208, 131, 0.78);
  background:
    linear-gradient(135deg, rgba(240, 208, 131, 0.24), rgba(216, 181, 108, 0.1)),
    rgba(12, 18, 16, 0.8);
  box-shadow: 0 0 0 1px rgba(240, 208, 131, 0.18) inset, 0 16px 32px rgba(0, 0, 0, 0.22);
}

.spread-picker-start {
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  border-radius: 7px;
  font-size: 1.08rem;
}

.spread-picker-start,
.spread-picker-start:hover {
  color: #15140d;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent) -140% 0 / 38% 100% no-repeat,
    linear-gradient(180deg, #f5d98f, #c99a4d);
  border-color: rgba(245, 217, 143, 0.84);
  box-shadow: 0 16px 42px rgba(216, 181, 108, 0.24), inset 0 0 0 1px rgba(255, 244, 198, 0.48);
}

.spread-picker-start:hover {
  background-position: 160% 0, 0 0;
}

@supports (-webkit-touch-callout: none) {
  .spread-picker-dialog::backdrop,
  .card-dialog::backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .spread-picker-dialog {
    background: linear-gradient(145deg, #111f1c, #060b0a 64%, #160c08);
  }
}

.mobile-ritual-note,
.spread-ritual-note {
  display: none;
}

.dialog-close {
  position: absolute;
  z-index: 20;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.5rem;
  transition: transform 0.18s var(--ease-out-quart), border-color 0.18s var(--ease-out-quart), background 0.18s var(--ease-out-quart);
}

.dialog-close:hover {
  border-color: rgba(216, 181, 108, 0.5);
  background: rgba(216, 181, 108, 0.12);
  transform: rotate(8deg);
}

.dialog-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: clamp(20px, 4vw, 54px);
  height: auto;
  max-height: calc(100dvh - clamp(24px, 6vh, 72px));
  min-height: 0;
  overflow: hidden;
  padding: clamp(22px, 3.4vw, 46px);
  align-items: center;
}

.dialog-art {
  display: flex;
  width: 100%;
  height: min(70dvh, 760px);
  min-width: 0;
  min-height: 0;
  max-height: calc(100dvh - clamp(160px, 22vh, 240px));
  align-items: center;
  justify-content: center;
  margin: 0;
}

.card-edge-aura {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(240, 208, 131, 0.36);
  border-radius: 10px;
  padding: 3px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 232, 154, 0.18), transparent 42%),
    rgba(216, 181, 108, 0.14);
  box-shadow:
    0 20px 52px rgba(0, 0, 0, 0.36),
    0 0 22px rgba(216, 181, 108, 0.16),
    0 0 0 1px rgba(2, 5, 6, 0.74) inset;
}

.card-edge-aura::before,
.card-edge-aura::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.card-edge-aura::before {
  z-index: 0;
  inset: -46%;
  background:
    conic-gradient(
      from 0deg,
      transparent 0deg 42deg,
      rgba(255, 240, 167, 0.96) 58deg,
      rgba(216, 181, 108, 0.58) 74deg,
      transparent 94deg 208deg,
      rgba(255, 223, 137, 0.72) 225deg,
      rgba(105, 182, 165, 0.28) 240deg,
      transparent 262deg 360deg
    );
  opacity: 0.9;
  animation: card-edge-orbit 5.2s linear infinite;
}

.card-edge-aura::after {
  z-index: 1;
  inset: 4px;
  border: 1px solid rgba(255, 225, 142, 0.5);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(3, 7, 8, 0.72),
    0 0 16px rgba(216, 181, 108, 0.16);
  animation: card-edge-breathe 3.8s ease-in-out infinite;
}

.card-edge-aura > img {
  position: relative;
  z-index: 2;
  border: 0 !important;
  border-radius: 7px;
  box-shadow: none !important;
}

.dialog-art .card-edge-aura {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.dialog-art img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: var(--shadow-soft);
}

.dialog-art .card-edge-aura > img {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.dialog-text {
  min-width: min(100%, 280px);
  overflow: hidden;
}

.dialog-text h2 {
  margin-top: 12px;
  font-size: clamp(2.8rem, 5vw, 5.2rem);
  line-height: 1.02;
}

.dialog-text p {
  color: var(--muted);
  font-size: clamp(1.02rem, 1.35vw, 1.22rem);
  line-height: 1.9;
  max-width: 68ch;
}

@media (max-aspect-ratio: 1/1) {
  .card-dialog {
    width: min(760px, calc(100vw - clamp(20px, 5vw, 48px)));
  }

  .dialog-body {
    grid-template-columns: 1fr;
    gap: clamp(14px, 2.4vh, 28px);
    align-content: start;
    justify-items: center;
  }

  .dialog-art {
    height: min(48dvh, 560px);
    max-height: none;
  }

  .dialog-text {
    width: min(100%, 620px);
    justify-self: center;
    text-align: left;
  }

  .dialog-text p:not(.eyebrow) {
    overflow: visible;
  }
}

.shuffle {
  animation: draw-card 0.58s var(--ease-out-quint) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes draw-card {
  0% {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(20px) rotateX(9deg) scale(0.96);
  }
  56% {
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotateX(0) scale(1);
  }
}

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

@keyframes library-in {
  from {
    opacity: 0;
    transform: translateY(14px) rotateX(4deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

@keyframes deck-rise {
  from {
    opacity: 0;
    transform: translateY(18px) rotate(var(--tilt, 0deg)) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--tilt, 0deg)) scale(1);
  }
}

@keyframes hero-card-drift {
  from {
    transform: rotate(2deg) translateY(0);
  }
  to {
    transform: rotate(4deg) translateY(-8px);
  }
}

@keyframes button-sheen {
  0% {
    opacity: 0;
    transform: translateX(-120%);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@keyframes card-edge-orbit {
  to {
    transform: rotate(1turn);
  }
}

@keyframes card-edge-breathe {
  0%,
  100% {
    border-color: rgba(255, 225, 142, 0.34);
    box-shadow:
      inset 0 0 0 1px rgba(3, 7, 8, 0.72),
      0 0 12px rgba(216, 181, 108, 0.14);
  }

  50% {
    border-color: rgba(255, 232, 156, 0.68);
    box-shadow:
      inset 0 0 0 1px rgba(3, 7, 8, 0.64),
      0 0 28px rgba(216, 181, 108, 0.28);
  }
}

@keyframes keyword-glint {
  0%,
  54% {
    transform: translateX(0) skewX(-18deg);
  }

  100% {
    transform: translateX(420%) skewX(-18deg);
  }
}

@starting-style {
  .card-dialog[open] {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }

  .card-dialog[open]::backdrop {
    opacity: 0;
  }
}
