:root {
  color-scheme: dark;
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  background: #0d100e;
  color: #fbf1d7;
  --ink: #0d100e;
  --surface: rgb(14 18 15 / 88%);
  --surface-strong: rgb(10 13 11 / 94%);
  --paper-ink: #312410;
  --gold: #dfbd71;
  --gold-bright: #f5d88f;
  --gold-deep: #7d5a24;
  --line: rgb(223 189 113 / 54%);
  --muted: #dfd2b2;
  --motion-enter: 620ms cubic-bezier(.22, .8, .2, 1);
  --motion-exit: 360ms ease-out;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--ink);
}

button,
summary { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

/* CR-028：宫位格等可点击容器禁用移动端点击高亮与文本选区（否则 Android/Chrome 点击时出现青色方框） */
.palace-cell,
.conclusion-sheet .palace-cell,
.meaning-card,
.meaning-card * {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.ritual-stage {
  --luopan-angle: 0deg;
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: #0a0d0b url("./assets/visual/background/night_observatory.webp") center / cover no-repeat;
}

.stage-scrim,
.ritual-stage::before,
.ritual-stage::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.stage-scrim {
  z-index: 1;
  background: linear-gradient(180deg, rgb(4 7 5 / 36%), rgb(7 10 8 / 80%) 67%, rgb(6 8 7 / 94%));
}

.ritual-stage::before {
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, transparent 0 12rem, rgb(5 7 6 / 62%) 33rem);
}

.ritual-stage::after {
  z-index: 5;
  opacity: .45;
  background-image: radial-gradient(circle at center, rgb(255 235 172 / 80%) 0 1px, transparent 1.5px);
  background-size: 8.5rem 8.5rem;
  mask-image: radial-gradient(circle at 50% 50%, #000 0 10rem, transparent 28rem);
}

.star-layer {
  position: absolute;
  z-index: 1;
  inset: 0;
  opacity: .6;
  background-image: url("./assets/visual/background/star_field.webp");
  background-position: center top;
  background-size: cover;
  mix-blend-mode: screen;
}

.star-layer-two { opacity: .16; transform: scale(1.12); filter: blur(1.5px); }

.stage-taiji,
.stage-taiji-ring,
.luopan-assembly,
.stage-scroll,
.stage-paper {
  position: absolute;
  left: 50%;
  pointer-events: none;
  user-select: none;
  transition: opacity var(--motion-exit), transform var(--motion-enter), filter var(--motion-enter);
}

/* 太极/金光同心一体：旋转容器负责定位与动画，图片填满容器即天然同圆心。
   两容器共用同一 left/top + translate 居中，水平垂直双对齐、圆心重合。
   垂直中心变量 --taiji-center-top；此处 calc 仅作 JS 未执行时的兜底值 */
:root { --taiji-center-top: calc(50% + 4.5rem - 120px); }

.orbit-spin {
  position: absolute;
  left: 50%;
  top: var(--taiji-center-top);
  width: calc(min(52vw, 18rem) * 1.5); /* 整体放大 1.5 倍 */
  aspect-ratio: 1;
  translate: -50% -50%; /* 容器中心点精确落在 (50%, 变量值) */
  z-index: 3;
  pointer-events: none;
}
@keyframes spin-cw { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes spin-ccw { from { transform: rotate(370deg); } to { transform: rotate(10deg); } }
.spin-cw { animation: spin-cw 40s linear infinite; }
.spin-ccw { animation: spin-ccw 40s linear infinite; }
/* 图片铺满正形容器：覆盖外层通用规则的 left:50%，确保与容器同圆心 */
.stage-taiji,
.stage-taiji-ring {
  display: block;
  left: 0;
  top: 0;
  translate: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center; /* 显式居中：无论原图透明留白是否对称，都对齐画布中心 */
}

/* 太极再缩小 0.9 倍（累计 0.9³≈0.729，金光保持容器原尺寸），仍与容器同心 */
.stage-taiji {
  inset: 13.5%;
  width: 73%;
  height: 73%;
}

.luopan-assembly {
  z-index: 4;
  top: calc(50% - 35px); /* 全局上调35px：六宫随罗盘整体移动，固定位置 */
  width: min(93vw, 33rem);
  aspect-ratio: 1;
  translate: -50% -50%;
  opacity: 0;
  transform: scale(.64) rotate(var(--luopan-angle));
  transform-origin: center;
  will-change: transform;
}

.luopan-assembly img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.luopan-inner { opacity: .84; transform: scale(.77); }
/* CR-022 剑指分层转动：确认后外盘 t=0 顺转，内盘 t=+1s 逆转（与点亮时序一致） */
@keyframes luopan-cw { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes luopan-ccw { from { transform: rotate(0deg) scale(.77); } to { transform: rotate(-360deg) scale(.77); } }
.sword-rotating .luopan-outer,
.sword-rotating .luopan-outer-light { animation: luopan-cw 8s linear infinite; }
.sword-rotating .luopan-inner,
.sword-rotating .luopan-inner-light { animation: luopan-ccw 8s linear infinite; animation-delay: 1s; }
body[data-state="FIST_SETTLING"] .sword-rotating .luopan-outer,
body[data-state="FIST_SETTLING"] .sword-rotating .luopan-outer-light,
body[data-state="FIST_SETTLING"] .sword-rotating .luopan-inner,
body[data-state="FIST_SETTLING"] .sword-rotating .luopan-inner-light { animation-play-state: paused; }
/* 阵法点亮层：张掌确认后直接显示点亮版罗盘（无混合效果）。CR-021：背景整体降亮至 .85。
   分层递进：外层 t=0 点亮 → 内层 t=+1s → 六宫 t=+2s */
.luopan-outer-light,
.luopan-inner-light { opacity: 0; transition: opacity var(--motion-enter); transition-delay: 0ms; filter: brightness(.85); }
.luopan-inner-light { transform: scale(.77); }

.palace-orbit {
  --palace-radius: min(32.225vw, 11.43rem); /* CR-020：由贴内盘边缘 min(35.805vw,12.705rem) 向心聚拢 0.9 倍 */
  position: absolute;
  z-index: 6;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.palace-orbit li {
  --palace-scale: 1;
  --palace-transform-duration: 460ms;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5.85rem; /* CR-020：六宫整体扩大 1.5 倍（原 3.9rem） */
  height: 5.85rem;
  translate: -50% -50%;
  opacity: 0;
  transition: opacity 460ms ease-out, transform var(--palace-transform-duration) cubic-bezier(.16, .8, .24, 1), box-shadow var(--motion-exit);
}
.palace-orbit li img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
/* 宫位点亮层：张掌后与罗盘同步渐显（阵法开启） */
.palace-orbit .palace-light { opacity: 0; transition: opacity var(--motion-enter); }

.palace-orbit li:nth-child(1) { transform: rotate(calc(var(--palace-spin, 0deg) + 0deg)) translateY(calc(-1 * var(--palace-radius))) rotate(calc(-1 * var(--palace-spin, 0deg))) scale(var(--palace-scale)); }
.palace-orbit li:nth-child(2) { transform: rotate(calc(var(--palace-spin, 0deg) + 60deg)) translateY(calc(-1 * var(--palace-radius))) rotate(calc(var(--palace-spin, 0deg) * -1 - 60deg)) scale(var(--palace-scale)); }
.palace-orbit li:nth-child(3) { transform: rotate(calc(var(--palace-spin, 0deg) + 120deg)) translateY(calc(-1 * var(--palace-radius))) rotate(calc(var(--palace-spin, 0deg) * -1 - 120deg)) scale(var(--palace-scale)); }
.palace-orbit li:nth-child(4) { transform: rotate(calc(var(--palace-spin, 0deg) + 180deg)) translateY(calc(-1 * var(--palace-radius))) rotate(calc(var(--palace-spin, 0deg) * -1 - 180deg)) scale(var(--palace-scale)); }
.palace-orbit li:nth-child(5) { transform: rotate(calc(var(--palace-spin, 0deg) + 240deg)) translateY(calc(-1 * var(--palace-radius))) rotate(calc(var(--palace-spin, 0deg) * -1 - 240deg)) scale(var(--palace-scale)); }
.palace-orbit li:nth-child(6) { transform: rotate(calc(var(--palace-spin, 0deg) + 300deg)) translateY(calc(-1 * var(--palace-radius))) rotate(calc(var(--palace-spin, 0deg) * -1 - 300deg)) scale(var(--palace-scale)); }

/* 点赞进入天机台：六宫固定显示（liugong-off 素材），不隐藏、不依次显现 */
body[data-state="PALACE_READY"] .palace-orbit li { opacity: 1; }

/* 时刻起课法角标：时宫(is-shi)=金边；刻宫/身宫(is-ke)=最强金光 */
.palace-orbit li.is-shi { box-shadow: 0 0 1.1rem rgb(234 211 157 / 55%); }
.palace-orbit li.is-ke {
  box-shadow: 0 0 1.75rem rgb(244 203 102 / 76%), inset 0 0 1.25rem rgb(255 236 164 / 40%);
}
.palace-orbit li::after {
  content: "";
  position: absolute;
  inset: -.55rem;
  border: 1px solid rgb(255 225 139 / 88%);
  border-radius: 50%;
  opacity: 0;
  transform: scale(.72);
  box-shadow: 0 0 1rem rgb(255 210 103 / 0%);
  pointer-events: none;
}
body[data-state="FIST_SETTLING"] .palace-orbit li.is-ke::after { animation: ke-palace-lock 900ms cubic-bezier(.16, .8, .24, 1) both; }

.stage-scroll { z-index: 8; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.06); }
.stage-paper { z-index: 7; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.04); }

/* 天机开启与开宫：太极隐去，罗盘完整显现 */
body[data-state="PALACE_READY"] .stage-taiji,
body[data-state="PALACE_READY"] .stage-taiji-ring,
body[data-state="PALM_OPENED"] .stage-taiji,
body[data-state="PALM_OPENED"] .stage-taiji-ring { opacity: 0; transform: scale(.6); }
body[data-state="PALACE_READY"] .luopan-assembly,
body[data-state="PALM_OPENED"] .luopan-assembly { opacity: 1; transform: scale(1) rotate(var(--luopan-angle)); }

/* 阵法点亮（分层递进）：外层罗盘 t=0 → 内层罗盘 t=+1s → 六宫 t=+2s */
body[data-state="PALM_OPENED"] .luopan-outer-light,
body[data-state="POINT_CONTROL"] .luopan-outer-light,
body[data-state="FIST_SETTLING"] .luopan-outer-light,
body[data-state="PALACE_REVEAL"] .luopan-outer-light { opacity: 1; transition-delay: 0ms; }

body[data-state="PALM_OPENED"] .luopan-inner-light,
body[data-state="POINT_CONTROL"] .luopan-inner-light,
body[data-state="FIST_SETTLING"] .luopan-inner-light,
body[data-state="PALACE_REVEAL"] .luopan-inner-light { opacity: 1; transition-delay: 1000ms; }

body[data-state="PALM_OPENED"] .palace-orbit .palace-light,
body[data-state="POINT_CONTROL"] .palace-orbit .palace-light,
body[data-state="FIST_SETTLING"] .palace-orbit .palace-light,
body[data-state="PALACE_REVEAL"] .palace-orbit .palace-light { opacity: 1; transition-delay: 2000ms; }

/* 张掌开宫：六宫亮起（li 保持可见；light 层按分层时序由上方规则控制） */
body[data-state="PALM_OPENED"] .palace-orbit li { opacity: 1; }

/* CR-021 定课瞬间：六宫同时消失，落宫（刻宫/身宫）移至罗盘中心 */
body[data-state="FIST_SETTLING"] .palace-orbit li { opacity: 0; --palace-scale: 1; --palace-transform-duration: 0ms; transition-delay: 0ms; }

/* 中心落宫图：比罗盘内盘（scale .77）小一圈（.62 相对 assembly），出现时渐显+放大。
   特异性需压过 .luopan-assembly img 的 width/height 100% */
.luopan-assembly .ke-palace-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  width: 62%;
  height: auto;
  aspect-ratio: 1;
  translate: -50% -50%;
  opacity: 0;
  transform: scale(.72);
  transition: opacity var(--motion-enter), transform var(--motion-enter);
  pointer-events: none;
}
body[data-state="FIST_SETTLING"] .luopan-assembly .ke-palace-center {
  opacity: 1;
  transform: scale(1);
}

body[data-state="POINT_CONTROL"] .palace-orbit li,
body[data-state="PALACE_REVEAL"] .palace-orbit li { opacity: 1; --palace-scale: 1; --palace-transform-duration: 0ms; transition-delay: 0ms; }

body[data-state="POINT_CONTROL"] .stage-taiji,
body[data-state="FIST_SETTLING"] .stage-taiji,
body[data-state="POINT_CONTROL"] .stage-taiji-ring,
body[data-state="FIST_SETTLING"] .stage-taiji-ring { opacity: 0; transform: scale(.6); }
body[data-state="POINT_CONTROL"] .luopan-assembly,
body[data-state="FIST_SETTLING"] .luopan-assembly,
body[data-state="PALACE_REVEAL"] .luopan-assembly { opacity: 1; transform: scale(1) rotate(var(--luopan-angle)); }
body[data-state="PALACE_REVEAL"] .stage-scrim { background: linear-gradient(180deg, rgb(3 5 4 / 42%), rgb(6 8 6 / 84%)); }

body[data-state="CONCLUSION"] .stage-taiji,
body[data-state="CONCLUSION"] .stage-taiji-ring,
body[data-state="CONCLUSION"] .luopan-assembly { opacity: 0; transform: scale(.72); }
body[data-state="CONCLUSION"] .stage-scroll { opacity: .92; transform: scale(1); }
body[data-state="CONCLUSION"] .stage-paper { opacity: 1; transform: scale(1); }
body[data-state="CONCLUSION"] .stage-scrim { z-index: 9; background: rgb(57 38 11 / 15%); }
body[data-state="CONCLUSION"] .star-layer { opacity: 0; }

.topbar,
main { position: relative; z-index: 10; }

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(.55rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 2rem) 0;
  pointer-events: none;
}

.topbar .eyebrow,
.setting-actions { pointer-events: auto; }
.setting-actions { display: flex; gap: .45rem; }

main {
  height: 100dvh;
  width: min(100%, 42rem);
  margin: 0 auto;
  padding: max(3.5rem, calc(env(safe-area-inset-top) + 3rem)) clamp(1rem, 5vw, 2rem) max(1rem, env(safe-area-inset-bottom));
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(2.3rem, 10vw, 3.8rem);
  font-weight: 600;
  letter-spacing: .16em;
  line-height: 1.16;
  text-shadow: 0 0 1.8rem rgb(242 196 102 / 30%), 0 2px 14px rgb(0 0 0 / 65%);
}

h2 { margin-bottom: .7rem; font-size: clamp(1.3rem, 5vw, 1.7rem); font-weight: 600; letter-spacing: .08em; line-height: 1.35; }
p { font-size: 1rem; line-height: 1.75; }

.eyebrow { color: var(--gold); font-size: .74rem; font-weight: 600; letter-spacing: .17em; margin-bottom: .5rem; }
.detail, .disclaimer, .result-hint { color: var(--muted); font-size: .9rem; }
.gesture-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  margin: 0 auto;
}
/* 空片段不占位；运宫诀正文沿用 detail，括号手势在同一行内沿用 gesture-hint。 */
.gesture-row > .detail:empty,
.gesture-row > .gesture-hint:empty { display: none; }
.gesture-hint { margin: 0; color: rgb(223 189 113 / 72%); font-size: .78rem; line-height: 1.75; letter-spacing: .1em; white-space: nowrap; }
body[data-state="POINT_CONTROL"] .gesture-row > .detail.is-mixed {
  min-width: 0;
  max-width: 100%;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}
