/* ============================================================
 * 玄机阁 — 姻缘天机测算
 * 暗黑国风 / 黑金配色
 * ============================================================ */

:root {
  --ink: #07050a;
  --ink2: #100b12;
  --ink3: #171018;
  --gold: #e9c97c;
  --gold-2: #c9a44c;
  --gold-3: #8a6b28;
  --jade: #7fc8ae;
  --red: #c2453f;
  --paper: #e7dcc0;
  --text: #d8cdb4;
  --dim: #8d8270;
  --line: rgba(201, 164, 76, .28);
  --line-soft: rgba(201, 164, 76, .14);
  --font-kai: "STKaiti", "KaiTi", "Kaiti SC", "STSong", "Songti SC", "SimSun", "Noto Serif CJK SC", serif;
  --font-song: "STZhongsong", "STSong", "Songti SC", "SimSun", "Noto Serif CJK SC", serif;
  --font-sym: "Segoe UI Symbol", "Noto Sans Symbols", "Noto Sans Symbols 2", "Symbola", serif;
}

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

html, body { height: 100%; }

body {
  min-height: 100%;
  font-family: var(--font-kai);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #241726 0%, transparent 60%),
    radial-gradient(900px 600px at 12% 100%, #12202a 0%, transparent 62%),
    radial-gradient(800px 500px at 92% 82%, #2a1420 0%, transparent 60%),
    linear-gradient(180deg, #0a0709 0%, #07050a 55%, #050406 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 星空 & 光晕 ---------------- */
.stars { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.stars i {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: #f3e2b0;
  opacity: .5;
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: .12; transform: scale(.6); }
  50% { opacity: .95; transform: scale(1.25); }
}

.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(circle at 50% 42%, transparent 30%, rgba(4, 2, 6, .72) 100%);
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 46px);
}
.brand {
  font-family: var(--font-song);
  font-size: 22px; letter-spacing: .5em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(233, 201, 124, .45);
}
.topbar nav { display: flex; gap: 10px; }
.ghost-btn {
  font-family: var(--font-kai);
  font-size: 14px; letter-spacing: .18em;
  color: var(--gold-2);
  background: rgba(201, 164, 76, .05);
  border: 1px solid var(--line);
  padding: 8px 16px; border-radius: 2px;
  cursor: pointer;
  transition: .25s;
}
.ghost-btn:hover { color: #fff3d2; border-color: var(--gold-2); background: rgba(201, 164, 76, .14); box-shadow: 0 0 18px rgba(201, 164, 76, .2); }

/* ---------------- 主体 ---------------- */
.stage {
  position: relative; z-index: 2;
  max-width: 780px; margin: 0 auto;
  padding: 10px clamp(14px, 4vw, 24px) 60px;
  display: flex; flex-direction: column; align-items: center;
}

.title {
  font-family: var(--font-song);
  font-size: clamp(30px, 6.4vw, 52px);
  letter-spacing: .22em;
  font-weight: 400;
  background: linear-gradient(180deg, #fff6d8 0%, #f0d590 42%, #b98f34 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 24px rgba(233, 201, 124, .35));
  animation: glowPulse 4.5s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(233, 201, 124, .28)); }
  50% { filter: drop-shadow(0 0 34px rgba(233, 201, 124, .55)); }
}

.subtitle {
  margin-top: 12px;
  font-size: 13px; letter-spacing: .34em; color: var(--dim);
  text-align: center;
}
.rule {
  margin: 18px 0 6px;
  width: 260px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-3), transparent);
}

/* ---------------- 罗盘 ---------------- */
.compass-wrap {
  position: relative;
  width: min(78vw, 460px); aspect-ratio: 1;
  margin: 10px 0 4px;
  display: grid; place-items: center;
}
.compass { position: absolute; inset: 0; }
.compass svg { width: 100%; height: 100%; display: block; }

