/* Card Game Rules – website
   A printed-rulebook look: cream paper, red & black ink like a real deck,
   book typography. In dark mode the page becomes a green card table and the
   playing cards stay light, like real cards on felt. */

@font-face {
  font-family: "Alegreya";
  src: url("../webfonts/alegreya.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("../webfonts/alegreya-italic.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
/* ♠♥♦♣ and a few arrows/maths signs, so suits look the same on every device */
@font-face {
  font-family: "Suits";
  src: url("../webfonts/suits.woff2") format("woff2");
  unicode-range: U+2660-2667, U+2190-2195, U+2264-2265, U+00D7, U+2212, U+25B8, U+25A2;
}

:root {
  --paper: #f3ede0;
  --ink: #1b1714;
  --ink-soft: #5d544a;
  --rule: #cfc4ae;          /* decorative hairlines */
  --line: #877c68;          /* borders of controls: ≥ 3:1 against the paper (WCAG 1.4.11) */
  --red: #b3141b;
  --card: #fffcf5;
  --card-ink: #1b1714;
  --card-soft: #6a6055;
  --card-rule: #ddd3c0;
  --card-line: #8f8571;
  --card-red: #b3141b;
  --serif: "Alegreya", "Suits", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1a14;          /* felt */
    --ink: #e8e0cc;
    --ink-soft: #a9b3a4;
    --rule: #2c4236;
    --line: #6b8a77;
    --red: #ef6a5f;
    color-scheme: dark;
  }
  body {
    background:
      radial-gradient(ellipse at 50% -10%, #1c3a2b 0%, transparent 60%),
      var(--paper);
    background-attachment: fixed;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.125rem/1.55 var(--serif);
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 42rem; margin: 0 auto; padding: 0 20px 2rem; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; text-decoration-color: var(--rule); transition: text-decoration-color .15s; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.suit.red, .r { color: var(--red); }

/* small caps label style, used for navigation and headings of minor sections */
.label, .kicker, .bar, .jump, .facts dt, .playing-card h2, .aside, .foot {
  font-variant-caps: all-small-caps;
  font-variant-numeric: lining-nums;
  letter-spacing: .08em;
}

/* ---- top bar ---------------------------------------------------------- */
.bar {
  max-width: 42rem; margin: 0 auto; padding: 14px 20px 0;
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 1.05rem;
}
.bar a { text-decoration: none; }
.bar-home { font-weight: 700; }
.bar-lang { display: flex; gap: .7rem; }
.bar-lang a { color: var(--ink-soft); }
.bar-lang a:hover { color: var(--ink); }
.bar-lang [aria-current] { border-bottom: 1.5px solid var(--red); }

/* ---- ornaments -------------------------------------------------------- */
.ornament { text-align: center; letter-spacing: .6em; margin: 0; font-size: 1rem; color: var(--ink); }
.ornament span { font-family: "Suits", var(--serif); }

/* ---- front page ------------------------------------------------------- */
.masthead { text-align: center; padding: 3.2rem 0 2.2rem; border-bottom: 3px double var(--rule); }
.masthead h1 { font-size: clamp(2.6rem, 11vw, 4rem); margin: .8rem 0 .6rem; font-weight: 900; letter-spacing: -.02em; hyphens: manual; }
.lede { font-style: italic; color: var(--ink-soft); margin: 0 auto; max-width: 30rem; font-size: 1.2rem; line-height: 1.4; }

.games { list-style: none; margin: 0; padding: 0; }
.games li { border-bottom: 1px solid var(--rule); }
.games a { display: flex; gap: 1.1rem; align-items: center; padding: 1.25rem 0; text-decoration: none; }
.g-text { display: flex; flex-direction: column; min-width: 0; }
.g-title { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.games a:hover .g-title { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: .15em; }
.g-tag { font-style: italic; color: var(--ink-soft); line-height: 1.35; margin: .25rem 0 .35rem; }
.g-meta { font-size: .95rem; font-variant-caps: all-small-caps; letter-spacing: .06em; font-variant-numeric: lining-nums; color: var(--ink-soft); }

/* collections (overview pages) */
.collections { margin: 1.4rem 0 0; }
.collections .label { display: block; margin-bottom: .3rem; }
.collections ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; }
.collections a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.collections a:hover, .collections a[aria-current] { border-bottom-color: var(--red); }
.collections a[aria-current] { font-weight: 700; }
.collections .n, .group-title .n { font-size: .8em; color: var(--ink-soft); font-variant-numeric: lining-nums; }
.masthead.small { padding: 2.4rem 0 1.6rem; }
.masthead.small h1 { font-size: clamp(2.2rem, 9vw, 3.2rem); margin-top: .4rem; }
.masthead .kicker a { text-decoration: none; border-bottom: 1px solid var(--rule); }
main > .collections:last-child { margin-top: 2.6rem; padding-top: 1.2rem; border-top: 3px double var(--rule); }

.in-collections { text-align: center; margin: 1rem 0 0; font-size: 1rem; color: var(--ink-soft); }
.in-collections .label { font-size: .95rem; margin-right: .3rem; }
.in-collections a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }

/* games grouped by kind on the front page */
.group[hidden] { display: none; }
.group-title {
  margin: 2.2rem 0 0; padding-bottom: .4rem; border-bottom: 2px solid var(--ink);
  font-size: 1.15rem; font-weight: 700; font-variant-caps: all-small-caps; letter-spacing: .08em;
}

.group-intro { margin: .5rem 0 0; color: var(--ink-soft); font-size: .98rem; line-height: 1.45; }
.glossary { margin: 0; padding: .2rem 0 .7rem; border-top: 1px dotted var(--rule); font-size: .95rem; }
.glossary dt { font-weight: 700; margin-top: .6rem; }
.glossary dd { margin: .1rem 0 0; color: var(--ink-soft); }

/* game filter */
/* foldable boxes on the start page (collections, filter, jump to): one stacked accordion */
.fold { margin: 1.6rem 0 .4rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.fold + .fold, .fold + .fold[hidden] + .fold { margin-top: -.4rem; border-top: 0; }
.fold summary { cursor: pointer; padding: .6rem 0; list-style: none; display: flex; align-items: baseline; gap: .8rem; min-height: 44px; box-sizing: border-box; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "▸"; font-family: "Suits", sans-serif; color: var(--red); font-size: .8rem; transition: transform .15s; }
.fold[open] summary::before { transform: rotate(90deg); }
.fold .f-sum { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold[open] .f-sum { display: none; }
.best-nav .all a { font-style: italic; }
.fold .collections, .fold .jump-groups { margin: 0; padding: .2rem 0 .7rem; border-top: 1px dotted var(--rule); }
.f-title { font-weight: 700; font-variant-caps: all-small-caps; letter-spacing: .08em; font-size: 1.1rem; }
.f-sum { font-style: italic; color: var(--ink-soft); font-size: .98rem; }
.filter { padding: 0 0 .3rem; border-top: 1px dotted var(--rule); }
.f-row { display: flex; align-items: baseline; gap: .9rem; padding: .45rem 0; border-bottom: 1px dotted var(--rule); }
.f-opts { flex: 1; display: flex; flex-wrap: wrap; gap: .1rem .9rem; }
.f-row:last-of-type { border-bottom: 0; }
.f-label { flex: 0 0 5.2rem; font-variant-caps: all-small-caps; letter-spacing: .08em; color: var(--ink-soft); font-size: 1rem; }
.filter button {
  font: inherit; font-size: 1.02rem; color: var(--ink-soft); background: none; border: 0; padding: .1rem 0; cursor: pointer;
  border-bottom: 2px solid transparent; font-variant-numeric: lining-nums;
}
.filter button:hover { color: var(--ink); }
.filter button[aria-pressed="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--red); }
.f-status { margin: .5rem 0 .2rem; font-size: .98rem; color: var(--ink-soft); font-style: italic; }
.f-status button { font-style: normal; font-variant-caps: all-small-caps; letter-spacing: .06em; margin-left: .5rem; color: var(--red); }
.f-none { text-align: center; font-style: italic; color: var(--ink-soft); padding: 2rem 0; border-bottom: 1px solid var(--rule); margin: 0; }
.games li[hidden] { display: none; }
@media (max-width: 480px) { .f-label { flex-basis: 4.4rem; } .filter button { font-size: .98rem; } }

/* a small playing card with corner indices */
.pip-card {
  flex: none; position: relative;
  width: 58px; height: 81px;
  background: var(--card); color: var(--card-ink);
  border: 1px solid var(--card-rule); border-radius: 6px;
  box-shadow: 0 1px 0 rgb(0 0 0 / .06), 0 3px 8px -4px rgb(0 0 0 / .25);
  font-family: "Suits", var(--serif);
  transform: rotate(-3deg);
  transition: transform .2s ease;
}
.games li:nth-child(even) .pip-card { transform: rotate(2.5deg); }
.games a:hover .pip-card { transform: rotate(0) translateY(-3px); }
.pip-card.red { color: var(--card-red); }
.pip-card .idx { position: absolute; left: 5px; top: 4px; font: 700 .72rem/1 var(--serif); text-align: center; }
.pip-card .idx.flip { left: auto; top: auto; right: 5px; bottom: 4px; transform: rotate(180deg); }
.pip-card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.9rem; font-family: "Suits", sans-serif; }

.aside { margin: 1.6rem 0 0; color: var(--ink-soft); font-size: 1.05rem; text-align: center; }
.aside a { color: var(--ink); }

.takeaway { margin-top: 3rem; padding-top: 1.2rem; border-top: 3px double var(--rule); }
.label { font-size: 1.05rem; font-weight: 700; margin: 0 0 .6rem; color: var(--ink-soft); }
.takeaway ul { list-style: none; padding: 0; margin: 0; }
.takeaway li { padding: .35rem 0; }
.takeaway li::before { content: "↓"; font-family: "Suits", sans-serif; color: var(--red); margin-right: .6rem; font-size: .9em; }

/* ---- game page -------------------------------------------------------- */
.game-head { padding: 2.6rem 0 1.4rem; text-align: center; }
.kicker { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }
.suit-mark { font-family: "Suits", sans-serif; color: var(--ink); margin-left: .25rem; font-variant-caps: normal; }
.is-red .suit-mark, .suit-mark.r { color: var(--red); }
.game-head h1 { font-size: clamp(2.6rem, 12vw, 4.2rem); margin: .3rem 0 .5rem; font-weight: 900; letter-spacing: -.02em; }
.game-head .lede { margin-bottom: 1.6rem; }

.facts {
  display: grid; grid-template-columns: repeat(2, 1fr);
  margin: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
@media (min-width: 560px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.facts div { padding: .6rem .4rem; }
.facts .wide { grid-column: 1 / -1; border-top: 1px solid var(--rule); }
.facts dt { font-size: .9rem; color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 700; line-height: 1.25; font-variant-numeric: lining-nums; }

.jump { display: flex; justify-content: center; flex-wrap: wrap; gap: .3rem .7rem; margin: 1.3rem 0 1.6rem; font-size: 1.1rem; }
.jump span { color: var(--rule); }
.jump a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.jump a:hover { border-color: var(--red); }

/* quick rules + cheat sheet as two real-looking playing cards */
.table { display: grid; gap: 22px; margin: 0 0 3rem; }
@media (min-width: 760px) {
  .table { grid-template-columns: 1fr 1fr; margin-left: -3rem; margin-right: -3rem; }
}
.playing-card {
  position: relative;
  background: var(--card); color: var(--card-ink);
  border: 1px solid var(--card-rule);
  border-radius: 14px;
  padding: 1.4rem 2.4rem 1.6rem;
  font-size: 1.02rem; line-height: 1.45;
  font-variant-numeric: lining-nums;
  box-shadow: 0 1px 0 rgb(0 0 0 / .05), 0 10px 24px -14px rgb(0 0 0 / .35);
}
/* the inner frame line of a real card */
.playing-card::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--card-rule); border-radius: 9px; pointer-events: none;
}
.corner { position: absolute; font: 700 1rem/1 var(--serif); text-align: center; font-family: "Suits", var(--serif); }
.corner.tl { left: 13px; top: 13px; }
.corner.br { right: 13px; bottom: 13px; transform: rotate(180deg); }
.is-red .corner { color: var(--card-red); }
.playing-card h2 { text-align: center; font-size: 1.2rem; margin: 0 0 .8rem; color: var(--card-soft); font-weight: 700; }
.playing-card h3 { font-size: 1rem; font-variant-caps: all-small-caps; letter-spacing: .07em; margin: 1rem 0 .3rem; }
.playing-card ul { padding-left: 1.1rem; margin: 0; }
.playing-card li { margin: .3rem 0; }
.playing-card li::marker { color: var(--card-red); }
.playing-card p { margin: .5rem 0; }
.playing-card .suit.red { color: var(--card-red); }
.playing-card th, .playing-card td { border-color: var(--card-rule); }
.playing-card table { font-size: .95rem; }

/* ---- long-form rules -------------------------------------------------- */
.prose { hyphens: auto; }
.prose .part {
  text-align: center; font-size: 1.9rem; margin: 0 0 1.2rem;
  padding-top: 1.6rem; border-top: 3px double var(--rule);
}
.toc {
  margin: 0 0 2.2rem; padding: .8rem 0; list-style: none; counter-reset: toc;
  font-size: 1.05rem; line-height: 1.5;
  columns: 2; column-gap: 1.5rem;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.toc { hyphens: manual; font-size: 1.1rem; }
.toc li { counter-increment: toc; break-inside: avoid; padding: .15rem 0 .15rem 1.7rem; text-indent: -1.7rem; }
.toc li::before { content: counter(toc); display: inline-block; width: 1.7rem; text-indent: 0; color: var(--red); font-weight: 700; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.prose h2:not(.part) {
  font-size: 1.55rem; margin: 2.6rem 0 .7rem;
}
.prose h2:not(.part)::before {
  content: "♠"; font-family: "Suits", sans-serif; font-size: .7em; vertical-align: .12em;
  margin-right: .5rem; color: var(--ink-soft);
}
.is-red .prose h2:not(.part)::before { content: "♥"; color: var(--red); }
.prose h3 { font-size: 1.2rem; margin: 1.8rem 0 .4rem; }
.prose p { margin: 0 0 .9rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1rem; }
.prose li { margin: .3rem 0; }
.prose li::marker { color: var(--ink-soft); }
.prose strong { font-weight: 800; }

blockquote {
  margin: 1.4rem 0; padding: .1rem 0 .1rem 1.1rem;
  border-left: 2px solid var(--red);
  font-style: italic;
}
blockquote strong { font-style: normal; }
blockquote p { margin: .4rem 0; }

table {
  width: 100%; border-collapse: collapse; margin: 1rem 0 1.4rem;
  font-size: 1rem; line-height: 1.35;
  border-top: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  font-variant-numeric: lining-nums tabular-nums;
}
.prose table { display: block; overflow-x: auto; }
@media (min-width: 560px) { .prose table { display: table; } }
th {
  text-align: left; font-weight: 700; padding: .45rem .6rem .35rem 0;
  border-bottom: 1px solid currentColor;
  font-variant-caps: all-small-caps; letter-spacing: .06em;
}
td { padding: .4rem .6rem .4rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

/* background & history: facts list as a ruled table, sources small */
.history { margin-top: 3.2rem; }
.history > ul:first-of-type { list-style: none; padding: 0; margin: 0 0 1.6rem; border-top: 1px solid var(--rule); }
.history > ul:first-of-type li { margin: 0; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.history > ul:first-of-type strong { font-weight: 700; font-variant-caps: all-small-caps; letter-spacing: .06em; color: var(--ink-soft); margin-right: .3rem; }
.history h2:not(.part) { font-size: 1.1rem; font-variant-caps: all-small-caps; letter-spacing: .08em; color: var(--ink-soft); margin-top: 2rem; }
.history h2:not(.part)::before { content: none; }
.history h2:not(.part) + ul { font-size: .95rem; color: var(--ink-soft); padding-left: 1.1rem; }

/* ---- footer ----------------------------------------------------------- */
.foot { max-width: 42rem; margin: 2rem auto 0; padding: 2rem 20px 3rem; text-align: center; color: var(--ink-soft); font-size: 1.05rem; }
.foot .ornament { margin-bottom: .8rem; font-variant-caps: normal; }
.foot a { color: inherit; }

/* ---- simple pages (language picker, 404) ------------------------------ */
.center { text-align: center; padding-top: 18vh; }
.button { display: inline-block; padding: .5rem 0; font-size: 1.3rem; }

@media print {
  .bar, .jump, .foot, .toc, .skip, .search, .filter-box, .fold, .jump-groups, .takeaway, .collections, .start-here,
  .sp-more, .sp-actions, .sp-storage { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .playing-card { break-inside: avoid; box-shadow: none; }
}

/* ---- score pad (assets/js/score.js) ----------------------------------- */
.jump .jump-score { color: var(--red); border-bottom-color: var(--red); }
.score-head { padding-bottom: 1rem; }
.score-app { margin: 0 0 1rem; font-variant-numeric: lining-nums tabular-nums; }
.score-app button, .score-app input, .score-app select { font: inherit; color: inherit; }
.sp-h { font-size: 1.05rem; font-weight: 700; font-variant-caps: all-small-caps; letter-spacing: .08em; color: var(--ink-soft); margin: 1.6rem 0 .6rem; }
.sp-sub { color: var(--ink-soft); font-style: italic; font-size: .92em; }
.sp-sessions { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.sp-sessions li { display: flex; align-items: center; border-bottom: 1px solid var(--rule); }
.sp-link { flex: 1; text-align: left; background: none; border: 0; padding: .6rem 0; cursor: pointer; display: flex; flex-direction: column; }
.sp-names { font-weight: 700; }
.sp-del { background: none; border: 0; font-size: 1.4rem; color: var(--ink-soft); cursor: pointer; padding: .2rem .6rem; }
.sp-players { display: grid; gap: .5rem; }
.score-app input[type=text], .score-app input[type=number], .score-app select {
  width: 100%; padding: .55rem .7rem; font-size: 1.1rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--card-ink);
}
.sp-count { display: flex; align-items: center; gap: .8rem; margin: .7rem 0; color: var(--ink-soft); }
.sp-count button, .sp-more button, .sp-actions button {
  background: none; border: 1px solid var(--line); border-radius: 6px; padding: .4rem .9rem; cursor: pointer;
}
.sp-count button { width: 2.6rem; font-size: 1.2rem; padding: .2rem 0; }
.sp-settings { margin: 1rem 0; border-top: 1px dotted var(--rule); border-bottom: 1px dotted var(--rule); padding: .4rem 0; }
.sp-settings summary { cursor: pointer; padding: .3rem 0; }
.sp-field { display: grid; gap: .25rem; margin: .7rem 0; }
.sp-field > span:first-child, .sp-field > label { font-size: .95rem; color: var(--ink-soft); font-variant-caps: all-small-caps; letter-spacing: .06em; }
.sp-check { display: flex; gap: .6rem; align-items: center; margin: .7rem 0; }
.sp-check input { width: 1.2rem; height: 1.2rem; }
.score-app .sp-primary { background: var(--ink); color: var(--paper); border: 0; border-radius: 6px; padding: .65rem 1.4rem; font-weight: 700; cursor: pointer; }
.sp-danger { color: var(--red) !important; border-color: var(--red) !important; }
.sp-summary { text-align: center; color: var(--ink-soft); font-style: italic; margin: 0 0 .6rem; }
.sp-note { font-size: .98rem; border-left: 2px solid var(--red); padding-left: .8rem; margin: .6rem 0 1rem; }
.sp-winner { text-align: center; padding: .8rem; margin: 0 0 1rem; border-top: 3px double var(--rule); border-bottom: 3px double var(--rule); font-size: 1.25rem; }
.sp-winner strong { font-weight: 800; }
.sp-table-wrap { overflow-x: auto; }
.sp-table { width: 100%; border-collapse: collapse; display: table; font-size: 1.1rem; }
.sp-table th, .sp-table td { text-align: right; padding: .45rem .5rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.sp-table thead th { text-align: right; font-variant-caps: normal; letter-spacing: 0; font-size: 1rem; border-bottom: 1.5px solid currentColor; max-width: 8rem; overflow: hidden; text-overflow: ellipsis; }
.sp-table .sp-rn { text-align: left; color: var(--ink-soft); width: 2.2rem; font-weight: 400; }
.sp-table tbody tr { cursor: pointer; }
.sp-table tbody tr:hover { background: color-mix(in srgb, var(--red) 6%, transparent); }
.sp-table tbody tr:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; background: color-mix(in srgb, var(--red) 8%, transparent); }
.sp-total td, .sp-total th { font-weight: 800; border-top: 1.5px solid currentColor; border-bottom: 0; background: var(--paper); position: sticky; bottom: 0; }
.sp-lead { color: var(--red); }
.sp-table .sp-out { color: var(--ink-soft); text-decoration: line-through; font-weight: 400; }
.sp-entry { margin: 1rem 0; padding: .4rem 1rem 1rem; background: var(--card); color: var(--card-ink); border: 1px solid var(--card-rule); border-radius: 10px; }
.sp-entry .sp-h { color: var(--card-soft); }
.sp-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0 .8rem; }
.sp-num { display: flex; gap: .3rem; }
.sp-pm { flex: none; width: 2.6rem; border: 1px solid var(--card-line); border-radius: 6px; background: none; cursor: pointer; font-size: 1.1rem; }
.sp-warn { color: var(--card-red); font-size: .95rem; margin: .3rem 0; }
.sp-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.sp-more { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.6rem 0 0; font-size: .95rem; }
.sp-storage { color: var(--ink-soft); font-size: .9rem; font-style: italic; text-align: center; }
.sp-next { text-align: center; font-weight: 700; margin: 0 0 .6rem; }
.sp-table td.sp-dealt::before { content: "●"; font-size: .5em; vertical-align: .25em; margin-right: .35em; color: var(--red); }
.sp-seats { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .4rem 0; }
.sp-dealer-pick { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.sp-dealer-pick .sp-field { margin: .4rem 0; }
.sp-seats button, .sp-dealer-pick button { font: inherit; background: none; border: 1px solid var(--line); border-radius: 6px; padding: .35rem .8rem; cursor: pointer; color: inherit; min-height: 44px; }
.sp-taps { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .5rem; margin: .6rem 0; }
.sp-tap { font: inherit; font-weight: 700; min-height: 52px; border: 1px solid var(--card-line); border-radius: 8px; background: #fff; color: var(--card-ink); cursor: pointer; }
.sp-tap[disabled] { opacity: .4; cursor: default; }
.sp-bt { display: block; font-size: .72em; color: var(--ink-soft); font-weight: 400; }
.sp-pot { text-align: right; color: var(--ink-soft); font-style: italic; margin: .4rem 0 0; }
.sp-pending { margin: .8rem 0; padding: .6rem .8rem; border: 1px dashed var(--line); border-radius: 8px; }
.sp-link-btn { font: inherit; background: none; border: 0; color: var(--red); text-decoration: underline; cursor: pointer; margin-left: .6rem; min-height: 44px; }
.sp-group { border: 1px solid var(--card-line); border-radius: 8px; padding: .2rem .7rem .5rem; margin: .4rem 0; }
.sp-group legend { font-weight: 700; padding: 0 .3rem; }
.sp-preview { display: block; font-weight: 700; text-align: right; margin-top: .3rem; }
.sp-calc-btn { font: inherit; margin: 0 0 .6rem; background: none; border: 1px solid var(--card-line); border-radius: 6px; padding: .35rem .9rem; cursor: pointer; color: var(--card-ink); min-height: 44px; }
.sp-calc { margin: 0 0 .8rem; padding: .6rem; border: 1px dashed var(--card-line); border-radius: 8px; }

/* ---------- game helpers (assets/js/tools/*.js) – shared building blocks ---------- */
.pane-tools .tool { margin: 0 0 2rem; }
.tl-h { font-size: 1.05rem; font-weight: 700; font-variant-caps: all-small-caps; letter-spacing: .08em; color: var(--ink-soft); margin: 1.2rem 0 .5rem; }
.tl-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.tl-btn { font: inherit; background: none; color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: .4rem .9rem; cursor: pointer; min-height: 44px; }
.tl-btn.on, .tl-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tl-btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.tl-btn[disabled] { opacity: .4; cursor: default; }
.tl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .5rem; margin: .5rem 0; }
.tl-field { display: grid; gap: .25rem; margin: .5rem 0; }
.tl-field > span { font-size: .95rem; color: var(--ink-soft); font-variant-caps: all-small-caps; letter-spacing: .06em; }
.tl-out { font-size: 1.3rem; font-weight: 800; text-align: center; margin: .8rem 0; padding: .6rem; border-top: 3px double var(--rule); border-bottom: 3px double var(--rule); }
.tl-note { font-size: .95rem; color: var(--ink-soft); font-style: italic; }
.tl-card { background: var(--card); color: var(--card-ink); border: 1px solid var(--card-rule); border-radius: 10px; padding: .6rem .8rem; }
.tl-warn { color: var(--red); font-size: .95rem; }
/* spoiler blocks in the rules (":::spoiler Title" in Markdown) */
details.spoiler { margin: 1.2rem 0; border: 1px dashed var(--line); border-radius: 8px; padding: 0 1rem; }
details.spoiler > summary { cursor: pointer; padding: .7rem 0; font-weight: 700; color: var(--red); list-style-position: inside; }
details.spoiler[open] > summary { border-bottom: 1px dotted var(--rule); margin-bottom: .6rem; }
details.spoiler[open] { padding-bottom: .6rem; }
@media print { details.spoiler > * { display: block; } }
.tool button, .tool input, .tool select { font: inherit; color: inherit; }
.tool input[type=text], .tool input[type=number], .tool select {
  width: 100%; padding: .55rem .7rem; font-size: 1.1rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--card-ink);
}
.tl-card input, .tl-card select { color: var(--card-ink); background: #fff; border-color: var(--card-line); }
.tl-card .tl-btn { color: var(--card-ink); border-color: var(--card-line); }
.tl-card .tl-btn[aria-pressed="true"], .tl-card .tl-btn.primary { background: var(--card-ink); color: var(--card); }
.tl-btn.red:not([aria-pressed="true"]) { color: var(--red); }

/* ---- review fixes: accessibility & small screens ------------------------ */
/* author display rules must not defeat the hidden attribute */
[hidden], .sp-actions[hidden], .sp-field[hidden] { display: none !important; }
/* screen-reader-only status line of the score pad */
.sp-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* visible keyboard focus everywhere */
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px; border-radius: 3px;
}
/* tap targets ≥ 44 px (WCAG 2.2 / platform guidelines) */
.filter button { min-width: 44px; min-height: 44px; padding: .3rem .5rem; }
.bar-lang a, .bar-lang [aria-current] { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: center; }
.bar-home { display: inline-flex; align-items: center; min-height: 44px; }
.jump a, .collections a, .toc a, .foot a { display: inline-block; padding: .55rem 0; }
/* the TOC uses a hanging indent for its numbers – links must not inherit it */
.toc a { text-indent: 0; }
.sp-pm, .score-app .sp-primary, .sp-more button, .sp-actions button, .sp-count button { min-height: 44px; }
.sp-del { min-width: 44px; min-height: 44px; }
/* the entry card is always light: use the card palette inside it (dark mode) */
.sp-entry .sp-field > label, .sp-entry .sp-field > span:first-child { color: var(--card-soft); }
.sp-entry input { color: var(--card-ink); background: #fff; border-color: var(--card-line); }
.sp-entry .sp-primary { background: var(--card-ink); color: var(--card); }
.sp-entry .sp-actions button:not(.sp-primary) { color: var(--card-ink); border-color: var(--card-line); }
.sp-entry .sp-danger { color: var(--card-red) !important; border-color: var(--card-red) !important; }
/* no sideways scrolling on narrow phones */
@media (max-width: 480px) { .toc { columns: 1; } }
.playing-card table { display: block; overflow-x: auto; }
.playing-card { overflow-wrap: anywhere; }
.bar { flex-wrap: wrap; row-gap: 0; }
/* wide tables: hint that they scroll */
.prose table, .sp-table-wrap { background:
  linear-gradient(to right, var(--paper) 30%, transparent) left / 2rem 100% no-repeat local,
  linear-gradient(to left, var(--paper) 30%, transparent) right / 2rem 100% no-repeat local,
  radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / .18), transparent) left / .8rem 100% no-repeat scroll,
  radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / .18), transparent) right / .8rem 100% no-repeat scroll; }

/* beginner box, search, jump links */
.start-here { margin: .5rem 0 0; font-size: .95rem; font-style: italic; color: var(--ink-soft); }
.search { margin: 1.4rem 0 0; }
.search .label { display: block; margin-bottom: .3rem; }
.search input {
  width: 100%; font: inherit; font-size: 1.1rem; padding: .6rem .8rem; min-height: 44px;
  color: var(--ink); background: color-mix(in srgb, var(--paper) 70%, #fff); border: 1px solid var(--line); border-radius: 8px;
}
.jump-groups { margin: 1.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0 1rem; }
.jump-groups a { text-decoration: none; border-bottom: 1px solid var(--rule); padding: .55rem 0; }

/* Layout diagrams (layouts.py): inline SVG with print colours; recoloured for dark mode */
figure.layout { margin: 1.6rem 0; text-align: center; }
figure.layout svg { max-width: 100%; height: auto; overflow: visible; font-variant-numeric: lining-nums; }
figure.layout figcaption { margin-top: .6rem; color: var(--ink-soft); font-style: italic; font-size: 1rem; }
@media (prefers-color-scheme: dark) {
  figure.layout .lc-panel { fill: rgba(255,255,255,.045); stroke: rgba(255,255,255,.14); }
  figure.layout .lc-label { fill: var(--ink-soft); }
  figure.layout .lc-slot { stroke: var(--ink-soft); }
  figure.layout .lc-hint { fill: var(--ink-soft); }
  figure.layout .lc-shadow { fill: #000; fill-opacity: .4; }
}

/* ---- Game page: panes, mobile tabs, full-screen cards ------------------ */
.panes { display: grid; gap: 22px; }
.side { display: contents; }
.pane-score { margin: 1rem 0 2rem; }
.pane-rules { margin-top: 1.5rem; }
.fs-toggle {
  position: absolute; top: 6px; right: 34px; z-index: 1;
  min-width: 44px; min-height: 44px; border: 0; background: none; cursor: pointer;
  color: var(--card-soft); font: 1.15rem/1 "Suits", var(--serif);
}
.fs-toggle:hover { color: var(--card-red); }
.tabs-on .playing-card.pane { cursor: zoom-in; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -6px 16px -12px rgb(0 0 0 / .35);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 9px; min-height: 56px; text-decoration: none; color: var(--ink-soft);
  font-size: .92rem; line-height: 1.1; border-top: 3px solid transparent; margin-top: -1px;
}
.tabbar .ti { font: 1.25rem/1 "Suits", var(--serif); }
.tabbar a:nth-child(3) .ti { color: var(--red); }
.tabbar a.active { color: var(--ink); border-top-color: var(--red); font-weight: 700; }

@media (max-width: 999.98px) {
  html.has-tabs body, html:has(.tabs-on) body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabs-on .jump { display: none; }
  .tabs-on .pane { display: none; }
  .tabs-on .pane.active { display: block; }
  /* tall enough that choosing a tab can scroll its section to the top of the screen */
  .tabs-on .panes { min-height: calc(100vh - 64px); }
  .tabs-on .pane-rules.active, .tabs-on .pane-score.active { margin-top: 0; }
}

@media (min-width: 1000px) {
  html.has-tabs main, main:has(> article.game-page) { max-width: 78rem; }
  .game-page .game-head, .game-page .in-collections, .game-page .jump { max-width: 42rem; margin-left: auto; margin-right: auto; }
  .tabbar { display: none !important; }
  .panes { grid-template-columns: minmax(0, 1fr) minmax(22rem, 27rem); gap: 3rem; align-items: start; }
  .side {
    display: flex; flex-direction: column; gap: 22px; grid-column: 2; grid-row: 1;
    position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto;
    padding: 4px 6px 16px; margin: -4px -6px 0; scrollbar-width: thin;
  }
  .side .playing-card { padding: 1.3rem 1.6rem 1.4rem; font-size: .98rem; }
  .pane-rules { grid-column: 1; grid-row: 1; margin-top: 0; }
  .pane-rules .prose > .part:first-child { margin-top: 0; }
}

.playing-card.fs {
  position: fixed; inset: 0; z-index: 50; display: block !important;
  margin: 0; border-radius: 0; max-height: none; overflow: auto; cursor: zoom-out;
  padding: 3.2rem max(1.6rem, calc((100vw - 40rem) / 2)) 3rem;
  font-size: 1.3rem; line-height: 1.5;
}
.playing-card.fs::before { inset: 10px; border-radius: 12px; }
.playing-card.fs h2 { font-size: 1.5rem; }
.playing-card.fs .fs-toggle { position: fixed; top: 14px; right: 18px; font-size: 1.4rem; }
html.fs-open { overflow: hidden; }
.playing-card.fs { touch-action: pan-y; }
.fs-pager { display: none; }
.playing-card.fs .fs-pager { display: flex; position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); gap: .3rem; background: var(--card); border: 1px solid var(--card-rule); border-radius: 999px; padding: .2rem; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.fs-pager button { white-space: nowrap; font: inherit; font-size: .85rem; border: 0; background: none; color: var(--card-soft); padding: .45rem .9rem; border-radius: 999px; cursor: pointer; min-height: 40px; font-variant-caps: all-small-caps; letter-spacing: .06em; }
.fs-pager button[aria-current="true"] { background: var(--card-ink); color: var(--card); }
.playing-card.fs { padding-bottom: 5rem; }
.playing-card.fs.flip-left { animation: fs-in-left .22s ease-out; }
.playing-card.fs.flip-right { animation: fs-in-right .22s ease-out; }
@keyframes fs-in-left { from { transform: translateX(30%); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes fs-in-right { from { transform: translateX(-30%); opacity: .3; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .playing-card.fs.flip-left, .playing-card.fs.flip-right { animation: none; } }
html.fs-open .tabbar { display: none; }

@media print {
  .tabbar, .fs-toggle { display: none !important; }
  .pane { display: block !important; }
  .side { display: contents !important; }
}

/* ---- At a glance: stars and profile scales ----------------------------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.profile { margin: 1.1rem auto 0; max-width: 30rem; }
/* star shapes, defined once per page (web/base.html); the half star's gradient takes its colour from here */
.scales { margin: 0; display: grid; gap: .25rem; }
.scale-row dd { margin: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .7rem; font-size: .95rem; color: var(--ink-soft); }
.scale-row .lo { text-align: right; }
.scale-row .track { display: inline-flex; gap: 5px; }
.scale-row .track i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--line); }
.scale-row .track i.on { background: var(--red); border-color: var(--red); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem .5rem; margin: .8rem 0 0; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: .15rem .7rem; font-size: .92rem; color: var(--ink); }
.chip .label { margin: 0 .2rem 0 0; font-size: .8rem; }

/* ---- Best-of lists ------------------------------------------------------ */
.g-rank { flex: none; align-self: center; width: 2.2rem; text-align: center; font: 900 1.9rem/1 var(--serif); color: var(--red); font-variant-numeric: lining-nums; }
.g-why { display: block; margin: .1rem 0 .4rem; line-height: 1.4; }
.best-lists { list-style: none; padding: 0; margin: 1.5rem 0 3rem; display: grid; gap: 14px; }
@media (min-width: 700px) { .best-lists { grid-template-columns: 1fr 1fr; } }
.best-lists a { display: block; height: 100%; padding: 1rem 1.2rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); background: color-mix(in srgb, var(--paper) 88%, var(--card)); }
.best-lists a:hover { border-color: var(--red); }
.bl-title { display: block; font-weight: 800; font-size: 1.25rem; }
.bl-intro { display: block; color: var(--ink-soft); font-style: italic; margin: .2rem 0 .5rem; line-height: 1.35; }
.bl-top { display: block; font-size: .95rem; }
.best-badges { text-align: center; margin: .9rem 0 0; font-size: .98rem; }
.best-badges a { display: inline-block; margin: .15rem .3rem; padding: .15rem .7rem; border-radius: 99px; background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--ink); text-decoration: none; }
.best-badges a b { color: var(--red); }
@media (max-width: 559.98px) { .best-entries .pip-card { display: none; } }
.tag { display: inline-block; font: 700 .72rem/1.5 var(--serif); font-variant-caps: all-small-caps; letter-spacing: .08em; padding: 0 .5rem; border: 1px solid var(--red); color: var(--red); border-radius: 99px; vertical-align: .25em; }
.untested-note { max-width: 34rem; margin: 0 auto 1rem; padding: .7rem 1rem; border: 1px dashed var(--red); border-radius: 10px; font-size: .98rem; line-height: 1.4; }

/* ---- skip link, reduced motion ------------------------------------------ */
.skip { position: absolute; left: -9999px; top: 0; z-index: 100; padding: .6rem 1rem; background: var(--paper); color: var(--ink); border: 2px solid var(--red); border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .pip-card, .games li:nth-child(even) .pip-card, .games a:hover .pip-card { transform: none; }
}

/* ---- review round 2: dark-mode tool cards, phone overflow, tap targets ---- */
/* tool cards stay light in dark mode, so their text tokens must be the card's, not the page's */
.tl-card, .sp-entry { --ink-soft: var(--card-soft); --red: var(--card-red); --line: var(--card-line); --rule: var(--card-rule); }
/* grid items default to min-width:auto, so a wide table or diagram stretched the whole page */
.panes { grid-template-columns: minmax(0, 1fr); }
.pane { min-width: 0; }
@media (min-width: 1000px) { .panes { grid-template-columns: minmax(0, 1fr) minmax(22rem, 27rem); } }
/* tap targets of at least 44px */
.in-collections a, .jump a, .foot p a, .collections a, .jump-groups a, .takeaway a {
  display: inline-flex; align-items: center; min-height: 44px;
}
.best-badges a { display: inline-block; padding-top: .65rem; padding-bottom: .65rem; margin-top: 0; margin-bottom: 0; }
.jump { gap: 0 .7rem; }
.jump a { border-bottom: 0; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: .2em; }
.history h2:not(.part) + ul li { min-height: 44px; display: flex; align-items: center; }
.history h2:not(.part) + ul li a { display: inline-flex; align-items: center; min-height: 44px; }
.takeaway li { padding: 0; }
.start-here a { display: inline-block; padding: .7rem 0; margin: -.7rem 0; }
/* the long start page: skip rendering groups that are off-screen */
#games .group { content-visibility: auto; contain-intrinsic-size: auto 800px; }
