@font-face { font-family: "Bodoni Moda"; font-weight: 600; font-display: swap; src: url(/fonts/bodoni-moda-600.woff2) format("woff2"); }
@font-face { font-family: "Sign"; font-display: block; src: url(/fonts/sacramento-sign.woff2) format("woff2"); }

:root {
  --ground: #0f1b17; --panel: #142420; --line: #24352e; --ink: #ede7dc; --mute: #a6b7ae;
  /* The lantern ramp: the only emphasis scale (turn, selection, callable, closeness). */
  --l1: rgba(242, 182, 90, .06); --l2: rgba(242, 182, 90, .13); --l3: rgba(242, 182, 90, .24); --l4: rgba(242, 182, 90, .5); --l5: #f2b65a;
  --neon: #ff5fa8; --neon-ink: #ffc2de;
  --dot: #1e5aa8; --bam: #17744a; --crak: #b62f2a; --bone: #fffbf3; --bone2: #efe5d3; --edge: #d8c8ac;
  --back: #c4467a; --lip: #ebdfc9; /* tile backs are SUR rose, like a pink-backed American set */
  --sa: #8ab4f8; --sb: #f28b82; --sc: #81c995; /* card colors for suit a, b, c: the printed card's blue, red, green */
  --twmax: 58px; --sw: min(26px, 3.1vw); --xs: 20px; --pile: var(--xs); /* --pile: a discard in a by-player pile */
  --pad-t: max(8px, env(safe-area-inset-top)); --pad-b: max(10px, env(safe-area-inset-bottom));
  --pad-l: max(16px, env(safe-area-inset-left)); --pad-r: max(16px, env(safe-area-inset-right));
  /* On a wide window the home, table, and end screens sit in a centered 1080px band instead of hugging both edges. */
  --edge-l: max(var(--pad-l), calc(50vw - 540px)); --edge-r: max(var(--pad-r), calc(50vw - 540px));
  --stroke: rgba(237, 231, 220, .38); /* control edges: 3.1:1 on the ground */
  --sheet: #12201c; --night: #0d1714; --name-on: #fff3dc; --neon-soft: #ffd0e4; --joker-ink: #ffd6e8;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --display: "Bodoni Moda", "Didot", serif;
  --ease: cubic-bezier(.2, .9, .25, 1);
  color-scheme: dark;
}
:root.big { --sw: min(31px, 3.7vw); --xs: 24px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--ground); color: var(--ink); font: 15px/1.35 var(--ui); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--l5); outline-offset: 2px; }
::selection { background: var(--l4); color: var(--ink); }
.defs { position: absolute; width: 0; height: 0; }

