/* 选佛谱网页版 · 藻井星河
 *
 * 规范见项目根目录「设计方向-藻井星河.md」。
 * 色彩锁定：青金夜为底，金箔是唯一强调色，朱砂只表达语义（恶、断线、错误）。
 * 字体：标题/位次名用宋体（古籍题材），正文用系统黑体。不加载网络字体。
 * 圆角：卡片 14，星签 12，按钮全圆。动效：UI 用强 ease-out，200 到 280ms。
 */
:root {
  --night-deep: #070b22;
  --night: #0b1235;
  --night-top: #111a48;
  --lapis: #24357a;
  --surface: rgba(30, 44, 104, 0.34);
  --line: rgba(160, 178, 230, 0.16);
  --azurite: #8fb4e6;
  --malachite: #6fb6a6;
  --gold: #e8c77d;
  --gold-deep: #c9a253;
  --gold-pale: #f4e4bb;
  --gold-paper: #fcf6e7; /* 星签底色：极浅的金笺 */
  --cinnabar: #d97a60;
  --ink: #e9ecf4;
  --muted: #9aa6c8;
  --faint: #808cb5;

  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --z-sky-ui: 4;
  --z-label: 5;
  --z-prompt: 50;
  --z-bloom: 80;
  --z-modal: 90;
  --z-toast: 100;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--night-deep) linear-gradient(180deg, var(--night-top) 0%, var(--night) 38%, var(--night-deep) 100%) fixed;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.gold { color: var(--gold); }
.warn { color: var(--cinnabar); }
.dim { color: var(--muted); }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.screen { animation: fade .28s var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* 只有真正「浮起来」的东西才用卡片：联机状态栏、弹窗 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
}
.section-title { font-family: var(--serif); font-size: 16px; font-weight: 600; letter-spacing: 1px; color: var(--ink); margin: 0 0 8px; }

/* ===== 首页 ===== */
.hero { position: relative; margin: 0 -16px; height: min(62vh, 520px); height: min(62dvh, 520px); overflow: hidden; }
#menuSky { position: absolute; inset: 0; display: block; }
.brand {
  position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; pointer-events: none;
}
.brand h1 {
  font-family: var(--serif); font-weight: 600; font-size: 44px; letter-spacing: 0.32em; text-indent: 0.32em;
  margin: 0; color: var(--gold-pale);
  text-shadow: 0 0 22px rgba(232, 199, 125, 0.35);
}
.subtitle { margin: 10px 0 0; font-size: 14px; letter-spacing: 0.2em; color: var(--muted); }
.menu-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1 1 auto; min-width: 0; letter-spacing: 0.08em; text-transform: uppercase; }
.join-row input::placeholder { text-transform: none; letter-spacing: 0; }
.join-row .btn { width: auto; flex: 0 0 auto; padding-left: 28px; padding-right: 28px; }
input {
  width: 100%; min-height: 48px; padding: 12px 16px;
  background: rgba(7, 11, 34, 0.6); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  font: 15px var(--sans); outline: none;
  transition: border-color .2s var(--ease-out);
}
input::placeholder { color: var(--faint); }
input:focus { border-color: var(--gold); }
.trial-note { margin: 18px 4px 0; font-size: 13px; line-height: 1.7; color: var(--gold-pale); text-wrap: pretty; }
[hidden] { display: none !important; }
.disclaimer { font-size: 12px; line-height: 1.8; color: var(--faint); margin: 22px 4px 0; text-wrap: pretty; }
.link {
  display: block; margin: 14px auto 0; padding: 10px 14px; min-height: 44px;
  background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(154, 166, 200, 0.4);
}
.link:hover { color: var(--ink); }

/* ===== 按钮 ===== */
.btn {
  display: block; width: 100%; min-height: 50px; padding: 14px 18px;
  border-radius: 999px; border: 1px solid transparent;
  font: 600 16px var(--sans); letter-spacing: 0.12em; cursor: pointer;
  transition: transform .16s var(--ease-out), background-color .2s var(--ease-out), opacity .2s var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--gold); color: #2a1e08; }
.btn.primary:hover { background: #efd291; }
.btn.secondary { background: transparent; color: var(--gold); border-color: rgba(232, 199, 125, 0.55); }
.btn.secondary:hover { background: rgba(232, 199, 125, 0.08); }
.btn:disabled { cursor: not-allowed; }
.btn-ghost {
  min-height: 44px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--line); font-size: 14px;
}
.btn-ghost:hover { color: var(--ink); border-color: rgba(160, 178, 230, 0.35); }

