/* 天机阁 · 四柱八字 */
:root {
  --bg: #07080b;
  --ink: #f2ecdc;
  --gold: #d9b45b;
  --gold-dim: rgba(217, 180, 91, 0.34);
  --cinnabar: #b6331f;
  --serif: 'Songti SC', 'Noto Serif SC', 'Source Han Serif SC', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 场景 ---------- */
#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
}
#scene img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 46%;
  user-select: none;
  pointer-events: none;
}
#scene .vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 30%, rgba(4, 6, 10, 0.55) 78%, rgba(4, 6, 10, 0.88) 100%),
    linear-gradient(180deg, rgba(4, 6, 10, 0.5) 0%, transparent 18%, transparent 52%, rgba(4, 6, 10, 0.86) 100%);
  pointer-events: none;
}

/* ---------- 顶栏 ---------- */
.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
}

.back {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background: rgba(8, 10, 14, 0.5);
  color: rgba(255, 248, 232, 0.75);
  text-decoration: none;
  font-size: 16px;
  backdrop-filter: blur(10px);
  transition: all 0.25s;
}
.back:hover { border-color: var(--gold); color: #fff6dd; }

.brand { display: flex; align-items: center; gap: 11px; }

.seal {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: linear-gradient(160deg, #a8301f, #6b1410);
  color: #f6dfa4;
  font-size: 20px;
  box-shadow: inset 0 0 0 1.5px rgba(246, 223, 164, 0.42), 0 4px 18px rgba(0, 0, 0, 0.6);
}

.brand-text { line-height: 1.2; }
.brand-text b {
  display: block;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #fff8e8;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}
.brand-text i {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: rgba(217, 180, 91, 0.72);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

.ghost {
  margin-left: auto;
  appearance: none;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  background: rgba(8, 10, 14, 0.5);
  color: rgba(255, 246, 221, 0.82);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.1em;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.25s;
}
.ghost:hover { border-color: var(--gold); color: #fff6dd; }

/* ---------- 主体 ---------- */
#wrap {
  position: relative;
  z-index: 10;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 22px max(24px, env(safe-area-inset-bottom));
}

/* ---------- 生辰表单 ---------- */
#setup {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(6px);
}
#setup[hidden] { display: none; }

.setup-inner {
  width: min(460px, 92vw);
  padding: 32px 32px 28px;
  border-radius: 16px;
  background: rgba(12, 12, 16, 0.92);
  border: 1px solid rgba(217, 180, 91, 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
}

.kicker {
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: rgba(217, 180, 91, 0.78);
  margin-bottom: 10px;
}

.note {
  margin: 0 0 24px;
  font-size: 12.5px;
  line-height: 1.8;
  color: rgba(255, 248, 232, 0.62);
}

.row { display: flex; align-items: center; gap: 14px; margin-bottom: 15px; }
.row > label {
  flex: 0 0 80px;
  font-size: 12.5px;
  color: rgba(217, 180, 91, 0.85);
}
.inputs { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }

.inputs input {
  width: 78px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid rgba(217, 180, 91, 0.26);
  background: rgba(6, 6, 9, 0.85);
  color: #fff6e2;
  font-family: var(--serif);
  font-size: 13.5px;
  outline: none;
}
.inputs input:focus { border-color: rgba(217, 180, 91, 0.7); }

.shichen { font-size: 11.5px; color: rgba(217, 180, 91, 0.65); white-space: nowrap; }

.gender { display: flex; gap: 9px; flex: 1; }
.gbtn {
  flex: 1;
  appearance: none;
  padding: 9px 0;
  border-radius: 9px;
  border: 1px solid rgba(217, 180, 91, 0.26);
  background: rgba(6, 6, 9, 0.8);
  color: rgba(255, 246, 226, 0.6);
  font-family: var(--serif);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.22s;
}
.gbtn.on {
  border-color: rgba(217, 180, 91, 0.75);
  background: rgba(58, 40, 16, 0.8);
  color: #fff3d6;
}

.err { min-height: 18px; margin: 6px 0 10px; font-size: 12.5px; color: #e88070; }

.cast {
  width: 100%;
  appearance: none;
  padding: 14px 0;
  border-radius: 10px;
  border: 1px solid rgba(217, 180, 91, 0.55);
  background: linear-gradient(180deg, rgba(96, 66, 24, 0.92), rgba(52, 36, 14, 0.96));
  color: #ffeec4;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.22em;
  cursor: pointer;
  transition: all 0.25s;
}
.cast:hover { border-color: rgba(246, 214, 140, 0.9); }
.cast:disabled { opacity: 0.5; cursor: default; }

/* ---------- 四柱：浮在光柱之上 ---------- */
#reading { width: 100%; }

.pillars {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 2.2vw, 26px);
  margin-bottom: clamp(18px, 3.4vh, 40px);
}

.pillar {
  flex: 0 0 auto;
  min-width: clamp(88px, 11vw, 130px);
  padding: 14px 10px 13px;
  border-radius: 12px;
  text-align: center;
  background: rgba(10, 12, 16, 0.42);
  border: 1px solid rgba(217, 180, 91, 0.26);
  backdrop-filter: blur(14px) saturate(1.15);
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: riseIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.pillar:nth-child(1) { animation-delay: 0.05s }
.pillar:nth-child(2) { animation-delay: 0.13s }
.pillar:nth-child(3) { animation-delay: 0.21s }
.pillar:nth-child(4) { animation-delay: 0.29s }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.pillar .label {
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: rgba(217, 180, 91, 0.7);
  margin-bottom: 8px;
}
.pillar .gz {
  font-size: clamp(19px, 2.1vw, 25px);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff6e2;
  line-height: 1.15;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9), 0 0 28px rgba(217, 180, 91, 0.3);
}
.pillar .py {
  margin-top: 6px;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(217, 180, 91, 0.66);
}
.pillar .wx {
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(255, 248, 232, 0.4);
}

/* ---------- 对话区 ---------- */
.panels {
  width: min(720px, 94vw);
  margin: 0 auto;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 34vh;
  overflow-y: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 180, 91, 0.28) transparent;
}
.chat::-webkit-scrollbar { width: 4px; }
.chat::-webkit-scrollbar-thumb { background: rgba(217, 180, 91, 0.28); border-radius: 4px; }

.msg {
  padding: 13px 17px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.85;
  animation: riseIn 0.4s ease both;
}

.msg.q {
  align-self: flex-end;
  max-width: 76%;
  background: rgba(60, 40, 16, 0.62);
  border: 1px solid rgba(217, 180, 91, 0.3);
  color: rgba(255, 246, 226, 0.94);
  backdrop-filter: blur(10px);
}

.msg.a {
  align-self: flex-start;
  max-width: 94%;
  background: rgba(8, 10, 14, 0.72);
  border: 1px solid rgba(217, 180, 91, 0.16);
  border-left: 2.5px solid rgba(182, 51, 31, 0.85);
  color: rgba(255, 248, 232, 0.9);
  backdrop-filter: blur(14px);
}

.msg.a.thinking { color: rgba(255, 248, 232, 0.45); font-style: italic; }

.msg .who {
  display: block;
  margin-bottom: 6px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(217, 180, 91, 0.6);
}

/* ---------- 输入 ---------- */
.askbar { display: flex; gap: 10px; margin-bottom: 11px; }

.askbar input {
  flex: 1;
  padding: 13px 18px;
  border-radius: 10px;
  border: 1px solid rgba(217, 180, 91, 0.26);
  background: rgba(8, 10, 14, 0.72);
  color: #fff6e2;
  font-family: var(--serif);
  font-size: 13.5px;
  outline: none;
  backdrop-filter: blur(14px);
}
.askbar input:focus { border-color: rgba(217, 180, 91, 0.62); }
.askbar input::placeholder { color: rgba(255, 248, 232, 0.35); }

.askbar button {
  appearance: none;
  padding: 0 24px;
  border-radius: 10px;
  border: 1px solid rgba(217, 180, 91, 0.45);
  background: rgba(52, 36, 14, 0.82);
  color: #ffeec4;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.22s;
}
.askbar button:hover { border-color: rgba(246, 214, 140, 0.9); }
.askbar button:disabled { opacity: 0.45; cursor: default; }

/* ---------- 快捷问题 ---------- */
.quick { display: flex; flex-wrap: wrap; gap: 8px; }

.quick button {
  appearance: none;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(217, 180, 91, 0.24);
  background: rgba(8, 10, 14, 0.6);
  color: rgba(255, 246, 226, 0.72);
  font-family: var(--serif);
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.22s;
}
.quick button:hover {
  border-color: rgba(217, 180, 91, 0.7);
  background: rgba(40, 28, 12, 0.8);
  color: #fff3d6;
}

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
  #wrap { padding: 0 14px 16px; }
  .bar { padding: 12px 14px; }
  .brand-text b { font-size: 15px; }
  .seal { width: 32px; height: 32px; font-size: 17px; }

  .pillars { gap: 7px; margin-bottom: 14px; }
  .pillar { min-width: 74px; padding: 10px 6px 9px; }
  .pillar .gz { font-size: 17px; }
  .pillar .py { font-size: 8px; letter-spacing: 0.1em; }
  .pillar .wx { display: none; }

  .chat { max-height: 26vh; }
  .msg { font-size: 12.5px; padding: 10px 13px; }
  .msg.q, .msg.a { max-width: 100%; }

  .setup-inner { padding: 24px 20px 22px; }
  .row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .row > label { flex: none; }
  .inputs, .gender { width: 100%; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .pillars { margin-bottom: 8px; }
  .pillar { padding: 7px 8px 6px; min-width: 84px; }
  .pillar .gz { font-size: 16px; }
  .chat { max-height: 30vh; }
}

/* ============================================================
   特效层
   ============================================================ */
/* 星空缓慢呼吸 */
#scene img {
  animation: skyBreath 26s ease-in-out infinite;
}
@keyframes skyBreath {
  0%, 100% { filter: brightness(1) saturate(1); transform: scale(1.02); }
  50%      { filter: brightness(1.08) saturate(1.1); transform: scale(1.045); }
}

/* 浮尘 */
#fx-dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.9;
  z-index: 2;
}

/* 四道光柱辉光 */
#fx-pillars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.fx-beam {
  position: absolute;
  bottom: 24%;
  width: 3.2%;
  height: 34%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(255, 226, 156, 0) 0%,
    rgba(255, 226, 156, 0.22) 18%,
    rgba(255, 238, 190, 0.36) 46%,
    rgba(255, 226, 156, 0.18) 78%,
    rgba(255, 226, 156, 0) 100%
  );
  filter: blur(3px);
  opacity: 0.34;
  transition: opacity 0.9s ease, filter 0.9s ease;
}