.ring { transform-origin: 300px 300px; }
.ring-64 { animation: spin 150s linear infinite; }
.ring-8 { animation: spinRev 70s linear infinite; }
.ring-zhi { animation: spin 100s linear infinite; }
.taiji { transform-origin: 300px 300px; animation: spin 46s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinRev { to { transform: rotate(-360deg); } }

.compass.spinning .ring-64 { animation-duration: 3s; }
.compass.spinning .ring-8 { animation-duration: 2s; }
.compass.spinning .ring-zhi { animation-duration: 2.4s; }
.compass.spinning .taiji { animation-duration: 1.4s; }

.compass-core {
  position: relative; z-index: 2;
  width: 88px; height: 88px;
  border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle at 50% 42%, rgba(22, 15, 24, .95), rgba(8, 5, 10, .98));
  border: 1px solid rgba(201, 164, 76, .55);
  box-shadow: 0 0 30px rgba(201, 164, 76, .25), inset 0 0 24px rgba(0, 0, 0, .9);
}
.core-hex {
  font-family: var(--font-sym);
  font-size: 36px; line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(233, 201, 124, .7);
  transition: .4s;
}
.core-label { margin-top: 6px; font-size: 11px; letter-spacing: .18em; color: var(--dim); }

/* ---------------- 表单 ---------------- */
.panel {
  width: 100%; max-width: 520px;
  margin-top: 8px; padding: 26px clamp(18px, 4vw, 30px) 24px;
  background: linear-gradient(180deg, rgba(24, 17, 26, .78), rgba(11, 8, 13, .86));
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55), inset 0 0 40px rgba(201, 164, 76, .04);
  backdrop-filter: blur(6px);
}
.panel-head {
  text-align: center; font-size: 13px; letter-spacing: .3em; color: var(--gold-2);
  padding-bottom: 18px; margin-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.input-group { margin-bottom: 18px; }
.input-group label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; letter-spacing: .22em; color: var(--gold-2); margin-bottom: 8px;
}
.input-group label b {
  font-weight: 400; font-family: var(--font-sym); font-size: 15px; color: var(--gold);
}
.input-group input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-kai); font-size: 17px; letter-spacing: .12em;
  color: #fff5dc;
  background: rgba(255, 246, 220, .035);
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  transition: .25s;
}
.input-group input::placeholder { color: #6c6252; letter-spacing: .1em; font-size: 15px; }
.input-group input:focus {
  border-color: var(--gold-2);
  background: rgba(255, 246, 220, .07);
  box-shadow: 0 0 0 1px rgba(201, 164, 76, .25), 0 0 26px rgba(201, 164, 76, .22);
}
.input-group.err input { border-color: var(--red); box-shadow: 0 0 20px rgba(194, 69, 63, .28); }

.btn-primary {
  position: relative;
  width: 100%; margin-top: 6px; padding: 15px;
  font-family: var(--font-song); font-size: 19px; letter-spacing: .5em; text-indent: .5em;
  color: #1a1207;
  background: linear-gradient(180deg, #f6e0a4 0%, #d9b45f 48%, #a97e2c 100%);
  border: none; border-radius: 2px; cursor: pointer;
  box-shadow: 0 8px 30px rgba(201, 164, 76, .28);
  overflow: hidden;
  transition: .25s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(233, 201, 124, .45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: wait; transform: none; }
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-20deg);
  animation: sweep 3.6s ease-in-out infinite;
}
@keyframes sweep { 0% { left: -120%; } 55%, 100% { left: 160%; } }

.tip { min-height: 20px; margin-top: 12px; text-align: center; font-size: 13px; letter-spacing: .1em; color: var(--red); }

.history { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.history:empty { display: none; }
.history .chip {
  font-size: 12px; letter-spacing: .08em; color: var(--gold-2);
  border: 1px solid var(--line-soft); border-radius: 20px;
  padding: 5px 12px; cursor: pointer;
  background: rgba(201, 164, 76, .05);
  transition: .2s;
}
.history .chip:hover { color: #fff3d2; border-color: var(--gold-2); background: rgba(201, 164, 76, .14); }

.footer {
  position: relative; z-index: 2;
  margin-top: 34px; text-align: center;
  font-size: 12px; line-height: 2; letter-spacing: .12em; color: #6b6255;
}

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4, 2, 6, .78);
  backdrop-filter: blur(6px);
}
.modal.open { display: flex; animation: fadeIn .28s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  padding: 30px clamp(18px, 4vw, 34px) 26px;
  background: linear-gradient(180deg, #1b1320 0%, #0d0910 100%);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .8), inset 0 0 60px rgba(201, 164, 76, .05);
  animation: riseIn .38s cubic-bezier(.2, .8, .3, 1);
}
@keyframes riseIn { from { opacity: 0; transform: translateY(26px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-card::-webkit-scrollbar { width: 6px; }
.modal-card::-webkit-scrollbar-thumb { background: var(--gold-3); border-radius: 3px; }
.modal-card::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }

.close {
  position: absolute; top: 10px; right: 14px;
  width: 32px; height: 32px; line-height: 28px; text-align: center;
  font-size: 24px; color: var(--gold-3);
  background: none; border: none; cursor: pointer; transition: .2s;
}
.close:hover { color: var(--gold); transform: rotate(90deg); }

.m-title { text-align: center; font-family: var(--font-song); font-size: 22px; letter-spacing: .3em; color: var(--gold); }
.m-sub { text-align: center; margin-top: 8px; font-size: 12px; letter-spacing: .2em; color: var(--dim); }

/* 结果头部 */
.r-head { display: flex; align-items: center; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.r-symbol { font-family: var(--font-sym); font-size: 60px; line-height: 1; color: var(--gold); text-shadow: 0 0 26px rgba(233, 201, 124, .55); }
.r-title { flex: 1; min-width: 0; }
.r-name { font-family: var(--font-song); font-size: 27px; letter-spacing: .16em; color: #fff2d4; }
.r-meta { margin-top: 6px; font-size: 12px; letter-spacing: .16em; color: var(--dim); }

.r-score { position: relative; width: 108px; height: 108px; flex: none; display: grid; place-items: center; }
.r-score svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.r-score .bg { fill: none; stroke: rgba(201, 164, 76, .16); stroke-width: 7; }
.r-score .fg { fill: none; stroke: url(#scoreGrad); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.2, .8, .3, 1); }
.score-num { font-family: var(--font-song); font-size: 34px; color: var(--gold); line-height: 1; }
.score-num i { font-size: 13px; font-style: normal; color: var(--dim); margin-left: 2px; }
.score-tag { position: absolute; bottom: -6px; font-size: 12px; letter-spacing: .16em; color: var(--gold-2); }

.r-couple {
  margin: 16px 0 4px; text-align: center;
  font-size: 15px; letter-spacing: .2em; color: #f0e2bd;
}
.r-couple small { display: block; margin-top: 6px; font-size: 11px; letter-spacing: .12em; color: var(--dim); }

/* 六爻图 */
.r-lines { margin: 14px auto 4px; width: 210px; display: flex; flex-direction: column; gap: 9px; }
.yline { position: relative; height: 13px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.yline .bar { flex: 1; background: linear-gradient(90deg, #8a6b28, #f0d68a, #8a6b28); box-shadow: 0 0 12px rgba(233, 201, 124, .35); height: 7px; border-radius: 1px; }
.yline.yin .bar { background: none; box-shadow: none; height: 7px; }
.yline.yin .bar::before, .yline.yin .bar::after {
  content: ""; display: block; width: 44%; height: 7px; background: linear-gradient(90deg, #8a6b28, #e6cd8b, #8a6b28); box-shadow: 0 0 10px rgba(233, 201, 124, .3); border-radius: 1px;
}
.yline.yin .bar { display: flex; justify-content: space-between; }
.yline .idx { position: absolute; left: -30px; font-size: 11px; color: var(--dim); font-family: var(--font-song); }
.yline .mark { position: absolute; right: -30px; font-size: 15px; color: var(--red); text-shadow: 0 0 12px rgba(194, 69, 63, .8); }
.yline.moving .bar { filter: brightness(1.4); }

/* 结果格子 */
.r-grid { margin-top: 18px; display: grid; gap: 12px; }
.r-cell {
  padding: 14px 16px;
  background: rgba(255, 246, 220, .035);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--gold-3);
  border-radius: 2px;
}
.r-cell h4 {
  font-family: var(--font-song); font-size: 14px; font-weight: 400;
  letter-spacing: .26em; color: var(--gold-2); margin-bottom: 8px;
}
.r-cell p { font-size: 15px; line-height: 1.95; color: var(--paper); letter-spacing: .04em; }
.r-cell.quote p { font-family: var(--font-song); font-size: 16px; color: #f7e9c4; }
.r-cell.hl { border-left-color: var(--red); background: rgba(194, 69, 63, .08); }
.r-cell.hl h4 { color: #e7968f; }
.r-cell.hl p { color: #ffe9d6; }
.r-cell.jade { border-left-color: var(--jade); }
.r-cell.jade h4 { color: var(--jade); }

.r-change {
  margin-top: 14px; padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 2px;
  font-size: 14px; line-height: 1.9; color: #cdbf9e;
}
.r-change b { font-family: var(--font-song); color: var(--gold); font-weight: 400; letter-spacing: .1em; }

.r-actions { margin-top: 20px; display: flex; gap: 12px; }
.r-actions button {
  flex: 1; padding: 12px;
  font-family: var(--font-kai); font-size: 15px; letter-spacing: .22em;
  color: var(--gold-2); background: rgba(201, 164, 76, .06);
  border: 1px solid var(--line); border-radius: 2px; cursor: pointer; transition: .25s;
}
.r-actions button:hover { color: #fff3d2; border-color: var(--gold-2); background: rgba(201, 164, 76, .16); }
.r-actions button.solid { color: #1a1207; background: linear-gradient(180deg, #f0d68a, #b98f34); border-color: transparent; }
.r-actions button.solid:hover { filter: brightness(1.12); color: #1a1207; }

/* 典籍 */
.codex-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.codex-item {
  padding: 10px 4px; text-align: center; cursor: pointer;
  border: 1px solid var(--line-soft); border-radius: 2px;
  background: rgba(255, 246, 220, .03);
  transition: .2s;
}
.codex-item:hover { border-color: var(--gold-2); background: rgba(201, 164, 76, .13); transform: translateY(-2px); }
.codex-item .c-sym { font-family: var(--font-sym); font-size: 24px; color: var(--gold); line-height: 1.2; }
.codex-item .c-no { font-size: 10px; color: var(--dim); letter-spacing: .06em; }
.codex-item .c-name { font-size: 12px; color: #d8cdb4; letter-spacing: .04em; }
.codex-item .c-luck { font-size: 10px; margin-top: 2px; }
.lk1 { color: #f0c46a; }  /* 上上 上吉 */
.lk2 { color: #9fd3bb; }  /* 中吉 */
.lk3 { color: #b3aa97; }  /* 中平 */
.lk4 { color: #d98b85; }  /* 下下 */

.codex-search {
  width: 100%; margin-top: 16px; padding: 10px 14px;
  font-family: var(--font-kai); font-size: 15px; color: #fff5dc;
  background: rgba(255, 246, 220, .04); border: 1px solid var(--line);
  border-radius: 2px; outline: none;
}
.codex-search:focus { border-color: var(--gold-2); box-shadow: 0 0 20px rgba(201, 164, 76, .2); }

/* 起卦法 */
.method-body { margin-top: 18px; font-size: 15px; line-height: 2.05; color: var(--paper); }
.method-body h5 { font-family: var(--font-song); font-weight: 400; font-size: 15px; letter-spacing: .24em; color: var(--gold-2); margin: 18px 0 6px; }
.method-body ul { margin-left: 18px; }
.method-body code {
  font-family: var(--font-sym); color: var(--gold); font-size: 16px;
  background: rgba(201, 164, 76, .1); padding: 0 4px; border-radius: 2px;
}
.disclaim { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 12px; line-height: 1.9; color: #7b7263; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 560px) {
  .brand { font-size: 18px; letter-spacing: .35em; }
  .r-head { flex-wrap: wrap; justify-content: center; text-align: center; }
  .r-title { text-align: center; }
  .r-score { margin: 0 auto; }
  .r-symbol { font-size: 48px; }
  .r-lines { width: 170px; }
  .codex-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}
