/* Hearts, ivory cards on a soft green baize table, on a calm linen page. Fixed palette. */
:root {
  color-scheme: light;
  --bg: #f1ece3;
  --bg-2: #e7dfd2;
  --ink: #2b2a33;
  --muted: #847c71;
  --paper: #fffdf8;
  --line: #e2d9ca;
  --felt: #2f6a53;
  --felt-hi: #3b7d63;
  --felt-lo: #245543;
  --red: #c42c3b;
  --black: #1f222b;
  --back: #2f4c7c;
  --gold: #f2c14e;
  --s0: #e9a23b;   /* you */
  --s1: #7db3a2;   /* Ana, left */
  --s2: #a9a3d6;   /* Ben, across */
  --s3: #e59478;   /* Cleo, right */
  /* tutorial kit (tutorial.css) */
  --tut-accent: #f2c14e;
  --tut-accent-ink: #2b2a33;
  --tut-bubble: #fffdf8;
  --tut-ink: #2b2a33;
  --tut-muted: #847c71;
  --tut-dim: rgba(14, 30, 24, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 30%, #f8f5ef 0%, var(--bg) 60%, var(--bg-2) 100%) fixed;
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- bar ---------- */
.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 980px; margin: 0 auto;
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(14px, env(safe-area-inset-left));
}
.bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 60px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; padding: 12px 2px; }
.back:hover, .back:focus-visible { color: var(--ink); }
.bar-actions { display: flex; gap: 8px; }

.btn {
  min-height: 44px; min-width: 44px; padding: 0 18px; border-radius: 22px;
  border: 0; background: var(--paper); color: var(--ink);
  font-weight: 650; cursor: pointer; box-shadow: 0 1px 2px rgba(43, 42, 51, .12), 0 0 0 1px var(--line);
  transition: transform .12s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.icon { padding: 0; width: 44px; font-size: 22px; line-height: 1; letter-spacing: .04em; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.primary { background: var(--ink); color: var(--paper); box-shadow: none; }
.btn.wide { width: 100%; min-height: 50px; font-size: 17px; }
.btn:disabled, .row:disabled { opacity: .35; cursor: default; transform: none; }
.btn:focus-visible, .pc:focus-visible, .seg button:focus-visible, .row:focus-visible, .link:focus-visible {
  outline: 3px solid var(--s0); outline-offset: 2px;
}

/* ---------- game ---------- */
.game {
  flex: 1; min-height: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px; padding-bottom: 10px;
}
.turn {
  justify-self: center; display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 18px; border-radius: 999px; background: var(--paper);
  box-shadow: 0 0 0 1px var(--line); font-weight: 650; font-size: 16px; min-height: 40px;
}
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; transition: background .2s; }
.dot.s0 { background: var(--s0); } .dot.s1 { background: var(--s1); }
.dot.s2 { background: var(--s2); } .dot.s3 { background: var(--s3); }
.turn.thinking #turn-text::after { content: ''; display: inline-block; width: 1.1em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.hint { justify-self: center; min-height: 22px; font-size: 15px; color: var(--muted); text-align: center; line-height: 1.35; }
.hint b { color: var(--ink); }
.hint .sym { display: inline-block; width: .9em; height: .9em; vertical-align: -.1em; }

/* ---------- table ---------- */
.table {
  position: relative; min-height: 0;
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 50% 42%, var(--felt-hi) 0%, var(--felt) 55%, var(--felt-lo) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), inset 0 10px 30px rgba(0, 0, 0, .18), 0 8px 20px rgba(43, 42, 51, .14);
  overflow: hidden;
  display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none;
}
.stage { position: relative; flex: 1 1 auto; min-height: 0; }
.seat { position: absolute; z-index: 3; }
.seat-2 { top: 10px; left: 50%; transform: translateX(-50%); }
.seat-1 { left: 10px; top: 50%; transform: translateY(-50%); }
.seat-3 { right: 10px; top: 50%; transform: translateY(-50%); }
.seat-0 { bottom: 6px; left: 50%; transform: translateX(-50%); }
.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 7px; border-radius: 16px;
  background: rgba(16, 40, 31, .38); color: #f4f1e8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  transition: box-shadow .2s, background .2s;
  white-space: nowrap;
}
.seat-1 .chip, .seat-3 .chip { flex-direction: column; gap: 3px; padding: 8px 8px 7px; text-align: center; }
.chip.active { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(242, 193, 78, .45); background: rgba(16, 40, 31, .55); }
.chip .who { display: flex; flex-direction: column; line-height: 1.15; }
.seat-1 .chip .who, .seat-3 .chip .who { align-items: center; }
.chip .nm { font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 5px; }
.chip .nm i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip .sc { font-size: 13px; color: rgba(244, 241, 232, .78); font-variant-numeric: tabular-nums; }
.chip .sc b { color: #fff; font-size: 15px; }
.chip .tk { color: #ffb3a8; font-weight: 700; margin-left: 4px; }
.mini {
  position: relative; width: 22px; height: 30px; border-radius: 4px; flex: none;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .16) 0 2px, transparent 2px 5px), var(--back);
  box-shadow: 0 0 0 1.5px #fffdf8, 2px -2px 0 -.5px rgba(255, 253, 248, .6);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff;
}
.mini span { background: var(--back); border-radius: 3px; padding: 0 2px; line-height: 14px; }

