/* 彩算盤：手機優先、無外部字型、單一樣式檔 */
:root {
  --paper: #fffbef;       /* 奶油白底 */
  --card: #ffffff;
  --ink: #1b2a22;
  --muted: #5d6762;
  --line: #ece3c8;
  --jade: #0b7f62;        /* 主色：連結、按鈕、頁首 */
  --jade-soft: #d9f0e6;
  --sun: #f5b301;         /* 向日葵黃：只當填色，上面的字一律用 --on-sun */
  --sun-soft: #fff3c4;
  --on-sun: #1b2a22;
  --amber: #946200;       /* 黃色系的文字色 */
  --gold: var(--sun);
  --top-bg: #0b7f62;
  --top-ink: #ffffff;
  --grid: rgba(217, 240, 230, .6);
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --tabbar: 62px;
  /* 立柱顏色（最多 8 柱），上面的字用白色 */
  --c1: #0b7f62; --c2: #946200; --c3: #2f5d9a; --c4: #8a6a12;
  --c5: #7a3e8e; --c6: #3d7f2a; --c7: #9a4f2f; --c8: #4b5560;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111a16; --card: #1a2520; --ink: #eef1e8; --muted: #a9b6ad;
    --line: #2f3e36;
    --jade: #5fd0a8; --jade-soft: #1b3a30;
    --sun: #f5b301; --sun-soft: #3a3110; --amber: #f2c14e;
    --top-bg: #0d3a2e; --top-ink: #eef1e8;
    --grid: rgba(95, 208, 168, .07);
    --c1: #5fd0a8; --c2: #f2c14e; --c3: #79a6e6; --c4: #d6aa48;
    --c5: #c08ad2; --c6: #8ccd73; --c7: #e09872; --c8: #a9b4bf;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 16px/1.75 var(--sans);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
a { color: var(--jade); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; }
h1 { font-size: 1.55rem; letter-spacing: .02em; border-left: 6px solid var(--jade); padding-left: 12px; }
h2 { font-size: 1.2rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* 頂欄：只放站名，導覽在底部 */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--top-bg);
  border-bottom: 3px solid var(--sun);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--top-ink); font-weight: 700; font-size: 1.1rem; }
.brand svg { width: 30px; height: 30px; }
.top .crumb { margin-left: auto; font-size: .85rem; color: var(--top-ink); }
.top .crumb a { color: var(--top-ink); }

/* 底部分頁列（手機）；桌機改成頂欄右側 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .78rem;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--amber); font-weight: 700; }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 32px; }
.lede {
  font-size: 1.05rem; color: var(--ink); max-width: 40em;
  background: var(--sun-soft); border-radius: 12px; padding: 12px 16px;
}
.sub { color: var(--muted); font-size: .92rem; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; border-top: 4px solid var(--jade);
}
.stack > * + * { margin-top: 14px; }
.tiles { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 16px 0; }
.tile { display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.tile .ico { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; background: var(--jade-soft); color: var(--jade); display: grid; place-items: center; }
.tile .ico svg { width: 26px; height: 26px; }
.tile strong { display: block; font-size: 1.05rem; }
.tile > span:last-child { color: var(--muted); font-size: .9rem; }
.tile:hover { border-color: var(--jade); box-shadow: 0 2px 0 var(--sun); }
.tiles-h { margin: 22px 0 -4px; }

/* 計算器 */
.calc { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--card); }
.seg button {
  border: 0; background: none; font: inherit; font-size: .95rem; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 700; }

.field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field label { font-weight: 600; }
.field input[type="number"] {
  width: 7.5em; font: inherit; font-family: var(--mono); padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
}

