:root {
  --gold: #f2c46d; --gold2: #c8902f; --cream: #f8f1e5; --ink: #3b2a1a; --muted: #8a7660;
  --glass: rgba(28,20,14,.62); --line: rgba(255,255,255,.13);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #120c08; overscroll-behavior: none; }
body { font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: #fff; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.btn { height: 46px; padding: 0 22px; border-radius: 999px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.gold { background: linear-gradient(#f6d27e, #c8902f); color: #3a2205; box-shadow: 0 6px 20px rgba(246,190,90,.3); }
.btn.ghost { background: rgba(0,0,0,.06); color: var(--ink); }
.btn.big { height: 54px; padding: 0 36px; font-size: 17px; }
.btn.small { height: 34px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { color: var(--gold2); font-size: 13px; text-decoration: underline; margin-top: 4px; }

/* ---------- boot / welcome ---------- */
.screen { position: fixed; inset: 0; z-index: 40; }
.boot { display: grid; place-items: center; background: radial-gradient(ellipse at center, #3c1e0a, #0a0603 75%); transition: opacity .6s; }
.boot.fade { opacity: 0; pointer-events: none; }
.boot-card { text-align: center; padding: 24px; max-width: 360px; }
.logo { font-size: 60px; color: var(--gold); text-shadow: 0 0 30px rgba(242,196,109,.6); animation: spin 30s linear infinite; display: inline-block; }
.boot h1 { font-size: 30px; margin: 10px 0 6px; color: #fbe3ae; }
.boot p { color: #e6d3b3; margin-bottom: 22px; line-height: 1.6; }
.boot small { display: block; color: #a8957a; font-size: 12px; margin-top: 14px; }
.spinner { width: 28px; height: 28px; margin: 0 auto; border: 3px solid rgba(242,196,109,.2); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- setup ---------- */
.setup { display: flex; flex-direction: column; background: linear-gradient(#2a170c, #120a05); }
.setup-preview { position: relative; flex: 0 0 38%; min-height: 200px; }
#previewCanvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.steps { position: absolute; top: calc(14px + var(--st)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.steps i { width: 26px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); }
.steps i.on { background: var(--gold); }
.setup-card { flex: 1; background: var(--cream); color: var(--ink); border-radius: 24px 24px 0 0; padding: 20px 18px calc(16px + var(--sb)); display: flex; flex-direction: column; overflow: hidden; }
.step { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.step h2 { font-size: 21px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; color: #6b5640; }
.field input { height: 48px; border-radius: 14px; border: 1.5px solid #e2d4bd; background: #fff; padding: 0 14px; font-size: 16px; color: var(--ink); -webkit-user-select: text; user-select: text; }
.field input:focus { outline: none; border-color: var(--gold2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { height: 40px; padding: 0 16px; border-radius: 999px; background: #efe5d3; color: var(--ink); font-size: 14px; font-weight: 500; }
.chips button.on { background: var(--ink); color: #fbe3ae; }
.chips.big button { height: 46px; padding: 0 18px; }
.swatches { display: flex; gap: 10px; }
.swatches button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.1) inset; }
.swatches button.on { border-color: var(--ink); }
.setup-nav { display: flex; justify-content: space-between; gap: 10px; padding-top: 10px; }
.setup-nav .btn { flex: 1; }
.sect-list { display: grid; gap: 10px; }
.sect { text-align: left; border-radius: 18px; padding: 14px; background: #fff; border: 2px solid transparent; display: grid; grid-template-columns: 48px 1fr; gap: 4px 12px; color: var(--ink); }
.sect.on { border-color: var(--sc, var(--gold2)); box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.sect .ic { grid-row: span 3; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: var(--sc); }
.sect b { font-size: 16px; }
.sect p { font-size: 13px; color: #6b5640; line-height: 1.45; }
.sect small { font-size: 12px; font-weight: 700; color: var(--sc); }

/* ---------- danh sách chùa ---------- */
.region { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 2px; }
.temple { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px; border-radius: 18px; background: #fff; margin-bottom: 10px; text-align: left; color: var(--ink); width: 100%; border: 2px solid transparent; }
.temple.on { border-color: var(--gold2); }
.temple .thumb { width: 64px; height: 64px; border-radius: 14px; display: grid; place-items: center; font-size: 30px; }
.temple b { font-size: 15px; }
.temple .meta { font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
.temple p { font-size: 13px; line-height: 1.4; color: #5a4632; }
.temple .tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #f1e7d6; color: #6b5640; font-weight: 600; }
.tag.green { background: #def0d8; color: #2f6a2a; }
.tag.gold { background: #fbe9b8; color: #7a5210; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud > *, .hud button { pointer-events: auto; }
.hud-top { position: absolute; top: calc(10px + var(--st)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.me-chip { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); max-width: 60vw; text-align: left; }
.me-ava { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #6b4a2a; flex: none; }
.me-info { display: flex; flex-direction: column; min-width: 0; }
.me-info b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info small { font-size: 11px; color: #f7dfae; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp { display: block; height: 4px; border-radius: 4px; background: rgba(255,255,255,.15); margin-top: 3px; overflow: hidden; width: 110px; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f6d27e, #ffb84a); transition: width .4s; }
.me-lv { font-size: 12px; font-weight: 800; color: #3a2205; background: var(--gold); border-radius: 999px; min-width: 24px; height: 24px; display: grid; place-items: center; padding: 0 6px; }
.wallet { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; pointer-events: auto; }
.wallet span { padding: 5px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.hud-temple { position: absolute; top: calc(64px + var(--st)); left: 12px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; text-shadow: 0 1px 4px #000; }
.hud-temple b { font-size: 15px; color: #fbe3ae; }
.hud-temple span { font-size: 12px; }
#tOnline { color: #9fe39a; }
.ev { color: #ffd36b; font-weight: 700; }
.buff { color: #ffb36b; }
.side-menu { position: absolute; right: 10px; top: calc(86px + var(--st)); display: flex; flex-direction: column; gap: 8px; }
.side-menu button { position: relative; width: 48px; height: 48px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); display: grid; place-items: center; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.side-menu span { font-size: 21px; }
.side-menu em { display: none; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #e5483b; font-size: 11px; font-style: normal; font-weight: 700; display: grid; place-items: center; }
.guide { position: absolute; left: 0; right: 0; top: calc(128px + var(--st)); text-align: center; font-size: 12px; text-shadow: 0 1px 4px #000; pointer-events: none !important; transition: opacity 1s; padding: 0 70px; }
.guide.fade { opacity: 0; }
.actions { position: absolute; right: 10px; bottom: calc(14px + var(--sb)); display: grid; grid-template-columns: repeat(2, 66px); gap: 10px; }
.act { width: 66px; height: 66px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: transform .1s, background .2s; }
.act:active { transform: scale(.94); }
.act span { font-size: 24px; line-height: 1; }
.act em { font-style: normal; font-size: 11px; white-space: nowrap; }
.act.on { background: rgba(242,196,109,.32); border-color: rgba(242,196,109,.6); }
.act.wait { opacity: .55; }
.ctx-wrap { position: absolute; right: 10px; bottom: calc(176px + var(--sb)); width: 142px; display: flex; justify-content: center; }
.ctx { height: 44px; padding: 0 18px; border-radius: 999px; background: linear-gradient(#f6d27e, #c8902f); color: #3a2205; font-weight: 700; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.35); animation: pop .25s; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.pop { position: absolute; right: 10px; bottom: calc(160px + var(--sb)); background: rgba(28,20,14,.9); border: 1px solid var(--line); border-radius: 18px; padding: 6px; display: flex; flex-direction: column; min-width: 220px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: pop .2s; }
.pop button { height: 46px; text-align: left; padding: 0 12px; border-radius: 12px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.pop button:active { background: rgba(255,255,255,.08); }
.pop b { font-size: 12px; color: var(--gold); }

.joy { position: fixed; z-index: 9; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25); pointer-events: none; opacity: 0; transition: opacity .15s; }
.joy.on { opacity: 1; }
.joy .knob { position: absolute; left: 39px; top: 39px; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.55); box-shadow: 0 2px 10px rgba(0,0,0,.3); }

@media (min-width: 900px) {
  .side-menu { flex-direction: row; top: auto; bottom: calc(18px + var(--sb)); left: 50%; right: auto; transform: translateX(-50%); }
  .side-menu button { width: auto; height: 50px; padding: 0 14px; display: flex; gap: 6px; }
  .side-menu em { display: inline; font-style: normal; font-size: 13px; }
  .actions { grid-template-columns: repeat(4, 76px); }
  .act { width: 76px; height: 76px; }
  .ctx-wrap { width: 334px; bottom: calc(104px + var(--sb)); }
  .pop { bottom: calc(104px + var(--sb)); }
}

/* ---------- tràng hạt ---------- */
.beads { position: fixed; inset: 0; z-index: 20; background: radial-gradient(ellipse at 50% 40%, #f6f1e8, #e9e1d4); color: var(--ink); }
#beadsCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.pill { position: absolute; top: calc(12px + var(--st)); height: 44px; padding: 0 16px; border-radius: 999px; background: rgba(255,255,255,.8); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.06); font-size: 15px; }
.pill.back { left: 12px; }
.bead-count { position: absolute; left: 22px; bottom: calc(26px + var(--sb)); pointer-events: none; }
.bead-count b { font-size: 48px; font-weight: 700; }
.bead-count span { font-size: 18px; color: #7d6a57; }
.bead-count small { display: block; font-size: 13px; color: #7d6a57; margin-top: 2px; }
.bead-hint { position: absolute; right: 22px; bottom: calc(30px + var(--sb)); font-size: 12px; color: #9b8873; pointer-events: none; text-align: right; line-height: 1.6; }
#beadGain { color: #b07a26; font-weight: 700; }

/* ---------- thiền ---------- */
.meditate { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(8,5,3,.55); }
.med-pick { background: var(--cream); color: var(--ink); border-radius: 24px; padding: 22px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.med-pick .row { display: flex; gap: 10px; } .med-pick .row .btn { flex: 1; }
.med-run { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.breath { position: relative; width: 200px; height: 200px; display: grid; place-items: center; }
.breath i { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255,214,140,.55), rgba(255,180,80,.05) 70%); animation: breathe 10s ease-in-out infinite; }
.breath span { position: relative; font-size: 18px; color: #fbe3ae; }
@keyframes breathe { 0%, 100% { transform: scale(.55); } 40%, 50% { transform: scale(1); } }
.med-time { font-size: 44px; font-weight: 300; letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.med-run .btn.ghost { background: rgba(255,255,255,.14); color: #fff; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: min(560px, 100%); max-height: 86vh; background: var(--cream); color: var(--ink); border-radius: 24px 24px 0 0; display: flex; flex-direction: column; animation: up .25s ease-out; padding-bottom: var(--sb); }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-card { border-radius: 24px; max-height: 80vh; } }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.sheet-head h3 { font-size: 19px; }
.x { width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,.06); font-size: 16px; color: var(--ink); }
.tabs { flex: none; display: flex; gap: 6px; padding: 4px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.tabs:empty { display: none; }
.tabs button { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; background: #efe5d3; font-size: 13px; font-weight: 600; color: var(--ink); }
.tabs button.on { background: var(--ink); color: #fbe3ae; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 18px; -webkit-overflow-scrolling: touch; -webkit-user-select: text; user-select: text; }
.card { background: #fff; border-radius: 16px; padding: 12px; margin-bottom: 10px; display: flex; gap: 12px; align-items: center; }
.card .ic { width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 26px; background: #f3ead9; }
.card .body { flex: 1; min-width: 0; }
.card b { font-size: 15px; }
.card p { font-size: 12.5px; color: #6b5640; line-height: 1.4; margin-top: 2px; }
.card .side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.card.done { background: #fffbea; box-shadow: 0 0 0 2px #f2c46d inset; }
.card.claimed { opacity: .55; }
.bar { height: 6px; border-radius: 6px; background: #eadfcb; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #f6d27e, #d99a2b); }
.rw { font-size: 12px; color: #7a5210; margin-top: 4px; font-weight: 600; }
.price { font-size: 12px; white-space: nowrap; }
.lock { font-size: 12px; color: #a0522d; font-weight: 600; }
.rank-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: #fff; margin-bottom: 6px; }
.rank-row .no { font-weight: 800; font-size: 16px; text-align: center; }
.rank-row small { display: block; font-size: 12px; color: var(--muted); }
.rank-row .sc { font-weight: 700; color: #7a5210; }
.rank-row.me { box-shadow: 0 0 0 2px var(--gold2) inset; }
.me-rank { position: sticky; bottom: -18px; background: var(--cream); padding: 8px 0; }
.sect-bars { display: grid; gap: 6px; margin-bottom: 12px; }
.sect-bar { display: grid; grid-template-columns: 80px 1fr 60px; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.sect-bar .bar { margin: 0; height: 10px; }
.filters { display: flex; gap: 8px; margin-bottom: 10px; }
.filters select { flex: 1; height: 38px; border-radius: 12px; border: 1px solid #e2d4bd; background: #fff; padding: 0 8px; color: var(--ink); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.stat { background: #fff; border-radius: 14px; padding: 12px; }
.stat b { font-size: 22px; display: block; }
.stat small { color: var(--muted); font-size: 12px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; font-size: 14px; }
.setting input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold2); }
.setting input[type=range] { flex: 1; accent-color: var(--gold2); }
.setting select { height: 34px; border-radius: 10px; border: 1px solid #e2d4bd; background: #fff; padding: 0 8px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: #efe5d3; padding: 10px; border-radius: 10px; }
textarea.wish { width: 100%; min-height: 90px; border-radius: 14px; border: 1.5px solid #e2d4bd; padding: 12px; font-size: 16px; resize: none; color: var(--ink); }
.row-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(0,0,0,.5); }
.modal-card { background: var(--cream); color: var(--ink); border-radius: 24px; padding: 24px; width: min(360px, 90vw); text-align: center; display: flex; flex-direction: column; gap: 10px; animation: pop .3s; }
.modal-card .big { font-size: 52px; }
.modal-card h3 { font-size: 21px; }
.modal-card p { font-size: 14px; color: #6b5640; line-height: 1.5; }

/* ---------- đèn hoa đăng / chữ bay / toast ---------- */
.lantern-layer { position: fixed; inset: 0; z-index: 12; pointer-events: none; overflow: hidden; }
.lantern { position: absolute; bottom: -120px; width: 190px; text-align: center; animation: rise 16s linear forwards; }
.lantern .l { font-size: 34px; filter: drop-shadow(0 0 14px rgba(255,170,60,.9)); }
.lantern p { margin-top: 4px; font-size: 12px; line-height: 1.4; color: #ffe9c0; text-shadow: 0 1px 4px #000; background: rgba(30,18,8,.4); padding: 4px 8px; border-radius: 10px; }
@keyframes rise { 0% { transform: translateY(0) translateX(0); opacity: 0; } 8% { opacity: 1; } 50% { transform: translateY(-55vh) translateX(20px); } 85% { opacity: 1; } 100% { transform: translateY(-110vh) translateX(-10px); opacity: 0; } }
.floaters { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.floater { position: absolute; left: 50%; top: 56%; transform: translateX(-50%); font-weight: 800; font-size: 18px; color: #ffd36b; text-shadow: 0 2px 6px rgba(0,0,0,.7); animation: floatUp 1.4s ease-out forwards; white-space: nowrap; }
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 10px); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -60px); } }
.toast { position: fixed; left: 50%; top: calc(140px + var(--st)); transform: translate(-50%, -10px); z-index: 60; background: rgba(20,14,10,.88); color: #fbe3ae; padding: 12px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; text-align: center; max-width: 86vw; line-height: 1.45; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Icon SVG ---------- */
.i { width: 1.15em; height: 1.15em; vertical-align: -.22em; flex: none; display: inline-block; }
.logo .i { width: 1em; height: 1em; }
.side-menu .i { width: 23px; height: 23px; color: var(--gold); }
.act .i { width: 28px; height: 28px; color: var(--gold); }
.card .ic .i, .sect .ic .i { width: 30px; height: 30px; color: #7a5210; }
.card .ic.tint .i, .sect .ic .i { color: #fff; }
.temple .thumb .i { width: 34px; height: 34px; color: #7a5210; }
.modal-card .big .i { width: 64px; height: 64px; color: var(--gold2); }
.me-ava { overflow: hidden; color: #fff; }
.me-ava .i { width: 24px; height: 24px; }
.me-ava img, .ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5fd47a; box-shadow: 0 0 8px #5fd47a; vertical-align: 1px; }
.medal { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-style: normal; font-size: 13px; color: #3a2205; }
.medal.m1 { background: linear-gradient(135deg, #ffe08a, #d9a441); } .medal.m2 { background: linear-gradient(135deg, #f1f1f1, #a9adb5); } .medal.m3 { background: linear-gradient(135deg, #f2c49b, #b0703c); }
.btn.emo { width: 64px; height: 64px; padding: 0; } .btn.emo .i { width: 32px; height: 32px; }
.tname { font: inherit; font-weight: 700; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline dotted rgba(255,255,255,.4); text-underline-offset: 3px; cursor: pointer; }
.pop .i { color: var(--gold); margin-right: 4px; }
.toast .i, .floater .i { color: var(--gold); }

/* ---------- Avatar ---------- */
.ava { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; color: #fff; flex: none; font-weight: 800; }
.ava .i { width: 60%; height: 60%; }
.ava-edit { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ava-edit .ava { width: 84px; height: 84px; font-size: 30px; box-shadow: 0 0 0 3px var(--gold); }
.rank-row { grid-template-columns: 36px 40px 1fr auto; }

/* ---------- Bục vinh danh ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; margin: 6px 0 14px; padding: 16px 8px 0; border-radius: 18px; background: radial-gradient(ellipse at 50% 0%, rgba(242,196,109,.45), transparent 70%), linear-gradient(#3b2614, #1e130a); color: #fff; overflow: hidden; }
.podium .pl { text-align: center; min-width: 0; }
.podium .ava { margin: 0 auto 6px; width: 54px; height: 54px; box-shadow: 0 0 0 3px #a9adb5; }
.podium .p1 .ava { width: 72px; height: 72px; box-shadow: 0 0 0 3px #ffd36b, 0 0 24px rgba(255,211,107,.7); }
.podium .p3 .ava { box-shadow: 0 0 0 3px #c88a55; }
.podium b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium small { display: block; font-size: 11px; color: #f2d9a8; }
.podium .pstep { margin-top: 8px; border-radius: 10px 10px 0 0; display: grid; place-items: center; font-weight: 900; font-size: 22px; color: #3a2205; }
.podium .p1 .pstep { height: 78px; background: linear-gradient(#ffe08a, #c8902f); }
.podium .p2 .pstep { height: 56px; background: linear-gradient(#f1f1f1, #9aa0a8); }
.podium .p3 .pstep { height: 42px; background: linear-gradient(#f2c49b, #a5652f); }
.podium .crown { color: #ffd36b; width: 26px; height: 26px; display: block; margin: 0 auto 2px; }

/* ---------- Bản đồ chùa ---------- */
.mapview { position: fixed; inset: 0; z-index: 40; background: #0f1a14; display: flex; flex-direction: column; color: #fff; }
.mapview.hidden { display: none; }
.map-head { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--st)) 14px 4px; }
.map-head h3 { flex: 1; font-size: 18px; }
.map-head .x { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; border: 0; display: grid; place-items: center; }
.map-wrap { flex: 1; position: relative; min-height: 0; display: flex; flex-direction: column; }
.map-area { flex: 1; min-height: 0; position: relative; }
.map-area svg { position: absolute; inset: 0; }
.map-svg { width: 100%; height: 100%; display: block; }
.map-svg .pinb { cursor: pointer; }
.map-svg .pinb circle.halo { animation: halo 2.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { from { opacity: .7; transform: scale(.6); } to { opacity: 0; transform: scale(2.2); } }
.map-card { margin: 0 8px calc(8px + var(--sb)); flex: none; background: var(--cream); color: var(--ink); border-radius: 22px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.5); max-height: 54%; display: flex; flex-direction: column; }
.map-card canvas { width: 100%; height: 150px; flex: none; display: block; background: #9cc0d8; touch-action: none; }
.map-card .mc-body { padding: 12px 16px 14px; overflow: auto; }
.map-card h4 { font-size: 18px; }
.map-card .real { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.map-card .row-btns { margin-top: 10px; }
@media (min-width: 900px) {
  .map-wrap { flex-direction: row; }
  .map-card { width: 440px; margin: 10px; max-height: none; }
  .map-card canvas { height: 280px; }
}

/* ---------- Bài hướng dẫn / câu chuyện ---------- */
.prose { font-size: 14.5px; line-height: 1.65; }
.prose h4 { font-size: 15px; margin: 14px 0 6px; color: #7a5210; display: flex; align-items: center; gap: 6px; }
.prose p { margin: 0 0 8px; }
.prose ul, .prose ol { margin: 0 0 8px 20px; }
.prose li { margin-bottom: 4px; }
.prose .lead { font-size: 15.5px; font-style: italic; color: #5a4128; border-left: 3px solid var(--gold2); padding-left: 10px; }
.prose .chant { background: #fff8ea; border: 1px solid #ecd9b4; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; white-space: pre-line; }
.prose .chant b { display: block; color: #7a5210; margin-bottom: 4px; }
.prose .src { font-size: 12px; color: var(--muted); }
.prose .src a { color: var(--gold2); word-break: break-all; }
.guide-hero { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; color: #fff; margin-bottom: 10px; }
.guide-hero .i { width: 46px; height: 46px; background: rgba(255,255,255,.9); border-radius: 14px; padding: 6px; }
.guide-hero b { font-size: 18px; display: block; } .guide-hero small { opacity: .9; }

/* ---------- Điện thoại xoay ngang ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .hud-top { top: calc(6px + var(--st)); left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); }
  .me-chip { padding: 3px 8px 3px 3px; max-width: 40vw; }
  .me-ava { width: 32px; height: 32px; }
  .xp { width: 90px; }
  .wallet { flex-direction: row; }
  .wallet span { padding: 4px 10px; font-size: 12px; }
  .hud-temple { top: calc(48px + var(--st)); left: calc(12px + var(--sl)); }
  .hud-temple b { font-size: 13px; } .hud-temple span { font-size: 11px; }
  .guide { display: none; }
  /* menu thành hàng icon ở giữa đáy, tránh vùng joystick (trái) và nút hành trì (phải) */
  .side-menu { flex-direction: row; top: auto; right: auto; left: 50%; transform: translateX(-50%); bottom: calc(8px + var(--sb)); gap: 6px; }
  .side-menu button { width: 42px; height: 42px; border-radius: 13px; }
  .side-menu .i { width: 20px; height: 20px; }
  .actions { right: calc(8px + var(--sr)); bottom: calc(8px + var(--sb)); grid-template-columns: repeat(2, 58px); gap: 8px; }
  .act { width: 58px; height: 58px; border-radius: 18px; }
  .act .i { width: 23px; height: 23px; } .act em { font-size: 10px; }
  .ctx-wrap { right: calc(8px + var(--sr)); bottom: calc(140px + var(--sb)); width: 124px; }
  .pop { right: calc(140px + var(--sr)); bottom: calc(8px + var(--sb)); max-height: calc(100vh - 20px); overflow: auto; }
  .pop button { height: 40px; }
  /* sheet: thành ngăn kéo bên phải, cao hết màn hình */
  .sheet { justify-content: flex-end; align-items: stretch; }
  .sheet-card { width: min(460px, 62vw); max-height: none; height: 100%; border-radius: 22px 0 0 22px; padding-right: var(--sr); animation: side .25s ease-out; }
  .sheet-head { padding: 10px 14px 4px; } .tabs { padding: 2px 12px 6px; }
  .modal-card { max-height: 92vh; overflow: auto; width: min(460px, 80vw); padding: 16px 20px; gap: 8px; }
  .modal-card .big { font-size: 36px; } .modal-card .big .i { width: 42px; height: 42px; }
  /* màn tạo nhân vật: xem trước bên trái, form bên phải */
  .setup { flex-direction: row; }
  .setup-preview { flex: 0 0 42%; min-height: 0; }
  .setup-card { flex: 1; max-height: 100vh; overflow: auto; border-radius: 22px 0 0 22px; }
  /* tràng hạt, thiền */
  .bead-count b { font-size: 36px; }
  .bead-count { left: calc(18px + var(--sl)); bottom: calc(14px + var(--sb)); }
  .bead-hint { bottom: calc(16px + var(--sb)); right: calc(18px + var(--sr)); }
  .med-run { gap: 8px; } .breath { width: 140px; height: 140px; } .med-time { font-size: 32px; }
  .med-pick { padding: 16px; gap: 10px; max-height: 94vh; overflow: auto; }
  /* bản đồ: bản đồ trái, thẻ chùa phải */
  .map-wrap { flex-direction: row; }
  .map-head { padding: calc(4px + var(--st)) calc(12px + var(--sr)) 2px calc(12px + var(--sl)); }
  .map-head h3 { font-size: 15px; } .map-head .x { width: 34px; height: 34px; }
  .map-card { width: min(400px, 52vw); max-height: none; margin: 0 calc(8px + var(--sr)) calc(8px + var(--sb)) 0; }
  .map-card canvas { height: 42%; min-height: 120px; }
  .boot-card { transform: scale(.85); }
}
@keyframes side { from { transform: translateX(100%); } }

/* ---------- Hiệu ứng tải ---------- */
.lotus-load { width: 92px; height: 92px; margin: 0 auto 6px; }
.lotus-load svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 14px rgba(242,196,109,.55)); }
.lotus-load path { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 2.4s ease-in-out infinite; }
.lotus-load path:nth-child(2), .lotus-load path:nth-child(3) { animation-delay: .2s; }
.lotus-load path:nth-child(4), .lotus-load path:nth-child(5) { animation-delay: .4s; }
.lotus-load .water { animation-delay: .6s; stroke: rgba(242,196,109,.5); }
.lotus-load .petals { transform-origin: 50% 76%; animation: bloom 2.4s ease-in-out infinite; }
@keyframes draw { 0% { stroke-dashoffset: 160; fill: rgba(242,196,109,0); } 55% { stroke-dashoffset: 0; fill: rgba(242,196,109,0); } 75% { stroke-dashoffset: 0; fill: rgba(242,196,109,.28); } 100% { stroke-dashoffset: 0; fill: rgba(242,196,109,0); opacity: .2; } }
@keyframes bloom { 0%, 100% { transform: scale(.92); } 60% { transform: scale(1.04); } }
.boot-bar, .loader .bar { width: 200px; height: 4px; margin: 12px auto 0; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; }
.boot-bar i, .loader .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f6d27e, #ffb84a); border-radius: 4px; transition: width .35s ease; box-shadow: 0 0 10px #ffcf70; }
.loader { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, #3d240f, #120a05 75%); color: #fbe3ae; transition: opacity .6s ease; }
.loader.out { opacity: 0; pointer-events: none; }
.loader-card { text-align: center; padding: 24px; max-width: 360px; }
.loader h2 { font-size: 20px; margin-top: 6px; }
.loader small { display: block; margin-top: 8px; font-size: 12px; color: #c8b08a; min-height: 16px; }
.loader .quote { margin-top: 22px; font-size: 14px; font-style: italic; color: #e6d3b3; line-height: 1.6; opacity: 0; animation: fadein 1s .4s forwards; }
@keyframes fadein { to { opacity: 1; } }
/* khung xương khi tải dữ liệu */
.skel { border-radius: 14px; margin-bottom: 8px; height: 64px; background: linear-gradient(100deg, #efe5d3 30%, #f8f1e5 50%, #efe5d3 70%); background-size: 300% 100%; animation: shimmer 1.2s linear infinite; }
.skel.sm { height: 18px; width: 60%; } .skel.lg { height: 160px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.map-card .mv-wrap { position: relative; flex: none; }
.map-card .mv-load { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(100deg, #b9cfe0 30%, #d4e3ee 50%, #b9cfe0 70%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; color: #3b5a70; font-size: 13px; font-weight: 600; transition: opacity .5s; }
.map-card .mv-load.done { opacity: 0; pointer-events: none; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border: 2.5px solid rgba(58,34,5,.25); border-top-color: #3a2205; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.ghost.loading::after { border-color: rgba(0,0,0,.15); border-top-color: var(--ink); }

/* ---------- Nút cách chơi & hướng dẫn từng bước ---------- */
.top-right { display: flex; gap: 6px; align-items: flex-start; pointer-events: auto; }
.help-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--glass); border: 1px solid var(--line); color: var(--gold); font-weight: 800; font-size: 16px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
@media (orientation: landscape) and (max-height: 520px) { .top-right { align-items: center; } .help-btn { width: 28px; height: 28px; font-size: 14px; } }
.coach { position: fixed; inset: 0; z-index: 55; }
.coach-hole { position: absolute; border-radius: 20px; box-shadow: 0 0 0 9999px rgba(10,6,3,.72), 0 0 0 3px var(--gold), 0 0 30px 6px rgba(242,196,109,.6); transition: all .35s ease; pointer-events: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9999px rgba(10,6,3,.72), 0 0 0 5px var(--gold), 0 0 40px 10px rgba(242,196,109,.75); } }
.coach-tip { position: absolute; left: 16px; right: 16px; max-width: 360px; margin: 0 auto; background: var(--cream); color: var(--ink); border-radius: 18px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: top .35s ease; animation: pop .3s; }
.coach-tip b { font-size: 16px; display: block; margin-bottom: 4px; }
.coach-tip p { font-size: 14px; line-height: 1.5; color: #5a4128; }
.coach-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.coach-nav .link { margin: 0; }
#coachDots i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #e2d4bd; margin: 0 2px; }
#coachDots i.on { background: var(--gold2); width: 16px; border-radius: 4px; }
.howto .step-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #3a2205; font-weight: 800; font-size: 13px; margin-right: 6px; }
.howto .tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 8px; }
.howto .tbl td { padding: 6px 4px; border-bottom: 1px solid #ecdfc8; vertical-align: top; }
.howto .tbl td:first-child { white-space: nowrap; font-weight: 700; color: #7a5210; padding-right: 10px; }
.howto details { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; }
.howto summary { font-weight: 700; cursor: pointer; }
.howto details p { margin: 6px 0 0; }

/* ---------- Sư trụ trì ---------- */
.abbot-head { display: flex; gap: 10px; align-items: center; text-align: left; }
.abbot-head .ava { width: 48px; height: 48px; }
.abbot-head b { display: block; font-size: 16px; } .abbot-head small { color: var(--muted); font-size: 12px; }
.abbot-say { text-align: left; background: #fff; border-radius: 16px; padding: 12px 14px; font-size: 14.5px; line-height: 1.6; color: #4a3520; position: relative; max-height: 46vh; overflow: auto; }
.abbot-say p { margin: 0 0 8px; } .abbot-say p:last-child { margin: 0; } .abbot-say ul { margin: 0 0 0 18px; }
.abbot-opts { display: flex; flex-direction: column; gap: 6px; }
.abbot-opts .btn { height: 42px; font-size: 14px; justify-content: flex-start; text-align: left; }
.abbot-opts .btn.gold { justify-content: center; }
.name-row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.name-row input { flex: 1; margin-top: 0 !important; }
.dice { width: 48px; flex: none; border-radius: 14px; background: #efe5d3; color: #7a5210; display: grid; place-items: center; }
.dice .i { width: 24px; height: 24px; }
.help-btn .i { width: 16px; height: 16px; }
.vol-box { background: #fff; border-radius: 14px; padding: 4px 12px; margin: 8px 0; }
.setting.vol { gap: 8px; }
.setting.vol span { flex: 0 0 42%; font-size: 13px; }
.setting.vol input { flex: 1; min-width: 0; }
.setting.vol b { width: 30px; text-align: right; font-size: 12px; color: var(--muted); }
.vol-box .setting { margin: 0; padding: 10px 0; border-radius: 0; border-bottom: 1px solid #f0e6d4; } .vol-box .setting:last-child { border-bottom: 0; }
.tale-title { margin: 0 0 6px; color: #8a4b12; font-size: 15.5px; }
.out-btn { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 2px; padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255, 211, 107, .55); background: rgba(30, 20, 12, .62); color: #ffe2a0; font: 600 13px/1.2 inherit; font-family: inherit; backdrop-filter: blur(6px); cursor: pointer; pointer-events: auto; }
.out-btn .i { width: 16px; height: 16px; }
.out-btn.hidden { display: none; }
.full-screen { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 50% 40%, #3c2612, #0c0805); }
.full-screen.hidden { display: none; }
.full-card { max-width: 380px; text-align: center; color: #f6e6c4; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.full-card h3 { margin: 0; font-size: 22px; color: #ffd36b; }
.full-card p { margin: 0; line-height: 1.6; font-size: 15px; }
.full-card small { opacity: .7; }
.full-lotus .i { width: 64px; height: 64px; color: #ffb3c6; animation: fullPulse 2.4s ease-in-out infinite; }
@keyframes fullPulse { 50% { transform: scale(1.08); opacity: .75; } }
