:root {
  --background: #faf8f3;
  --foreground: #363a31;
  --primary: #b03a2e;
  --gold: #a17c49;
  --border: #e4ded2;
  --ink: #373c32;
  --serif: "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: var(--sans); background: #101418; }
.hidden { display: none !important; }

/* 纸纹质感面板：径向光晕 + 点阵噪点（对齐参考站技巧） */
.panel {
  position: absolute; padding: 10px 14px; border-radius: 14px;
  background:
    radial-gradient(ellipse at 50% 0, #fdfbf6f0, #f4efe3e6),
    radial-gradient(#aaa88e33 .8px, transparent .8px);
  background-size: auto, 6px 6px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px #0000002b;
  color: var(--foreground); z-index: 10;
}
.panel-tl { top: 14px; left: 14px; min-width: 180px; max-width: 46vw; }
.panel-tr { top: 14px; right: 14px; display: flex; align-items: center; gap: 10px; }
.panel-title { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: 2px; }
.online { font-size: 13px; color: var(--gold); font-weight: 600; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--background); color: var(--primary); font-size: 16px; cursor: pointer;
}
.icon-btn.on { background: var(--primary); color: #fff; }

/* 进出信息流 */
.feed { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.feed-item { font-size: 12px; color: #6b7060; animation: feedIn .3s ease; }
.feed-item.out { opacity: 0; transition: opacity .6s; }
@keyframes feedIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }

/* 底部动作栏 */
.action-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 10px; padding: 8px 14px; border-radius: 999px; z-index: 10;
  background: radial-gradient(ellipse at 50% 0, #fdfbf6f5, #f0e9dbec);
  border: 1px solid var(--border); box-shadow: 0 6px 20px #00000038;
}
.action-btn {
  min-width: 74px; padding: 8px 12px; border-radius: 999px; border: none; cursor: pointer;
  background: transparent; color: var(--ink); font-size: 15px; font-family: var(--serif);
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: background .2s;
}
.action-btn .ico { font-size: 18px; }
.action-btn:hover { background: #b03a2e14; }
.action-btn.hot { background: var(--primary); color: #fff; }
.action-btn.active { background: var(--gold); color: #fff; }
.action-btn:disabled { opacity: .4; cursor: default; }

/* 蒲团可用提示（动作栏上方胶囊） */
.seat-hint {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 10; padding: 7px 18px; border-radius: 999px;
  background: rgba(54, 58, 49, 0.78); color: #f3ead6;
  font-size: 14px; font-family: var(--serif); letter-spacing: 1px;
  border: 1px solid #c9a25a66; box-shadow: 0 4px 14px #0003;
  white-space: nowrap; pointer-events: none;
}
/* 互动点提示：蒲团提示上方错开，避免重叠 */
.interact-hint { bottom: 138px; background: rgba(161, 124, 73, 0.88); }

/* ---- P1 抽签结果签纸 ---- */
.oracle-modal {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center;
  justify-content: center; background: rgba(16, 20, 24, 0.45);
}
.oracle-card {
  width: min(340px, 84vw); padding: 34px 28px; text-align: center; border-radius: 18px;
  background:
    radial-gradient(ellipse at 50% 0, #fdfbf6fa, #f2ecdfF2),
    radial-gradient(#aaa88e33 .8px, transparent .8px);
  background-size: auto, 6px 6px;
  border: 1px solid var(--gold); box-shadow: 0 18px 50px #00000073;
  animation: feedIn .3s ease;
}
.oracle-level { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--primary); letter-spacing: 3px; }
.oracle-text { font-family: var(--serif); font-size: 20px; color: var(--ink); margin: 16px 0 10px; letter-spacing: 2px; }
.oracle-tip { font-size: 13px; color: #8a6a4a; margin-bottom: 20px; }
.oracle-close {
  padding: 9px 34px; border: none; border-radius: 999px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 15px; font-family: var(--serif); letter-spacing: 2px;
}

/* ---- P1 许愿墙面板 ---- */
.wish-panel {
  position: absolute; right: 14px; bottom: 100px; width: min(320px, 86vw); max-height: 60vh;
  z-index: 30; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0, #fdfbf6fa, #f4efe3f0),
    radial-gradient(#aaa88e33 .8px, transparent .8px);
  background-size: auto, 6px 6px;
  border: 1px solid var(--border); box-shadow: 0 10px 30px #0000004d;
}
.wish-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.wish-title { font-family: var(--serif); font-size: 16px; font-weight: 700; letter-spacing: 2px; color: var(--primary); }
.wish-close { border: none; background: transparent; font-size: 15px; cursor: pointer; color: #6b7060; }
.wish-list { flex: 1; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.wish-empty { font-size: 13px; color: #8a8a7a; text-align: center; padding: 18px 0; }
.wish-item { font-size: 13px; color: var(--ink); background: #ffffffb0; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.wish-item.wish-new { border-color: var(--gold); animation: feedIn .4s ease; }
.wish-name { color: var(--gold); font-weight: 600; margin-right: 8px; }
.wish-text { margin-right: 8px; word-break: break-all; }
.wish-time { float: right; font-size: 11px; color: #a0a090; }
/* 预设心愿选择区（不开放自由输入） */
.wish-presets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 10px 12px; border-top: 1px solid var(--border);
}
.wish-preset-tip { grid-column: 1 / -1; font-size: 11px; color: #8a8a7a; text-align: center; }
.wish-preset {
  padding: 7px 4px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--ink); font-size: 12px; font-family: var(--serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .2s;
}
.wish-preset:hover:not(:disabled) { background: var(--primary); color: #fff; border-color: var(--primary); }
.wish-preset:disabled { opacity: .45; cursor: default; }

/* ---- P1 快捷语弹层（动作栏上方） ---- */
.phrase-pop {
  position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 6px; padding: 10px;
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 0, #fdfbf6fa, #f4efe3f0),
    radial-gradient(#aaa88e33 .8px, transparent .8px);
  background-size: auto, 6px 6px;
  border: 1px solid var(--border); box-shadow: 0 10px 30px #0000004d;
}
.phrase-btn {
  padding: 8px 22px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--ink); font-size: 14px; font-family: var(--serif);
  white-space: nowrap; transition: background .2s;
}
.phrase-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 虚拟摇杆（仅触屏显示） */
.joystick {
  position: absolute; left: 26px; bottom: 26px; width: 110px; height: 110px;
  border-radius: 50%; background: #ffffff2b; border: 2px solid #ffffff59;
  display: none; z-index: 10; touch-action: none;
}
.joystick-knob {
  position: absolute; left: 35px; top: 35px; width: 40px; height: 40px;
  border-radius: 50%; background: #ffffffc9; box-shadow: 0 2px 8px #0004;
}
@media (pointer: coarse) { .joystick { display: block; } }

/* 欢迎 Toast */
.toast {
  position: absolute; top: 70px; right: 14px; z-index: 20; padding: 10px 16px;
  border-radius: 12px; background: #363a31e6; color: #faf8f3; font-size: 14px;
  border: 1px solid #ffffff2b; animation: feedIn .3s ease;
}
/* 失败/降级页 */
.fail {
  position: absolute; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; flex-direction: column; gap: 12px;
  background: #171a16ee; color: var(--background); font-size: 16px; text-align: center; padding: 20px;
}

/* 进场页 */
.entry {
  position: absolute; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#00000055, #00000099), url("../assets/entry-bg.jpg") center/cover, #2c332b;
}
.entry-card {
  width: min(400px, 88vw); padding: 40px 34px; text-align: center; border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 0, #fdfbf6fa, #f2ecdfF2),
    radial-gradient(#aaa88e33 .8px, transparent .8px);
  background-size: auto, 6px 6px;
  border: 1px solid var(--border); box-shadow: 0 18px 50px #00000073;
}
.entry-logo { font-size: 44px; color: var(--primary); }
.entry-card h1 { font-family: var(--serif); font-size: 40px; letter-spacing: 8px; color: var(--ink); margin: 6px 0 2px; }
.entry-slogan { color: var(--gold); letter-spacing: 6px; font-size: 14px; margin-bottom: 24px; }
#entry-name {
  width: 100%; padding: 12px 14px; margin-bottom: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; font-size: 15px; text-align: center; outline: none;
}
#entry-name:focus { border-color: var(--primary); }
#entry-btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 17px; letter-spacing: 4px; font-family: var(--serif);
}
#entry-btn:disabled { opacity: .6; }
.entry-status { margin-top: 10px; font-size: 13px; color: #8a6a4a; min-height: 18px; }

/* ================= 仪式结果卡（掷筊 / 点灯）================= */
.ritual-card {
  position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%);
  z-index: 36; width: min(300px, 84vw); padding: 15px 20px 14px;
  border-radius: 18px; text-align: center; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0, #fdfbf6fa, #f2ecdfF2),
    radial-gradient(#aaa88e33 .8px, transparent .8px);
  background-size: auto, 6px 6px;
  border: 1px solid var(--gold);
  box-shadow: 0 16px 40px #00000059, inset 0 0 26px #c9a25a1f;
  animation: ritualIn .4s cubic-bezier(.2, .85, .35, 1);
}
.ritual-out { animation: ritualOut .32s ease forwards; }
@keyframes ritualIn {
  from { opacity: 0; transform: translate(-50%, 22px) scale(.93); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes ritualOut { to { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }

/* 筊杯：阴面=平面浅色带孔 / 阳面=凸面深色带高光阴影 */
.jb-pair {
  display: flex; gap: 22px; justify-content: center; align-items: center;
  height: 56px; perspective: 320px; margin-bottom: 6px;
}
.jb-block {
  position: relative; width: 72px; height: 38px; border-radius: 50%;
  animation: jbDrop .6s cubic-bezier(.25, .9, .35, 1.2) both;
}
.jb-block:nth-child(2) { animation-delay: .14s; }
@keyframes jbDrop {
  from { opacity: 0; transform: translateY(-26px) rotateX(72deg) scale(.82); }
  60% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
.jb-block.yang {
  background: radial-gradient(circle at 36% 28%, #f6e2b4, #c9a25a 58%, #8f6a2f 100%);
  box-shadow: inset 0 -5px 9px #00000038, 0 6px 10px #00000026;
}
.jb-block.yin {
  background: linear-gradient(180deg, #f0e5cb, #d8c69c);
  border: 1px solid #b08a4a80;
  box-shadow: inset 0 2px 0 #ffffffa0, 0 3px 6px #0000001a;
}
.jb-block.yin::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 11px; height: 11px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #8a6a3a, #4a3826);
  box-shadow: inset 0 1px 2px #00000066;
}
.jb-name { font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: 5px; color: var(--primary); }
.jb-desc { font-size: 13px; color: #8a6a4a; margin-top: 5px; letter-spacing: 1px; }

/* 长明灯插画：暖光纸灯 + 摇曳焰苗 */
.lamp-art { position: relative; height: 62px; display: flex; justify-content: center; align-items: flex-end; margin-bottom: 8px; }
.lamp-lantern {
  position: relative; width: 48px; height: 58px; border-radius: 46% / 42%;
  background: radial-gradient(circle at 50% 42%, #fff8dd, #f3bd58 52%, #cf7c2c 100%);
  box-shadow: 0 0 26px 8px #ffb34780, inset 0 0 14px #fff6c9b3;
  animation: lampGlow 1.8s ease-in-out infinite alternate;
}
.lamp-lantern::before, .lamp-lantern::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  width: 13px; height: 6px; border-radius: 2px; background: #7a5230;
}
.lamp-lantern::before { top: -5px; }
.lamp-lantern::after { bottom: -5px; }
.lamp-flame {
  position: absolute; left: 50%; top: 50%; width: 13px; height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 68%, #fffdf0, #ffd75e 48%, #ff8f2a 100%);
  animation: flameSway 1.1s ease-in-out infinite alternate;
}
@keyframes lampGlow {
  from { box-shadow: 0 0 18px 5px #ffb34766, inset 0 0 12px #fff6c99e; }
  to { box-shadow: 0 0 32px 11px #ffb34799, inset 0 0 16px #fff6c9cc; }
}
@keyframes flameSway {
  from { transform: translate(-50%, -50%) scale(.92) rotate(-3deg); }
  to { transform: translate(-50%, -52%) scale(1.06) rotate(3deg); }
}