.grid39 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0 6px; }
.grid39 button {
  aspect-ratio: 1; min-height: 40px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  font: 600 .98rem var(--mono); cursor: pointer; padding: 0;
  transition: transform .08s;
}
.grid39 button:active { transform: scale(.92); }
.grid39 button.on { background: var(--sun); border-color: var(--sun); color: var(--on-sun); }
.grid39 button[data-col] { color: #fff; }
.grid39 button[data-col="1"] { background: var(--c1); border-color: var(--c1); }
.grid39 button[data-col="2"] { background: var(--c2); border-color: var(--c2); }
.grid39 button[data-col="3"] { background: var(--c3); border-color: var(--c3); }
.grid39 button[data-col="4"] { background: var(--c4); border-color: var(--c4); }
.grid39 button[data-col="5"] { background: var(--c5); border-color: var(--c5); }
.grid39 button[data-col="6"] { background: var(--c6); border-color: var(--c6); }
.grid39 button[data-col="7"] { background: var(--c7); border-color: var(--c7); }
.grid39 button[data-col="8"] { background: var(--c8); border-color: var(--c8); }
@media (prefers-color-scheme: dark) { .grid39 button[data-col] { color: #111a16; } }

.cols { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cols button {
  font: inherit; font-size: .9rem; padding: 4px 12px; min-height: 36px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
}
.cols button .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.cols button[aria-pressed="true"] { border-color: var(--ink); font-weight: 700; }
.cols .add { border-style: dashed; color: var(--muted); }

.picked { font-family: var(--mono); font-size: .92rem; color: var(--muted); min-height: 1.5em; word-break: break-all; }
.picked b { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: .92rem; padding: 6px 14px; min-height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn.ghost { background: none; }

/* 結果：像一張收據 */
.receipt {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; position: relative;
}
.receipt::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: -1px; height: 4px;
  background: repeating-linear-gradient(90deg, var(--sun) 0 10px, transparent 10px 16px);
  border-radius: 2px;
}
.big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
.big div { background: var(--paper); border-radius: 10px; padding: 10px 12px; }
.big small { display: block; color: var(--muted); font-size: .8rem; }
.big output { display: block; font: 700 1.6rem/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.big .money output { color: var(--amber); }

table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th, table.t td { padding: 7px 6px; border-bottom: 1px dashed var(--line); text-align: right; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.t tr.cur td { color: var(--amber); font-weight: 700; }

.note { margin: 12px 0 0; padding: 10px 12px; border-left: 4px solid var(--sun); background: var(--sun-soft); border-radius: 0 10px 10px 0; font-size: .92rem; }
details.list { margin-top: 10px; font-size: .9rem; }
details.list summary { cursor: pointer; color: var(--jade); }
details.list ol { font-family: var(--mono); columns: 2; column-gap: 18px; padding-left: 2.6em; margin: 8px 0 0; }
.warn { color: var(--amber); font-size: .9rem; min-height: 1.4em; margin: 4px 0 0; }

/* 合作推薦區 */
.partner { border: 1.5px solid var(--sun); border-top: 4px solid var(--sun); }
.partner .tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: var(--jade-soft); color: var(--ink); margin-right: 6px; }
.partner .age { background: var(--sun-soft); color: var(--amber); font-weight: 700; }
.partner ul { padding-left: 1.2em; margin: .4em 0 1em; }
.cta {
  display: inline-block; text-decoration: none; background: var(--jade); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-weight: 700;
}
@media (prefers-color-scheme: dark) { .cta { color: #0d1a14; } }
.disclose { font-size: .82rem; color: var(--muted); margin: 10px 0 0; }

.prose { max-width: 42em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose h2, main > h2 {
  background: var(--jade-soft); border-left: 4px solid var(--jade); border-radius: 0 10px 10px 0;
  padding: 6px 12px;
}
.prose h3 { border-left: 3px solid var(--sun); padding-left: 10px; margin-top: 1.2em; }
.prose h3 + p, .prose h2 + p { margin-top: .7em; }
.formula { font-family: var(--mono); background: var(--sun-soft); border: 1px dashed var(--sun); border-radius: 10px; padding: 10px 12px; overflow-x: auto; }

footer.site { max-width: 1040px; margin: 0 auto; padding: 16px 16px 28px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
footer.site a { color: var(--muted); }

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .tabbar {
    position: static; display: flex; height: auto; padding: 0; background: none; border: 0; gap: 4px;
    margin-left: auto;
  }
  .tabbar a { flex-direction: row; font-size: .95rem; padding: 6px 12px; border-radius: 999px; gap: 6px; }
  .tabbar a svg { width: 18px; height: 18px; }
  .tabbar a { color: var(--top-ink); }
  .tabbar a:hover { background: rgba(255, 255, 255, .16); }
  .tabbar a[aria-current="page"] { background: var(--sun); color: var(--on-sun); }
  .top .crumb { display: none; }
  h1 { font-size: 1.9rem; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .calc { grid-template-columns: 1.15fr 1fr; align-items: start; }
  .calc .receipt { position: sticky; top: 16px; }
  .grid39 { grid-template-columns: repeat(8, 1fr); }
}

/* 手機：點號碼時，底部浮出即時總數 */
.live {
  position: fixed; left: 12px; right: 12px; z-index: 19;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink); color: var(--paper); border-radius: 12px; padding: 8px 14px;
  font: 600 .95rem var(--mono); box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.live[hidden] { display: none; }
.live a { color: var(--paper); font-family: var(--sans); font-size: .85rem; }
@media (min-width: 760px) { .live { display: none; } }

/* 開獎紀錄 */
table.draws td small { color: var(--muted); font-family: var(--sans); }
.ball {
  display: inline-block; width: 1.9em; height: 1.9em; line-height: 1.9em; margin: 1px 2px;
  border-radius: 50%; text-align: center; background: var(--sun-soft); color: var(--amber); font-weight: 700;
}
@media (max-width: 420px) { table.draws td:nth-child(2) { display: none; } table.draws th:nth-child(2) { display: none; } }

/* 版路表 */
.lu-wrap { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.lu { border-collapse: collapse; font: 600 .72rem/1 var(--mono); font-variant-numeric: tabular-nums; }
table.lu th, table.lu td { min-width: 24px; height: 24px; padding: 0; text-align: center; border: 1px solid var(--line); }
table.lu thead th, table.lu tfoot th { color: var(--muted); background: var(--paper); }
table.lu tr > :first-child { position: sticky; left: 0; z-index: 1; min-width: 46px; padding: 0 4px; background: var(--paper); color: var(--muted); font-weight: 400; }
table.lu tr > :nth-child(10n+2):not(:nth-child(2)) { border-left: 2px solid var(--muted); }
table.lu td.hit { background: var(--sun); color: var(--on-sun); }
.lu-hint { margin-top: 6px; }
@media (min-width: 760px) { .lu-hint { display: none; } }
ol.stat { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
ol.stat li { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 6px; font-size: .9rem; }
ol.stat .ball { margin: 0; grid-row: span 3; }
ol.stat b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
ol.stat i { display: block; height: 4px; border-radius: 2px; background: var(--jade); }
ol.stat small { color: var(--muted); font-size: .76rem; line-height: 1.4; white-space: nowrap; }
@media (min-width: 760px) { ol.stat { grid-template-columns: repeat(5, 1fr); } }

/* 運彩工具 */
table.plays th, table.plays td { text-align: left; font-family: var(--sans); }
table.plays td:first-child { font-weight: 600; white-space: nowrap; }
.legs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legs li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.leg-no { min-width: 3.6em; color: var(--muted); font-size: .92rem; }
.legs input[name="odds"], .odds-grid input, .field select {
  font: inherit; font-family: var(--mono); padding: 8px 10px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.legs input[name="odds"] { width: 6.5em; }
.field select { font-family: var(--sans); max-width: 100%; }
.push { font-size: .9rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.odds-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.odds-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
.odds-grid input { width: 100%; font-size: 1.1rem; }

/* 插畫 */
.art { margin: 0 0 16px; }
.art img { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line); background: var(--card); }
.art-hero { display: none; }
@media (min-width: 760px) {
  .home-top { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: center; }
  .art-hero { display: block; margin: 0; }
  .art-side { float: right; width: 300px; margin: 0 0 12px 20px; }
}
@media (max-width: 759px) { .art-side { max-width: 420px; } }

/* 右下角飄浮「開始遊戲」：固定不拖曳、沒有關閉鈕 */
.go-chip { position: fixed; right: 14px; z-index: 18; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 70px); }
.go-chip a {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--sun); color: var(--on-sun); font-weight: 800; font-size: 1rem;
  padding: 11px 16px 11px 14px; border-radius: 12px 12px 12px 4px;
  border: 2px solid var(--on-sun); box-shadow: 3px 4px 0 rgba(27, 42, 34, .28);
}
.go-chip a small { font: 700 .68rem var(--mono); background: var(--on-sun); color: var(--sun); padding: 1px 5px; border-radius: 6px; }
@media (max-width: 759px) {
  .go-chip { right: 12px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); }
  .go-chip a { height: 38px; padding: 0 11px 0 10px; gap: 5px; font-size: 14px; }
  .go-chip a small { font-size: .6rem; padding: 0 4px; }
  body { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 62px); }
}
@media (min-width: 760px) { .go-chip { bottom: 22px; right: 22px; } }
