:root {
  --ink: #121010;
  --ink-2: #1b1816;
  --paper: #e9dfcc;
  --paper-dim: #b9ad98;
  --muted: #8a7f70;
  --line: #3a332c;
  --cinnabar: #c0392b;
  --cinnabar-2: #e0533f;
  --gold: #c9a45c;
  --jade: #5f9a6b;
  --water: #4f7fa8;
  --card: rgba(30, 26, 23, .82);
  --radius: 14px;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", var(--serif);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--ink); color: var(--paper);
  font-family: var(--serif); line-height: 1.65; font-size: 16px;
  background-image: radial-gradient(ellipse at 50% -10%, rgba(192, 57, 43, .16), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(201, 164, 92, .08), transparent 60%);
  background-attachment: fixed;
}
.bg-compass { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 0; color: var(--gold); opacity: .07; }
.bg-compass svg { width: min(130vw, 900px); animation: spin 240s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bg-compass svg { animation: none; } }

header.top, nav.modes, main, footer { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 0 16px; }
header.top { display: flex; align-items: center; gap: 16px; padding-top: 32px; padding-bottom: 8px; }
.seal {
  flex: none; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 8px;
  background: var(--cinnabar); color: #f6e9d6; font-family: var(--kai); font-size: 24px; letter-spacing: 2px;
  flex-direction: column; line-height: 1.05; box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 5px #f3d9c6; transform: rotate(-4deg);
}
.brand h1 { margin: 0; font-family: var(--kai); font-weight: 400; font-size: 30px; letter-spacing: 6px; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; letter-spacing: 2px; }

