/* Deluxe Memory: the shared look for splash, phone and TV. A card table: deep green felt, cream
   cards with ruby backs, brass tokens. 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: #0b332f; --felt2: #104640; --felt3: #18594f; --line: #2f7a6e;
  --ink: #f6efdc; --dim: #a9c9bf; --card: #fbf5e2; --inkd: #1c1a17;
  --gold: #e7bd5b; --gold2: #b98a2c; --ruby: #c8324b; --ruby2: #8f1d33;
  --good: #7be3a4; --bad: #ff8a8a; --you: #8fd3ff;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #18594f 0%, #0b332f 62%); --cs-end-fg: #f6efdc; --cs-end-dim: #a9c9bf;
  --cs-end-accent: #e7bd5b; --cs-end-win: #e7bd5b; --cs-end-loss: #ff8a8a;
  --display: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); font: 500 16px/1.4 var(--body); background: var(--felt) radial-gradient(ellipse at 50% -10%, var(--felt3), var(--felt) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
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(--card); font-size: 20px; }
button { background: var(--felt3); border: 1.5px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--inkd); }
button:disabled { opacity: .45; 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(--card); color: var(--inkd);
  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(--ruby); 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: #0006; 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; }
.levers select { max-width: 62%; }

/* ---- shared pieces: the table of cards, a card face, a player chip, the chart ----
   The board fills the box around it (a size container) at a card's proportions, 5 by 7. Standing up it is
   7 across and 8 down; on its side (.land: the TV, a rig panel) the same layout is turned, 8 across and 7 down. */
.board { --cols: 7; --rows: 8; --w: min(100cqw, 100cqh * .625); width: var(--w); height: calc(var(--w) / .625);
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: calc(var(--w) / 110); font-size: calc(var(--w) / var(--cols) * .36); }
.board.land { --cols: 8; --rows: 7; --w: min(100cqw, 100cqh * .8163); height: calc(var(--w) / .8163); }
.cell { grid-row: calc(var(--r) + 1); grid-column: calc(var(--c) + 1); position: relative; min-width: 0; min-height: 0; padding: 0; border-radius: .28em;
  font: inherit; font-family: var(--display); line-height: 1; cursor: default; transition: transform .15s, box-shadow .15s, filter .15s; }
