/* ============================================================
   九品芝麻官 · 视觉系统
   墨底 / 朱砂 / 鎏金 / 宣纸
   ============================================================ */

:root {
  --ink-0: #070605;
  --ink-1: #0d0b09;
  --ink-2: #14100d;
  --ink-3: #1b1512;
  --ink-4: #241c17;

  --gold: #c9a227;
  --gold-lt: #f2dc9b;
  --gold-dp: #8c6f18;
  --red: #a32b22;
  --red-lt: #d4453a;
  --paper: #efe3cb;
  --paper-2: #d9c9a8;
  --muted: rgba(239, 227, 203, 0.52);
  --muted-2: rgba(239, 227, 203, 0.34);
  --line: rgba(201, 162, 39, 0.16);
  --line-2: rgba(201, 162, 39, 0.08);

  --f-display: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "SimSun", serif;
  --f-body: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --f-mono: "Bahnschrift", "DIN Alternate", "Consolas", "SF Mono", monospace;

  --r: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--ink-0);
  color: var(--paper);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 纸纹 + 光晕 */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.32;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 520px at 18% -8%, rgba(163, 43, 34, 0.22), transparent 62%),
    radial-gradient(760px 480px at 92% 4%, rgba(201, 162, 39, 0.14), transparent 60%),
    radial-gradient(900px 700px at 50% 108%, rgba(201, 162, 39, 0.07), transparent 65%);
}

main, header, footer { position: relative; z-index: 1; }

/* ============================================================
   通用
   ============================================================ */

