:root {
  --bg: #0f0a0a;
  --bg-2: #1a1010;
  --surface: #241616;
  --surface-2: #2e1c1c;
  --line: rgba(255, 214, 150, 0.16);
  --ink: #f7efe4;
  --muted: #c4b2a0;
  --muted-2: #9a8776;
  --red: #b91c1c;
  --red-bright: #dc2626;
  --gold: #d4a017;
  --gold-soft: #f0d78c;
  --gold-dim: rgba(212, 160, 23, 0.15);
  --ok: #16a34a;
  --blue-ball: #1d4ed8;
  --green-ball: #15803d;
  --red-ball: #b91c1c;
  --shadow: 0 12px 40px rgba(0,0,0,.35);
  --radius: 16px;
  --radius-sm: 10px;
  --max: 1120px;
  --font: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", "PingFang HK", "Microsoft JhengHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(185,28,28,.28), transparent 55%),
    radial-gradient(900px 400px at 90% 0%, rgba(212,160,23,.16), transparent 50%),
    var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--gold-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
.container { width: min(100% - 2rem, var(--max)); margin-inline: auto; }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--gold); color: #111;
  padding: .6rem 1rem; z-index: 100; border-radius: 8px;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  background: rgba(15,10,10,.88);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem 0;
}
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, #dc2626, #7f1d1d);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; box-shadow: 0 0 0 2px rgba(240,215,140,.35);
}
.brand-text strong { display: block; font-size: 1.05rem; letter-spacing: .02em; }
.brand-text small { color: var(--muted); font-size: .75rem; }
.nav-links { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted); padding: .45rem .8rem; border-radius: 999px; font-size: .92rem;
}
.nav-links a:hover, .nav-links a.is-active {
  color: var(--ink); background: var(--gold-dim); text-decoration: none;
}
.nav-toggle {
  display: none; background: transparent; border: 1px solid var(--line);
  color: var(--ink); border-radius: 10px; padding: .45rem .7rem;
}

.hero {
  padding: 2.5rem 0 1.5rem;
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: .4rem;
  color: var(--gold-soft); font-size: .85rem; font-weight: 600;
  background: var(--gold-dim); border: 1px solid rgba(212,160,23,.3);
  padding: .3rem .75rem; border-radius: 999px; margin: 0 0 .9rem;
}
.hero h1 {
  margin: 0 0 .75rem; font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.25; letter-spacing: .01em;
}
.hero h1 .accent { color: var(--gold-soft); }
.hero-lead { color: var(--muted); max-width: 42rem; margin: 0 0 1.4rem; }
.meta-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem;
  margin: 1.25rem 0 0;
}
.meta-card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .9rem 1rem;
}
.meta-card .label { color: var(--muted-2); font-size: .78rem; }
.meta-card .value { font-size: 1.15rem; font-weight: 700; color: var(--gold-soft); margin-top: .15rem; }

