/* เล้งซัวไฮ่ 海山龍 — แอปเทพประจำวัน (ดำด้าน / ทอง / แดงตราประทับ) */
:root {
  --bg: #0b0907; --surface: #15120d; --gold: #D4AF37; --gold-2: #f5e6a8; --gold-dk: #a8861a; --gold-rgb: 212,175,55;
  --gold-soft: rgba(var(--gold-rgb),.35); --gold-faint: rgba(var(--gold-rgb),.1);
  --red: #a4161a; --text: #e6dfcf; --muted: #948d7d; --dim: #5e584c;
  --day: #4aa3ff; --radius: 16px;
  --serif: "Noto Serif Thai", serif; --sans: "Sarabun", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-weight: 300; line-height: 1.6; -webkit-tap-highlight-color: transparent; padding-bottom: 84px; }
img { display: block; max-width: 100%; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--dim); font-size: 12px; text-align: center; margin: 8px 0 0; }
.gold-text { background: linear-gradient(135deg, var(--gold-2), var(--gold) 45%, var(--gold-dk)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.card { background: linear-gradient(145deg, var(--gold-faint), var(--surface) 45%); border: 1px solid var(--gold-soft); border-radius: var(--radius); padding: 16px; }

/* ปุ่ม */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 20px; border-radius: 12px; font-family: var(--serif); font-weight: 700; font-size: 15px; line-height: 1.2; border: 1px solid transparent; transition: transform .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-gold { color: #0b0907; background: linear-gradient(135deg, var(--gold-2), var(--gold) 50%, var(--gold-dk)); box-shadow: 0 4px 24px rgba(var(--gold-rgb),.3), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-outline { color: var(--gold); border-color: var(--gold-soft); background: rgba(0,0,0,.3); }
.btn-block { width: 100%; }

/* แถบบน */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: rgba(11,9,7,.88); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(var(--gold-rgb),.15); }
.brand-logo { height: 34px; border-radius: 6px; }
/* โลโก้ศาลเจ้า กดแล้วกลับหน้าแรกได้ทุกหน้า */
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 0; margin: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 10px; transition: opacity .15s; }
.brand:active { opacity: .65; }
.brand:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }
.topbar-text { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.topbar-text strong { font-family: var(--serif); color: var(--gold); font-size: 14px; }
.topbar-text span { color: var(--muted); font-size: 11px; }
.pill { font-size: 12px; font-weight: 600; color: #0b0907; background: var(--gold); border-radius: 999px; padding: 3px 10px; }

/* หน้าจอ */
main { max-width: 32rem; margin: 0 auto; padding: 0 16px; }
@media (min-width: 900px) { main { max-width: 56rem; } }
.screen { display: none; padding: 20px 0 24px; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.screen h2 { font-size: 24px; text-align: center; margin-bottom: 4px; }
.screen > .muted { text-align: center; margin: 0 0 16px; font-size: 14px; }

/* วันนี้ */
.today-head { text-align: center; margin-bottom: 14px; }
.today-head .date { font-family: var(--serif); color: var(--gold); margin: 0 0 4px; font-size: 15px; }
.today-head h1 { font-size: 30px; line-height: 1.2; }
.today-head .muted { margin: 4px 0 0; font-size: 13px; }
.special { display: inline-block; margin: 0 0 6px; padding: 3px 12px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 500; }
.wall-wrap { position: relative; width: min(100%, 360px); margin: 0 auto; border-radius: 22px; overflow: hidden; box-shadow: 0 0 60px rgba(var(--gold-rgb),.12), 0 20px 50px rgba(0,0,0,.6); border: 1px solid var(--gold-soft); }
@media (min-width: 900px) { .today-head { margin-top: 10px; } #today { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; } #today .today-head, #today .birthday, #today .actions, #today .hint, #today .blessing { grid-column: 2; } #today .wall-wrap { grid-column: 1; grid-row: 1 / span 6; } }
#wall { width: 100%; height: auto; display: block; aspect-ratio: 9/20; background: #0b0907; }
.wall-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--gold); font-family: var(--serif); background: #0b0907; }
.wall-loading.hidden { display: none; }
.birthday { text-align: center; margin: 16px 0 12px; }
.birthday .muted { margin: 0 0 8px; }
.chips { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--gold-soft); background: rgba(0,0,0,.35); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip.active { border-color: var(--gold); background: var(--gold-faint); color: var(--gold-2); }
.actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.blessing { margin-top: 16px; text-align: center; }
.blessing .zh { font-family: "Ma Shan Zheng", var(--serif); font-size: 34px; color: var(--gold); line-height: 1.1; }
.blessing .name { font-family: var(--serif); font-size: 16px; color: var(--gold-2); margin: 4px 0 2px; }
.blessing .power { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.blessing .text { font-family: var(--serif); font-size: 15px; color: var(--text); margin: 0; }
.blessing .gem { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* สมุดสะสม */
.progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; margin: 0 0 16px; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-dk), var(--gold-2)); transition: width .5s; }
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 600px) { .book-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .book-grid { grid-template-columns: repeat(6, 1fr); } }
.slot { position: relative; aspect-ratio: 3/4; border-radius: 14px; border: 1px solid rgba(var(--gold-rgb),.2); background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px; text-align: center; color: var(--dim); cursor: pointer; transition: transform .15s; }
.slot:active { transform: scale(.97); }
.slot .zh { font-family: "Ma Shan Zheng", serif; font-size: 26px; line-height: 1; }
.slot .th { font-size: 10px; line-height: 1.25; }
.slot .num { position: absolute; top: 6px; left: 8px; font-size: 10px; }
/* ใบที่ได้รับไปแล้ว โชว์ภาพจริงที่ผู้ใช้ได้รับ ชื่อองค์เทพลอยทับด้านล่าง */
.slot { overflow: hidden; }
.slot .shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 16%; }
.slot.has-shot { justify-content: flex-end; padding: 0; }
.slot.has-shot::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,9,7,.15) 0%, rgba(11,9,7,0) 38%, rgba(11,9,7,.9) 100%); }
.slot.has-shot .zh, .slot.has-shot .th, .slot.has-shot .num { position: relative; z-index: 2; }
.slot.has-shot .zh { display: none; }
.slot.has-shot .th { color: var(--gold-2); font-weight: 500; padding: 0 6px 8px; text-shadow: 0 1px 4px #000; }
.slot.has-shot .num { position: absolute; top: 6px; left: 8px; color: var(--gold-2); text-shadow: 0 1px 4px #000; }
.slot.got { color: var(--gold); border-color: var(--gold); background: radial-gradient(circle at 50% 30%, rgba(var(--gold-rgb),.25), var(--surface) 70%); box-shadow: 0 0 18px rgba(var(--gold-rgb),.2); }
.slot.today { outline: 2px solid var(--day); outline-offset: 2px; }
.slot.today::after { content: "วันนี้"; position: absolute; bottom: 6px; font-size: 9px; color: var(--day); }
.reward { margin-top: 16px; text-align: center; }
.reward h3 { color: var(--gold); font-size: 18px; margin-bottom: 4px; }
.reward .muted { margin: 0 0 12px; font-size: 13px; }
.unlock { margin-top: 12px; }
.unlock h3 { color: var(--gold); font-size: 16px; margin-bottom: 2px; }
.unlock .muted { margin: 0 0 10px; }
.unlock-form { display: flex; gap: 8px; }
.unlock-form input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--gold-soft); background: rgba(0,0,0,.35); color: var(--text); letter-spacing: .08em; }
#unlock-msg { margin: 8px 0 0; color: var(--gold); min-height: 1em; }

