:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #efece3;
  --text: #1d2420;
  --muted: #5c665f;
  --line: #dcd7ca;
  --felt: #1f5c45;
  --felt-ink: #ffffff;
  --gold: #a5761c;
  --chaos: #a3307a;
  --teal: #1d7f7a;
  --violet: #6a55b8;
  --ok: #2f7d4f;
  --warn: #a8641a;
  --code-bg: #ece8dc;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 5%);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Noto Sans Mono CJK SC", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111613; --surface: #182019; --surface-2: #1f2a22; --text: #e6ebe7; --muted: #9aa69e;
    --line: #2c3a30; --felt: #2f8a66; --gold: #d9a845; --chaos: #e06bb7; --teal: #4cc3b8; --violet: #a493f0; --ok: #5fc08a; --warn: #e3a35a;
    --code-bg: #222d25; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111613; --surface: #182019; --surface-2: #1f2a22; --text: #e6ebe7; --muted: #9aa69e;
  --line: #2c3a30; --felt: #2f8a66; --gold: #d9a845; --chaos: #e06bb7; --teal: #4cc3b8; --violet: #a493f0; --ok: #5fc08a; --warn: #e3a35a;
  --code-bg: #222d25; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
a { color: var(--felt); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--felt); color: var(--felt-ink); }
.top a { color: inherit; text-decoration: none; }
.brand { font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand .tag { font-weight: 500; opacity: .75; }
.suit { color: var(--gold); }
.search-wrap { position: relative; margin-left: auto; }
.filter { width: min(300px, 40vw); padding: 6px 10px; border-radius: 8px; border: 0;
  background: rgb(255 255 255 / 15%); color: inherit; font: inherit; font-size: 14px; }
.filter::placeholder { color: rgb(255 255 255 / 70%); }
.theme { flex: none; width: 32px; height: 32px; border: 1px solid rgb(255 255 255 / 40%); border-radius: 999px;
  background: none; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.theme:hover, .lang:hover { background: rgb(255 255 255 / 12%); }
.lang { font-size: 14px; padding: 4px 10px; border: 1px solid rgb(255 255 255 / 40%); border-radius: 999px; }
.menu { display: none; background: none; border: 0; color: inherit; font-size: 20px; cursor: pointer; }

/* layout */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr) 200px; gap: 32px;
  max-width: 1280px; margin: 0 auto; padding: 24px 20px 48px; }