/* 点亮后脉动 */
.fx-beam.lit {
  opacity: 1;
  filter: blur(2px) drop-shadow(0 0 18px rgba(255, 214, 130, 0.55));
  animation: beamPulse 3.6s ease-in-out infinite;
}
.fx-beam.lit:nth-child(1) { animation-delay: 0s; }
.fx-beam.lit:nth-child(2) { animation-delay: 0.42s; }
.fx-beam.lit:nth-child(3) { animation-delay: 0.84s; }
.fx-beam.lit:nth-child(4) { animation-delay: 1.26s; }

@keyframes beamPulse {
  0%, 100% { transform: translateX(-50%) scaleY(1); opacity: 0.82; }
  50%      { transform: translateX(-50%) scaleY(1.06); opacity: 1; }
}

/* 卡片点亮：金色描边亮起 */
.pillar {
  transition: border-color 0.7s ease, box-shadow 0.7s ease;
}
.pillar.lit {
  border-color: rgba(246, 214, 140, 0.62);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(255, 214, 130, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* 引导语 */
#prophecy {
  position: fixed;
  left: 50%;
  bottom: 34%;
  transform: translate(-50%, 10px);
  z-index: 18;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.82);
  border: 1px solid rgba(217, 180, 91, 0.34);
  backdrop-filter: blur(14px);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: rgba(255, 244, 214, 0.9);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
#prophecy.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 问事时：光柱整体亮一下 */
@keyframes beamFlash {
  0%   { opacity: 0.82; }
  30%  { opacity: 1; filter: blur(1px) drop-shadow(0 0 30px rgba(255, 226, 156, 0.85)); }
  100% { opacity: 0.82; }
}
.fx-beam.flash { animation: beamFlash 0.9s ease; }

/* 输入未解锁 */
#ask-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#ask-input:disabled::placeholder {
  color: rgba(217, 180, 91, 0.55);
}

