:root {
  --bg: #24130e;
  --glass: rgba(36, 20, 14, .78);
  --glass-2: rgba(52, 28, 18, .9);
  --line: rgba(232, 193, 90, .45);
  --gold: #e8c15a;
  --gold-2: #f6dc94;
  --ink: #fbf1dc;
  --muted: #d9c3a0;
  --red: #b8322a;
  --red-2: #d8473a;
  --jade: #2f7d6d;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body, button { touch-action: manipulation; } /* 連點按鈕不會放大畫面 */
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
/* 白天：明亮的藍天 */
body { background: linear-gradient(#7cc8f8, #b8e4ff 45%, #e6f6ff); overscroll-behavior: none; }
body.night { background: linear-gradient(#0b1030, #1c2250 55%, #3a2a4a); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

/* ---------- 開場 ---------- */
#splash { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(28px + var(--sat)) 16px calc(18px + var(--sab)); text-align: center;
  background: linear-gradient(rgba(20, 10, 6, .72), rgba(20, 10, 6, 0) 34%, rgba(20, 10, 6, 0) 50%, rgba(20, 10, 6, .86) 76%); transition: opacity .5s var(--ease); }
#splash.leaving { opacity: 0; pointer-events: none; }
.eyebrow { margin: 0 0 8px; letter-spacing: .3em; color: var(--gold-2); font-size: 13px; opacity: 0; animation: up .7s .1s var(--ease) forwards; }
#splash h1 { margin: 0; font-size: clamp(38px, 11vw, 62px); line-height: 1.12; letter-spacing: .08em; font-weight: 900;
  background: linear-gradient(100deg, #fff4d6 20%, #f3c95a 45%, #fff4d6 55%, #f3c95a 80%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 2px 18px rgba(0, 0, 0, .25);
  opacity: 0; animation: up .8s .25s var(--ease) forwards, shine 4s 1.2s linear infinite; }
.subtitle { margin: 12px 0 0; color: var(--ink); opacity: 0; font-size: 15px; animation: up .7s .45s var(--ease) forwards; text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shine { to { background-position: -250% 0; } }
.splash-bottom { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: 0; animation: up .7s .6s var(--ease) forwards; }
.enter { display: flex; align-items: center; gap: 10px; padding: 14px 30px; border-radius: 999px; border: 1px solid var(--gold);
  background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff6e0; font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: .12em;
  box-shadow: 0 6px 24px rgba(184, 50, 42, .5), inset 0 1px 0 rgba(255, 255, 255, .25); animation: breathe 2.6s ease-in-out infinite; }
.enter svg { width: 26px; height: 26px; fill: none; stroke: var(--gold-2); stroke-width: 3; stroke-linecap: round; }
@keyframes breathe { 50% { box-shadow: 0 6px 34px rgba(232, 193, 90, .55), inset 0 1px 0 rgba(255, 255, 255, .25); } }
.picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ghost { padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--ink); min-height: 40px; }
.ghost[aria-pressed="true"], .ghost[aria-expanded="true"] { background: var(--red); border-color: var(--gold); }
.ghost.small { padding: 6px 12px; font-size: 13px; min-height: 34px; }
button:active { transform: scale(.97); }
#customize { width: 100%; background: var(--glass); border: 1px solid var(--line); border-radius: 18px; padding: 8px 12px; }
.crow { display: grid; grid-template-columns: 4.2em 44px 1fr 44px; align-items: center; gap: 6px; padding: 3px 0; }
.crow span { text-align: left; color: var(--muted); font-size: 14px; }
.crow button { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: transparent; }
.crow b { font-weight: 600; font-size: 14px; display: flex; justify-content: center; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .5); display: inline-block; }
.disclaimer { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- 遊戲畫面 ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#hud > * { pointer-events: auto; }
.topbar { position: absolute; top: calc(10px + var(--sat)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.tools { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.icon, #presence { width: 42px; height: 42px; border-radius: 999px; border: 0; background: transparent; display: grid; place-items: center; }
#info-btn { background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#presence { width: auto; padding: 0 10px; display: flex; gap: 6px; align-items: center; font-size: 14px; }
.icon svg, #presence svg { width: 22px; height: 22px; fill: none; stroke: var(--gold-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#sound-btn[aria-pressed="false"] .wave { opacity: .15; }
#time-btn[aria-pressed="true"] svg { fill: var(--gold-2); }

#guide { position: absolute; top: calc(64px + var(--sat)); left: 12px; width: min(300px, calc(100% - 24px)); background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: hidden; }
#guide-toggle { width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: none; border: 0; font-family: var(--serif); font-weight: 700; font-size: 15px; color: var(--gold-2); }
#guide-toggle b { font-family: var(--sans); font-weight: 500; font-size: 13px; color: var(--muted); margin-left: auto; }
#guide-toggle i { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
#guide-toggle[aria-expanded="false"] i { transform: rotate(-45deg); }
#guide-body { padding: 0 14px 12px; }
#guide-toggle[aria-expanded="false"] + #guide-body { display: none; }
#guide-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
#guide-steps li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 13.5px; line-height: 1.45; color: var(--muted); align-items: start; }
#guide-steps li::before { content: attr(data-n); width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 11px; margin-top: 1px; }
#guide-steps li.cur { color: var(--ink); font-weight: 600; }
#guide-steps li.cur::before { background: var(--red); border-color: var(--gold); color: #fff; }
#guide-steps li.ok { color: rgba(217, 195, 160, .6); text-decoration: line-through; text-decoration-color: rgba(232, 193, 90, .5); }
#guide-steps li.ok::before { content: "✓"; background: var(--jade); border-color: transparent; color: #fff; }
#guide-carry { margin: 8px 0 0; font-size: 12.5px; color: var(--gold-2); }
#guide-carry:empty { display: none; }

#next { position: absolute; left: 12px; right: 12px; bottom: calc(96px + var(--sab)); margin: 0 auto; max-width: 520px; padding: 10px 14px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line); font-size: 14.5px; line-height: 1.5; pointer-events: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#next:empty { display: none; }
#next b { color: var(--gold-2); }
#toast { position: absolute; left: 50%; top: calc(118px + var(--sat)); transform: translate(-50%, -8px); max-width: min(520px, calc(100% - 24px)); width: max-content;
  padding: 10px 16px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--gold); font-size: 14.5px; line-height: 1.5; opacity: 0; pointer-events: none; transition: .25s var(--ease); z-index: 3; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.guide-open #toast { top: auto; bottom: calc(150px + var(--sab)); }

#dock { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--sab)); display: flex; gap: 0; padding: 5px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line); max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#dock::-webkit-scrollbar { display: none; }
#dock span { white-space: nowrap; font-size: 11.5px; letter-spacing: -.02em; }
#dock button { flex: 0 0 auto; width: clamp(34px, calc((100vw - 34px) / 10.4), 62px); min-height: 66px; padding: 6px 0 4px; border: 0; border-radius: 14px; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); position: relative; }
#dock svg { width: 26px; height: 26px; fill: none; stroke: var(--gold-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#dock button.done { opacity: .55; }
#dock button.done::after { content: ""; position: absolute; top: 6px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: #5fd0a8; }
#dock button.cur { background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff; box-shadow: 0 0 0 1px var(--gold) inset; animation: nudge 2.4s ease-in-out infinite; }
#dock button.cur svg { stroke: #fff4d2; }
#dock .sep { width: 1px; align-self: stretch; margin: 8px 1px; background: var(--line); flex: 0 0 auto; }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(-4px); } 90% { transform: none; } }
#dock[aria-busy="true"] button { pointer-events: none; }

/* 地點名牌、香客名牌、對話泡泡 */
.mark { position: absolute; transform: translate(-50%, -100%); padding: 5px 12px 6px; border-radius: 999px; border: 1px solid var(--gold); background: rgba(150, 36, 28, .9);
  color: #fff4d6; font-family: var(--serif); font-weight: 700; font-size: 14px; white-space: nowrap; pointer-events: auto; cursor: pointer; transition: opacity .2s; }
.mark::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--gold); border-bottom: 0; }
.mark.dim { opacity: .55; background: rgba(36, 20, 14, .75); border-color: var(--line); }
.mark.goal { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, calc(-100% - 5px)); } }
.tag { position: absolute; transform: translate(-50%, -100%); padding: 2px 9px; border-radius: 999px; background: rgba(36, 20, 14, .72); border: 1px solid rgba(232, 193, 90, .35);
  font-size: 12px; white-space: nowrap; pointer-events: auto; cursor: pointer; }
.tag.me { border-color: var(--gold); color: var(--gold-2); pointer-events: none; }
.bubble { position: absolute; transform: translate(-50%, -100%); padding: 6px 12px; border-radius: 14px; background: #fff7e6; color: #5a1a14; font-weight: 700; font-size: 14px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); animation: pop .3s var(--ease); }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff7e6; border-bottom: 0; }
@keyframes pop { from { transform: translate(-50%, -80%) scale(.6); opacity: 0; } }
.result-chip { position: absolute; transform: translate(-50%, -100%); padding: 8px 16px; border-radius: 14px; background: var(--red); border: 1px solid var(--gold); color: #fff4d6;
  font-family: var(--serif); font-size: 20px; font-weight: 900; letter-spacing: .1em; white-space: nowrap; animation: pop .35s var(--ease); }

.card-pop { position: absolute; z-index: 6; min-width: 220px; max-width: calc(100% - 24px); padding: 12px; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--gold); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
#cheer-name { margin: 0 0 8px; font-family: var(--serif); font-weight: 700; color: var(--gold-2); }
#cheer-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
#cheer-list button { padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); font-size: 14px; }

/* ---------- 對話框 ---------- */
dialog { max-width: min(480px, calc(100% - 24px)); width: 100%; max-height: calc(100% - 40px); border: 1px solid var(--gold); border-radius: 22px; padding: 18px 18px 14px;
  background: linear-gradient(180deg, #3a1f15, #24130e); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .55); overflow: auto; }
dialog[open] { animation: dlg .28s var(--ease); }
@keyframes dlg { from { opacity: 0; transform: translateY(14px) scale(.98); } }
dialog::backdrop { background: rgba(10, 5, 3, .55); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 8px; font-size: 21px; color: var(--gold-2); }
dialog h3 { margin: 16px 0 6px; font-size: 16px; color: var(--gold-2); }
dialog p { line-height: 1.65; }
.say { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; }
.say.promise { color: var(--gold-2); margin-top: 10px; }
.sub { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.lbl { margin: 8px 0 6px; font-size: 13.5px; color: var(--muted); }
.pending { font-size: 12.5px; color: rgba(217, 195, 160, .8); margin: 10px 0 0; line-height: 1.6; }
.row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.row > button:not(.ghost), dialog .row button:not(.ghost) { padding: 10px 20px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff6e0; font-weight: 700; min-height: 44px; }
.row .ghost { min-height: 44px; }
label { display: grid; gap: 4px; margin: 8px 0; font-size: 13.5px; color: var(--muted); }
input, textarea { font: inherit; font-size: 16px; color: var(--ink); background: rgba(0, 0, 0, .28); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); margin-top: 12px; }
label.check input { width: 20px; height: 20px; accent-color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); font-size: 14px; min-height: 36px; }
.chips button[aria-pressed="true"] { background: var(--red); border-color: var(--gold); }
#intro-dlg[data-mode="heaven"] .for-wenchang, #intro-dlg[data-mode="wenchang"] .for-heaven { display: none; }

.offer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.offer-grid button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px 8px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); min-width: 0; }
.offer-grid button b { font-family: var(--serif); font-size: 16px; }
.offer-grid button small { font-size: 12px; color: var(--muted); }
.offer-grid button i { width: 30px; height: 30px; border-radius: 50%; margin-bottom: 2px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18); }
.offer-grid button[aria-pressed="true"] { background: rgba(184, 50, 42, .55); border-color: var(--gold); }
.offer-grid button[aria-pressed="true"] small { color: var(--gold-2); }
.offer-grid.taboo { grid-template-columns: repeat(3, 1fr); }
.offer-grid.taboo button { opacity: .75; border-style: dashed; }
.msg { min-height: 1.6em; margin: 10px 0 0; font-size: 14px; color: var(--gold-2); }
.msg.warn { color: #ffb4a0; }

/* 過爐、求籤 全螢幕卡 */
#pass-ui, #qian-ui, #jinzhi-ui { user-select: none; -webkit-user-select: none; position: fixed; inset: 0; z-index: 8; display: grid; place-items: end center; padding: 16px 16px calc(16px + var(--sab)); background: linear-gradient(transparent 30%, rgba(10, 5, 3, .55)); }
.pass-card, .qian-card { width: 100%; max-width: 420px; padding: 16px; border-radius: 22px; background: var(--glass-2); border: 1px solid var(--gold); text-align: center; animation: dlg .3s var(--ease); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.pass-card h2, .qian-card h2 { margin: 0 0 6px; color: var(--gold-2); }
.pass-ring { width: min(210px, 56vw); user-select: none; -webkit-user-select: none; aspect-ratio: 1; margin: 0 auto; touch-action: none; }
.pass-ring svg { width: 100%; height: 100%; overflow: visible; }
.pass-ring .track { fill: rgba(255, 140, 60, .08); stroke: rgba(232, 193, 90, .35); stroke-width: 18; stroke-dasharray: 2 10; }
.pass-ring .prog { fill: none; stroke: var(--gold); stroke-width: 6; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 100px 100px; stroke-dasharray: 490; stroke-dashoffset: 490; filter: drop-shadow(0 0 6px rgba(255, 190, 90, .9)); }
#pass-item rect { fill: #fff7e6; stroke: var(--red); stroke-width: 2; }
#pass-item path { stroke: var(--red); stroke-width: 2; fill: none; }
.pass-ring text { fill: var(--ink); font-family: var(--serif); font-size: 26px; font-weight: 900; text-anchor: middle; }
.pass-ring text.small { font-size: 12px; font-weight: 500; fill: var(--muted); font-family: var(--sans); }

.qian-tube { position: relative; width: 120px; height: 200px; margin: 6px auto 8px; border: 0; background: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.qian-tube svg { width: 100%; height: 100%; overflow: visible; }
.qian-tube .tube { fill: #8a4a24; stroke: #e8c15a; stroke-width: 2; }
.qian-tube .band { fill: #e8c15a; }
.qian-tube .sticks rect { fill: #e9cf94; stroke: #8a5a2a; }
.tube-word { fill: #f6dc94; font-family: var(--serif); font-size: 30px; font-weight: 900; text-anchor: middle; }
.qian-tube.shaking svg { animation: shake .14s linear infinite; transform-origin: 50% 90%; }
@keyframes shake { 25% { transform: rotate(-9deg) translateY(-3px); } 75% { transform: rotate(9deg) translateY(-3px); } }
.stick-out { position: absolute; left: 50%; top: 10px; width: 10px; height: 110px; border-radius: 3px; background: #f0d9a0; border: 1px solid #8a5a2a; opacity: 0; transform: translateX(-50%); }
.stick-out.fall { animation: fall .9s var(--ease) forwards; }
@keyframes fall { 0% { opacity: 1; transform: translate(-50%, 0) rotate(0); } 40% { transform: translate(-50%, -70px) rotate(-10deg); } 100% { opacity: 1; transform: translate(40px, 60px) rotate(80deg); } }
.shake-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; margin: 0 20px; }
.shake-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--red-2)); transition: width .1s linear; }

/* 籤詩 */
dialog.lot { padding: 0; }
.slip { margin: 16px 16px 0; padding: 16px; border-radius: 6px; background: linear-gradient(180deg, #fbefcf, #f0dba8); color: #4a1a10; border: 2px solid #b8322a; box-shadow: inset 0 0 0 4px #fbefcf, inset 0 0 0 5px #b8322a; text-align: center; }
.slip-title { margin: 0; font-family: var(--serif); font-size: 13px; letter-spacing: .3em; color: #8a2a20; }
.slip-head { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 4px 0 8px; }
#lot-number { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 900; }
#lot-rank { padding: 2px 10px; border-radius: 6px; background: #b8322a; color: #fff4d6; font-family: var(--serif); font-weight: 700; }
.lot-poem { display: flex; flex-direction: row-reverse; justify-content: center; gap: 14px; font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.25; }
.lot-poem { min-height: 8.6em; align-items: flex-start; }
.lot-poem span { writing-mode: vertical-rl; height: 8.4em; letter-spacing: .12em; opacity: 0; animation: ink .5s var(--ease) forwards; }
@keyframes ink { from { opacity: 0; filter: blur(4px); } to { opacity: 1; filter: none; } }
.lot-body { padding: 4px 18px 0; }
.lot-body p { margin: 0; }
#lot-lines { margin: 6px 0 0; padding-left: 1.4em; line-height: 1.7; font-size: 14px; }
details summary { cursor: pointer; color: var(--gold-2); margin-top: 12px; font-size: 14.5px; }
dialog.lot .row { padding: 0 18px 16px; }

.done-badge { width: 64px; height: 64px; margin: 4px auto 6px; }
.done-badge svg { width: 100%; height: 100%; fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done-badge path { stroke-dasharray: 50; stroke-dashoffset: 50; animation: draw .6s .25s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
#done-dlg h2 { text-align: center; }
.facts { padding-left: 1.2em; line-height: 1.7; font-size: 14.5px; }
.facts li { margin: 4px 0; }
#info-steps { padding-left: 1.4em; line-height: 1.7; font-size: 14.5px; }
#info-sources a { color: var(--gold-2); }

.card-edit { display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: start; }
.card-preview { aspect-ratio: 3/5; border-radius: 6px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-family: var(--serif);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35); transition: background .2s, color .2s; position: relative; }
.card-preview::before { content: ""; position: absolute; top: -10px; left: 50%; width: 2px; height: 12px; background: var(--red-2); }
.card-preview b { font-size: 15px; }
.card-preview p { margin: 0; font-size: 13px; line-height: 1.5; flex: 1; word-break: break-all; }
.card-preview small { font-size: 11px; opacity: .8; }
#card-colors button { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
#card-colors button[aria-pressed="true"] { outline: 2px solid var(--gold-2); outline-offset: 2px; }

@media (min-width: 720px) {
  #dock button { width: 62px; }
  #next { bottom: calc(100px + var(--sab)); }
}
@media (max-height: 640px) {
  #guide-body { max-height: 30vh; overflow: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- 和其他考生互動 ---------- */
#social-btn { position: absolute; right: 12px; bottom: calc(160px + var(--sab)); width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--gold);
  background: linear-gradient(180deg, #3b7d6d, #23584c); color: #fff4d6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
#social-btn svg { width: 24px; height: 24px; fill: none; stroke: #fff4d6; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
#social-btn[aria-expanded="true"] { background: linear-gradient(180deg, var(--red-2), var(--red)); }
#social-btn .dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--red-2); border: 1px solid var(--gold); font-size: 11px; line-height: 16px; }
#social { right: 12px; bottom: calc(224px + var(--sab)); width: min(320px, calc(100% - 24px)); max-height: calc(100% - 300px - var(--sab)); overflow: auto; animation: dlg .22s var(--ease); }
.pop-title { margin: 0 0 8px; font-family: var(--serif); font-weight: 700; color: var(--gold-2); font-size: 14.5px; }
.emote-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.emote-list button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); font-size: 12px; }
.emote-list button i { font-style: normal; font-size: 22px; line-height: 1.1; }
#people-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#people-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
#people-list b { font-weight: 600; font-size: 14px; }
#people-list small { display: block; color: var(--muted); font-size: 12px; }
#people-list button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--gold); background: var(--red); font-size: 13px; min-height: 36px; }
#feed { position: absolute; left: 12px; bottom: calc(156px + var(--sab)); margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column-reverse; gap: 4px; align-items: flex-start; pointer-events: none; max-width: calc(100% - 96px); }
#feed li { padding: 5px 10px; border-radius: 10px; background: rgba(36, 20, 14, .8); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.4; animation: feedIn .3s var(--ease); transition: opacity .5s; }
#feed li.out { opacity: 0; }
@keyframes feedIn { from { opacity: 0; transform: translateY(8px); } }
#toast.show { pointer-events: auto; }
#toast .reply { margin-left: 8px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--gold); background: var(--red); font-size: 13px; }
.tag.done::after { content: " ✓"; color: #7fe0b8; }

/* ---------- 悄悄話 ---------- */
.invite-btn { width: 100%; margin-bottom: 8px; padding: 10px; border-radius: 12px; border: 1px solid var(--gold); background: linear-gradient(180deg, #3b7d6d, #23584c); font-weight: 700; min-height: 44px; }
#people-list .acts { display: flex; gap: 6px; }
#people-list button.alt { background: #23584c; }
#people-list button:disabled { opacity: .45; }
#invite-card { left: 0; right: 0; margin: 0 auto; top: calc(118px + var(--sat)); width: min(340px, calc(100% - 24px)); animation: dlg .25s var(--ease); z-index: 7; }
#invite-text { margin: 0; font-size: 15.5px; line-height: 1.5; }
#invite-text b { color: var(--gold-2); }
#invite-card .row { margin-top: 10px; }
#chat { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; flex-direction: column; max-height: min(58%, 460px); margin: 0 auto; max-width: 560px;
  padding: 12px 12px calc(10px + var(--sab)); border-radius: 20px 20px 0 0; background: var(--glass-2); border: 1px solid var(--gold); border-bottom: 0;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: sheet .3s var(--ease); }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
#chat header { display: flex; align-items: center; gap: 6px; }
#chat h2 { margin: 0 auto 0 0; font-size: 17px; color: var(--gold-2); }
.chat-safe { margin: 6px 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
#chat-log { flex: 1; min-height: 90px; overflow-y: auto; margin: 0; padding: 4px 2px; list-style: none; display: flex; flex-direction: column; gap: 6px; }
#chat-log li { max-width: 80%; padding: 7px 11px; border-radius: 14px; font-size: 15px; line-height: 1.45; word-break: break-word; }
#chat-log li.them { align-self: flex-start; background: #fff7e6; color: #4a1a10; border-bottom-left-radius: 4px; }
#chat-log li.me { align-self: flex-end; background: var(--red); color: #fff4d6; border-bottom-right-radius: 4px; }
#chat-log li.sys { align-self: center; max-width: 100%; background: none; color: var(--muted); font-size: 12.5px; padding: 2px; }
#chat-phrases { flex-wrap: nowrap; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
#chat-phrases::-webkit-scrollbar { display: none; }
#chat-phrases button { flex: 0 0 auto; font-size: 13px; min-height: 34px; }
#chat-form { display: flex; gap: 8px; }
#chat-form input { flex: 1; min-width: 0; }
#chat-form button { padding: 0 18px; border-radius: 12px; border: 1px solid var(--gold); background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff6e0; font-weight: 700; min-height: 44px; }
body.chatting #dock, body.chatting #next, body.chatting #social-btn, body.chatting #feed, body.chatting #dm-btn { display: none; }
#dm-btn { position: absolute; right: 12px; bottom: calc(224px + var(--sab)); width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--gold);
  background: linear-gradient(180deg, #4a5aa0, #2c3770); color: #fff4d6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
#dm-btn svg { width: 24px; height: 24px; fill: none; stroke: #fff4d6; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
#dm-btn .dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--red-2); border: 1px solid var(--gold); font-size: 11px; line-height: 16px; }
#social { bottom: calc(288px + var(--sab)); }
.dm-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.dm-tabs:empty { display: none; }
.dm-tabs::-webkit-scrollbar { display: none; }
.dm-tabs button { flex: 0 0 auto; position: relative; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); font-size: 13.5px; min-height: 34px; }
.dm-tabs button[aria-selected="true"] { background: #2c3770; border-color: var(--gold); }
.dm-tabs button.gone { opacity: .5; }
.dm-tabs b { margin-left: 6px; padding: 0 6px; border-radius: 9px; background: var(--red-2); font-size: 11px; }
.dm-empty { margin: 8px 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.dm-toggle { margin-top: 12px; font-size: 14px; }
#chat-form input:disabled { opacity: .5; }

/* ---------- 版本更新 ---------- */
#update-chip { margin-right: auto; margin-left: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff4d6; font-size: 13.5px; font-weight: 700; animation: breathe 2.6s ease-in-out infinite; }
.update-list { margin: 4px 0 0; padding-left: 1.3em; display: grid; gap: 10px; }
.update-list li b { display: block; color: var(--ink); font-size: 15px; }
.update-list li span { display: block; color: var(--muted); font-size: 14px; line-height: 1.6; margin-top: 2px; }
#app-ver { display: block; margin-top: 4px; }

/* ---------- 方向搖桿（左下角，像打電動） ---------- */
#stick { position: absolute; left: 14px; bottom: calc(100px + var(--sab)); width: 124px; height: 124px; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle, rgba(36, 20, 14, .25) 30%, rgba(36, 20, 14, .55) 70%); border: 2px solid rgba(232, 193, 90, .55); box-shadow: inset 0 0 18px rgba(0, 0, 0, .35); }
#stick::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 1px dashed rgba(232, 193, 90, .3); }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #f6dc94, #c99a3c 60%, #8a6420); box-shadow: 0 4px 10px rgba(0, 0, 0, .45); transition: transform .15s var(--ease); }
#stick.on #stick-knob { transition: none; }
#kneel-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(238px + var(--sab)); display: flex; gap: 8px; z-index: 4; }
#kneel-bar button { min-height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 700; }
#kneel-bow { border: 1px solid var(--gold); background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff4d6; }
/* 直式：下一步提示讓出左下給搖桿 */
#next { left: 150px; }
#feed { bottom: calc(232px + var(--sab)); }
body.kneeling #feed { bottom: calc(292px + var(--sab)); }
body.chatting #stick, body.chatting #kneel-bar { display: none; }

/* ---------- 橫向（手機打橫） ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  #guide { top: calc(58px + var(--sat)); width: 260px; }
  #guide-body { max-height: calc(100vh - 170px); overflow: auto; }
  #stick { left: calc(14px + env(safe-area-inset-left, 0px)); bottom: calc(14px + var(--sab)); width: 112px; height: 112px; }
  #dock { bottom: calc(6px + var(--sab)); }
  #dock button { width: 50px; min-height: 58px; }
  #next { left: 50%; right: auto; transform: translateX(-50%); top: calc(10px + var(--sat)); bottom: auto; width: min(420px, calc(100% - 380px)); padding: 6px 12px; font-size: 13px; }
  #feed { left: calc(140px + env(safe-area-inset-left, 0px)); bottom: calc(80px + var(--sab)); max-width: 38%; }
  #social-btn { bottom: calc(14px + var(--sab)); right: calc(12px + env(safe-area-inset-right, 0px)); }
  #dm-btn { bottom: calc(78px + var(--sab)); right: calc(12px + env(safe-area-inset-right, 0px)); }
  #social { bottom: calc(14px + var(--sab)); right: calc(76px + env(safe-area-inset-right, 0px)); max-height: calc(100% - 80px); }
  #kneel-bar { bottom: calc(80px + var(--sab)); }
  #toast { top: calc(56px + var(--sat)); }
  #chat { max-height: 100%; max-width: 520px; right: calc(12px + env(safe-area-inset-right, 0px)); left: auto; border-radius: 20px 20px 0 0; }
  #splash { flex-direction: row; align-items: flex-end; justify-content: space-between; text-align: left; padding: calc(16px + var(--sat)) 24px calc(14px + var(--sab)); }
  #splash h1 { font-size: 40px; }
  .splash-top { align-self: flex-start; }
  .splash-bottom { max-width: 360px; }
  dialog { max-height: calc(100% - 16px); }
}

/* ---------- 背景音樂 ---------- */
#music-btn[aria-expanded="true"] { background: rgba(232, 193, 90, .18); }
#music-btn.playing svg { animation: musicPulse 2.4s ease-in-out infinite; }
@keyframes musicPulse { 50% { transform: scale(1.12); } }
#music-pop { right: 12px; top: calc(64px + var(--sat)); width: min(320px, calc(100% - 24px)); animation: dlg .22s var(--ease); z-index: 7; }
.music-on { margin: 0 0 10px; font-size: 14.5px; }
.music-list { display: grid; gap: 6px; }
.music-list button { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; text-align: left; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); }
.music-list button::before { content: ""; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--line); }
.music-list button[aria-checked="true"] { border-color: var(--gold); background: rgba(184, 50, 42, .35); }
.music-list button[aria-checked="true"]::before { border-color: var(--gold); background: radial-gradient(circle, var(--gold-2) 45%, transparent 50%); }
.music-list b { display: block; font-size: 14.5px; }
.music-list small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 1px; }
.music-list .now { color: var(--gold-2); font-size: 12px; margin-left: 6px; font-weight: 500; }
@media (prefers-reduced-motion: reduce) { #music-btn.playing svg { animation: none; } }

/* ---------- 燒金紙 ---------- */
.jinzhi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 4px; }
.jinzhi-grid button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); }
.jinzhi-grid button i { width: 46px; height: 34px; border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(138, 90, 20, .6), 3px 3px 0 rgba(0, 0, 0, .25); position: relative; }
.jinzhi-grid button i::after { content: ""; position: absolute; inset: 9px 15px; background: #c8352b; }
.jinzhi-grid b { font-family: var(--serif); font-size: 17px; }
.jinzhi-grid small { font-size: 12px; color: var(--muted); }
.jinzhi-grid button.next { border-color: var(--gold); background: rgba(184, 50, 42, .4); animation: nudge 2s ease-in-out infinite; }
.jinzhi-grid button.burnt { opacity: .4; }

/* ---------- 暱稱 ---------- */
.nick { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 320px; margin: 0; padding: 4px 6px 4px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); }
.nick span { flex: 0 0 auto; font-family: var(--serif); font-weight: 700; color: var(--gold-2); font-size: 15px; }
.nick input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 4px; font-size: 16px; }
.nick input:focus { outline: none; }
.nick:focus-within { border-color: var(--gold); }
.nick-msg { margin: -6px 0 0; min-height: 0; font-size: 13px; color: #ffb4a0; }
.nick-msg:empty { display: none; }
.my-nick { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 12px; font-size: 14px; color: var(--muted); }
.my-nick input { padding: 7px 10px; border-radius: 10px; }
.my-nick button { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--gold); background: var(--red); min-height: 36px; font-size: 13px; }

.tag.far { display: none !important; }

/* ---------- 靈犀占卜（遊戲內） ---------- */
#lingxi-ui { position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; background: #15112e; animation: dlg .25s var(--ease); }
.lx-bar { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--sat)) 12px 8px; background: linear-gradient(180deg, #2a1f4e, #1a1538); border-bottom: 1px solid var(--line); }
.lx-bar h2 { margin: 0 auto 0 0; font-size: 18px; color: var(--gold-2); letter-spacing: .06em; }
.lx-bar a { text-decoration: none; display: inline-flex; align-items: center; }
#lx-close { border-color: var(--gold); background: var(--red); }
.lx-menu { flex: 1; overflow: auto; padding: 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.lx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lx-grid button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 4px 12px; border-radius: 16px; border: 1px solid rgba(232, 193, 90, .4); background: rgba(255, 255, 255, .06); }
.lx-grid button i { font-style: normal; font-size: 26px; line-height: 1.1; }
.lx-grid b { font-size: 15px; }
.lx-grid small { font-size: 11.5px; color: var(--muted); }
#lx-frame { flex: 1; width: 100%; border: 0; background: #fff; }
body.lx-open #hud, body.lx-open #labels { visibility: hidden; }
.again-guide { margin-top: 10px; width: 100%; padding: 9px; border-radius: 12px; border: 1px solid var(--gold); background: rgba(184, 50, 42, .45); font-weight: 700; min-height: 40px; }

/* ---------- 已封鎖的人 ---------- */
#blocked-wrap { margin-top: 12px; }
.blocked-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.blocked-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.blocked-list b { font-weight: 600; font-size: 14px; }
.blocked-list small { display: block; color: var(--muted); font-size: 12px; }
.blocked-list button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; min-height: 36px; }

/* 今日：考試倒數、每日一籤、每日任務、還願 */
#today-btn { position: relative; margin-left: 8px; margin-right: auto; display: flex; align-items: center; gap: 4px; max-width: 150px; height: 42px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 13.5px; color: var(--gold-2); font-weight: 700; }
#today-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#today-btn .dot { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--red-2); border: 1px solid var(--gold); }
#today-btn.fest { border-color: var(--gold); background: linear-gradient(180deg, rgba(200, 36, 28, .85), rgba(140, 24, 18, .85)); }
dialog.today h2 small { font-size: 13px; color: var(--gold-2); font-weight: 400; margin-left: 6px; }
.tbox { margin: 12px 0 0; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); }
.tbox h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 16px; color: var(--gold-2); }
.tbox h3 small { font-weight: 400; font-size: 12.5px; margin-left: 4px; }
.tbox.fest { border-color: var(--gold); background: linear-gradient(180deg, rgba(200, 36, 28, .35), rgba(120, 20, 14, .2)); }
.tbox .row.tight { margin-top: 8px; }
.big-count { margin: 0 0 8px; font-family: var(--serif); font-size: 20px; font-weight: 700; }
.big-count b { color: var(--gold-2); font-size: 30px; margin: 0 4px; }
.exam-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.exam-row select, .exam-row input { flex: 1 1 130px; min-height: 40px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); color: var(--ink); font: inherit; }
.exam-row > button { flex: 1 1 100%; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--gold); background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff6e0; font-weight: 700; min-height: 44px; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.task-list li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; }
.task-list li i { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--gold); display: grid; place-items: center; font-style: normal; font-size: 13px; }
.task-list li.ok i { background: var(--gold); color: #3a2408; }
.task-list li.ok span { opacity: .65; text-decoration: line-through; }
.task-list li span { flex: 1; font-size: 14.5px; }
.task-list li button { padding: 4px 12px; min-height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); font-size: 13px; }
#acc-list button[disabled] { opacity: .5; }
#acc-list button small { display: block; font-size: 11px; opacity: .8; }
.bang-list { margin: 0 0 8px; padding: 0 0 0 4px; list-style: none; max-height: 132px; overflow: auto; font-size: 14px; }
.bang-list li { padding: 3px 0; }
.bang-list li::before { content: "✦ "; color: var(--gold-2); }
.bang-list li small { opacity: .7; margin-left: 6px; }
@media (orientation: landscape) and (max-height: 520px) { #today-btn { max-width: 120px; } }
#presence .online { white-space: nowrap; }

#today-short { display: none; white-space: nowrap; }
/* 窄螢幕：今日按鈕改短字、右上工具列縮小，全部擠得進一行 */
@media (max-width: 430px) {
  #today-label { display: none; } #today-short { display: inline; }
  #today-btn { padding: 0 10px; font-size: 13px; margin-left: 6px; }
  .topbar { left: 10px; right: 10px; }
  .tools { gap: 0; padding: 3px; flex-shrink: 0; }
  .tools .icon { width: 38px; height: 38px; }
  #presence { padding: 0 8px; height: 38px; }
}
@media (max-width: 350px) { #today-short { display: none; } .tools .icon { width: 34px; height: 34px; } }

/* 0.16：任務小卡、慶祝、獎勵、廣場 */
#task-chip { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 14px; border: 0; border-top: 1px solid var(--line); background: linear-gradient(90deg, rgba(200, 53, 43, .35), transparent);
  font-family: var(--serif); font-weight: 700; font-size: 14.5px; color: var(--gold-2); }
#task-chip b { margin-left: auto; font-family: var(--sans); font-size: 13px; color: var(--ink); }
#task-chip i { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; }
#task-chip[aria-expanded="true"] i { transform: rotate(45deg) translateY(-2px); }
#task-chip.done { background: linear-gradient(90deg, rgba(47, 125, 109, .45), transparent); }
#task-chip.pop { animation: chipPop .6s var(--ease); }
@keyframes chipPop { 40% { transform: scale(1.04); background-color: rgba(232, 193, 90, .35); } }
.task-mini { padding: 0 10px 10px; }
.task-mini li { padding: 3px 2px; }
.task-mini li span { font-size: 13px; }
#dock .dot { position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--red-2); border: 1px solid var(--gold); }
#celebrate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; pointer-events: none; }
#celebrate.big { pointer-events: auto; background: rgba(10, 5, 3, .5); }
.cel-card { min-width: 220px; max-width: min(340px, calc(100% - 40px)); padding: 18px 22px; border-radius: 22px; text-align: center; background: var(--glass-2); border: 1.5px solid var(--gold);
  box-shadow: 0 0 40px rgba(232, 193, 90, .35); animation: celIn .45s var(--ease); }
@keyframes celIn { from { transform: scale(.6); opacity: 0; } }
.cel-ic { width: 54px; height: 54px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 900; background: linear-gradient(180deg, #f6dc94, #d8ab45); color: #3a2408; }
.cel-t { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--gold-2); }
.cel-s { margin: 4px 0 8px; font-size: 13.5px; color: var(--muted); }
.cel-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.cel-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d8ab45, #f6dc94); transition: width .6s var(--ease); }
.cel-rw { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.cel-rw li { padding: 6px 10px; border-radius: 10px; background: rgba(232, 193, 90, .14); border: 1px solid rgba(232, 193, 90, .4); font-size: 14px; }
.cel-rw:empty { display: none; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.chips.rw button small { display: block; font-size: 11px; opacity: .8; }
.chips.rw button[disabled] { opacity: .5; }
#study-ui { left: 50%; top: calc(64px + var(--sat)); transform: translateX(-50%); width: min(300px, calc(100% - 24px)); text-align: center; }
#study-ui .chips { justify-content: center; }
.study-time { margin: 2px 0; font-family: var(--serif); font-size: 44px; font-weight: 700; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.photo-img { display: block; width: 100%; border-radius: 12px; border: 1px solid var(--line); }
#photo-count { position: fixed; inset: 0; z-index: 31; display: grid; place-items: center; font-family: var(--serif); font-size: 120px; font-weight: 900; color: #fff4d6; text-shadow: 0 4px 30px rgba(0, 0, 0, .6); pointer-events: none; }
#flash { position: fixed; inset: 0; z-index: 32; background: #fff; animation: flash .5s ease-out forwards; pointer-events: none; }
@keyframes flash { to { opacity: 0; } }
body.photo-mode #hud > *:not(#labels), body.photo-mode .mark { visibility: hidden; }
.tag[data-tier="1"] { border-color: #c9ced6; }
.tag[data-tier="2"] { border-color: #e2735a; background: rgba(120, 26, 18, .82); }
.tag[data-tier="3"] { border: 1.5px solid #f6dc94; background: linear-gradient(180deg, rgba(150, 100, 20, .9), rgba(90, 56, 10, .9)); color: #fff4d6; box-shadow: 0 0 10px rgba(246, 220, 148, .5); }
.tag .ttl { color: var(--gold-2); margin-right: 3px; font-size: .92em; }
body.studying #guide { display: none; }
@media (max-width: 430px) { #dock span { font-size: 10.5px; letter-spacing: -.04em; } }
/* 走到廣場地點附近出現的大按鈕 */
#near-btn { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(236px + var(--sab)); z-index: 4; padding: 12px 26px; min-height: 52px; border-radius: 999px;
  border: 1.5px solid var(--gold); background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff6e0; font-size: 17px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45), 0 0 0 4px rgba(232, 193, 90, .18); animation: nearPulse 2s ease-in-out infinite; }
#near-btn.pop { animation: nearIn .35s var(--ease), nearPulse 2s .35s ease-in-out infinite; }
@keyframes nearIn { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@keyframes nearPulse { 50% { box-shadow: 0 6px 22px rgba(0, 0, 0, .45), 0 0 0 9px rgba(232, 193, 90, .1); } }
body.kneeling #near-btn { bottom: calc(300px + var(--sab)); }
body.chatting #near-btn { display: none; }
@media (orientation: landscape) and (max-height: 520px) { #near-btn { bottom: calc(96px + var(--sab)); } body.kneeling #near-btn { bottom: calc(150px + var(--sab)); } }
/* 全螢幕專注畫面 */
#focus-screen { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: calc(20px + var(--sat)) 20px calc(20px + var(--sab));
  background: radial-gradient(ellipse at 50% 30%, #3a1a14 0%, #1a0c08 70%); color: var(--ink); text-align: center; overflow-y: auto; touch-action: manipulation; }
.fs-top { margin: 0; color: var(--gold-2); font-family: var(--serif); font-weight: 700; letter-spacing: .08em; }
.fs-time { margin: 0; font-family: var(--serif); font-size: clamp(64px, 22vw, 120px); font-weight: 700; color: #f6dc94; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(232, 193, 90, .35); line-height: 1; }
.fs-cheer { margin: 0; font-family: var(--serif); font-size: 17px; color: #fff4d6; min-height: 1.4em; }
.fs-together { margin: 0; font-size: 14px; color: var(--muted); }
.fs-sound { width: min(420px, 100%); margin-top: 6px; }
.fs-lbl { margin: 0 0 6px; font-size: 13px; color: var(--gold-2); }
.fs-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.fs-chips button { padding: 6px 12px; min-height: 34px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ink); font-size: 13.5px; }
.fs-chips button[aria-pressed="true"] { background: var(--red); border-color: var(--gold); }
.fs-chips .grp { width: 100%; margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.fs-stats { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.fs-unlock { position: relative; overflow: hidden; margin-top: 10px; padding: 12px 26px; min-height: 48px; border-radius: 999px; border: 1px solid var(--gold); background: rgba(255, 255, 255, .06); color: #fff4d6; font-size: 15px; font-weight: 700; user-select: none; -webkit-user-select: none; }
.fs-unlock i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(232, 193, 90, .35); }
.fs-unlock span { position: relative; }
.fs-note { margin: 0; font-size: 12px; color: var(--muted); }
@media (orientation: landscape) and (max-height: 520px) { #focus-screen { gap: 6px; } .fs-time { font-size: 64px; } }
/* 排行榜 */
.seg { display: flex; gap: 4px; padding: 4px; margin: 6px 0; border-radius: 999px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; }
.seg button[aria-selected="true"] { background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff6e0; }
.seg.sm button { min-height: 32px; font-size: 13px; }
.rank-list { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 4px; min-height: 120px; }
.rank-list li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); }
.rank-list li.me { background: rgba(232, 193, 90, .18); border: 1px solid rgba(232, 193, 90, .5); }
.rank-list li b { text-align: center; font-size: 17px; }
.rank-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list li em { font-style: normal; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.rank-list li.empty { display: block; text-align: center; color: var(--muted); background: none; padding: 30px 0; }
.rank-me { margin: 6px 0 0; padding: 8px 12px; border-radius: 12px; background: rgba(200, 53, 43, .25); font-weight: 700; text-align: center; }
.rank-me:empty { display: none; }
.rank-open, .install-open { margin-top: 6px; }
/* 加到主畫面 */
.install-link { margin-top: 10px; padding: 8px 14px; border-radius: 999px; border: 1px dashed var(--gold); background: transparent; color: var(--gold-2); font-size: 13.5px; }
.install-steps { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 10px; }
.install-steps li { counter-increment: st; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; font-size: 15px; line-height: 1.5; }
.install-steps li::before { content: counter(st); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--red); border: 1px solid var(--gold); color: #fff; font-weight: 700; }
.install-steps .ico { width: 22px; height: 22px; vertical-align: -5px; margin: 0 2px; fill: none; stroke: var(--gold-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.install-steps .note { display: block; font-size: 12.5px; color: var(--muted); }
.install-steps.done li::before { content: "✓"; background: var(--jade); }

/* 打怪：畫面邊緣閃金光、魔王大血條 */
#hit-flash { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(255, 215, 106, .85); }
#hit-flash.on { animation: hitFlash .55s ease-out; }
#hit-flash.small.on { animation: hitFlashS .3s ease-out; }
@keyframes hitFlash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hitFlashS { 0% { opacity: .45; } 100% { opacity: 0; } }
#boss-bar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(166px + var(--sat)); z-index: 4; width: min(360px, calc(100% - 24px)); padding: 8px 12px 6px; border-radius: 14px;
  background: rgba(40, 14, 50, .88); border: 1.5px solid #b48ae8; text-align: center; pointer-events: none; animation: dlg .25s var(--ease); }
#boss-bar b { font-family: var(--serif); color: #f0d8ff; font-size: 15px; letter-spacing: .1em; }
.bb-track { position: relative; height: 16px; margin: 5px 0 3px; border-radius: 8px; background: rgba(0, 0, 0, .55); overflow: hidden; border: 1px solid rgba(255, 255, 255, .2); }
.bb-track i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #e8402a, #f08a3a); transition: width .3s var(--ease); }
.bb-track span { position: relative; font-size: 11.5px; font-weight: 700; color: #fff; line-height: 16px; text-shadow: 0 1px 2px #000; }
#boss-bar small { font-size: 11px; color: #c8b0e0; }
#boss-bar.hit { animation: bossHit .25s ease-out; }
@keyframes bossHit { 30% { transform: translateX(calc(-50% + 4px)); } 60% { transform: translateX(calc(-50% - 4px)); } }
body.guide-open #boss-bar { top: auto; bottom: calc(300px + var(--sab)); }
@media (orientation: landscape) and (max-height: 520px) { #boss-bar, body.guide-open #boss-bar { top: calc(58px + var(--sat)); bottom: auto; width: min(300px, 40%); } }

/* 自訂外觀：角色在上半部，選單在下半部可捲動 */
body.customizing .splash-top, body.customizing #splash .disclaimer, body.customizing #splash-install { display: none; }
body.customizing #splash { justify-content: flex-end; background: linear-gradient(rgba(20, 10, 6, 0) 40%, rgba(20, 10, 6, .82) 58%); }
body.customizing .splash-bottom { gap: 8px; }
body.customizing #customize { max-height: 34vh; overflow-y: auto; }
body.customizing .nick { display: none; }

/* 地圖 */
#map-btn { position: absolute; right: 12px; top: calc(64px + var(--sat)); width: 50px; height: 50px; border-radius: 50%; border: 1px solid var(--gold); z-index: 3;
  background: var(--glass-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; color: #fff4d6; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
#map-btn span { font-size: 20px; line-height: 1; } #map-btn small { font-size: 10px; }
body.chatting #map-btn, body.studying #map-btn, body.photo-mode #map-btn { display: none; }
.map-dlg canvas { display: block; width: 100%; aspect-ratio: 64 / 80; max-height: 52vh; margin: 8px auto 0; border-radius: 12px; border: 1px solid var(--line); touch-action: manipulation; }
.map-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.map-list button { padding: 6px 10px; min-height: 34px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ink); font-size: 13px; }
@media (orientation: landscape) and (max-height: 520px) { #map-btn { top: auto; bottom: calc(80px + var(--sab)); right: calc(80px + env(safe-area-inset-right, 0px)); } .map-dlg canvas { max-height: 40vh; width: auto; } }

.fs-mute { margin: 8px 0 0; font-size: 13.5px; color: #ffcf8a; }
.fs-mute button { margin-left: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--gold); background: var(--red); color: #fff6e0; font-size: 13px; }