.trick { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: calc(var(--cw) * 2.45); height: calc(var(--cw) * 3); }
.tc { position: absolute; }
.tc.at-0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.tc.at-2 { left: 50%; top: 0; transform: translateX(-50%); }
.tc.at-1 { left: 0; top: 50%; transform: translateY(-50%) rotate(-4deg); }
.tc.at-3 { right: 0; top: 50%; transform: translateY(-50%) rotate(4deg); }
.tc .pc { position: relative; display: block; }
.tc.fly-0 .pc { animation: fly0 .28s ease-out; }
.tc.fly-1 .pc { animation: fly1 .28s ease-out; }
.tc.fly-2 .pc { animation: fly2 .28s ease-out; }
.tc.fly-3 .pc { animation: fly3 .28s ease-out; }
@keyframes fly0 { from { transform: translateY(120%); opacity: .3; } }
@keyframes fly1 { from { transform: translateX(-120%); opacity: .3; } }
@keyframes fly2 { from { transform: translateY(-120%); opacity: .3; } }
@keyframes fly3 { from { transform: translateX(120%); opacity: .3; } }
.tc.won .pc { box-shadow: 0 0 0 3px var(--gold), 0 4px 14px rgba(0, 0, 0, .35); }
.trick.collect-0 .tc { transition: transform .35s ease-in, opacity .35s ease-in; opacity: 0; transform: translate(-50%, 160%); }
.trick.collect-2 .tc { transition: transform .35s ease-in, opacity .35s ease-in; opacity: 0; transform: translate(-50%, -160%); }
.trick.collect-1 .tc { transition: transform .35s ease-in, opacity .35s ease-in; opacity: 0; transform: translate(-160%, -50%); }
.trick.collect-3 .tc { transition: transform .35s ease-in, opacity .35s ease-in; opacity: 0; transform: translate(160%, -50%); }
.pass-btn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; min-width: 150px; min-height: 50px; font-size: 17px; }
.pass-btn:active { transform: translate(-50%, -50%) scale(.97); }
.pass-btn:disabled { opacity: 1; transform: translate(-50%, -50%); background: rgba(16, 40, 31, .45); color: rgba(244, 241, 232, .7); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }

/* ---------- cards ---------- */
.pc {
  --r: calc(var(--cw) * .09);
  position: absolute; width: var(--cw); height: calc(var(--cw) * 1.4);
  border-radius: var(--r); border: 0; padding: 0; margin: 0;
  background: linear-gradient(180deg, #fffefb, #faf6ec);
  color: var(--black);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .28), 0 0 0 1px rgba(31, 34, 43, .12);
  font-size: var(--cw); line-height: 1;
  text-align: left;
}
.pc.red { color: var(--red); }
.pc .ix { position: absolute; left: .06em; top: .07em; width: .3em; display: flex; flex-direction: column; align-items: center; }
.pc .ix b { font-size: .29em; font-weight: 800; letter-spacing: -.02em; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.pc .ix b.ten { letter-spacing: -.09em; margin-left: -.06em; }
.pc .ix svg { width: .21em; height: .21em; margin-top: .03em; fill: currentColor; }
.pc .mid { position: absolute; left: .3em; right: .08em; top: .3em; bottom: .12em; display: grid; place-items: center; }
.pc .mid svg { width: .5em; height: .5em; fill: currentColor; }
.pc .mid.ace svg { width: .56em; height: .56em; }
.pc .face {
  position: absolute; left: .32em; right: .09em; top: .33em; bottom: .1em;
  border-radius: .06em; border: .012em solid currentColor; opacity: .92;
  display: grid; place-items: center; align-content: center; gap: .02em;
  background: linear-gradient(180deg, rgba(242, 193, 78, .16), rgba(242, 193, 78, .05));
}
.pc .face b { font: 700 .4em/1 Georgia, "Times New Roman", serif; }
.pc .face svg { width: .2em; height: .2em; fill: currentColor; }
.pc.back {
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .13) 0 3px, transparent 3px 8px),
              repeating-linear-gradient(-45deg, rgba(255, 255, 255, .13) 0 3px, transparent 3px 8px), var(--back);
  box-shadow: inset 0 0 0 calc(var(--cw) * .05) #fffdf8, 0 1px 2px rgba(0, 0, 0, .28);
}

