/* ===== ธีมมูเตลู: ท้องฟ้ากลางคืน + ทอง + Kanit ===== */
:root {
  --bg-deep: #0b0720;
  --bg-mid: #1a1040;
  --gold: #e8c66b;
  --gold-soft: #f4dfa0;
  --purple: #7c5cff;
  --purple-glow: #9d7bff;
  --text: #ece6ff;
  --text-dim: #b6acd8;
  --card-bg: rgba(28, 18, 64, 0.72);
  --card-border: rgba(232, 198, 107, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Kanit', sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% -10%, #2a1a5e 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, #3a1f5c 0%, transparent 45%),
    linear-gradient(160deg, var(--bg-deep), var(--bg-mid));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.65;
  overflow-x: hidden;
}

/* ดาวระยิบ */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 70% 60%, #fff, transparent),
    radial-gradient(1px 1px at 40% 80%, #fff, transparent),
    radial-gradient(1px 1px at 85% 20%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff, transparent),
    radial-gradient(1px 1px at 10% 65%, #fff, transparent),
    radial-gradient(1px 1px at 92% 75%, #fff, transparent);
  background-size: 100% 100%;
  opacity: 0.5;
  animation: twinkle 5s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.25; } to { opacity: 0.6; } }

.container {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 22px 32px;
  position: relative;
  z-index: 1;
}

/* หัวเรื่อง */
.brand {
  text-align: center;
  margin-bottom: 36px;
  animation: rise 0.7s ease both;
}
.brand .moon { font-size: 52px; display: block; filter: drop-shadow(0 0 14px var(--gold)); }
.brand h1 {
  font-family: 'Cinzel', 'Kanit', serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 1px;
  margin-top: 8px;
  background: linear-gradient(120deg, var(--gold-soft), var(--gold), #c79a3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand p { color: var(--text-dim); font-weight: 300; font-size: 15px; margin-top: 4px; }

/* การ์ดกล่องเนื้อหา */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 28px 26px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255,255,255,0.03);
  animation: rise 0.8s ease both;
}

/* ฟอร์ม */
label { display: block; font-weight: 500; margin-bottom: 10px; color: var(--gold-soft); }
textarea, .spread-grid { width: 100%; }
textarea {
  background: rgba(10, 6, 28, 0.7);
  border: 1px solid rgba(232,198,107,0.25);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 14px 16px;
  resize: vertical;
  min-height: 92px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,198,107,0.15); }

.preset-select {
  width: 100%;
  background: rgba(10, 6, 28, 0.7);
  border: 1px solid rgba(232,198,107,0.25);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 13px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23e8c66b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.preset-select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,198,107,0.15); }
/* เมนูที่กางออก (popup) บังคับพื้นเข้มให้อ่านออกทุกเบราว์เซอร์ */
.preset-select option { background: #150c36; color: var(--text); }
.preset-select optgroup { background: #0b0720; color: var(--gold); font-weight: 600; }

.spread-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 26px; }
.spread-opt input { display: none; }
.spread-opt label {
  display: block;
  text-align: center;
  padding: 16px 10px;
  border: 1px solid rgba(232,198,107,0.25);
  border-radius: 14px;
  cursor: pointer;
  margin: 0;
  color: var(--text);
  font-weight: 400;
  transition: all 0.2s;
}
.spread-opt label .big { display: block; font-size: 22px; margin-bottom: 4px; }
.spread-opt label small { color: var(--text-dim); font-weight: 300; }
.spread-opt input:checked + label {
  border-color: var(--gold);
  background: rgba(232,198,107,0.12);
  box-shadow: 0 0 18px rgba(232,198,107,0.2);
}

/* ปุ่ม */
.btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  font-family: inherit;
  font-weight: 600;
  font-size: 17px;
  padding: 15px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #1a1040;
  background: linear-gradient(120deg, var(--gold-soft), var(--gold));
  box-shadow: 0 10px 28px rgba(232,198,107,0.3);
  transition: transform 0.15s, box-shadow 0.2s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(232,198,107,0.45); }
.btn:active { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  box-shadow: none;
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 400;
  font-size: 15px;
}
.btn-ghost:hover { box-shadow: none; color: var(--text); }

