/* ชิ้นส่วนกลางที่ทุกหน้าใช้: ปุ่ม การ์ด ไพ่ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; line-height: 1.25; margin: 0 0 var(--space-s); }
p { margin: 0 0 var(--space-m); }
.muted { color: var(--text-secondary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-s);
  font-family: var(--font-heading); font-weight: 500; font-size: 1rem;
  padding: 12px var(--space-l);
  border: 2px solid transparent; border-radius: var(--radius-button);
  background: var(--color-primary); color: #fff;
  cursor: pointer; text-decoration: none;
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255, 107, 0, .3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn-outline { background: transparent; color: var(--color-secondary); border-color: var(--color-secondary); }
.btn-outline:hover { box-shadow: none; background: #f4f4f4; }

.card {
  background: #fff; border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: var(--space-l);
}

/* ---------- หัวเว็บ / ท้ายเว็บ (ทุกหน้า) ---------- */
.topbar {
  height: 56px; padding: 0 var(--space-m);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-secondary); color: #fff;
}
.logo { font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem; color: #fff; text-decoration: none; }
.logo span { color: var(--color-primary); }
.step { font-size: .9rem; color: #ccc; }
.topbar a.nav { color: #fff; text-decoration: none; font-size: .9rem; }

.footer { padding: var(--space-l) var(--space-m) 40px; text-align: center; color: var(--text-secondary); font-size: .85rem; }
.footer a { color: var(--text-secondary); }

/* ---------- ป้ายคุกกี้ ---------- */
.cookie {
  position: fixed; left: var(--space-m); right: var(--space-m); bottom: var(--space-m); z-index: 2000;
  max-width: 560px; margin: 0 auto; padding: var(--space-m);
  display: flex; flex-wrap: wrap; gap: var(--space-s) var(--space-m); align-items: center;
  animation: cookieIn .4s ease;
}
.cookie p { margin: 0; flex: 1 1 260px; font-size: .9rem; }
.cookie .btns { display: flex; gap: var(--space-s); }
.cookie .btn { padding: 8px 16px; font-size: .9rem; }
@keyframes cookieIn { from { transform: translateY(20px); opacity: 0; } }

/* ---------- ไพ่ ---------- */
.tcard { position: absolute; width: var(--card-w); height: var(--card-h); perspective: 800px; }
.tcard-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .3, 1);
}
.tcard.flipped .tcard-inner { transform: rotateY(180deg); }
.tcard-face {
  position: absolute; inset: 0; border-radius: calc(var(--card-w) * .12);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
}
/* หลังไพ่: หินอ่อนขาว (marble.webp) + ลายเส้นโรสโกลด์ (back.svg) */
.tcard-back {
  background: url(/cards/back.svg) center / 100% 100% no-repeat, #fafaf8 url(/cards/marble.webp) center / cover;
  border: 1px solid #E6D6CA;
  box-shadow: 0 2px 10px rgba(80, 50, 30, .22);
}
/* หน้าไพ่ (ชั่วคราว จนกว่าจะมีภาพจริง) */
.tcard-front {
  transform: rotateY(180deg);
  background: var(--color-cream); border: 3px solid var(--color-secondary);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 8% 6%; text-align: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.tcard-front .no { font-family: var(--font-heading); font-weight: 700; color: var(--color-primary); font-size: calc(var(--card-w) * .14); }
.tcard-front .art {
  width: 70%; aspect-ratio: 1; border-radius: 50%;
  background: var(--color-primary); color: #fff; display: grid; place-items: center;
  font-size: calc(var(--card-w) * .3); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12);
}
.tcard-front .name { font-family: var(--font-heading); font-weight: 700; font-size: calc(var(--card-w) * .12); line-height: 1.2; }
.tcard-front .en { font-size: calc(var(--card-w) * .075); color: var(--text-secondary); }
.tcard.reversed .tcard-front { transform: rotateY(180deg) rotate(180deg); }

/* ---------- โลโก้: ไพ่ 2 ใบ · ชี้เมาส์แล้วสลับไพ่วนไปเรื่อยๆ ---------- */
.logo { display: inline-flex; align-items: center; height: 100%; }
.deck { position: relative; display: block; width: 54px; height: 50px; }
.lc {
  position: absolute; left: 50%; top: 50%; width: auto; height: 42px; margin: -21px 0 0 -14px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35));
  transition: transform .3s ease;
}
/* ท่าปกติ: ใบหน้าเอียงนิดเดียว ใบหลังเอียงมากกว่า เหมือนรูปต้นฉบับ */
.lc1 { z-index: 2; transform: translate(2px, 0) rotate(-6.5deg); }
.lc2 { z-index: 1; transform: translate(-5px, 2px) rotate(-25deg); }
.logo:hover .lc, .logo:focus-visible .lc { animation: deck-swap 1.6s cubic-bezier(.45, 0, .3, 1) infinite; }
.logo:hover .lc2, .logo:focus-visible .lc2 { animation-delay: -.8s; }
/* หนึ่งรอบ = ใบนี้เลื่อนออกขวา → มุดไปอยู่ข้างหลัง → ค่อยๆ เลื่อนกลับมาข้างหน้า */
@keyframes deck-swap {
  0%   { z-index: 2; transform: translate(2px, 0) rotate(-6.5deg); }
  22%  { z-index: 2; transform: translate(22px, -4px) rotate(14deg); }
  28%  { z-index: 1; transform: translate(20px, -2px) rotate(10deg); }
  50%  { z-index: 1; transform: translate(-5px, 2px) rotate(-25deg); }
  78%  { z-index: 1; transform: translate(-5px, 2px) rotate(-25deg); }
  79%  { z-index: 2; transform: translate(-4px, 2px) rotate(-22deg); }
  100% { z-index: 2; transform: translate(2px, 0) rotate(-6.5deg); }
}
@media (prefers-reduced-motion: reduce) { .logo:hover .lc, .logo:focus-visible .lc { animation: none; } }

/* ฟอนต์ลายมือสำหรับคำว่า "เริ่มดูดวง" — ถ้าได้ไฟล์ Vanilla มา ใส่ url(/fonts/vanilla.woff2) ใน @font-face ด้านล่าง ตอนนี้ใช้ Mali แทน */
@font-face { font-family: "Vanilla"; src: local("Vanilla"); font-display: swap; }
.font-fun { font-family: "Vanilla", "Mali", var(--font-heading); font-weight: 700; letter-spacing: .01em; }
