/* Roomful Cards (/cards/*), v2.0: the setup, join and lobby screens on P1's grounds (rf-cream for setup, rf-room for a
   table, rf-night rf-tv for the TV) and components (rf- classes in site.css), and the card table itself: the seats along
   the top, the middle of the table, your hand fanned along the bottom in the thumb zone with big cards, a bright
   "Your turn" right above it. The table is the page's own color scheme (Room Blue follows the party colors); the cards
   are paper. Portrait first; the text and card size settings are --font-scale and --card-scale (cards-ui.js). Every
   class here starts ct- (the table) or cc-/bj-/th-/sol- (cards-chips.css); nothing here redefines an rf- component. */

:root {
  --font-scale: 1;
  --card-scale: 1;
  --card-w: calc(clamp(64px, 21vw, 112px) * var(--card-scale));
  --card-h: calc(var(--card-w) * 1.4);
  --hand-overlap: 0.3;
  --suit-red: #c31c1c;
  --suit-black: #1b1b1b;
}

/* ---------- the page: a Cards screen is the whole page (no site header or footer), on its ground ---------- */
body:has(.ct-app) { margin: 0; background: var(--rf-blue); }
body:has(.ct-app.rf-cream) { background: var(--rf-cream); }
body:has(.ct-app.rf-night) { background: var(--rf-night); }
body:has(.ct-app) .landing-top, body:has(.ct-app) .site-foot { display: none; }
body:has(.ct-app) .page { max-width: none; margin: 0; padding: 0; }
body:has(.ct-app) main { margin: 0; padding: 0; }
.ct-app { min-height: 100vh; min-height: 100dvh; }
.ct-app h1, .ct-app h2, .ct-app h3 { font-stretch: 100%; font-variation-settings: normal; }
.ct-app .rf-title { margin: 0; font-size: var(--rf-fs-title); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.ct-app .rf-label { margin: 0; }
.ct-loading { margin: 0; }
/* site.css's v1 input[type="text"] rule outranks .rf-input (0,1,1 > 0,1,0): P1's field look, restated for these screens */
.ct-app .rf-input { width: 100%; min-height: 56px; margin: 0; padding: 0 16px; border: var(--rf-line) solid var(--rf-outline); border-radius: 16px; background: var(--rf-white);
  color: var(--rf-ink); font: inherit; font-size: 20px; font-weight: 600; box-shadow: none; }
.ct-app .rf-input.rf-code-input { min-height: 72px; text-align: center; font-size: 44px; font-weight: 800; letter-spacing: 0.3em; padding-left: 0.3em; text-transform: uppercase; }
.ct-app select.rf-input { padding-right: 12px; font-size: 18px; }
.ct-note { margin: -4px 0 0; font-size: 15px; font-weight: 600; color: var(--rf-muted); line-height: 1.35; }
.ct-tag { display: inline-flex; align-items: center; padding: 0 6px; min-height: 20px; border-radius: 6px; background: var(--rf-night); color: var(--rf-white);
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em; vertical-align: middle; }
.rf-cream .ct-tag, .rf-card .ct-tag, .rf-sheet .ct-tag, .ct-dialog .ct-tag { background: var(--rf-ink); color: var(--rf-white); }
.ct-crown { display: inline-flex; color: var(--rf-primary); }
.ct-crown .rf-icon { width: 18px; height: 18px; }
.ct-crown.is-acting { opacity: 0.75; }
.rf-chip .ct-crown, .rf-cream .ct-crown, .rf-card .ct-crown { color: var(--rf-ink); }
.rf-chip--me .ct-crown { color: var(--rf-ink); }

/* ---------- setup (/cards/host, solo's choices): cream, game tiles, segmented rows, the button in the thumb zone ---------- */
.ct-setup { gap: 18px; }
.ct-setup .rf-topbar { justify-content: flex-start; }
.ct-setup-title { flex: 1; min-width: 0; }
.ct-form { gap: 16px; }
.ct-row { display: flex; flex-direction: column; gap: 8px; }
.ct-row-label { margin: 0; }
.ct-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.ct-seg > label, .ct-seg > button { min-width: 0; padding-left: 4px; padding-right: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-seg--many > label { font-size: 17px; }
.ct-games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ct-gametile { position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  min-height: 72px; padding: 10px 12px; border: var(--rf-line) solid var(--rf-outline); border-radius: var(--rf-r-tile); background: var(--rf-white); color: var(--rf-ink);
  box-shadow: var(--rf-press-sm); cursor: pointer; transition: transform var(--rf-dur-press) ease-out, box-shadow var(--rf-dur-press) ease-out; }
.ct-gametile > input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.ct-gametile .rf-shape { grid-row: 1 / 3; width: 30px; height: 30px; color: var(--rf-tile); stroke: var(--rf-ink); stroke-width: 2.5; }
.ct-gametile-name { font-size: 18px; font-weight: 800; line-height: 1.1; }
.ct-gametile-sub { font-size: 13px; font-weight: 600; color: var(--rf-muted-cream); }
.ct-gametile:has(input:checked) { background: var(--rf-tile); outline: 3px solid var(--rf-blue); outline-offset: 3px; }
.ct-gametile:has(input:checked) .rf-shape { color: var(--rf-ink); }
.ct-gametile:has(input:checked) .ct-gametile-sub { color: var(--rf-ink); }
.ct-gametile:has(input:focus-visible) { outline: 3px solid var(--rf-focus); outline-offset: 3px; }
.ct-gametile:active { transform: translateY(3px); box-shadow: var(--rf-pressed); }
.ct-tvbox { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--rf-line-cream); border-radius: 18px; background: var(--rf-white);
  color: var(--rf-ink); text-decoration: none; }
.ct-tvbox:hover { color: var(--rf-ink); border-color: var(--rf-ink); }
.ct-tvbox-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--rf-night); color: var(--rf-white); }
.ct-tvbox-text { display: flex; flex-direction: column; font-size: 15px; }
.ct-tvbox-text span { color: var(--rf-link-cream); font-weight: 700; }
.ct-sticky-go { position: sticky; bottom: 0; padding: 12px 0 calc(8px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--rf-bg) 30%); }
.ct-dealing { justify-content: center; align-items: center; }

