/* 獎勵系統的樣式：錢袋、銅錢、刻字圓石（道具／禮物）、朱砂印章、結算、寶箱、金幣雨（index／cross／map 共用） */

/* ── 錢袋（左上角） ── */
#purse { display: inline-flex; align-items: center; gap: 4px; background: rgba(251, 247, 236, 0.92); padding: 2px 9px 2px 6px; border-radius: 99px;
  font-size: 14px; color: #8a5a10; white-space: nowrap; }
#purse b { font-weight: 700; min-width: 1.5em; }
#purse.bump { animation: purseBump 0.3s ease-out; }
@keyframes purseBump { 40% { transform: scale(1.18); } }
.coin-ico, .coin-fly { display: inline-block; width: 16px; height: 16px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 38% 34%, #fff3b0 0 12%, #e8b53a 45%, #a8701a 100%); box-shadow: inset 0 0 0 1.5px #8a5a10; }
.coin-ico::after, .coin-fly::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); background: #5a3a0c; }
.coin-fly { position: fixed; z-index: 70; width: 18px; height: 18px; pointer-events: none; margin: 0; }
.coin-fly.ingot { width: 24px; height: 16px; border-radius: 40% 40% 50% 50% / 60% 60% 40% 40%; }
.coin-fly.ingot::after { display: none; }