/* ===== 联机状态栏 ===== */
.mp-bar { margin-top: 14px; }
.mp-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.mp-conn { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.mp-conn.on { color: var(--malachite); background: rgba(111, 182, 166, 0.12); }
.mp-conn.off { color: var(--cinnabar); background: rgba(217, 122, 96, 0.12); }
.mp-turn { margin-top: 8px; font-size: 14px; color: var(--muted); }
.mp-turn.me { color: var(--gold); font-weight: 600; }
.mp-turn .gturn { color: var(--ink); }
.mp-turn.me .gturn { color: var(--gold); }
.mp-feed { margin-top: 8px; max-height: 128px; overflow-y: auto; font-size: 12px; }
.feed-item { display: flex; gap: 8px; padding: 3px 0; align-items: baseline; }
.feed-name { color: var(--muted); flex-shrink: 0; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-combo { font-weight: 600; flex-shrink: 0; }
.feed-text { color: var(--faint); }
.mp-reconnect { margin: 10px 0 0; font-size: 13px; text-align: center; }

/* 轮到你：落在拇指区，靠近掷骰按钮 */
.turn-prompt {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: var(--z-prompt);
  transform: translateX(-50%);
  background: var(--gold); color: #2a1e08;
  padding: 12px 22px; border-radius: 999px; font-size: 15px; font-weight: 600; letter-spacing: 0.06em;
  white-space: nowrap; box-shadow: 0 6px 18px rgba(7, 11, 34, 0.6);
  animation: rise .26s var(--ease-out);
}
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ===== 星河 ===== */
.sky { position: relative; margin: 12px -16px 0; touch-action: none; overflow: hidden; }
#board { display: block; touch-action: none; }
.sky-head {
  position: absolute; left: 16px; right: 16px; top: 12px; z-index: var(--z-sky-ui);
  display: flex; justify-content: flex-end; align-items: center; pointer-events: none;
}
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.lg { display: flex; align-items: center; gap: 5px; }
.lg-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.lg-current { background: #eef2fb; box-shadow: 0 0 6px 1px rgba(233, 236, 244, 0.8); }
.lg-visited { background: var(--gold); }
.lg-goal { background: var(--gold-pale); box-shadow: 0 0 7px 2px rgba(232, 199, 125, 0.7); }
.sky-tools { position: absolute; right: 14px; bottom: 14px; z-index: var(--z-sky-ui); display: flex; gap: 8px; }
.tool {
  min-height: 36px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: rgba(7, 11, 34, 0.55); color: var(--gold-pale); border: 1px solid rgba(232, 199, 125, 0.28);
  font-size: 13px; letter-spacing: 0.08em;
  transition: background-color .2s var(--ease-out), transform .16s var(--ease-out);
}
.tool:hover { background: rgba(36, 53, 122, 0.7); }
.tool:active { transform: scale(0.96); }
.tool::after { content: ''; position: absolute; inset: -4px; } /* 触控区补足 44px */
.tool { position: relative; }
.sky-hint { font-size: 12px; line-height: 1.7; color: var(--faint); margin: 10px 0 0; text-wrap: pretty; }

/* ===== 立体骰子层 ===== */
.dice-layer { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; }

/* ===== 手势掷骰：摄像头小窗 ===== */
/* 小窗放在左上角（标题下方），像一面小镜子；下半部分留给骰子 */
.hand-panel { position: absolute; left: 14px; top: 44px; z-index: var(--z-sky-ui); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; }
.hand-cam {
  position: relative; width: 104px; height: 78px; border-radius: 12px; overflow: hidden; flex: 0 0 auto;
  background: rgba(7, 11, 34, 0.8); box-shadow: inset 0 0 0 1px rgba(232, 199, 125, 0.35), 0 6px 16px rgba(2, 4, 16, 0.5);
}
.hand-cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: 0.55; filter: saturate(0.6); }
.hand-cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hand-status {
  max-width: 210px; padding: 6px 11px; border-radius: 999px; font-size: 12px; line-height: 1.4;
  color: var(--gold-pale); background: rgba(7, 11, 34, 0.72); box-shadow: inset 0 0 0 1px rgba(232, 199, 125, 0.25);
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.hand-status:empty { display: none; }
.hand-status.is-grab { background: var(--gold); color: #2a1e08; box-shadow: none; }
.hand-status.is-blocked { color: #f0b9a8; box-shadow: inset 0 0 0 1px rgba(217, 122, 96, 0.4); }
.hand-btn { min-width: 160px; }
.hand-btn[aria-pressed="true"] { color: var(--gold); border-color: rgba(232, 199, 125, 0.55); }
.hand-tip { margin: 2px 8px 0; font-size: 12px; line-height: 1.7; color: var(--faint); text-wrap: pretty; }

/* ===== 星签：半透明磨砂玻璃（带一点金调） =====
 * 玻璃里垫一层薄深色并压暗背后的星河：飞到银心等亮区时，浅色字依然清楚 */
.star-label {
  position: absolute; left: 0; top: 0; z-index: var(--z-label);
  width: min(300px, calc(100% - 24px)); max-height: 46%; overflow-y: auto; /* 不压住右下角的视角按钮，长释义在签内滚动 */
  padding: 13px 16px 14px; border-radius: 14px; cursor: pointer;
  color: #f3eee2;
  background:
    linear-gradient(155deg, rgba(255, 238, 200, 0.18) 0%, rgba(232, 199, 125, 0.07) 60%, rgba(232, 199, 125, 0.04) 100%),
    rgba(12, 16, 40, 0.42);
  -webkit-backdrop-filter: blur(16px) saturate(1.25) brightness(0.82);
  backdrop-filter: blur(16px) saturate(1.25) brightness(0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 238, 200, 0.28), inset 0 1px 0 rgba(255, 246, 222, 0.35), 0 12px 30px rgba(2, 4, 16, 0.45);
  -webkit-overflow-scrolling: touch; will-change: transform;
}
.star-label::before {
  content: ''; position: absolute; top: -6px; left: var(--arrow-x, 50%);
  width: 11px; height: 11px; margin-left: -5.5px; transform: rotate(45deg);
  background: rgba(46, 46, 62, 0.75);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: inset 1px 1px 0 rgba(255, 238, 200, 0.3);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .star-label { background: linear-gradient(155deg, rgba(255, 238, 200, 0.12), rgba(232, 199, 125, 0.04)), rgba(16, 22, 52, 0.9); }
  .star-label::before { background: rgba(30, 36, 66, 0.95); }
}
.star-label.sl-in { animation: slIn .28s var(--ease-out) both; }
@keyframes slIn { from { opacity: 0; translate: 0 6px; scale: 0.97; } to { opacity: 1; translate: 0 0; scale: 1; } }
.sl-note { font-size: 12px; color: var(--gold); margin-bottom: 3px; }
.sl-name { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: 0.08em; color: #fbf1d8; line-height: 1.3; text-shadow: 0 1px 8px rgba(2, 4, 16, 0.5); }
.sl-door { font-size: 12px; color: #d9c08a; margin-top: 2px; }
.sl-teach { font-size: 14px; line-height: 1.72; color: #e6e8f0; margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(255, 238, 200, 0.2); text-wrap: pretty; }

/* ===== 当前位次 ===== */
.current { padding: 22px 2px 4px; }
.cur-name { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: 0.08em; color: var(--gold); line-height: 1.25; }
.cur-name.dim { color: var(--muted); font-size: 20px; }
.cur-door { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cur-teach { font-size: 15px; line-height: 1.8; margin-top: 10px; color: #cdd4e6; text-wrap: pretty; }
.cur-teach.dim { color: var(--muted); }
.teach-btn { margin-top: 12px; }

/* ===== 掷骰 ===== */
.throw { text-align: center; margin-top: 22px; }
.dice-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.dice {
  width: 68px; height: 68px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font: 600 36px var(--serif);
  background: rgba(7, 11, 34, 0.55); border: 1.5px solid var(--line);
  transition: border-color .2s var(--ease-out);
}
.dice span:empty::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); opacity: 0.5; display: block; }
.combo-line { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.combo-line .gold { font-family: var(--serif); }
.result-line { font-size: 15px; color: #cdd4e6; min-height: 24px; margin: 8px 0 0; }
.btn-row { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 14px; }
.roll-hint { margin: 4px 0 0; font-family: var(--serif); font-size: 15px; letter-spacing: 0.24em; text-indent: 0.24em; color: var(--gold-pale); }
.roll-btn { max-width: 300px; }
.btn.primary.waiting, .btn.primary.waiting:hover { background: rgba(36, 53, 122, 0.55); color: var(--muted); }

/* ===== 行棋记录 ===== */
.log { margin-top: 26px; }
.log-item { display: flex; gap: 10px; padding: 7px 0; font-size: 13px; align-items: baseline; border-bottom: 1px solid rgba(160, 178, 230, 0.08); }
.log-no { flex: 0 0 22px; text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.log-combo { display: none; } /* 记录正文已含【轮相】，不再重复一列 */
.log-text { color: var(--muted); }

.footer { text-align: center; margin-top: 26px; font-size: 11px; line-height: 1.7; color: var(--faint); }

/* ===== 金莲浮层 ===== */
.bloom-mask {
  position: fixed; inset: 0; z-index: var(--z-bloom); background: rgba(5, 8, 26, 0.96);
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto;
}
#bloomCanvas { position: fixed; inset: 0; width: 100%; height: 100%; }
/* 莲台底座在画面 40% 高度处（bloomRender.js cy = h*0.40），文字从底座下方开始 */
.bloom-sign {
  position: relative; z-index: 2; max-width: 360px; margin: calc(40vh + 18px) 24px 32px;
  text-align: center; opacity: 0; transform: translateY(12px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
}
.bloom-sign.sign-in { opacity: 1; transform: translateY(0); }
.sign-label { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--gold-pale); letter-spacing: 0.12em; }
.sign-node { font-size: 13px; color: var(--muted); margin-top: 6px; }
.sign-teach { font-size: 14px; line-height: 1.8; color: #cdd4e6; margin-top: 14px; text-wrap: pretty; }
.sign-verse { font-family: var(--serif); font-size: 18px; line-height: 2.1; color: var(--gold); margin-top: 16px; letter-spacing: 0.08em; }
.sign-verse .vl { display: block; }
/* 偈语逐字浮现：先是一团亮金、带模糊，落定后变清晰；全部显完后，一道柔光沿字依次流过（循环） */
.vc { display: inline-block; opacity: 0; }
.bloom-sign.sign-in .vc {
  animation: vc-in 1.1s var(--ease-out) forwards, vc-glow 4.2s ease-in-out infinite;
  animation-delay: calc(0.5s + var(--i) * 0.12s), calc(0.5s + 20 * 0.12s + 1.2s + var(--i) * 0.09s);
}
@keyframes vc-in {
  0%   { opacity: 0; transform: translateY(8px) scale(1.25); filter: blur(6px); color: #fff6dc; text-shadow: 0 0 18px rgba(255, 226, 150, 0.95); }
  55%  { opacity: 1; filter: blur(0); color: #fff1c8; text-shadow: 0 0 14px rgba(255, 220, 140, 0.8); }
  100% { opacity: 1; transform: none; filter: none; color: var(--gold); text-shadow: 0 0 6px rgba(232, 199, 125, 0.25); }
}
@keyframes vc-glow {
  0%, 70%, 100% { color: var(--gold); text-shadow: 0 0 6px rgba(232, 199, 125, 0.25); }
  82% { color: #fff4d2; text-shadow: 0 0 14px rgba(255, 224, 150, 0.85); }
}
.sign-author { font-size: 12px; color: var(--muted); margin-top: 6px; letter-spacing: 0.2em; }
.bloom-sign.sign-in .sign-author { opacity: 0; animation: fade-up .8s var(--ease-out) forwards; animation-delay: calc(0.5s + var(--i) * 0.12s); }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sign-hint { font-size: 12px; color: var(--faint); margin-top: 18px; }
.sign-btn { max-width: 220px; margin: 18px auto 0; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(5, 8, 26, 0.8);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .2s var(--ease-out);
}
.modal-box {
  width: 100%; max-width: 420px; max-height: 80vh; overflow-y: auto; padding: 22px 20px 20px;
  background: #0f1840; border: 1px solid var(--line); border-radius: 14px;
}
.modal-title { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: 0.06em; color: var(--gold); margin-bottom: 4px; }
.modal-door { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.modal-body { font-size: 14px; line-height: 1.9; color: #cdd4e6; white-space: pre-line; margin-bottom: 18px; text-wrap: pretty; }

/* ===== 轻提示 ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: var(--z-toast);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  max-width: 86%; padding: 10px 18px; border-radius: 999px; text-align: center;
  background: #0f1840; border: 1px solid var(--line); color: var(--ink); font-size: 14px;
  transition: opacity .22s var(--ease-out), transform .22s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .screen, .modal, .turn-prompt { animation: none; }
  .star-label.sl-in { animation: fade .2s linear both; }
  .bloom-sign { transform: none; }
  .bloom-sign.sign-in .vc, .bloom-sign.sign-in .sign-author { animation: none; opacity: 1; }
}
