/* EasyVote Public, the one stylesheet (design brief docs/design/design-brief.md,
   sections 3, 4, 7, 9). Dark is the base form (:root), light is a
   prefers-color-scheme block (R4); felt and card faces never change scheme.
   Every text colour meets 4.5:1 against the least favourable background it
   sits on, in both schemes (WCAG 1.4.3, measured in web/test/contrast.test.js
   and by the axe run of JRN-13.1, docs/design/accessibility-check.md).
   No inline styles anywhere: positions come from custom properties that the
   renderer sets with element.style.setProperty (R3). Fonts: web/fonts.css. */

/* ---- 1. Tokens ---------------------------------------------------------- */
:root {
  /* felt, gold, ivory, ink, ruby: scheme-independent (brief 3) */
  --felt-900: #062014; --felt-800: #072819; --felt-700: #0a3d2a; --felt-600: #10523a; --felt-500: #1a6546;
  --gold-500: #d4af37; --gold-300: #e8c96b; --gold-100: #f2e2a0; --gold-shadow: rgba(212, 175, 55, 0.35);
  --ivory-100: #f1e3c1; --ivory-300: #c9b98f; --ivory-500: #8a7d5c; --ink-900: #0a1610; --ink-700: #1a2620;
  --ruby: #a33545; --ruby-soft: #5a2028; --ruby-glow: rgba(163, 53, 69, 0.4);

  /* semantic, dark (brief 4) */
  --bg: #072819;
  --bg-texture: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.04) 0 2px, transparent 2px 9px);
  --panel: linear-gradient(180deg, #0a3d2a 0%, #072819 100%);
  --panel-inset: rgba(6, 32, 20, 0.5);
  --text: #f1e3c1; --text-dim: #c9b98f; --text-mute: #b1a27b; /* mute was #8a7d5c, 3.0:1 on the panel */
  --line: rgba(212, 175, 55, 0.2); --line-soft: rgba(212, 175, 55, 0.12); --line-strong: #d4af37;
  --accent: #d4af37; --accent-text: #d4af37; --accent-bright: #e8c96b; --accent-soft: rgba(212, 175, 55, 0.12);
  --primary: #d4af37; --primary-ink: #0a1610; --primary-hover: #e8c96b;
  --danger: #a33545; --danger-text: #e08a98;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45); --shadow-lift: 0 14px 38px rgba(0, 0, 0, 0.55);
  --overlay: rgba(6, 32, 20, 0.72);
  --header: linear-gradient(180deg, #062014, #072819); --header-line: #d4af37;
  --focus: #e8c96b;
  /* The felt keeps its colours in both schemes, so its focus ring does too:
     the light scheme's dark green ring would vanish on it (1.3:1). */
  --focus-felt: #e8c96b;
  --status-dot: #b1a27b;

  --font-display: 'Cormorant Garamond', 'Didot', 'Times New Roman', serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --radius-card: 6px; --radius-panel: 14px; --radius-chip: 999px;
  --content-max: 1280px; --header-h: 56px;

  --dur-quick: 180ms; --dur-deal: 420ms; --dur-reveal: 900ms;
  --ease-out-card: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4efe3;
    --bg-texture: radial-gradient(ellipse 70% 40% at 50% -5%, rgba(10, 61, 42, 0.05), transparent 60%);
    --panel: #fbf8f0;
    --panel-inset: rgba(16, 35, 27, 0.04);
    --text: #16241d; --text-dim: #4f6157; --text-mute: #5b6559; /* were #586a60, #6b7569: under 4.5:1 on gold tints */
    --line: rgba(16, 35, 27, 0.12); --line-soft: rgba(16, 35, 27, 0.08); --line-strong: rgba(16, 35, 27, 0.18);
    --accent: #725a14; --accent-text: #6f5814; --accent-bright: #7d6216; --accent-soft: rgba(154, 123, 31, 0.12); /* were #9a7b1f, #b8901f: 3.5:1 and 2.8:1 */
    --primary: #0a3d2a; --primary-ink: #f6efdc; --primary-hover: #10523a;
    --danger: #b13146; --danger-text: #b13146;
    --shadow: 0 6px 22px rgba(20, 40, 30, 0.1); --shadow-lift: 0 24px 50px rgba(20, 40, 30, 0.16);
    --overlay: rgba(20, 36, 29, 0.34);
    --header: #fbf8f0; --header-line: rgba(16, 35, 27, 0.12);
    --focus: #0a3d2a;
    --status-dot: #5b6559;
    color-scheme: light;
  }
}

