/* PC28 挂机规则战绩榜
 * 方向：纸上账本 / 深松绿报头 / 黄铜分隔线。
 * 目标：手机一屏能扫更多规则；数据用等宽数字，规则用窄行，不堆卡片。
 */
:root {
  --mist: #e9ede7;
  --paper: #f8f9f4;
  --ink: #15221c;
  --muted: #68756e;
  --faint: #8a968e;
  --line: #d4dbd3;
  --line-strong: #b9c3b9;
  --pine: #0f6b50;
  --pine-soft: #e2eee7;
  --oxide: #b7432e;
  --oxide-soft: #f3e4df;
  --brass: #b58b3a;
  --masthead: #14251e;
  --masthead-ink: #eef2e9;
  --masthead-muted: #9aa99d;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", Menlo, Consolas, monospace;
  --pad: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, #dfe5de 0, var(--mist) 240px);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
.page { max-width: 980px; margin: 0 auto; }

/* ── 报头 ─────────────────────────────── */
.masthead {
  position: relative;
  padding: 16px var(--pad) 0;
  background: var(--masthead);
  color: var(--masthead-ink);
  border-bottom: 3px solid var(--brass);
  overflow: hidden;
}
.masthead::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 49.7%, rgba(238,242,233,.06) 49.7% 50.3%, transparent 50.3%),
    radial-gradient(480px 220px at 82% 0, rgba(181,139,58,.13), transparent 68%);
}
.topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 26px;
}
.wordmark {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .10em;
  color: var(--masthead-ink);
}
.wordmark .slash { color: var(--brass); padding: 0 3px; }
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .03em;
  color: var(--masthead-muted);
}
.live-pill i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7fcf9d;
  box-shadow: 0 0 0 3px rgba(127,207,157,.12);
}
.live-pill.is-error { color: #f0b3a4; }
.live-pill.is-error i { background: #e1785e; }
.live-pill.is-loading i { background: var(--brass); animation: pulse 1.1s ease infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(238,242,233,.22);
  border-radius: 50%;
  color: var(--masthead-ink);
  background: transparent;
}
.icon-btn:hover { border-color: var(--brass); color: var(--brass); }
.icon-btn.is-loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.masthead-main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .13em;
  color: var(--brass);
  margin-bottom: 6px;
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(30px, 7.4vw, 48px);
  line-height: .98;
  letter-spacing: -.035em;
  color: var(--masthead-ink);
}
.dek {
  max-width: 530px;
  margin: 9px 0 0;
  color: var(--masthead-muted);
  font-size: 12px;
  line-height: 1.6;
}
.mock-tag {
  flex: none;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  padding: 4px 7px;
  color: #f0d28f;
  border: 1px solid rgba(181,139,58,.55);
}

.tape {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: .72fr 1.2fr 1.2fr;
  margin-top: 12px;
  border-top: 1px solid rgba(238,242,233,.16);
  border-bottom: 1px solid rgba(238,242,233,.16);
}
.tape-cell {
  min-width: 0;
  padding: 10px 10px 11px 0;
  border-right: 1px solid rgba(238,242,233,.12);
}
.tape-cell:last-child { border-right: 0; padding-left: 12px; }
.tape-cell:nth-child(2) { padding-left: 12px; }
.tape-cell b {
  display: block;
  font-family: var(--mono);
  font-size: clamp(17px, 4.2vw, 27px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  color: var(--masthead-ink);
  white-space: nowrap;
}
.tape-cell span {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .04em;
  color: var(--masthead-muted);
}
.tape-cell b.pos { color: #8ee0b3; }
.tape-cell b.neg { color: #f0a58f; }
.tape-cell.tape-week b.pos { color: #d5c18b; }
.meta-line {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 7px 0 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--masthead-muted);
}
.meta-line b { color: var(--masthead-ink); font-weight: 500; }
.meta-right { margin-left: auto; }

/* ── 主面板 ───────────────────────────── */
.sheet {
  background: var(--paper);
  padding: 11px var(--pad) 26px;
  border-bottom: 1px solid var(--line-strong);
}
.controls { border-bottom: 1px solid var(--line); padding-bottom: 9px; }
.control-row { display: flex; gap: 8px; align-items: stretch; }
.search-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 32px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: 0;
}
.search-wrap input::placeholder { color: var(--faint); }
.search-wrap input:focus { border-color: var(--ink); }
.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 11px;
  flex: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}
.filter-btn:hover { border-color: var(--ink); }
.filter-btn.has-active { border-color: var(--pine); color: var(--pine); }
.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--pine);
  color: #fff;
  font-family: var(--mono);
  font-size: 9px;
}
.filter-panel {
  margin-top: 10px;
  padding: 12px;
  background: #eef1ea;
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
}
.fgroup { padding: 7px 0 9px; border-bottom: 1px solid var(--line); }
.fgroup:first-child { padding-top: 0; }
.fgroup:last-of-type { border-bottom: 0; }
.fgroup-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.fgroup-label { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.fgroup-hint { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-width: 38px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.fpanel-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}
.fpanel-note { font-size: 10px; color: var(--faint); }
.reset-btn {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--oxide);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.list-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 0 6px;
  border-bottom: 1px solid var(--ink);
}
.list-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.list-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
}
.sort { margin-left: auto; display: flex; flex: none; }
.sort-btn {
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-left: 0;
  background: transparent;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
}
.sort-btn:first-child { border-left: 1px solid var(--line-strong); }
.sort-btn.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* 紧凑账本行 */
.ledger { border-top: 0; }
.row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 80px 74px 9px;
  grid-template-areas: "rank main total week chev";
  align-items: center;
  gap: 7px;
  min-height: 50px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  position: relative;
  transition: background-color .12s ease;
}
.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: transparent;
}
.row:hover { background: #f1f4ee; }
.row:hover::before { background: var(--brass); }
.row:active { background: #e8ede6; }
.row.is-empty { display: none; }
.rank {
  grid-area: rank;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  align-self: start;
  padding-top: 2px;
}
.main {
  grid-area: main;
  min-width: 0;
  display: block;
}
.name-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.kind {
  flex: none;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  padding: 1px 4px;
}
.kind-chain, .kind-follow { color: #496a5b; border-color: #b8cbbf; }
.kind-reverse { color: var(--oxide); border-color: #d9bdb2; }
.kind-pool { color: #776a4f; border-color: #d4c8ae; }
.config {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--faint);
}
.fig {
  display: block;
  min-width: 0;
  text-align: right;
  align-self: center;
}
.fig-total { grid-area: total; }
.fig-week { grid-area: week; border-left: 1px solid var(--line); padding-left: 8px; }
.fig-k {
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .04em;
  color: var(--faint);
  margin-bottom: 1px;
}
.fig-v {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fig-v.pos { color: var(--pine); }
.fig-v.neg { color: var(--oxide); }
.fig-v.zero { color: var(--muted); }
.chev {
  grid-area: chev;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
}
.row:hover .chev { color: var(--ink); }

/* 骨架 / 空态 / 错误 */
.skeleton-card {
  height: 50px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #f1f3ee 0 30%, #e5e9e2 45%, #f1f3ee 60% 100%);
  background-size: 240% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -240% 0; } }
.state-box {
  padding: 32px 16px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.state-box h3 { margin: 0 0 5px; font-family: var(--display); font-size: 18px; font-weight: 600; }
.state-box p { margin: 0 auto 14px; max-width: 360px; color: var(--muted); font-size: 12px; }
.ghost-btn {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 11px;
}
.ghost-btn:hover { background: var(--ink); color: #fff; }
.error-bar {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 11px;
  padding: 9px 10px;
  border: 1px solid #d9b5a8;
  border-left: 3px solid var(--oxide);
  background: var(--oxide-soft);
  color: var(--oxide);
  font-size: 11px;
}
.error-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 10px;
}
.error-body { flex: 1 1 auto; min-width: 0; }
.error-body b { display: block; font-size: 11px; margin-bottom: 1px; }
.error-body span { display: block; color: var(--muted); }
.retry-btn {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--oxide);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.foot { padding-top: 15px; color: var(--faint); font-size: 10px; line-height: 1.6; }
.foot p { margin: 0 0 2px; }
.foot-dim { font-family: var(--mono); font-size: 9px; }

@media (min-width: 700px) {
  .sheet { padding-left: 28px; padding-right: 28px; }
  .row { grid-template-columns: 28px minmax(0, 1fr) 120px 110px 12px; gap: 14px; min-height: 61px; }
  .name { font-size: 15px; }
  .fig-v { font-size: 16px; }
  .tape-cell { padding: 13px 17px 14px 0; }
  .tape-cell:nth-child(2) { padding-left: 17px; }
  .tape-cell:last-child { padding-left: 17px; }
  .masthead { padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 374px) {
  :root { --pad: 13px; }
  .row { grid-template-columns: 18px minmax(0, 1fr) 68px 64px 7px; gap: 5px; }
  .fig-v { font-size: 12.5px; }
  .name { font-size: 13px; }
  .kind { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