/* สนับสนุน */
.qr-card { text-align: center; }
.qr-img { width: 230px; margin: 0 auto 8px; border-radius: 10px; }
.qr-card .small { margin: 0 0 10px; }
.tiers-title { color: var(--gold); text-align: center; font-size: 19px; margin: 22px 0 12px; }
.tiers { display: grid; gap: 10px; }
@media (min-width: 900px) { .tiers { grid-template-columns: 1fr 1fr 1fr; } }
.tier { position: relative; display: flex; flex-direction: column; gap: 6px; }
.tier.highlight { border-color: var(--gold); box-shadow: 0 0 30px rgba(var(--gold-rgb),.15); }
.tier.soon { opacity: .7; border-style: dashed; }
.tier .amount { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--gold); line-height: 1; }
.tier .amount em { display: block; font-family: var(--sans); font-style: normal; font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 2px; }
.tier .amount small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.tier .title { font-family: var(--serif); font-size: 16px; font-weight: 700; color: #f0e6c8; }
.tier .desc { color: var(--muted); font-size: 13px; margin: 0; }
.tier .tag { position: absolute; top: 12px; right: 12px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: #0b0907; font-weight: 600; }
.tier.soon .tag { background: transparent; color: var(--muted); border: 1px solid var(--gold-soft); }
.tier .btn { margin-top: 6px; }

/* โหมดรับสนับสนุน ยืมหน้าตาจากการ์ดเดิม ไม่แตะสไตล์ .tier เพราะต้องกลับมาเหมือนเดิมตอนเปิด VVIP อีกครั้ง */
.donate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.donate-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 16px 10px; border-radius: var(--radius); text-align: center;
  background: linear-gradient(145deg, var(--gold-faint), var(--surface) 45%);
  border: 1px solid var(--gold-soft); color: var(--text); transition: transform .15s, border-color .2s; }
.donate-chip:active { transform: scale(.97); }
.donate-chip .v { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--gold); line-height: 1.1; }
.donate-chip .l { font-size: 12px; color: var(--muted); line-height: 1.4; }
/* ตัวที่เน้นกับตัวใส่ยอดเองกินเต็มแถว ไม่งั้นจะเหลือช่องว่างข้างเดียวดูเหมือนจัดหน้าพลาด */
.donate-chip.highlight { grid-column: 1 / -1; border-color: var(--gold); box-shadow: 0 0 26px rgba(var(--gold-rgb),.15); }
.donate-chip.any { grid-column: 1 / -1; }
.donate-chip.any .v { font-size: 19px; }
.donate-card { margin-top: 14px; }
.donate-card h3 { color: var(--gold); font-size: 17px; margin-bottom: 8px; }
.donate-card ol { margin: 0 0 12px; padding-left: 20px; }
.donate-card li { font-size: 14px; line-height: 1.8; }
.donate-card #donate-fine { line-height: 1.8; margin: 0 0 14px; }
.steps { margin-top: 14px; }
.steps h3 { color: var(--gold); font-size: 16px; margin-bottom: 6px; }
.steps ol { margin: 0 0 12px; padding-left: 20px; font-size: 14px; }

