:root {
  color-scheme: light;
  --paper: oklch(97.6% 0.008 250); --paper-2: oklch(94% 0.014 250); --paper-3: oklch(90.5% 0.02 250);
  --ink: oklch(24% 0.03 260); --ink-2: oklch(40% 0.03 260); --muted: oklch(53% 0.025 260);
  --rule: oklch(87% 0.02 250);
  --accent: oklch(56% 0.15 258); --accent-soft: oklch(92% 0.04 258); --accent-ink: oklch(32% 0.1 260);
  --suit-red: oklch(56% 0.19 25);
  --good: oklch(80% 0.15 152); --good-soft: oklch(93% 0.06 152); --good-ink: oklch(30% 0.08 152);
  --bad: oklch(70% 0.17 25); --bad-soft: oklch(93% 0.04 25); --bad-ink: oklch(40% 0.14 25);
  --card: oklch(99.5% 0.003 250);
  --font: "Manrope", system-ui, sans-serif;
  --radius: 18px; --pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --t-sm: 0.875rem; --t-md: 1rem; --t-lg: 1.25rem; --t-xl: 1.6rem; --t-2xl: 2.2rem; --t-3xl: 3rem;
  --dur: 140ms; --ease: cubic-bezier(0.16, 1, 0.3, 1); --flip: 560ms;
  --page: 30rem;
  --card-w: clamp(132px, min(52vw, 27dvh), 220px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 500 var(--t-md)/1.5 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: clip; }
h1, h2, p, ol, ul { margin: 0; }
h1, h2 { font-weight: 800; line-height: 1.02; letter-spacing: -0.025em; text-wrap: balance; overflow-wrap: break-word; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: var(--s-5); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.page { max-width: var(--page); margin-inline: auto; padding: calc(var(--s-6) + var(--safe-t)) calc(var(--s-4) + var(--safe-r)) calc(var(--s-7) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); }

.masthead h1 { font-size: var(--t-3xl); }
.lead { margin-top: var(--s-3); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; max-width: 30ch; text-wrap: pretty; }
.quiet { margin-top: var(--s-3); font-size: var(--t-sm); color: var(--muted); }

.block { margin-top: var(--s-6); }
.label { display: block; margin-bottom: var(--s-2); font-size: var(--t-sm); font-weight: 700; color: var(--ink-2); }
.note { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.foot { margin-top: var(--s-6); display: grid; gap: var(--s-2); font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.foot #record { color: var(--ink-2); font-weight: 700; }
.stack-tight { display: grid; gap: var(--s-2); }
.home-tally { margin-top: var(--s-3); }

.rules { padding: var(--s-4) var(--s-5) var(--s-4) calc(var(--s-5) + 1.1em); border-radius: var(--radius); background: var(--paper-2); display: grid; gap: var(--s-2); color: var(--ink-2); text-wrap: pretty; }
.rules li::marker { color: var(--accent); font-weight: 800; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 48px; padding: var(--s-2) var(--s-5); border: 0; border-radius: var(--pill); background: var(--paper-2); color: var(--ink); font-weight: 700; font-size: var(--t-md); cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear, transform var(--dur) var(--ease), opacity var(--dur) linear; }
.btn:hover { background: var(--paper-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--ink-2); }
.btn--quiet { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule); }
.btn--quiet:hover { background: var(--paper-2); }
.btn--wide { width: 100%; }
.btn--big { min-height: 60px; font-size: var(--t-lg); }
.link { background: none; border: 0; min-height: 44px; padding: var(--s-2) 0; font-size: var(--t-sm); font-weight: 700; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.25em; cursor: pointer; }
.link:hover { color: var(--ink); }

.players { list-style: none; padding: 0; display: grid; gap: var(--s-2); margin-bottom: var(--s-2); counter-reset: p; }
.player { display: flex; align-items: center; gap: var(--s-2); counter-increment: p; }
.player::before { content: counter(p); width: 1.4em; flex: none; text-align: right; font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.player input { flex: 1; min-width: 0; min-height: 48px; padding: var(--s-2) var(--s-4); border: 0; border-radius: var(--pill); background: var(--paper-2); font-size: var(--t-md); }
.player input:hover { background: var(--paper-3); }
.player input:focus { background: var(--card); box-shadow: inset 0 0 0 2px var(--accent); outline: none; }
.player input::placeholder { color: var(--muted); }
.remove { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.remove:hover { background: var(--paper-2); color: var(--ink); }
.remove:disabled { visibility: hidden; }
#players-note { margin-top: var(--s-2); }
#players-note.warn { color: var(--bad-ink); font-weight: 700; }

/* ---- play ------------------------------------------------------------------------------------------ */
.game { position: relative; max-width: var(--page); min-height: 100dvh; margin-inline: auto; display: flex; flex-direction: column; gap: var(--s-3); padding: calc(var(--s-2) + var(--safe-t)) calc(var(--s-4) + var(--safe-r)) calc(var(--s-4) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); }
.topline { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; }
.step { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.turn { min-height: 1em; }
.kicker { font-size: var(--t-sm); font-weight: 700; color: var(--ink-2); }
.who { font-size: var(--t-2xl); overflow-wrap: anywhere; }
.turn.fresh .who { animation: pop 420ms var(--ease); }
@keyframes pop { from { transform: translateY(6px); opacity: 0.2; } to { transform: none; opacity: 1; } }

.stakes { display: grid; gap: var(--s-2); }
.row { list-style: none; padding: 0; display: flex; align-items: center; min-height: 52px; }
.row:empty::before { content: "The row starts with the card below."; font-size: var(--t-sm); color: var(--muted); }
.row li { flex: none; }
.row li + li { margin-left: -10px; }
.mini { width: 38px; height: 52px; display: grid; place-content: center; justify-items: center; gap: 0; border-radius: 8px; background: var(--card); box-shadow: 0 0 0 1px var(--rule), 0 1px 2px oklch(30% 0.03 260 / 0.08); font-size: 0.95rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.mini svg { width: 14px; height: 14px; fill: currentColor; margin-top: 3px; }
.mini.red { color: var(--suit-red); }
.mini.new { animation: slide 360ms var(--ease); }
@keyframes slide { from { transform: translate(18px, 18px) scale(1.25); opacity: 0; } to { transform: none; opacity: 1; } }
.row.lost .mini { background: var(--bad-soft); box-shadow: 0 0 0 1px oklch(85% 0.06 25); }
.more { margin-left: var(--s-2) !important; font-size: var(--t-sm); font-weight: 700; color: var(--muted); }
.stakes__line { display: flex; align-items: center; gap: var(--s-3); font-weight: 700; color: var(--ink-2); }
.pips { display: inline-flex; gap: 5px; }
.pips i { width: 12px; height: 12px; border-radius: 50%; background: var(--paper-3); transition: background-color var(--dur) linear, transform var(--dur) var(--ease); }
.pips i.on { background: var(--accent); }
.pips[data-n="3"] i.on { background: var(--bad); }
#play[data-result="bad"] .pips i.on { background: var(--bad); }

/* the card */
.table { display: grid; place-items: center; padding: var(--s-2) 0; perspective: 900px; }
.card3d { width: var(--card-w); aspect-ratio: 5 / 7; }
.flip { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.flip.reveal { animation: reveal var(--flip) cubic-bezier(0.45, 0, 0.2, 1); }
@keyframes reveal {
  0% { transform: translateY(-16px) rotateY(-180deg) scale(1.03); }
  100% { transform: none; }
}
.face { position: absolute; inset: 0; border-radius: var(--radius); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.front { background: var(--card); box-shadow: 0 0 0 1px var(--rule), 0 10px 24px -12px oklch(30% 0.05 260 / 0.35); color: var(--ink); transition: box-shadow var(--dur) linear; }
.front.red { color: var(--suit-red); }
.back { transform: rotateY(180deg); background:
  repeating-linear-gradient(45deg, oklch(100% 0 0 / 0.13) 0 6px, transparent 6px 14px),
  var(--accent); box-shadow: inset 0 0 0 8px var(--card), inset 0 0 0 9px var(--rule); display: grid; place-items: center; color: var(--card); }
.back__mark { display: flex; gap: 2px; padding: 10px 12px; border-radius: var(--pill); background: var(--accent); }
.back__mark svg { width: 26px; height: 26px; }
.corner { position: absolute; display: grid; justify-items: center; line-height: 1; font-weight: 800; font-size: calc(var(--card-w) * 0.15); letter-spacing: -0.05em; }
.corner svg { width: calc(var(--card-w) * 0.1); height: calc(var(--card-w) * 0.1); fill: currentColor; margin-top: 4px; }
.corner.tl { top: 8%; left: 9%; }
.corner.br { bottom: 8%; right: 9%; transform: rotate(180deg); }
.centre { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; }
.centre svg { width: calc(var(--card-w) * 0.44); height: calc(var(--card-w) * 0.44); fill: currentColor; }
.centre b { font-size: calc(var(--card-w) * 0.46); font-weight: 800; line-height: 0.9; letter-spacing: -0.06em; }
.centre b + svg { width: calc(var(--card-w) * 0.22); height: calc(var(--card-w) * 0.22); margin-top: 6px; }
.court .centre b { padding: 0.08em 0.18em 0.12em; border-radius: 14px; background: var(--paper-2); }
.front.red.court .centre b { background: oklch(95% 0.025 25); }
#play[data-result="good"] .front { box-shadow: 0 0 0 3px var(--good), 0 10px 24px -12px oklch(30% 0.05 260 / 0.35); }
#play[data-result="bad"] .front { box-shadow: 0 0 0 3px var(--bad), 0 10px 24px -12px oklch(30% 0.05 260 / 0.35); }

.say { min-height: 3em; display: grid; place-items: center; text-align: center; font-weight: 700; color: var(--ink-2); text-wrap: balance; }
.say.good { color: var(--good-ink); }
.say.bad { color: var(--bad-ink); }

.controls, .verdict { display: grid; gap: var(--s-2); margin-top: auto; }
.calls { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s-2); }
.call { min-height: 72px; padding-inline: var(--s-3); background: var(--accent-soft); color: var(--accent-ink); }
.call:hover { background: oklch(88.5% 0.055 258); }
.call svg { width: 22px; height: 22px; flex: none; }
.same { min-height: 72px; padding-inline: var(--s-3); min-width: 72px; font-size: var(--t-sm); color: var(--ink-2); }
.pass-on:not(:disabled) { background: var(--ink); color: var(--paper); }
.pass-on:not(:disabled):hover { background: var(--ink-2); }
.verdict { padding: var(--s-4); border-radius: var(--radius); background: var(--bad-soft); }
.verdict__sips { font-size: var(--t-xl); font-weight: 800; line-height: 1.15; color: var(--bad-ink); text-wrap: balance; overflow-wrap: anywhere; }
.verdict__why { color: var(--ink-2); text-wrap: pretty; margin-bottom: var(--s-2); }
.tally { min-height: 1.5em; font-size: var(--t-sm); color: var(--muted); text-align: center; text-wrap: balance; }
.tally b { color: var(--ink-2); font-weight: 700; }
.tally b.now { color: var(--accent-ink); }

.flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 5; }
.flash.good { background: var(--good); animation: flash 520ms ease-out; }
.flash.bad { background: var(--bad); animation: flash 640ms ease-out; }
@keyframes flash { 0% { opacity: 0.55; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 22.5rem) { :root { --t-3xl: 2.5rem; --t-2xl: 1.9rem; } .call { font-size: var(--t-md); } }
@media (max-height: 700px) {
  :root { --card-w: clamp(116px, 21dvh, 190px); }
  .game { gap: var(--s-2); }
  .who { font-size: var(--t-xl); }
  .turn .kicker { display: none; }
  .row { min-height: 46px; } .mini { width: 34px; height: 46px; }
  .table { padding: 0; }
  .say { min-height: 3em; font-size: var(--t-sm); }
  .call, .same { min-height: 56px; }
  .verdict { padding: var(--s-3) var(--s-4); }
}

/* back to games.el.zone, on the home screen only */
.back-home { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; min-height: 44px; margin: -12px 0 4px -6px; padding: 0 10px 0 4px; border-radius: 999px; color: inherit; opacity: 0.6; font-size: 0.875rem; font-weight: 600; line-height: 1; text-decoration: none; transition: opacity 140ms linear; }
.back-home:hover, .back-home:focus-visible { opacity: 1; }
.back-home svg { flex: none; }