.float-txt { position: fixed; z-index: 70; transform: translate(-50%, -50%); pointer-events: none; font-family: var(--kai); font-weight: 700; font-size: 18px;
  color: #8a5a10; text-shadow: 0 0 3px #fffaf0, 0 0 6px #fffaf0; animation: floatUp 1.3s ease-out forwards; white-space: nowrap; }
.float-txt.gold { color: #c27f0e; font-size: 22px; }
.float-txt.love { color: #c0396b; }
@keyframes floatUp { 0% { opacity: 0; margin-top: 8px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -54px; } }

/* ── 刻字圓石：道具、禮物、籤（稀有度＝光暈顏色 --rc） ── */
.tok { --ts: 54px; position: relative; display: inline-grid; place-items: center; width: var(--ts); height: var(--ts); border-radius: 50%; flex: none;
  background: radial-gradient(circle at 40% 32%, #f3eee2 0 30%, #d6cfbf 70%, #b9b09c 100%);
  box-shadow: 0 3px 0 #9d9380, 0 0 0 2px var(--rc), 0 0 12px 2px var(--rg); }
.tok.r1 { box-shadow: 0 3px 0 #9d9380, 0 0 0 2px #e9e2d0, 0 0 6px rgba(255, 255, 255, 0.8); }
.tok b { font-family: var(--kai); font-size: calc(var(--ts) * 0.52); line-height: 1; color: #3a3330; font-weight: 700; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }
.tok.r4 b { color: #7a4c0e; }
.tok i { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #2b2620; color: #fff;
  font-style: normal; font-size: 11px; line-height: 18px; text-align: center; font-family: -apple-system, sans-serif; }
.tok.off { filter: grayscale(1) opacity(0.45); }

/* ── 朱砂印章 ── */
.seal { display: inline-grid; place-items: center; width: 54px; height: 54px; border: 3px solid #b8352a; border-radius: 6px; color: #b8352a; transform: rotate(-8deg);
  background: rgba(255, 245, 235, 0.35); box-shadow: inset 0 0 0 2px rgba(184, 53, 42, 0.25); flex: none; }
.seal b { font-family: var(--kai); font-size: 34px; line-height: 1; }
.seal.big { width: 76px; height: 76px; visibility: hidden; }
.seal.big b { font-size: 50px; }
.seal.g甲 { background: #b8352a; color: #fff4e6; }
.seal.record { width: auto; height: auto; padding: 8px 12px; border-width: 4px; }
.seal.record b { font-size: 34px; letter-spacing: 4px; writing-mode: horizontal-tb; }
.seal.mini { width: 18px; height: 18px; border-width: 1.5px; border-radius: 3px; }
.seal.mini b { font-size: 12px; }

/* ── 結算 ── */
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.res-tbl { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 15px; }
.res-tbl th { text-align: left; font-weight: 400; color: #6b6170; padding: 3px 0; }
.res-tbl td { text-align: right; padding: 3px 0 3px 10px; white-space: nowrap; }
.res-tbl td.neg { color: #b8352a; }
.res-tbl tr.tot th, .res-tbl tr.tot td { border-top: 1.5px solid rgba(43, 38, 32, 0.4); padding-top: 6px; font-size: 18px; color: #2b2620; }
.res-extra { display: grid; gap: 6px; margin-top: 6px; }
.res-extra .coinline { display: flex; align-items: center; gap: 6px; color: #8a5a10; }

/* ── 寶箱 ── */
.chest-ov { position: fixed; inset: 0; z-index: 35; display: grid; grid-template-rows: auto 1fr auto auto auto; justify-items: center; align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 38%, rgba(52, 42, 32, 0.84), rgba(20, 16, 14, 0.95)); animation: fadeIn 0.25s; cursor: pointer; }
.chest-ov.out { opacity: 0; transition: opacity 0.25s; }
.chest-ov.slow { animation: slowGlow 2.2s ease-in-out; }
@keyframes slowGlow { 30%, 70% { background-color: rgba(255, 200, 60, 0.25); } }
@keyframes fadeIn { from { opacity: 0; } }
.chest-title { font-family: var(--kai); font-size: 26px; color: #fff4dc; letter-spacing: 6px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.chest-stage { position: relative; width: min(260px, 70vw); aspect-ratio: 200 / 170; align-self: end; }
.chest-box { position: absolute; inset: 0; transform-origin: 50% 90%; }
.chest-svg { width: 100%; height: 100%; overflow: visible; }
.chest-lid { transform-box: fill-box; transform-origin: 20% 100%; }
.chest-seam { opacity: 0; filter: drop-shadow(0 0 6px var(--seam)) drop-shadow(0 0 14px var(--seam)); }
.chest-seam.on { animation: seam 0.5s ease-in forwards; }
@keyframes seam { from { opacity: 0; } to { opacity: 1; } }
.chest-pillar { position: absolute; left: 50%; bottom: 40%; width: 46%; height: 260%; transform: translateX(-50%) scaleY(0); transform-origin: 50% 100%; opacity: 0; pointer-events: none;
  background: linear-gradient(0deg, var(--best), rgba(255, 255, 255, 0)); filter: blur(6px); border-radius: 50% 50% 0 0; }
.chest-pillar.on { animation: pillar 1.3s ease-out forwards; }
@keyframes pillar { 0% { opacity: 0; transform: translateX(-50%) scaleY(0); } 25% { opacity: 1; transform: translateX(-50%) scaleY(1); } 100% { opacity: 0.35; transform: translateX(-50%) scaleY(1); } }
.chest-ov.burst::after { content: ""; position: fixed; inset: 0; background: #fff; pointer-events: none; animation: flashOut 0.45s ease-out forwards; }
.chest-paper { width: min(360px, 100%); min-height: 120px; margin-top: 12px; padding: 14px 10px; border-radius: 6px;
  background: #f1e7d0; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(120, 95, 60, 0.35); }
.chest-loot { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; perspective: 600px; }
.loot { display: grid; justify-items: center; gap: 2px; width: 78px; }
.loot .ln { font-family: var(--kai); font-size: 15px; color: #2b2620; text-align: center; }
.loot .lr { font-size: 12px; font-weight: 700; }
.chest-tip { color: #f3e6c8; font-size: 15px; margin-top: 8px; min-height: 1.2em; }
.chest-row { margin-top: 8px; }
.chest-row button, .ov-btn { font-size: 17px; padding: 9px 26px; background: #b8352a; color: #fff; border-color: #7a1d16; }
.chest-row button:hover, .ov-btn:hover { background: #9c2b21; color: #fff; }

/* ── 金幣元寶雨 ── */
.coin-rain { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; touch-action: none; }
.coin-tip { position: fixed; left: 50%; top: max(70px, calc(env(safe-area-inset-top) + 56px)); transform: translateX(-50%); z-index: 61; pointer-events: none;
  background: rgba(43, 38, 32, 0.85); color: #ffe7a6; padding: 6px 14px; border-radius: 99px; font-size: 14px; white-space: nowrap; animation: fadeIn 0.3s; }

.bag-fly { position: fixed; z-index: 70; pointer-events: none; }

/* 小香跳出來的掛軸要在寶箱、結算上面 */
#cheer { z-index: 45 !important; }

/* ── 戰鬥道具列（畫面下方，最多 4 種） ── */
#itemBar { flex-basis: 100%; display: flex; justify-content: center; gap: 10px; margin-bottom: 6px; }
#itemBar .ib { display: grid; justify-items: center; gap: 1px; padding: 0; background: none; border: 0; border-radius: 10px; width: 56px; }
#itemBar .ib:hover { background: rgba(251, 247, 236, 0.5); }
#itemBar .ib span { font-size: 13px; color: #5a4f45; text-shadow: 0 0 3px #fbf7ec, 0 0 3px #fbf7ec; line-height: 1.2; }
#itemBar .ib.passive span { color: #9a5bd0; }
#itemBar .ib.none { display: grid; place-items: center; height: 44px; }
#itemBar .ib.none i { width: 34px; height: 34px; border-radius: 50%; border: 1.5px dashed rgba(43, 38, 32, 0.25); }
.item-use { position: fixed; z-index: 9; pointer-events: none; transform: translate(-50%, -50%); animation: itemUse 0.85s ease-out forwards; }
.item-use::after { content: ""; position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; border-radius: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(255, 220, 120, 0.9); animation: itemRing 0.7s ease-out forwards; }
@keyframes itemUse { 0% { margin-top: 0; opacity: 1; } 40% { margin-top: -60px; transform: translate(-50%, -50%) scale(1.3); } 100% { margin-top: -90px; opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }
@keyframes itemRing { to { width: 140px; height: 140px; opacity: 0; } }
.revive-fx { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 30; pointer-events: none; text-align: center; font-family: var(--kai);
  color: #fff3d0; text-shadow: 0 0 10px #9a5bd0, 0 0 22px #9a5bd0; animation: revive 1.8s ease-out forwards; }
.revive-fx b { display: block; font-size: 46px; letter-spacing: 6px; }
.revive-fx small { font-size: 18px; }
@keyframes revive { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); } }
/* 護身符擋下攻擊：一圈金色的護盾 */
.shield-fx { position: fixed; inset: 0; z-index: 7; pointer-events: none; animation: flashOut 0.8s ease-out forwards;
  background: radial-gradient(ellipse at center, rgba(255, 220, 120, 0) 40%, rgba(255, 210, 90, 0.55) 100%); }
/* 身上有效果（護身符、火符）：左上角的小標記 */
#buffs { display: inline-flex; gap: 4px; }
#buffs .tok { --ts: 22px; }

/* ── 圖鑑：包袱、回憶 CG ── */
.bag-top { display: flex; gap: 18px; align-items: center; font-size: 15px; padding: 6px 2px 2px; }
.bag-top span { display: inline-flex; align-items: center; gap: 6px; }
.bag-h { font-size: 16px; margin: 14px 0 6px; font-weight: 700; }
.bag-h .sub { font-weight: 400; margin-left: 6px; }
.bag-row { display: flex; align-items: center; gap: 12px; padding: 7px 2px; border-bottom: 1px dashed #d8cfba; }
.bag-txt { flex: 1; display: grid; gap: 1px; min-width: 0; }
.bag-txt span { font-size: 13px; color: #6b6170; }
.bag-carry { font-size: 13px; padding: 3px 12px; }
.bag-carry.on { background: #3f8f6a; border-color: #2d6b4e; color: #fff; }
.bag-carry.on:hover { background: #357a5a; color: #fff; }
.pref { font-style: normal; font-weight: 700; }
.pref.love { color: #c0396b; } .pref.ok { color: #6b6170; } .pref.meh { color: #8a7a5a; }
.cg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cg { display: grid; gap: 3px; text-align: center; font-size: 13px; }
.cg b { font-size: 14px; }
.cg span { font-size: 12px; color: #8a6d3b; }
.cg-pic { aspect-ratio: 4 / 3; border-radius: 8px; display: grid; place-items: center; font-size: 15px; color: #fff; line-height: 1.3;
  background: linear-gradient(135deg, #e7a9b8, #f3d3a6); box-shadow: inset 0 0 0 4px #fff, 0 3px 8px rgba(40, 30, 20, 0.2); }
.cg-pic small { font-size: 11px; }
.cg-pic.sil { background: #d9d2c2 radial-gradient(ellipse 22% 30% at 50% 42%, #b5ab97 98%, transparent) ; box-shadow: inset 0 0 0 4px #efe8d8; }
.cg-pic.sil::after { content: ""; width: 46%; height: 40%; margin-top: 46%; border-radius: 50% 50% 0 0; background: #b5ab97; grid-area: 1 / 1; }

/* ── 搖籤筒 ── */
.lot-ov { position: fixed; inset: 0; z-index: 35; display: grid; justify-items: center; align-content: center; gap: 10px; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(70, 30, 24, 0.86), rgba(24, 14, 12, 0.95)); animation: fadeIn 0.25s; }
.lot-ov.out { opacity: 0; transition: opacity 0.25s; }
.lot-title { font-family: var(--kai); font-size: 26px; color: #fff4dc; letter-spacing: 8px; }
.lot-stage { position: relative; width: 220px; height: 280px; }
.lot-tube { position: absolute; left: 50%; bottom: 0; width: 108px; height: 230px; margin-left: -54px; transform-origin: 50% 100%; touch-action: none; cursor: grab; }
.lot-sticks { position: absolute; left: 50%; bottom: 120px; width: 0; height: 0; }
.lot-sticks i { position: absolute; left: -4px; bottom: 0; width: 8px; height: var(--h); border-radius: 3px 3px 1px 1px; transform: translateX(var(--x)) rotate(var(--r));
  background: linear-gradient(90deg, #e8cf94, #f6e3b4 40%, #c9a865); box-shadow: 0 0 0 1px rgba(90, 60, 20, 0.5); transition: transform 0.15s; transform-origin: 50% 100%; }
.lot-sticks i::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px; background: #b8352a; border-radius: 3px 3px 0 0; }
.lot-body { position: absolute; left: 0; right: 0; bottom: 0; height: 150px; border-radius: 10px 10px 16px 16px; display: grid; place-items: center;
  background: linear-gradient(90deg, #7a2a1e, #b8352a 35%, #c8483a 55%, #7a2a1e); box-shadow: inset 0 0 0 3px #e2a72e, 0 8px 18px rgba(0, 0, 0, 0.4); }
.lot-body b { font-family: var(--kai); font-size: 54px; color: #ffe08a; text-shadow: 0 2px 0 #5a1a10; }
.lot-out { position: absolute; left: 50%; top: 40px; width: 26px; height: 150px; margin-left: -13px; opacity: 0; pointer-events: none; transform-style: preserve-3d; perspective: 500px; }
.lot-out.fall { animation: lotFall 0.9s cubic-bezier(.3, .6, .4, 1) forwards; }
.lot-out.flip .lot-face.front { transform: rotateY(180deg); } .lot-out.flip .lot-face.back { transform: rotateY(0); }
.lot-face { position: absolute; inset: 0; border-radius: 4px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform 0.6s;
  background: linear-gradient(90deg, #e8cf94, #f6e3b4 40%, #c9a865); box-shadow: 0 0 0 1px rgba(90, 60, 20, 0.6); }
.lot-face.back { transform: rotateY(-180deg); display: grid; align-content: start; justify-items: center; padding-top: 14px; gap: 6px; }
.lot-face.back b { font-family: var(--kai); writing-mode: vertical-rl; font-size: 22px; color: #b8352a; letter-spacing: 4px; }
.lot-face.back small { writing-mode: vertical-rl; font-size: 11px; color: #6b4a20; }
@keyframes lotFall { 0% { opacity: 1; transform: translateY(40px) rotate(0); } 40% { transform: translateY(-80px) rotate(-200deg); } 100% { opacity: 1; transform: translate(70px, -10px) rotate(-90deg) scale(1.5); } }
.lot-out.flip { animation: none; opacity: 1; transform: translate(70px, -10px) rotate(-90deg) scale(1.5); }
body.lot-open #cheer { left: max(8px, env(safe-area-inset-left)) !important; right: auto !important; top: max(8px, env(safe-area-inset-top)) !important; width: 96px !important; }
body.lot-open #cheerLine { font-size: 11px; padding: 2px 6px; }
.lot-say { font-size: 14px; margin-top: 6px; color: #5a4f45; }
.lot-say b { color: #c0396b; }
/* 矮螢幕（iPhone SE 這類）：籤筒縮小，翻開的籤詩卡才放得下 */
.lot-ov { overflow-y: auto; }
@media (max-height: 720px) {
  .lot-ov { align-content: start; gap: 4px; padding-top: max(10px, env(safe-area-inset-top)); }
  .lot-stage { height: 200px; transform: scale(0.72); transform-origin: 50% 0; margin-bottom: -56px; }
  .lot-title { font-size: 22px; }
  .lot-poem span { font-size: 17px; }
}
.lot-tip { color: #f3e6c8; font-size: 15px; min-height: 1.3em; }
.lot-perm { display: grid; gap: 8px; justify-items: center; }
.lot-perm button:not(.ov-btn) { font-size: 14px; background: rgba(251, 247, 236, 0.9); }
.lot-card { width: min(340px, 100%); background: #f6eedb; border-radius: 8px; padding: 14px 16px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4); animation: fadeIn 0.4s; text-align: center; }
.lot-level { font-family: var(--kai); font-size: 22px; color: #b8352a; letter-spacing: 2px; }
.lot-level.l上上 { color: #fff; background: #b8352a; border-radius: 6px; display: inline-block; padding: 2px 12px; }
.lot-poem { display: flex; flex-direction: row-reverse; justify-content: center; gap: 10px; margin: 10px 0; }
.lot-poem span { writing-mode: vertical-rl; font-family: var(--kai); font-size: 19px; letter-spacing: 3px; color: #2b2620; }
.lot-prize { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px; background: #ede2c8; border-radius: 10px; }
.lot-prize div { display: grid; text-align: left; } .lot-prize span { font-size: 12px; font-weight: 700; }

/* ── 開場、結尾（story.js） ── */
.story-ov { position: fixed; inset: 0; z-index: 32; background: #f1ead9; overflow: hidden; animation: fadeIn 0.4s; }
.story-ov.out { opacity: 0; transition: opacity 0.35s; }
.story-bgwrap { position: absolute; inset: 0; }
.story-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.story-fx { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; }
.story-scroll { position: absolute; left: 50%; top: 16%; width: min(260px, 64vw); height: calc(min(260px, 64vw) * 4 / 3); margin-left: calc(min(260px, 64vw) / -2);
  animation: unroll 1.1s cubic-bezier(.3, .8, .3, 1) both; }
.story-scroll::before, .story-scroll::after { content: ""; position: absolute; left: -10px; right: -10px; height: 12px; border-radius: 6px; background: linear-gradient(180deg, #8a5a33, #3e2512); z-index: 2; }
.story-scroll::before { top: -6px; } .story-scroll::after { bottom: -6px; }
.ss-paper { position: absolute; inset: 0; overflow: hidden; box-shadow: 0 10px 30px rgba(40, 30, 20, 0.45); }
.ss-paper .story-bg { position: absolute; }
.story-scroll.glow .paint-words { animation: wordGlow 1.4s ease-in-out infinite alternate; }
.story-scroll.glow::after { box-shadow: 0 0 40px 20px rgba(255, 220, 120, 0.6); }
.story-scroll.glow .ss-paper { animation: inkBleed 3s ease-in forwards; }
@keyframes unroll { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wordGlow { to { fill: #ffcf4a; filter: drop-shadow(0 0 6px #ffcf4a) drop-shadow(0 0 14px #ffb020); opacity: 1; } }
@keyframes inkBleed { 60% { filter: none; } 100% { filter: contrast(1.4) brightness(0.55); } }
/* 開場五人版：大妖的墨影從遠山後升起 → 墨風 → 三位姊姊被三團墨捲走 */
.story-shade { position: absolute; left: 50%; top: 22%; width: 70vw; max-width: 300px; aspect-ratio: 1; margin-left: min(-35vw, -150px);
  border-radius: 46% 54% 40% 60% / 60% 55% 45% 40%; background: radial-gradient(circle at 50% 45%, #0d0b0a 0 45%, rgba(13, 11, 10, 0.75) 60%, transparent 72%);
  filter: blur(3px); animation: shadeRise 2.6s cubic-bezier(.3, .7, .3, 1) both; }
.story-shade::before, .story-shade::after { content: ""; position: absolute; top: 34%; width: 9%; height: 5%; border-radius: 50%; background: #d9453a; box-shadow: 0 0 12px 4px rgba(217, 69, 58, 0.7); }
.story-shade::before { left: 34%; } .story-shade::after { right: 34%; }
@keyframes shadeRise { from { transform: translateY(40%) scale(0.6); opacity: 0; } to { transform: none; opacity: 0.92; } }
.story-ov.storm .story-bgwrap { animation: stormShake 0.18s linear infinite; }
.story-ov.storm .story-fx::after { content: ""; position: absolute; inset: 0; animation: windStreak 0.5s linear infinite;
  background: repeating-linear-gradient(-14deg, transparent 0 34px, rgba(20, 16, 14, 0.18) 34px 37px, transparent 37px 70px); }
@keyframes stormShake { 25% { transform: translate(2px, -1px); } 75% { transform: translate(-2px, 1px); } }
@keyframes windStreak { from { background-position: 0 0; } to { background-position: -140px 30px; } }
.story-swept { position: absolute; left: 50%; top: 52%; width: 64px; height: 64px; margin: -32px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(20, 16, 14, 0.9) 0 40%, rgba(20, 16, 14, 0.4) 60%, transparent 70%); animation: swept 2.2s cubic-bezier(.5, 0, .7, 1) both; }
.story-swept b { font: 15px "TW-Kai Sub", serif; color: #f1ead9; }
.story-swept.s0 { --tx: -60vw; --ty: -38vh; } .story-swept.s1 { --tx: 62vw; --ty: -30vh; animation-delay: 0.15s; } .story-swept.s2 { --tx: 8vw; --ty: -62vh; animation-delay: 0.3s; }
@keyframes swept { from { transform: scale(0.4); opacity: 0; } 20% { transform: scale(1.1); opacity: 1; } to { transform: translate(var(--tx), var(--ty)) rotate(540deg) scale(0.3); opacity: 0; } }
.story-photo { position: absolute; right: 16px; top: max(56px, calc(env(safe-area-inset-top) + 44px)); width: min(150px, 38vw); background: #fff; padding: 7px 7px 22px; border-radius: 3px;
  box-shadow: 0 6px 18px rgba(40, 30, 20, 0.3); transform: rotate(3deg); }
.story-photo .shot { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: #333; }
.story-photo video, .story-photo .still-box { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.18s; }
.story-photo video.on, .story-photo .still-box.on { opacity: 1; }
.story-ov.inside .story-photo { background: #e9dcc0; transform: rotate(-2deg); }     /* 畫裡：照片框換成宣紙色（像掛軸） */
.story-box { position: absolute; left: 12px; right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); min-height: 108px; padding: 12px 16px 26px; cursor: pointer;
  background: rgba(251, 247, 236, 0.96); border: 2px solid #2b2620; border-radius: 14px; box-shadow: 0 8px 22px rgba(40, 30, 20, 0.25); }
.story-who { display: inline-block; color: #c0396b; font-size: 15px; margin-bottom: 4px; }
.story-text { font-size: 18px; line-height: 1.55; font-family: var(--kai); }
.story-next { position: absolute; right: 14px; bottom: 6px; font-size: 12px; color: #8a6d3b; animation: nextBob 0.9s ease-in-out infinite; }
@keyframes nextBob { 50% { transform: translateY(3px); } }
.story-skip { position: absolute; right: 12px; top: max(12px, env(safe-area-inset-top)); font-size: 13px; padding: 3px 12px; background: rgba(251, 247, 236, 0.85); }
/* 寫回原樣：灰墨蓋著 → 墨退去、上色 */
.story-bg.restore { filter: grayscale(1) contrast(1.15) brightness(0.92); transition: filter 2.6s ease-in-out 0.4s; }
.restoring .story-bg.restore { filter: none; }
.ink-cover2 { position: absolute; inset: 0; pointer-events: none; }
.ink-cover2 i { position: absolute; left: var(--x); top: var(--y); width: 70vmax; height: 70vmax; margin: -35vmax 0 0 -35vmax; border-radius: 47% 53% 44% 56%;
  background: radial-gradient(circle, rgba(29, 27, 32, 0.92) 40%, rgba(29, 27, 32, 0) 70%); transition: transform 2.2s cubic-bezier(.5, 0, .3, 1) var(--d), opacity 2.2s var(--d); }
.restoring .ink-cover2 i { transform: scale(0); opacity: 0; }
.restore-txt { position: absolute; left: 0; right: 0; top: 38%; text-align: center; font-family: var(--kai); font-size: 30px; letter-spacing: 8px; color: #2b2620; opacity: 0;
  text-shadow: 0 0 12px #fffaf0, 0 0 24px #fffaf0; transition: opacity 1s 1.6s; }
.restoring .restore-txt { opacity: 1; }
.story-result { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(400px, calc(100% - 28px)); max-height: 90vh; overflow: auto; animation: fadeIn 0.4s; }
.record-wrap { display: flex; justify-content: center; margin: 6px 0; }
.next-teaser { display: flex; gap: 12px; align-items: center; margin-top: 10px; padding: 8px; border-radius: 10px; background: #2b2f3a; color: #e6e9f0; animation: fadeIn 0.6s; }
.nt-pic { width: 120px; flex: none; border-radius: 6px; overflow: hidden; }
.nt-pic svg { display: block; width: 100%; height: auto; }
.nt-txt { display: grid; gap: 2px; } .nt-txt small { color: #aab3c6; font-size: 12px; } .nt-txt b { font-family: var(--kai); font-size: 18px; } .nt-txt span { font-size: 12px; color: #aab3c6; }

/* ── 教學箭頭 ── */
.tut-arrow { position: fixed; z-index: 9; width: 0; height: 0; pointer-events: none; }
.tut-arrow::before { content: ""; position: absolute; left: -14px; top: -50px; width: 28px; height: 38px; animation: tutBob 0.7s ease-in-out infinite;
  background: #b8352a; clip-path: polygon(30% 0, 70% 0, 70% 55%, 100% 55%, 50% 100%, 0 55%, 30% 55%); filter: drop-shadow(0 2px 0 #fff); }
.tut-arrow::after { content: ""; position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid #b8352a; animation: tutRing 1s ease-out infinite; }
@keyframes tutBob { 50% { transform: translateY(-8px); } }
@keyframes tutRing { from { transform: scale(0.6); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.tut-tag { position: fixed; left: 50%; transform: translateX(-50%); z-index: 9; background: #b8352a; color: #fff; padding: 3px 12px; border-radius: 99px; font-size: 13px; pointer-events: none; white-space: nowrap; }

/* 金幣雨下著的時候：浮在最上面的錢袋計數（深色浮層會蓋住原本的錢袋） */
.rain-purse { position: fixed; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); z-index: 63; pointer-events: none;
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 12px 3px 7px; border-radius: 99px; font-size: 17px; font-weight: 700; color: #8a5a10;
  background: #fbf3dc; box-shadow: 0 0 0 2px #e2a72e, 0 0 18px rgba(255, 200, 60, 0.75); animation: fadeIn 0.25s; }
.rain-purse .coin-ico { width: 20px; height: 20px; }
.rain-purse.bump { animation: purseBump 0.22s ease-out; }
.rain-purse.out { opacity: 0; transition: opacity 0.3s; }
/* 立體寶箱的畫布 */
.chest-stage { width: min(330px, 86vw); aspect-ratio: 1 / 0.82; }
.chest-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
