:root {
  color-scheme: light;
  --bg: #f6f8f5;
  --surface: #fbfcfa;
  --surface-strong: #ffffff;
  --ink: #2f3431;
  --muted: #68726b;
  --line: #d5ded6;
  --accent: #9a7480;
  --accent-strong: #6f4f63;
  --sage: #dce8dd;
  --rose: #ead7dd;
  --gold: #b9a15d;
  --shadow: 0 18px 50px rgba(72, 88, 76, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(220, 232, 221, 0.9), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(234, 215, 221, 0.75), transparent 28rem),
    linear-gradient(135deg, #f6f8f5 0%, #f7f4f8 48%, #eef5f0 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  line-height: 1.6;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 22px;
  align-items: start;
}

.intro-panel,
.shuffle-panel,
.analysis-panel,
.reading-panel,
.result-panel {
  background: rgba(251, 252, 250, 0.9);
  border: 1px solid rgba(213, 222, 214, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-panel {
  position: sticky;
  top: 24px;
  padding: 28px;
}

.shuffle-panel,
.analysis-panel,
.reading-panel,
.result-panel {
  padding: 24px;
}

.result-panel {
  grid-column: 2;
}

.brand-row,
.section-header,
.form-actions,
.result-card-title {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 10px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--accent-strong);
  background: var(--surface-strong);
  font-family: Georgia, serif;
  font-size: 14px;
  letter-spacing: 0;
}

.brand-label,
.eyebrow,
.question-summary span {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(40px, 7vw, 68px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
}

.lead {
  color: var(--muted);
  font-size: 17px;
}

.question-form {
  margin-top: 24px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 132px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 107, 95, 0.14);
}

.form-actions {
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent-strong);
  color: #fff;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--accent-strong);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.safety-note,
.deck-guidance,
.card-meaning,
.gentle-disclaimer {
  color: var(--muted);
}

.safety-note {
  margin: 18px 0 0;
  font-size: 14px;
}

.section-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin-bottom: 4px;
}

.draw-counter {
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--sage);
  color: #3f513b;
  font-weight: 800;
  text-align: center;
}

.draw-stage {
  display: grid;
  gap: 18px;
  overflow: visible;
}

.draw-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  width: min(620px, 100%);
  margin: 42px auto 12px;
}

.draw-slot {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px solid rgba(154, 116, 128, 0.12);
  border-radius: 8px;
  background: rgba(246, 241, 249, 0.72);
  color: rgba(111, 79, 99, 0.52);
  box-shadow: 0 12px 34px rgba(72, 88, 76, 0.08);
}

.slot-number {
  font-size: 48px;
  font-weight: 800;
}

.slot-label,
.slot-card-name {
  font-size: 14px;
}

.slot-card-name {
  display: block;
  max-width: 100%;
  color: var(--ink);
  text-align: center;
  line-height: 1.25;
}

.draw-slot.is-filled {
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

.draw-slot.is-receiving {
  border-color: rgba(185, 161, 93, 0.75);
  box-shadow: 0 14px 38px rgba(185, 161, 93, 0.22);
}

.swipe-hint {
  margin: 8px 0 0;
  text-align: center;
  color: #9a9496;
  font-size: 20px;
}

.deck-scroll {
  position: relative;
  width: min(100%, 680px);
  max-width: 680px;
  aspect-ratio: 1 / 1;
  margin: 24px auto 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
}


.deck-scroll::before,
.deck-scroll::after {
  content: "";
  position: absolute;
  left: 50%;
  pointer-events: none;
  top: 50%;
  z-index: 0;
  width: min(620px, 92%);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 50% 42%, rgba(232, 224, 255, 0.3), transparent 36%),
    radial-gradient(circle at 50% 58%, rgba(246, 228, 168, 0.16), transparent 58%);
}

.deck-scroll::before {
  display: none;
}




.deck-fan {
  z-index: 1;
}
.deck-scroll.is-dragging {
  cursor: grabbing;
}

.deck-fan {
  --deck-size: min(82vw, 620px);
  --card-w: clamp(42px, 8vw, 76px);
  --card-h: calc(var(--card-w) * 1.708);
  --radius: min(38vw, 285px);
  --neg-radius: calc(-1 * var(--radius));
  --wheel-rotation: 0deg;
  position: relative;
  width: var(--deck-size);
  height: var(--deck-size);
  margin: 0 auto;
  transform-origin: 50% 50%;
  transition: filter 160ms ease;
}

.tarot-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--card-w);
  height: var(--card-h);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  --lift: 0px;
  --focus-scale: 1;
  --layout-x: 0px;
  --layout-y: 0px;
  --layout-rotate: 0deg;
  cursor: pointer;
  transform:
    translate(-50%, -50%)
    rotate(calc(var(--angle) + var(--wheel-rotation)))
    translateY(calc(var(--neg-radius) - var(--lift)))
    rotate(calc(-1 * (var(--angle) + var(--wheel-rotation))))
    scale(var(--focus-scale));
  transform-origin: 50% 50%;
  transition: opacity 140ms ease, filter 140ms ease, box-shadow 140ms ease;
  will-change: transform;
  z-index: var(--stack, var(--i));
}

.tarot-card:hover:not(:disabled) {
  filter: brightness(1.06);
}

.tarot-card.is-focus:not(:disabled) {
  filter: brightness(1.14) drop-shadow(0 8px 14px rgba(185, 161, 93, 0.2));
}


.tarot-card.is-selectable-near-focus:not(.is-focus):not(:disabled) {
  filter: brightness(1.08) drop-shadow(0 6px 12px rgba(185, 161, 93, 0.14));
}


.tarot-card.is-outside-select-range:not(:disabled) {
  cursor: grab;
}
.deck-scroll.is-dragging .tarot-card {
  transition: opacity 90ms linear, filter 90ms linear;
}

.deck-scroll.is-dragging .tarot-card.is-focus {
  filter: brightness(1.12) drop-shadow(0 8px 14px rgba(185, 161, 93, 0.18));
}


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

.tarot-card.is-muted {
  opacity: 0.18;
  filter: grayscale(0.2);
}

.tarot-card.is-drawn {
  opacity: 0;
  pointer-events: none;
}

.tarot-card.is-selected {
  --lift: 34px;
  --focus-scale: 1.12;
  z-index: 180;
}

.card-back,
.card-art {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 12px 24px rgba(111, 79, 99, 0.16);
}

