:root {
  --bg: #0f1c17;
  --bg-2: #16261f;
  --panel: #1c3027;
  --line: #2d4a3c;
  --text: #e8f2ec;
  --muted: #9bb5a8;
  --accent: #d4a017;
  --accent-2: #2f9e6b;
  --danger: #d4544a;
  --red: #e23b3b;
  --blue: #2f6fe0;
  --green: #1f9a5b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(212, 160, 23, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(47, 158, 107, 0.16), transparent 50%),
    linear-gradient(180deg, #102018, #0b1511 40%, #0f1c17);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(12, 22, 18, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #e0b53a, #9a6f10);
  color: #1a1405; font-weight: 800;
}
.brand strong { display: block; line-height: 1.1; }
.brand small { color: var(--muted); }
.topbar nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar nav a.active, .topbar nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.container { width: min(1100px, calc(100% - 32px)); margin: 24px auto 48px; }

.page-head {
  display: flex; justify-content: space-between; align-items: end;
  gap: 16px; margin-bottom: 18px;
}
.page-head h1 { margin: 0 0 6px; font-size: 1.8rem; }
.page-head p { margin: 0; color: var(--muted); }
.page-head .actions { margin-top: 0; }

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px;
}
.panel h2 { margin: 0; font-size: 1.15rem; }
.mt { margin-top: 18px; }
.muted { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 18px; }