.mono { font-family: var(--f-mono); letter-spacing: 0.02em; }
.gold { color: var(--gold-lt); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  color: var(--paper);
  font-family: var(--f-body);
  font-size: 14px; font-weight: 600; letter-spacing: .06em;
  padding: 12px 22px; border-radius: 10px;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(201,162,39,.45); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn.sm { padding: 9px 16px; font-size: 13px; }
.btn.lg { padding: 15px 30px; font-size: 15px; }
.btn.block { width: 100%; }

.btn.primary {
  background: linear-gradient(145deg, #d9b545, #a8801c 55%, #8c6a15);
  border-color: rgba(242, 220, 155, .5);
  color: #241a03;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(201, 162, 39, .22), inset 0 1px 0 rgba(255,255,255,.45);
}
.btn.primary:hover { box-shadow: 0 14px 34px rgba(201, 162, 39, .34), inset 0 1px 0 rgba(255,255,255,.5); }

.btn.danger {
  background: linear-gradient(145deg, #b8372c, #8a231a);
  border-color: rgba(212, 69, 58, .45);
  color: #ffe9e4;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(163, 43, 34, .26), inset 0 1px 0 rgba(255,255,255,.18);
}

.btn.ghost { background: rgba(255,255,255,.02); }

.btn.primary.evict {
  background: linear-gradient(145deg, #d1503f, #8a231a 55%, #6d1a13);
  border-color: rgba(255, 180, 170, .42);
  color: #ffece6;
  box-shadow: 0 10px 26px rgba(163, 43, 34, .35), inset 0 1px 0 rgba(255,255,255,.22);
}

.panel {
  background:
    linear-gradient(168deg, rgba(38, 30, 24, .92), rgba(16, 13, 11, .96) 62%),
    radial-gradient(600px 200px at 0% 0%, rgba(201,162,39,.06), transparent 70%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.035);
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: ""; position: absolute; inset: 6px;
  border: 1px solid var(--line-2); border-radius: 10px; pointer-events: none;
}

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line-2);
}
.panel-head.tight { padding: 18px 20px 14px; align-items: center; }
.panel-head h3 { font-family: var(--f-display); font-size: 21px; letter-spacing: .12em; font-weight: 700; }
.panel-head p { font-size: 12.5px; color: var(--muted); letter-spacing: .04em; margin-top: 4px; }

.badge {
  font-size: 11px; letter-spacing: .1em; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.02);
}
.badge.gold { color: var(--gold-lt); border-color: rgba(201,162,39,.4); background: rgba(201,162,39,.08); }
.badge.red { color: #ffd4cd; border-color: rgba(212,69,58,.4); background: rgba(163,43,34,.18); }

.hint { font-size: 11.5px; color: var(--muted-2); letter-spacing: .04em; text-align: center; margin-top: 12px; }

/* ============================================================
   顶栏
   ============================================================ */

.topbar {
  max-width: 1320px; margin: 0 auto; padding: 26px 32px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 14px; }
.seal-logo {
  width: 52px; height: 52px;
  filter: drop-shadow(0 6px 14px rgba(163, 43, 34, .35));
  transform: rotate(-3deg);
}
.brand-text h1 { font-family: var(--f-display); font-size: 24px; letter-spacing: .22em; font-weight: 700; }
.brand-text p { font-size: 9.5px; letter-spacing: .34em; color: var(--muted-2); margin-top: 2px; }

.top-right { display: flex; align-items: center; gap: 12px; }
.chip {
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .1em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  background: rgba(255,255,255,.02);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: #5fbf8a; box-shadow: 0 0 10px #5fbf8a; }
.chip.off .dot { background: #8a8378; box-shadow: none; }

/* ============================================================
   HERO
   ============================================================ */

.hero {
  max-width: 1320px; margin: 0 auto; padding: 34px 32px 44px;
  display: grid; grid-template-columns: 1.08fr .92fr; gap: 56px; align-items: center;
}
.kicker {
  display: inline-block; font-size: 11.5px; letter-spacing: .28em; color: var(--gold);
  border-left: 2px solid var(--gold); padding-left: 12px; margin-bottom: 20px;
}
.hero h2 {
  font-family: var(--f-display); font-size: clamp(48px, 5.6vw, 78px);
  line-height: 1.08; letter-spacing: .06em; font-weight: 700;
  text-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.hero h2 .gold {
  background: linear-gradient(180deg, #f7e6b4, #c9a227 70%, #8c6a15);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { margin-top: 22px; font-size: 15px; color: var(--muted); max-width: 30em; line-height: 1.9; }
.hero-actions { display: flex; gap: 12px; margin-top: 30px; }
.hero-meta { display: flex; gap: 12px; margin-top: 26px; font-size: 12px; letter-spacing: .1em; color: var(--muted-2); }
.hero-meta em { color: var(--gold-dp); font-style: normal; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat {
  padding: 20px 20px 18px; border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(38,30,24,.8), rgba(13,11,9,.9));
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 2px;
  background: linear-gradient(180deg, transparent, var(--gold), transparent); opacity: .55;
}
.stat label { display: block; font-size: 11px; letter-spacing: .18em; color: var(--muted-2); }
.stat b { display: block; font-family: var(--f-mono); font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: .02em; }
.stat small { display: block; font-size: 11px; color: var(--muted-2); margin-top: 6px; letter-spacing: .04em; }
.stat b.mono { font-size: 19px; }

/* ============================================================
   BOARD
   ============================================================ */

.board {
  max-width: 1320px; margin: 0 auto; padding: 0 32px 56px;
  display: grid; grid-template-columns: 1fr 384px; gap: 22px; align-items: start;
}

.legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted-2); letter-spacing: .06em; padding-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.lg-gold { background: linear-gradient(90deg, #f2dc9b, #c9a227); }
.lg-dim { background: rgba(239,227,203,.3); }

.ladder-head, .rank-row {
  display: grid;
  grid-template-columns: 1.55fr 1.02fr .88fr 1.08fr .72fr;
  align-items: center; gap: 12px;
}
.ladder-head {
  padding: 14px 24px 10px; font-size: 10.5px; letter-spacing: .18em; color: var(--muted-2);
  border-bottom: 1px solid var(--line-2);
}
.ladder-head .num, .rank-row .num { text-align: right; }

.ladder { padding: 8px 12px 12px; }

.rank-row {
  padding: 13px 12px; border-radius: 9px;
  border: 1px solid transparent;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
  position: relative;
}
.rank-row + .rank-row { margin-top: 2px; }
.rank-row:hover { background: rgba(255,255,255,.028); border-color: var(--line-2); }

.rank-row.is-me {
  background: linear-gradient(90deg, rgba(201,162,39,.12), rgba(201,162,39,.02) 60%, transparent);
  border-color: rgba(201,162,39,.32);
}
.rank-row.is-me::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, #f2dc9b, #c9a227);
  box-shadow: 0 0 14px rgba(201,162,39,.55);
}
.rank-row.is-emperor {
  background: linear-gradient(90deg, rgba(163,43,34,.18), rgba(163,43,34,.03) 60%, transparent);
  border-color: rgba(212,69,58,.3);
}
.rank-row.is-emperor .rank-title strong { color: #ffd9d2; }

.rank-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rank-pin {
  flex: none; width: 40px; height: 40px; border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--f-display); font-size: 13px; line-height: 1.05; text-align: center;
  color: var(--paper-2);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
}
.rank-row.is-me .rank-pin { border-color: rgba(201,162,39,.5); color: var(--gold-lt); background: rgba(201,162,39,.1); }
.rank-row.is-emperor .rank-pin { border-color: rgba(212,69,58,.55); color: #ffd9d2; background: rgba(163,43,34,.18); }
.rank-title strong {
  font-family: var(--f-display); font-size: 17px; letter-spacing: .1em; font-weight: 700; display: block;
}
.me-pill {
  font-style: normal; font-family: var(--f-body); font-size: 9.5px; font-weight: 800;
  letter-spacing: .08em; vertical-align: 2px; margin-left: 8px; padding: 2px 7px;
  border-radius: 999px; color: #2a1e02;
  background: linear-gradient(135deg, #f2dc9b, #c9a227);
  box-shadow: 0 0 14px rgba(201,162,39,.35);
}
.full-pill {
  font-style: normal; font-family: var(--f-body); font-size: 9px; font-weight: 800;
  letter-spacing: .06em; vertical-align: 2px; margin-left: 6px; padding: 1px 6px;
  border-radius: 4px; color: #ffd9d2;
  background: rgba(163,43,34,.55); border: 1px solid rgba(212,69,58,.5);
}
.rank-title small { display: block; font-size: 10.5px; color: var(--muted-2); letter-spacing: .16em; margin-top: 2px; }

.rank-cost, .rank-cum, .rank-holders { font-family: var(--f-mono); font-size: 13.5px; text-align: right; }
.rank-cost { color: var(--paper); }
.rank-cum { color: var(--muted-2); font-size: 12px; }
.rank-holders { color: var(--muted); }
.rank-holders em { font-style: normal; color: var(--muted-2); font-size: 10.5px; margin-left: 1px; }
.rank-holders.full { color: #ff9b8f; }
.rank-holders.full em { color: rgba(255,155,143,.7); }

.rank-quota { display: flex; align-items: center; gap: 10px; }
.quota-track {
  flex: 1; height: 6px; border-radius: 3px; background: rgba(239,227,203,.09); overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(239,227,203,.05);
}
.quota-fill {
  display: block; height: 100%; min-width: 3px; border-radius: 3px;
  background: linear-gradient(90deg, #8c6a15, #c9a227 42%, #f2dc9b);
  box-shadow: 0 0 14px rgba(201,162,39,.65);
}
.quota-val { font-family: var(--f-mono); font-size: 12.5px; color: var(--gold-lt); width: 40px; text-align: right; }

.me-tag {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%) scale(.9);
  font-size: 9.5px; letter-spacing: .12em; color: #2a1e02;
  background: linear-gradient(135deg, #f2dc9b, #c9a227);
  padding: 2px 8px; border-radius: 999px; font-weight: 800;
}
.rank-row.is-me .rank-holders, .rank-row.is-me .rank-cost { padding-right: 0; }

.ladder-foot {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 14px 24px 18px; border-top: 1px solid var(--line-2);
  font-size: 11px; color: var(--muted-2); letter-spacing: .04em;
  flex-wrap: wrap;
}

/* ============================================================
   侧栏
   ============================================================ */

.side { display: flex; flex-direction: column; gap: 18px; }

.me-id { display: flex; align-items: center; gap: 16px; padding: 20px 20px 16px; }

.seal {
  flex: none; width: 66px; height: 66px; border-radius: 9px;
  background: linear-gradient(150deg, #c33a2d, #7d1d16);
  border: 2px solid rgba(255, 220, 200, .32);
  display: grid; grid-template-columns: 1fr 1fr; place-items: center;
  font-family: var(--f-display); font-size: 21px; color: #ffece6; font-weight: 700;
  box-shadow: 0 10px 26px rgba(163, 43, 34, .35), inset 0 0 0 3px rgba(0,0,0,.14);
  transform: rotate(-3deg);
  line-height: 1;
}
.me-rank { font-family: var(--f-display); font-size: 20px; letter-spacing: .1em; font-weight: 700; }
.me-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; letter-spacing: .03em; }

.me-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); margin: 4px 20px 0; border-radius: 8px; overflow: hidden; }
.me-stats > div { background: rgba(13,11,9,.7); padding: 13px 14px; }
.me-stats label { display: block; font-size: 10.5px; letter-spacing: .12em; color: var(--muted-2); }
.me-stats b { font-family: var(--f-mono); font-size: 17px; font-weight: 700; display: inline-block; margin-top: 5px; }
.me-stats i { font-style: normal; font-size: 10px; color: var(--muted-2); margin-left: 5px; letter-spacing: .08em; }

.me-actions { display: flex; flex-direction: column; gap: 9px; padding: 18px 20px 4px; }
.row2 { display: flex; gap: 9px; }
.row2 .btn { flex: 1; padding-left: 10px; padding-right: 10px; font-size: 13px; }

/* 举荐 */
.ref-rows { padding: 14px 20px 6px; display: flex; flex-direction: column; gap: 9px; }
.ref-rows > div { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.ref-rows b { font-weight: 600; color: var(--paper); font-size: 12.5px; }
.ref-bind { display: flex; gap: 8px; padding: 8px 20px 2px; }
.ref-bind input {
  flex: 1; min-width: 0;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 8px;
  color: var(--paper); font-family: var(--f-mono); font-size: 12px;
  padding: 9px 12px; outline: none;
  transition: border-color .18s ease;
}
.ref-bind input::placeholder { color: var(--muted-2); font-family: var(--f-body); }
.ref-bind input:focus { border-color: rgba(201,162,39,.5); }

/* 金銮殿 */
.throne-name {
  text-align: center; font-size: 22px; color: #ffd9d2; letter-spacing: .06em;
  padding: 18px 20px 6px; text-shadow: 0 0 24px rgba(163,43,34,.5);
}
.throne-rows { padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 9px; }
.throne-rows > div { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.throne-rows b { font-family: var(--f-mono); color: var(--paper); font-weight: 600; }
.throne-panel .btn { margin: 0 20px 4px; width: calc(100% - 40px); }

/* ============================================================
   FLOW
   ============================================================ */

.flow {
  max-width: 1320px; margin: 0 auto; padding: 0 32px 64px;
  display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 18px; align-items: center;
}
.flow-step {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 26px 24px; background: linear-gradient(160deg, rgba(38,30,24,.55), rgba(13,11,9,.7));
}
.flow-num { font-family: var(--f-display); font-size: 13px; color: var(--gold); letter-spacing: .3em; margin-bottom: 10px; }
.flow-step h4 { font-family: var(--f-display); font-size: 19px; letter-spacing: .12em; margin-bottom: 8px; }
.flow-step p { font-size: 12.5px; color: var(--muted); line-height: 1.85; }
.flow-arrow { color: var(--gold-dp); font-size: 20px; }

/* ============================================================
   RULES
   ============================================================ */

.rules { max-width: 1320px; margin: 0 auto; padding: 0 32px 56px; }
.rules-title {
  font-family: var(--f-display); font-size: 30px; letter-spacing: .3em; text-align: center;
  margin-bottom: 32px; color: var(--paper);
}
.rules-title::after {
  content: ""; display: block; width: 60px; height: 1px; margin: 16px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.rule-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.rule {
  border: 1px solid var(--line); border-radius: var(--r); padding: 28px 24px;
  background: linear-gradient(165deg, rgba(38,30,24,.6), rgba(13,11,9,.75));
  position: relative;
}
.rule-icon {
  width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--f-display); font-size: 19px; color: var(--gold-lt);
  border: 1px solid rgba(201,162,39,.3); background: rgba(201,162,39,.06);
  margin-bottom: 16px;
}
.rule h4 { font-family: var(--f-display); font-size: 20px; letter-spacing: .12em; margin-bottom: 10px; }
.rule p { font-size: 13px; color: var(--muted); line-height: 1.9; }
.rule-note {
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line-2);
  font-size: 11.5px; color: var(--gold-dp); letter-spacing: .04em;
}

.risk {
  max-width: 1320px; margin: 0 auto 40px; padding: 22px 26px;
  border: 1px solid rgba(212,69,58,.2); border-radius: var(--r);
  background: rgba(163,43,34,.07);
}
.risk h4 { font-size: 12px; letter-spacing: .2em; color: #ffb3a8; margin-bottom: 8px; }
.risk p { font-size: 12px; color: var(--muted); line-height: 1.9; }

footer {
  max-width: 1320px; margin: 0 auto; padding: 28px 32px 44px;
  display: flex; justify-content: space-between; gap: 16px;
  border-top: 1px solid var(--line-2);
  font-size: 11.5px; color: var(--muted-2); letter-spacing: .08em;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast-wrap { position: fixed; right: 24px; bottom: 24px; z-index: 99; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 380px; padding: 14px 18px; border-radius: 10px;
  background: rgba(24, 18, 15, .96); border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  font-size: 13px; color: var(--paper);
  animation: toastIn .28s cubic-bezier(.2,.9,.3,1.3);
}
.toast.ok { border-color: rgba(95,191,138,.45); }
.toast.err { border-color: rgba(212,69,58,.5); }
.toast small { display: block; color: var(--muted-2); font-size: 11px; margin-top: 4px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 1120px) {
  .hero { grid-template-columns: 1fr; gap: 36px; }
  .board { grid-template-columns: 1fr; }
  .side { position: static; }
  .rule-grid { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); justify-self: center; }
}

@media (max-width: 720px) {
  .topbar, .hero, .board, .flow, .rules, footer { padding-left: 18px; padding-right: 18px; }
  .ladder-head, .rank-row { grid-template-columns: 1.4fr 1fr .9fr; }
  .ladder-head span:nth-child(3), .rank-cum { display: none; }
  .rank-quota { grid-column: 1 / -1; margin-top: 6px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hero h2 { font-size: 42px; }
}