.card-back {
  position: relative;
  padding: 0;
  border: 1px solid rgba(190, 157, 79, 0.68);
  background: #181b30;
  color: #f6e4a8;
  overflow: hidden;
}

.card-back img,
.image-card-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-art {
  border: 1px solid rgba(185, 161, 93, 0.74);
  background: linear-gradient(180deg, #fffdf7 0%, #f7edf3 100%);
}

.card-art.is-reversed .art-frame {
  transform: rotate(180deg);
}

.image-card-art {
  padding: 0;
  overflow: hidden;
  background: #f4ecdc;
}

.image-card-art .fallback-card-art {
  display: none;
}

.image-card-art.is-missing-image {
  padding: 8px;
}

.image-card-art.is-missing-image .fallback-card-art {
  display: grid;
  border: 0;
  box-shadow: none;
}

.image-card-art.is-reversed img {
  transform: rotate(180deg);
}

.art-frame {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 6px;
  padding: 9px 7px;
  border: 1px solid rgba(154, 116, 128, 0.28);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(234, 215, 221, 0.44));
}

.art-top,
.art-orientation {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
}

.art-illustration {
  position: relative;
  align-self: center;
  justify-self: center;
  width: 100%;
  height: 100%;
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(185, 161, 93, 0.72);
  border-radius: 5px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #b9dcf0 0 42%, #f6df86 42% 70%, #8fbf7a 70% 100%);
}

.art-sun {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f6c85f;
  box-shadow: 0 0 0 7px rgba(246, 200, 95, 0.2);
}

.art-figure {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(111, 79, 99, 0.28);
  color: var(--accent-strong);
  font-family: Georgia, serif;
  font-size: 20px;
}

.art-ground {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -8px;
  height: 28px;
  border-radius: 50% 50% 0 0;
  background: rgba(119, 154, 94, 0.74);
}

.wand-art {
  background:
    linear-gradient(180deg, #f5d36b 0 46%, #f1b66d 46% 70%, #8fbe75 70% 100%);
}

.wand-art::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 54px;
  border-radius: 999px;
  background: #9b6a3c;
  transform: rotate(-18deg);
}

