:root { --bg: #1a1220; --panel: rgba(34, 24, 22, .92); --line: rgba(232, 180, 90, .45); --red: #b8609a; --blood: #8a2a1e; --paper: #f2e6c0; --ink: #fbf3e2; --dim: #d2bf9c; --green: #c8e88a; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: "Noto Sans TC", system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: #f0cf70; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; font-family: "Noto Serif TC", serif; font-size: 20px; color: var(--dim); background: var(--bg); z-index: 50; }
.entry { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(140, 90, 30, .4), rgba(0, 0, 0, .85)); z-index: 40; padding: 16px; }
.entry-card { width: min(400px, 100%); text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px 20px; box-shadow: 0 0 60px rgba(232, 180, 90, .25); }
.eyebrow { margin: 0; letter-spacing: .3em; color: var(--dim); font-size: 13px; }
.entry h1 { font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 52px; margin: 6px 0; color: #f0cf70; text-shadow: 0 0 18px rgba(240, 207, 112, .6); letter-spacing: .1em; }
.slogan { color: var(--ink); line-height: 1.7; margin: 0 0 16px; }
.field { display: block; text-align: left; font-size: 13px; color: var(--dim); margin-bottom: 12px; }
input, select, textarea { width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .45); color: var(--ink); font: inherit; font-size: 16px; }
.primary { background: linear-gradient(180deg, #e0a040, #a0601e); color: #fff; font-weight: 700; border-radius: 12px; padding: 12px 16px; width: 100%; box-shadow: 0 0 18px rgba(232, 180, 90, .45); }
.primary.big { font-size: 20px; letter-spacing: .2em; }
.primary:disabled { opacity: .5; }
.ghost { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; width: 100%; background: rgba(0, 0, 0, .3); }
.note { font-size: 12px; color: var(--dim); line-height: 1.6; margin: 10px 0 0; }
.hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 12px 10px; z-index: 20; pointer-events: none; }
.hud > * { pointer-events: auto; }
.brand { font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 20px; color: #f0cf70; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.brand small { font-family: "Noto Sans TC"; font-weight: 400; font-size: 11px; color: var(--dim); margin-left: 6px; }
.stats { display: flex; gap: 6px; margin: 0 auto; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; text-align: center; min-width: 58px; }
.stats b { display: block; font-size: 15px; } .stats span { font-size: 10px; color: var(--dim); }
.right { display: flex; gap: 6px; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; min-height: 34px; display: inline-flex; align-items: center; gap: 6px; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
.online i.off { background: #666; box-shadow: none; }
.bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 6px; z-index: 20; }
.bar button { display: grid; justify-items: center; gap: 2px; width: 52px; padding: 4px 0; border-radius: 12px; }
.bar button i { font-style: normal; font-family: "Noto Serif TC", serif; font-weight: 900; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 0, 0, .4); color: #f6e2b0; }
.bar button span { font-size: 11px; color: var(--dim); }
.bar button.gold i { background: var(--red); color: #fff; }
.bar button:active { background: rgba(232, 180, 90, .2); }
.sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); width: min(480px, calc(100vw - 24px)); max-height: min(calc(100vh - 170px), 700px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; z-index: 25; backdrop-filter: blur(8px); }
.sheet h2 { font-family: "Noto Serif TC", serif; margin: 0 0 4px; color: #f0cf70; font-size: 20px; }
.sheet .sub { color: var(--dim); font-size: 13px; margin: 0 0 12px; }
.sheet .x { position: absolute; right: 10px; top: 8px; font-size: 22px; color: var(--dim); }
.sheet h3 { font-size: 14px; margin: 16px 0 8px; color: #f6e2b0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; background: rgba(0, 0, 0, .35); }
.chip.on { background: var(--red); color: #fff; border-color: var(--red); }
.buys { display: grid; gap: 8px; }
.buy { display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 2px 8px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(0, 0, 0, .35); }
.buy b { font-size: 15px; } .buy span { grid-column: 1; font-size: 12px; color: var(--dim); } .buy em { grid-row: 1 / 3; grid-column: 2; align-self: center; font-style: normal; font-weight: 700; color: #ffe9b0; }
.buy.own { opacity: .7; } .buy.on { border-color: var(--green); }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(0, 0, 0, .3); margin-top: 10px; }
.card p { margin: 4px 0; font-size: 14px; }
.lamplist { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.lamplist div { border: 1px solid rgba(232, 180, 90, .25); border-radius: 8px; padding: 6px; font-size: 11px; text-align: center; background: rgba(60, 36, 14, .5); }
.lamplist div.flag { border-color: #f0cf70; background: rgba(90, 60, 10, .5); }
.lamplist b { display: block; font-size: 12px; color: var(--green); }
.feed { position: fixed; left: 12px; top: calc(70px + var(--safe-t)); display: grid; gap: 4px; z-index: 15; max-width: min(320px, 70vw); pointer-events: none; }
.feed div { background: rgba(40, 24, 10, .72); border-left: 3px solid var(--red); border-radius: 6px; padding: 4px 8px; font-size: 12px; animation: in .3s ease; transition: opacity .6s; }
.chatlog { position: fixed; left: 12px; bottom: calc(92px + var(--safe-b)); display: grid; gap: 3px; z-index: 15; max-width: min(320px, 70vw); pointer-events: none; }
.chatlog div { background: rgba(40, 24, 10, .65); border-radius: 8px; padding: 4px 8px; font-size: 13px; transition: opacity .6s; }
.chatlog b { color: #f6e2b0; margin-right: 4px; }
.chatbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); width: min(420px, calc(100vw - 24px)); display: flex; gap: 6px; z-index: 26; }
.chatbar input { margin: 0; } .chatbar button { background: var(--red); border-radius: 10px; padding: 0 14px; color: #fff; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(70px + var(--safe-t)); display: grid; gap: 6px; z-index: 60; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: rgba(46, 28, 12, .94); border: 1px solid var(--red); border-radius: 12px; padding: 10px 14px; font-size: 14px; text-align: center; animation: in .25s ease; transition: opacity .4s; }
.toast.out { opacity: 0; }
@keyframes in { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 520px) {
  .brand small { display: none; } .brand { font-size: 17px; }
  .bar button { width: 46px; } .bar button i { width: 30px; height: 30px; }
  .stats div { min-width: 48px; padding: 3px 6px; }
}

.row-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); margin: 4px 0; }
.row-check input { width: auto; margin: 0; }
/* 觀音殿 */
.lamplist div.gold { border-color: #f0c040; background: rgba(90, 60, 10, .5); }
.lamplist b { color: #f6d890; }
.lv { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.lv b { font-family: "Noto Serif TC", serif; font-size: 20px; color: #f0cf70; }
.bar-wrap { height: 8px; border-radius: 99px; background: rgba(0, 0, 0, .4); overflow: hidden; flex: 1; }
.bar-wrap i { display: block; height: 100%; background: linear-gradient(90deg, #f0cf70, #ffe9b0); }
textarea { resize: none; height: 78px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); margin: 8px 0 12px; }
.check input { width: auto; margin: 0; }
.diary { display: grid; gap: 6px; }
.diary div { font-size: 13px; border-left: 3px solid #f0cf70; padding: 4px 8px; background: rgba(0, 0, 0, .25); border-radius: 6px; }
.diary small { color: var(--dim); margin-right: 6px; }
.jiao { display: flex; justify-content: center; gap: 22px; margin: 16px 0 8px; min-height: 70px; }
.jiao span { width: 34px; height: 64px; border-radius: 34px 34px 6px 6px; background: linear-gradient(180deg, #d84a4a, #8e1b22); box-shadow: inset -6px 0 0 rgba(0, 0, 0, .25); transition: transform .5s; }
.jiao span.flat { background: linear-gradient(180deg, #f2d2a0, #c8945a); border-radius: 6px; }
.jiao.toss span { animation: toss .7s ease; }
@keyframes toss { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-60px) rotate(360deg); } 100% { transform: translateY(0) rotate(720deg); } }
.res { text-align: center; font-family: "Noto Serif TC", serif; font-size: 22px; color: #ffe9b0; min-height: 1.4em; }
.dots { display: flex; justify-content: center; gap: 8px; margin: 6px 0 12px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #f0cf70; }
.dots i.on { background: #f0cf70; box-shadow: 0 0 8px #f0cf70; }
.poem { text-align: center; font-family: "Noto Serif TC", serif; font-size: 19px; line-height: 1.9; color: #fbf3e2; margin: 10px 0; }
.poem h4 { margin: 0; color: #f0cf70; font-size: 15px; letter-spacing: .3em; }
.cards { display: grid; gap: 8px; }
.cardx { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(240, 200, 120, .07); }
.cardx p { margin: 0 0 8px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.cardx .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cardx .stk { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; background: rgba(0, 0, 0, .3); }
.cardx .stk.on { background: var(--red); color: #fff; }
.cardx .rep { margin-left: auto; font-size: 11px; color: var(--dim); }
.cardx small { color: var(--dim); font-size: 11px; }
.story { display: flex; gap: 10px; align-items: flex-start; }
.story .who { flex: none; background: var(--red); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.story p { margin: 0; font-size: 15px; line-height: 1.7; }
.care p { font-size: 15px; line-height: 1.8; }
.care a { display: block; text-align: center; margin: 8px 0; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); color: #fff; text-decoration: none; font-size: 16px; }
.amounts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
@media (max-width: 520px) { .bar { gap: 2px; padding: 5px; } .bar button { width: 40px; } .bar button i { width: 28px; height: 28px; font-size: 14px; } .bar button span { font-size: 10px; } .stats div { min-width: 44px; } #hudLv { font-size: 12px; } }


/* 右上角樂捐按鈕 */
.pill.donate { background: linear-gradient(180deg, #f3d27a, #c99a3a); color: #2a1a06; font-weight: 700; border: 0; cursor: pointer; }

/* 窄手機：HUD 多一格數字，縮小間距讓右上角樂捐按鈕留在畫面內 */
@media (max-width: 420px) {
  .hud { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .brand { font-size: 15px; padding: 6px 8px; }
  .stats { gap: 3px; }
  .stats div { min-width: 38px; padding: 3px 4px; }
  .stats b { font-size: 13px; }
  .hud .pill { padding: 5px 8px; font-size: 12px; gap: 4px; }
}

/* 土地公殿 */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .field { margin-bottom: 8px; }
.primary.alt { background: linear-gradient(180deg, #c8a050, #7a5a20); }
.plaques { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.plaques div { display: grid; gap: 3px; border: 1px solid rgba(232, 180, 90, .3); border-radius: 10px; padding: 8px; background: linear-gradient(180deg, rgba(216, 184, 128, .18), rgba(120, 80, 40, .2)); }
.plaques div.gold { border-color: #f0c040; box-shadow: 0 0 10px rgba(240, 192, 64, .35); }
.plaques div.pin { order: -1; }
.plaques small { color: var(--dim); font-size: 11px; }
.plaques b { font-family: "Noto Serif TC", serif; font-size: 15px; word-break: break-all; }
.plaques span { font-size: 11px; color: var(--dim); }
.plaques .stk { justify-self: start; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; background: rgba(0, 0, 0, .3); }
select { appearance: auto; }
.disclaimer { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--dim); line-height: 1.6; }
@media (max-width: 420px) { .pill.donate { display: none; } .stats div { min-width: 40px; padding: 3px 5px; } .stats b { font-size: 13px; } .pill.online { padding: 6px 8px; font-size: 12px; } .row2 { grid-template-columns: 1fr; } }
.pill, .brand, .stats span { white-space: nowrap; }
@media (max-width: 520px) { .hud { gap: 6px; padding-left: 8px; padding-right: 8px; } .stats { gap: 4px; } .stats span { font-size: 9px; } .right { gap: 4px; } }
@media (max-width: 420px) { .brand { display: none; } .stats { margin: 0; } }

/* 共用列表 */
.board { display: grid; gap: 6px; }
.board div { display: grid; grid-template-columns: 32px 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 0 8px; border: 1px solid rgba(232, 180, 90, .3); border-radius: 10px; padding: 6px 10px; background: rgba(0, 0, 0, .28); }
.board div.gold { border-color: #f0c040; box-shadow: 0 0 10px rgba(240, 192, 64, .3); }
.board em { grid-row: 1 / 3; font-style: normal; font-family: "Noto Serif TC", serif; font-weight: 900; color: #f0cf70; text-align: center; }
.board b { font-size: 14px; } .board span { grid-column: 2; font-size: 11px; color: var(--dim); }
.board .stk { grid-row: 1 / 3; grid-column: 3; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; background: rgba(0, 0, 0, .3); min-height: 32px; }
.smiles { display: flex; flex-wrap: wrap; gap: 6px; }
.smiles .chip { min-height: 36px; }
.smiles .chip:disabled { opacity: .55; } .smiles .chip.on:disabled { opacity: 1; }
.turn { font-family: "Noto Serif TC", serif; font-size: 18px; line-height: 1.7; color: #ffe9b0; text-align: center; margin: 6px 0; }
.fanfly { text-align: center; font-size: 40px; animation: fly 1.4s ease forwards; }
@keyframes fly { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(160px, -90px) rotate(540deg); opacity: 0; } }
/* 9 顆按鈕：窄手機再縮一點，確保不超出畫面 */
@media (max-width: 420px) { .bar { gap: 1px; padding: 4px; } .bar button { width: 37px; } .bar button i { width: 27px; height: 27px; font-size: 13px; } .bar button span { font-size: 9.5px; letter-spacing: -.03em; } }

/* 毛安堂 */
.kinds .chip { min-height: 34px; }
.vet { margin-top: 8px !important; padding: 8px 10px; border-radius: 10px; background: rgba(90, 160, 210, .18); border: 1px solid rgba(120, 190, 240, .5); font-size: 13px !important; }
.stars { display: grid; gap: 8px; }
.stars > div { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; border: 1px solid rgba(180, 190, 255, .35); border-radius: 12px; padding: 8px 10px; background: linear-gradient(90deg, rgba(30, 36, 80, .6), rgba(60, 50, 100, .35)); }
.stars .ic { font-size: 26px; text-align: center; }
.stars p { margin: 0; display: grid; gap: 2px; }
.stars b { font-family: "Noto Serif TC", serif; font-size: 16px; color: #fff2b0; }
.stars small { font-size: 12px; color: var(--ink); word-break: break-all; }
.stars em { font-style: normal; font-size: 11px; color: var(--dim); }
.stars .stk { border: 1px solid rgba(255, 240, 180, .6); border-radius: 999px; padding: 6px 10px; font-size: 12px; background: rgba(0, 0, 0, .3); min-height: 34px; }
.stars .stk:disabled { opacity: .55; }

/* 織星宮 */
.passes { display: grid; gap: 8px; }
.passes > div { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 8px; border: 1px solid rgba(240, 180, 220, .4); border-radius: 12px; padding: 8px 10px; background: linear-gradient(90deg, rgba(90, 40, 80, .55), rgba(60, 50, 110, .35)); }
.passes .ic { font-size: 26px; text-align: center; }
.passes p { margin: 0; display: grid; gap: 2px; }
.passes b { font-family: "Noto Serif TC", serif; font-size: 16px; color: #ffe2f2; }
.passes small { font-size: 12px; color: var(--ink); word-break: break-all; }
.passes em { font-style: normal; font-size: 11px; color: var(--dim); }
.needle { margin: 14px 0 6px; }
.ntrack { position: relative; height: 54px; border-radius: 12px; background: linear-gradient(90deg, #2a1a3a, #4a2a5a, #2a1a3a); border: 1px solid var(--line); overflow: hidden; }
.neye { position: absolute; left: 50%; top: 8px; bottom: 8px; transform: translateX(-50%); border: 3px solid #e8ecf6; border-radius: 999px; box-shadow: 0 0 10px rgba(232, 236, 246, .6); }
.nthread { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: linear-gradient(180deg, #e85a6a, #f0904a, #f0d04a, #7ac85a, #5aa8e0, #6a6ad0, #b86ad0); border-radius: 2px; }
/* 第 99 輪：今日織星五件事、綁七娘媽絭、七夕花水 */
.qnToday { position: fixed; right: max(8px, env(safe-area-inset-right)); top: calc(50% - 116px); z-index: 45; width: 52px; min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: rgba(70, 22, 50, .92); color: #fff0f6; font: 700 12px/1.25 "Noto Sans TC", system-ui, sans-serif; padding: 4px 2px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); cursor: pointer; touch-action: manipulation; }
.qnToday b { display: block; font-size: 16px; }
.qnToday.done { border-color: #ffd36a; background: rgba(140, 70, 110, .94); }
body.sheetOpen .qnToday, body.sheetOpen .flbar, body.sheetOpen .tevBtn { display: none; }
/* 第 121 輪：樓層列變 9 層後會蓋到左側的「今日」「今日活動」，改放右側（照城隍殿、中壇元帥殿） */
body .tevBtn { left: auto; right: max(8px, env(safe-area-inset-right)); top: calc(50% - 56px); }
.tdRow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 16px; }
.tdRow i { font-style: normal; font-family: "Noto Serif TC", serif; font-weight: 900; width: 30px; text-align: center; color: #ffb0d8; }
.tdRow span { flex: 1; line-height: 1.4; }
.tdRow button { min-width: 92px; min-height: 46px; border-radius: 12px; font: 700 15px "Noto Sans TC", sans-serif; background: linear-gradient(180deg, #e890c8, #a0406e); color: #fff; }
.tdRow em { font-style: normal; color: #ffe08a; font-weight: 700; min-width: 92px; text-align: center; font-size: 15px; }
/* 第 121 輪：幸運星攤、七夕湯圓 */
.lkCol .chip { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.lkCol .chip i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.lkRes { margin: 10px 0 4px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 240, 246, .12); font-size: 16px; line-height: 1.5; }
.lkRes b { font-size: 20px; }
.tgBar { position: relative; height: 34px; margin: 12px 4px 8px; border-radius: 17px; background: linear-gradient(90deg, #6a5a62, #8a7a82 40%, #8a7a82 78%, #a84a4a); overflow: hidden; }
.tgBar .ok { position: absolute; left: 42%; width: 36%; top: 0; bottom: 0; background: rgba(246, 176, 200, .55); }
.tgBar .gd { position: absolute; left: 53%; width: 14%; top: 0; bottom: 0; background: #f06aa0; }
.tgBar b { position: absolute; top: -2px; bottom: -2px; width: 8px; border-radius: 4px; background: #fff; box-shadow: 0 0 8px #fff; left: 0; }
.tgRow { display: flex; justify-content: center; gap: 8px; font-size: 22px; margin: 4px 0; }
.tgRow .r2 { color: #ffb0d0; } .tgRow .r1 { color: #f6e0ec; } .tgRow .r0 { color: #a07a8a; }
.tgSc { text-align: center; font-size: 16px; margin: 6px 0 10px; }
.primary.tgGo { min-height: 64px; font-size: 26px; }
.tgTop { margin-top: 12px; font-size: 15px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.tgTop b { width: 100%; }