/* ---- 2. Base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  font: 15px/1.5 var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-texture);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-bright); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.table :focus-visible { outline-color: var(--focus-felt); }
[hidden] { display: none !important; }
.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;
}
.mono {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text-mute);
}
.suit { color: var(--accent); }
.suit.red { color: var(--ruby); }

/* ---- 3. Header ---------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: var(--header); border-bottom: 1px solid var(--header-line);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: var(--sp-4); padding: 0 var(--sp-5);
}
.mark { font: italic 500 1.35rem var(--font-display); color: var(--accent); white-space: nowrap; }
.chip {
  justify-self: center; font-size: 12px; letter-spacing: 0.04em; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-chip); color: var(--text-dim);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.status {
  justify-self: end; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
/* The dot's shape says the tone as well as its colour (WCAG 1.4.1): a ring
   while connecting, a filled circle when connected, a square when offline. */
.status::before {
  content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: transparent; border: 1.5px solid var(--status-dot);
}
.status[data-tone="connecting"]::before { animation: pulse 1.2s ease-in-out infinite; }
.status[data-tone="on"]::before { background: var(--gold-500); border-color: var(--gold-500); box-shadow: 0 0 8px var(--gold-shadow); }
.status[data-tone="off"]::before { background: var(--ruby); border-color: var(--danger-text); border-radius: 1px; }
/* Short visible text for narrow headers (section 13); the empty alternative
   keeps it out of the accessibility tree, which reads #connection-text. */
.status::after { content: none; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---- 4. Page shell, panels, buttons, footer ----------------------------- */
.page {
  max-width: var(--content-max); margin: 0 auto; padding: var(--sp-4);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4);
}
.panel {
  width: 100%; max-width: 640px; margin: var(--sp-7) auto 0; padding: var(--sp-7) var(--sp-6);
  text-align: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-panel); box-shadow: var(--shadow);
}
.panel > .suit { display: block; font-size: 40px; opacity: 0.7; margin-bottom: var(--sp-3); }
.title { font: italic 500 clamp(2rem, 5vw, 2.75rem)/1.1 var(--font-display); color: var(--accent); margin-bottom: var(--sp-3); }
.lede { color: var(--text-dim); font-size: 16px; line-height: 1.6; max-width: 46ch; margin: 0 auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 12px var(--font-body); letter-spacing: 0.2em; text-transform: uppercase;
  padding: 10px 22px; border-radius: 2px; border: 1px solid var(--accent); color: var(--accent-text);
  background: transparent; transition: background var(--dur-quick), color var(--dur-quick);
}
.btn:hover { background: var(--accent); color: var(--primary-ink); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 20px var(--accent-soft); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.quiet { border-color: var(--line); color: var(--text-dim); }
.btn.quiet:hover { background: var(--accent-soft); color: var(--text); }
.btn:disabled, .btn:disabled:hover { opacity: 0.5; background: transparent; color: var(--accent-text); }
.btn.primary:disabled, .btn.primary:disabled:hover { background: var(--primary); color: var(--primary-ink); }
.btn.cta { font-size: 13px; padding: 14px 34px; }
/* Decoration only: the empty alternative keeps the star out of the button's name ("✦ Reveal the hand"). */
.btn.reveal::before { content: '✦' / ''; font-size: 11px; }
.actions { display: flex; justify-content: center; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-6); }
.fine { margin-top: var(--sp-5); font-size: 12px; color: var(--text-mute); line-height: 1.6; }
/* Links inside running text are underlined, not told apart by colour alone (WCAG 1.4.1). */
.fine a, .notice a { text-decoration: underline; text-underline-offset: 2px; }
.err { margin-top: var(--sp-4); color: var(--danger-text); font-size: 14px; min-height: 1.5em; }

.foot {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
}
.foot a { color: var(--text-dim); }
.foot .tag { width: 100%; text-align: center; }