.disclaimer { max-width: 26rem; margin-inline: auto; }

/* 首屏：标题固定在太极上方，免责声明贴底，整段不参与滚动 */
.intro {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  text-wrap: balance;
}

.intro-head { padding-top: .5rem; }

/* 全局免责声明：固定悬浮于视口底缘，所有页面统一显示 */
.global-disclaimer {
  position: fixed;
  left: 50%;
  bottom: max(8px, calc(max(1rem, env(safe-area-inset-bottom)) - 44px));
  translate: -50% 0;
  z-index: 40;
  width: min(92vw, 26rem);
  margin: 0;
  text-align: center;
}

/* 结语页古纸底上：免责声明用黑色 */
body[data-state="CONCLUSION"] .global-disclaimer { color: #242018; }

/* 仪式中段：标题与首屏保持同尺寸（不缩小） */
.intro.ritual-head .intro-head { padding-top: 0; }

/* HUD 停靠卡：手势引导与定课结果。全局统一尺寸、紧凑布局，
   固定悬于免责声明上方一点（不覆盖免责声明） */
.card.hud-dock {
  position: fixed;
  left: 50%;
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 3.6rem);
  z-index: 20;
  width: min(92vw, 27rem);
  translate: -50% 0;
  padding: .8rem clamp(.9rem, 3.5vw, 1.2rem);
  animation: rise-in var(--motion-enter) both;
}
.card.hud-dock h2 { margin-bottom: .35rem; }
.card.hud-dock .detail { line-height: 1.45; }

