/* Loser's Game: the shared look for splash, phone and TV. A card table in a back room: bottle-green
   felt, cream score-sheet paper, pencil grey, and a red rubber stamp for the bids that missed. The
   cards are plain paper faces with big pips, red and near-black. No web fonts, no remote anything:
   the party rig is offline, so every asset is local (test/pages.test.ts fails on an external URL). */
:root {
  --felt: #10261d; --felt2: #163829; --felt3: #1e4a37; --rail: #2c5c47; --line: #3d6b56;
  --paper: #f4ecd6; --paper2: #e6dcc0; --pencil: #3a3833; --ink: #f4ecd6; --dim: #a9c0b2;
  --gold: #e2b33c; --gold2: #b98a1c; --stamp: #c8372d; --good: #7fd18b;
  --cred: #c0302a; --cblk: #1d1f22;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #1e4a37 0%, #10261d 62%); --cs-end-fg: #f4ecd6; --cs-end-dim: #a9c0b2;
  --cs-end-accent: #e2b33c; --cs-end-win: #e2b33c; --cs-end-loss: #c8372d; --cs-end-panel: #163829;
  --display: "Rockwell", "Roboto Slab", "DejaVu Serif", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cs-end-font: var(--body);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); font: 500 16px/1.4 var(--body); -webkit-tap-highlight-color: transparent;
  background: var(--felt) radial-gradient(ellipse at 50% 0%, var(--felt3), var(--felt) 72%) fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--gold); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--felt3); border: 1.5px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--gold); border-color: var(--gold); color: #231a05; }
button:disabled { opacity: .4; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--felt2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--gold); }
.muted, .hint, .tagg { color: var(--dim); }
.tagg { font-size: 13px; margin-left: 6px; }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(160px); background: var(--paper); color: var(--pencil);
  padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; max-width: 92vw; font-weight: 700; }
#toast.show { transform: translateX(-50%) translateY(0); }
#conn { position: fixed; top: 8px; right: 8px; background: var(--stamp); color: #fff; padding: 4px 10px; border-radius: 8px; font-size: 13px; display: none; z-index: 60; }
#conn.show { display: block; }

/* ---- kit phone shell: join + lobby ---- */
.join, .lobbyv { max-width: 480px; margin: 0 auto; padding: 24px 16px; display: grid; gap: 12px; }
.join input { font-size: 20px; padding: 12px; }
.join button, .lobbyv button { font-size: 17px; padding: 12px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnrow button { flex: 1 1 auto; }
.seat-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: #0004; border: 1px solid var(--line); border-radius: 10px; margin: 4px 0; }
.levers { display: grid; gap: 8px; }
.levers label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--dim); font-weight: 700; }

/* ---- shared pieces: a card, the trump badge, the counted hand ---- */
.pc { --cw: 46px; position: relative; display: inline-grid; grid-template-rows: auto 1fr; justify-items: start; width: var(--cw); height: calc(var(--cw) * 1.4);
  padding: 2px 0 0 4px; border-radius: calc(var(--cw) * .12); background: var(--paper); border: 1px solid #0005; box-shadow: 0 2px 4px #0006;
  font: 800 calc(var(--cw) * .42)/1 var(--body); color: var(--cblk); flex: none; overflow: hidden; }