/* Techspace mark (brief 5.6): <picture> picks the scheme, no JavaScript.
   Footer wordmark 20 px on every page except the landing; there the card
   closes with "A <wordmark> app" at 28 px behind a thin rule. */
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); width: 100%; justify-content: center; }
.brand img { height: 20px; width: auto; }
.card-brand { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.card-brand img { height: 28px; }

/* ---- 5. Toasts ---------------------------------------------------------- */
#toast-container {
  position: fixed; top: calc(var(--header-h) + var(--sp-3)); right: var(--sp-4); z-index: 60;
  display: grid; gap: var(--sp-2); max-width: calc(100vw - 2 * var(--sp-4));
}
.toast {
  padding: 10px 14px; font-size: 13px; background: var(--panel); color: var(--text);
  border: 1px solid var(--accent-bright); border-radius: var(--radius-card); box-shadow: var(--shadow);
  animation: toast-in var(--dur-quick) var(--ease-out-card);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---- 6. Landing --------------------------------------------------------- */
.hero-cards { position: relative; height: 112px; margin-bottom: var(--sp-5); }
.hero-card {
  position: absolute; left: 50%; top: 16px; width: 64px; height: 94px; margin-left: -32px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--ivory-100); color: var(--ink-900); border: 1px solid var(--gold-500);
  border-radius: var(--radius-card); box-shadow: var(--shadow); font-family: var(--font-display);
}
.hero-card b { font-size: 28px; font-weight: 600; line-height: 1; }
.hero-card i { font-style: normal; font-size: 18px; }
.hero-card.l { transform: translateX(-46px) rotate(-12deg); }
.hero-card.c { top: 8px; z-index: 1; }
.hero-card.r { transform: translateX(46px) rotate(12deg); }
.steps {
  list-style: none; margin: var(--sp-7) auto 0; max-width: 440px; text-align: left;
  display: grid; gap: var(--sp-3); color: var(--text-dim); font-size: 14px;
}
.steps li { display: flex; gap: var(--sp-3); align-items: baseline; }
.steps b { color: var(--text); font-weight: 600; }
.steps .suit { width: 1em; flex: none; }
.trust { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.trust p + p { margin-top: var(--sp-2); color: var(--text); }
.trust a { text-decoration: underline; text-underline-offset: 2px; }

/* ---- 7. Legal pages ----------------------------------------------------- */
.legal {
  width: 100%; max-width: 760px; margin: var(--sp-5) auto 0; padding: var(--sp-6) var(--sp-5);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: var(--shadow); text-align: left; font-size: 14px; line-height: 1.7; color: var(--text-dim);
}
.legal h1 { font: italic 500 clamp(1.8rem, 4vw, 2.4rem)/1.15 var(--font-display); color: var(--accent); margin-bottom: var(--sp-4); }
.legal h2 { font: 600 1.25rem/1.3 var(--font-display); color: var(--accent); margin: var(--sp-5) 0 var(--sp-2); }
.legal p, .legal ul { margin-bottom: var(--sp-3); }
.legal ul { padding-left: 1.4em; }
.legal strong { color: var(--text); }
.legal code { font: 12px var(--font-mono); color: var(--text); }
.legal a { text-decoration: underline; text-underline-offset: 2px; }
.legal .back { display: inline-block; margin-top: var(--sp-5); }
/* Art. 21 Abs. 4 DSGVO: the right to object stands apart from the other information. */
.legal .apart { margin: var(--sp-5) 0; padding: var(--sp-2) var(--sp-4) var(--sp-1); border-left: 3px solid var(--accent); background: var(--accent-soft); }
.legal .apart h2 { margin-top: var(--sp-2); }
.legal .lang-note { font-size: 13px; }

/* ---- 8. Room: invite bar, capacity notice, command bar ------------------ */
.page-room { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); min-width: 0; }
.invite {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--radius-panel);
  background: var(--accent-soft);
}
.invite h2 { font: italic 500 1.3rem/1.2 var(--font-display); color: var(--accent); }
.invite small { font-size: 12px; color: var(--text-dim); display: block; }
.invite .terms-note { margin-top: 2px; }
.invite .terms-note a { text-decoration: underline; text-underline-offset: 2px; }
.share { display: flex; gap: var(--sp-2); align-items: center; flex: 1 1 320px; max-width: 560px; min-width: 0; }
.url {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 12px var(--font-mono); padding: 9px 12px; background: var(--panel-inset);
  border: 1px solid var(--line); border-radius: 2px; color: var(--text); user-select: all;
}
.notice {
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--radius-card);
  background: var(--accent-soft); font-size: 14px; color: var(--text);
}
.notice strong { color: var(--accent-text); margin-right: 6px; }
.cmd { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; min-height: 42px; }
.role {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim);
}
.hint {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-mute); max-width: 34ch;
}
.dealer {
  display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center;
  border-radius: 50%; font: 700 10px var(--font-body); color: var(--ink-900);
  background: var(--ivory-100); border: 1.5px solid var(--gold-500);
}
.controls { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.banner { width: 100%; }

/* ---- 9. The table ------------------------------------------------------- */
.table {
  position: relative; width: 100%; max-width: 1260px; margin: 0 auto var(--sp-5);
  aspect-ratio: 16 / 6; border-radius: 50% / 62%; isolation: isolate;
}
.felt {
  position: absolute; inset: 0; border-radius: inherit; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(241, 227, 193, 0.12), transparent 65%),
    radial-gradient(ellipse at 50% 50%, var(--felt-600) 0%, var(--felt-700) 50%, var(--felt-900) 100%);
}
.rail {
  position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--gold-500); z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 0 4px var(--felt-900), inset 0 0 0 5px rgba(212, 175, 55, 0.4), 0 0 32px rgba(212, 175, 55, 0.12);
}
.oval {
  position: absolute; inset: 14% 16%; border-radius: 50% / 70%; z-index: 1;
  background: radial-gradient(ellipse, var(--felt-700) 0%, var(--felt-800) 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(212, 175, 55, 0.15);
}
/* The centre sits in the upper part of the inner ellipse (brief 7, finding
   PRE-03): below the cards in front of the seats, above the hand's dock. Its
   vertical position is a share of the table height, so it never meets the
   dock at any width (the mockups' padding in vw did, at 800 px and 1280 px). */
.centre {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 1;
  width: 60%; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  pointer-events: none;
}
.counter {
  font: italic 500 clamp(1.3rem, 2.6vw, 2.2rem)/1.1 var(--font-display); color: var(--gold-500);
  letter-spacing: 0.03em; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); white-space: nowrap;
}
.centre .mono { color: var(--ivory-300); } /* ivory-500 was 3.0:1 on the inner felt */