.center-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 20;
  width: min(92vw, 27rem);
  max-height: min(86dvh, 44rem);
  overflow-y: auto;
  translate: -50% -50%;
  animation: rise-in var(--motion-enter) both;
}

.card {
  padding: clamp(1.1rem, 4.5vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: linear-gradient(145deg, rgb(24 27 19 / 93%), var(--surface-strong));
  box-shadow: 0 1.15rem 3rem rgb(0 0 0 / 32%), inset 0 1px rgb(255 234 180 / 9%);
  text-align: center;
}

.result-hint { margin: .85rem auto 0; max-width: 27rem; }

/* 六宫排盘网格：固定两行三列 */
.palace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  gap: .5rem;
  margin: .4rem auto 0;
  width: 100%;
  max-width: 24rem;
}

.palace-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .14rem;
  padding: .55rem .25rem .45rem;
  border: 1px solid rgb(223 189 113 / 30%);
  border-radius: .5rem;
  background: radial-gradient(circle at 50% 32%, rgb(37 30 16 / 88%), rgb(11 14 11 / 72%) 78%);
  color: #e3cb94;
  transition: color var(--motion-exit), background var(--motion-exit), border-color var(--motion-exit), box-shadow var(--motion-exit);
}

.palace-star {
  font-size: .56rem;
  letter-spacing: .02em;
  color: var(--muted);
  white-space: nowrap;
}