/* ---------- join (/cards/join) ---------- */
.ct-join .rf-topbar { justify-content: space-between; }
.ct-join-form { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.ct-join-more { margin: 0; text-align: center; font-weight: 700; }
.ct-stop .rf-body { margin: 0; }

/* ---------- the lobby (/cards/play before the game) ---------- */
.ct-lobby { gap: 18px; }
.ct-joincard .rf-code > span { height: clamp(64px, 20vw, 86px); font-size: clamp(44px, 14vw, 60px); }
.ct-joincard .rf-invite { display: flex; align-items: center; gap: 14px; }
.ct-joincard .rf-qr { margin: 0; flex: none; }
.ct-joincard .rf-qr-box { display: block; width: 112px; height: 112px; padding: 4px; border: var(--rf-line) solid var(--rf-ink); border-radius: 14px; background: var(--rf-cream); }
.rf-qr-box canvas.qr { display: block; width: 100%; height: 100%; max-width: none; border-radius: 6px; image-rendering: pixelated; }
.ct-joincard .rf-invite-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ct-joincard .rf-invite-url { font-weight: 800; font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.ct-seats .rf-section-head { align-items: center; }
.ct-count { font-weight: 800; font-size: 18px; }
.ct-seat-list { list-style: none; margin: 0; padding: 0; }
.ct-seat-list .rf-chip.is-bot { background: var(--rf-night); color: var(--rf-white); border-color: transparent; }
.ct-hostline, .ct-tvline { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--rf-muted); font-weight: 700; font-size: 15px; }
.ct-hostline .rf-icon, .ct-tvline .rf-icon { width: 18px; height: 18px; flex: none; }
.ct-tvline b { color: var(--rf-fg); }
.ct-watchers { gap: 8px; }
.ct-watchers .rf-chip { flex-wrap: wrap; height: auto; min-height: 44px; }
.ct-summary { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-weight: 700; color: var(--rf-muted); }
.ct-summary .rf-shape { width: 18px; height: 18px; color: var(--rf-orange); }
.ct-summary-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-me-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 0 0; text-align: center; }
.ct-hero-disc { display: grid; place-items: center; width: 220px; height: 220px; max-width: 64vw; max-height: 64vw; border-radius: 50%; background: rgba(255, 255, 255, 0.1); }
.ct-hero-name { margin: -6px 0 0; font-size: var(--rf-fs-title); font-weight: 800; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.ct-lobby .rf-topbar .rf-pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-lobby .rf-topbar .rf-codepill { margin-left: auto; }

/* ---------- sheets (rf-sheet): the host's, a player's menu, settings, rules ---------- */
.ct-sheet-body { display: flex; flex-direction: column; gap: 16px; }
.ct-sheet .rf-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ct-sheet .rf-action { min-height: 92px; font-size: 15px; }
.ct-sheet .rf-action[aria-pressed="false"] { color: var(--rf-muted-cream); }
.ct-tvrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--rf-line-cream); border-radius: 18px; background: var(--rf-white); }
.ct-tvrow-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--rf-night); color: var(--rf-white); }
.ct-tvrow-text { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; }
.ct-handoff-head { display: flex; align-items: center; gap: 8px; }
.ct-handoff-head .rf-icon { width: 18px; height: 18px; }
.ct-sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ct-sheet .ct-note { margin: 0; }
.ct-sheet .ct-note-row { justify-content: flex-start; text-align: left; }
.ct-seat-kinds .rf-list-row { flex-wrap: wrap; }
.ct-seat-kinds .rf-list-title { white-space: normal; font-size: 17px; }
.ct-partners { gap: 8px; }
.ct-partners .rf-btn { align-self: flex-start; }
.ct-links { margin: 0; text-align: center; font-size: 15px; font-weight: 600; }
.ct-rules { margin: 0; padding-left: 1.2em; line-height: 1.5; font-size: 17px; }
.ct-rules li { margin-bottom: 8px; }
.ct-setting .ct-seg { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(5.5em, 1fr)); }
.ct-share-box { min-height: 96px; padding: 12px; font-size: 17px; resize: none; }