/* ไพ่ */
.cards-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 24px 0; }
.tcard {
  width: 132px;
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  background: linear-gradient(165deg, #241653, #150c36);
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 26px rgba(0,0,0,0.5);
  animation: flipIn 0.7s ease both;
}
.tcard:nth-child(2) { animation-delay: 0.15s; }
.tcard:nth-child(3) { animation-delay: 0.3s; }
.tcard .pos { font-size: 12px; color: var(--gold); letter-spacing: 0.5px; margin-bottom: 8px; text-transform: uppercase; }
.tcard .glyph { font-size: 34px; margin: 6px 0 10px; display: block; transition: transform 0.4s; }
.tcard.rev .glyph { transform: rotate(180deg); }
.card-img {
  width: 100%;
  aspect-ratio: 2 / 3.45;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  margin: 4px 0 10px;
  background: #150c36;
  transition: transform 0.4s;
}
.tcard.rev .card-img { transform: rotate(180deg); }
.tcard .name { font-weight: 500; font-size: 15px; }
.tcard .orient { font-size: 12px; margin-top: 4px; padding: 2px 10px; border-radius: 20px; display: inline-block; }
.tcard .orient.up { color: #8ff0c0; background: rgba(80,220,150,0.12); }
.tcard .orient.down { color: #ffb3a0; background: rgba(255,120,90,0.12); }
.tcard .kw { font-size: 11px; color: var(--text-dim); font-weight: 300; margin-top: 8px; }

/* teaser / reading */
.teaser {
  font-size: 17px;
  color: var(--gold-soft);
  font-style: italic;
  text-align: center;
  border-left: none;
  padding: 18px 16px;
  background: rgba(232,198,107,0.07);
  border-radius: 14px;
  margin: 8px 0 22px;
}
.reading { font-size: 16px; color: var(--text); }
.reading h2, .reading h3 { color: var(--gold); margin: 20px 0 8px; font-weight: 600; }
.reading strong { color: var(--gold-soft); }
.reading p { margin: 12px 0; }
.locked-hint { text-align: center; color: var(--text-dim); font-size: 14px; margin: 4px 0 18px; }

/* กล่องราคา/จ่าย */
.pay-box { text-align: center; margin: 8px 0 20px; }
.price { font-size: 38px; font-weight: 700; color: var(--gold); }
.price small { font-size: 18px; font-weight: 400; }
.qr-placeholder {
  width: 200px; height: 200px; margin: 18px auto;
  border: 2px dashed rgba(232,198,107,0.4);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  color: var(--text-dim); font-size: 13px; text-align: center; padding: 14px;
}
.qr-placeholder .big { font-size: 40px; }
/* ป้ายแจ้งเตือน (ไม่ใช่ปุ่ม) — ขอบประ พื้นจาง ตัวเล็ก จงใจให้ดูไม่กดได้ */
.free-badge {
  display: inline-block; margin: 4px 0 8px;
  font-size: 15px; font-weight: 500; color: var(--gold-soft);
  background: rgba(232,198,107,0.08);
  border: 1px dashed rgba(232,198,107,0.45);
  padding: 6px 14px; border-radius: 8px;
}
.price-strike { color: var(--text-dim); font-size: 14px; text-decoration: line-through; }

/* แบนเนอร์นับถอยหลังหน้าแรก */
.free-countdown {
  text-align: center;
  background: rgba(232,198,107,0.1);
  border: 1px solid rgba(232,198,107,0.4);
  color: var(--gold-soft);
  border-radius: 12px;
  padding: 11px 16px;
  margin-bottom: 18px;
  font-weight: 400;
  font-size: 15px;
  animation: rise 0.7s ease both;
}
.free-countdown b { color: var(--gold); font-weight: 600; }

/* ===== หน้า PromptPay QR ===== */
.qr-wrap {
  display: inline-block; margin: 18px auto; padding: 14px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.qr-img { display: block; width: 230px; height: 230px; }
.qr-hint { color: var(--text-dim); font-size: 14px; margin: 6px 0 14px; }
.qr-status { color: var(--gold-soft); font-weight: 500; font-size: 15px; }
.dot-pulse {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); margin-right: 6px; vertical-align: middle;
  animation: pulseGlow 1.4s ease-in-out infinite;
}

.section-title { text-align: center; color: var(--gold); font-weight: 600; font-size: 18px; margin: 4px 0 6px; }
.q-echo { text-align: center; color: var(--text-dim); font-size: 15px; margin-bottom: 6px; }
.q-echo b { color: var(--text); font-weight: 500; }
.spacer { height: 14px; }

/* ===== หน้าโหลด "กำลังตีความไพ่" (ตอนกดจ่าย) ===== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 5, 22, 0.94);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fadein 0.3s ease;
}
.loading-box { text-align: center; padding: 30px; }
.loading-moon { font-size: 64px; display: block; animation: pulseGlow 1.7s ease-in-out infinite; }
.loading-title { font-size: 22px; color: var(--gold); font-weight: 600; margin-top: 20px; }
.loading-sub { color: var(--text-dim); margin-top: 10px; font-size: 15px; line-height: 1.7; }
.loading-dots { margin-top: 20px; }
.loading-dots span {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); margin: 0 4px; animation: bounceDot 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.85; filter: none; }
  50% { transform: scale(1.13); opacity: 1; filter: drop-shadow(0 0 20px var(--gold)); }
}
@keyframes bounceDot {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-8px); opacity: 1; }
}

/* ===== หน้าแอดมิน ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  position: relative;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 18px 14px 16px; text-align: center;
  backdrop-filter: blur(8px); animation: rise 0.6s ease both; overflow: hidden;
}
.stat-hero {
  background: linear-gradient(150deg, rgba(232,198,107,0.16), rgba(28,18,64,0.72));
  border-color: var(--gold);
}
.stat-ic { font-size: 22px; margin-bottom: 6px; filter: saturate(1.2); }
.stat-num { font-size: 26px; font-weight: 700; color: var(--gold); line-height: 1.1; }
.stat-num small { font-size: 14px; font-weight: 400; }
.stat-label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.panel-head .section-title { margin: 0; }
.chip-paid { font-size: 12px; color: var(--text-dim); background: rgba(255,255,255,0.05); border-radius: 20px; padding: 4px 12px; }

/* กราฟแท่ง 7 วัน */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; margin-top: 14px; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-val { font-size: 11px; color: var(--gold-soft); margin-bottom: 4px; height: 14px; }
.bar {
  width: 100%; max-width: 38px; min-height: 3px;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold) 60%, #b8902f);
  border-radius: 6px 6px 0 0;
  box-shadow: 0 0 12px rgba(232,198,107,0.25);
  transition: height 0.5s ease;
}
.bar-label { font-size: 11px; color: var(--text-dim); margin-top: 8px; }

.table-wrap { overflow-x: auto; margin-top: 14px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left; color: var(--gold); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--card-border); white-space: nowrap;
}
.admin-table td { padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: middle; }
.admin-table tbody tr:hover { background: rgba(232,198,107,0.05); }
.admin-table .t-time { color: var(--text-dim); white-space: nowrap; font-size: 13px; }
.admin-table .t-q { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-table .t-spread { color: var(--text-dim); white-space: nowrap; }
.admin-table .t-amt { font-weight: 500; color: var(--gold-soft); white-space: nowrap; }
.pill { font-size: 12px; padding: 4px 11px; border-radius: 20px; white-space: nowrap; font-weight: 400; }
.pill-ok { color: #8ff0c0; background: rgba(80,220,150,0.13); }
.pill-wait { color: #ffc9a0; background: rgba(255,150,80,0.13); }
.disclaimer-note { text-align: center; color: var(--text-dim); font-size: 12px; margin: 14px 0; }

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .admin-table .t-q { max-width: 120px; }
}

/* ===== หน้าเลือกไพ่เอง ===== */
.pick-status { text-align: center; color: var(--gold-soft); font-weight: 500; margin: 6px 0 16px; }
.pick-hint { margin-top: 8px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pos-chip {
  font-size: 12px; font-weight: 300; color: var(--text-dim);
  border: 1px solid rgba(232,198,107,0.2); border-radius: 20px; padding: 3px 10px;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 9px;
  margin: 8px 0 24px;
}
.cardback {
  position: relative;
  aspect-ratio: 2 / 3;
  border: 1px solid rgba(232,198,107,0.3);
  border-radius: 9px;
  background:
    repeating-linear-gradient(45deg, rgba(232,198,107,0.06) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #2a1a5e, #150c36);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  padding: 0;
}
.cardback .cb-emblem { color: rgba(232,198,107,0.45); font-size: 17px; transition: color 0.2s; }
.cardback:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 8px 20px rgba(0,0,0,0.5); }
.cardback.picked {
  border-color: var(--gold);
  background: linear-gradient(160deg, #4a3a16, #2a1f08);
  box-shadow: 0 0 16px rgba(232,198,107,0.4);
  transform: translateY(-4px);
}
.cardback.picked .cb-emblem { color: var(--gold-soft); }
.cb-badge {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold); color: #1a1040;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0.5); transition: opacity 0.2s, transform 0.2s;
}
.cardback.picked .cb-badge { opacity: 1; transform: scale(1); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes flipIn { from { opacity: 0; transform: rotateY(70deg) translateY(10px); } to { opacity: 1; transform: none; } }

.disclaimer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 300;
  padding: 20px;
  position: relative;
  z-index: 1;
}

@media (max-width: 480px) {
  .spread-grid { grid-template-columns: 1fr; }
  .tcard { width: 46%; }
  .brand h1 { font-size: 25px; }
}