.cup-art {
  background:
    linear-gradient(180deg, #b9def5 0 48%, #f4df99 48% 72%, #8fbf7a 72% 100%);
}

.cup-art::before {
  content: "";
  position: absolute;
  width: 34px;
  height: 28px;
  border: 4px solid #d39b45;
  border-top: 8px solid #d39b45;
  border-radius: 0 0 16px 16px;
}

.sword-art {
  background:
    linear-gradient(180deg, #c8d6ee 0 48%, #f2e8ad 48% 72%, #a8c58d 72% 100%);
}

.sword-art::before {
  content: "";
  position: absolute;
  width: 5px;
  height: 62px;
  border-radius: 999px;
  background: #9ba4b3;
  transform: rotate(32deg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.52);
}

.pentacle-art {
  background:
    linear-gradient(180deg, #b5d6c7 0 44%, #f4dc75 44% 72%, #90b76d 72% 100%);
}

.pentacle-art::before {
  content: "★";
  position: absolute;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #d7b84d;
  color: #6f4f63;
  font-size: 22px;
}

.major-art {
  background:
    linear-gradient(180deg, #b8d8f0 0 38%, #f0cb74 38% 67%, #86b777 67% 100%);
}

.major-art::before {
  content: "";
  position: absolute;
  width: 38px;
  height: 54px;
  border-radius: 22px 22px 8px 8px;
  background: linear-gradient(180deg, #e18d73, #b7658b);
}

.art-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}


.card-back-number {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 3;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 1px solid rgba(246, 228, 168, 0.42);
  border-radius: 999px;
  background: rgba(15, 18, 38, 0.62);
  color: rgba(246, 228, 168, 0.92);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 10px rgba(246, 228, 168, 0.16);
}
.fan-card-art {
  pointer-events: none;
}

.slot-flight-target {
  width: 84px;
  height: 140px;
  display: block;
  grid-area: 1 / 1;
  opacity: 0;
  pointer-events: none;
}

.result-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.result-actions .ghost-button {
  min-width: 148px;
}

@media (max-width: 640px) {
  .slot-flight-target {
    width: 70px;
    height: 118px;
  }
}

@media (max-width: 390px) {
  .slot-flight-target {
    width: 60px;
    height: 102px;
  }
}
.slot-card-art {
  width: 84px;
  height: 140px;
}

.drawn-card-animation {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.98;
  transform: translateZ(0);
  transition:
    left 620ms cubic-bezier(0.2, 0.72, 0.18, 1),
    top 620ms cubic-bezier(0.2, 0.72, 0.18, 1),
    width 620ms cubic-bezier(0.2, 0.72, 0.18, 1),
    height 620ms cubic-bezier(0.2, 0.72, 0.18, 1),
    opacity 220ms ease 520ms;
}

.drawn-card-animation.is-flying {
  opacity: 0;
}

.animation-card-art {
  width: 100%;
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .drawn-card-animation {
    transition: none;
  }

  .shuffle-card {
    animation: none;
  }
}

.question-summary {
  padding: 16px 18px;
  margin-bottom: 18px;
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.62);
  border-radius: 8px;
}

.question-summary p {
  margin: 4px 0 0;
}

.card-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.result-card,
.synthesis {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.result-card {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.result-card-art {
  width: min(150px, 100%);
  height: 238px;
  justify-self: center;
}

.result-card-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.result-card-title strong {
  font-size: 18px;
}

.result-card p:last-child,
.synthesis p:last-child {
  margin-bottom: 0;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
}

.card-core {
  margin-bottom: 0;
  color: var(--accent-strong);
  font-weight: 800;
}

.keyword-row span {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--sage);
  color: #405541;
  font-size: 12px;
  font-weight: 700;
}

.synthesis {
  margin-top: 16px;
  padding: 20px;
}

.fallback-reading {
  color: var(--muted);
}

.fallback-reading summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

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

.ai-reading-panel {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.ai-reading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.ai-reading-header h3 {
  margin-bottom: 0;
}

.ai-status {
  color: var(--muted);
  font-size: 14px;
}

.ai-reading-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.ai-card {
  padding: 16px;
  border: 1px solid rgba(154, 116, 128, 0.2);
  border-radius: 8px;
  background: rgba(251, 252, 250, 0.92);
}

.ai-card-wide {
  grid-column: 1 / -1;
}

.ai-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.ai-card strong {
  display: block;
  margin-bottom: 8px;
}

.ai-card p {
  margin-bottom: 0;
}
.result-panel p,
.result-card p,
.synthesis p,
.ai-card p,
.question-summary p,
.card-core,
.gentle-disclaimer {
  text-align: justify;
  text-align-last: auto;
}

.ai-card p + p {
  margin-top: 10px;
}

.safety-ai-card {
  border-color: rgba(185, 161, 93, 0.5);
  background: rgba(255, 250, 235, 0.82);
}

.location-ai-card {
  border-color: rgba(111, 79, 99, 0.32);
  background: rgba(246, 241, 249, 0.88);
}

.location-ai-card p {
  font-weight: 700;
}

.gentle-disclaimer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .intro-panel {
    position: static;
  }

  .result-panel {
    grid-column: auto;
  }

  .deck-scroll {
    width: min(100%, 640px);
    max-width: 640px;
  }

  .deck-fan {
    --deck-size: min(82vw, 560px);
    --card-w: clamp(40px, 7.2vw, 68px);
    --radius: min(37vw, 250px);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding: 14px 0 32px;
    gap: 14px;
  }

  .intro-panel,
.shuffle-panel,
.analysis-panel,
.reading-panel,
.result-panel {
    padding: 18px;
  }

  h1 {
    font-size: 46px;
  }

  .lead {
    font-size: 15px;
  }

  .section-header {
    align-items: flex-start;
  }

  .draw-slots {
    gap: 10px;
    margin-top: 22px;
  }

  .draw-slot {
    min-height: 172px;
  }

  .slot-number {
    font-size: 38px;
  }

  .slot-card-art {
    width: 70px;
    height: 118px;
  }

  .deck-scroll {
    width: min(100%, 420px);
    max-width: 420px;
    margin-top: 18px;
  }

  .deck-fan {
    --deck-size: min(82vw, 360px);
    --card-w: clamp(30px, 8.5vw, 52px);
    --radius: min(37vw, 155px);
  }
  body[data-deck-layout="fan"] .deck-scroll {
    width: min(100%, 420px);
    aspect-ratio: 2.35 / 1;
  }

  body[data-deck-layout="fan"] .deck-fan {
    --card-w: clamp(30px, 8vw, 46px);
    height: min(42vw, 170px);
  }

  body[data-deck-layout="matrix"] .deck-scroll {
    width: min(100%, 420px);
    aspect-ratio: 4.2 / 1;
  }

  body[data-deck-layout="matrix"] .deck-fan {
    --card-w: clamp(30px, 7.8vw, 44px);
    height: clamp(92px, 25vw, 118px);
  }

  .tarot-card,
  .card-back,
  .card-art {
    min-height: 0;
  }

  .card-back {
    padding: 4px;
    border-width: 1px;
  }

  .card-back::before {
    inset: 5px;
    border-width: 1px;
  }

  .card-symbol {
    width: 20px;
    height: 20px;
    font-size: 9px;
  }

  .back-corner {
    width: 5px;
    height: 5px;
    box-shadow: 0 0 0 3px rgba(255, 241, 169, 0.18);
  }

  .back-corner:first-child {
    top: 9px;
    left: 7px;
  }

  .back-corner:last-child {
    right: 7px;
    bottom: 9px;
  }

  .card-results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .result-card {
    padding: 8px;
    gap: 8px;
  }

  .result-card-art {
    width: min(74px, 100%);
    height: 126px;
  }

  .result-card-title {
    display: grid;
    gap: 4px;
    margin-bottom: 0;
  }

  .result-card-title span {
    font-size: 12px;
  }

  .result-card-title strong {
    font-size: 13px;
    line-height: 1.25;
  }

  .card-core {
    font-size: 12px;
    line-height: 1.5;
  }

  .ai-reading-header {
    align-items: stretch;
    display: grid;
  }

  .ai-reading-cards {
    grid-template-columns: 1fr;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .draw-slots {
    gap: 8px;
  }

  .draw-slot {
    min-height: 150px;
  }

  .slot-card-art {
    width: 60px;
    height: 102px;
  }

  .deck-scroll {
    width: min(100%, 340px);
    max-width: 340px;
  }

  .deck-fan {
    --deck-size: min(82vw, 300px);
    --card-w: clamp(26px, 8.2vw, 44px);
    --radius: min(36vw, 128px);
  }
}
.app-shell.is-question-phase,
.app-shell.is-shuffle-phase {
  grid-template-columns: minmax(0, 680px);
  justify-content: center;
}

.app-shell.is-question-phase .intro-panel,
.app-shell.is-shuffle-phase .shuffle-panel {
  position: static;
  min-height: min(720px, calc(100vh - 80px));
  display: grid;
  align-content: center;
}

.shuffle-panel[hidden],
.reading-panel[hidden],
.result-panel[hidden],
.intro-panel[hidden] {
  display: none;
}

.shuffle-panel {
  overflow: hidden;
}

.shuffle-copy {
  position: relative;
  z-index: 2;
  max-width: 520px;
}

.shuffle-copy h2 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 7vw, 62px);
  line-height: 1;
}

.shuffle-copy p:last-child {
  color: var(--muted);
  font-size: 17px;
}

.shuffle-stage {
  position: relative;
  min-height: 320px;
  margin-top: 28px;
  display: grid;
  place-items: center;
}

.shuffle-deck {
  position: relative;
  width: min(520px, 100%);
  height: 280px;
}

.shuffle-card {
  --spread-x: calc(var(--n) * 42px);
  --spread-r: calc(var(--n) * 7deg);
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78px;
  height: 132px;
  border: 1px solid rgba(190, 157, 79, 0.78);
  border-radius: 8px;
  background:
    url("assets/card-backs/oil-moon-back.png") center / cover,
    #181b30;
  box-shadow: 0 18px 34px rgba(72, 88, 76, 0.18);
  transform: translate(-50%, -50%) rotate(calc(var(--n) * 1deg));
  animation: shuffle-flow 2800ms cubic-bezier(0.2, 0.72, 0.18, 1) both;
  animation-delay: calc((var(--n) + 4) * 42ms);
}

.shuffle-card::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(246, 228, 168, 0.38);
  border-radius: 6px;
}

@keyframes shuffle-flow {
  0% {
    opacity: 0;
    transform: translate(-50%, -44%) scale(0.92) rotate(0deg);
  }
  16% {
    opacity: 1;
    transform: translate(calc(-50% + var(--spread-x)), -50%) rotate(var(--spread-r));
  }
  38% {
    transform: translate(calc(-50% - var(--spread-x) * 0.72), -54%) rotate(calc(var(--spread-r) * -0.8));
  }
  58% {
    transform: translate(-50%, -50%) rotate(calc(var(--n) * 1deg));
  }
  76% {
    transform: translate(-50%, -50%) scale(1.03) rotate(0deg);
  }
  100% {
    opacity: 1;
    transform: translate(calc(-50% + var(--spread-x) * 0.72), -50%) rotate(calc(var(--spread-r) * 0.72));
  }
}

@media (max-width: 640px) {
  .shuffle-stage {
    min-height: 260px;
  }

  .shuffle-deck {
    height: 230px;
  }

  .shuffle-card {
    --spread-x: calc(var(--n) * 28px);
    width: 58px;
    height: 98px;
  }
}
.reading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.reading-actions .ghost-button {
  min-height: 38px;
  padding: 0 14px;
}
.deck-layout-switcher {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
}

.deck-layout-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.deck-layout-chip.is-active {
  background: var(--accent-strong);
  color: var(--surface-strong);
}

body[data-deck-layout="fan"] .deck-scroll {
  width: min(100%, 760px);
  max-width: 760px;
  aspect-ratio: 2.6 / 1;
  overflow: hidden;
}

body[data-deck-layout="fan"] .deck-fan {
  --deck-size: min(100%, 760px);
  --card-w: clamp(44px, 7vw, 72px);
  width: 100%;
  height: min(44vw, 280px);
}

body[data-deck-layout="matrix"] .deck-scroll {
  width: min(100%, 760px);
  max-width: 760px;
  aspect-ratio: 4.8 / 1;
  overflow: hidden;
}

body[data-deck-layout="matrix"] .deck-fan {
  --deck-size: min(100%, 760px);
  --card-w: clamp(42px, 6vw, 64px);
  width: 100%;
  height: clamp(118px, 22vw, 170px);
}

body[data-deck-layout="fan"] .tarot-card,
body[data-deck-layout="matrix"] .tarot-card {
  transform:
    translate(-50%, -50%)
    translate(var(--layout-x), var(--layout-y))
    rotate(var(--layout-rotate))
    scale(var(--focus-scale));
}
body[data-theme="purple"] {
  --bg: #f4f0fb;
  --surface: #fbf8ff;
  --surface-strong: #ffffff;
  --ink: #31283d;
  --muted: #746781;
  --line: #ded2ea;
  --accent: #9b77b7;
  --accent-strong: #65457d;
  --sage: #e6def3;
  --rose: #ead8ef;
  --gold: #c5a852;
  --shadow: 0 18px 50px rgba(74, 52, 105, 0.16);
  background:
    radial-gradient(circle at top left, rgba(213, 197, 238, 0.9), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(238, 211, 232, 0.8), transparent 28rem),
    linear-gradient(135deg, #f4f0fb 0%, #f9f5ff 48%, #efe8f8 100%);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11142a;
  --surface: #181b34;
  --surface-strong: #202442;
  --ink: #f3efe7;
  --muted: #b8b2c7;
  --line: rgba(232, 221, 194, 0.2);
  --accent: #e0c75c;
  --accent-strong: #f0d96d;
  --sage: rgba(224, 199, 92, 0.18);
  --rose: rgba(155, 119, 183, 0.22);
  --gold: #ead765;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  background:
    radial-gradient(circle at top left, rgba(66, 53, 116, 0.82), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(125, 91, 145, 0.35), transparent 28rem),
    linear-gradient(135deg, #11142a 0%, #1b1e3a 54%, #090b18 100%);
}

body[data-theme="dark"] .intro-panel,
body[data-theme="dark"] .shuffle-panel,
body[data-theme="dark"] .analysis-panel,
body[data-theme="dark"] .reading-panel,
body[data-theme="dark"] .result-panel,
body[data-theme="dark"] .ai-reading-panel,
body[data-theme="dark"] .result-card,
body[data-theme="dark"] .ai-card,
body[data-theme="dark"] .synthesis {
  background: rgba(24, 27, 52, 0.88);
  border-color: rgba(232, 221, 194, 0.18);
}

.theme-switcher {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  box-shadow: 0 10px 28px rgba(72, 88, 76, 0.12);
  backdrop-filter: blur(10px);
}

.theme-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.theme-chip.is-active {
  background: var(--accent-strong);
  color: var(--surface-strong);
}

.analysis-panel {
  min-height: min(720px, calc(100vh - 80px));
  display: grid;
  place-items: center;
  gap: 28px;
  text-align: center;
}

.analysis-panel[hidden] {
  display: none;
}

.analysis-orbit {
  position: relative;
  width: min(320px, 72vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.analysis-ring,
.analysis-dot {
  position: absolute;
  border-radius: 50%;
}

.analysis-ring {
  inset: 18%;
  border: 1px solid rgba(185, 161, 93, 0.55);
  border-left-color: transparent;
  border-bottom-color: transparent;
  animation: analysis-spin 4.8s linear infinite;
}

.ring-two {
  inset: 11%;
  animation-duration: 7s;
  animation-direction: reverse;
  opacity: 0.74;
}

.ring-three {
  inset: 4%;
  animation-duration: 10s;
  opacity: 0.46;
}

.analysis-core {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, #f1df6a 0%, #d2b847 72%);
  color: #272944;
  font-size: 26px;
  box-shadow: 0 0 34px rgba(234, 215, 101, 0.55);
}

.analysis-dot {
  width: 8px;
  height: 8px;
  background: var(--gold);
  box-shadow: 0 0 16px rgba(234, 215, 101, 0.72);
  animation: analysis-pulse 1.8s ease-in-out infinite alternate;
}

.dot-one {
  top: 12%;
  left: 58%;
}

.dot-two {
  right: 18%;
  bottom: 26%;
  animation-delay: 320ms;
}

.dot-three {
  left: 19%;
  bottom: 18%;
  animation-delay: 640ms;
}

.analysis-copy {
  max-width: 520px;
}

.analysis-copy h2 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1.05;
}

.analysis-copy p:last-child {
  color: var(--muted);
}

@keyframes analysis-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes analysis-pulse {
  from {
    transform: scale(0.8);
    opacity: 0.48;
  }
  to {
    transform: scale(1.2);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .theme-switcher {
    position: static;
    width: fit-content;
    margin: 10px auto 0;
  }

  .analysis-panel {
    min-height: 560px;
  }
}
.app-shell.is-analysis-phase,
.app-shell.is-result-phase {
  grid-template-columns: minmax(0, 860px);
  justify-content: center;
}

.app-shell.is-analysis-phase .analysis-panel,
.app-shell.is-result-phase .result-panel {
  grid-column: auto;
}

.app-shell.is-analysis-phase .reading-panel {
  grid-column: auto;
}

.reading-panel.is-reviewing {
  margin-bottom: 0;
}

.reading-panel.is-reviewing .draw-stage {
  min-height: auto;
  grid-template-rows: auto;
}

.reading-panel.is-reviewing .draw-slots {
  margin: 22px auto 4px;
}

.reading-panel.is-reviewing .swipe-hint,
.reading-panel.is-reviewing .deck-scroll {
  display: none;
}

.reading-panel.is-reviewing + .analysis-panel {
  min-height: min(520px, calc(100vh - 220px));
}

@media (max-width: 640px) {
  .reading-panel.is-reviewing + .analysis-panel {
    min-height: 460px;
  }
}

.app-shell.is-draw-phase {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.app-shell.is-draw-phase .reading-panel {
  grid-column: auto;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  overflow: visible;
}

@media (min-width: 981px) {
  .app-shell.is-draw-phase .deck-scroll {
    max-width: 680px;
    margin-top: 28px;
  }

  .app-shell.is-draw-phase .deck-fan {
    --deck-size: 560px;
    --card-w: 58px;
    --radius: 245px;
  }
}

/* Deck layout modes need to win over the draw-phase defaults above. */
body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll {
  width: min(100%, 760px);
  max-width: 760px;
  aspect-ratio: 2.6 / 1;
  overflow: hidden;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  --deck-size: min(100%, 760px);
  --card-w: clamp(44px, 7vw, 72px);
  width: 100%;
  height: min(44vw, 280px);
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
  width: min(100%, 760px);
  max-width: 760px;
  aspect-ratio: 4.8 / 1;
  overflow: hidden;
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --deck-size: min(100%, 760px);
  --card-w: clamp(42px, 6vw, 64px);
  width: 100%;
  height: clamp(118px, 22vw, 170px);
}

@media (max-width: 640px) {
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll {
    width: min(100%, 420px);
    aspect-ratio: 2.35 / 1;
  }

  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(30px, 8vw, 46px);
    height: min(42vw, 170px);
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
    width: min(100%, 420px);
    aspect-ratio: 4.2 / 1;
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(30px, 7.8vw, 44px);
    height: clamp(92px, 25vw, 118px);
  }

  .reading-actions {
    justify-content: flex-start;
  }

  .deck-layout-switcher {
    width: 100%;
    justify-content: center;
  }
}

/* Unified customization drawer and stable draw-stage sizing. */
.customize-button {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 32;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  backdrop-filter: blur(10px);
}

.customize-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 10, 22, 0.32);
  backdrop-filter: blur(2px);
}

.customize-backdrop[hidden],
.customize-drawer[hidden] {
  display: none;
}

.customize-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 31;
  width: min(360px, calc(100vw - 28px));
  min-height: 100vh;
  padding: 22px;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 94%, transparent);
  color: var(--ink);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.customize-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.customize-drawer-header h2 {
  margin: 0;
  font-size: 28px;
}

.drawer-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.customize-group {
  display: grid;
  gap: 10px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.customize-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.customize-drawer .theme-switcher,
.customize-drawer .deck-layout-switcher {
  position: static;
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  box-shadow: none;
}

.customize-drawer .theme-chip,
.customize-drawer .deck-layout-chip {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
}

.app-shell.is-draw-phase {
  width: min(100% - 20px, 720px);
  grid-template-columns: minmax(0, 720px);
}

.app-shell.is-draw-phase .reading-panel {
  max-width: 720px;
  padding: clamp(16px, 3vw, 24px);
  overflow: hidden;
}

.app-shell.is-draw-phase .section-header {
  align-items: flex-start;
}

.app-shell.is-draw-phase .reading-actions {
  justify-content: flex-end;
}

.app-shell.is-draw-phase .draw-stage {
  max-width: 640px;
  margin: 0 auto;
  gap: clamp(10px, 2vh, 16px);
}

.app-shell.is-draw-phase .draw-slots {
  width: min(100%, 560px);
  gap: clamp(8px, 2vw, 16px);
  margin: clamp(14px, 3vh, 24px) auto 8px;
}

.app-shell.is-draw-phase .draw-slot {
  min-width: 0;
  min-height: clamp(138px, 22vw, 188px);
}

.app-shell.is-draw-phase .swipe-hint {
  margin-top: 2px;
  font-size: clamp(18px, 4.7vw, 24px);
  line-height: 1.45;
}

.app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
  width: min(100%, 620px);
  max-width: 620px;
  height: clamp(250px, 42vh, 390px);
  aspect-ratio: auto;
  margin: 8px auto 0;
  overflow: hidden;
}

.app-shell.is-draw-phase .deck-fan,
body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --deck-size: min(74vw, 500px);
  --card-w: clamp(36px, 6.6vw, 58px);
  --radius: min(31vw, 190px);
  width: 100%;
  height: 100%;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(40px, 7.4vw, 64px);
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(42px, 7.8vw, 66px);
}

@media (max-width: 640px) {
  .customize-button {
    top: 10px;
    right: 10px;
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
  }

  .app-shell.is-draw-phase {
    width: min(100% - 20px, 430px);
  }

  .app-shell.is-draw-phase .section-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .app-shell.is-draw-phase .reading-actions {
    align-self: start;
  }

  .app-shell.is-draw-phase .reading-actions .ghost-button {
    min-height: 36px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .app-shell.is-draw-phase .draw-slots {
    width: 100%;
    gap: 8px;
  }

  .app-shell.is-draw-phase .draw-slot {
    min-height: clamp(138px, 38vw, 166px);
  }

  .app-shell.is-draw-phase .slot-card-art {
    width: clamp(54px, 17vw, 68px);
    height: calc(clamp(54px, 17vw, 68px) * 1.68);
  }

  .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
    width: 100%;
    height: clamp(240px, 36vh, 320px);
  }

  .app-shell.is-draw-phase .deck-fan,
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan,
  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --deck-size: min(78vw, 340px);
    --card-w: clamp(32px, 9vw, 48px);
    --radius: min(33vw, 142px);
  }

  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(36px, 10vw, 52px);
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(38px, 10.4vw, 54px);
  }
}
/* Final draw balance: smaller selected slots, larger flat deck layouts. */
.app-shell.is-draw-phase .draw-stage {
  gap: clamp(8px, 1.5vh, 12px);
}