.board.land .cell { grid-row: calc(var(--c) + 1); grid-column: calc(var(--r) + 1); }
.cell.gone { background: none; border: 1px dashed #ffffff26; }
.cell.back { border: .09em solid var(--gold2); background: repeating-linear-gradient(45deg, var(--ruby2) 0 .2em, var(--ruby) .2em .4em); box-shadow: inset 0 0 0 .1em #0003; }
.cell.up { background: var(--card); border: .06em solid #c9bf9f; color: var(--inkd); }
.f { display: grid; justify-items: center; align-content: center; gap: .06em; height: 100%; line-height: 1; }
.f b { font-size: 1.12em; font-weight: 700; } .f i { font-style: normal; font-size: 1.06em; }
.f.red { color: var(--ruby); } .f.black { color: var(--inkd); }
.f.joker b { color: var(--gold2); } .f.joker i { font: 700 .42em var(--body); color: var(--inkd); }
.cell.fixed { box-shadow: 0 0 0 .1em var(--gold); }
.cell.peek { box-shadow: 0 0 0 .1em var(--you); }
.cell.picked { transform: translateY(-5%); box-shadow: 0 0 0 .1em var(--ink), 0 .2em .5em #000a; }
.cell.peek.picked { box-shadow: 0 0 0 .1em var(--you), 0 .2em .5em #000a; }
.cell.swapped { outline: .1em dashed var(--ink); outline-offset: .08em; }
.cell.sel { box-shadow: 0 0 0 .13em var(--good), 0 .2em .5em #000a; transform: translateY(-5%); }
.cell .eye, .cell .stamp { position: absolute; left: 0; right: 0; font: 800 .3em/1.5 var(--body); font-style: normal; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; }
.cell .eye { bottom: 0; background: var(--you); color: #06283d; border-radius: 0 0 .7em .7em; }
.cell .stamp { top: 0; background: var(--good); color: #06321b; border-radius: .7em .7em 0 0; }
.cell.peek .f { padding-bottom: .34em; } .cell.sel .f { padding-top: .2em; }

.seat { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 6px; min-width: 0; padding: 6px 8px; text-align: left;
  border-radius: 12px; background: #0005; border: 2px solid var(--line); color: var(--ink); cursor: default; }
.seat .s-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } 
.seat .s-tok { display: flex; align-items: center; gap: 4px; font: 700 1.35em/1 var(--display); color: var(--gold); }
.coin { width: .62em; height: .62em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3c4, var(--gold) 45%, var(--gold2)); box-shadow: 0 0 0 1px #0005; }
.seat .s-tags { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; min-height: 1.3em; }
.tag { font: 700 .68em/1.6 var(--body); font-style: normal; text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; border-radius: 99px; background: var(--felt3); color: var(--dim); white-space: nowrap; }
.tag.keep { background: var(--card); color: var(--inkd); }
.tag.you { background: var(--gold); color: var(--inkd); }
.seat.up { border-color: var(--gold); background: #e7bd5b1f; }
.seat.out { opacity: .5; }
.seat.can { cursor: pointer; border-style: dashed; border-color: var(--good); }
.seat.sel { border-style: solid; border-color: var(--good); background: #7be3a42b; }
.seat .ord { position: absolute; top: -9px; left: -7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--good); color: #06321b; font: 800 13px/1 var(--body); font-style: normal; }

.m-cards { display: inline-flex; gap: 4px; vertical-align: middle; margin-right: 8px; }
.m-cards .f { width: 2.1em; height: 2.9em; border-radius: .35em; background: var(--card); font-family: var(--display); }
.cell.gone.picked { transform: none; box-shadow: none; border: 1px dashed var(--ink); }
.chart { display: grid; gap: 4px; }
.ch-row { display: grid; grid-template-columns: 2.2em minmax(0, 1fr); gap: 8px; align-items: baseline; text-align: left; padding: 5px 8px; border-radius: 8px; background: #0004; border: 1.5px solid transparent; color: var(--ink); font-weight: 500; }
.ch-row b { font: 700 1.15em var(--display); color: var(--gold); text-align: center; }
.ch-row.live { border-color: var(--gold); background: #e7bd5b26; }
button.ch-row { cursor: pointer; border-color: var(--line); } button.ch-row.sel { border-color: var(--good); background: #7be3a42b; }

/* ---- 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-rows: auto auto auto auto minmax(0, 1fr) 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 { font: 700 18px var(--display); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.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 #e7bd5b55; } }
.chartbtn { flex: none; height: 40px; padding: 0 12px; font-size: 14px; }
#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.35; min-height: 74px; display: grid; align-content: center; gap: 5px; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-match { color: var(--ink); font-size: 13.5px; } .g-match .m-cards { font-size: 11px; }
.g-seats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; font-size: 13.5px; }
.g-table { container-type: size; display: grid; place-items: center; min-height: 0; min-width: 0; }
.g.mine .cell.can { cursor: pointer; }
.g.mine .cell:not(.can):not(.gone) { filter: brightness(.62); }
.g.mine .cell.gone.can { border: 2px dashed var(--good); }
.g-king { align-self: stretch; width: 100%; max-height: 100%; overflow-y: auto; font-size: 13.5px; }
.g-btns { display: grid; grid-template-columns: 1fr 2.2fr; gap: 8px; }
.g.one-btn .g-btns { grid-template-columns: 1fr; }
.g-btns button { min-height: 50px; padding: 6px 8px; font-size: 16px; line-height: 1.15; }
.g-sheet { position: fixed; inset: 0; z-index: 2200; background: #021210d9; display: grid; place-items: center; padding: 10px; }
.g-sheetin { width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; display: grid; gap: 8px; background: var(--felt2); border: 2px solid var(--gold); border-radius: 18px; padding: 14px; font-size: 14px; }
.g-sheetin p { margin: 0; }
/* the kit's pill sits above every layer: an open sheet hides it, so it never lands on the sheet's heading */
body:has(.g-sheet:not([hidden])) #cs-pill { visibility: hidden; }

/* The kit's pill (table-dock.ts: "Table", or "Sound") opens the sheet with what happened, and the phone's
   sound switches. Its own spot is the bottom right corner, which is where the big button lives, so 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: 60px; 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; }

/* A rig panel or a phone on its side: the cards on the left, turned to 8 across, and everything a player
   presses on the right. Nothing is below the fold, and the top centre stays clear for the launcher's strip. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); column-gap: 14px; padding: 8px 14px 10px; }
  .g-head { grid-column: 2; grid-row: 1; }
  #cs-pres-slot { grid-column: 2; grid-row: 2; }
  .g-coach { grid-column: 2; grid-row: 3; min-height: 64px; }
  .g-seats { grid-column: 2; grid-row: 4; grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .g-btns { grid-column: 2; grid-row: 5; align-self: end; }
  .g-table { grid-column: 1; grid-row: 1 / -1; }
  .g-table .board { --cols: 8; --rows: 7; --w: min(100cqw, 100cqh * .8163); height: calc(var(--w) / .8163); }
  .g-table .board .cell { grid-row: calc(var(--c) + 1); grid-column: calc(var(--r) + 1); }
  .g-head .g-title { display: none; }
  .g-head .g-pillgap { display: none; }
  body.phone #cs-pill { left: calc(14px + (100vw - 42px) * .5122 + 14px + 50px); top: 8px; }
  .g-head .chartbtn { margin-left: auto; }
  .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(2, 18, 16, .84); }
.cm-ring { fill: none; stroke: var(--gold); stroke-width: 2; }
.cm-ln { stroke: var(--card); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--gold); stroke: var(--inkd); 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: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15.5px/22px var(--display); color: var(--card); }
.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: #06211ef7; 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 h1 { font-size: clamp(36px, 7vw, 60px); }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--gold); color: var(--inkd); 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(--felt2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--gold); 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; }
.byline { color: var(--dim); margin: 4px 0 2px; } .byline a { white-space: nowrap; }
.hero .mark { width: 150px; height: auto; float: right; margin: 0 0 8px 16px; }
.helppage .chart { margin: 10px 0; } .helppage .ch-row { font-size: .98em; }
.helppage table.pairs { border-collapse: collapse; margin: 8px 0; } .helppage table.pairs td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.helppage table.pairs td:first-child { white-space: nowrap; font-weight: 800; color: var(--gold); }
@media (max-width: 520px) { .hero .mark { width: 96px; } }