.btn {
  appearance: none; border: 1px solid var(--line);
  background: #243c31; color: var(--text);
  border-radius: 10px; padding: 10px 16px;
  cursor: pointer; font: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.btn.primary {
  background: linear-gradient(135deg, #d4a017, #b8860b);
  border-color: transparent; color: #1a1405; font-weight: 700;
}
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(212,84,74,0.15); border-color: rgba(212,84,74,0.45); color: #ffb4ae; }
.btn.full { width: 100%; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; align-items: end; }

.flash-wrap { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #20362c;
}
.flash.success { border-color: rgba(47,158,107,0.5); }
.flash.error { border-color: rgba(212,84,74,0.55); background: rgba(212,84,74,0.12); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
  margin-bottom: 18px;
}
.stats > div {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px;
}
.stats small { color: var(--muted); display: block; margin-bottom: 6px; }
.stats strong { font-size: 1.35rem; }
.streak-box h3 { margin: 16px 0 8px; font-size: 1rem; }
.streak-table { max-width: 720px; }
.export-inline { margin-left: auto; }
.up { color: #57d39a; }
.down { color: #ff8d84; }

.balls { display: flex; flex-wrap: wrap; gap: 12px; }
.balls.compact { gap: 6px; }
.ball {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
  border: 4px solid #888;
  background: radial-gradient(circle at 35% 30%, #fff, #ececec 45%, #d5d5d5);
  color: #1a1a1a;
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.12), 0 6px 14px rgba(0,0,0,0.25);
}
.ball.mini { width: 34px; height: 34px; border-width: 3px; }
.ball.mini .ball-num { font-size: 0.78rem; }
.ball-num { font-weight: 800; font-size: 1.05rem; line-height: 1; }
.ball-zodiac {
  font-size: 0.72rem; line-height: 1; margin-top: 2px; color: #333;
}
.ball.wave-red { border-color: var(--red); }
.ball.wave-blue { border-color: var(--blue); }
.ball.wave-green { border-color: var(--green); }
.ball.hit {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tag {
  background: rgba(212,160,23,0.15);
  color: var(--accent);
  border: 1px solid rgba(212,160,23,0.35);
  border-radius: 999px; padding: 4px 10px; font-size: 0.85rem;
}
.pill {
  display: inline-block; border-radius: 999px;
  padding: 3px 10px; font-size: 0.82rem;
  border: 1px solid var(--line);
}
.pill.win { background: rgba(47,158,107,0.18); color: #7dffc0; }
.pill.lose { background: rgba(212,84,74,0.15); color: #ffb0aa; }
.pill.pending { background: rgba(255,255,255,0.05); color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.9rem; }

.zodiac-toolbar {
  margin: 4px 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}
.zodiac-hint {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
}
.zodiac-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.zodiac-btn {
  min-width: 44px;
  padding: 8px 12px;
  font-weight: 700;
}
.zodiac-btn.active {
  background: linear-gradient(135deg, #d4a017, #b8860b);
  border-color: transparent;
  color: #1a1405;
}
.zodiac-btn.partial {
  border-color: rgba(212, 160, 23, 0.7);
  color: var(--accent);
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 18px;
}
.num-pick {
  position: relative; cursor: pointer; user-select: none;
}
.num-pick input { position: absolute; opacity: 0; pointer-events: none; }
.num-pick span {
  display: grid; place-items: center;
  height: 42px; border-radius: 10px;
  border: 1px solid var(--line);
  background: #15241d;
  font-weight: 700;
}
.num-pick.on span, .num-pick input:checked + span {
  background: linear-gradient(135deg, #d4a017, #b8860b);
  color: #1a1405;
  border-color: transparent;
}
.counter { color: var(--muted); }
.counter strong { color: var(--accent); font-size: 1.2rem; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sim-form h2 { margin: 8px 0 12px; font-size: 1.05rem; }
.sim-form .check { margin-top: 0; min-height: 42px; }
.template-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.template-bar .grow { flex: 1; min-width: 220px; }
.template-hint { margin: 0; flex: 1; min-width: 200px; }
.sim-table .sim-trace td {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.12);
  padding-top: 4px;
  padding-bottom: 12px;
}
.sim-table details summary { cursor: pointer; color: var(--muted); }
.sim-table details[open] summary { margin-bottom: 8px; color: var(--text); }
.sim-win td { background: rgba(47,158,107,0.08); }
.sim-bust td { background: rgba(212,84,74,0.10); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #122019; color: var(--text);
  font: inherit;
}
input[readonly] {
  opacity: 0.88;
  cursor: default;
  background: #0e1c16;
}
select { cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.pick-rule h3 { margin: 0 0 10px; font-size: 1.02rem; }
.pick-form { margin: 0; }
.pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
}
.pick-row > label { min-width: 140px; flex: 1; }
.pick-kinds {
  display: flex;
  gap: 14px;
  align-items: center;
  min-height: 42px;
  padding-bottom: 2px;
}
.pick-kinds .check {
  margin-top: 0;
  color: var(--text);
  font-size: 1rem;
}
.pick-kinds .check input { width: auto; accent-color: var(--accent); }
.pick-row .btn { min-width: 96px; }
.pick-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}
.pick-result p { margin: 0 0 8px; }
.pick-result p:last-child { margin-bottom: 0; }
.pick-result .chip-list { margin-bottom: 8px; }
.pick-copy { user-select: all; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { width: 120px; padding: 8px 10px; }

.kv { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.kv li {
  display: flex; justify-content: space-between; gap: 12px;
  padding-bottom: 8px; border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.kv span { color: var(--muted); }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-width: 42px; text-align: center;
  padding: 6px 8px; border-radius: 8px;
  background: #15241d; border: 1px solid var(--line);
  font-weight: 700;
}
.chip.exclude { opacity: 0.55; text-decoration: line-through; }
.chip.hit { border-color: var(--accent); color: var(--accent); }
.chip.link {
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, color 0.15s;
}
.chip.link:hover { border-color: var(--accent); color: var(--accent); }

.expect-picker {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}
.expect-search { flex: 1; min-width: 220px; }
.expect-block h3, .expect-block-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}
.expect-block-title.mt { margin-top: 14px; }
.expect-history {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; }
.year-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.year-tabs a { text-decoration: none; }

.login-page {
  min-height: 100vh; display: grid; place-items: center;
  width: min(920px, calc(100% - 24px)); margin: 0 auto;
}
.login-panel {
  width: 100%;
  display: grid; grid-template-columns: 1.1fr 0.9fr;
  border-radius: 24px; overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--panel);
}
.login-hero {
  padding: 48px 40px;
  background:
    linear-gradient(160deg, rgba(212,160,23,0.22), transparent 50%),
    linear-gradient(20deg, #193328, #0f1f18);
}
.login-hero .eyebrow {
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); font-size: 0.78rem;
}
.login-hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  margin: 8px 0 12px; line-height: 1;
}
.login-hero p { color: var(--muted); max-width: 16em; }
.login-form { padding: 42px 36px; display: grid; gap: 14px; align-content: center; }
.login-form h2 { margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

.draw-card + .draw-card { margin-top: 12px; }

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--muted);
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--text); }

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.source-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: inherit;
  text-decoration: none;
}
.source-card:hover {
  text-decoration: none;
  border-color: rgba(212, 160, 23, 0.45);
  background: #1a2c24;
}
.source-index {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(212, 160, 23, 0.12);
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.04em;
}
.source-body { flex: 1; min-width: 0; }
.source-body h3 { margin: 0 0 6px; font-size: 1.12rem; }
.source-body p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}
.source-go {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.kelly-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}
.kelly-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.payout-presets { display: grid; gap: 6px; align-content: end; }
.chip.wave-red { border-color: rgba(226, 59, 59, 0.7); }
.chip.wave-blue { border-color: rgba(47, 111, 224, 0.7); }
.chip.wave-green { border-color: rgba(31, 154, 91, 0.7); }
.rank-table td, .rank-table th { white-space: nowrap; }
.rank-table td.ocr-cell, .rank-table th.ocr-cell {
  white-space: normal;
  max-width: 12rem;
  line-height: 1.35;
  overflow: hidden;
}
.poem-table td.poem { white-space: normal; min-width: 12em; max-width: 28em; line-height: 1.4; }
.poem-table td.poem a { color: inherit; }
.poem-table td.poem a:hover { color: var(--accent); }
.poem-search .actions { margin-top: 0; }
.poem-search mark,
.poem-table mark {
  background: rgba(212, 160, 23, 0.35);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}
.repeat-box {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}
.repeat-box h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}
.repeat-box p { margin: 0 0 8px; line-height: 1.55; }
.repeat-box p:last-child { margin-bottom: 0; }

.zcalc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
}
.zcalc-col { display: grid; gap: 6px; }
.zcalc-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #15241d;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.zcalc-item:hover { filter: brightness(1.08); }
.zcalc-item .z-name {
  color: #e45a4f;
  font-weight: 800;
  min-width: 5.6em;
  flex-shrink: 0;
}
.zcalc-item .z-animals {
  color: #6ea8ff;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.zcalc-item.on {
  background: rgba(212, 160, 23, 0.16);
  border-color: rgba(212, 160, 23, 0.7);
}
.zcalc-item.on .z-name { color: #ff8b7e; }
.zcalc-item.on .z-animals { color: #9ec4ff; }
.zcalc-result { position: sticky; bottom: 10px; }
.zcalc-result .expect-block-title span {
  margin-left: 8px;
  color: var(--accent);
  font-weight: 700;
}
.chip.z-hit {
  border-color: var(--accent);
  color: var(--accent);
}
.chip.z-miss { opacity: 0.7; }
.chip .z-n {
  margin-left: 4px;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--muted);
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.rule-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #15241d;
  text-decoration: none;
  color: inherit;
}
.rule-card:hover { border-color: var(--accent); text-decoration: none; }
.rule-card.on {
  border-color: rgba(212, 160, 23, 0.75);
  background: rgba(212, 160, 23, 0.12);
}
.rule-card strong { font-size: 0.98rem; }
.rule-rate { font-size: 1.35rem; font-weight: 800; }

.help-list {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.55;
}
.help-list strong { color: var(--text); }
.ntfy-setup {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.ntfy-setup img {
  width: 196px;
  height: 196px;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
}
.ntfy-setup ol.help-list { padding-left: 1.2em; }
.ntfy-setup code {
  color: var(--text);
  font-size: 0.92rem;
  word-break: break-all;
}
.stack-form .hint { margin: 4px 0 8px; }
textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #122019; color: var(--text);
  font: inherit; min-height: 80px;
}

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  .grid-2, .login-panel, .stats, .form-row, .form-row.cols-3, .form-row.cols-4, .zcalc-grid, .rule-grid, .ntfy-setup { grid-template-columns: 1fr; }
  .number-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .page-head { align-items: start; flex-direction: column; }
  .source-card { align-items: flex-start; flex-wrap: wrap; }
  .source-go { margin-left: auto; }
}