.seats, .cards { position: absolute; inset: 0; z-index: 3; list-style: none; pointer-events: none; }
.seat {
  position: absolute; left: var(--x); top: var(--y);
  width: clamp(36px, 3.5vw, 44px); height: clamp(36px, 3.5vw, 44px); transform: translate(-50%, -50%);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font: 600 clamp(11px, 1.1vw, 13px) var(--font-body); letter-spacing: 0.04em; color: var(--ink-900);
  background: linear-gradient(180deg, var(--ivory-100), #d9c8a0); border: 1px solid var(--gold-500);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  pointer-events: auto; animation: seat-in var(--dur-deal) var(--ease-out-card);
}
.seat.me { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 0 2px var(--gold-shadow); border-color: var(--gold-300); }
.seat.mod::before {
  content: 'D' / ''; position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font: 700 10px var(--font-body);
  color: var(--ink-900); background: var(--ivory-100); border: 1.5px solid var(--gold-500);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
@keyframes seat-in { from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } }

.card {
  position: absolute; left: var(--x); top: var(--y);
  width: clamp(30px, 3vw, 40px); height: clamp(42px, 4.2vw, 56px); transform: translate(-50%, -50%);
  border-radius: 4px; border: 1px solid var(--gold-500); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  font: italic 700 clamp(14px, 1.6vw, 20px) var(--font-display);
  transform-style: preserve-3d; animation: deal var(--dur-deal) var(--ease-out-card) backwards;
  animation-delay: var(--delay, 0ms);
}
.card::before, .card .face { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; }
.card::before {
  content: ''; background: linear-gradient(135deg, #102e20, #0a2418);
  background-image: repeating-linear-gradient(45deg, rgba(212, 175, 55, 0.25) 0 2px, transparent 2px 5px), linear-gradient(135deg, #102e20, #0a2418);
  background-clip: content-box, border-box; padding: 3px;
}
.card .face {
  display: flex; align-items: center; justify-content: center; background: var(--ivory-100); color: var(--ink-900);
  transform: rotateY(180deg);
}
.card.up { transform: translate(-50%, -50%) rotateY(180deg); }
.card.up.flip { animation: flip var(--dur-reveal) var(--ease-out-card) backwards; animation-delay: var(--delay, 0ms); }
@keyframes deal { from { opacity: 0; transform: translate(-50%, calc(-50% - 60px)) scale(0.8); } }
@keyframes flip { from { transform: translate(-50%, -50%) rotateY(0deg); } to { transform: translate(-50%, -50%) rotateY(180deg); } }

/* 11 seats and more (7 on narrow screens): a wider arc, smaller seats and
   cards (brief 7); two rows on a phone from 11 seats. */
.table.many .seat { width: 32px; height: 32px; font-size: 11px; }
.table.many .card { width: 24px; height: 34px; font-size: 13px; }
.table.rows .seat { width: 26px; height: 26px; font-size: 10px; letter-spacing: 0; }
.table.rows .card { width: 20px; height: 28px; font-size: 12px; }
.table.rows .seat.mod::before { width: 14px; height: 14px; font-size: 8px; top: -5px; right: -5px; }

/* ---- 10. The hand (dock) ------------------------------------------------ */
.dock {
  position: absolute; left: 50%; bottom: -3%; transform: translateX(-50%); z-index: 6;
  width: min(640px, 66%);
}
.yours {
  position: absolute; top: 0; left: 0; right: 0; text-align: center;
  font: italic 500 1.05rem var(--font-display); color: var(--gold-300); min-height: 1.4em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.hand {
  display: flex; align-items: flex-end; justify-content: center;
  padding: 80px var(--sp-4) var(--sp-2); width: 100%; perspective: 1400px;
}
/* Dimmed while locked, but never the focused card: its focus ring keeps full contrast (WCAG 1.4.11). */
.hand[aria-disabled="true"] .pc:not(:focus-visible) { opacity: 0.55; }
.pc {
  position: relative; width: clamp(72px, 9vw, 108px); aspect-ratio: 0.68; margin-inline: -10px;
  border-radius: var(--radius-card); background: var(--ivory-100); color: var(--ink-900); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font: italic 700 clamp(1.5rem, 3vw, 2.2rem)/1 var(--font-display);
  --lift: 48px;
  transform: rotate(var(--rot)) translateY(var(--y));
  transition: transform var(--dur-quick) var(--ease-out-card), box-shadow var(--dur-quick);
}
.pc::before { content: ''; position: absolute; inset: 5px; border: 1px solid rgba(10, 22, 16, 0.12); border-radius: 4px; }
.pc small {
  position: absolute; top: 6px; left: 7px; font: 600 10px/1 var(--font-body); font-style: normal;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.pc small .suit { font-size: 11px; }
.pc small + small { top: auto; left: auto; bottom: 6px; right: 7px; transform: rotate(180deg); }
.hand:not([aria-disabled="true"]) .pc:hover { transform: rotate(var(--rot)) translateY(calc(var(--y) - 20px)); z-index: 7; }
.pc[aria-checked="true"], .hand:not([aria-disabled="true"]) .pc[aria-checked="true"]:hover {
  transform: rotate(var(--rot)) translateY(calc(var(--y) - var(--lift))) scale(1.08); z-index: 7;
  box-shadow: var(--shadow-lift), 0 0 0 2px var(--gold-500), 0 0 36px var(--gold-shadow);
}
.pc[aria-checked="true"]::after {
  content: '✦' / ''; position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  font: 18px var(--font-body); color: var(--gold-500); text-shadow: 0 0 16px var(--gold-500);
}
/* The hand's cards reach past the felt onto the page (and below 480 px lie
   on it), so their gold focus ring runs on a dark band of its own: 10.6:1 on
   whatever is behind (WCAG 1.4.11, 2.4.7). */
.pc:focus-visible { z-index: 8; box-shadow: var(--shadow), 0 0 0 6px var(--felt-900); }
.pc[aria-checked="true"]:focus-visible { box-shadow: var(--shadow-lift), 0 0 0 2px var(--gold-500), 0 0 0 6px var(--felt-900), 0 0 36px var(--gold-shadow); }
.pc:nth-child(1) { --rot: -14deg; --y: 14px; } .pc:nth-child(2) { --rot: -10deg; --y: 10px; }
.pc:nth-child(3) { --rot: -6deg; --y: 6px; }   .pc:nth-child(4) { --rot: -2deg; --y: 2px; }
.pc:nth-child(5) { --rot: 2deg; --y: 2px; }    .pc:nth-child(6) { --rot: 6deg; --y: 6px; }
.pc:nth-child(7) { --rot: 10deg; --y: 10px; }  .pc:nth-child(8) { --rot: 14deg; --y: 14px; }

/* ---- 11. Showdown ------------------------------------------------------- */
.showdown {
  width: 100%; max-width: 760px; margin: 0 auto; padding: var(--sp-4); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-panel); box-shadow: var(--shadow);
  display: grid; gap: var(--sp-3);
}
.dist { width: 100%; border-collapse: collapse; }
.dist th { text-align: left; padding: 0 var(--sp-2) 4px; font: 10px var(--font-mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-mute); }
.dist td { padding: 6px var(--sp-2); vertical-align: middle; }
.dist tr.median td { background: var(--accent-soft); }
.dist td.value { font: italic 700 1.1rem var(--font-display); color: var(--text); width: 60px; text-align: right; }
.dist tr.median td.value { color: var(--accent-text); }
.dist td.gauge { width: 50%; }
.bar { height: 8px; border-radius: var(--radius-chip); background: var(--panel-inset); border: 1px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w); background: linear-gradient(90deg, var(--ivory-500), var(--ivory-300)); transition: width var(--dur-deal) var(--ease-out-card); }
.median .bar i { background: linear-gradient(90deg, var(--gold-500), var(--gold-300)); box-shadow: 0 0 12px var(--gold-shadow); }
.dist td.n { font: italic 700 1rem var(--font-display); color: var(--accent-bright); text-align: center; width: 32px; }
.dist td.who { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; color: var(--text-dim); text-align: right; white-space: nowrap; }
.dist td.who b { color: var(--accent-text); }
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--panel-inset); text-align: center;
}
.stats dt { font: 9px var(--font-mono); letter-spacing: 0.25em; text-transform: uppercase; color: var(--text-mute); }
.stats dd { font: italic 700 1.7rem/1.1 var(--font-display); color: var(--accent); }

/* ---- 12. Dialog --------------------------------------------------------- */
dialog {
  margin: auto; width: min(420px, calc(100vw - 2 * var(--sp-4))); padding: var(--sp-6) var(--sp-5);
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--radius-panel); box-shadow: var(--shadow-lift); text-align: center;
}
dialog::backdrop { background: var(--overlay); }
dialog h2 { font: italic 500 1.6rem/1.2 var(--font-display); color: var(--accent); margin-bottom: var(--sp-3); }
dialog p { color: var(--text-dim); }
dialog .actions { margin-top: var(--sp-5); }

