/* 清缘堂 —— 界面层。
 * 原则：UI 只占四角，中间全部留给场景；所有面板都是半透明深色 + 一根金色细线。 */

:root {
  --ink: #0d0b09;
  --ink2: #17130f;
  --gold: #C9A24A;
  --gold-l: #E3C36A;
  --paper: #F2E7CE;
  --dim: #A79C8C;
  --dim2: #8D8073;
  --line: rgba(201, 162, 74, 0.22);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

/* 电影感暗角：把注意力收到中间 */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 34%, rgba(6,5,4,0.42) 78%, rgba(6,5,4,0.78) 100%);
}

/* ---------------- 开场 ---------------- */
.boot {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: #0d0b09;
  transition: opacity .6s ease;
}
.boot.hide { opacity: 0; pointer-events: none; }
.boot-mark { font-size: 30px; color: var(--gold); animation: spin 9s linear infinite; }
.boot p { font-size: 13px; letter-spacing: .32em; color: var(--dim2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- HUD ---------------- */
.hud {
  position: fixed; inset: 0; z-index: 10;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom));
}
.hud > * { pointer-events: auto; }

.hud-top {
  display: flex; align-items: flex-start; justify-content: flex-start; gap: 11px;
}
/* 返回首页。放在"清缘堂"左边一个小箭头，不抢画面，
   但必须有 —— 从首页横幅进来的人如果找不到出口，会觉得被关在这里。 */
.back-home {
  flex: 0 0 auto;
  width: 34px; height: 34px; margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(13,11,9,.5);
  border: 1px solid var(--line);
  color: var(--dim);
  backdrop-filter: blur(8px);
  transition: .18s;
}
.back-home:hover { color: var(--gold-l); border-color: rgba(201,162,74,.55); background: rgba(23,19,15,.75); }
.back-home svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.room { display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; }
.room-name {
  font-size: 15px; letter-spacing: .34em; color: var(--paper);
  text-shadow: 0 2px 14px rgba(0,0,0,.9);
}
.room-sub {
  font-size: 11px; letter-spacing: .16em; color: var(--dim2);
  text-shadow: 0 2px 10px rgba(0,0,0,.9);
}

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(13,11,9,.55);
  border: 1px solid var(--line);
  color: var(--gold);
  font-size: 15px; line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: .18s;
}
.icon-btn:hover { border-color: rgba(201,162,74,.55); background: rgba(23,19,15,.75); }

.status {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  font-size: 12px; letter-spacing: .2em; color: var(--dim2);
  opacity: 0; transition: opacity .3s;
  text-shadow: 0 2px 10px rgba(0,0,0,.9);
  white-space: nowrap;
}
.status:not(:empty) { opacity: .9; }

/* 底部四件事 */
.dock {
  align-self: center;
  display: flex; gap: 6px;
  padding: 7px 10px;
  background: rgba(11, 9, 7, .62);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.04);
}
.act {
  position: relative;
  width: 68px; padding: 9px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; border: 0; border-radius: 16px;
  color: var(--dim);
  cursor: pointer;
  transition: .16s;
}
.act:hover, .act:focus-visible { background: rgba(201,162,74,.10); color: var(--gold-l); }
.act:active { transform: scale(.96); }
.act svg {
  width: 25px; height: 25px;
  fill: none; stroke: currentColor; stroke-width: 1.3;
  stroke-linecap: round; stroke-linejoin: round;
}
.act span { font-size: 11px; letter-spacing: .16em; }
.act .badge {
  position: absolute; top: 5px; right: 9px;
  min-width: 15px; height: 15px; padding: 0 4px;
  font-size: 9px; font-style: normal; line-height: 15px; text-align: center;
  color: var(--ink); background: var(--gold);
  border-radius: 8px;
  opacity: 0; transform: scale(.8); transition: .2s;
}
.act .badge.on { opacity: 1; transform: scale(1); }

.bottom {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
}

.fineprint {
  font-size: 9.5px; letter-spacing: .18em; color: rgba(141,128,115,.62);
  white-space: nowrap; pointer-events: none;
  text-shadow: 0 1px 8px rgba(0,0,0,.9);
}