.side, .toc { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow-y: auto; font-size: 14px; }
.side .group { margin-bottom: 18px; }
.side p, .toc p { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side a, .toc a { display: block; padding: 3px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.side a.sub { padding-left: 20px; color: var(--muted); font-size: 13px; }
.side details.subs > summary { display: flex; align-items: center; list-style: none; cursor: pointer; border-radius: 6px; }
.side details.subs > summary::-webkit-details-marker { display: none; }
.side details.subs > summary a { flex: 1; min-width: 0; }
.side details.subs > summary .count { font-size: 11px; color: var(--muted); padding: 0 2px; }
.side details.subs > summary::after { content: "▸"; padding: 0 8px; color: var(--muted); transition: transform .15s; }
.side details.subs[open] > summary::after { transform: rotate(90deg); }
.side details.subs > summary:hover { background: var(--surface-2); }
.side details.subs > summary:hover a { background: none; }
.side details.subs { margin: 0; padding: 0; border: 0; }
.side details.subs[open] { padding-bottom: 4px; }
.side a:hover, .toc a:hover { background: var(--surface-2); }
.side a[aria-current="page"] { background: var(--surface-2); color: var(--felt); font-weight: 600; }
.toc a.l3 { padding-left: 18px; color: var(--muted); }
main { min-width: 0; }
article { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 36px; box-shadow: var(--shadow); }
article h1 { margin: 0 0 12px; font-size: 30px; line-height: 1.25; }
article h2 { margin-top: 36px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 22px; }
article h3 { margin-top: 24px; font-size: 18px; }
article img { max-width: 100%; }
article img[src="../img/poker-head.png"], article img[src="../img/j54.png"] {
  display: block; width: min(100%, 420px); height: auto;
  margin: 20px auto; border-radius: var(--radius);
}
blockquote { margin: 16px 0; padding: 4px 16px; border-left: 3px solid var(--gold); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.stamp { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.notice { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); color: var(--warn); font-size: 14px; }
.crumb { margin: 0 0 12px; font-size: 14px; }

/* search results */
.results { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(460px, 92vw);
  max-height: 70vh; overflow-y: auto; padding: 6px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgb(0 0 0 / 22%); }
.results .none { margin: 10px 12px; color: var(--muted); font-size: 14px; }
.hit { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px;
  color: var(--text) !important; text-decoration: none; }
.hit[aria-selected="true"], .hit:hover { background: var(--surface-2); }
.hit img, .hit .dot { width: 32px; height: 32px; flex: none; border-radius: 8px; object-fit: contain; background: var(--surface-2); }
.hit .dot { display: inline-block; }
.hit span { display: flex; flex-direction: column; min-width: 0; }
.hit strong { font-size: 14px; }
.hit em { font-style: normal; font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: .04em; }
.hit small { font-size: 12px; color: var(--muted); line-height: 1.45; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; border-radius: 2px; }

/* breadcrumbs, pager, full rules */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--felt); }
.crumbs [aria-current] { color: var(--text); }
.crumbs .sep { opacity: .6; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; max-width: 48%; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 8px; text-decoration: none; }
.pager a:hover { border-color: var(--felt); }
.pager a[rel="next"] { margin-left: auto; text-align: right; }
.pager small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tagline { margin: 6px 0 0; font-style: italic; color: var(--gold); }
dl.details { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 12px 0; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
dl.details dt, dl.details dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); }
dl.details dt { color: var(--muted); font-weight: 600; background: var(--surface-2); }
dl.details dt:last-of-type, dl.details dd:last-of-type { border-bottom: 0; }