@media (max-width: 640px) {
  #prophecy { font-size: 11.5px; padding: 8px 16px; bottom: 40%; }
  .fx-beam { width: 4%; }
}

/* ============================================================
   点灯仪式
   ============================================================ */
.ritual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(14px, 2.6vh, 28px);
  transition: opacity 0.5s ease, transform 0.5s ease, max-height 0.5s ease;
  max-height: 120px;
}
.ritual.done {
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  margin-bottom: 0;
  pointer-events: none;
}

.light-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 12px 30px;
  border-radius: 999px;
  border: 1px solid rgba(217, 180, 91, 0.55);
  background: linear-gradient(180deg, rgba(66, 46, 16, 0.86), rgba(32, 22, 9, 0.92));
  color: #ffeec4;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.24em;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
  transition: all 0.28s;
}
.light-btn:hover {
  border-color: rgba(255, 232, 168, 0.95);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.6), 0 0 32px rgba(255, 214, 130, 0.3);
  transform: translateY(-2px);
}

/* 小灯 */
.lamp {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(217, 180, 91, 0.5);
  box-shadow: 0 0 10px rgba(217, 180, 91, 0.4);
  transition: all 0.4s;
  animation: lampIdle 2.4s ease-in-out infinite;
}
@keyframes lampIdle {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50%      { opacity: 1; transform: scale(1.08); }
}

