/* 公開統計頁樣式；配色與管理頁共用同一組設計 token。 */
:root {
  color-scheme: light dark;
  --page: #f3f6fb; --surface: #fff; --surface-soft: #edf2fa; --text: #17243a;
  --muted: #5e6c82; --line: #d6dfeb; --accent: #173c70; --accent-hover: #24558f;
  --link: #173c70; --error: #b42336; --ok: #23744d;
  --gold: #c99a32; --danger: #a72d3b; --focus: #e3b64f;
}
@media (prefers-color-scheme: dark) {
  :root { --page:#101827; --surface:#182437; --surface-soft:#202f45; --text:#e7edf7;
    --muted:#a8b6ca; --line:#34455e; --accent:#294f7c; --accent-hover:#37699f;
    --link:#a9ceff; --error:#ff9ba6; --ok:#8ed9aa;
    --gold:#d4ad52; --danger:#9d3444; --focus:#e7c56f; }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1rem; }
html, body { margin: 0; padding: 0; }
body { background: var(--page); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
/* PKG57 WEB10：內容很少時（例：排行榜沒有資料）頁尾原本緊接在內容後面，底部那份四語免費警語
   在整頁截圖裡像是出現在頁面中段。改成 flex 直欄、main 吃掉剩餘高度，頁尾固定在頁面最底。
   兩份警語（頂端＋底部）是 docs/free-notice.md 規定的多處放置，不是 sticky／fixed，也不是重複渲染。 */
body { display: flex; flex-direction: column; min-height: 100vh; }
body > main { flex: 1 0 auto; }
a { color: var(--link); }
.wrap { width: min(1100px, 100%); margin: 0 auto; padding: 0 16px; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); padding: 18px 0 10px; }
.site-header h1 { margin: 0; font-size: clamp(1.5rem, 2vw, 2rem); letter-spacing: .02em; }
.site-header .sub { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
nav.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: .48rem .8rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--surface-soft); color: var(--text); text-decoration: none; font-size: .9rem; }
nav.tabs a:hover, nav.tabs a:focus-visible { border-color: var(--focus); background: var(--surface); }
nav.tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
nav.tabs a.login { margin-left: auto; }
main.wrap { padding-top: 16px; padding-bottom: 40px; }
section.card, .card { margin-bottom: 1rem; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); box-shadow: 0 3px 12px #10284a0b; }
.card.narrow { max-width: 420px; margin: 24px auto; }
/* stats.js 以這兩個規則控制分頁顯示，未載入 JS 時保留所有內容。 */
body.js-tabs section.tab { display: none; }
body.js-tabs section.tab.active { display: block; }
h2 { margin: 0 0 1rem; padding-bottom: .55rem; border-bottom: 1px solid var(--line); font-size: 1.15rem; }
h3 { margin: 1.25rem 0 .6rem; }
p.note { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .55rem .75rem; align-items: flex-end; margin-bottom: .75rem; }
.toolbar label, .stack label { display: flex; flex-direction: column; gap: .25rem; color: var(--muted); font-size: .85rem; }
.stack { display: flex; flex-direction: column; gap: .65rem; }
input, select, button { max-width: 100%; min-height: 44px; padding: .48rem .6rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--surface); color: var(--text); font: inherit; }
button { cursor: pointer; padding-inline: .8rem; border-color: var(--line); background: var(--surface-soft); color: var(--text); font-weight: 600; transition: background .15s, border-color .15s; }
button:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.secondary { background: var(--surface-soft); border-color: var(--line); color: var(--text); }
button:disabled { cursor: not-allowed; opacity: .55; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.table-wrap { max-width: 100%; margin: .6rem 0; overflow-x: auto; border: 1px solid var(--line); border-radius: .5rem; }
table { width: 100%; min-width: 42rem; border-collapse: collapse; margin: 0; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .9rem; overflow-wrap: anywhere; }
th { background: var(--surface-soft); white-space: nowrap; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-soft) 58%, transparent); }
tbody tr:hover { background: var(--surface-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 卡號是完整識別鍵；多欄統計表改用橫捲，不拆開官方編號。 */
#cards-table td:first-child { white-space: nowrap; }
td.empty { padding: 1rem; color: var(--muted); text-align: center; }
.pager { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .65rem; color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; padding: 1px 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); font-size: .8rem; }
.badge.gold { color: var(--gold); border-color: var(--gold); }
.badge.warn { color: var(--gold); border-color: var(--gold); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.chip { display: inline-block; width: 12px; height: 12px; margin-right: 3px; border: 1px solid #0008; border-radius: 50%; vertical-align: -1px; }
.chip.blue { background: #1e90ff; } .chip.red { background: #e0413a; } .chip.white { background: #f2f2f2; }
.chip.black { background: #444; } .chip.green { background: #3cb44b; } .chip.colorless { background: #a0a0a0; }
.pool-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: .75rem; }
.pool-tabs button.active { border-color: var(--focus); background: var(--surface-soft); color: var(--text); }
.pool-summary { margin: .4rem 0 .75rem; }
.pool-summary .big { color: var(--link); font-size: 1.15rem; font-weight: 700; }
#err, .msg { min-height: 1em; margin: .65rem 0; color: var(--error); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ok { color: var(--ok); }
.note:empty, #err:empty, .msg:empty { display: none; }
.loading { margin: .65rem 0; color: var(--muted, inherit); }
.loading[hidden] { display: none; }
#err:not(:empty), .msg:not(:empty) { display: block; padding: .6rem .75rem; border: 1px solid var(--line); border-left: 3px solid var(--danger); border-radius: .4rem; background: var(--surface-soft); }
.msg.ok:not(:empty) { border-left-color: var(--ok); }
.low-sample { color: var(--muted); font-style: italic; }
footer.site-footer { padding: 20px 0 30px; color: var(--muted); font-size: .8rem; text-align: center; }
.free-notice { margin: .5rem 0 1rem; padding: .65rem .85rem; border: 2px solid #c99a32; border-radius: .55rem; background: #fff4cf; color: #503c00; font-size: 1rem; font-weight: 650; text-align: left; }
.free-notice p { margin: .15rem 0; }
footer.site-footer .free-notice { max-width: 960px; margin: 10px auto 0; }
footer.site-footer .disclaimer { max-width: 960px; margin: 10px auto 0; font-size: .8rem; }
footer.site-footer .disclaimer p { margin: 2px 0; }
.need-login[hidden], .need-auth[hidden] { display: none; }
.toolbar .hint { align-self: center; color: var(--muted); font-size: .85rem; }
@media (max-width: 640px) {
  body { font-size: 14px; }
  /* PKG57 WEB10：390px 寬時四語警語原本 16px 粗體約 440px 高，把標題與分頁擠到第一屏外。
     窄螢幕改 13px（仍大於頁尾聲明的 .8rem）、行距與內距收緊，約減到一半高；文字與四語都不刪。 */
  .free-notice { margin: .4rem 0 .75rem; padding: .45rem .6rem; font-size: .8125rem; line-height: 1.4; font-weight: 600; }
  .free-notice p { margin: .1rem 0; }
  footer.site-footer { padding-inline: 12px; }
  .wrap { padding-inline: 12px; }
  .site-header { padding-top: 12px; }
  nav.tabs a { flex: 1 1 auto; justify-content: center; }
  nav.tabs a.login { margin-left: 0; }
  section.card { padding: .85rem; }
  .toolbar label { flex: 1 1 45%; min-width: min(100%, 10rem); }
  .toolbar input, .toolbar select { width: 100%; }
  th, td { padding: .45rem .5rem; }
}
/* PKG59 EXTRA-48：寬螢幕的 table 有 min-width 42rem（=672px），390 寬時外框只剩約 338px，
   後面的欄位要橫向捲動才看得到（違反「不得有捲動才看得到的截斷」）。
   760px（42rem＋頁面與卡片左右內距）以下改成每列一張卡片、每格一行「欄名：值」；
   欄名來自 stats.js／cards.js 的 labelCells()，從表頭複製到 data-label，所以跟表頭同語言。
   跨欄儲存格（樣本不足、沒有資料）沒有 data-label，整行顯示。 */
@media (max-width: 760px) {
  .table-wrap { overflow-x: visible; border: 0; border-radius: 0; }
  table { min-width: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tbody tr { margin-bottom: .6rem; border: 1px solid var(--line); border-radius: .5rem; }
  tbody tr:last-child { margin-bottom: 0; }
  td, td.num { display: flow-root; text-align: left; }
  tbody tr td:last-child { border-bottom: 0; }
  td[data-label]::before { content: attr(data-label); float: left; width: 40%; padding-right: .6rem; color: var(--muted); font-weight: 600; }
  #cards-table td:first-child { white-space: normal; }
}
@media (max-width: 390px) {
  .wrap { padding-inline: 8px; }
  section.card { padding: .75rem; }
  .toolbar label { flex-basis: 100%; }
  nav.tabs a { flex: 0 1 calc(50% - 3px); min-width: 0; overflow-wrap: anywhere; }
}
/* PKG59 複測：卡片統計表（#cards-table，卡號＋16 個數值欄）在 1280 寬原本要橫捲
   （headless Edge 實測表寬 1458〜2567px，外框只有 1026px）。改成：卡片頁內容區放寬到 1240px、
   這張表的表頭可換行、字級與內距收小、數值不換行；內容區還是放不下全部欄位的寬度
   （1180px 以下）改用與窄螢幕相同的「每列一張卡片」版面，任何寬度都不需要橫捲。 */
.wrap.wide { width: min(1240px, 100%); }
#cards-table { min-width: 0; }
#cards-table th { white-space: normal; overflow-wrap: normal; font-size: .74rem; line-height: 1.3; vertical-align: bottom; }
#cards-table th, #cards-table td { padding: .4rem .28rem; }
#cards-table td { font-size: .8rem; }
#cards-table td.num { white-space: nowrap; }
@media (max-width: 1180px) {
  #cards-table, #cards-table tbody, #cards-table tr, #cards-table td { display: block; width: 100%; }
  #cards-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #cards-table tbody tr { margin-bottom: .6rem; border: 1px solid var(--line); border-radius: .5rem; }
  #cards-table tbody tr:last-child { margin-bottom: 0; }
  #cards-table td, #cards-table td.num { display: flow-root; text-align: left; font-size: .9rem; padding: .45rem .6rem; }
  #cards-table tbody tr td:last-child { border-bottom: 0; }
  #cards-table td[data-label]::before { content: attr(data-label); float: left; width: 40%; padding-right: .6rem; color: var(--muted); font-weight: 600; }
  #cards-table td:first-child { white-space: normal; }
  .table-wrap:has(> #cards-table) { overflow-x: visible; border: 0; border-radius: 0; }
}