/* tables */
.table-wrap { overflow-x: auto; margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
table.catalog { min-width: 640px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: var(--surface-2); font-weight: 600; }
table.facts { width: auto; min-width: 50%; }
table.facts th { width: 160px; color: var(--muted); font-weight: 500; background: none; }
table.transcript td:first-child { color: var(--muted); }
table.transcript td:nth-child(2) { white-space: nowrap; }

/* cards and icons */
.icon { width: 48px; height: 48px; flex: none; border-radius: 10px; object-fit: contain; background: var(--surface-2); }
.icon.big { width: 96px; height: 96px; border-radius: 16px; }
.icon.ph { display: inline-grid; place-items: center; font: 700 15px var(--mono); color: var(--muted);
  border: 1px dashed var(--line); }
.icon.ph.big { font-size: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 16px 0; }
.card { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; background: var(--surface); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--felt); transform: translateY(-1px); }
.card.rule:hover { border-color: var(--chaos); }
.card-body { display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; }
.card-body strong { font-size: 15px; }
.pill { display: inline-block; width: fit-content; padding: 0 8px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--gold); font-weight: 600; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--warn); vertical-align: middle; }
.hero { display: flex; gap: 20px; align-items: center; margin-bottom: 8px; }
.hero h1 { margin: 0; }
.hero.rule h1 { color: var(--chaos); }
.lead { margin: 6px 0 0; font-size: 17px; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.art { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.art .icon.big { width: 100%; height: 110px; }
.art figcaption { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 8px; font-size: 13px; }
.art code { font-size: 11px; }

.landing main { max-width: 480px; margin: 20vh auto; text-align: center; }

/* responsive */
@media (max-width: 1100px) { .layout { grid-template-columns: 220px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .menu { display: block; }
  .side { display: none; position: static; max-height: none; }
  body.nav-open .side { display: block; }
  .top { gap: 8px; padding: 10px 16px; }
  .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .brand .tag { display: none; }
  .filter { width: 100%; }
  .lang { flex: none; white-space: nowrap; }
  article { padding: 20px 16px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .search-wrap { flex: 1 1 0; min-width: 0; }
  .results { position: fixed; left: 12px; right: 12px; top: 56px; width: auto; }
  dl.details { grid-template-columns: 1fr; }
  dl.details dt { border-bottom: 0; padding-bottom: 2px; }
  .pager a { max-width: 100%; }
}
@media (max-width: 480px) {
  .brand .name { display: none; }
}

/* design docs */
.banner { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-size: 14px;
  background: var(--surface-2); border-left: 3px solid var(--ok); }
.banner.planned { border-left-color: var(--chaos); }
article details { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
article summary { cursor: pointer; color: var(--muted); }

/* card colour by item group (game GROUP_COLORS) */
.card.g-perm { border-left: 3px solid var(--gold); }
.card.g-cons { border-left: 3px solid var(--teal); }
.card.g-special { border-left: 3px solid var(--violet); }
.card.rule { border-left: 3px solid var(--chaos); }
.card.environment { border-left: 3px solid var(--chaos); }

/* catalog filters */
.filters { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 8px; padding: 12px 14px;
  background: var(--surface-2); border-radius: var(--radius); font-size: 13px; }
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.flabel { min-width: 64px; color: var(--muted); font-weight: 600; }
.filters button, .filters select { font: inherit; font-size: 13px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--felt); border-color: var(--felt); color: var(--felt-ink); }
.filters select { border-radius: 8px; }
.ftools { padding-top: 6px; border-top: 1px dashed var(--line); }
.ftools label { color: var(--muted); }
.fcount { margin-left: auto; color: var(--muted); }
.filters .ftoggle { display: none; }
.catalog-view.list .cards { grid-template-columns: 1fr; gap: 4px; }
.catalog-view.list .card { padding: 6px 10px; align-items: center; }
.catalog-view.list .card .icon { width: 28px; height: 28px; border-radius: 6px; }
.catalog-view.list .card-body { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.catalog-view.list .card-body .muted { flex-basis: 100%; font-size: 13px; }
[hidden] { display: none !important; }

/* table cards (Home, Tables) */
.table-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.table-card { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.table-card:hover { border-color: var(--felt); transform: translateY(-2px); }
.table-card .portrait { width: 100%; height: 160px; object-fit: cover; object-position: center 22%; background: var(--surface-2); }
.table-card .icon.big { width: 100%; height: 150px; border-radius: 0; }
.tc-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; font-size: 14px; }
.tc-body strong { font-size: 17px; }
.tc-body .host { color: var(--muted); font-size: 13px; }
.tc-body .desc { color: var(--text); }
.tc-body .mini { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tc-body .mini span { display: flex; flex-direction: column; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.tc-body .mini em { font-style: normal; font-size: 11px; color: var(--muted); }

/* stat tiles (table and dealer pages) */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 15px; font-weight: 600; }
blockquote.quote { font-style: italic; border-left-color: var(--gold); }

/* phones: tables become one card per row */
@media (max-width: 760px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack.catalog { min-width: 0; }
  table.stack thead { display: none; }
  table.stack tr { margin: 0 0 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
  table.stack td { display: flex; gap: 10px; padding: 4px 0; border: 0; }
  table.stack td::before { content: attr(data-label); flex: 0 0 34%; color: var(--muted); font-size: 12px; }
  .flabel { min-width: 100%; }
  .filters .ftoggle { display: inline-block; }
  .filters .ftoggle[aria-expanded="true"] { background: var(--felt); border-color: var(--felt); color: var(--felt-ink); }
  .filters:not(.open) .frow:not(.ftools) { display: none; }
  .filters:not(.open) .ftools { padding-top: 0; border-top: 0; }
  .table-card .portrait, .table-card .icon.big { height: 120px; }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 3px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--text); background: var(--surface); }
.chip:hover { border-color: var(--felt); }
.chip .icon { width: 22px; height: 22px; border-radius: 999px; font-size: 9px; }