.toast {
  position: absolute; left: 50%; bottom: 108px; transform: translate(-50%, 8px);
  padding: 8px 18px;
  font-size: 12px; letter-spacing: .12em; color: var(--paper);
  background: rgba(13,11,9,.82);
  border: 1px solid var(--line);
  border-radius: 100px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 入殿卡 ---------------- */
.intro {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(30,24,17,.55), rgba(6,5,4,.93) 72%);
  backdrop-filter: blur(2px);
  transition: opacity .7s ease;
  padding: 24px;
}
.intro.hide { opacity: 0; pointer-events: none; }

.intro-card {
  position: relative;
  width: min(360px, 100%);
  padding: 44px 30px 30px;
  text-align: center;
  background: linear-gradient(180deg, rgba(20,16,12,.86), rgba(12,10,8,.92));
  border: 1px solid rgba(201,162,74,.30);
  border-radius: 3px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7), inset 0 0 60px rgba(201,162,74,.05);
}
/* 四角金线：老式书封的做法 */
.intro-card::before, .intro-card::after {
  content: ''; position: absolute; width: 22px; height: 22px;
  border: 1px solid rgba(201,162,74,.5);
}
.intro-card::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.intro-card::after { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.intro-mark { font-size: 20px; color: var(--gold); margin-bottom: 16px; }
.intro-card h1 {
  font-size: 27px; font-weight: 400; letter-spacing: .34em; text-indent: .34em;
  color: var(--paper); margin-bottom: 14px;
}
.intro-line { font-size: 13px; letter-spacing: .14em; color: var(--dim); margin-bottom: 26px; }
.intro-name { font-size: 12px; letter-spacing: .1em; color: var(--dim2); margin-bottom: 26px; }
.intro-name b { color: var(--gold-l); font-weight: 400; }

#enterBtn {
  width: 100%; padding: 14px 0;
  font-family: var(--serif); font-size: 14px; letter-spacing: .34em; text-indent: .34em;
  color: #14100c;
  background: linear-gradient(135deg, #D9B45E, #B08A34);
  border: 0; border-radius: 2px;
  cursor: pointer;
  transition: .2s;
}
#enterBtn:hover { filter: brightness(1.08); }
#enterBtn:active { transform: translateY(1px); }

.intro-tip { margin-top: 18px; font-size: 10.5px; letter-spacing: .1em; color: rgba(141,128,115,.75); line-height: 1.9; }

/* ---------------- 念珠 ---------------- */
.beads {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,5,4,.72);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.beads.show { opacity: 1; pointer-events: auto; }

.beads-panel {
  position: relative;
  width: min(340px, 88vw);
  padding: 18px 18px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(22,18,13,.9), rgba(12,10,8,.94));
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0,0,0,.7);
}
.beads-svg { width: 100%; height: auto; display: block; touch-action: none; cursor: default; }
.beads-count {
  margin-top: -6px;
  font-size: 20px; letter-spacing: .12em; color: var(--gold-l);
  font-variant-numeric: tabular-nums;
}
.beads-tip { margin-top: 6px; font-size: 11px; letter-spacing: .14em; color: var(--dim2); }
.beads-close {
  margin-top: 16px; padding: 9px 26px;
  font-family: var(--serif); font-size: 12px; letter-spacing: .24em; text-indent: .24em;
  color: var(--dim);
  background: none; border: 1px solid var(--line); border-radius: 2px;
  cursor: pointer;
}
.beads-close:hover { color: var(--gold-l); border-color: rgba(201,162,74,.5); }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 560px) {
  .hud { padding: max(14px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom)); }
  .room-name { font-size: 13px; }
  .room-sub { font-size: 10px; }
  .dock { gap: 2px; padding: 6px 6px; border-radius: 20px; }
  .act { width: 62px; padding: 8px 0 6px; }
  .act svg { width: 23px; height: 23px; }
  .act span { font-size: 10px; letter-spacing: .1em; }
  .toast { bottom: 96px; font-size: 11px; }
  .fineprint { font-size: 9px; letter-spacing: .12em; }
  .intro-card { padding: 36px 24px 26px; }
  .intro-card h1 { font-size: 24px; }
}

/* 尊重系统的"减少动画"设置 */
@media (prefers-reduced-motion: reduce) {
  .boot-mark { animation: none; }
  * { transition-duration: .01ms !important; }
}