.palace-name { font-size: clamp(.95rem, 3.8vw, 1.15rem); letter-spacing: .12em; text-indent: .12em; text-shadow: 0 1px 1px #000; }

.palace-badge {
  min-height: 1.05rem;
  font-size: .68rem;
  letter-spacing: .08em;
  color: var(--muted);
}

.palace-cell.is-shi {
  border-color: #caa25a;
  color: #fff0bd;
}

.palace-cell.is-shi .palace-badge { color: #ffe9a8; }

.palace-cell.is-ke {
  border-color: var(--gold-bright);
  background: radial-gradient(circle at 50% 32%, #816018, #2b210f 78%);
  color: #fff5cf;
  box-shadow: 0 0 1.1rem rgb(244 203 102 / 62%), inset 0 0 .8rem rgb(255 236 164 / 34%);
}

.palace-cell.is-ke .palace-badge { color: #fff5cf; }

/* 结语页：上=六宫显象模块，下=理性提示 */
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  text-align: center;
}

/* 排盘页：以古纸(ancient_paper)原图为背景，标题区居中偏上、免责声明贴底 */
.conclusion-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 42rem);
  margin: 0 auto;
  padding: max(3.5rem, calc(env(safe-area-inset-top) + 3rem)) clamp(1rem, 5vw, 2rem) max(1rem, env(safe-area-inset-bottom));
  background: url("./assets/visual/oracle/ancient_paper.webp") center / cover no-repeat;
  text-align: center;
}

/* 标题"六宫排盘"：与首屏主标题"天机台"同款字号/字重/位置，颜色黑色 */
.sheet-title {
  margin-bottom: .6rem;
  font-size: clamp(2.3rem, 10vw, 3.8rem);
  font-weight: 600;
  letter-spacing: .16em;
  line-height: 1.16;
  color: #171512;
  text-shadow: none;
}

.conclusion-sheet .eyebrow { color: #3a332a; }

/* "课成于此……"紧跟主标题下方，黑色 */
.conclusion-detail {
  margin-top: .4rem;
  color: #242018;
}

/* 六宫网格 + 按钮组整体居中：按钮紧随网格下方，不贴屏幕底 */
.conclusion-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1.2rem;
}
.conclusion-sheet .palace-grid {
  width: 100%;
  max-width: 24rem;
}
.conclusion-sheet .palace-cell {
  border-color: rgb(90 65 24 / 45%);
  box-shadow: 0 2px 10px rgb(60 42 12 / 22%);
  cursor: pointer;
}

/* CR-022 提示行：位于空亡宫正下方、按钮上方 */
.meaning-hint {
  margin: .9rem 0 0;
  font-size: .82rem;
  letter-spacing: .14em;
  color: #5c4622;
}

/* CR-022 断语文字卡：标题固定「断语」，正文可编辑 */
.duanyu-card {
  width: 100%;
  max-width: 24rem;
  margin-top: 1rem;
  padding: .8rem .9rem .9rem;
  border: 1px solid rgb(90 65 24 / 38%);
  border-radius: .6rem;
  background: rgb(249 231 176 / 12%);
  box-shadow: 0 2px 12px rgb(60 42 12 / 18%);
  text-align: left;
}
.duanyu-title {
  margin: 0 0 .4rem;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: .18em;
  color: #3a2f18;
}
.duanyu-input {
  width: 100%;
  min-height: 3.2rem;
  resize: vertical;
  padding: .5rem .6rem;
  border: 1px solid rgb(90 65 24 / 42%);
  border-radius: .4rem;
  background: rgb(255 250 235 / 78%);
  color: #2b2110;
  font: inherit;
  font-size: .9rem;
  line-height: 1.6;
}
.duanyu-input::placeholder { color: #8a7448; }
.duanyu-input:focus { outline: 2px solid #b08a3e; outline-offset: 1px; }

/* CR-025 宫位含义弹窗：古卷纸墨风（浅色纸底，深墨文字，便于阅读） */
.meaning-card {
  max-height: min(86dvh, 46rem);
  overflow-y: auto;
  border-color: rgb(90 65 24 / 45%);
  background: linear-gradient(160deg, #efe0ba, #e3cd9c 72%, #d8bf87);
  box-shadow: 0 1.15rem 3rem rgb(0 0 0 / 45%), inset 0 1px rgb(255 250 230 / 70%);
  color: #312410;
}
.meaning-card .eyebrow { color: #000; } /* CR-025：宫位之象眉题改黑色 */
.meaning-name {
  margin-bottom: .35rem;
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 600;
  letter-spacing: .22em;
  color: #3a2a10;
}
.meaning-poem {
  margin: 0 auto .5rem;
  max-width: 22rem;
  font-size: .95rem;
  line-height: 1.8;
  color: #4a3518;
}
.meaning-aspect {
  margin: 0 auto .75rem;
  max-width: 22rem;
  font-size: .85rem;
  line-height: 1.7;
  color: #5c4a28;
  text-align: left;
}
.meaning-info {
  margin-top: .4rem;
  padding: .7rem .85rem;
  border: 1px solid rgb(90 65 24 / 30%);
  border-radius: .5rem;
  background: rgb(249 231 176 / 14%);
  text-align: left;
}
.meaning-info-title {
  margin: 0 0 .45rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .2em;
  color: #7a5a26;
}
.meaning-fields { margin: 0; }
.meaning-field { display: grid; grid-template-columns: 3.2rem 1fr; gap: .5rem; margin: .3rem 0; }
.meaning-field dt {
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: #6b4c1d;
}
.meaning-field dd { margin: 0; font-size: .85rem; line-height: 1.65; color: #3f2f14; }
.meaning-marks {
  margin: .6rem 0 0;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: #a04417;
}

.conclusion-foot {
  display: flex;
  justify-content: center;
  margin-top: auto; /* 免责声明贴到页面底部 */
}

/* 免责声明：贴页面最底部，深墨色 */
.conclusion-disclaimer {
  color: #242018;
}

/* 按钮区：断语卡之后，整体下移（CR-022） */
.conclusion-actions {
  position: relative;
  z-index: 1;
  margin-top: 1.4rem;
  margin-bottom: 1rem;
}
/* 结语页按钮在古纸底上保持可见 */
.conclusion-primary {
  border-color: rgb(90 65 24 / 60%);
  background: linear-gradient(180deg, #8a6420, #6d4d15);
  color: #fff3cf;
}
.conclusion-secondary { color: #3a332a; border-color: rgb(90 65 24 / 55%); background: rgb(255 250 235 / 55%); }

.parchment {
  border-color: rgb(90 65 24 / 38%);
  background: rgb(249 231 176 / 10%);
  backdrop-filter: blur(6px);
  box-shadow: none;
  color: var(--paper-ink);
  text-shadow: 0 1px rgb(255 248 216 / 65%);
}

.parchment .eyebrow,
body[data-state="CONCLUSION"] .topbar .eyebrow { color: #6e4b17; }
.parchment .detail { color: #3d2d17; font-size: 1rem; }
.parchment .disclaimer { color: #4c381b; }

/* 弹窗遮罩：授权、失败提示直接覆盖全屏 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgb(4 6 5 / 66%);
  backdrop-filter: blur(4px);
  animation: fade-in var(--motion-exit) both;
}

.modal-card {
  width: min(92vw, 22rem);
  animation: rise-in var(--motion-enter) both;
}

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; margin-top: 1.2rem; }

.icon-button,
.primary,
.secondary {
  min-height: 2.875rem;
  border-radius: .35rem;
  cursor: pointer;
  transition: transform 120ms ease, background var(--motion-exit), color var(--motion-exit), border-color var(--motion-exit), opacity var(--motion-exit);
}

.icon-button {
  width: 2.25rem;   /* 36px：移动端最小可点尺寸，框不再显大 */
  height: 2.25rem;  /* 固定高=宽：正方框 */
  min-height: 2.25rem;
  display: grid;
  place-items: center; /* 图标在圆角方框内水平+垂直双居中 */
  padding: 0;          /* 去内边距，由 place-items 精确居中 */
  border: 1px solid rgb(223 189 113 / 80%);
  background: rgb(9 12 10 / 42%);
  color: var(--gold-bright);
}

.icon-button svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.55; }
.icon-button[aria-pressed="true"] { border-color: var(--gold-bright); background: rgb(223 189 113 / 17%); color: #ffedb7; }

/* CR-025：排盘界面（古纸浅底）摄像头/声音图标边框改黑色 */
body[data-state="CONCLUSION"] .icon-button,
body[data-state="CONCLUSION"] .icon-button[aria-pressed="true"] { border-color: #1a1208; }

.primary, .secondary { padding: .67rem 1.2rem; font-weight: 600; letter-spacing: .04em; }
.primary { border: 1px solid var(--gold-bright); background: linear-gradient(135deg, #e8c87f, #b6893d); color: #201709; box-shadow: 0 .4rem 1rem rgb(0 0 0 / 25%); }
.secondary { border: 1px solid rgb(224 211 175 / 58%); background: rgb(9 12 10 / 42%); color: #fbf1d7; }
.parchment .secondary { border-color: rgb(72 49 18 / 58%); background: rgb(255 249 223 / 26%); color: #36250f; }

button:hover { border-color: #fff0bd; }
button:active { transform: scale(.97); }
button:focus-visible, summary:focus-visible { outline: 3px solid #fff2c7; outline-offset: 3px; }

.hidden { display: none !important; }
.camera-input, .sr-only { position: fixed; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

@keyframes ke-palace-lock {
  0% { opacity: 0; transform: scale(.62); box-shadow: 0 0 0 rgb(255 210 103 / 0%); }
  52% { opacity: 1; transform: scale(1.24); box-shadow: 0 0 2.2rem rgb(255 210 103 / 92%); }
  100% { opacity: .52; transform: scale(1.08); box-shadow: 0 0 1.2rem rgb(255 210 103 / 58%); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(1.15rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (min-width: 45rem) {
  .topbar { padding-inline: max(2rem, calc((100vw - 42rem) / 2)); }
  .ritual-stage { background-position: center 42%; }
}

@media (orientation: landscape) and (max-height: 34rem) {
  .topbar { min-height: 3rem; }
  main { padding-top: max(3rem, env(safe-area-inset-top)); }
  .orbit-spin { width: min(31vw, 13rem); } /* 太极/金光同心容器统一缩放 */
  .luopan-assembly { left: 25%; top: calc(50% - 27px); width: min(47vw, 22rem); }
  .palace-orbit { --palace-radius: min(16.286vw, 7.62rem); } /* CR-020：横屏随竖屏同比例聚拢 0.9 倍 */
  .card.hud-dock {
    left: 75%;
    width: min(46vw, 27rem);
    bottom: calc(max(.75rem, env(safe-area-inset-bottom)) + 3.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  /* 太极/金光旋转是产品核心视觉（用户明确要求持续旋转），豁免于 reduced-motion 压制 */
  .spin-cw, .spin-ccw { animation-duration: 40s !important; animation-iteration-count: infinite !important; }
  /* CR-022：罗盘内外盘转动同为仪式核心，一并豁免 */
  .sword-rotating .luopan-outer,
  .sword-rotating .luopan-outer-light,
  .sword-rotating .luopan-inner,
  .sword-rotating .luopan-inner-light { animation-duration: 8s !important; animation-iteration-count: infinite !important; }
}