.app-shell.is-draw-phase .draw-slots {
  width: min(100%, 500px);
  gap: clamp(7px, 1.8vw, 12px);
  margin: clamp(8px, 1.8vh, 14px) auto 4px;
}

.app-shell.is-draw-phase .draw-slot {
  min-height: clamp(112px, 18vw, 148px);
}

.app-shell.is-draw-phase .slot-number {
  font-size: clamp(30px, 6vw, 44px);
}

.app-shell.is-draw-phase .slot-card-art {
  width: clamp(54px, 10vw, 76px);
  height: calc(clamp(54px, 10vw, 76px) * 1.68);
}

.app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
  height: clamp(310px, 49vh, 440px);
  margin-top: 2px;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
  background: transparent;
  box-shadow: none;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll::after,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll::after {
  display: none;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(54px, 8.4vw, 78px);
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(50px, 8vw, 72px);
}

body[data-deck-layout="fan"] .tarot-card.is-outside-select-range,
body[data-deck-layout="matrix"] .tarot-card.is-outside-select-range {
  opacity: 0;
  pointer-events: none;
}

body[data-deck-layout="fan"] .tarot-card.is-selectable-near-focus,
body[data-deck-layout="matrix"] .tarot-card.is-selectable-near-focus {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 640px) {
  .app-shell.is-draw-phase .draw-slots {
    width: min(100%, 330px);
    gap: 7px;
  }

  .app-shell.is-draw-phase .draw-slot {
    min-height: clamp(102px, 28vw, 128px);
  }

  .app-shell.is-draw-phase .slot-card-art {
    width: clamp(44px, 14vw, 58px);
    height: calc(clamp(44px, 14vw, 58px) * 1.68);
  }

  .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
    height: clamp(300px, 43vh, 370px);
  }

  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(46px, 13vw, 62px);
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(44px, 12vw, 58px);
  }
}

