/* ===== หน้าไพ่ทาโรต์ ===== */
body { overflow-x: hidden; }

.tarot {
  position: relative; z-index: 5;
  max-width: 1080px; margin: 0 auto;
  padding: 0 16px 60px; text-align: center;
}
.tarot-head { margin-bottom: 26px; animation: rise .9s ease both; }
.step { animation: rise .7s ease both; }
.step[hidden] { display: none; }

/* ---------- ขั้น 1 ---------- */
.question { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 0 auto 26px; text-align: left; color: var(--muted); font-size: .95rem; }
.question small { opacity: .7; }
.question input {
  font: inherit; color: var(--text); padding: 13px 18px; border-radius: 14px;
  background: rgba(10, 4, 30, .6); border: 1px solid rgba(245, 201, 107, .25); outline: none;
  transition: border-color .25s, box-shadow .25s;
}
.question input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 201, 107, .18); }

.deck-choice { display: inline-flex; gap: 4px; padding: 4px; margin: -8px auto 24px; border-radius: 999px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); flex-wrap: wrap; justify-content: center; }
.deck-choice input { position: absolute; opacity: 0; pointer-events: none; }
.deck-choice span { display: block; padding: 8px 18px; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: .92rem; transition: background .3s, color .3s; }
.deck-choice input:checked + span { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1503; font-weight: 600; }
.deck-choice input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.spreads { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.spread {
  position: relative; overflow: hidden;
  padding: 26px 20px 24px; border-radius: 20px; text-align: center;
  background: linear-gradient(170deg, rgba(50, 25, 110, .7), rgba(15, 6, 40, .8));
  border: 1px solid var(--line);
  transition: transform .3s, border-color .3s, box-shadow .3s;
}
.spread::before {
  content: ""; position: absolute; inset: -50%;
  background: conic-gradient(from 0deg, transparent, rgba(245, 201, 107, .25), transparent 30%);
  animation: spin 6s linear infinite; opacity: 0; transition: opacity .3s;
}
.spread:hover { transform: translateY(-6px); border-color: var(--gold); box-shadow: 0 16px 50px rgba(123, 77, 255, .4); }
.spread:hover::before { opacity: 1; }
.spread > * { position: relative; }
.spread .ico { display: block; font-size: 2.2rem; color: var(--gold); text-shadow: 0 0 16px var(--gold); margin-bottom: 8px; }
.spread .nm { display: block; font-size: 1.2rem; font-weight: 500; color: var(--gold-2); }
.spread .ds { display: block; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.spread .cnt { display: inline-block; margin-top: 12px; padding: 3px 12px; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); color: var(--gold); }

/* ---------- ไพ่ทั่วไป ---------- */
.tcard {
  --w: clamp(52px, 9vw, 84px);
  position: relative; width: var(--w); height: calc(var(--w) * var(--ratio, 1.62));
  perspective: 900px;
}
.tcard-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateY(180deg);
  transition: transform 1s cubic-bezier(.3, 1.4, .5, 1);
}
.tcard.flipped .tcard-inner { transform: rotateY(0deg); }
.tcard.reversed .face.front { transform: rotate(180deg); }
.tcard .face.front .th { font-size: calc(var(--w) * .11); color: var(--muted); }