.light-btn.lighting .lamp {
  background: #ffe6a8;
  box-shadow: 0 0 26px rgba(255, 224, 150, 1), 0 0 60px rgba(255, 200, 100, 0.6);
  animation: lampFlare 0.7s ease;
}
@keyframes lampFlare {
  0%   { transform: scale(0.9); box-shadow: 0 0 10px rgba(255,224,150,.5); }
  40%  { transform: scale(1.9); box-shadow: 0 0 60px rgba(255,224,150,1), 0 0 120px rgba(255,200,100,.7); }
  100% { transform: scale(1);   box-shadow: 0 0 26px rgba(255,224,150,1), 0 0 60px rgba(255,200,100,.6); }
}

.ritual-hint {
  margin: 0;
  font-family: var(--serif);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: rgba(217, 180, 91, 0.6);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

/* 未点灯：卡片暗着 */
.pillar {
  filter: brightness(0.72) saturate(0.7);
  transition: filter 0.7s ease, border-color 0.7s ease, box-shadow 0.7s ease;
}
.pillar.lit { filter: brightness(1) saturate(1); }

/* 未点灯：输入区暗 */
#reading.locked .askbar,
#reading.locked .quick {
  opacity: 0.32;
  pointer-events: none;
  filter: blur(0.4px);
  transition: opacity 0.5s ease, filter 0.5s ease;
}

/* 点灯时的全屏暖光 */
#light-flash {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  background: radial-gradient(ellipse 60% 50% at 50% 62%, rgba(255, 216, 140, 0.42), transparent 70%);
  opacity: 0;
}
#light-flash.go {
  animation: flashUp 1.5s ease-out;
}
@keyframes flashUp {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 640px) {
  .light-btn { padding: 10px 24px; font-size: 13px; }
  .ritual-hint { font-size: 10.5px; }
}