/* Final pass: hide open customize trigger and enlarge flat deck modes. */
body.is-customizing .customize-button {
  display: none;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
  height: clamp(340px, 54vh, 480px);
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(68px, 10vw, 92px);
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(66px, 9.6vw, 88px);
}

body[data-deck-layout="fan"] .tarot-card.is-selectable-near-focus,
body[data-deck-layout="matrix"] .tarot-card.is-selectable-near-focus {
  filter: brightness(1.08) drop-shadow(0 10px 18px rgba(40, 36, 64, 0.18));
}

@media (max-width: 640px) {
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
    height: clamp(330px, 48vh, 420px);
  }

  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(60px, 16vw, 74px);
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(58px, 15vw, 72px);
  }
}
/* Final pass 2: stretch flat modes across the lower deck canvas. */
body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(74px, 11vw, 104px);
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(72px, 10.5vw, 98px);
}

@media (max-width: 640px) {
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(66px, 17.5vw, 84px);
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(64px, 17vw, 82px);
  }
}
/* Final pass 3: compact selected slots and give the deck more room. */
.app-shell.is-draw-phase .draw-stage {
  gap: clamp(4px, 1vh, 8px);
}

.app-shell.is-draw-phase .draw-slots {
  width: min(100%, 330px);
  gap: clamp(6px, 1.4vw, 10px);
  margin: clamp(4px, 1vh, 8px) auto 0;
}