.section { padding: 1.5rem 0 2rem; }
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.section-head h2 { margin: 0; font-size: 1.25rem; }
.section-head p { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.note {
  background: rgba(212,160,23,.08); border: 1px solid rgba(212,160,23,.22);
  color: var(--muted); border-radius: var(--radius-sm); padding: .85rem 1rem;
  font-size: .9rem; margin: 0 0 1.25rem;
}
.disclaimer {
  background: rgba(185,28,28,.12); border: 1px solid rgba(220,38,38,.28);
  color: #f3c4c4; border-radius: var(--radius-sm); padding: .85rem 1rem;
  font-size: .88rem; margin: 1rem 0;
}

.card {
  background: linear-gradient(180deg, var(--surface), #1a1010);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.15rem;
}
.card + .card { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.balls { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.ball {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; color: #fff;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.25), 0 4px 10px rgba(0,0,0,.25);
  border: 2px solid rgba(255,255,255,.2);
}
.ball.sm { width: 34px; height: 34px; font-size: .85rem; }
.ball.red { background: radial-gradient(circle at 30% 28%, #f87171, var(--red-ball) 55%, #7f1d1d); }
.ball.blue { background: radial-gradient(circle at 30% 28%, #60a5fa, var(--blue-ball) 55%, #1e3a8a); }
.ball.green { background: radial-gradient(circle at 30% 28%, #4ade80, var(--green-ball) 55%, #14532d); }
.ball.special {
  outline: 2px dashed var(--gold-soft); outline-offset: 3px;
}
.plus { color: var(--gold-soft); font-weight: 700; font-size: 1.2rem; margin: 0 .15rem; }
.draw-meta { color: var(--muted); font-size: .92rem; margin-bottom: .85rem; }
.draw-meta strong { color: var(--ink); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .85rem;
}
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink); border-radius: 999px; padding: .45rem .9rem; cursor: pointer;
  font-size: .88rem;
}
.btn:hover { border-color: rgba(240,215,140,.45); }
.btn.is-active, .btn-primary {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  border-color: transparent; color: #fff; font-weight: 600;
}
.btn-ghost { background: transparent; }

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.data {
  width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 520px;
}
table.data th, table.data td {
  padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th {
  background: rgba(0,0,0,.28); color: var(--gold-soft); font-weight: 600;
  position: sticky; top: 0; cursor: pointer; user-select: none;
}
table.data th:hover { color: #fff; }
table.data tr:hover td { background: rgba(255,255,255,.03); }
table.data td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank { color: var(--muted-2); width: 2.5rem; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(255,255,255,.04); border-radius: 999px; padding: .15rem .55rem .15rem .2rem;
}

.stat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.stat-list li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .55rem .65rem; border-radius: 12px; background: rgba(0,0,0,.18);
  border: 1px solid transparent;
}
.stat-list li:hover { border-color: var(--line); }
.stat-list .count {
  font-variant-numeric: tabular-nums; color: var(--gold-soft); font-weight: 700;
}

.chart-box {
  width: 100%; overflow-x: auto; padding: .25rem 0 .5rem;
}
.chart-box svg { width: 100%; min-width: 640px; height: auto; }

.site-footer {
  margin-top: 2rem; border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem; color: var(--muted-2); font-size: .85rem;
}
.site-footer .footer-grid {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
}
.site-footer a { color: var(--muted); }

.loading, .error {
  padding: 2rem; text-align: center; color: var(--muted);
}
.error { color: #fca5a5; }

@media (max-width: 860px) {
  .grid-2, .grid-3, .meta-strip { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none; width: 100%; flex-direction: column; align-items: stretch;
    padding-bottom: .5rem;
  }
  .nav-links.is-open { display: flex; }
  .nav { flex-wrap: wrap; }
}

/* —— Enhancements: dist bars, zodiac, trend, draw sim —— */
.dist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.dist-card h3 { margin: 0 0 .75rem; font-size: 1rem; }
.dist-row { display: grid; grid-template-columns: 4.5rem 1fr 4.2rem; gap: .5rem; align-items: center; margin: .4rem 0; font-size: .9rem; }
.dist-row .bar-track { height: 10px; border-radius: 99px; background: rgba(255,255,255,.06); overflow: hidden; }
.dist-row .bar-fill { height: 100%; border-radius: 99px; }
.dist-row .bar-fill.red { background: linear-gradient(90deg, #f87171, #b91c1c); }
.dist-row .bar-fill.blue { background: linear-gradient(90deg, #60a5fa, #1d4ed8); }
.dist-row .bar-fill.green { background: linear-gradient(90deg, #4ade80, #15803d); }
.dist-row .bar-fill.gold { background: linear-gradient(90deg, #f0d78c, #d4a017); }
.dist-row .bar-fill.muted { background: linear-gradient(90deg, #9a8776, #6b5a4c); }
.dist-row .pct { color: var(--gold-soft); font-variant-numeric: tabular-nums; text-align: right; font-weight: 700; }

.zodiac-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .55rem; }
.zodiac-chip {
  background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .65rem;
}
.zodiac-chip strong { display: block; color: var(--gold-soft); margin-bottom: .25rem; }
.zodiac-chip .nums { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.zodiac-chip.is-year { border-color: rgba(212,160,23,.55); box-shadow: 0 0 0 1px rgba(212,160,23,.2); }

.trend-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--line); }
.trend-grid { border-collapse: collapse; font-size: .7rem; min-width: 1100px; }
.trend-grid th, .trend-grid td {
  border: 1px solid rgba(255,214,150,.1); padding: 0; text-align: center;
  width: 22px; height: 22px; min-width: 22px; font-variant-numeric: tabular-nums;
}
.trend-grid th { background: rgba(0,0,0,.35); color: var(--muted); font-weight: 600; position: sticky; top: 0; z-index: 2; }
.trend-grid th.sticky-col, .trend-grid td.sticky-col {
  position: sticky; left: 0; z-index: 3; background: #1a1010; min-width: 72px; width: 72px; text-align: left; padding: 0 .4rem; font-size: .72rem;
}
.trend-grid th.sticky-col { z-index: 4; }
.trend-grid td.hit { color: #fff; font-weight: 800; }
.trend-grid td.hit.red { background: #b91c1c; }
.trend-grid td.hit.blue { background: #1d4ed8; }
.trend-grid td.hit.green { background: #15803d; }
.trend-grid td.omit { color: #6b5a4c; }
.trend-grid tr:hover td:not(.hit) { background: rgba(255,255,255,.03); }

.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.tab-btn.is-active { background: linear-gradient(135deg, #dc2626, #991b1b); border-color: transparent; color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.draw-stage {
  position: relative; min-height: 220px;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(185,28,28,.35), transparent 55%),
    linear-gradient(180deg, #2a1515, #120a0a);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1rem 1.25rem; overflow: hidden;
}
.draw-stage .stage-label { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.draw-balls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; align-items: center; min-height: 72px;
}
.draw-balls .ball {
  width: 56px; height: 56px; font-size: 1.15rem;
  opacity: 0; transform: translateY(-40px) scale(.6);
  animation: ballDrop .55s cubic-bezier(.2,.8,.2,1) forwards;
}
.draw-balls .ball.special { width: 56px; height: 56px; }
@keyframes ballDrop {
  0% { opacity: 0; transform: translateY(-48px) scale(.5) rotate(-12deg); }
  70% { opacity: 1; transform: translateY(4px) scale(1.05) rotate(2deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
.draw-summary { margin-top: 1.1rem; color: var(--muted); font-size: .92rem; }
.draw-summary dl { display: grid; grid-template-columns: 6.5rem 1fr; gap: .35rem .75rem; margin: .5rem 0 0; }
.draw-summary dt { color: var(--muted-2); }
.draw-summary dd { margin: 0; color: var(--ink); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.form-field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.form-field input, .form-field select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink); border-radius: 10px; padding: .55rem .7rem;
}
.rule-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.rule-card {
  background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem; font-size: .88rem; color: var(--muted);
}
.rule-card h4 { margin: 0 0 .4rem; color: var(--gold-soft); font-size: .95rem; }
.pool-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .4rem; }
.pool-list li {
  display: flex; justify-content: space-between; gap: .5rem; align-items: center;
  padding: .45rem .6rem; background: rgba(0,0,0,.18); border-radius: 10px; font-size: .9rem;
}
.prize-badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: rgba(212,160,23,.15); color: var(--gold-soft); border: 1px solid rgba(212,160,23,.35);
}
.prize-badge.none { background: rgba(255,255,255,.04); color: var(--muted-2); border-color: var(--line); }
.prize-badge.win1, .prize-badge.win2 { background: rgba(220,38,38,.25); color: #fecaca; border-color: rgba(220,38,38,.45); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .55rem; margin: .75rem 0; }
.mini-stats .meta-card .value { font-size: 1rem; }

@media (max-width: 860px) {
  .draw-balls .ball { width: 44px; height: 44px; font-size: .95rem; }
}

/* —— 智慧組合 —— */
.smart-pool { display:flex; flex-wrap:wrap; gap:.45rem; min-height:2.5rem; padding:.5rem; border:1px dashed var(--line, #d4c4a8); border-radius:12px; background:rgba(255,255,255,.04); }
.smart-palette { display:flex; flex-wrap:wrap; gap:.35rem; margin-top:.75rem; max-height:220px; overflow:auto; padding:.5rem; border-radius:12px; background:rgba(0,0,0,.15); }
.smart-pool .ball, .smart-palette .ball { cursor:pointer; transition:transform .12s, box-shadow .12s, opacity .12s; }
.smart-pool .ball:hover, .smart-palette .ball:hover { transform:scale(1.08); }
.smart-palette .ball.is-in-pool { outline:2px solid var(--gold-soft, #d4a017); opacity:.45; }
.ticket-list { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:.6rem; margin-top:.75rem; }
.ticket-card { padding:.65rem .75rem; border-radius:12px; background:rgba(255,255,255,.04); border:1px solid var(--line, #d4c4a8); }
.ticket-card .t-idx { font-size:.75rem; color:var(--muted); margin-bottom:.35rem; }
.cost-compare { display:flex; flex-wrap:wrap; gap:.75rem; margin:.5rem 0 0; }
.cost-compare .meta-card { flex:1; min-width:120px; }

/* —— HKJC-inspired 攪珠／運財／投注區 —— */
.hkjc-last-draw {
  margin-bottom: 1.25rem;
  background: linear-gradient(180deg, #2a1212 0%, #1a0e0e 100%);
  border: 1px solid rgba(220, 38, 38, 0.35);
}
.hkjc-last-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .65rem .9rem;
  margin-bottom: .85rem;
}
.hkjc-badge {
  display: inline-flex; align-items: center;
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  color: #fff; font-weight: 800; font-size: .82rem;
  padding: .28rem .7rem; border-radius: 6px;
  letter-spacing: .04em;
  box-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.hkjc-last-meta { color: var(--gold-soft); font-weight: 600; font-size: .95rem; }
.hkjc-last-balls { margin: .25rem 0 .5rem; }
.hkjc-note { margin: .65rem 0 0; color: var(--muted-2); font-size: .8rem; }

.hkjc-lucky-panel {
  margin-top: .25rem;
  padding: 1rem 1.1rem 1.1rem;
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(120,20,40,.35), rgba(20,10,10,.55));
  border: 1px solid rgba(236, 72, 153, 0.28);
}
.hkjc-lucky-title {
  font-size: 1.05rem; font-weight: 800; color: #fda4af;
  margin: 0 0 .65rem; letter-spacing: .03em;
}
.hkjc-stage { background: rgba(0,0,0,.22); border-radius: 12px; padding: .85rem; }
.hkjc-actions {
  display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .9rem; align-items: center;
}

.btn-retry {
  background: linear-gradient(180deg, #fb7185, #db2777) !important;
  border-color: #be185d !important;
  color: #fff !important;
  font-weight: 700;
  min-width: 5.5rem;
}
.btn-retry:hover { filter: brightness(1.06); }
.btn-retry:disabled { opacity: .45; filter: none; }

.btn-add-bet {
  background: linear-gradient(180deg, #fde047, #eab308) !important;
  border-color: #ca8a04 !important;
  color: #422006 !important;
  font-weight: 800;
  min-width: 8.5rem;
  box-shadow: 0 2px 0 rgba(161, 98, 7, 0.45);
}
.btn-add-bet:hover { filter: brightness(1.05); }
.btn-add-bet:disabled { opacity: .45; filter: none; box-shadow: none; }

.bet-slip-card {
  border: 1px solid rgba(234, 179, 8, 0.35);
  background: linear-gradient(180deg, rgba(60,45,10,.35), rgba(20,14,8,.7));
}
.bet-slip-toolbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: .65rem; margin: .75rem 0;
}
#bet-slip-count { font-weight: 700; color: var(--gold-soft); }
.bet-slip-list { display: grid; gap: .45rem; }
.bet-slip-empty { color: var(--muted); font-size: .9rem; margin: 0; }
.bet-slip-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: .55rem;
  padding: .55rem .7rem; border-radius: 10px;
  background: rgba(0,0,0,.28); border: 1px solid var(--line);
}
.bet-slip-line .bs-idx {
  font-size: .78rem; color: var(--muted); min-width: 2.4rem; font-weight: 600;
}
.bet-slip-line .bs-text {
  font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .04em;
  flex: 1; min-width: 10rem;
}
.bet-slip-line .bs-remove {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: .2rem .55rem; cursor: pointer; font-size: .8rem;
}
.bet-slip-line .bs-remove:hover { color: #fecaca; border-color: rgba(220,38,38,.45); }

.ticket-list.is-truncated::after {
  content: attr(data-more);
  display: block; grid-column: 1 / -1;
  color: var(--muted); font-size: .85rem; margin-top: .25rem;
}
.warn-huge {
  margin: .6rem 0 0; padding: .55rem .75rem; border-radius: 10px;
  background: rgba(220, 38, 38, 0.12); border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fecaca; font-size: .85rem;
}

.btn-add-bet { min-width: 11rem; }

.responsible-note {
  color: #fbbf24 !important;
  font-weight: 600;
}

.site-toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(120%);
  z-index: 9999;
  max-width: min(92vw, 34rem);
  padding: .85rem 1.1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border: 1px solid rgba(234, 179, 8, 0.55);
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  font-size: .92rem;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: transform .28s ease, opacity .28s ease;
}
.site-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}


.breadcrumbs { margin: .75rem 0 0; }
.breadcrumbs ol {
  list-style: none; display: flex; flex-wrap: wrap; gap: .35rem .55rem;
  margin: 0; padding: 0; font-size: .82rem; color: var(--muted);
}
.breadcrumbs li:not(:last-child)::after {
  content: "/"; margin-left: .55rem; color: var(--muted-2, var(--muted));
}
.breadcrumbs a { color: var(--gold-soft, #fbbf24); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: var(--ink, #fff); font-weight: 600; }