.pc.red { color: var(--cred); }
.pc .c-r { letter-spacing: -.04em; }
.pc .c-s { align-self: end; justify-self: end; font-size: calc(var(--cw) * .62); line-height: .95; margin: 0 3px 2px 0; }
.pc.trump { background: linear-gradient(160deg, #fff7da, #f1dc9c); border-color: var(--gold2); }
.pc.mini { --cw: 26px; padding: 1px 0 0 2px; box-shadow: none; }
.pc.mini .c-s { margin: 0 2px 1px 0; }
button.pc { cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .12s; }
button.pc.dim { opacity: .38; filter: grayscale(.5); }
button.pc.can { box-shadow: 0 0 0 2px var(--good), 0 2px 4px #0006; }
button.pc.picked { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--gold), 0 8px 14px #000a; }
button.pc:disabled { opacity: 1; }

.tbadge { display: inline-flex; align-items: center; gap: 8px; }
.tbadge b { display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--paper); color: var(--cblk); font: 800 22px/1 var(--body); border: 2px solid var(--gold); }
.tbadge.red b { color: var(--cred); }
.tbadge.none b { color: var(--dim); background: var(--felt2); border-color: var(--line); }
.tbadge i { font-style: normal; font-weight: 700; color: var(--gold); }
.tbadge.none i { color: var(--dim); }
.callr { font-style: normal; color: var(--cblk); background: var(--paper); border-radius: 4px; padding: 0 3px; margin-right: 3px; font-size: .9em; }
.callr.red { color: var(--cred); }

table.tally { width: 100%; border-collapse: collapse; background: var(--paper); color: var(--pencil); border-radius: 8px; overflow: hidden; font-size: 14px; }
table.tally th { font-weight: 700; font-size: .8em; text-transform: uppercase; letter-spacing: .06em; color: #6d6a5f; padding: 4px 6px; text-align: center; border-bottom: 1px solid #c9bd9b; }
table.tally td { padding: 4px 6px; text-align: center; border-bottom: 1px dashed #d8cdae; }
table.tally td.t-n { text-align: left; font-weight: 700; white-space: nowrap; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
table.tally td small { display: block; font-size: .72em; color: #6d6a5f; }
table.tally tr.me td.t-n { text-decoration: underline; text-decoration-color: var(--gold2); text-decoration-thickness: 2px; }
table.tally td.t-d { font-weight: 800; color: #2f7a3c; }
table.tally tr.miss td.t-d { color: var(--stamp); }
table.tally tr.miss td.t-d::after { content: ' missed'; font-size: .7em; font-weight: 700; text-transform: uppercase; }
table.tally td.t-t { font: 800 1.1em var(--display); }
table.tally .callr { background: none; padding: 0; }

/* ---- the phone: a fixed skeleton that never scrolls the page (the rig's panels are 960x540 with
   no scrollbar: a control below the fold there is not a control) ---- */
.g { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; overflow: hidden; }
.g-head { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.g-title { min-width: 0; font: 700 17px var(--display); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-round { margin-left: auto; white-space: nowrap; color: var(--dim); font-size: 13.5px; font-weight: 700; } .g-round b { color: var(--paper); font-size: 1.2em; }
.help { flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 20px; }
.help.pulse { animation: helppulse 1.6s ease-in-out infinite; border-color: var(--gold); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #e2b33c55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--felt2); border-left: 4px solid var(--gold); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 14.5px; line-height: 1.33; min-height: 54px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }

.g-seats { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 5px; }
.seat { display: grid; justify-items: center; gap: 1px; padding: 4px 2px 5px; border-radius: 10px; background: #0003; border: 1.5px solid var(--line); min-width: 0; }
.seat.up { border-color: var(--gold); background: #e2b33c22; }
.seat.me .s-n { color: var(--gold); }
.seat .s-n { font-size: 12.5px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .s-sc { font: 800 21px/1.05 var(--display); color: var(--paper); }
.seat .s-bt { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.s-pile, .t-pile { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; color: var(--paper); }
.s-pile i, .t-pile i { display: inline-block; width: 9px; height: 12px; border-radius: 2px; background: repeating-linear-gradient(45deg, var(--stamp) 0 2px, #8f241e 2px 4px); border: 1px solid var(--paper2); }

.g-table { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px; background: radial-gradient(ellipse at 50% 40%, var(--felt3), var(--felt2) 75%);
  border: 2px solid var(--rail); border-radius: 18px; padding: 8px 10px; overflow: hidden; }
.tb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tb-n { color: var(--dim); font-size: 13px; font-weight: 700; }
.trick { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; min-height: 0; }
.trick .play { display: grid; justify-items: center; gap: 2px; }
.trick .play .pc { --cw: 60px; }
.trick .play .who { font-size: 11.5px; color: var(--dim); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trick .play.win .pc { box-shadow: 0 0 0 3px var(--gold), 0 0 16px #e2b33caa; }
.trick .play.win .who { color: var(--gold); font-weight: 800; }
.trick .empty { color: var(--dim); font-style: italic; }
.aside { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--dim); flex-wrap: wrap; }
.aside span { margin-right: 4px; }
.tally-wrap { grid-row: 1 / -1; display: grid; align-content: center; gap: 6px; min-height: 0; overflow: hidden; }
.t-cap { text-align: center; color: var(--paper); font-weight: 700; font-size: 14px; }

.g-act { min-height: 48px; display: grid; align-items: center; }
.g-act .wide { width: 100%; min-height: 48px; font-size: 16px; }
.g-act .wait { text-align: center; color: var(--dim); font-size: 14px; } .g-act .wait b { color: var(--paper); }
.suits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.suit { display: grid; justify-items: center; padding: 4px 2px 6px; background: var(--paper); color: var(--cblk); border-color: var(--gold2); font-size: 13px; }
.suit b { font-size: 26px; line-height: 1.05; }
.suit.red { color: var(--cred); }
.bid { display: grid; grid-template-columns: 52px 1fr 52px 1.5fr; gap: 6px; align-items: center; }
.bid button { min-height: 48px; font-size: 22px; padding: 0; }
.bid #g-bid { font-size: 17px; }
.bid-n { display: grid; justify-items: center; line-height: 1; } .bid-n b { font: 800 28px var(--display); color: var(--paper); } .bid-n small { color: var(--dim); font-size: 11px; margin-top: 2px; }

.g-hand { --gap: 4px; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 12px var(--gap); min-height: 70px; padding-top: 10px; }
.g-hand .pc { --cw: min(48px, calc((100vw - 20px - 8 * var(--gap)) / 9)); }
.g-none { color: var(--dim); }

/* The kit's pill (table-dock.ts: "Table", or "Sound") opens the sheet with what happened, and the phone's
   sound switches. It is moved up beside "?" and the header keeps a gap for it (.g-pillgap). Off the top
   centre and the top right: the rig's launcher owns those on a panel. */
body.phone #cs-pill { top: max(8px, env(safe-area-inset-top)); bottom: auto; left: 58px; right: auto; height: 40px; width: 96px; padding: 0 6px;
  font-size: 13.5px; white-space: nowrap; text-align: center; }
.g-pillgap { flex: none; width: 96px; }
@media (max-width: 420px) { .g-title { font-size: 15px; } }

/* A rig panel or a phone on its side: use the width. The table left, your hand right. Nothing a player
   presses is below the fold, and the top centre stays clear for the launcher's own strip. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); column-gap: 14px; padding: 8px 14px 10px; }
  .g-head, .g-coach, #cs-pres-slot { grid-column: 1 / -1; }
  .g-seats { grid-column: 1; grid-row: 4; }
  .g-table { grid-column: 1; grid-row: 5; }
  .g-act { grid-column: 2; grid-row: 4; }
  .g-hand { grid-column: 2; grid-row: 5; align-content: start; }
  .g-hand .pc { --cw: min(46px, calc((50vw - 30px - 8 * var(--gap)) / 9)); }
  body.phone #cs-pill { left: 62px; top: 8px; }
  .g-head .g-title { max-width: 190px; }
  .g-coach { min-height: 42px; }
  .lobbyv { max-width: 900px; grid-template-columns: 1fr 1fr; align-items: start; padding: 44px 16px 10px; gap: 8px 16px; }
  .lobbyv h1 { grid-column: 1 / -1; font-size: 26px; }
  .lobbyv > div:nth-child(2) { grid-row: span 4; }
  .join { padding-top: 44px; }
}

/* ---- coach marks (table/client/coach.ts draws them; these are its classes) ---- */
.coach { position: fixed; inset: 0; z-index: 2300; color: var(--ink); -webkit-user-select: none; user-select: none; animation: cmin .18s ease-out; }
@keyframes cmin { from { opacity: 0; } to { opacity: 1; } }
.cm-svg { position: absolute; inset: 0; display: block; }
.cm-dim { fill: rgba(5, 14, 10, .84); }
.cm-ring { fill: none; stroke: var(--gold); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--gold); stroke: #231a05; stroke-width: 1.5; }
.cm-call { position: absolute; padding: 9px 12px 10px; border-radius: 14px; font-size: 14.5px; line-height: 1.33; background: var(--felt2); border: 1.5px solid var(--gold); box-shadow: 0 10px 28px #000a; }
.cm-call .cm-n { float: left; width: 22px; height: 22px; margin: 0 8px 0 0; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #231a05; font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15.5px/22px var(--display); color: var(--paper); }
.cm-call .cm-b { margin-top: 3px; clear: both; } .cm-call .cm-b b { color: #fff; }
.cm-measure { visibility: hidden; left: -9999px; top: 0; pointer-events: none; }
.cm-none { text-align: center; }
.cm-pager { position: absolute; display: flex; align-items: center; gap: 8px; padding: 7px; border-radius: 16px; background: #0b1c15f7; border: 1px solid var(--line); box-shadow: 0 8px 26px #000a; }
.cm-pager button { min-height: 44px; padding: 0 16px; font-size: 16px; border-radius: 12px; }
.cm-pager .cm-close { width: 44px; padding: 0; font-size: 26px; line-height: 1; border-radius: 50%; flex: none; }
.cm-pager .cm-count { flex: 1; text-align: center; color: var(--dim); font-weight: 700; white-space: nowrap; }
.cm-last { position: absolute; left: 8px; right: 8px; display: flex; overflow: auto; overscroll-behavior: contain; }
.cm-lastin { margin: auto; width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto; padding: 14px 16px 16px; border-radius: 18px; border: 2px solid var(--gold); background: var(--felt2); font-size: 15px; line-height: 1.4; -webkit-user-select: text; user-select: text; }
.cm-lastin .cm-kick { text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--gold); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 22px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.cm-lastin ul { margin: 0; padding-left: 1.2em; } .cm-lastin li { margin: 0 0 6px; } .cm-lastin b { color: #fff; }

/* ---- splash + help ---- */
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 18px 60px; }
.hero { display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: center; }
.hero > :not(.mark) { grid-column: 2; }
.hero .mark { grid-row: 1 / span 5; width: 130px; height: 170px; }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } .hero > :not(.mark) { grid-column: 1; } .hero .mark { grid-row: auto; width: 90px; height: 118px; } }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.credit { color: var(--paper); } .credit a { color: var(--gold); }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 12px; background: var(--gold); color: #231a05; font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--felt3); color: var(--ink); border: 1.5px solid var(--line); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 26px; }
.how div { background: var(--paper); color: var(--pencil); border-radius: 6px; padding: 12px 14px; box-shadow: 0 3px 10px #0006; } .how h3 { color: var(--stamp); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--felt2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--gold); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--felt2); border-left: 4px solid var(--gold); border-radius: 8px; padding: 12px 16px; margin-top: 18px; } #rejoin.show { display: block; }
footer { margin-top: 40px; color: var(--dim); font-size: .9em; }
.helppage h2 { margin: 26px 0 6px; } .helppage li { margin-bottom: 6px; } .helppage .back { text-decoration: none; font-weight: 700; }
.helppage figure { margin: 22px 0; } .helppage figure img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); display: block; }
.helppage figure.phone img { max-width: 300px; margin: 0 auto; }
.helppage figcaption { color: var(--dim); margin-top: 8px; font-size: .95em; }
.helppage table.pts { border-collapse: collapse; background: var(--paper); color: var(--pencil); border-radius: 6px; overflow: hidden; }
.helppage table.pts td { padding: 6px 12px; border-bottom: 1px dashed #c9bd9b; } .helppage table.pts td:last-child { font-weight: 800; text-align: right; }