/* ---------- the table: the whole screen while playing ---------- */
body.ct-playing { overflow: hidden; }
body.ct-playing .page { max-width: none; padding: 0; }
body.ct-playing .landing-top, body.ct-playing .site-foot { display: none; }
body.ct-playing main { margin: 0; }
body.ct-playing .ct-toast { top: calc(84px + env(safe-area-inset-top, 0px)); bottom: auto; }
.ct {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px; font-size: calc(17px * var(--font-scale)); color: var(--rf-white);
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overflow: hidden;
}
.ct button { font-family: inherit; touch-action: manipulation; }
/* the bar: P1's host-bar capsule for everyone; the host's has a crown */
.ct-bar { flex: 0 0 auto; min-height: 56px; padding: 4px 4px 4px 12px; gap: 8px; border-radius: 20px; }
.ct-hostmark { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 12px; background: var(--rf-primary); color: var(--rf-ink); }
.ct-hostmark[hidden] { display: none; }
.ct-hostmark .rf-icon { width: 20px; height: 20px; }
.ct-heading { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.ct-title { font-weight: 800; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-info { font-size: 0.8em; font-weight: 600; color: var(--rf-muted-room); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-tools { display: flex; gap: 4px; flex: none; }
.ct-tools .rf-hostbar-btn { width: 44px; height: 44px; }
.ct-tools .rf-hostbar-btn[hidden] { display: none; }
.ct-tools .rf-hostbar-btn:disabled { opacity: 0.4; cursor: default; }
.ct-tools .rf-hostbar-btn[aria-expanded="true"] { background: var(--rf-primary); color: var(--rf-ink); }
.ct :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* opponents */
.ct-opps { display: flex; flex-wrap: nowrap; justify-content: flex-start; gap: 8px; padding: 4px 2px 6px; flex: 0 0 auto; overflow-x: auto; scrollbar-width: none; }
.ct-opps::-webkit-scrollbar { display: none; }
/* centred while the tiles fit; once the strip overflows the auto margins are 0, so the first tiles stay in reach (centring pushed them past its start) */
.ct-opps > .ct-opp:first-child { margin-left: auto; }
.ct-opps > .ct-opp:last-child { margin-right: auto; }
.ct-opps > .ct-opp { flex-shrink: 0; } /* the strip scrolls: a tile keeps its width rather than wrapping into a tall column */
.ct-opp { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 5.2em; max-width: 9em; flex: 0 1 auto; padding: 7px 10px 8px; text-align: center;
  background: var(--rf-night); color: var(--rf-white); border: 3px solid transparent; border-radius: 16px; transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s; }
.ct-opp.active { border-color: var(--rf-primary); box-shadow: 0 0 0 3px var(--rf-ink), 0 0 18px rgba(255, 210, 63, 0.5); }
.ct-opp.away { opacity: 0.8; } /* dimmed, still readable: 5 : 1 or more in every color scheme (0.55 was 3.2 : 1) */
.ct-opp-name { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; font-weight: 800; font-size: 0.9em; line-height: 1.2; }
.ct-opp-name .rf-avatar { width: 18px; height: 18px; flex: none; }
.ct-opp-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-opp-name .ct-crown .rf-icon { width: 16px; height: 16px; }
.ct-opp-cards { font-size: 0.95em; font-weight: 800; display: inline-flex; align-items: center; gap: 3px; }
.ct-mini-back { display: inline-block; width: 13px; height: 18px; border-radius: 3px; background: var(--rf-blue); border: 2px solid var(--rf-cream); }
.ct-opp-score { font-size: 0.78em; font-weight: 600; color: var(--rf-muted-room); }

/* the middle: message, piles, your-turn banner */
.ct-center { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px; overflow-y: auto; }
/* centred while it fits; when it doesn't (Hold'em's 8 seats on a short phone) it scrolls instead of spilling under the
   opponents' tiles and over your own line: the auto margins fall to 0, as in the opponents' strip */
.ct-center > :first-child { margin-top: auto; }
.ct-center::after { content: ''; flex: none; margin-bottom: auto; }
.ct-msg { margin: 0; min-height: 2.6em; padding: 0 10px; text-align: center; font-weight: 700; line-height: 1.3; color: var(--rf-white); }
.ct-msg.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: ct-dots 1.2s steps(1) infinite; }
@keyframes ct-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
/* "Your turn": a big yellow capsule right above your hand */
.ct-banner { margin: 0; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 4px 26px;
  border: var(--rf-line) solid var(--rf-ink); border-radius: 999px; background: var(--rf-primary); color: var(--rf-ink); box-shadow: var(--rf-press-sm);
  font-weight: 800; font-size: 1.25em; letter-spacing: -0.01em; }
.ct-banner[hidden] { display: none; }
.ct-piles { display: flex; gap: 18px; align-items: center; }
.ct-pile-wrap { display: flex; flex-direction: column; align-items: center; }
.ct-pile { position: relative; width: var(--card-w); height: var(--card-h); border-radius: 10px; box-shadow: 0 6px 0 rgba(11, 20, 80, 0.55); padding: 0; border: 0; background: transparent; }
.ct-pile svg { width: 100%; height: 100%; display: block; }
.ct-draw { cursor: pointer; transition: transform 0.12s; }
.ct-draw:hover:not(:disabled) { transform: translateY(-3px); }
.ct-draw:disabled { cursor: default; opacity: 0.6; }
.ct-pile-label { margin-top: 6px; font-size: max(13px, 0.72em); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rf-muted-room); }
.ct-badge { position: absolute; top: -11px; right: -11px; z-index: 3; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rf-pink); color: var(--rf-ink); border: 2px solid var(--rf-ink); font-weight: 800; font-size: 0.92em; animation: ct-pulse 0.9s ease-in-out infinite alternate; }
@keyframes ct-pulse { from { transform: scale(1); } to { transform: scale(1.15); } }
.ct-suit-badge { position: absolute; right: -10px; bottom: -10px; z-index: 3; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--suit-black); border: 2px solid var(--rf-ink); font-size: 1.15em; }
.ct-suit-badge.red { color: var(--suit-red); }
.ct-dir { font-size: 1.9em; color: var(--rf-primary); }
.ct-dir[hidden] { visibility: hidden; display: inline; }
.ct-pop-target.pop { animation: ct-pop 0.3s; }
.ct-middle { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 100%; }
@keyframes ct-pop { 0% { transform: scale(1.18) rotate(-5deg); } 60% { transform: scale(0.97) rotate(1deg); } 100% { transform: none; } }

