:root {
  color-scheme: light;
  --bg: #f4efe6;
  --paper: #fffdf8;
  --ink: #241c16;
  --muted: #6f675c;
  --line: #e6dccb;
  --cinnabar: #9c2f2f;
  --green: #1c7a4a;
  --gold: #8a5a28;
  --chip: #f6f0e4;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.06);
  --red: #d94b4b;
  --blue: #3a6fd6;
  --green-ball: #2f9a5a;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14110e;
    --paper: #221c17;
    --ink: #f6f1e8;
    --muted: #b7ad9e;
    --line: #3c332a;
    --cinnabar: #f0a3a0;
    --green: #8ddeaf;
    --gold: #e2c09a;
    --chip: #2c251e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
h1, h2, h3 { font-family: "Songti SC", "STSong", "Noto Serif SC", serif; font-weight: 600; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
p { margin: 0.4rem 0; }
a { color: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner, main, footer { width: min(980px, calc(100% - 28px)); margin: 0 auto; }
.top-inner { padding: 12px 0 10px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; justify-content: space-between; }
.brand { margin: 0; letter-spacing: 0.12em; font-size: 0.72rem; color: var(--gold); }
.topline { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.92rem; }
.jumps { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; }
.jumps a {
  flex: 0 0 auto;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

main { padding: 16px 0 28px; display: grid; gap: 14px; min-width: 0; }
.hero, .stack, .how, .card, .fold { min-width: 0; max-width: 100%; }
.scroll { overflow-x: auto; max-width: 100%; }
.how, .card, .fold {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.how, .card { padding: 16px; }
.how ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 8px; }
.hero, .stack { display: grid; gap: 14px; }
.muted { color: var(--muted); font-size: 0.88rem; }
.row-head, .ticket-head, .bet, .foot, .form-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge, .pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--chip);
  font-size: 0.78rem;
}
.badge.narrow { background: #f8d7d4; color: #7a201c; }
.badge.wide { background: #d9f0e3; color: #145c38; }
.badge.wait { background: #f3e4c4; color: #6d4a16; }
@media (prefers-color-scheme: dark) {
  .badge.narrow { background: #5a2c2c; color: #ffd0cc; }
  .badge.wide { background: #1d4332; color: #c9f5df; }
  .badge.wait { background: #4a3820; color: #ffe3b5; }
}
.period { font-variant-numeric: tabular-nums; font-size: 1.8rem; margin: 0; letter-spacing: 0.04em; }
.book { margin-top: 12px; font-size: 0.78rem; letter-spacing: 0.08em; color: var(--gold); }
.bet { padding: 8px 0; border-top: 1px solid var(--line); }
.bet b { font-size: 1.05rem; }
.stake { font-variant-numeric: tabular-nums; font-weight: 650; }
.foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.money { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.6rem; }
.pos { color: var(--green); }
.neg { color: var(--cinnabar); }
.balls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: white;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.ball.red { background: var(--red); }
.ball.blue { background: var(--blue); }
.ball.green { background: var(--green-ball); }
.ball.special { outline: 2px solid var(--gold); outline-offset: 2px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 550; font-size: 0.75rem; }
.draw { padding: 10px 0; border-bottom: 1px solid var(--line); }
.draw-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.fold { padding: 0 16px 12px; }
.fold summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.fold summary:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button, input { font: inherit; color: inherit; }
button { min-height: 44px; border-radius: 999px; padding: 0 16px; }
.solid { background: var(--ink); color: var(--bg); border: 0; }
.ghost { background: transparent; border: 1px solid var(--line); }
#more, .form-actions { margin-top: 12px; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 0.88rem; }
input[type="date"], .num-grid input {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 0 10px;
}
fieldset { border: 1px solid var(--line); border-radius: 14px; margin: 0; padding: 10px; }
legend { padding: 0 6px; color: var(--muted); font-size: 0.82rem; }
.num-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.special-input { box-shadow: inset 0 0 0 1px var(--gold); }
.form-msg { min-height: 1.2em; }
.check { padding: 10px 12px; border-radius: 12px; background: var(--chip); }
.check.bad { background: #f8d7d4; color: #6d201c; }
.note { font-size: 0.88rem; color: var(--muted); }
.hit { font-weight: 700; }

@media (min-width: 860px) {
  h1 { font-size: 2rem; }
  .hero { grid-template-columns: 1.35fr 0.8fr; align-items: start; }
  .num-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 359px) {
  .top-inner, main, footer { width: min(980px, calc(100% - 16px)); }
  .ball { width: 28px; height: 28px; }
  .period { font-size: 1.45rem; }
}
