:root {
  --gold: #e8c06a;
  --gold2: #fff1c1;
  --gold3: #b5832f;
  --lac: #7d1610;
  --lac2: #4a0a06;
  --ink: #5b1209;
  --paper: #fbf1d8;
  --text: #fbefd2;
  --muted: #d9bf8f;
  --bg: #1c0703;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(150, 40, 18, .55), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(90, 20, 6, .7), transparent 60%),
    var(--bg);
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
.gold-text {
  background: linear-gradient(180deg, var(--gold2) 10%, var(--gold) 55%, var(--gold3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .7));
}
.lac {
  background: linear-gradient(160deg, #94241a 0%, var(--lac) 45%, var(--lac2) 100%);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 3px var(--lac2), inset 0 0 0 5px rgba(232, 192, 106, .7), 0 10px 30px rgba(0, 0, 0, .5);
}
.btn-gold {
  border: 0; border-radius: 999px; padding: 13px 26px; font-weight: 800; letter-spacing: .3px;
  color: var(--lac2);
  background: linear-gradient(180deg, #fff3c9, var(--gold) 60%, #c08d3a);
  box-shadow: 0 4px 0 #7a5418, 0 8px 20px rgba(0, 0, 0, .35);
  transition: transform .1s, filter .2s;
}
.btn-gold:hover { filter: brightness(1.06); }
.btn-gold:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a5418; }
.btn-line {
  background: transparent; border: 1px solid rgba(232, 192, 106, .7); color: var(--gold2);
  border-radius: 999px; padding: 9px 18px; font-weight: 600; font-size: 14px;
}
.btn-line:hover { background: rgba(232, 192, 106, .12); }
.muted { color: var(--muted); opacity: .8; font-style: italic; font-family: 'Lora', serif; }
:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }

/* ===== Cổng ===== */
.gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, rgba(20, 6, 2, .55), rgba(20, 6, 2, .85)), url(assets/bg-key.jpg) center 30% / cover;
  transition: opacity .9s, visibility .9s;
}
.gate.hide { opacity: 0; visibility: hidden; }
.gate-card { width: min(440px, 100%); border-radius: 10px; padding: 34px 26px 26px; text-align: center; position: relative; }
.gate-lotus { width: 74px; margin: -70px auto 4px; display: block; filter: drop-shadow(0 0 18px rgba(255, 210, 120, .8)); }
.gate-kicker { margin: 0; font: italic 600 15px 'Lora', serif; color: var(--muted); }
.gate h1 { margin: 6px 0 2px; font: 900 44px/1.05 'Playfair Display', serif; letter-spacing: 4px; }
.gate-sub { margin: 0 0 14px; font: italic 600 18px 'Lora', serif; color: #f6dfae; }
.gate-desc { margin: 0 0 18px; font-size: 14.5px; line-height: 1.55; color: #f3e1bd; }
.gate-field { display: grid; gap: 6px; text-align: left; margin-bottom: 18px; font-size: 13px; color: var(--muted); }
.gate-field input, .wish-card textarea {
  width: 100%; border-radius: 8px; border: 1px solid rgba(232, 192, 106, .7); padding: 12px 14px;
  background: rgba(30, 6, 2, .55); color: var(--gold2); font: 600 16px 'Be Vietnam Pro', sans-serif;
}
.gate-field input::placeholder, .wish-card textarea::placeholder { color: rgba(240, 210, 160, .45); }
.gate .btn-gold { width: 100%; font-size: 17px; }
.gate-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }

/* ===== Bố cục ===== */
.app {
  height: 100vh; height: 100svh;
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "left stage right";
}
.panels { display: contents; }
.side { overflow-y: auto; padding: 22px 18px; display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; scrollbar-color: var(--gold3) transparent; }
.side.left { grid-area: left; align-items: flex-end; }
.side.right { grid-area: right; align-items: flex-start; }
.side > * { width: 100%; max-width: 330px; }

.scroll-card {
  position: relative; padding: 22px 18px 18px; border-radius: 6px;
  background: linear-gradient(170deg, rgba(122, 24, 16, .55), rgba(58, 8, 4, .5));
  border: 1px solid rgba(232, 192, 106, .7);
  box-shadow: inset 0 0 0 4px rgba(58, 8, 4, .35), inset 0 0 0 5px rgba(232, 192, 106, .25), 0 10px 26px rgba(0, 0, 0, .35);
}
.scroll-card::before, .scroll-card::after {
  content: ''; position: absolute; left: -8px; right: -8px; height: 9px; border-radius: 5px;
  background: linear-gradient(180deg, #6b3b1c, #2e160a); box-shadow: 0 2px 5px rgba(0, 0, 0, .4);
}
.scroll-card::before { top: -5px; } .scroll-card::after { bottom: -5px; }
.scroll-card h3 { margin: 0 0 14px; text-align: center; font: 800 20px 'Playfair Display', serif; letter-spacing: 4px; }
.scroll-card h3::after { content: ''; display: block; height: 1px; margin: 8px 10px 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

.guide { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.guide li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; }
.guide li img, .guide .emo {
  width: 34px; height: 34px; border-radius: 50%; object-fit: contain; padding: 4px; display: grid; place-items: center; font-size: 18px;
  background: radial-gradient(circle, #6d1a10, #2d0805 72%); box-shadow: 0 0 0 1.5px var(--gold);
}
.guide b { display: block; font: 700 15.5px 'Lora', serif; color: var(--gold2); }
.guide span:not(.emo) { font-size: 12.5px; color: #edd5a8; }

.kinh { margin: 0 0 14px; font: italic 600 15.5px/1.65 'Lora', serif; color: #f6e2bb; text-align: center; min-height: 6em; }
.credit { font-size: 11px; color: rgba(217, 191, 143, .6); line-height: 1.5; text-align: right; }
.credit code { font-size: 10.5px; }

.me { text-align: center; margin-bottom: 8px; }
.me-name { font: 700 19px 'Lora', serif; color: var(--gold2); }
.me-title { display: inline-block; margin-top: 6px; padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--lac2); background: linear-gradient(180deg, var(--gold2), var(--gold)); }
.merit-big { text-align: center; margin: 6px 0 10px; }
.merit-big b { display: block; font: 900 46px/1 'Playfair Display', serif; color: var(--gold2); text-shadow: 0 0 22px rgba(255, 200, 90, .45); }
.merit-big span { font: italic 600 14px 'Lora', serif; color: var(--muted); }
.incense-bar { position: relative; height: 8px; border-radius: 3px; background: linear-gradient(180deg, #8a5a2e, #4d2c12); }
.incense-bar .ash { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #d8cfc0, #f2ece2); transition: width .8s; }
.merit-next { margin-top: 8px; text-align: center; font-size: 12.5px; color: var(--muted); }
.tally { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tally > div { text-align: center; padding: 8px 4px; border-radius: 6px; background: rgba(30, 6, 2, .35); border: 1px solid rgba(232, 192, 106, .25); }
.tally b { display: block; font: 800 20px 'Playfair Display', serif; color: var(--gold2); }
.tally span { font-size: 11.5px; color: var(--muted); }

.today-xam .ts { font: 900 20px 'Playfair Display', serif; color: var(--gold2); text-align: center; }
.today-xam .tl { text-align: center; font-size: 12px; font-weight: 700; color: var(--lac2); background: var(--gold); border-radius: 3px; width: max-content; margin: 4px auto 8px; padding: 1px 8px; }
.today-xam .tt { font: italic 600 14.5px/1.55 'Lora', serif; text-align: center; color: #f6e2bb; }
.today-xam .tg { margin-top: 8px; font-size: 13px; color: #edd5a8; text-align: center; }
.today-xam button { display: block; margin: 12px auto 0; }
.wishes { margin: 0; padding: 0 0 0 4px; list-style: none; display: grid; gap: 10px; max-height: 300px; overflow: auto; }
.wishes li { font: italic 15px/1.45 'Lora', serif; color: #f6e2bb; padding-left: 26px; position: relative; }
.wishes li::before { content: '🏮'; position: absolute; left: 0; top: 0; font-style: normal; font-size: 15px; }
.wishes li.muted::before { content: none; }
.wishes li small { display: block; font: normal 11.5px 'Be Vietnam Pro', sans-serif; color: var(--muted); opacity: .8; }

/* ===== Chánh điện ===== */
.stage-wrap {
  grid-area: stage; position: relative; overflow: hidden;
  height: 100vh; height: 100svh; aspect-ratio: 9 / 16; max-width: 100vw;
  box-shadow: 0 0 0 2px rgba(232, 192, 106, .45), 0 0 80px rgba(0, 0, 0, .7);
  background: #2a0b05;
}
.world { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; transform-origin: 0 0; user-select: none; }
.world .bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.layer { position: absolute; inset: 0; pointer-events: none; }

.sprite { position: absolute; background-image: url(assets/devotee.png); background-repeat: no-repeat; transform-origin: 50% 100%; pointer-events: none; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35)); }
.aura { position: absolute; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .8s;
  background: radial-gradient(circle, rgba(255, 226, 150, .75), rgba(255, 200, 90, .25) 45%, transparent 70%); mix-blend-mode: screen; }
.pillar { position: absolute; top: 0; width: 160px; opacity: 0; pointer-events: none; transition: opacity .7s; mix-blend-mode: screen;
  background: linear-gradient(90deg, transparent, rgba(255, 230, 160, .55) 35%, rgba(255, 248, 220, .85) 50%, rgba(255, 230, 160, .55) 65%, transparent);
  -webkit-mask: linear-gradient(180deg, transparent, #000 25%, #000); mask: linear-gradient(180deg, transparent, #000 25%, #000); }
.pillar.on, .aura.on { opacity: 1; }
.halo { position: absolute; left: 540px; top: 420px; width: 900px; height: 900px; margin: -450px 0 0 -450px; border-radius: 50%; opacity: 0; pointer-events: none;
  mix-blend-mode: screen; transition: opacity 1.2s;
  background:
    radial-gradient(circle, rgba(255, 245, 210, .9) 0%, rgba(255, 215, 120, .55) 22%, rgba(255, 180, 60, .18) 45%, transparent 68%),
    repeating-conic-gradient(from 0deg, rgba(255, 225, 150, .35) 0deg 3deg, transparent 3deg 12deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: spin 40s linear infinite; }
.halo.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.glows i { position: absolute; width: 60px; height: 60px; margin: -30px; border-radius: 50%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255, 220, 140, .85), rgba(255, 170, 60, .3) 40%, transparent 70%); animation: flick 2.2s ease-in-out infinite alternate; }
@keyframes flick { 0% { opacity: .55; transform: scale(.9); } 50% { opacity: 1; } 100% { opacity: .7; transform: scale(1.08); } }

.ftext { position: absolute; transform: translate(-50%, 0); white-space: nowrap; font: 800 calc(20px * var(--inv, 2)) 'Playfair Display', serif; color: var(--gold2);
  text-shadow: 0 2px 6px #000, 0 0 18px rgba(255, 200, 90, .8); animation: floatUp 2.2s ease-out forwards; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -140px) scale(1); } }
.flyer { position: absolute; width: 70px; height: 70px; margin: -35px; filter: drop-shadow(0 0 14px rgba(255, 210, 120, .9)); }

.lantern { position: absolute; width: 0; height: 0; transition: transform 7s cubic-bezier(.3, .1, .3, 1), opacity 1.6s; }
.lantern .lt { position: absolute; left: -48px; top: -96px; width: 96px; height: 96px; animation: sway 2.6s ease-in-out infinite alternate; }
.lantern .lt img { width: 100%; filter: drop-shadow(0 0 22px rgba(255, 190, 90, 1)) brightness(1.08); }
.lantern .lt::before { content: ''; position: absolute; left: 50%; top: 55%; width: 170px; height: 170px; margin: -85px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 210, 120, .55), transparent 65%); }
.lantern .wish { position: absolute; left: 0; top: -150px; transform: translateX(-50%); max-width: 520px; width: max-content; padding: 8px 18px; border-radius: 30px;
  font: italic 600 calc(15px * var(--inv, 2))/1.3 'Lora', serif; color: var(--gold2); text-align: center; background: rgba(40, 10, 4, .6); border: 1.5px solid rgba(232, 192, 106, .7); text-shadow: 0 2px 4px #000; }
@keyframes sway { from { transform: rotate(-5deg) translateX(-8px); } to { transform: rotate(5deg) translateX(8px); } }

/* HUD */
.hud-top { position: absolute; left: 12px; right: 12px; top: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.plaque { padding: 8px 16px 7px; border-radius: 6px; text-align: center; }
.plaque b { display: block; font: 900 22px/1.1 'Playfair Display', serif; letter-spacing: 2px; white-space: nowrap; }
.plaque span { font: italic 600 12.5px 'Lora', serif; color: #f6dfae; white-space: nowrap; }
.hud-btns { display: flex; gap: 8px; align-items: center; }
.chip { display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border-radius: 999px; background: rgba(40, 10, 4, .7); border: 1px solid var(--gold); }
.chip img { width: 24px; height: 24px; }
.chip b { font: 800 17px 'Playfair Display', serif; color: var(--gold2); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--gold); background: rgba(40, 10, 4, .7); font-size: 18px; display: grid; place-items: center; }
.only-mobile { display: none; }

.kinh-banner { position: absolute; left: 8%; right: 8%; top: 18%; text-align: center; padding: 14px 18px 16px; border-radius: 8px;
  background: linear-gradient(170deg, rgba(122, 24, 16, .72), rgba(58, 8, 4, .66)); border: 1px solid rgba(232, 192, 106, .8);
  opacity: 0; transform: translateY(-10px); transition: opacity 1s, transform 1s; pointer-events: none; }
.kinh-banner.show { opacity: 1; transform: none; }
.kb-t { font: 800 13px 'Playfair Display', serif; letter-spacing: 4px; color: var(--gold); }
.kinh-banner p { margin: 6px 0 0; font: italic 600 clamp(13px, 1.9vh, 17px)/1.55 'Lora', serif; color: #fbeccb; text-shadow: 0 2px 4px #000; }

.toast { position: absolute; left: 50%; top: 52%; transform: translate(-50%, 10px); padding: 9px 20px; border-radius: 999px; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  background: rgba(40, 10, 4, .85); border: 1px solid var(--gold); color: var(--gold2); font: 600 15px 'Lora', serif; opacity: 0; transition: .5s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.actbar { position: absolute; left: 10px; right: 10px; bottom: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 6px; justify-content: center;
  padding: 8px; border-radius: 16px; background: linear-gradient(180deg, rgba(60, 14, 6, .78), rgba(30, 6, 2, .9)); border: 1px solid rgba(232, 192, 106, .7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); backdrop-filter: blur(4px); }
.actbar button { flex: 1 1 0; min-width: 0; border: 0; background: transparent; border-radius: 10px; padding: 6px 2px 5px; display: grid; justify-items: center; gap: 3px; transition: background .2s, opacity .2s, transform .1s; }
.actbar button:hover:not(:disabled) { background: rgba(232, 192, 106, .14); }
.actbar button:active:not(:disabled) { transform: scale(.94); }
.actbar img, .actbar i { width: 38px; height: 38px; object-fit: contain; font-style: normal; font-size: 26px; display: grid; place-items: center;
  border-radius: 50%; background: radial-gradient(circle, #6d1a10, #2d0805 72%); box-shadow: 0 0 0 1.5px var(--gold); padding: 4px; }
.actbar span { font-size: 11.5px; font-weight: 700; color: var(--gold2); white-space: nowrap; }
.actbar button:disabled { opacity: .38; cursor: default; }
.actbar .mo-btn:disabled { opacity: 1; cursor: pointer; }
.actbar button.hit img { animation: knock .18s ease-out; }
@keyframes knock { 50% { transform: scale(.86) rotate(-8deg); } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(15, 4, 1, .62); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity .35s, visibility .35s; }
.modal.show { opacity: 1; visibility: visible; }
.wish-card { width: min(460px, 100%); padding: 24px 22px 20px; border-radius: 10px; text-align: center; }
.wish-card h3 { margin: 0 0 6px; font: 900 26px 'Playfair Display', serif; letter-spacing: 3px; }
.muted-l { margin: 0 0 14px; font-size: 13.5px; color: #f0dbb2; line-height: 1.5; }
.wish-card textarea { resize: none; font: italic 600 16px/1.5 'Lora', serif; }
.sugs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 16px; }
.sugs button { border: 1px solid rgba(232, 192, 106, .55); background: rgba(30, 6, 2, .4); color: #f3dfb6; border-radius: 999px; padding: 5px 11px; font-size: 12.5px; }
.sugs button:hover { background: rgba(232, 192, 106, .15); }
.row { display: flex; gap: 10px; justify-content: center; }

/* quẻ xăm */
.xam { width: min(560px, 100%); display: grid; justify-items: center; gap: 14px; }
.ong { position: relative; width: 100px; height: 190px; transition: opacity .5s, height .5s; }
.ong .cup { position: absolute; left: 6px; right: 6px; bottom: 0; height: 120px; border-radius: 8px 8px 18px 18px; background: linear-gradient(90deg, #5a1a0c, #a8402a 35%, #c5603e 50%, #8a2e1c 70%, #4a1208); box-shadow: 0 8px 16px rgba(0, 0, 0, .45); }
.ong .cup::before, .ong .cup::after { content: ''; position: absolute; left: 0; right: 0; height: 7px; background: linear-gradient(90deg, #8a6020, var(--gold2), #8a6020); }
.ong .cup::before { top: 13px; } .ong .cup::after { bottom: 16px; }
.ong .sticks { position: absolute; left: 12px; right: 12px; bottom: 105px; height: 76px; }
.ong .sticks i { position: absolute; bottom: 0; width: 8px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, #c9a46a, #f1dcae, #b08850); }
.ong .sticks i::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 10px; background: #b3140e; border-radius: 3px 3px 0 0; }
.ong.shake { animation: shake .16s linear infinite; transform-origin: 50% 100%; }
@keyframes shake { 0% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } 100% { transform: rotate(-9deg); } }
.ong .one { position: absolute; left: 42px; bottom: 120px; width: 16px; height: 120px; border-radius: 4px 4px 0 0; display: flex; justify-content: center;
  background: linear-gradient(90deg, #c9a46a, #f6e4bb, #b08850); box-shadow: 0 0 14px rgba(255, 220, 140, .9);
  opacity: 0; transform: translateY(50px); transition: transform .7s cubic-bezier(.2, 1.4, .4, 1), opacity .2s; }
.ong .one::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 15px; background: #b3140e; border-radius: 4px 4px 0 0; }
.ong .one span { margin-top: 20px; font: 900 13px/1 'Playfair Display', serif; color: var(--ink); writing-mode: vertical-rl; }
.ong.up .one { opacity: 1; transform: translateY(-40px); }
.ong.gone { opacity: 0; height: 0; }

.slip { position: relative; width: 100%; padding: 22px 26px 18px; color: var(--ink); border-radius: 6px; text-align: center;
  background: linear-gradient(180deg, #fff8e6, #f4e2b8); border: 2px solid var(--gold3); box-shadow: inset 0 0 0 5px #fff8e6, inset 0 0 0 6px rgba(184, 134, 47, .6), 0 20px 50px rgba(0, 0, 0, .5);
  clip-path: inset(0 0 100% 0); transition: clip-path 1.1s ease; }
.slip.open { clip-path: inset(-60px -60px -60px -60px); }
.slip .hd { display: flex; align-items: center; justify-content: center; gap: 14px; }
.slip .hd::before, .slip .hd::after { content: ''; flex: 1; max-width: 90px; height: 1px; background: linear-gradient(90deg, transparent, rgba(125, 22, 16, .6)); }
.slip .hd::after { transform: scaleX(-1); }
.slip .so { font: 900 28px 'Playfair Display', serif; color: var(--lac); letter-spacing: 4px; white-space: nowrap; }
.slip .tho { margin: 14px 0 10px; font: italic 600 clamp(18px, 4.6vw, 23px)/1.5 'Lora', serif; color: #4a0f08; }
.slip .rule { display: flex; align-items: center; gap: 10px; margin: 0 30px 10px; color: var(--gold3); font-size: 14px; }
.slip .rule::before, .slip .rule::after { content: ''; flex: 1; height: 1px; background: rgba(184, 134, 47, .7); }
.slip .loi { font-size: 16px; line-height: 1.55; color: #3d2a1c; }
.slip .loi b { color: var(--lac); }
.slip .ft { margin-top: 14px; display: flex; justify-content: space-between; gap: 10px; font: italic 13.5px 'Lora', serif; color: #6b4a2e; }
.slip .loai { position: absolute; right: 14px; top: 12px; padding: 4px 8px; font: 900 13px/1.1 'Playfair Display', serif; letter-spacing: 1px; text-transform: uppercase;
  color: var(--tone, #b3140e); border: 3px double var(--tone, #b3140e); border-radius: 4px; background: rgba(255, 255, 255, .3);
  opacity: 0; transform: rotate(14deg) scale(1.4); transition: opacity .3s 1s, transform .3s 1s; }
.slip.open .loai { opacity: .92; transform: rotate(-8deg); }
.xam-note { margin: 0; text-align: center; font: italic 14px 'Lora', serif; color: #f0dbb2; min-height: 1em; }
.xam .btn-gold { opacity: 0; transition: opacity .4s; pointer-events: none; }
.xam.done .btn-gold { opacity: 1; pointer-events: auto; }

/* ===== Điện thoại ===== */
@media (max-width: 1000px) {
  .app { display: block; }
  .stage-wrap { width: 100vw; aspect-ratio: auto; box-shadow: none; }
  .only-mobile { display: grid; }
  .panels { display: block; position: fixed; inset: 0; z-index: 50; overflow-y: auto; padding: 70px 16px 30px;
    background: rgba(20, 6, 2, .94); backdrop-filter: blur(6px); opacity: 0; visibility: hidden; transition: opacity .35s, visibility .35s; }
  .panels.open { opacity: 1; visibility: visible; }
  .side { overflow: visible; padding: 0 0 18px; align-items: center !important; }
  .side.left { order: 2; }
  .panels .side.right { padding-top: 0; }
  .panels { display: flex; flex-direction: column; }
  .panels:not(.open) { pointer-events: none; }
  .credit { text-align: center; }
  .sheet-close { position: fixed; top: 14px; right: 14px; z-index: 51; }
}
@media (min-width: 1001px) { .sheet-close { display: none; } }
@media (max-width: 420px) {
  .plaque b { font-size: 18px; } .plaque span { font-size: 11px; }
  .actbar { left: 6px; right: 6px; gap: 2px; padding: 6px 4px; }
  .actbar img, .actbar i { width: 34px; height: 34px; font-size: 22px; }
  .actbar span { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .halo { animation: none; } .glows i { animation: none; } .lantern .lt { animation: none; }
}

/* nhãn nút và dòng thông báo được xuống dòng khi khung hẹp */
.actbar span { white-space: normal; text-align: center; line-height: 1.12; font-size: 10.5px; min-height: 2.24em; display: flex; align-items: center; }
.toast { white-space: normal; text-align: center; border-radius: 16px; width: max-content; max-width: 86%; }

/* thẻ xăm: lúc lắc ống thì lá xăm chưa chiếm chỗ; khi mở thì ống ẩn đi */
.xam:not(.reveal) .slip { position: absolute; visibility: hidden; }
.xam.reveal .ong { display: none; }
.xam .ong { margin-top: 60px; }

/* thời kinh nằm trên thanh nghi thức, không che tượng Phật */
.kinh-banner { top: auto; bottom: 112px; left: 5%; right: 5%; transform: translateY(10px); }
.kinh-banner.show { transform: none; }

/* đèn nguyện: lời nguyện nằm trên đóa sen, không che đèn */
.lantern .lt { left: -65px; top: -130px; width: 130px; height: 130px; }
.lantern .wish { top: auto; bottom: 138px; max-width: 760px; }
@media (max-width: 520px) { .slip { padding-top: 46px; } .slip .loai { top: 10px; } }

/* ===== Bảng tên trên đầu Phật tử ===== */
.nametag {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap; text-align: center;
  padding: calc(3px * var(--inv, 2)) calc(11px * var(--inv, 2)) calc(4px * var(--inv, 2));
  border-radius: calc(8px * var(--inv, 2));
  background: linear-gradient(180deg, rgba(110, 22, 14, .9), rgba(52, 8, 4, .9));
  border: calc(1.2px * var(--inv, 2)) solid rgba(232, 192, 106, .75);
  box-shadow: 0 calc(3px * var(--inv, 2)) calc(8px * var(--inv, 2)) rgba(0, 0, 0, .45);
  transition: box-shadow .6s;
}
.nametag::after {
  content: ''; position: absolute; left: 50%; bottom: calc(-5px * var(--inv, 2)); transform: translateX(-50%);
  border: calc(5px * var(--inv, 2)) solid transparent; border-bottom: 0; border-top-color: rgba(232, 192, 106, .8);
}
.nametag b { display: block; font: 700 calc(13px * var(--inv, 2))/1.15 'Lora', serif; color: var(--gold2); text-shadow: 0 1px 2px #000; }
.nametag span { display: block; font: 700 calc(10px * var(--inv, 2))/1.25 'Be Vietnam Pro', sans-serif; color: #f0d59c; letter-spacing: .2px; }
.nametag[data-tier="1"] { border-color: var(--gold); }
.nametag[data-tier="1"] span { color: var(--gold); }
.nametag[data-tier="2"] { border-color: var(--gold2); box-shadow: 0 0 calc(10px * var(--inv, 2)) rgba(255, 210, 120, .75); }
.nametag[data-tier="2"] span { color: var(--gold2); }
.nametag[data-tier="3"] { border-color: #fff6d4; background: linear-gradient(180deg, #b0281a, #5a0c06); box-shadow: 0 0 calc(16px * var(--inv, 2)) rgba(255, 220, 140, .95); }
.nametag[data-tier="3"] span { color: #fff6d4; }
.nametag[data-tier="2"] span::before, .nametag[data-tier="3"] span::before { content: '✦ '; }

.sync-note { margin-top: 6px; text-align: center; font-size: 11.5px; color: rgba(217, 191, 143, .7); }
.sync-note.on { color: #b9e3a5; }

/* ===== PC: mọi thứ nằm gọn trong một khung hình, không cuộn trang ===== */
@media (min-width: 1001px) {
  html, body { overflow: hidden; }
  .side { height: 100vh; height: 100svh; overflow: hidden; padding: 14px 16px; gap: 12px; }
  .side > * { flex: 0 0 auto; }
  .scroll-card { padding: 16px 14px 12px; }
  .scroll-card h3 { font-size: 17px; margin-bottom: 9px; letter-spacing: 3px; }
  .scroll-card h3::after { margin-top: 6px; }
  .guide { gap: 7px; }
  .guide li { grid-template-columns: 30px 1fr; gap: 9px; }
  .guide li img, .guide .emo { width: 30px; height: 30px; font-size: 16px; }
  .guide b { font-size: 14.5px; }
  .guide span:not(.emo) { font-size: 12px; }
  /* thời kinh & sổ nguyện co giãn theo chỗ còn lại, chữ dài thì cuộn bên trong thẻ */
  .sec-kinh, .sec-wish { flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; }
  .kinh { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-bottom: 10px; font-size: 14.5px; }
  .sec-kinh .btn-line { align-self: center; flex: 0 0 auto; }
  .wishes { flex: 1 1 auto; min-height: 0; max-height: none; }
  .credit { margin: 0; }
  .me { margin-bottom: 4px; }
  .me-name { font-size: 17px; }
  .merit-big { margin: 4px 0 8px; }
  .merit-big b { font-size: 38px; }
  .tally { margin-top: 10px; gap: 6px; }
  .tally > div { padding: 5px 2px; }
  .tally b { font-size: 17px; }
  .tally span { font-size: 11px; }
  .today-xam .ts { font-size: 18px; }
  .today-xam .tt { font-size: 13.5px; line-height: 1.45; }
  .today-xam .tg { font-size: 12.5px; margin-top: 6px; }
  .today-xam button { margin-top: 8px; padding: 6px 14px; font-size: 13px; }
}
/* màn hình thấp (laptop 768px trở xuống): gọn thêm */
@media (min-width: 1001px) and (max-height: 820px) {
  .guide span:not(.emo) { display: none; }
  .guide { gap: 6px; }
  .credit { display: none; }
  .merit-big b { font-size: 32px; }
  .merit-next, .sync-note { font-size: 11px; margin-top: 5px; }
  .tally span { font-size: 10px; }
  .today-xam .tg { display: none; }
  .scroll-card { padding: 13px 13px 10px; }
  .side { gap: 10px; padding: 10px 14px; }
}
@media (min-width: 1001px) {
  .side.left { justify-content: center; }
  .sec-kinh { flex: 0 1 auto; min-height: 0; }
}
@media (min-width: 1001px) and (max-height: 720px) {
  .sec-wish { min-height: 84px; }
  .merit-big b { font-size: 28px; }
  .me-title { margin-top: 3px; padding: 1px 10px; }
  .tally > div { padding: 3px 2px; }
  .tally b { font-size: 15px; }
  .today-xam .tl { margin: 2px auto 4px; }
  .today-xam .tt { font-size: 12.5px; }
  .today-xam button { margin-top: 5px; padding: 4px 12px; }
  .scroll-card h3 { font-size: 15px; margin-bottom: 6px; }
  .guide li img, .guide .emo { width: 26px; height: 26px; }
  .guide li { grid-template-columns: 26px 1fr; }
}