.app-shell.is-draw-phase .draw-slot {
  min-height: 0;
  height: clamp(92px, 14vw, 124px);
  padding: 5px;
  gap: 3px;
}

.app-shell.is-draw-phase .draw-slot.is-filled {
  align-content: center;
  justify-content: center;
}

.app-shell.is-draw-phase .slot-card-art {
  width: clamp(48px, 8vw, 66px);
  height: calc(clamp(48px, 8vw, 66px) * 1.68);
}

.app-shell.is-draw-phase .slot-card-name {
  display: none;
}

.app-shell.is-draw-phase .slot-number {
  font-size: clamp(24px, 4.5vw, 34px);
}

.app-shell.is-draw-phase .slot-label {
  font-size: 12px;
}

.app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
  height: clamp(360px, 57vh, 530px);
  margin-top: 0;
}

.app-shell.is-draw-phase .deck-fan {
  --deck-size: min(100%, 520px);
  --card-w: clamp(46px, 7.4vw, 72px);
  --radius: min(36vw, 230px);
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(86px, 13vw, 122px);
}

body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
  --card-w: clamp(82px, 12vw, 116px);
}

@media (max-width: 640px) {
  .app-shell.is-draw-phase .draw-slots {
    width: min(100%, 250px);
    gap: 6px;
  }

  .app-shell.is-draw-phase .draw-slot {
    height: clamp(78px, 21vw, 94px);
    padding: 4px;
  }

  .app-shell.is-draw-phase .slot-card-art {
    width: clamp(38px, 11vw, 48px);
    height: calc(clamp(38px, 11vw, 48px) * 1.68);
  }

  .app-shell.is-draw-phase .slot-number {
    font-size: clamp(22px, 6vw, 28px);
  }

  .app-shell.is-draw-phase .slot-label {
    font-size: 11px;
  }

  .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll,
  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-scroll {
    height: clamp(365px, 50vh, 470px);
  }

  .app-shell.is-draw-phase .deck-fan {
    --deck-size: min(90vw, 410px);
    --card-w: clamp(40px, 10.8vw, 56px);
    --radius: min(38vw, 174px);
  }

  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(78px, 20vw, 98px);
  }

  body[data-deck-layout="matrix"] .app-shell.is-draw-phase .deck-fan {
    --card-w: clamp(76px, 19vw, 94px);
  }
}
/* Final pass 4: make draw slots photo-sized and align review cards with result cards. */
.app-shell.is-draw-phase .draw-slots {
  justify-items: center;
  width: min(100%, 260px);
  gap: clamp(6px, 1.2vw, 9px);
}

.app-shell.is-draw-phase .draw-slot {
  width: clamp(56px, 8.2vw, 70px);
  height: calc(clamp(56px, 8.2vw, 70px) * 1.68);
  padding: 4px;
  border-radius: 8px;
}