/* ---------- ขั้น 2 ---------- */
.slots { display: flex; justify-content: center; gap: clamp(12px, 4vw, 40px); flex-wrap: wrap; margin-bottom: 18px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.slot .tcard { --w: clamp(70px, 14vw, 110px); }
.slot-box {
  position: relative; width: clamp(70px, 14vw, 110px); aspect-ratio: 1 / var(--ratio, 1.62);
  border-radius: 12px; border: 2px dashed rgba(245, 201, 107, .35);
  display: grid; place-items: center; color: rgba(245, 201, 107, .4); font-size: 1.6rem;
  animation: breathe 2.4s ease-in-out infinite;
}
.slot-box.filled { border: 0; animation: none; }
.slot-box.filled .tcard { position: absolute; inset: 0; animation: land .6s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes land { from { transform: translateY(160px) scale(.6) rotate(-20deg); opacity: 0; } }
@keyframes breathe { 50% { border-color: rgba(245, 201, 107, .75); box-shadow: 0 0 20px rgba(245, 201, 107, .25); } }
.slot-label { font-size: .9rem; color: var(--gold-2); max-width: clamp(80px, 16vw, 130px); line-height: 1.4; }

.deck-area { transition: height .6s ease; position: relative; height: clamp(230px, 34vw, 330px); margin: 10px auto 10px; }
.deck { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: 84px; height: 136px; }
.deck .tcard { --w: 84px; position: absolute; left: 0; top: 0; }
.deck .tcard:nth-child(n) { transform: translate(calc(var(--i) * -1.5px), calc(var(--i) * -1.5px)); }
.deck.shuffling .tcard:nth-child(odd) { animation: riffleL .45s ease-in-out 3; }
.deck.shuffling .tcard:nth-child(even) { animation: riffleR .45s ease-in-out 3; }
@keyframes riffleL { 50% { transform: translate(-70px, -10px) rotate(-14deg); } }
@keyframes riffleR { 50% { transform: translate(70px, -10px) rotate(14deg); } }
.deck.gone { opacity: 0; transform: translateX(-50%) scale(.6); transition: all .4s; }

.fan { position: absolute; inset: 0; }
.fan-card {
  position: absolute; left: 50%; bottom: var(--lift, 0px);
  margin-left: calc(var(--w) / -2);
  transform-origin: 50% var(--origin);
  transform: rotate(var(--rot));
  opacity: 0; animation: deal .5s ease forwards; animation-delay: var(--delay);
  cursor: pointer;
}
.fan-card .tcard-inner { transition: transform .25s ease; }
.fan-card:hover .tcard-inner, .fan-card:focus-visible .tcard-inner { transform: rotateY(180deg) translateY(-28px); }
.fan-card:hover .face, .fan-card:focus-visible .face { box-shadow: 0 0 26px var(--gold), inset 0 0 0 3px rgba(20, 8, 50, .9), inset 0 0 0 4px var(--gold-3); }
.fan-card:focus-visible { outline: none; }
.fan-card.taken { pointer-events: none; animation: takeOut .5s ease forwards; }
@keyframes deal { from { opacity: 0; transform: rotate(0deg); } to { opacity: 1; transform: rotate(var(--rot)); } }
@keyframes takeOut { from { opacity: 1; transform: rotate(var(--rot)); } to { opacity: 0; transform: rotate(var(--rot)) translateY(-200px) scale(.6); } }
.fan.done .fan-card:not(.taken) { animation: fanAway .6s ease forwards; pointer-events: none; }
@keyframes fanAway { from { opacity: 1; transform: rotate(var(--rot)); } to { opacity: 0; transform: rotate(0deg) translateY(40px); } }

.actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 20px; }
.actions [hidden] { display: none; }

/* ---------- ขั้น 3 ---------- */
.your-q { color: var(--gold-2); font-size: 1.05rem; margin-bottom: 20px; font-style: italic; }
.readings { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
.reading {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 24px 20px; border-radius: 22px;
  background: linear-gradient(170deg, rgba(45, 22, 100, .72), rgba(12, 5, 35, .85));
  border: 1px solid var(--line);
  opacity: 0; animation: rise .7s ease forwards; animation-delay: var(--delay);
}
.reading .pos { font-size: .85rem; letter-spacing: .15em; color: var(--muted); }
.reading .tcard { --w: clamp(110px, 26vw, 140px); margin: 6px 0 4px; filter: drop-shadow(0 10px 30px rgba(123, 77, 255, .5)); }
.reading h3 { font-family: "Charm", serif; font-size: 1.9rem; line-height: 1.2; color: var(--gold-2); }
.reading .en { font-family: "Cinzel Decorative", serif; font-size: .8rem; color: var(--gold); margin-top: -6px; }
.badge { padding: 3px 12px; border-radius: 999px; font-size: .78rem; border: 1px solid; }
.badge.up { color: #8ff0b5; border-color: rgba(143, 240, 181, .5); background: rgba(143, 240, 181, .08); }
.badge.rev { color: #ffb38a; border-color: rgba(255, 179, 138, .5); background: rgba(255, 179, 138, .08); }
.reading .suit { font-size: .78rem; color: var(--muted); letter-spacing: .05em; }
.reading .kw { color: var(--gold); font-size: .88rem; }
.reading p { color: var(--text); font-weight: 300; line-height: 1.7; }
.summary {
  margin: 26px auto 0; max-width: 720px; padding: 22px 24px; border-radius: 20px;
  border: 1px solid var(--gold); background: rgba(245, 201, 107, .07);
  color: var(--gold-2); line-height: 1.8; font-weight: 300;
  opacity: 0; animation: rise .8s ease forwards; animation-delay: var(--delay, 1s);
}
.summary strong { font-weight: 500; color: #fff; }
.disclaimer { margin-top: 26px; color: var(--muted); font-size: .78rem; opacity: .7; }

@media (max-width: 560px) {
  .deck-area { height: 220px; }
  .actions { flex-direction: column; }
  .actions > * { width: 100%; }
}

/* ฟอนต์ Charm: เว้นบรรทัดให้สระบนไม่ชน */
.reading h3 { line-height: 1.65; padding-top: .1em; }
.reading .en { margin-top: -2px; }

/* ---------- สำรับไพ่ที่มีภาพ (tarot-decks.js) · งานศิลป์คงสีเดิมทั้งโหมดมืดและสว่าง ---------- */
/* ภาพมีเลขและชื่อไพ่พิมพ์อยู่แล้ว → contain (ไม่ครอปจนชื่อหาย) บนพื้นสีเดียวกับขอบภาพของแต่ละสำรับ */
.face.front.has-art { padding: 0; gap: 0; background: #f6efe0; }
.face.front.has-art img.art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
body[data-deck="amethyst"] .face.front.has-art { background: #2a1446; }
body[data-deck="classic"] .face.front.has-art { background: #efe3c4; }
body[data-deck="doodles"] .face.front.has-art, body[data-deck="love"] .face.front.has-art { background: #fffdf7; }
body[data-deck="whiskers"] .face.front.has-art { background: #f3ead6; }

/* หลังไพ่ต่อสำรับ: ลายสมมาตรเมื่อหมุน 180° (ดูจากหลังไพ่ไม่ออกว่าใบไหนกลับหัว) */
.face.back.back-amethyst, .card-face.back-amethyst {
  background:
    radial-gradient(circle, transparent 17%, rgba(245, 201, 107, .75) 18%, transparent 20%),
    radial-gradient(circle, transparent 31%, rgba(245, 201, 107, .45) 32%, transparent 33.5%),
    repeating-conic-gradient(rgba(245, 201, 107, .16) 0 6deg, transparent 6deg 15deg),
    radial-gradient(circle, #3b1a63, #1a0a33 70%);
}
.face.back.back-amethyst::before { content: "✦"; }
.face.back.back-classic, .card-face.back-classic {
  border-color: #c9b98f;
  box-shadow: inset 0 0 0 4px #efe6cf, inset 0 0 0 5px #8a7a52;
  background:
    repeating-linear-gradient(45deg, rgba(239, 230, 207, .35) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(239, 230, 207, .35) 0 1px, transparent 1px 9px),
    #1f3a6b;
}
.face.back.back-picnic, .card-face.back-picnic {
  border-color: #f6efe0;
  box-shadow: inset 0 0 0 4px #f6efe0;
  background:
    radial-gradient(circle, #f9e7b0 0 12%, transparent 13%),
    radial-gradient(circle, transparent 0 24%, rgba(249, 231, 176, .55) 25% 26%, transparent 27%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .14) 0 10px, transparent 10px 20px),
    #9c86c4;
}
.face.back.back-doodles, .card-face.back-doodles {
  border-color: #2e2a26;
  box-shadow: inset 0 0 0 4px #fffdf7, inset 0 0 0 5px #2e2a26;
  background:
    radial-gradient(circle, #ffd84d 0 13%, #2e2a26 13.5% 14.5%, transparent 15%),
    radial-gradient(circle, transparent 0 33%, #fff1a8 34%),
    repeating-conic-gradient(#ffd84d 0 9deg, #fff1a8 9deg 30deg);
}
.face.back.back-whiskers, .card-face.back-whiskers {
  border-color: #c9b98f;
  box-shadow: inset 0 0 0 4px #f3ead6, inset 0 0 0 5px #8a7a52;
  background:
    radial-gradient(circle, #f3d58a 0 10%, transparent 11%),
    radial-gradient(circle, transparent 0 20%, rgba(243, 213, 138, .6) 21% 22%, transparent 23%),
    radial-gradient(rgba(243, 234, 214, .5) 1px, transparent 1.5px) 0 0 / 14px 14px,
    #2d3550;
}
.face.back.back-love, .card-face.back-love {
  border-color: #f4a6c0;
  box-shadow: inset 0 0 0 4px #fffdf7, inset 0 0 0 5px #f4a6c0;
  background:
    radial-gradient(circle, #ff6f91 0 11%, transparent 12%),
    radial-gradient(circle, transparent 0 22%, #ffd1dc 23% 25%, transparent 26%),
    radial-gradient(#ffffff 1.2px, transparent 1.8px) 0 0 / 16px 16px,
    #ffb3c7;
}
.face.back.back-classic::before, .face.back.back-picnic::before, .face.back.back-doodles::before,
.face.back.back-whiskers::before, .face.back.back-love::before { content: none; }


/* ---------- ขั้นเลือกสำรับ: แกลเลอรี ---------- */
.deck-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-width: 760px; margin: 0 auto 8px; }
.deck-gallery[hidden] { display: none; }
.dg-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px 12px; border-radius: 18px;
  border: 1px solid var(--line); background: linear-gradient(170deg, rgba(50, 25, 110, .6), rgba(15, 6, 40, .75));
  color: var(--text); font: inherit; cursor: pointer; transition: border-color .2s, box-shadow .2s, transform .2s;
}
.dg-item:hover { transform: translateY(-3px); }
.dg-item[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 10px 30px rgba(245, 201, 107, .25); }
.dg-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.dg-fan { position: relative; width: 120px; height: 96px; margin-bottom: 6px; }
.dg-card { position: absolute; left: 50%; bottom: 0; width: 50px; aspect-ratio: 2 / 3; border-radius: 6px; border: 1.5px solid rgba(245, 201, 107, .7);
  transform-origin: 50% 120%; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); background-color: #f6efe0; }
.dg-card.card-face { transform: translateX(-50%) rotate(-24deg); }
.dg-face { object-fit: cover; transform: translateX(-50%) rotate(calc(-8deg + var(--k) * 16deg)); }
.dg-item[aria-checked="true"] .dg-face { animation: dgLift .5s ease both; }
@keyframes dgLift { from { transform: translateX(-50%) rotate(0deg); } }
.dg-name { font-weight: 500; color: var(--gold-2); font-size: .95rem; }
.dg-desc { font-size: .75rem; color: var(--muted); line-height: 1.45; font-weight: 300; }
.dg-item[aria-checked="true"] .dg-name::before { content: "✓ "; color: var(--gold); }

/* ---------- โต๊ะแม่หมอ ---------- */
.seer-table { position: relative; max-width: 720px; margin: -6px auto 0; }
.seer-figure { position: relative; height: 150px; display: flex; justify-content: center; pointer-events: none; }
.seer-pic { width: 210px; height: auto; margin-top: -24px; filter: drop-shadow(0 0 22px rgba(160, 90, 255, .55)); animation: seerBreath 6s ease-in-out infinite; }
@keyframes seerBreath { 50% { transform: translateY(-4px); } }
.seer-say {
  position: relative; z-index: 3; max-width: 520px; margin: -6px auto 12px; padding: 10px 16px; border-radius: 16px;
  background: rgba(20, 8, 50, .82); border: 1px solid rgba(245, 201, 107, .45); color: #fff3d6; font-size: .92rem; line-height: 1.6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.seer-say::before { content: ""; position: absolute; left: 50%; top: -7px; width: 12px; height: 12px; margin-left: -6px; transform: rotate(45deg);
  background: inherit; border-left: 1px solid rgba(245, 201, 107, .45); border-top: 1px solid rgba(245, 201, 107, .45); }
.seer-say.pop { animation: sayPop .35s ease; }
@keyframes sayPop { from { opacity: 0; transform: translateY(6px); } }
.seer-say:empty { display: none; }
.cloth {
  position: relative; padding: 22px 12px 16px; border-radius: 28px 28px 22px 22px; overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, transparent 0 26%, rgba(245, 201, 107, .22) 26.4% 26.9%, transparent 27.3%),
    radial-gradient(circle at 50% 40%, transparent 0 33%, rgba(245, 201, 107, .14) 33.3% 33.6%, transparent 34%),
    radial-gradient(120% 90% at 50% 0%, #5b2392 0%, #3a1468 45%, #1f0a3d 100%);
  border: 1px solid rgba(245, 201, 107, .55);
  box-shadow: inset 0 0 0 6px rgba(20, 8, 50, .35), inset 0 0 0 7px rgba(245, 201, 107, .35), inset 0 -30px 60px rgba(0, 0, 0, .35), 0 20px 50px rgba(0, 0, 0, .4);
}
.cloth .slots { margin-bottom: 8px; }
.cloth .deck-area { height: clamp(200px, 30vw, 280px); margin: 0 auto; overflow: visible; }
.slot-box.filled .tcard.flipped { filter: drop-shadow(0 0 14px rgba(245, 201, 107, .6)); }
#changeDeckBtn[hidden] { display: none; }

/* สรุปจากแม่หมอ: หลายย่อหน้า */
.summary { text-align: left; }
.summary p { margin: 0 0 10px; }
.summary p:last-child { margin-bottom: 0; }
.summary .sum-head { text-align: center; margin-bottom: 12px; }

@media (max-width: 560px) {
  .deck-gallery { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dg-fan { width: 104px; height: 84px; }
  .dg-card { width: 44px; }
  .seer-figure { height: 120px; }
  .seer-pic { width: 170px; }
  .cloth .deck-area { height: 190px; }
}

/* หมายเหตุไพ่กลับหัว: อธิบายให้คนที่ไม่คุ้นกับทาโรต์ */
.rev-note { max-width: 720px; margin: 0 auto 18px; padding: 14px 18px; border-radius: 16px; text-align: left;
  background: rgba(255, 179, 138, .08); border: 1px solid rgba(255, 179, 138, .45); color: var(--text); font-size: .9rem; line-height: 1.7; font-weight: 300; }
.rev-note[hidden] { display: none; }
.rev-note b { display: block; color: #ffb38a; font-weight: 500; margin-bottom: 4px; }
.rev-note p + p { margin-top: 6px; }

/* เรื่องที่อยากถาม */
.topic-pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 560px; margin: -10px auto 22px; }
.topic-pick[hidden] { display: none; }
.topic-pick .tp-label { flex-basis: 100%; text-align: left; color: var(--muted); font-size: .9rem; }
.topic-pick button { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(30, 16, 70, .5);
  color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; transition: border-color .2s, background .2s; }
.topic-pick button[aria-checked="true"] { border-color: var(--gold); background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1503; font-weight: 600; }
.topic-pick button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