/* ศาลเจ้า */
.seal { width: 80px; margin: 0 auto 8px; display: block; filter: drop-shadow(0 0 12px rgba(164,22,26,.5)); }
/* เรื่องของศาลเจ้า อยู่ท้ายแถบวันนี้ */
.shrine { margin-top: 28px; padding-top: 22px; border-top: 1px solid rgba(var(--gold-rgb),.15); }
.shrine h2 { font-size: 22px; text-align: center; margin-bottom: 10px; }
.shrine p { font-size: 15px; }
.shrine strong { color: var(--gold); font-weight: 500; }
.photo-grid { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 700px) { .photo-grid { grid-template-columns: 1fr 1fr; } }
.photo-grid figure { margin: 0; padding: 0; overflow: hidden; }
.photo-grid img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.photo-grid figcaption { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.footer { text-align: center; margin-top: 24px; font-size: 14px; }
.footer .small { margin: 8px 0 0; }

/* แท็บล่าง */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: flex; background: rgba(11,9,7,.95); backdrop-filter: blur(10px); border-top: 1px solid rgba(var(--gold-rgb),.18); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 4px 9px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button span { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--gold); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; background: var(--gold); color: #0b0907; padding: 10px 16px; border-radius: 999px; font-weight: 500; font-size: 14px; z-index: 60; transition: all .3s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== สลับใบเทศกาล / เทพประจำวัน ===== */
.mode-switch { display: flex; gap: 6px; justify-content: center; margin: 0 0 14px; }
.mode-switch button { flex: 1; max-width: 190px; padding: 9px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); background: rgba(0,0,0,.35); border: 1px solid var(--gold-soft); }
.mode-switch button.on { color: #0b0907; background: linear-gradient(135deg, var(--gold-2), var(--gold)); border-color: var(--gold); font-weight: 600; }

/* ===== ชั้นบารมี ===== */
.round-bar { text-align: center; margin: 0 0 10px; }
.round-name { display: inline-block; font-family: var(--serif); font-weight: 700; font-size: 15px; color: #0b0907; background: var(--gold); border-radius: 999px; padding: 3px 14px; }
.round-hint { display: block; color: var(--dim); font-size: 12px; margin-top: 6px; }
.sub-head { color: var(--gold); font-size: 17px; text-align: center; margin: 26px 0 4px; }
.center { text-align: center; }
.secret-row { grid-template-columns: repeat(2, 1fr); max-width: 22rem; margin: 10px auto 0; }
@media (min-width: 900px) { .secret-row { max-width: 24rem; } }
.slot.secret { border-color: var(--gold); background: radial-gradient(circle at 50% 25%, rgba(var(--gold-rgb),.14), var(--surface) 70%); }
.slot.locked { color: var(--dim); border-style: dashed; border-color: rgba(var(--gold-rgb),.25); background: var(--surface); }
.slot.locked .zh { font-size: 22px; }

.ascend { border-color: var(--gold); box-shadow: 0 0 30px rgba(var(--gold-rgb),.18); }

/* ===== ใบเทศกาลที่เก็บได้ ===== */
.fes-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.fes-list p { margin: 4px 0; text-align: center; }
.fes-chip { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--gold-soft); background: var(--surface); cursor: pointer; }
.fes-chip:active { transform: scale(.97); }
.fes-chip .zh { font-family: "Ma Shan Zheng", serif; font-size: 22px; line-height: 1; }
.fes-chip .t { font-size: 13px; color: var(--text); }

/* ───── ปุ่มเปิดปิดเสียง บนแถบหัว ───── */
.sound-btn { background: none; border: 0; padding: 4px 6px; font-size: 18px; line-height: 1;
  border-radius: 8px; opacity: .9; transition: opacity .15s, transform .15s; }
.sound-btn:active { transform: scale(.9); }
.sound-btn.off { opacity: .35; filter: grayscale(1); }
.sound-btn:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

/* ───── หน้าดูภาพเต็มจอ ───── */
.viewer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: rgba(6,5,4,.96); backdrop-filter: blur(6px); animation: fade .25s ease; }
.viewer.hidden { display: none !important; }
.viewer-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  padding: 52px 16px 8px; min-height: 0; }
.viewer-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 14px; border: 1px solid var(--gold-soft); box-shadow: 0 0 60px rgba(var(--gold-rgb),.15); }
.viewer-stage img.loading { filter: blur(6px); transform: scale(.99); }
.viewer-stage img { transition: filter .35s, transform .35s; }
.viewer-loading { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  font-family: var(--serif); font-size: 13px; color: var(--gold); }
.viewer-loading.hidden { display: none; }
.viewer-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 40px; height: 40px;
  border-radius: 50%; border: 1px solid var(--gold-soft); background: rgba(0,0,0,.5);
  color: var(--gold-2); font-size: 16px; line-height: 1; }
.viewer-close:active { transform: scale(.94); }
.viewer-bar { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); text-align: center; }
.viewer-bar p { font-family: var(--serif); font-size: 15px; color: var(--gold-2); margin: 0 0 10px; }
.viewer-bar .btn { width: min(100%, 22rem); }

/* ───── การ์ดเก็บสมุดข้ามเครื่อง ───── */
.sync-card { margin-bottom: 16px; text-align: center; }
.sync-card.hidden { display: none !important; }
.sync-lead { font-size: 13.5px; color: var(--muted); line-height: 1.7; margin: 0 0 12px; }
.sync-fine { font-size: 11.5px; color: var(--dim); line-height: 1.7; margin: 10px 0 0; }
.sync-who { display: flex; align-items: center; gap: 12px; text-align: left; }
.sync-who img { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--gold-soft); object-fit: cover; background: var(--surface); }
.sync-who strong { display: block; font-family: var(--serif); font-size: 15px; color: var(--gold-2); }
.sync-who span { font-size: 12px; color: var(--muted); }