.app-shell.is-draw-phase .slot-card-art {
  width: 100%;
  height: 100%;
}

.app-shell.is-draw-phase .slot-card-title,
.app-shell.is-draw-phase .slot-card-name {
  display: none;
}

.app-shell.is-draw-phase .slot-number {
  font-size: clamp(20px, 3.8vw, 28px);
}

.app-shell.is-draw-phase .slot-label {
  font-size: 10px;
  line-height: 1.1;
}

.reading-panel.is-reviewing .draw-slots {
  width: min(100%, 760px);
  gap: 14px;
  margin: 22px auto 4px;
}

.reading-panel.is-reviewing .draw-slot {
  width: auto;
  height: auto;
  min-height: 0;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  justify-items: stretch;
  place-items: initial;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 24%, transparent);
  box-shadow: none;
}

.reading-panel.is-reviewing .draw-slot.is-filled {
  background: color-mix(in srgb, var(--surface) 24%, transparent);
}

.reading-panel.is-reviewing .slot-card-art {
  width: min(150px, 100%);
  height: 238px;
  justify-self: center;
}

.reading-panel.is-reviewing .slot-card-title {
  display: grid;
  gap: 6px;
  color: var(--ink);
}

.reading-panel.is-reviewing .slot-card-title span {
  color: var(--ink);
  font-size: 15px;
}

.reading-panel.is-reviewing .slot-card-title strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.28;
}

body[data-theme="dark"] .reading-panel.is-reviewing .draw-slot,
body[data-theme="dark"] .reading-panel.is-reviewing .draw-slot.is-filled {
  background: rgba(24, 27, 52, 0.34);
  border-color: rgba(232, 221, 194, 0.18);
}

body[data-theme="dark"] .reading-panel.is-reviewing .slot-card-title span,
body[data-theme="dark"] .reading-panel.is-reviewing .slot-card-title strong {
  color: #fbf7e8;
}

@media (max-width: 640px) {
  .app-shell.is-draw-phase .draw-slots {
    width: min(100%, 220px);
    gap: 6px;
  }

  .app-shell.is-draw-phase .draw-slot {
    width: clamp(48px, 13vw, 58px);
    height: calc(clamp(48px, 13vw, 58px) * 1.68);
  }

  .reading-panel.is-reviewing .draw-slots {
    width: 100%;
    gap: 10px;
  }

  .reading-panel.is-reviewing .draw-slot {
    padding: 10px;
    gap: 8px;
  }

  .reading-panel.is-reviewing .slot-card-art {
    width: min(74px, 100%);
    height: 126px;
  }

  .reading-panel.is-reviewing .slot-card-title span {
    font-size: 12px;
  }

  .reading-panel.is-reviewing .slot-card-title strong {
    font-size: 14px;
  }
}
/* Final pass 5: home cards, brain games, and filled draw slots. */
.home-panel,
.brain-panel {
  background: rgba(251, 252, 250, 0.9);
  border: 1px solid rgba(213, 222, 214, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 34px);
}

.app-shell.is-home-phase,
.app-shell.is-brain-phase {
  grid-template-columns: minmax(0, 900px);
  justify-content: center;
}

.home-panel {
  min-height: min(760px, calc(100vh - 80px));
  display: grid;
  align-content: center;
  gap: clamp(24px, 5vw, 44px);
}

.home-copy {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 3vw, 22px);
  width: min(100%, 760px);
  margin: 0 auto;
}

.feature-card {
  min-height: clamp(230px, 32vw, 320px);
  padding: 22px 16px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  border: 1px solid rgba(185, 161, 93, 0.42);
  border-radius: 12px;
  background:
    radial-gradient(circle at top, rgba(246, 224, 93, 0.16), transparent 44%),
    linear-gradient(180deg, rgba(28, 31, 60, 0.94), rgba(14, 16, 35, 0.98));
  color: #fbf7e8;
  box-shadow: 0 18px 42px rgba(12, 13, 28, 0.22);
  cursor: pointer;
  text-align: center;
}

.feature-card:not(.is-disabled):hover {
  transform: translateY(-4px);
  border-color: rgba(246, 224, 93, 0.72);
}

.feature-card-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(246, 224, 93, 0.64);
  border-radius: 50%;
  color: #f6e05d;
  font-family: Georgia, serif;
}

.feature-card strong {
  font-size: clamp(24px, 4.5vw, 34px);
}

.feature-card small,
.brain-game-card small {
  color: color-mix(in srgb, currentColor 70%, transparent);
  font-size: 13px;
  line-height: 1.5;
}

.feature-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.brain-panel[hidden],
.home-panel[hidden] {
  display: none;
}

.brain-lead {
  margin-bottom: 18px;
}

.brain-game-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.brain-game-card,
.game-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.brain-game-card {
  min-height: 150px;
  padding: 18px;
  display: grid;
  gap: 8px;
  align-content: start;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.brain-game-card:hover {
  transform: translateY(-2px);
  border-color: rgba(185, 161, 93, 0.6);
}

.brain-game-card span {
  color: var(--gold);
  font-weight: 800;
}

.brain-game-card strong {
  font-size: 20px;
}

.game-panel {
  padding: clamp(16px, 3vw, 24px);
}

.game-panel[hidden],
.brain-game-menu[hidden] {
  display: none;
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.game-stats span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  color: var(--muted);
  font-size: 13px;
}

.game-stats strong {
  color: var(--ink);
}

.schulte-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(100%, 430px);
  margin: 16px auto 0;
}

.schulte-cell {
  aspect-ratio: 1;
  border: 1px solid rgba(185, 161, 93, 0.34);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(18px, 4vw, 28px);
  font-weight: 800;
}

.schulte-cell.is-found {
  background: rgba(185, 161, 93, 0.22);
  color: var(--muted);
}

.schulte-cell.is-wrong {
  border-color: #c75f70;
  box-shadow: 0 0 0 3px rgba(199, 95, 112, 0.16);
}

.moon-stage {
  width: min(100%, 440px);
  min-height: 300px;
  margin: 18px auto 0;
  display: grid;
  place-items: center;
  gap: 12px;
  border: 1px solid rgba(185, 161, 93, 0.32);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(246, 224, 93, 0.15), transparent 32%),
    rgba(20, 23, 48, 0.92);
  color: #fbf7e8;
  cursor: pointer;
}