/* ---- 13. Responsive ----------------------------------------------------- */
@media (max-width: 1100px) {
  .table { aspect-ratio: 16 / 7; }
  .pc { width: clamp(60px, 7.5vw, 108px); --lift: 32px; }
  .hand { padding-top: 64px; }
}
@media (max-width: 720px) {
  .top { padding: 0 var(--sp-4); grid-template-columns: auto minmax(0, 1fr) auto; }
  .chip { font-size: 11px; padding: 4px 8px; }
  .table { aspect-ratio: 4 / 3; }
  .oval { inset: 18% 12%; }
  .table.rows .centre { top: 52%; }
  .panel { margin-top: var(--sp-4); padding: var(--sp-6) var(--sp-4); }
  .legal { padding: var(--sp-5) var(--sp-4); }
  .stats dd { font-size: 1.4rem; }
}
@media (max-width: 480px) {
  .dock { top: 100%; bottom: auto; left: 0; transform: none; width: 100%; }
  .table { margin-bottom: 160px; }
  .centre { top: 50%; }
  .table.rows .centre { top: 64%; }
  .hand { padding-top: 36px; } /* room for the lifted card and its star */
  .pc { width: 40px; margin-inline: -2px; font-size: 1.1rem; transform: none; --lift: 10px; }
  /* Here the hand lies on the page instead of the felt: the card edge, the
     own-card line and the star take the page's accent so they keep 3:1 and
     4.5:1 in the light scheme too (WCAG 1.4.11, 1.4.3). */
  .pc { border: 1px solid var(--accent); }
  /* In the flow, so a line that wraps (320 px) pushes the hand down instead of covering it (WCAG 1.4.10). */
  .yours { position: static; color: var(--accent-text); text-shadow: none; }
  .pc[aria-checked="true"]::after { color: var(--accent); text-shadow: none; }
  .pc small { display: none; }
  .hand:not([aria-disabled="true"]) .pc:hover { transform: translateY(-6px); }
  .pc[aria-checked="true"], .hand:not([aria-disabled="true"]) .pc[aria-checked="true"]:hover { transform: translateY(calc(-1 * var(--lift))) scale(1.08); }
  .chip .chip-prefix { display: none; }
  .status #connection-text {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .status::after { content: attr(data-short); content: attr(data-short) / ''; } /* the first value is for browsers without CSS alt text */
  .status::before { width: 8px; height: 8px; }
  .dist td.who { white-space: normal; }
}

/* ---- 14. Reduced motion (R9) ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
