/* 願恩寺 — 日式佛堂 × 琳派：金箔地、墨、群青、緑青、朱，和紙質感 */
:root {
  --bg: #231b14;
  --ink: #1d1a17; /* 墨 */
  --ink-soft: #6a5f50;
  --gold: #c9a449;
  --gold-light: #e3c97f;
  --gold-deep: #8f6d24;
  --gunjo: #27408a; /* 群青 */
  --rokusho: #3b7a5c; /* 緑青 */
  --shu: #b8432c; /* 朱 */
  --washi: #f4eee2;
  --washi-deep: #e8dfca;
  --text: #f4eee2;
  --text-soft: rgba(244, 238, 226, 0.72);
  --glass: rgba(22, 18, 14, 0.62);
  --glass-line: rgba(227, 201, 127, 0.4);
  --radius: 999px;
  --gold-leaf: linear-gradient(135deg, #d9b860, #b8913a 50%, #d4b05a);
  --gate-iris: none;
  --washi-tex: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .2 0 0 0 .11 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --serif: "Noto Serif TC", "Songti TC", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: var(--sans); color: var(--text); -webkit-font-smoothing: antialiased; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#scene:active { cursor: grabbing; }

/* 和紙面 */
.washi { background: var(--washi-tex), var(--washi); }

/* ---------- 山門：金箔地 + 燕子花 ---------- */
.gate {
  /* 欄寬固定為畫面寬（minmax(0, 1fr)），卡片才不會被文字撐得比手機螢幕還寬而偏向一邊 */
  position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; z-index: 20; color: var(--ink);
  overflow-y: auto;
  background:
    var(--gate-iris) left bottom / auto 34vh repeat-x,
    radial-gradient(ellipse at 50% 35%, rgba(255, 244, 210, 0.35), rgba(80, 55, 10, 0.25) 80%),
    var(--gold-leaf) 0 0 / 260px;
  transition: opacity 0.8s ease;
}
.gate.fade { opacity: 0; pointer-events: none; }
.gate-card {
  position: relative; width: min(380px, 100%); text-align: center; padding: 34px 30px 26px;
  background: var(--washi-tex), var(--washi);
  border: 1px solid rgba(143, 109, 36, 0.45); box-shadow: 0 0 0 6px rgba(244, 238, 226, 0.35), 0 30px 60px -30px rgba(60, 40, 5, 0.7);
}
/* 手機：卡片左右留白縮小，說明文字略小，三行字各自排得下 */
@media (max-width: 420px) {
  .gate-card { padding: 30px 16px 22px; }
  .gate-desc { font-size: 14px; }
  .seal { top: 14px; right: 14px; }
}
.gate-card::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(201, 164, 73, 0.6); pointer-events: none; }
.seal {
  position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--shu); color: #fbe9d8; font-family: var(--serif); font-weight: 700; font-size: 13px; line-height: 1.05;
  border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(251, 233, 216, 0.6); transform: rotate(-4deg); writing-mode: horizontal-tb;
}
.gate h1 { font-family: var(--serif); font-weight: 700; font-size: 40px; letter-spacing: 0.45em; margin: 6px 0 4px 0.45em; color: var(--ink); }
.gate-status { font-size: 13px; color: var(--ink-soft); margin: 0 0 24px; letter-spacing: 0.15em; }
.gate-status::after { content: ""; display: block; width: 5px; height: 5px; margin: 20px auto 0; border-radius: 50%; background: var(--gold-deep); animation: breathe 1.6s ease-in-out infinite; }
.gate.ready .gate-status { display: none; }
@keyframes breathe { 50% { transform: scale(2.2); opacity: 0.4; } }
.gate-desc { font-family: var(--serif); line-height: 2; color: var(--ink); margin: 10px 0 22px; font-size: 15px; }
.field { display: block; text-align: left; font-size: 12px; color: var(--ink-soft); letter-spacing: 0.08em; }
.field-row { display: flex; gap: 8px; margin-top: 6px; }
.field input {
  flex: 1; min-width: 0; height: 46px; border-radius: 2px; border: 1px solid rgba(29, 26, 23, 0.22);
  background: rgba(255, 253, 247, 0.8); padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(201, 164, 73, 0.25); }