/* your hand: the bottom of the screen, under your thumb */
.ct-me { flex: 0 0 auto; margin: 0 -8px; padding: 6px 0 max(10px, env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: var(--rf-night);
  transition: box-shadow 0.2s; }
.ct-me.active { box-shadow: inset 0 4px 0 var(--rf-primary), 0 -6px 24px rgba(255, 210, 63, 0.25); }
.ct-myinfo { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; font-weight: 700; padding: 0 10px; margin-bottom: 2px; }
.ct-myname { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.ct-myname .rf-avatar { width: 22px; height: 22px; }
.ct-myname .ct-crown .rf-icon { width: 20px; height: 20px; }
.ct-myscore { color: var(--rf-muted-room); }
.ct-mini { min-height: 44px; padding: 4px 16px; border-radius: 14px; border: var(--rf-line) solid var(--rf-ink); background: var(--rf-white); color: var(--rf-ink);
  box-shadow: var(--rf-press-sm); font-weight: 800; font-size: 0.9em; cursor: pointer; }
.ct-mini:active:not(:disabled) { transform: translateY(3px); box-shadow: var(--rf-pressed); }
.ct-mini[aria-pressed="true"] { background: var(--rf-cream); }
.ct-pass, .ct-go { background: var(--rf-primary); color: var(--rf-ink); }
.ct-pass[hidden] { display: none; }
.ct-controls { display: contents; }
button.ct-opp { font: inherit; color: inherit; cursor: default; }
.ct-opp.askable { cursor: pointer; border-color: var(--rf-teal); box-shadow: 0 0 0 3px var(--rf-ink), 0 0 16px rgba(46, 196, 214, 0.55); }
.ct-hand { display: flex; justify-content: flex-start; padding: 22px 12px 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.ct-hand::-webkit-scrollbar { display: none; }
.ct-card { position: relative; flex: 0 0 auto; width: var(--card-w); height: var(--card-h); padding: 0; border: 0; border-radius: 10px; background: transparent;
  margin-left: calc(var(--card-w) * -1 * var(--hand-overlap)); box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.35); cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.ct-card:first-child { margin-left: auto; }
.ct-card:last-child { margin-right: auto; }
.ct-card svg { width: 100%; height: 100%; display: block; }
.ct-card.playable { transform: translateY(-12px); box-shadow: 0 0 0 3px var(--rf-primary), 0 8px 18px rgba(0, 0, 0, 0.5); }
.ct-card.playable:hover { transform: translateY(-18px); }   /* no z-index: a lifted card must not cover the strip of the next one (a tap there is that card) */
.ct-card.playable:focus-visible { transform: translateY(-22px); z-index: 5; }
.ct-card.not-playable { filter: brightness(0.72) saturate(0.75); }
.ct-card:focus-visible { z-index: 6; }
.ct-card.new-card { animation: ct-draw-in 0.35s; }
.ct-card.shake { animation: ct-shake 0.4s; }
@keyframes ct-draw-in { from { transform: translateY(-34px) scale(0.85); opacity: 0.2; } to { transform: none; opacity: 1; } }
@keyframes ct-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.ct-busy .ct-card, .ct-animating .ct-card { cursor: default; }

/* card art (cards-svg.js) */
.card-face-bg { fill: #fdfaf2; stroke: #d9d2bd; stroke-width: 2; }
.card-back-bg { fill: #1d33b8; stroke: #0b1450; stroke-width: 2; }
.corner-rank { font-size: 46px; font-weight: 700; font-family: Georgia, serif; }
.corner-suit { font-size: 36px; }
.pip { font-family: Georgia, serif; }

/* panels (CardTable.dialog): suit picker, hand over, bids, a choice: a cream card over the table */
.ct-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 16px 12px max(16px, env(safe-area-inset-bottom));
  background: rgba(11, 20, 80, 0.72); }
.ct-dialog { width: 100%; max-width: 460px; max-height: 86vh; max-height: 86dvh; overflow-y: auto; padding: 20px; border: var(--rf-line) solid var(--rf-ink); border-radius: 28px;
  text-align: center; background: var(--rf-cream); color: var(--rf-ink); box-shadow: var(--rf-press); font-size: calc(17px * var(--font-scale));
  --rf-fg: var(--rf-ink); --rf-muted: var(--rf-muted-cream); --rf-panel: var(--rf-white); --rf-link: var(--rf-link-cream); --rf-focus: var(--rf-link-cream); --rf-ghost: var(--rf-ink); }
.ct-dialog h2 { margin: 0 0 10px; font-size: 1.5em; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.ct-dialog p { line-height: 1.45; }
.ct-dialog .note { font-size: 0.9em; color: var(--rf-muted-cream); }
.ct-dialog-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.ct-dialog input[type="range"] { accent-color: var(--rf-blue); }
.ct-suits { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 12px; }
.ct-suit { min-height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 20px; cursor: pointer;
  border: var(--rf-line) solid var(--rf-ink); background: var(--rf-white); color: var(--suit-black); box-shadow: var(--rf-press-sm); font-weight: 800; }
.ct-suit:active { transform: translateY(3px); box-shadow: var(--rf-pressed); }
.ct-suit.red { color: var(--suit-red); }
.ct-suit-symbol { font-size: 2.2em; line-height: 1; }
.ct-suit span:last-child { font-size: 0.75em; text-transform: uppercase; color: var(--rf-ink); }
.ct-scores { width: 100%; border-collapse: separate; border-spacing: 0 6px; margin-top: 8px; }
.ct-scores th, .ct-scores td { padding: 8px 10px; text-align: left; }
.ct-scores td { background: var(--rf-white); border-top: 2px solid var(--rf-line-cream); border-bottom: 2px solid var(--rf-line-cream); font-weight: 700; }
.ct-scores td:first-child { border-left: 2px solid var(--rf-line-cream); border-radius: 14px 0 0 14px; }
.ct-scores td:last-child { border-right: 2px solid var(--rf-line-cream); border-radius: 0 14px 14px 0; }
.ct-scores th { font-size: 0.75em; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rf-muted-cream); }
.ct-scores td:nth-child(2), .ct-scores th:nth-child(2) { text-align: right; color: var(--rf-muted-cream); }
.ct-scores td:last-child, .ct-scores th:last-child { text-align: right; font-weight: 800; color: var(--rf-ink); }
.ct-scores tr.me td { background: var(--rf-primary); border-color: var(--rf-ink); }
.ct-scores .ct-tag { margin-left: 6px; }
.ct-setting { text-align: left; }
/* v2.2 (FIX-C, QA-C #3): a choice tile outside a segmented row (Spades bids and any CardTable option list): the v2 tile
   (44 px+, rounded, the page's font, white on the cream panel, ink outline; the chosen one in the primary color). Inside
   .rf-seg the segmented control's own rules apply. */
.ct-option { font-weight: 700; }
.ct-option:not(.rf-seg > .ct-option) {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 52px; margin: 0; padding: 6px 10px;
  border: var(--rf-line) solid var(--rf-ink); border-radius: 14px; background: var(--rf-white); color: var(--rf-ink); box-shadow: var(--rf-press-sm);
  font: inherit; font-size: 1.15em; font-weight: 800; line-height: 1.1; cursor: pointer; touch-action: manipulation;
}
.ct-option:not(.rf-seg > .ct-option):active { transform: translateY(3px); box-shadow: var(--rf-pressed); }
.ct-option:not(.rf-seg > .ct-option)[aria-pressed="true"] { background: var(--rf-primary); }
.ct-option:not(.rf-seg > .ct-option):focus-visible { outline: 3px solid var(--rf-focus, var(--rf-link-cream)); outline-offset: 2px; }
.ct-option:not(.rf-seg > .ct-option):disabled { opacity: 0.5; cursor: default; }
.ct-options { display: flex; flex-wrap: wrap; gap: 8px; }

/* the end of a match: a full cream screen, the winner in a blue band */
.ct-backdrop--final { padding: 0; align-items: stretch; background: var(--rf-cream); }
.ct-dialog.ct-final { max-width: 560px; max-height: none; height: 100%; margin: 0 auto; padding: 0 0 max(24px, env(safe-area-inset-bottom)); border: 0; border-radius: 0; box-shadow: none;
  display: flex; flex-direction: column; gap: 16px; text-align: left; }
.ct-final > :not(.ct-final-band) { margin-left: 16px; margin-right: 16px; }
.ct-final > .rf-btn--block { width: auto; }
.ct-final-band { padding-top: max(20px, env(safe-area-inset-top)); }
.ct-final-band .rf-pill { background: var(--rf-night); color: var(--rf-white); }
.ct-final-title { font-size: clamp(36px, 11vw, 56px); text-align: center; }
.ct-final-trophy { display: grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; background: var(--rf-primary); color: var(--rf-ink); border: var(--rf-line) solid var(--rf-ink); box-shadow: var(--rf-press); }
.ct-final-trophy .rf-icon { width: 64px; height: 64px; }
.ct-final-scores { display: flex; flex-direction: column; gap: 8px; }
.ct-final-scores > p { margin: 0; text-align: center; font-weight: 600; }
.ct-final-wait { align-self: center; }
.ct-next { display: flex; flex-direction: column; gap: 10px; }
.ct-next-head { align-items: center; }
.ct-next-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 22px; font-weight: 800; }
.ct-next .rf-gamestrip { margin-right: -16px; padding-right: 16px; }
.ct-next .rf-gametile { flex-basis: 104px; }
.ct-next .rf-gametile span { padding: 0 2px; text-align: center; line-height: 1.1; }

/* table features: reactions, the notice line (I'm back, watching, asking to play, Skip, the host away), the turn clock */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ct-tray { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; padding: 8px; margin: 0 auto; border-radius: 18px;
  background: var(--rf-night); flex: 0 0 auto; max-width: 100%; }
.ct-tray[hidden] { display: none; }
.ct-react { min-width: 48px; min-height: 48px; font-size: 1.5em; line-height: 1; border-radius: 14px; border: 0; background: rgba(255, 255, 255, 0.1); cursor: pointer; }
.ct-react:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.ct-react:disabled { opacity: 0.4; cursor: default; }
.ct-opp, .ct-myinfo { position: relative; }
.ct-bubble { position: absolute; z-index: 8; top: -14px; right: -8px; min-width: 1.9em; padding: 2px 6px; border-radius: 999px; background: var(--rf-cream); color: var(--rf-ink);
  border: 2px solid var(--rf-ink); font-size: 1.45em; line-height: 1.25; text-align: center; pointer-events: none; animation: ct-bubble 4s ease-out forwards; }
.ct-myinfo .ct-bubble { top: -30px; right: auto; left: 50%; transform: translateX(-50%); }
@keyframes ct-bubble { 0% { opacity: 0; scale: 0.4; } 8% { opacity: 1; scale: 1.15; } 14% { scale: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }
.ct-notice { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 8px; text-align: center; }
.ct-notice:empty { display: none; }
.ct-note-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; }
.ct-note-row p { margin: 0; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.ct-note-row p .rf-icon { width: 18px; height: 18px; flex: none; }
.ct-note-row.warn { padding: 8px 12px; border-radius: 16px; background: var(--rf-night); border: 3px solid var(--rf-primary); }
.ct-lobby .ct-note-row { padding: 8px 12px; border-radius: 16px; background: var(--rf-night); }
.ct-banner.hurry { background: var(--rf-orange); animation: ct-pulse 0.9s ease-in-out infinite alternate; }
.ct-opp.stand-in .ct-opp-who { font-style: italic; }
.ct-hand.stand-in { opacity: 0.55; pointer-events: none; }
.ct-hand[hidden] { display: none; }

/* ---------- the TV (/cards/tv): rf-night rf-tv, read-only, the join code always on screen ---------- */
.ct-tv-pair .rf-screen { max-width: 560px; justify-content: center; }
.ct-pair-icon { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 24px; background: var(--rf-blue); color: var(--rf-white); }
.ct-pair-icon .rf-icon { width: 48px; height: 48px; }
.ct-pair-lede { margin: 0; }
body.ct-tv-on { overflow: hidden; }
body.ct-tv-on .page { max-width: none; padding: 0; }
body.ct-tv-on .landing-top, body.ct-tv-on .site-foot { display: none; }
body.ct-tv-on main { margin: 0; }
.ct-tv { height: 100vh; height: 100dvh; overflow: hidden; font-size: calc(max(22px, 1.5vw) * var(--font-scale)); cursor: default; }
.ct-tv { --card-w: calc(clamp(80px, 16vmin, 220px) * var(--card-scale)); --card-h: calc(var(--card-w) * 1.4); }
.ct-tv .rf-tv-stage { height: 100%; min-height: 0; gap: clamp(10px, 1.4vw, 36px); padding: clamp(16px, 2vw, 56px) clamp(20px, 3vw, 84px); }
.ct-tv-brand { width: clamp(52px, 3.5vw, 96px); height: clamp(52px, 3.5vw, 96px); flex: none; }
.ct-tv-bar .rf-pill[hidden] { display: none; }
.ct-tv .ct-title { font-size: clamp(28px, 1.56vw, 46px); }
.ct-tv .ct-info { color: var(--rf-white); }
.ct-tv-host .rf-icon { color: var(--rf-primary); }
.ct-tv-lobby-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: space-between; gap: clamp(24px, 3vw, 90px); }
.ct-tv-join { display: flex; flex-direction: column; align-items: center; gap: 0.5em; text-align: center; }
.ct-tv-kicker { display: inline-flex; align-items: center; gap: 0.4em; margin: 0; font-weight: 800; }
.ct-tv .ct-tv-join .rf-qr { margin: 0; }
.ct-tv .ct-tv-join .rf-qr-box { display: block; width: clamp(200px, 22vw, 620px); height: clamp(200px, 22vw, 620px); padding: 0.2em; background: var(--rf-cream);
  border: 6px solid var(--rf-ink); border-radius: 0.8em; }
/* the lobby: the code big on the left, the QR code on the right, the seats along the bottom (mockup 17) */
.ct-tv-join.big { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "kicker qr" "code qr" "url qr"; align-items: center; justify-items: start;
  column-gap: clamp(32px, 5vw, 140px); row-gap: 0.4em; width: 100%; text-align: left; }
.ct-tv-join.big .ct-tv-kicker { grid-area: kicker; }
.ct-tv-join.big .ct-tv-code { grid-area: code; --rf-fs-code: clamp(110px, 10.4vw, 300px); }
.ct-tv-join.big .ct-tv-url { grid-area: url; }
.ct-tv-join.big .rf-qr { grid-area: qr; }
.ct-tv-join.big .rf-qr-box { width: clamp(240px, 25vw, 720px); height: clamp(240px, 25vw, 720px); }
.ct-tv .ct-tv-code { --rf-fs-code: clamp(64px, 6vw, 170px); }
.ct-tv-url { margin: 0; color: var(--rf-muted-room); font-weight: 700; }
.ct-tv-lobby-seats { display: flex; flex-direction: column; gap: 0.8em; min-width: 0; }
.ct-tv .ct-seat-list .rf-chip { background: var(--rf-cream); color: var(--rf-ink); }
.ct-tv .ct-seat-list .rf-chip--more { background: transparent; color: var(--rf-muted-room); }
.ct-tv .ct-seat-list .ct-crown .rf-icon { width: 1em; height: 1em; }
.ct-tv .ct-tag { font-size: 0.6em; min-height: 1.4em; padding: 0 0.4em; }
.ct-tv-watching { margin: 0; }
.ct-tv-table { gap: clamp(10px, 1.2vw, 30px); }
.ct-tv-main { flex: 1 1 auto; min-height: 0; display: flex; }
.ct-tv-play { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.5em; }
.ct-tv-seats { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5em; }
.ct-tv-seats .ct-opp { background: var(--rf-blue); flex: 1 1 5.5em; max-width: 12em; min-width: 0; padding: 0.35em 0.7em 0.45em; border-width: 4px; }
.ct-tv .ct-opp-name, .ct-tv .ct-opp-score, .ct-tv .ct-opp-cards { font-size: 1em; }
.ct-tv .ct-opp-name .rf-avatar { width: 1em; height: 1em; }
.ct-tv .ct-opp-name .rf-icon { width: 0.9em; height: 0.9em; }
.ct-tv .ct-msg { font-size: 1.15em; min-height: 2.6em; }
.ct-tv .ct-banner { font-size: 1.1em; min-height: 1.9em; box-shadow: none; }
.ct-tv .ct-pile-label, .ct-tv .ct-trick-line, .ct-tv .ct-last-trick, .ct-tv .ct-trick-who, .ct-tv .bj-total, .ct-tv .bj-bet-line, .ct-tv .th-up-name { font-size: 0.9em; }
.ct-tv .ct-dialog { max-width: 1100px; font-size: inherit; }
.ct-tv-panel { max-width: 900px; font-size: max(22px, 1.5vw); }   /* panels sit outside #screen: the TV's type size again */
.ct-tv-panel .ct-tv-code { display: flex; gap: 0.25em; }
.ct-tv-panel .ct-tv-code > span { width: 1.1em; height: 1.3em; font-size: clamp(36px, 3vw, 90px); border-radius: 0.2em; }
.ct-tv-panel .ct-tv-join .rf-qr { margin: 0; }
.ct-tv-panel .ct-tv-join .rf-qr-box { display: block; width: clamp(160px, 16vw, 420px); height: clamp(160px, 16vw, 420px); padding: 0.2em; background: var(--rf-cream);
  border: 4px solid var(--rf-ink); border-radius: 0.6em; }
.ct-backdrop:has(.ct-tv-panel) { align-items: center; }
.ct-dialog.ct-tv-panel.ct-final { max-width: none; }
.ct-backdrop--final:has(.ct-tv-panel) { background: var(--rf-night); }
.ct-tv-final { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.2em; align-items: start; padding: 0 1em 1em; }
.ct-tv-final-join { display: flex; flex-direction: column; align-items: center; gap: 0.6em; padding: 0.8em; border-radius: 1em; background: var(--rf-white); }
.ct-tv-final .ct-tv-url { color: var(--rf-muted-cream); }
.ct-tv .ct-scores th { font-size: 0.8em; }
@media (max-width: 700px), (orientation: portrait) {
  body.ct-tv-on { overflow: auto; }
  .ct-tv { height: auto; min-height: 100vh; overflow: visible; font-size: calc(18px * var(--font-scale)); }
  .ct-tv-lobby-main, .ct-tv-final { display: flex; flex-direction: column; gap: 16px; }
  /* v2.10.1: the big join panel stacks (QR, then the code), so the code's tiles no longer run over the QR or off the screen */
  .ct-tv-join.big { grid-template-columns: minmax(0, 1fr); grid-template-areas: "kicker" "qr" "code" "url"; justify-items: center; }
  .ct-tv-join.big .ct-tv-code { --rf-fs-code: clamp(56px, 14vw, 110px); }
}
/* ---------- phase 3: tricks (Hearts, Spades), the hand-building, the pond (Go Fish), bids ---------- */
.ct-card.selected { transform: translateY(-20px); box-shadow: 0 0 0 3px #5aa9e6, 0 10px 20px rgba(0, 0, 0, 0.5); }
.ct-card.idle { cursor: default; }
.ct-card.selected.idle { opacity: 0.85; }
.ct-mini:disabled { opacity: 0.5; cursor: default; }
.ct-trick-table { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ct-trick-line { margin: 0; font-size: 0.82em; font-weight: 700; color: var(--paper-dim); text-align: center; min-height: 1.2em; }
.ct-last-trick { margin: 0; font-size: 0.75em; color: var(--paper-dim); text-align: center; min-height: 1.1em; }
.ct-trick { --tw: calc(var(--card-w) * 0.82); position: relative; width: calc(var(--tw) * 3.3); height: calc(var(--tw) * 1.4 * 2.05); }
.ct-trick.n2 { height: calc(var(--tw) * 1.4 * 1.9); width: calc(var(--tw) * 1.6); }
.ct-trick[hidden], .ct-building[hidden] { display: none; }
.ct-trick-card { position: absolute; width: var(--tw); height: calc(var(--tw) * 1.4); border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45); animation: ct-play-in 0.25s; }
.ct-trick-card svg { width: 100%; height: 100%; display: block; }
.ct-trick-card.at-bottom { left: 50%; bottom: 0; transform: translateX(-50%); }
.ct-trick-card.at-top { left: 50%; top: 0; transform: translateX(-50%); }
.ct-trick-card.at-left { left: 0; top: 50%; transform: translateY(-50%) rotate(-4deg); }
.ct-trick-card.at-right { right: 0; top: 50%; transform: translateY(-50%) rotate(4deg); }
.ct-trick.n3 .ct-trick-card.at-left, .ct-trick.n3 .ct-trick-card.at-right { top: 30%; }
.ct-trick-who { position: absolute; left: 50%; bottom: -1.3em; transform: translateX(-50%); font-size: 0.62em; font-weight: 700; white-space: nowrap; color: var(--paper); }
.ct-trick.pop { animation: none; }
@keyframes ct-play-in { from { opacity: 0; scale: 1.2; } to { opacity: 1; scale: 1; } }
.ct-pile.empty { border: 2px dashed rgba(255, 246, 229, 0.3); box-shadow: none; }
.ct-peek { box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(0, 0, 0, 0.5); }
.ct-pile-wrap[hidden] { display: none; }
.ct-gofish { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ct-books { display: flex; flex-direction: column; gap: 3px; align-items: center; max-width: 100%; font-size: 0.82em; }
.ct-book-row { margin: 0; text-align: center; }
.ct-book-chip { display: inline-block; margin: 1px 3px; padding: 1px 8px; border-radius: 999px; background: var(--paper); color: var(--ink); font-weight: 700; font-size: 0.9em; }
.ct-bids { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.4em, 1fr)); gap: 8px; margin-top: 10px; }
.ct-bid-choice { min-height: 48px; font-size: 1.1em; }
.ct-tv .ct-trick { --tw: calc(var(--card-w) * 0.9); }
/* v2.2 (FIX-C, QA-C #4): the TV table fits the screen. cards-tv.js fitTable() steps --tv-fit down (cards and type
   together) when the seats, the middle or whose turn would run past the screen; whose turn sits below the middle. */
.ct-tv-table { --card-w: calc(clamp(80px, 16vmin, 220px) * var(--card-scale) * var(--tv-fit, 1)); --card-h: calc(var(--card-w) * 1.4);
  font-size: calc(max(22px, 1.5vw) * var(--font-scale) * var(--tv-fit, 1)); }
.ct-tv .ct-tv-table .rf-tv-bar .rf-pill, .ct-tv .ct-tv-table .rf-codepill { min-height: calc(clamp(52px, 3.125vw, 90px) * var(--tv-fit, 1)); font-size: calc(clamp(28px, 1.56vw, 46px) * var(--tv-fit, 1)); }
.ct-tv-table .ct-center { overflow: hidden; }
.ct-tv-play > .ct-banner { flex: none; align-self: center; }
.ct-tv-codebox { display: contents; }
.ct-sprite-inline { position: absolute; width: 0; height: 0; overflow: hidden; }   /* cards-tv.js: the sprite again, after a failed load */
.ct-tv-lockpill .rf-icon, .ct-tv-locked .rf-icon { color: var(--rf-primary); }
.ct-tv-locked { padding: 0.8em 1em; border-radius: 1em; background: var(--rf-blue); }
.ct-tv-locked.big { display: flex; align-items: flex-start; text-align: left; font-size: 1.4em; }
.ct-tv-locked .ct-tv-url { color: var(--rf-white); }
.ct-tv-panel .ct-tv-locked { background: transparent; }
.ct-tv-panel .ct-tv-locked .rf-icon { color: var(--rf-ink); }
.ct-tv-panel .ct-tv-locked .ct-tv-url { color: var(--rf-muted-cream); }


@media (orientation: landscape) and (max-height: 540px) {
  :root { --card-w: calc(clamp(48px, 15vh, 80px) * var(--card-scale)); }
  .ct { font-size: calc(14px * var(--font-scale)); }
  .ct-hand { padding-top: 12px; }
}
/* v2.2 (FIX-C, QA-C #7): a long hand on a narrow phone in two overlapping rows (cards-ui.js layoutHand() sets the columns),
   so every card keeps a 44 px tap strip; lifted cards lift less so the row below never hides the row above */
.ct-hand.is-rows { display: grid; grid-template-rows: calc(var(--card-h) * 0.6) auto; justify-content: center; overflow: visible; }
.ct-hand.is-rows > .ct-card { margin: 0; }
.ct-hand.is-rows > .ct-card.playable, .ct-hand.is-rows > .ct-card.playable:hover { transform: translateY(-5px); }
.ct-hand.is-rows > .ct-card.selected { transform: translateY(-8px); }
/* a long hand (Hearts, Spades: 13 cards) gets slightly smaller cards so more of it shows at once */
.ct-hand.is-long { --card-w: calc(clamp(56px, 17vw, 96px) * var(--card-scale)); --card-h: calc(var(--card-w) * 1.4); }
@media (min-width: 760px) {
  .ct-hand { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .ct-card, .ct-pop-target, .ct-trick-card, .ct-badge, .ct-draw, .ct-bubble, .ct-banner.hurry, .ct-gametile { animation: none !important; transition: none !important; }
}