/* ---------- hand ---------- */
.hand { position: relative; flex: none; min-height: 60px; margin: 0 8px 6px; }
.hand .pc .hit { position: absolute; left: 0; top: 0; }
.hand .pc { cursor: pointer; transition: transform .16s ease-out, filter .16s, left .2s, top .2s; }
.hand .pc.dim { filter: brightness(.84); cursor: default; }
.hand .pc.sel { transform: translateY(-18%); box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0, 0, 0, .25); }
.hand .pc.got::after {
  content: ''; position: absolute; left: .1em; top: .6em; width: .1em; height: .1em; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 .02em rgba(0, 0, 0, .15);
}
@media (hover: hover) { .hand .pc.can:hover { transform: translateY(-8%); } .hand .pc.sel:hover { transform: translateY(-18%); } }
.hand .pc.can:active { transform: translateY(-5%); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(43, 42, 51, .38);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
  animation: fade .2s ease-out;
}
.overlay.soft { background: rgba(241, 236, 227, .5); align-items: center; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet, .card-box {
  background: var(--paper); color: var(--ink);
  width: 100%; max-width: 440px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow: auto; overscroll-behavior: contain;
  border-radius: 24px; padding: 8px 20px 20px;
  box-shadow: 0 20px 50px rgba(43, 42, 51, .25);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) { .overlay { align-items: center; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.row {
  display: block; width: 100%; text-align: left; min-height: 50px; padding: 0 4px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; font-weight: 600; cursor: pointer;
}
.group { padding: 12px 0 4px; }
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--bg); }
.seg button {
  flex: 1 1 0; min-height: 44px; border: 0; border-radius: 12px; background: transparent;
  font-weight: 600; cursor: pointer; color: var(--muted); transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(43, 42, 51, .18); }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.menu-sheet #menu-undo { border-top: 1px solid var(--line); }
.menu-sheet #menu-scores { margin-top: 10px; border-top: 1px solid var(--line); }
.menu-sheet .btn.wide { margin-top: 16px; }

.sum-card, .over-card { max-width: 340px; text-align: center; padding: 24px 22px 14px; }
.sum-title, .over-title { font-size: 26px; font-weight: 800; }
.sum-sub { color: var(--muted); font-size: 15px; min-height: 4px; margin-top: 2px; }
.tally { margin: 14px 0 18px; text-align: left; }
.tally .tr { display: grid; grid-template-columns: 1fr auto 3.2em; gap: 8px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tally .tr:last-child { border-bottom: 0; }
.tally .tr span { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.tally .tr i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tally .tr em { font-style: normal; color: var(--red); font-weight: 700; font-size: 14px; }
.tally .tr em.zero { color: var(--muted); font-weight: 500; }
.tally .tr b { text-align: right; font-size: 18px; }
.tally .tr.best b { color: #1f7a4f; }
.link { display: block; margin: 8px auto 0; min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
i.c0 { background: var(--s0); } i.c1 { background: var(--s1); } i.c2 { background: var(--s2); } i.c3 { background: var(--s3); }

.score-grid { display: grid; grid-template-columns: 3em repeat(4, 1fr); font-variant-numeric: tabular-nums; text-align: center; padding-bottom: 8px; }
.score-grid > div { padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.score-grid .h { font-weight: 700; font-size: 14px; }
.score-grid .n { color: var(--muted); }
.score-grid .t { font-weight: 800; border-bottom: 0; }

.help-sheet { max-width: 560px; }
.help-body { padding-bottom: 6px; }
.help-body h3 { font-size: 16px; margin: 18px 0 4px; }
.help-body p, .help-body li { font-size: 15px; margin: 4px 0; }
.help-body ul { padding-left: 20px; }

/* ---------- small phones ---------- */
@media (max-width: 380px) {
  .app { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .btn { padding: 0 14px; }
  .back { font-size: 13px; }
  .chip { padding: 5px 9px 5px 6px; }
}
@media (max-height: 700px) {
  .bar { min-height: 52px; }
  .game { gap: 6px; padding-bottom: 6px; }
  .turn { min-height: 36px; padding: 6px 16px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* The tutorial kit's first-visit chip sits over the turn pill instead of on top of your hand
   (it goes away once you make your first move). */
body > .tut-chip { top: calc(env(safe-area-inset-top, 0px) + 58px); bottom: auto; }