.moon-signal {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(246, 224, 93, 0.86);
  color: #1b1e3a;
  font-size: 40px;
  box-shadow: 0 0 44px rgba(246, 224, 93, 0.36);
}

.moon-stage.is-green .moon-signal {
  background: #9ad8a1;
}

.moon-stage.is-red .moon-signal {
  background: #cc6f7d;
}

.reverse-stage {
  position: relative;
  min-height: 300px;
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 150px 1fr;
  gap: 12px;
  align-items: stretch;
}

.reverse-zone {
  border: 1px solid rgba(185, 161, 93, 0.32);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 68%, transparent);
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  font-weight: 800;
}

.reverse-signal {
  align-self: center;
  min-height: 150px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(246, 224, 93, 0.82);
  color: #1b1e3a;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 0 38px rgba(246, 224, 93, 0.28);
}

.reverse-stage.signal-left .reverse-zone[data-side="left"],
.reverse-stage.signal-right .reverse-zone[data-side="right"] {
  border-color: rgba(246, 224, 93, 0.72);
  box-shadow: inset 0 0 32px rgba(246, 224, 93, 0.16);
}

.reverse-stage.signal-red .reverse-signal {
  background: #cc6f7d;
  color: #fff;
}

.game-finish {
  min-height: 28px;
  margin: 14px 0 0;
  color: var(--accent-strong);
  font-weight: 800;
}

.app-shell.is-draw-phase .draw-slot.is-filled {
  padding: 0;
  overflow: hidden;
}

.app-shell.is-draw-phase .draw-slot.is-filled .slot-card-art {
  width: 100%;
  height: 100%;
}

.app-shell.is-draw-phase .draw-slot.is-filled .card-art,
.app-shell.is-draw-phase .draw-slot.is-filled .card-art img {
  width: 100%;
  height: 100%;
}

@media (max-width: 640px) {
  .feature-cards,
  .brain-game-menu {
    grid-template-columns: 1fr;
  }

  .feature-card {
    min-height: 160px;
  }

  .game-header {
    display: grid;
  }

  .reverse-stage {
    min-height: 240px;
    grid-template-columns: 1fr 104px 1fr;
  }

  .reverse-signal {
    min-height: 104px;
    font-size: 14px;
  }
}
/* Final pass 6: slot labels, dark contrast, wider fan, and music controls. */
.app-shell.is-draw-phase .draw-slot {
  overflow: hidden;
}

.app-shell.is-draw-phase .draw-slot:not(.is-filled) {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  align-content: stretch;
  padding: 7px 4px 6px;
}

.app-shell.is-draw-phase .draw-slot:not(.is-filled) .slot-flight-target {
  display: none;
}

.app-shell.is-draw-phase .slot-number {
  align-self: center;
  font-size: clamp(22px, 4.2vw, 30px);
  line-height: 1;
  margin: 0;
}

.app-shell.is-draw-phase .slot-label {
  align-self: end;
  max-width: 100%;
  margin: 0;
  color: rgba(111, 79, 99, 0.72);
  font-size: 10px;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
}

body[data-theme="dark"] .app-shell.is-draw-phase .slot-label,
body[data-theme="dark"] .app-shell.is-draw-phase .slot-number {
  color: rgba(251, 247, 232, 0.58);
}

body[data-theme="dark"] .home-panel,
body[data-theme="dark"] .brain-panel {
  background: rgba(24, 27, 52, 0.9);
  border-color: rgba(232, 221, 194, 0.2);
}

body[data-theme="dark"] .home-panel h1,
body[data-theme="dark"] .brain-panel h2,
body[data-theme="dark"] .brain-panel h3,
body[data-theme="dark"] .home-panel .lead,
body[data-theme="dark"] .brain-panel .lead,
body[data-theme="dark"] .brain-game-card,
body[data-theme="dark"] .game-panel,
body[data-theme="dark"] .game-panel p {
  color: #fbf7e8;
}

body[data-theme="dark"] .home-panel .lead,
body[data-theme="dark"] .brain-panel .lead,
body[data-theme="dark"] .brain-game-card small,
body[data-theme="dark"] .game-panel p,
body[data-theme="dark"] .deck-guidance,
body[data-theme="dark"] .swipe-hint,
body[data-theme="dark"] .ai-status {
  color: rgba(251, 247, 232, 0.74);
}

body[data-theme="dark"] .question-summary {
  background: rgba(24, 27, 52, 0.72);
  border-color: rgba(246, 224, 93, 0.58);
  color: #fbf7e8;
}

body[data-theme="dark"] .question-summary p {
  color: #fbf7e8;
}

body[data-theme="dark"] .question-summary span,
body[data-theme="dark"] .eyebrow,
body[data-theme="dark"] .card-core,
body[data-theme="dark"] .ai-card span {
  color: #f6e05d;
}

body[data-theme="dark"] .ai-card p,
body[data-theme="dark"] .synthesis p,
body[data-theme="dark"] .result-panel p {
  color: rgba(251, 247, 232, 0.88);
}

body[data-theme="dark"] .brain-game-card,
body[data-theme="dark"] .game-panel,
body[data-theme="dark"] .reverse-zone,
body[data-theme="dark"] .schulte-cell {
  background: rgba(18, 21, 44, 0.78);
  border-color: rgba(232, 221, 194, 0.18);
}

body[data-theme="dark"] .game-stats span {
  background: rgba(18, 21, 44, 0.72);
  border-color: rgba(232, 221, 194, 0.18);
  color: rgba(251, 247, 232, 0.72);
}

body[data-theme="dark"] .game-stats strong,
body[data-theme="dark"] .reverse-zone,
body[data-theme="dark"] .schulte-cell {
  color: #fbf7e8;
}

.brain-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-scroll {
  width: min(100%, 720px);
  max-width: 720px;
  overflow: hidden;
}

body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
  width: 128%;
  max-width: none;
  margin-left: -14%;
  --card-w: clamp(92px, 16vw, 132px);
}

@media (max-width: 640px) {
  .app-shell.is-draw-phase .slot-number {
    font-size: clamp(20px, 5.8vw, 26px);
  }

  .app-shell.is-draw-phase .slot-label {
    font-size: 9px;
  }

  body[data-deck-layout="fan"] .app-shell.is-draw-phase .deck-fan {
    width: 142%;
    margin-left: -21%;
    --card-w: clamp(84px, 23vw, 108px);
  }
}