/* ---------- Buttons ---------- */
.btn { min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 17px/1 var(--ui); border: 1px solid var(--stroke); background: rgba(237, 231, 220, .04); transition: transform .2s ease-out, background .3s ease-out; white-space: nowrap; }
.btn:active { transform: scale(.96); background: rgba(237, 231, 220, .16); transition-duration: 0s; } /* instant on the way down, eased on release */
/* The finger hides a button while it is down, so a soft wash confirms the tap as it lifts (see tapped() in main.js). */
.tapped { position: fixed; z-index: 35; pointer-events: none; background: rgba(237, 231, 220, .22); animation: tapped .4s ease-out forwards; }
@keyframes tapped { to { opacity: 0; } }
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary:active, .btn.mahjong:active { filter: brightness(.86); }
.btn.primary { background: var(--l5); color: #1d1408; border: 0; box-shadow: 0 2px 0 #b98431, 0 8px 16px rgba(0, 0, 0, .4); }
.btn.mahjong { background: var(--neon); color: #2a0718; border: 0; box-shadow: 0 2px 0 #b8336f, 0 8px 16px rgba(0, 0, 0, .4); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn.primary:disabled { opacity: 1; background: transparent; color: var(--mute); border: 1px solid var(--l4); box-shadow: none; }
.btn.icon { padding: 0; width: 44px; }

/* ---------- Tiles ---------- */
.t { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; flex: none;
  width: var(--tw, 46px); height: calc(var(--tw, 46px) * 1.34); border-radius: calc(var(--tw, 46px) * .15);
  background: linear-gradient(#fffdf8, var(--bone2) 92%);
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 var(--edge), 0 1px 0 var(--lip), 0 4px 0 var(--back), 0 8px 12px rgba(0, 0, 0, .45);
  font: 800 calc(var(--tw, 46px) * .52)/1 var(--ui); font-style: normal; color: #1c2a24; text-shadow: 0 1px 0 rgba(255, 255, 255, .8); /* carved: light catches the groove's lower lip */
  transition: transform .16s var(--ease); }
.t::after { flex: none; }
.d { color: var(--dot); }
.d::after { content: ""; width: .44em; height: .44em; border-radius: 50%; border: .1em solid var(--dot); background: radial-gradient(var(--crak) 0 30%, transparent 36%); }
.b { color: var(--bam); }
.b::after { content: ""; width: .19em; height: .56em; border-radius: .1em; background: linear-gradient(var(--bam) 0 44%, #0c4a30 44% 56%, var(--bam) 56%); }
.c { color: var(--crak); }
.c::after { content: "萬"; font: 700 .42em/1 "PingFang SC", "Hiragino Sans", sans-serif; }
.w::after { content: attr(data-h); font: 600 .42em/1 "PingFang SC", "Hiragino Sans", sans-serif; color: #56635c; }
.r, .g { font-family: "PingFang SC", "Hiragino Sans", sans-serif; font-weight: 700; }
.r { color: var(--crak); font-size: calc(var(--tw, 46px) * .56); } .g { color: var(--bam); font-size: calc(var(--tw, 46px) * .5); }
.o { color: var(--dot); }
.o .zero { display: grid; place-items: center; width: 1.06em; height: 1.22em; border: .09em solid var(--dot); border-radius: .14em; font-size: .72em; font-weight: 800; line-height: 1; }
.t.o::after { content: "SOAP"; font: 800 .3em/1 var(--ui); letter-spacing: .08em; padding-left: .08em; color: #56635c; }
.t.s.o::after { content: none; } .s.o .zero { font-size: .8em; }
.j { color: var(--joker-ink); font-weight: 900; text-shadow: 0 0 2px rgba(255, 95, 168, .9), 0 0 7px rgba(255, 95, 168, .5); }
.t.j::after { content: "JOKER"; font: 800 .34em/1 var(--ui); letter-spacing: .1em; padding-left: .1em; white-space: nowrap; }
.t.s.j::after { content: none; }
.t.j { background: radial-gradient(120% 90% at 50% 15%, #3b1a2d, #1c0d16 75%);
  box-shadow: inset 0 0 0 1.5px rgba(255, 95, 168, .6), inset 0 0 calc(var(--tw, 46px) * .22) rgba(255, 95, 168, .28), 0 1px 0 #4a2238, 0 4px 0 var(--back), 0 8px 12px rgba(0, 0, 0, .45); }
.t.s.j { box-shadow: inset 0 0 0 1px rgba(255, 95, 168, .6), inset 0 0 5px rgba(255, 95, 168, .25), 0 1px 0 #4a2238, 0 3px 0 var(--back), 0 5px 6px rgba(0, 0, 0, .35); }
.f svg { width: 80%; height: 62%; }
.s.w::after { content: none; } .s.w { font-size: calc(var(--tw) * .6); }
.s { --tw: var(--sw); box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 var(--edge), 0 1px 0 var(--lip), 0 3px 0 var(--back), 0 5px 6px rgba(0, 0, 0, .35); }
.xs { --tw: var(--xs); }
.t.sel { transform: translateY(-14%); outline: 2px solid var(--l5); outline-offset: 1px; }
.t.hint { outline: 2px dashed var(--l5); outline-offset: 2px; }
.t.last { outline: 2px solid var(--l5); outline-offset: 1px; }
.t.off { opacity: .45; }
button.t:active { transform: translateY(-6%) scale(.98); }

/* ---------- Home ---------- */
.home { position: fixed; inset: 0; display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; gap: 24px; overflow-y: auto;
  padding: var(--pad-t) var(--edge-r) var(--pad-b) var(--edge-l);
  --sx: calc(var(--edge-l) + min(304px, 22.8vw)); --sy: 40%; /* the spill sits behind the sign wherever the band puts it */
  background: radial-gradient(min(46%, 520px) 55% at var(--sx) var(--sy), rgba(255, 95, 168, .16), transparent 70%), radial-gradient(70% 60% at 30% 95%, var(--l3), transparent 70%), var(--ground); }
.sign { font: 400 clamp(44px, 9.5vw, 92px)/1.05 "Sign", cursive; color: var(--neon-ink); text-shadow: 0 0 4px rgba(255, 95, 168, .9), 0 0 16px rgba(255, 95, 168, .55), 0 0 34px rgba(255, 95, 168, .3); }
/* A sign is one line: sized to the column so "Mahj" never drops to a line of its own. */
.home .sign { font-size: min(88px, 6.6vw); white-space: nowrap; padding-bottom: .12em; }
.home .quip { margin-top: 18px; max-width: 36ch; }
.home .quip blockquote { font: 600 16px/1.35 var(--display); color: var(--neon-ink); }
.home .quip figcaption { font: 600 13px/1.3 var(--ui); color: var(--mute); margin-top: 4px; }
.home .menu { display: flex; flex-direction: column; gap: 12px; max-width: 340px; width: 100%; justify-self: end; }
.home .menu .btn { width: 100%; justify-content: space-between; }
.home .menu .btn small { font: 500 13px var(--ui); color: inherit; opacity: .75; }
.home .stats { color: var(--mute); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.home .stand { color: var(--mute); font-size: 12px; margin-top: 14px; }

/* ---------- Table ---------- */
.table { position: fixed; inset: 0; display: grid; gap: 6px 14px; padding: var(--pad-t) var(--edge-r) var(--pad-b) var(--edge-l);
  grid-template-columns: minmax(92px, 15%) minmax(0, 1fr) minmax(92px, 15%); grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "head head head" "left pool right" "bar bar bar" "rack rack rack"; }
/* Held sideways, height is the scarce thing: the player across shows called tiles beside the name, not under it. */
.head { grid-area: head; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.bar { grid-area: bar; display: flex; gap: 12px; align-items: center; min-width: 0; }
.lantern { position: fixed; left: 0; top: 0; width: 560px; height: 220px; margin: -110px 0 0 -280px; pointer-events: none; border-radius: 50%;
  background: radial-gradient(closest-side, var(--l3), var(--l2) 55%, transparent); transition: opacity .3s; z-index: 0; }
.table > * { position: relative; z-index: 1; }
.tl { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tl .sign { font-size: 27px; line-height: 1; white-space: nowrap; }
.sign.hum { color: var(--neon-soft); text-shadow: 0 0 3px rgba(255, 95, 168, .75), 0 0 10px rgba(255, 95, 168, .35); }
/* Neon spill: the sign's light on the wall behind it. Kept off the tiles. */
.table::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(min(34%, 420px) 44% at calc(var(--edge-l) + 110px) 0%, rgba(255, 95, 168, .13), transparent 72%); }
.sign.ignite { animation: ignite 1.3s steps(1) both; }
@keyframes ignite { 0% { opacity: .12; } 20% { opacity: 1; } 27% { opacity: .35; } 38%, 100% { opacity: 1; } }
.top { justify-self: center; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; max-width: 100%; }
.top .exps { margin-top: 0; }
.top .exp .t { --tw: var(--xs); }
.tr { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.tr .btn { flex: none; }
.left { grid-area: left; align-self: start; }
.right { grid-area: right; align-self: start; text-align: right; }
.right .row { justify-content: flex-end; }
.pool-wrap { grid-area: pool; display: flex; flex-direction: column; justify-content: center; min-height: 0; min-width: 0; }
/* Grouped and in order: rows of small tiles. When a long game outgrows the space, the oldest rows clip, not the newest. */
.pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 2px; align-content: flex-end; overflow: hidden; padding: 4px; min-height: 0; }
/* By player: each one's throws in a loose pile on their own side of the table, a little crooked, the way they land.
   Held sideways, the three others sit along the top and her own pile runs the width above her rack. main.js
   (place) shrinks a pile's tiles through --fit when a long game outgrows its patch. */
.pool.seat { flex: 1; display: grid; gap: 2px 6px; padding: 0; align-content: stretch;
  grid-template: "l t r" minmax(0, 1fr) "b b b" calc(var(--pile) * 1.34 + 12px) / minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
.pile { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 0 1px; overflow: hidden; min-width: 0; min-height: 0; padding: 3px; }
.pile.p3 { grid-area: l; } .pile.p2 { grid-area: t; } .pile.p1 { grid-area: r; } .pile.p0 { grid-area: b; }
.pile .t { --tw: var(--fit, var(--pile)); rotate: var(--r, 0deg); translate: var(--x, 0) var(--y, 0); margin-bottom: 1px; }
.pool .t.last { z-index: 2; }
/* Grouped: the count hangs off the tile's lower corner, clear of its suit mark. */
.pool.group { gap: 6px 5px; }
.grp { position: relative; display: inline-flex; }
.grp > b { position: absolute; right: -7px; bottom: -5px; z-index: 3; min-width: 14px; padding: 2px; border-radius: 8px; text-align: center;
  background: var(--night); color: var(--ink); font: 700 10px/1 var(--ui); font-variant-numeric: tabular-nums; box-shadow: 0 0 0 1px var(--stroke); }
/* The second-Charleston vote: the question in the middle of the table with its two answers. Flat on the ground, no card. */
.ask { flex: 1; min-height: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 4px 8px; text-align: center; }
.ask.enter { animation: talk-in .25s var(--ease); }
.askq { font: 600 22px/1.2 var(--ui); }
.asks { max-width: 46ch; margin-top: 4px; color: var(--mute); font-size: 14px; line-height: 1.35; }
.askb { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } /* two answers, one size: neither is the default */
.askb .btn { min-width: 132px; min-height: 48px; }
/* A phone held sideways is short, and a coach note can be open under it: one line of explanation, slimmer answers. */
@media (max-height: 500px) { .ask { gap: 8px; } .asks { max-width: none; } .askb .btn { min-height: 44px; } }
.poolfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; min-height: 28px; }
.pview { display: flex; gap: 2px; }
.pview button { position: relative; min-height: 28px; padding: 0 10px; border-radius: 8px; font: 600 12px/1 var(--ui); color: var(--mute); white-space: nowrap; }
.pview button::before { content: ""; position: absolute; inset: -12px 0 -4px; } /* a 44px tap target on a 28px control */
.pview button.on { background: var(--l2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--l4); }
.pview button:active { background: rgba(237, 231, 220, .16); }
.wallct { color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.name { display: block; font: 600 22px/1 var(--display); color: var(--ink); opacity: .82; transition: opacity .3s; }
.seat.on .name { opacity: 1; color: var(--name-on); }
/* Cartoon portraits. Whose turn it is must not rest on the glow alone: the acting player's portrait gets a bright, thicker ring. */
.av { flex: none; border-radius: 50%; object-fit: cover; background: var(--panel); box-shadow: 0 0 0 1px var(--stroke); }
/* The face and name are one button that opens the player's card. */
.who { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 2px 6px 2px 2px; margin: -2px -6px -2px -2px; border-radius: 12px; text-align: inherit; }
.who:active { background: rgba(237, 231, 220, .14); }
.left .who { flex-direction: column; align-items: flex-start; gap: 6px; }
.right .who { flex-direction: column; align-items: flex-end; gap: 6px; }
.seat.on .av { box-shadow: 0 0 0 3px var(--l5); }
.exps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.top .exps { justify-content: center; }
.exp { display: flex; gap: 2px; }
.talk { position: fixed; z-index: 25; max-width: 220px; padding: 8px 12px; border-radius: 12px; background: var(--bone); color: #1c2a24;
  font: 600 13px/1.3 var(--ui); box-shadow: 0 8px 18px rgba(0, 0, 0, .45); white-space: normal; }
.talk.enter { animation: talk-in .25s var(--ease); }
.talk[hidden], .toast[hidden] { display: none; }
@keyframes talk-in { from { opacity: 0; translate: 0 4px; } }

/* The Card button carries the hand she is going for: one control, with her progress in the caption. */
.tr .btn.goal { flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 0 14px 0 12px; gap: 10px; }
.goal svg { flex: none; }
.goal .gl { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.goal .gl > b { font: 600 15px/1 var(--ui); }
.goal .gl small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 12px/1.1 var(--ui); color: var(--mute); font-variant-numeric: tabular-nums; }
.goal .away { font-weight: 600; color: var(--ink); }
.goal .away.near { color: var(--l5); }

.coach { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 14px; border-radius: 12px; background: rgba(20, 36, 32, .82); border: 1px solid var(--line); min-width: 0; }
.coach:empty { visibility: hidden; }
.coach .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--l5); }
.coach .msg { font-size: 15px; line-height: 1.3; min-width: 0; }
.coach .msg b { font-weight: 600; }
.coach .rule { display: block; font: 600 12px/1.3 var(--ui); color: var(--ink); opacity: .75; margin-bottom: 2px; }
.coach .meta { margin-left: auto; flex: none; font-size: 12px; color: var(--mute); }
.coach .x { margin-left: auto; flex: none; }
.coach.note { border-color: var(--l4); }
.acts { flex: none; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
/* Sort: one button that cycles the rack's order, with the current order named under the icon. */
.btn.sort { flex: none; flex-direction: column; gap: 3px; padding: 0 8px; min-width: 52px; }
.btn.sort svg { width: 16px; height: 16px; }
.btn.sort small { font: 600 11px/1 var(--ui); color: var(--mute); }
.rack-row { grid-area: rack; display: flex; align-items: flex-end; gap: 12px; min-width: 0; }
.mine { display: flex; gap: 6px; flex: none; }
.rack-wrap { flex: 1; min-width: 0; container-type: inline-size; }
.rack { display: flex; gap: 4px; justify-content: center; padding-top: 10px; }
.rack .t { --tw: min(var(--twmax), calc((100cqw - (var(--n) - 1) * 4px - var(--apart, 0px) - 1px) / var(--n))); touch-action: none; }
.rack .t.apart { margin-left: 12px; } /* a gap before the tiles her hand does not need, and before new arrivals; --apart is their total */
.rack-row.on .t:not(.j) { background: linear-gradient(#fff6e2, #f2e0bf); }
.t.press { transform: translateY(-10%); }
.t.fly { transition: none; pointer-events: none; }
.t.drag { transition: none; z-index: 5; box-shadow: inset 0 -3px 0 var(--edge), 0 16px 24px rgba(0, 0, 0, .5); }

/* Portrait: the same table, stacked. */
@media (max-aspect-ratio: 4/5) {
  .table { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "head head" "left right" "pool pool" "bar bar" "rack rack"; }
  .head { grid-template-columns: minmax(0, 1fr); }
  .top { flex-direction: column; gap: 6px; } .top .exp .t { --tw: var(--sw); }
  .goalbar.many { grid-template-columns: minmax(0, 1fr); }
  .head .top { order: 3; }
  .bar { flex-direction: column; align-items: stretch; }
  .tl .sign { font-size: 24px; }
  .rack { flex-wrap: wrap; max-width: 100cqw; }
  .rack .t { --tw: min(var(--twmax), calc((100cqw - 6 * 4px - var(--apart, 0px) - 1px) / 7)); }
  .acts { justify-content: stretch; } .acts .btn { flex: 1; } .acts .btn.sort { flex: none; }
  .acts.quiet { justify-content: space-between; } .acts.quiet .btn { flex: none; } /* during the vote the answers are up on the table: Hint stays small */
  .pool.seat { grid-template: "t t" minmax(0, 1fr) "l r" minmax(0, 1.3fr) "b b" minmax(0, 1fr) / minmax(0, 1fr) minmax(0, 1fr); }
  :root { --pile: 24px; }
  .home { grid-template-columns: 1fr; align-content: center; text-align: center; --sx: 50%; --sy: 26%; }
  .home .quip { margin-inline: auto; } .home .menu { justify-self: center; }
  .left .who { flex-direction: row; align-items: center; gap: 8px; } .right .who { flex-direction: row-reverse; align-items: center; gap: 8px; }
  .home .sign { font-size: clamp(40px, 11.4vw, 72px); }
  :root { --sw: min(30px, 7.4vw); } /* portrait has room: bigger, more legible discards */
}

/* ---------- Sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(5, 10, 8, .55); }
.scrim.enter { animation: fade .2s ease-out; }
.sheet { position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(560px, 66vw); display: flex; flex-direction: column;
  padding: var(--pad-t) var(--pad-r) 0 20px; background: var(--sheet); border-left: 1px solid var(--line); box-shadow: -20px 0 40px rgba(0, 0, 0, .45); }
.sheet.enter { animation: slide .3s var(--ease); }
@media (max-aspect-ratio: 4/5) { .sheet { width: 100vw; padding-left: var(--pad-l); } }
@keyframes slide { from { transform: translateX(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet header { display: flex; align-items: center; gap: 12px; min-height: 52px; flex: none; }
.sheet h2 { font: 600 24px/1.1 var(--display); }
.sheet header .btn { margin-left: auto; }
.sheet .body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--pad-b) + 12px); flex: 1; }
.sheet .sub { color: var(--mute); font-size: 13px; margin-bottom: 8px; }
.sec { margin: 18px 0 6px; font: 700 12px/1 var(--ui); color: var(--mute); text-transform: uppercase; letter-spacing: .08em; }
.hand { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; min-height: 52px; border-radius: 12px; text-align: left; position: relative; }
.hand:active { background: var(--l1); }
.hand.pinned { background: rgba(237, 231, 220, .06); box-shadow: inset 0 0 0 2px var(--l5); margin: 4px 0; }
.hand .pat { font: 700 17px/1.25 var(--ui); letter-spacing: .04em; font-variant-numeric: tabular-nums; flex: 1; min-width: 0; }
.pat .pa { color: var(--sa); } .pat .pb { color: var(--sb); } .pat .pc { color: var(--sc); } .pat .pn { color: var(--ink); }
.hand .note { display: block; font: 500 12px/1.3 var(--ui); color: var(--mute); letter-spacing: 0; margin-top: 2px; }
.hand .val { flex: none; text-align: right; font: 600 13px/1.3 var(--ui); color: var(--mute); font-variant-numeric: tabular-nums; }
.hand .away { display: block; color: var(--ink); }
.hand .away.near { color: var(--l5); }
.hand.dead .pat { text-decoration: line-through; text-decoration-color: var(--mute); opacity: .5; }
.rules li { list-style: none; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rules h3 { font: 600 17px/1.3 var(--ui); }
.rules p { color: var(--mute); font-size: 14px; margin-top: 4px; }
.rules .dots { display: flex; gap: 5px; margin-top: 8px; }
.rules .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--stroke); }
.rules .dots i.on { background: var(--l5); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.opt .seg { display: flex; gap: 4px; }
.opt .seg .btn { min-height: 44px; padding: 0 12px; font-size: 14px; }
.opt .seg .btn.on { background: var(--l2); border-color: var(--l4); }

/* ---------- End of game ---------- */
.end { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: center;
  padding: var(--pad-t) var(--edge-r) var(--pad-b) var(--edge-l); background: radial-gradient(70% 60% at 25% 100%, var(--l2), transparent 70%), var(--night); }
.end.enter { animation: fade .3s ease-out; }
.end .sign.big { font-size: clamp(40px, 6.4vw, 64px); white-space: nowrap; padding-bottom: .22em; }
.end .sign.on { animation: flicker 1.2s steps(1) both; }
@keyframes flicker { 0% { opacity: 0; } 8% { opacity: 1; } 12% { opacity: .2; } 18% { opacity: 1; } 24% { opacity: .35; } 30%, 100% { opacity: 1; } }
.end h2 { font: 600 28px/1.15 var(--display); margin-top: 10px; }
.end .what { color: var(--mute); margin-top: 6px; }
.end .line { font: 600 17px/1.3 var(--display); color: var(--neon-ink); margin-top: 10px; }
.end .line .by { display: block; font: 600 13px/1.3 var(--ui); color: var(--mute); margin-top: 3px; }
.end .said { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.end .said .line { margin-top: 0; }
.end .won { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 14px; }
.end .won .t { --tw: 26px; }
.end .review h3 { font: 600 17px/1.3 var(--ui); }
.end .review .score { color: var(--mute); font-size: 14px; margin: 4px 0 12px; }
.end .review li { list-style: none; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.end .review li .rule { display: block; color: var(--mute); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.end .btns { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
@media (max-aspect-ratio: 4/5) { .end { grid-template-columns: 1fr; align-content: center; overflow-y: auto; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--pad-b) + 90px); transform: translateX(-50%); z-index: 40; padding: 10px 16px; border-radius: 12px;
  background: var(--bone); color: #1c2a24; font-weight: 600; box-shadow: 0 8px 18px rgba(0, 0, 0, .45); animation: talk-in .25s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .lantern { transition: opacity .3s; }
  .sheet.enter, .talk.enter, .toast, .ask.enter { animation: fade .2s ease-out; }
  .end .sign.on, .sign.ignite { animation: fade .5s ease-out both; }
  .t, .btn { transition: none; }
}

/* ---------- Seat pickers (Settings) ---------- */
.castnote { margin: 8px 0 4px; }
.ver { margin: 20px 0 4px; color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.ver span { display: block; margin-top: 2px; }
/* The card's second printed way to make a hand, and its credit line. */
.hand .alt { display: block; margin-top: 2px; }
.hand .alt i { margin-right: 8px; font: 500 12px/1 var(--ui); font-style: normal; letter-spacing: 0; color: var(--mute); }
.credit { margin: 20px 0 4px; color: var(--mute); font-size: 12px; }

/* ---------- Seat picker (Settings): tap a seat, then tap who sits there ---------- */
.seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seatbtn { display: grid; justify-items: center; gap: 4px; padding: 12px 4px; border-radius: 12px; border: 1px solid var(--stroke); background: rgba(237, 231, 220, .04); transition: transform .1s ease-out; }
.seatbtn.on { background: var(--l2); border-color: var(--l5); }
.seatbtn small { font: 600 12px/1 var(--ui); color: var(--mute); }
.seatbtn b { font: 600 17px/1.1 var(--display); }
.sub.about { margin: 10px 0 12px; }
.roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.castbtn { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 8px 2px; border-radius: 12px; transition: transform .1s ease-out; }
.castbtn b { font: 600 13px/1.1 var(--ui); }
.castbtn small { font: 600 11px/1 var(--ui); color: var(--mute); }
.castbtn.in small { color: var(--l5); }
.castbtn.in .av { box-shadow: 0 0 0 2px var(--l5); }
.seatbtn:active, .castbtn:active { transform: scale(.96); background: rgba(237, 231, 220, .16); }
/* A phone held sideways is short. Seats go portrait-beside-name and the roster six across, so the whole picker
   shows at once and she never scrolls between picking a seat and picking a player. */
@media (max-height: 500px) and (min-width: 780px) {
  .seatbtn { grid-template-columns: auto minmax(0, 1fr); justify-items: start; align-items: center; column-gap: 10px; row-gap: 3px; padding: 8px 12px; text-align: left; }
  .seatbtn .av { grid-row: 1 / 3; width: 40px; height: 40px; }
  .seatbtn small { align-self: end; }
  .seatbtn b { align-self: start; font-size: 16px; }
  .sub.about { margin: 8px 0 6px; }
  .roster { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .castbtn { padding: 6px 2px; }
  .castbtn .av { width: 44px; height: 44px; }
}

/* ---------- The hand she is going for, above her rack ---------- */
.goalbar { flex-direction: column; align-items: stretch; justify-content: center; gap: 3px; text-align: left; cursor: pointer; }
.goalrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: baseline; }
.goalbar .pat { display: block; min-width: 0; font: 700 15px/1.3 var(--ui); letter-spacing: .03em; font-variant-numeric: tabular-nums; }
/* Two or three hands: one line each, two across when she holds the phone sideways, so the bar stays short. */
.goalbar.many { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 20px; align-content: center; }
.goalbar.many .pat { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goalbar.many .way + .way { display: none; } /* the first printed way only; the card shows the other */
.goalbar .way { display: inline-block; white-space: nowrap; margin-right: 8px; } /* each printed way wraps as a whole */
.goalbar .pat i { margin-right: 6px; font: 500 12px/1 var(--ui); font-style: normal; letter-spacing: 0; color: var(--mute); }
.goalbar .gnote { grid-column: 1 / -1; display: block; font: 500 12px/1.25 var(--ui); color: var(--mute); }
.goalbar .meta { margin-left: 0; font: 600 13px/1 var(--ui); color: var(--ink); white-space: nowrap; }
.goalbar .meta.near { color: var(--l5); }
.goalbar:active { background: rgba(237, 231, 220, .12); }

/* ---------- Card progress, player cards, her profile, how to play ---------- */
.prog { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: baseline; padding: 10px 0 4px; font-size: 14px; }
.prog span { color: var(--mute); }
.prog b { font-weight: 600; font-variant-numeric: tabular-nums; }
.prog i { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--l5) calc(var(--p) * 100%), var(--stroke) 0); }
.hand .got { display: block; color: var(--l5); font-weight: 700; }
.pcard { display: flex; align-items: center; gap: 16px; padding: 8px 0 4px; }
.pcard .sub { margin: 6px 0 0; }
.lvl { display: flex; align-items: center; gap: 10px; font: 600 20px/1.1 var(--display); }
.pips { display: inline-flex; gap: 5px; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: var(--stroke); }
.pips i.on { background: var(--l5); }
.thought { margin: 14px 0 4px; }
.thought blockquote { font: 600 17px/1.35 var(--display); color: var(--neon-ink); }
.thought figcaption { font: 600 13px/1.3 var(--ui); color: var(--mute); margin-top: 4px; }
.traits { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.traits div { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.traits dt { font: 500 12px/1.2 var(--ui); color: var(--mute); }
.traits dd { margin-top: 2px; font: 600 15px/1.3 var(--ui); font-variant-numeric: tabular-nums; }
.sub.edge { margin-top: 12px; }
.howto dt { font: 600 17px/1.3 var(--ui); margin-top: 16px; }
.howto dd { margin-top: 4px; max-width: 62ch; color: var(--mute); font-size: 14px; line-height: 1.45; }
.opt > span small { display: block; margin-top: 2px; font: 500 12px/1.3 var(--ui); color: var(--mute); }

/* ---------- The Home Screen film: a tall video with its steps in words. Upright they stack; on a phone held sideways
   the film takes the sheet's height and the words sit beside it. It is sized so the steps show without scrolling. ---------- */
.film { display: grid; gap: 14px 20px; justify-items: start; margin-top: 4px; }
.film video { display: block; width: min(100%, 300px, 31vh); width: min(100%, 300px, 31dvh); aspect-ratio: 9 / 16; border-radius: 14px; border: 1px solid var(--line); background: var(--ground); }
.film ol { display: grid; gap: 8px; padding-left: 22px; max-width: 44ch; font: 500 15px/1.4 var(--ui); }
.film .sub { margin: 12px 0 0; max-width: 46ch; line-height: 1.45; }
@media (orientation: landscape) and (max-height: 560px) {
  .film { grid-template-columns: auto 1fr; }
  .film video { width: auto; height: calc(100vh - 128px - var(--pad-t) - var(--pad-b)); height: calc(100dvh - 128px - var(--pad-t) - var(--pad-b)); }
}

/* ---------- How to play demos: a cropped piece of the table, drawn finished; demo.js plays each one once ---------- */
.demo { margin: 12px 0 6px; max-width: 372px; } /* sized to what it shows: no empty half on a wide sheet */
.stage { position: relative; height: 168px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(60% 80% at 62% 108%, var(--l2), transparent 70%), var(--ground); }
/* In the turn demo her rack runs well off the left edge: only a tile the story does not touch is cut, and by most of
   its width, so it reads as a crop and not a near miss. The call demo keeps its short rack whole, a gutter each side. */
.drack { position: absolute; left: -27px; bottom: 12px; display: flex; align-items: flex-end; gap: 4px; }
.drack .t { --tw: 38px; }
.drack .dslot { flex: none; width: 38px; height: 51px; margin-left: 12px; } /* where a drawn tile waits, set apart */
/* The discards sit up and to the left of where she lets go, so a thrown tile comes in from the open side and crosses nothing. */
.dpile { position: absolute; left: 38%; top: 18px; display: flex; gap: 1px; }
.stage[data-demo="call"] .dpile { left: 46%; top: 14px; }
.dpile .t { --tw: 22px; }
.dpile .dslot { flex: none; width: 22px; height: 30px; }
.stage .dold, .stage .dcalled { outline: 2px solid rgba(242, 182, 90, 0); outline-offset: 1px; }
.stage .dnew, .stage .dcalled, .stage .dmine { z-index: 2; }
.stage .dnew, .stage .dcalled, .stage .dmine, .dbar { will-change: transform; } /* a lasting layer: the numeral never hops as a tile lands */
.stage[data-demo="call"] .drack { left: 12px; }
.dexp { flex: none; display: flex; align-items: flex-end; gap: 2px; width: 84px; } /* as wide as the two rack tiles it replaces and their gap, so nothing else moves */
.dexp .t { --tw: 24px; }
.dseat { position: absolute; left: 12px; top: 10px; display: flex; align-items: center; gap: 8px; font: 600 17px/1 var(--display); }
/* The call prompt sits where the coach bar does: between the discards and her rack, buttons at the right thumb. */
.dbar { position: absolute; right: 12px; bottom: 78px; display: flex; align-items: center; gap: 8px; opacity: 0; font: 500 13px/1.2 var(--ui); color: var(--ink); }
.dbar span { margin-right: 4px; }
.dbar b { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--stroke); background: rgba(237, 231, 220, .04); font: 600 13px/1 var(--ui); }
/* The fingertip. Not there until it touches. */
.finger { position: absolute; left: 0; top: 0; z-index: 5; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; opacity: 0; pointer-events: none;
  background: rgba(86, 99, 92, .5); box-shadow: inset 0 0 0 1.5px rgba(237, 231, 220, .6); } /* reads on ivory and on the night ground alike */
.demo figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; color: var(--mute); font-size: 13px; }
.demo figcaption .btn { flex: none; min-height: 44px; padding: 0 12px; font-size: 14px; color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .demo figcaption .btn { display: none; } } /* nothing to replay: the finished frame is the demo */