.step { margin: 28px 0; transition: opacity .4s; }
.step.locked { opacity: .28; pointer-events: none; filter: grayscale(.6); }
.step h2 { font-family: var(--kai); font-weight: 400; font-size: 22px; margin: 0 0 12px; letter-spacing: 4px; display: flex; align-items: center; gap: 10px; }
.num { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--cinnabar); color: var(--cinnabar-2); border-radius: 50%; font-size: 16px; letter-spacing: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; backdrop-filter: blur(4px); }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.row > label { flex: 1 1 200px; }
.row.three > label { flex: 1 1 80px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--paper-dim); }
label em { font-style: normal; color: var(--muted); font-size: 12px; }
label.leap { flex-direction: row; align-items: center; flex: 0 0 auto; align-self: flex-end; padding-bottom: 10px; }
input, select {
  font: inherit; color: var(--paper); background: #0e0c0b; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0; outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
input[type=checkbox] { width: auto; }
.adv { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.adv summary { cursor: pointer; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.btn { font: inherit; cursor: pointer; border-radius: 999px; padding: 10px 22px; border: 1px solid var(--line); background: transparent; color: var(--paper); letter-spacing: 2px; transition: transform .15s, background .2s, border-color .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff4e6; }
.btn.primary:hover { background: var(--cinnabar-2); }
.btn.ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn.big { font-size: 20px; padding: 14px 40px; font-family: var(--kai); letter-spacing: 6px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* 命 摘要 */
.ming { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.pillars { display: flex; gap: 10px; }
.pillar { text-align: center; }
.pillar small { display: block; color: var(--muted); font-size: 12px; }
.pillar .gz { font-family: var(--kai); font-size: 26px; line-height: 1.25; display: flex; flex-direction: column; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #0e0c0b; }
.pillar.day .gz { border-color: var(--cinnabar); color: #ffe7d6; }
.pillar .ss { color: var(--gold); font-size: 12px; }
.ming-meta { font-size: 14px; color: var(--paper-dim); }
.ming-meta b { color: var(--paper); }
.wx-bar { display: flex; gap: 4px; margin-top: 6px; }
.wx-bar span { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #0e0c0b; border: 1px solid var(--line); }
.linkish { background: none; border: 0; color: var(--gold); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }

/* 问 */
.group { margin-bottom: 10px; }
.group h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 14px; cursor: pointer; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #0e0c0b; color: var(--paper-dim); }
.chip:hover { border-color: var(--gold); }
.chip.on { background: var(--gold); border-color: var(--gold); color: #1a1410; }
.custom { margin-top: 12px; flex-wrap: nowrap; }
.custom input { flex: 1; }
.custom .btn { flex: none; }
.tf { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.tf button { font: inherit; font-size: 14px; background: none; border: 0; color: var(--paper-dim); padding: 6px 16px; cursor: pointer; }
.tf button.on { background: var(--cinnabar); color: #fff4e6; }
.question { font-family: var(--kai); font-size: 18px; color: var(--gold); margin: 14px 0 0; min-height: 1.6em; }

/* 起卦方法 */
.methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.method { font: inherit; color: var(--paper); cursor: pointer; text-align: center; padding: 18px 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; align-items: center; gap: 2px; transition: border-color .2s, transform .2s; }
.method:hover { border-color: var(--gold); transform: translateY(-2px); }
.method.on { border-color: var(--cinnabar); box-shadow: 0 0 0 1px var(--cinnabar) inset; }
.m-ico { font-size: 28px; color: var(--gold); line-height: 1.2; }
.method b { font-family: var(--kai); font-weight: 400; font-size: 19px; letter-spacing: 3px; }
.method small { color: var(--muted); font-size: 12px; }
@media (max-width: 480px) { .methods { gap: 6px; } .method { padding: 14px 4px; } .method b { font-size: 16px; letter-spacing: 1px; } }

.ritual { text-align: center; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.ritual .say { font-family: var(--kai); color: var(--paper-dim); font-size: 17px; margin: 0; }
.ritual .say b { color: var(--gold); font-weight: 400; }

/* 铜钱 */
.coins { display: flex; gap: 18px; justify-content: center; perspective: 600px; height: 92px; align-items: center; }
.coin { width: 74px; height: 74px; position: relative; transform-style: preserve-3d; transition: transform .2s; }
.coin .face { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; backface-visibility: hidden;
  background: radial-gradient(circle at 35% 30%, #e7c97c, #a7802f 60%, #6e5320); box-shadow: inset 0 0 0 4px #8a6a28, inset 0 0 0 6px #d8b866, 0 6px 14px rgba(0,0,0,.5); }
.coin .face::after { content: ""; position: absolute; width: 18px; height: 18px; background: var(--ink-2); box-shadow: inset 0 0 0 2px #8a6a28; }
.coin .face span { position: absolute; font-family: var(--kai); font-size: 14px; color: #3d2c10; }
.coin .face span:nth-child(1) { top: 9px; } .coin .face span:nth-child(2) { bottom: 9px; } .coin .face span:nth-child(3) { left: 11px; } .coin .face span:nth-child(4) { right: 11px; }
.coin .back { transform: rotateY(180deg); background: radial-gradient(circle at 35% 30%, #cdb06a, #8c6a25 60%, #5a431a); }
.coin .back span { font-size: 18px !important; }
.coin.spin { animation: coinspin .9s cubic-bezier(.2,.7,.3,1) both; }
@keyframes coinspin { 0% { transform: translateY(0) rotateY(0) rotateX(0); } 40% { transform: translateY(-60px) rotateY(900deg) rotateX(40deg); } 100% { transform: translateY(0) rotateY(var(--end)) rotateX(0); } }
.coin.landed { transform: rotateY(var(--end)); }
.toss-log { font-size: 13px; color: var(--muted); min-height: 1.4em; }

/* 卦画 */
.hex { display: inline-flex; flex-direction: column-reverse; gap: 7px; padding: 6px 0; }
.yao { display: flex; gap: 12px; align-items: center; width: 120px; height: 12px; position: relative; animation: rise .5s ease both; }
.yao i { flex: 1; height: 100%; background: var(--paper); border-radius: 2px; }
.yao.yin i:first-child { margin-right: 10px; }
.yao.mv i { background: var(--cinnabar-2); box-shadow: 0 0 10px rgba(224, 83, 63, .6); }
.yao.mv::after { position: absolute; right: -22px; color: var(--cinnabar-2); font-size: 13px; content: "○"; }
.yao.yin.mv::after { content: "×"; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scaleX(.6); } to { opacity: 1; transform: none; } }
.hex.small .yao { width: 64px; height: 7px; gap: 7px; } .hex.small { gap: 4px; }
.hex.small .yao.mv::after { right: -16px; font-size: 11px; }

/* 梅花 */
.steps-log { text-align: left; font-size: 14px; color: var(--paper-dim); max-width: 520px; }
.steps-log p { margin: 4px 0; animation: rise .6s both; }
.num-inputs { display: flex; gap: 10px; justify-content: center; }
.num-inputs input { width: 110px; text-align: center; font-size: 22px; font-family: var(--kai); }

/* 签筒 */
.tube { position: relative; width: 110px; height: 150px; margin-top: 40px; }
.tube .body { position: absolute; bottom: 0; left: 0; right: 0; height: 110px; border-radius: 10px 10px 18px 18px; background: linear-gradient(90deg, #5a2a1e, #8c3b26 45%, #5a2a1e); box-shadow: inset 0 0 0 2px #b9874a; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; font-family: var(--kai); color: #f2d8a0; font-size: 22px; z-index: 2; }
.tube .stick { position: absolute; bottom: 60px; width: 10px; height: 100px; background: linear-gradient(#e8d2a2, #c9a45c); border-radius: 3px; z-index: 1; }
.tube .stick.out { z-index: 3; animation: stickout .8s ease-out both; display: grid; place-items: start center; }
.tube .stick.out::before { content: ""; width: 10px; height: 18px; background: var(--cinnabar); border-radius: 3px 3px 0 0; }
@keyframes stickout { to { transform: translateY(-48px) rotate(-8deg); } }
.tube.shake { animation: shake .15s linear 10; }
@keyframes shake { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) translateY(-4px); } }
.lot-paper { font-family: var(--kai); background: #efe4cc; color: #2a1d12; padding: 14px 22px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: rise .6s both; }
.lot-paper b { color: var(--cinnabar); font-weight: 400; font-size: 24px; letter-spacing: 4px; }

/* 信号卡 */
.signal { background: linear-gradient(180deg, #221d19, #171412); border: 1px solid #4a3f34; border-radius: 18px; padding: 20px; position: relative; overflow: hidden; }
.signal::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(201,164,92,.25); border-radius: 13px; pointer-events: none; }
.sig-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sig-head h3 { margin: 0; font-family: var(--kai); font-weight: 400; font-size: 26px; letter-spacing: 3px; }
.sig-head .meta { color: var(--muted); font-size: 13px; }
.price { font-size: 20px; color: var(--paper); font-variant-numeric: tabular-nums; }
.verdict { margin: 16px 0; display: flex; gap: 16px; align-items: center; }
.verdict .stamp-wrap { flex: none; text-align: center; font-size: 11px; color: var(--muted); }
.verdict .stamp { flex: none; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-family: var(--kai); font-size: 34px; border: 3px double currentColor; transform: rotate(-12deg); animation: stamp .5s cubic-bezier(.3,1.6,.5,1) both .2s; }
@keyframes stamp { from { transform: scale(2.2) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(-12deg); opacity: 1; } }
.stamp.ji { color: var(--cinnabar-2); } .stamp.ping { color: var(--gold); } .stamp.xiong { color: #7e8b99; }
.verdict .say { font-size: 17px; }
.verdict .say b { font-family: var(--kai); font-weight: 400; font-size: 21px; display: block; color: var(--paper); }
.tri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 600px) { .tri { grid-template-columns: 1fr; } }
.cell { background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; color: var(--paper-dim); }
.cell h4 { margin: 0 0 6px; font-family: var(--kai); font-weight: 400; font-size: 18px; color: var(--gold); letter-spacing: 4px; display: flex; justify-content: space-between; }
.cell h4 .score { font-family: var(--serif); font-size: 13px; letter-spacing: 0; color: var(--muted); }
.cell .big { font-size: 17px; color: var(--paper); }
.hexes { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.hexes .arrow { color: var(--muted); margin-left: 14px; }
.hexes figure { margin: 0; text-align: center; font-size: 12px; }
.plan { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan div { background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.plan b { display: block; font-size: 16px; color: var(--paper); font-variant-numeric: tabular-nums; }
.plan .stop b { color: #9fb0c2; } .plan .tp b { color: var(--cinnabar-2); }
.sizing { margin-top: 12px; font-size: 14px; color: var(--paper-dim); }
.sizing .row { margin: 8px 0; }
.sizing .row label { flex: 1 1 120px; }
.warn { color: #e0a24f; font-size: 13px; }
canvas.chart { width: 100%; height: 200px; margin-top: 14px; display: block; border-radius: 10px; background: rgba(0,0,0,.25); }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.legend i { display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; justify-content: center; }
.err { color: #e0a24f; }
.loading { text-align: center; color: var(--muted); padding: 30px; font-family: var(--kai); font-size: 18px; }
.loading::after { content: "…"; animation: dots 1.2s steps(3) infinite; }

footer { color: var(--muted); font-size: 12px; text-align: center; padding-bottom: 40px; }
footer p { margin: 4px 0; }

nav.modes { display: flex; gap: 0; margin-top: 12px; }
nav.modes button { font: inherit; font-family: var(--kai); font-size: 16px; letter-spacing: 2px; cursor: pointer; flex: 1; max-width: 180px; padding: 8px 0; background: none; color: var(--muted); border: 0; border-bottom: 2px solid var(--line); }
nav.modes button.on { color: var(--paper); border-bottom-color: var(--cinnabar); }
.tf button[disabled] { opacity: .35; cursor: not-allowed; }
.tri.solo { grid-template-columns: 1fr; }