.dice { width: 46px; height: 46px; border-radius: 2px; border: 1px solid rgba(29, 26, 23, 0.22); background: rgba(255, 253, 247, 0.6); color: var(--ink-soft); display: grid; place-items: center; }
.dice svg { width: 20px; height: 20px; }
/* 身分：在家眾／出家眾 */
.kind-field { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
.kind-field legend { padding: 0; }
.kind-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.kind-opt { position: relative; cursor: pointer; }
.kind-opt input { position: absolute; opacity: 0; pointer-events: none; }
.kind-opt span {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 6px; border-radius: 2px;
  border: 1px solid rgba(29, 26, 23, 0.22); background: rgba(255, 253, 247, 0.6); color: var(--ink); transition: border-color 0.15s, background 0.15s;
}
.kind-opt b { font-family: var(--serif); font-size: 15px; letter-spacing: 0.2em; font-weight: 700; }
.kind-opt small { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.05em; }
.kind-opt input:checked + span { border-color: var(--gold-deep); background: rgba(227, 201, 127, 0.22); box-shadow: 0 0 0 3px rgba(201, 164, 73, 0.2); }
.kind-opt input:focus-visible + span { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
.btn-primary {
  width: 100%; margin-top: 18px; height: 50px; border: 1px solid var(--gold-deep); border-radius: 2px;
  background: var(--ink); color: var(--gold-light); font-size: 16px; letter-spacing: 0.35em; font-family: var(--serif);
  box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 4px rgba(227, 201, 127, 0.45); transition: transform 0.15s, background 0.2s;
}
.btn-primary:hover { background: #2a251f; }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.45; cursor: default; }
.btn-ghost {
  height: 50px; border: 1px solid rgba(29, 26, 23, 0.3); border-radius: 2px; background: transparent; color: var(--ink);
  font-family: var(--serif); letter-spacing: 0.2em; padding: 0 18px;
}
.gate-online { font-size: 12px; color: var(--ink-soft); margin: 14px 0 0; }
/* 「用外部瀏覽器開啟」：赭紅色、醒目 */
.ext-btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 50px; border-radius: 2px; background: #9a3b22; color: #fbefe2; font-family: var(--serif); font-size: 16px; letter-spacing: 0.25em; text-decoration: none; border: 1px solid #6e2412; box-shadow: 0 4px 14px -6px rgba(110, 36, 18, 0.7); }
.ext-btn[hidden] { display: none; }
/* App 內建瀏覽器的提醒 */
.browser-warn { margin: 6px 0 18px; padding: 14px 14px 12px; border: 1px solid var(--shu); background: rgba(184, 67, 44, 0.08); border-radius: 2px; text-align: center; }
.browser-warn b { display: block; font-family: var(--serif); font-size: 16px; color: var(--shu); letter-spacing: 0.08em; }
.browser-warn p { margin: 6px 0 12px; font-size: 13px; color: var(--ink); line-height: 1.6; }
.browser-warn .btn-ghost { width: 100%; height: 42px; margin-top: 8px; border: 1px solid rgba(29, 26, 23, 0.3); background: rgba(255, 253, 247, 0.7); color: var(--ink); font-size: 14px; letter-spacing: 0.2em; border-radius: 2px; font-family: var(--serif); }
.browser-warn small { display: block; margin-top: 8px; font-size: 11.5px; color: var(--ink-soft); line-height: 1.5; }
.gate-error { font-size: 13px; color: var(--shu); margin: 8px 0 0; min-height: 1em; }

/* ---------- 堂內介面 ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--glass-line);
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  color: var(--text); box-shadow: 0 6px 22px -10px rgba(0, 0, 0, 0.6);
}
.pill svg { width: 20px; height: 20px; color: var(--gold-light); }
.icon-btn { width: 44px; padding: 0; justify-content: center; }
.topbar {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.bar-left { display: flex; gap: 8px; min-width: 0; }
.room-btn b { font-family: var(--serif); font-size: 16px; letter-spacing: 0.2em; white-space: nowrap; color: var(--gold-light); }
.room-name { font-size: 12px; color: var(--text-soft); padding-left: 10px; border-left: 1px solid var(--glass-line); white-space: nowrap; }
.room-btn .chev { width: 16px; height: 16px; opacity: 0.7; }
.tools { gap: 2px; padding: 0 6px; }
.tools button { width: 38px; height: 38px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; }
.tools button:hover { background: rgba(227, 201, 127, 0.12); }
.tools svg { width: 19px; height: 19px; }
.online { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px 0 8px; font-size: 14px; }
.ic-off { display: none; }
.is-muted .ic-on { display: none; }
.is-muted .ic-off { display: block; }

/* 在堂人數是按鈕：點開名單 */
.tools .online { width: auto; border-radius: 19px; padding: 0 10px 0 8px; color: inherit; font: inherit; font-size: 14px; display: inline-flex; }

/* 聽念佛＋選佛號 */
.chant-box { position: absolute; top: calc(max(16px, env(safe-area-inset-top)) + 56px); right: 16px; display: flex; gap: 6px; align-items: flex-start; }
.chant-btn, .chant-pick { height: 36px; font-size: 13px; letter-spacing: 0.15em; font-family: var(--serif); }
.chant-pick { gap: 4px; padding: 0 10px 0 14px; }
.chant-pick svg { width: 14px; height: 14px; }
.chant-btn[aria-pressed="true"] { background: rgba(143, 109, 36, 0.75); border-color: var(--gold-light); }
.chant-menu {
  position: absolute; top: 42px; right: 0; width: min(300px, calc(100vw - 32px)); padding: 6px; border-radius: 4px;
  background: rgba(29, 26, 23, 0.9); border: 1px solid rgba(227, 201, 127, 0.45); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  max-height: calc(100vh - 200px); overflow-y: auto; overscroll-behavior: contain;
}
.chant-menu button {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; gap: 2px; padding: 9px 10px; border: 0; border-radius: 3px;
  background: none; color: var(--text); text-align: left; font-family: var(--serif); font-size: 13.5px;
}
.chant-menu button small { font-family: inherit; font-size: 11px; color: var(--text-soft); }
.chant-menu button:hover { background: rgba(227, 201, 127, 0.12); }
.chant-menu button[aria-checked="true"] { background: rgba(143, 109, 36, 0.45); color: var(--gold-light); }
.chant-menu p { margin: 2px 10px 6px; font-size: 11.5px; color: var(--text-soft); }

/* 在堂同修名單 */
.sheet h2 small { font-size: 13px; color: var(--ink-soft); letter-spacing: 0.05em; margin-left: 6px; }
.people-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.people-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: rgba(255, 253, 247, 0.7); border: 1px solid rgba(29, 26, 23, 0.1); border-radius: 2px; }
.people-list .badge { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #f6efe2; font-size: 13px; font-weight: 700; background: #6b6a5a; }
.people-list .badge.monastic { background: #8a4a1e; }
.people-list .me .badge { background: #4a3b2a; }
.people-list b { font-family: var(--serif); font-weight: 500; font-size: 15px; }
.people-list span.kind { margin-left: auto; font-size: 12px; color: var(--ink-soft); }

.toasts { position: absolute; top: calc(max(16px, env(safe-area-inset-top)) + 100px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: calc(100% - 32px); }
.toast {
  padding: 9px 20px; border-radius: 2px; font-size: 13px; letter-spacing: 0.05em; font-family: var(--serif);
  background: var(--washi-tex), rgba(244, 238, 226, 0.94); color: var(--ink);
  border-left: 3px solid var(--gold); box-shadow: 0 8px 22px -12px rgba(0, 0, 0, 0.6); animation: toast-in 0.35s ease both; max-width: 100%; text-align: center;
}
.toast.out { animation: toast-out 0.5s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

.chant-line {
  position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 100px); transform: translateX(-50%);
  display: flex; gap: 14px; font-family: var(--serif); font-size: 22px; letter-spacing: 0.05em; pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  padding: 6px 22px; border-radius: var(--radius); background: rgba(22, 18, 14, 0.5); border: 1px solid var(--glass-line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
/* 佛號音樂：設定裡的選單、左下角的 YouTube 播放器（依 YouTube 規定至少 200×200 可見） */
.chant-src {
  width: 100%; margin-top: 10px; height: 38px; border-radius: 2px; border: 1px solid rgba(29, 26, 23, 0.22);
  background: rgba(255, 253, 247, 0.8); color: var(--ink); font: inherit; font-size: 13px; padding: 0 8px;
}
.yt-card {
  position: absolute; left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: 50px; height: 50px; z-index: 5;
  background: #000; border: 1px solid rgba(227, 201, 127, 0.5); border-radius: 6px; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); pointer-events: auto;
}
.yt-card iframe, #yt-player { display: block; width: 50px; height: 50px; border: 0; }
@media (max-width: 520px) { .yt-card { left: 6px; bottom: calc(max(6px, env(safe-area-inset-bottom)) + 76px); } }
.chant-line span { color: rgba(244, 238, 226, 0.4); transition: color 0.25s, transform 0.25s; }
.chant-line span.on { color: var(--gold-light); transform: translateY(-2px); }

.dock {
  position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 2px; padding: 6px; border-radius: 30px; border: 1px solid var(--glass-line);
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.7);
}
.dock button {
  width: 76px; height: 62px; border: 0; background: none; border-radius: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; letter-spacing: 0.15em; font-family: var(--serif); transition: background 0.2s, opacity 0.2s;
}
.dock button:hover { background: rgba(227, 201, 127, 0.12); }
.dock button:disabled { opacity: 0.45; cursor: default; }
.dock svg { width: 24px; height: 24px; color: var(--gold-light); }

/* ---------- 念珠 ---------- */
.beads {
  position: fixed; inset: 0; z-index: 10; color: var(--ink);
  background: var(--washi-tex), radial-gradient(ellipse at 50% 45%, #f8f3e8, #e7dcc4 78%);
  display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none;
  animation: fade-in 0.35s ease both;
}
@keyframes fade-in { from { opacity: 0; } }
.beads .pill { background: rgba(255, 253, 247, 0.7); color: var(--ink); border-color: rgba(143, 109, 36, 0.35); box-shadow: 0 6px 18px -12px rgba(0, 0, 0, 0.35); }
.beads .pill svg { color: var(--ink); }
.back-btn { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; font-size: 14px; height: 40px; font-family: var(--serif); letter-spacing: 0.1em; }
.back-btn svg { width: 18px; height: 18px; }
.beads-mute { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; height: 40px; width: 40px; }
#beads-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#beads-canvas:active { cursor: grabbing; }
.beads-float { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.beads-float span {
  position: absolute; transform: translateY(-50%); font-family: var(--serif); font-size: 18px; letter-spacing: 0.25em;
  color: #6b3f1d; white-space: nowrap; animation: mantra-float 1.8s ease-out both;
}
@keyframes mantra-float {
  0% { opacity: 0; transform: translate(0, -30%); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(10px, -260%); }
}
.beads > .pill, .beads-count, .beads-mantra { z-index: 1; }
.beads-count { position: absolute; left: 24px; bottom: max(24px, env(safe-area-inset-bottom)); }
.beads-count .num { margin: 0; font-family: var(--serif); }
.beads-count b { font-size: 46px; font-weight: 500; }
.beads-count .num span { font-size: 14px; color: var(--ink-soft); margin-left: 6px; }
.beads-count p { margin: 2px 0; font-size: 13px; color: var(--ink-soft); }
.beads-count .hint { margin-top: 12px; font-size: 12px; line-height: 1.7; }
.beads-mantra {
  position: absolute; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); margin: 0; writing-mode: vertical-rl;
  font-family: var(--serif); letter-spacing: 0.5em; color: var(--ink); font-size: 16px;
  padding: 14px 8px; border-right: 2px solid var(--shu);
}

/* ---------- 對話框：和紙 + 金箔帶 ---------- */
.sheet {
  width: min(440px, calc(100% - 32px)); max-height: min(84vh, 720px); padding: 0 22px 20px; border: 0; border-radius: 4px;
  background: var(--washi-tex), var(--washi); color: var(--ink); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7); overflow: auto;
  border-top: 10px solid transparent; border-image: var(--gold-leaf) 30 0 0 0 / 10px 0 0 0 stretch;
}
.sheet::backdrop { background: rgba(20, 14, 8, 0.45); backdrop-filter: blur(2px); }
.sheet header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 16px 0 10px; margin-bottom: 4px; background: var(--washi-tex), var(--washi); border-bottom: 1px solid rgba(201, 164, 73, 0.5); }
.sheet h2 { font-family: var(--serif); font-size: 19px; margin: 0; letter-spacing: 0.12em; }
.x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(29, 26, 23, 0.07); font-size: 20px; line-height: 1; }
.muted { color: var(--ink-soft); font-size: 12.5px; margin: 2px 0 0; line-height: 1.6; }
.center { text-align: center; }
.server-list { margin: 16px 0; }
.server { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 2px; background: rgba(255, 253, 247, 0.7); border: 1px solid rgba(29, 26, 23, 0.1); }
.server.current { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.server b { font-family: var(--serif); }
.server span { font-size: 12.5px; color: var(--ink-soft); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.stats div { background: rgba(255, 253, 247, 0.6); border: 1px solid rgba(201, 164, 73, 0.3); padding: 12px 8px; text-align: center; }
.stats dt { font-size: 11.5px; color: var(--ink-soft); }
.stats dd { margin: 4px 0 0; font-family: var(--serif); font-size: 20px; font-variant-numeric: tabular-nums; }

.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; }
.set-row b { font-size: 14.5px; font-weight: 500; font-family: var(--serif); }
.set-row.head { border-bottom: 1px solid rgba(29, 26, 23, 0.08); margin-bottom: 8px; }
.set-card { background: rgba(255, 253, 247, 0.6); border: 1px solid rgba(201, 164, 73, 0.25); padding: 4px 14px 14px; margin-bottom: 10px; }
.set-card.off input[type="range"] { opacity: 0.4; }
input[type="range"] { width: 100%; accent-color: var(--gold-deep); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(29, 26, 23, 0.2); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch input:checked + i { background: var(--gold-deep); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--gold); outline-offset: 2px; }
details { border-top: 1px solid rgba(29, 26, 23, 0.08); padding: 12px 2px 0; margin-top: 8px; font-size: 13.5px; line-height: 1.75; }
summary { cursor: pointer; font-weight: 500; font-family: var(--serif); }
details ul { padding-left: 1.2em; }
kbd { font-family: inherit; font-size: 12px; padding: 1px 6px; border-radius: 3px; background: rgba(29, 26, 23, 0.08); }

/* ---------- 牌位 ---------- */
.sheet.wide { width: min(640px, calc(100% - 32px)); max-height: min(90vh, 840px); }
.kind-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.kind-tabs button {
  border: 1px solid rgba(29, 26, 23, 0.14); background: rgba(255, 253, 247, 0.6); border-radius: 2px; padding: 10px 12px;
  font-family: var(--serif); font-size: 16px; font-weight: 700; text-align: left; display: flex; flex-direction: column; gap: 2px;
}
.kind-tabs small { font-family: var(--sans); font-size: 11.5px; font-weight: 400; color: var(--ink-soft); }
.kind-tabs .red { color: #9b1b16; }
.kind-tabs .yellow { color: #8a5a10; }
.kind-tabs .red[aria-selected="true"] { background: #fbe9e6; border-color: #b8231d; box-shadow: inset 0 0 0 1px #b8231d; }
.kind-tabs .yellow[aria-selected="true"] { background: #fbf1d6; border-color: #c99a2a; box-shadow: inset 0 0 0 1px #c99a2a; }
.tablet-layout { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: start; }
.tablet-preview { width: 100%; aspect-ratio: 300 / 720; height: auto; filter: drop-shadow(0 10px 16px rgba(60, 30, 10, 0.3)); }
#tablet-form { display: flex; flex-direction: column; gap: 12px; }
#tablet-form .field input { width: 100%; margin-top: 6px; }
#tablet-form .btn-primary { margin-top: 4px; }
.my-tablets { margin-top: 16px; border-top: 1px solid rgba(29, 26, 23, 0.08); padding-top: 12px; }
.my-tablets h3 { font-size: 14px; margin: 0 0 8px; font-weight: 500; font-family: var(--serif); }
.my-tablets ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.my-tablets li { display: flex; align-items: center; gap: 10px; background: rgba(255, 253, 247, 0.6); padding: 8px 12px; font-size: 13.5px; }
.my-tablets li i { width: 10px; height: 22px; border-radius: 2px; flex: none; }
.my-tablets li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-tablets li button { border: 0; background: none; color: var(--ink-soft); font-size: 12.5px; text-decoration: underline; }
.my-tablets .empty { color: var(--ink-soft); font-size: 12.5px; background: none; padding: 0; }
.sheet.view { width: min(320px, calc(100% - 32px)); }
.sheet.view .tablet-preview { width: 62%; display: block; margin: 8px auto 0; }

/* ---------- 觀世音菩薩感應靈課 ---------- */
.lingke .yinguang {
  margin: 14px 0; padding: 14px 18px; font-family: var(--serif); font-size: 14.5px; line-height: 1.9;
  border-left: 3px solid var(--shu); background: rgba(255, 253, 247, 0.55);
}
.lingke .yinguang cite { display: block; font-style: normal; font-size: 12px; color: var(--ink-soft); margin-top: 4px; text-align: right; }
.lk-guide { margin: 0 0 14px; padding-left: 1.4em; font-size: 13.5px; line-height: 1.9; }
.lk-verse {
  font-family: var(--serif); text-align: center; line-height: 2.1; font-size: 15px; margin: 0 0 16px; padding: 14px 8px;
  border-top: 1px solid rgba(201, 164, 73, 0.6); border-bottom: 1px solid rgba(201, 164, 73, 0.6);
}
.lk-recite { margin: 16px 0 6px; text-align: center; }
.lk-times { display: inline-flex; border: 1px solid rgba(29, 26, 23, 0.2); margin-bottom: 12px; }
.lk-times button { border: 0; background: transparent; padding: 6px 14px; font-family: var(--serif); font-size: 13px; }
.lk-times button[aria-checked="true"] { background: var(--ink); color: var(--gold-light); }
.lk-name {
  display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0 auto; width: min(260px, 100%); padding: 16px 10px;
  font-family: var(--serif); font-size: 20px; letter-spacing: 0.3em; color: var(--ink);
  background: var(--gold-leaf) 0 0 / 160px; border: 1px solid var(--gold-deep); border-radius: 2px;
  box-shadow: 0 8px 20px -12px rgba(80, 55, 10, 0.7); user-select: none; -webkit-user-select: none;
}
.lk-name small { font-family: var(--sans); font-size: 12px; letter-spacing: 0.1em; color: #4a3712; }
.lk-name.pulse { animation: name-pulse 0.35s ease; }
@keyframes name-pulse { 40% { transform: scale(0.97); filter: brightness(1.12); } }
.lk-ask { text-align: center; font-family: var(--serif); font-size: 15px; margin: 18px 0 6px; color: var(--ink); }
.coins { display: flex; justify-content: center; gap: 14px; padding: 150px 0 18px; perspective: 700px; }
.coin-slot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.coin-slot > span { font-family: var(--serif); font-size: 12px; color: var(--ink-soft); }
.coin { position: relative; width: 58px; height: 58px; transform-style: preserve-3d; }
.coin .face {
  position: absolute; inset: 0; border-radius: 50%; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: radial-gradient(circle at 35% 30%, #f1d48a, #c9973f 45%, #8a5f20 85%, #6a4515);
  box-shadow: inset 0 0 0 3px rgba(106, 69, 21, 0.75), inset 0 0 0 6px rgba(241, 212, 138, 0.35), 0 4px 8px rgba(60, 35, 5, 0.35);
  display: grid; place-items: center;
}
.coin .face i { width: 14px; height: 14px; background: #3a2a18; box-shadow: inset 0 0 0 2px #8a5f20; }
.coin .face b { position: absolute; top: 5px; font-family: var(--serif); font-size: 15px; color: #3a1d0c; }
.coin .back { transform: rotateX(180deg); background: radial-gradient(circle at 35% 30%, #d9bb76, #a97c35 50%, #6e4a18); }
.lk-result-wrap { text-align: center; }
.lk-head { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 18px 0 8px; }
.lk-no { font-family: var(--serif); font-size: 14px; color: var(--ink-soft); letter-spacing: 0.15em; }
.lk-head h3 { margin: 0; font-family: var(--serif); font-size: 28px; letter-spacing: 0.25em; }
.lk-rank { font-family: var(--serif); font-size: 14px; padding: 3px 10px; letter-spacing: 0.2em; border: 1px solid currentColor; }
.lk-rank.good { color: var(--shu); }
.lk-rank.mid { color: var(--gold-deep); }
.lk-rank.bad { color: var(--ink); }
.lk-pattern { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; font-family: var(--serif); }
.lk-pattern span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: var(--ink-soft); border: 1px solid rgba(29, 26, 23, 0.2); }
.lk-pattern span.on { background: radial-gradient(circle at 35% 30%, #f1d48a, #c9973f 55%, #8a5f20); color: #3a1d0c; border-color: #8a5f20; }
.lk-poem {
  writing-mode: vertical-rl; display: flex; gap: 18px; margin: 0 auto 16px; padding: 18px 24px; height: 200px; width: fit-content;
  font-family: var(--serif); font-size: 24px; letter-spacing: 0.35em; line-height: 1.4;
  background: var(--gold-leaf) 0 0 / 180px; border: 1px solid var(--gold-deep); box-shadow: inset 0 0 0 4px rgba(244, 238, 226, 0.35);
}
.lk-poem p { margin: 0; }
.lk-explain { padding: 12px 16px; background: rgba(255, 253, 247, 0.6); border: 1px solid rgba(201, 164, 73, 0.3); font-family: var(--serif); font-size: 14.5px; line-height: 1.9; }
.lk-explain h4 { margin: 0 0 4px; font-size: 13px; color: var(--shu); letter-spacing: 0.3em; }
.lk-explain p { margin: 0; }
.lk-q { font-size: 13px; color: var(--ink-soft); margin: 12px 0 0; }
.lk-note { font-size: 12px; color: var(--ink-soft); margin: 12px 0 0; line-height: 1.7; }
.lk-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 16px; }
.lk-actions .btn-primary { margin-top: 0; }
/* 搭直升機前的問話 */
.heli-ask { padding-top: 22px; }
.heli-q { font-family: var(--serif); font-size: 24px; letter-spacing: 0.2em; text-align: center; margin: 6px 0 4px; }

@media (max-width: 560px) {
  .tablet-layout { grid-template-columns: 96px 1fr; gap: 14px; }
  .room-name { display: none; }
  .online { padding: 0 6px 0 4px; }
  .tools button { width: 34px; }
  .dock button { width: min(54px, calc((100vw - 32px) / 6)); height: 56px; letter-spacing: 0; font-size: 11.5px; }
  .chant-line { font-size: 18px; gap: 10px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 92px); }
  .beads-count b { font-size: 38px; }
  .coins { gap: 8px; padding-top: 130px; }
  .coin { width: 50px; height: 50px; }
  .lk-poem { font-size: 20px; height: 180px; gap: 12px; padding: 14px 18px; }
}

/* =========================================================
   早晚念佛共修（gongxiu.js）：字大、按鈕大，長輩在手機上一按就能進入
   ========================================================= */
.stats div:last-child:nth-child(odd) { grid-column: span 2; }
.gx-btn {
  height: 48px; padding: 0 22px; border-radius: 2px; border: 1px solid #6e2412; background: #9a3b22; color: #fbefe2;
  font-family: var(--serif); font-size: 17px; letter-spacing: 0.2em; box-shadow: 0 4px 14px -6px rgba(110, 36, 18, 0.7); cursor: pointer;
}
.gx-btn[hidden], .gx-leave[hidden] { display: none; }
.gx-gate { margin: 0 0 18px; padding: 14px 12px; border: 1px solid rgba(154, 59, 34, 0.45); background: rgba(154, 59, 34, 0.08); }
.gx-gate[hidden] { display: none; }
.gx-gate p { margin: 0; font-family: var(--serif); font-size: 16px; line-height: 1.6; color: var(--ink); }
/* 共修時段：「進入共修」與「入堂禮佛」左右並排 */
.enter-row { display: flex; gap: 10px; margin-top: 18px; }
.enter-row > button { flex: 1 1 0; min-width: 0; margin-top: 0; height: 54px; padding: 0 6px; letter-spacing: 0.15em; }
.gx-bar {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(max(16px, env(safe-area-inset-top)) + 108px);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 24px); padding: 8px 8px 8px 18px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 4px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text); font-family: var(--serif); font-size: 17px; letter-spacing: 0.06em;
}
.gx-bar[hidden] { display: none; }
.gx-bar #gx-bar-text { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.gx-bar .gx-btn { height: 44px; padding: 0 16px; flex: none; }
.gx-leave { flex: none; height: 40px; padding: 0 12px; border-radius: 2px; border: 1px solid var(--glass-line); background: transparent; color: var(--text-soft); font-family: var(--serif); font-size: 14px; letter-spacing: 0.1em; cursor: pointer; }
/* 法語、迴向偈、圓滿：畫面中上方的大字 */
.gx-text {
  position: fixed; z-index: 6; left: 50%; top: 30%; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); pointer-events: none;
  padding: 22px 24px; text-align: center; background: rgba(244, 238, 226, 0.9); color: var(--ink); border-radius: 4px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7); border-top: 6px solid transparent; border-image: var(--gold-leaf) 30 0 0 0 / 6px 0 0 0 stretch;
  font-family: var(--serif); animation: gx-in 0.8s ease both;
}
.gx-text[hidden] { display: none; }
.gx-text p { margin: 8px 0 0; font-size: 24px; line-height: 1.9; letter-spacing: 0.12em; }
.gx-text b { display: block; font-size: 26px; letter-spacing: 0.2em; }
.gx-text span { display: block; margin-top: 10px; font-size: 20px; }
.gx-text em { font-style: normal; color: #9a3b22; font-size: 28px; font-variant-numeric: tabular-nums; }
.gx-text small { display: block; font-size: 15px; color: var(--ink-soft); letter-spacing: 0.2em; }
.gx-text b + small, .gx-text span + small { margin-top: 10px; }
@keyframes gx-in { from { opacity: 0; transform: translate(-50%, 8px); } }
/* 隨眾念佛（分鐘）與行持選擇：底部中央 */
.gx-follow {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 88px);
  width: min(420px, calc(100% - 24px)); padding: 10px 10px 10px; text-align: center;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 4px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text); font-family: var(--serif);
}
.gx-follow[hidden] { display: none; }
.gx-follow p { margin: 0 0 8px; font-size: 17px; letter-spacing: 0.12em; }
.gx-follow b { color: var(--gold-light); font-size: 24px; font-variant-numeric: tabular-nums; }
.gx-walk-tip { display: block; margin: -2px 0 8px; font-size: 14px; color: var(--gold-light); letter-spacing: 0.08em; }
.gx-walk-tip[hidden] { display: none; }
.gx-practice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gx-practice button {
  height: 46px; border-radius: 2px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, 0.04); color: var(--text-soft);
  font-family: var(--serif); font-size: 16px; letter-spacing: 0.1em; cursor: pointer;
}
.gx-practice button[aria-pressed="true"] { background: #9a3b22; border-color: #6e2412; color: #fbefe2; }
/* 法語、迴向偈：每句一格的方陣，左右對稱 */
.gx-verse { display: grid; justify-content: center; gap: 6px 1.2em; margin-top: 10px; font-size: 24px; letter-spacing: 0.08em; line-height: 1.6; }
.gx-verse.four { grid-template-columns: repeat(4, auto); }
.gx-verse.five { grid-template-columns: repeat(2, auto); font-size: 26px; }
.gx-verse span { white-space: nowrap; }
.gx-schedule { margin: -10px 0 18px; font-family: var(--serif); font-size: 14px; letter-spacing: 0.12em; color: #9a3b22; }
/* 共修中：念珠、牌位、靈課先收起來；提示訊息往下讓出橫幅的位置 */
.gx-mode #btn-beads, .gx-mode #btn-tablet, .gx-mode #btn-lingke, .gx-mode .dock { display: none; }
.gx-mode .toasts { top: calc(max(16px, env(safe-area-inset-top)) + 172px); }
@media (max-width: 520px) {
  .gx-bar { flex-wrap: wrap; justify-content: center; text-align: center; padding: 8px 12px; font-size: 16px; }
  .gx-bar #gx-bar-text { flex-basis: 100%; }
  .gx-text p { font-size: 20px; }
  .gx-verse.four { grid-template-columns: repeat(2, auto); font-size: 22px; }
  .gx-verse.five { font-size: 21px; }
}
