/* Pass The Ewe: the shared look for splash, phone and TV. A meadow at dusk: deep grass green, cream
   wool, a black-faced ewe, cards in their own suit colours (royals in purple, as on Jonathan's
   reference sheet). 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 {
  --meadow: #1f3d1c; --meadow2: #2a5126; --meadow3: #386a30; --line: #4f8443; --grass: #8bcf55; --grass2: #6ab42e;
  --wool: #fbf6e4; --woolshade: #d8ceab; --ink: #fbf6e4; --dim: #b9cfa8; --inkd: #24211c; --soot: #2a2622;
  --s-H: #d22d3a; --s-D: #e0661a; --s-C: #1f5a33; --s-S: #22305a; --s-R: #7a3db8; --s-W: #c48a12;
  --good: #8bcf55; --bad: #ff8a7a; --gold: #f2c94c;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #386a30 0%, #1f3d1c 62%); --cs-end-fg: #fbf6e4; --cs-end-dim: #b9cfa8;
  --cs-end-accent: #f2c94c; --cs-end-win: #f2c94c; --cs-end-loss: #b9cfa8;
  --display: "Trebuchet MS", "Avenir Next", Futura, "Gill Sans", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); font: 500 16px/1.4 var(--body); background: var(--meadow) radial-gradient(ellipse at 50% -10%, var(--meadow3), var(--meadow) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--wool); font-size: 34px; line-height: 1.1; }
h2 { color: var(--wool); font-size: 20px; }
button { background: var(--meadow2); 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(--wool); border-color: var(--wool); color: var(--inkd); }
button:disabled { opacity: .4; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--meadow2); 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(--wool); 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(--bad); 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: #0005; 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: suit marks, cards, plays, the wheel, the ewe, the score table ---- */
.sm { width: 1em; height: 1em; vertical-align: -.12em; fill: currentColor; flex: none; }
.sm.s-H, .s-H { color: var(--s-H); fill: var(--s-H); } .sm.s-D, .s-D { color: var(--s-D); fill: var(--s-D); }
.sm.s-C, .s-C { color: var(--s-C); fill: var(--s-C); } .sm.s-S, .s-S { color: var(--s-S); fill: var(--s-S); }
.sm.s-R, .s-R { color: var(--s-R); fill: var(--s-R); } .sm.s-W, .s-W { color: var(--s-W); fill: var(--s-W); }
.set { display: inline-flex; align-items: center; gap: .25em; white-space: nowrap; }
.set .sm { background: var(--wool); border-radius: .3em; padding: .08em; width: 1.15em; height: 1.15em; }
.set b { font-size: 1.1em; }

.cd { position: relative; display: inline-grid; place-items: center; align-content: center; gap: .05em; width: 2.1em; height: 2.9em; border-radius: .32em;
  background: var(--wool); border: .08em solid var(--woolshade); color: var(--inkd); box-shadow: 0 .12em .3em #0006; font: 800 1em/1 var(--display); }
.cd b { font-size: .95em; } .cd .sm { width: 1em; height: 1em; }
.cd.royal { background: linear-gradient(160deg, #f3e9ff, var(--wool) 60%); border-color: #b89ad8; }
.cd.royal .crown { position: absolute; top: -.45em; right: -.35em; width: .95em; height: .95em; background: var(--wool); border-radius: 50%; padding: .08em; box-shadow: 0 0 0 .06em #b89ad8; }
.cd.wild { box-shadow: 0 0 0 .12em var(--s-W), 0 .12em .3em #0006; }

.play { display: flex; align-items: center; flex-wrap: wrap; gap: .3em .5em; }
.play .pl-who { font-weight: 800; color: var(--dim); }
.play .pl-wild { font-size: .8em; font-weight: 800; color: var(--s-W); background: var(--wool); border-radius: 99px; padding: 0 .5em; }
.play .pl-cards { display: flex; flex-wrap: wrap; gap: .2em; width: 100%; }
.play.big .pl-who { color: var(--ink); }

.wheel { display: block; aspect-ratio: 1; }
.wheel .ring line { stroke: var(--line); stroke-width: 2.4; stroke-linecap: round; }
.wheel line.hot { stroke: var(--grass); stroke-width: 2.4; stroke-dasharray: 3 2.5; }
.wheel .wn circle { fill: var(--wool); stroke: var(--woolshade); stroke-width: 1.4; }
.wheel .wn.top circle { stroke: var(--gold); stroke-width: 3.4; }
.wheel .wn.beat circle { stroke: var(--grass); stroke-width: 3.4; }
.wheel .wn.off { opacity: .45; }

.ewe { display: block; width: 4em; height: auto; overflow: visible; }
.ewe .ewe-legs, .ewe .ewe-head { fill: var(--soot); }
.ewe .ewe-wool circle { fill: var(--wool); stroke: var(--woolshade); stroke-width: 2; }
.ewe .ewe-body, .ewe .ewe-tuft { fill: var(--wool); }
.ewe .ewe-eye { fill: #fff; } .ewe .ewe-pupil { fill: #14201a; } .ewe .ewe-blush { fill: #f19a9a; opacity: .7; }
.ewe.tiny { display: inline-block; width: 1.45em; vertical-align: -.2em; margin-right: .2em; }
.ewe.hop { animation: hop .9s ease-out 1; }
@keyframes hop { 0% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-28%) rotate(-6deg); } 55% { transform: translateY(0) rotate(0); } 72% { transform: translateY(-10%); } 100% { transform: translateY(0); } }

.scores { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.scores caption { font: 700 1.1em var(--display); color: var(--gold); text-align: left; padding-bottom: .3em; }
.scores th, .scores td { padding: .2em .45em; text-align: center; border-bottom: 1px solid #ffffff1a; white-space: nowrap; }
.scores thead th { font-size: .78em; color: var(--dim); font-weight: 700; }
.scores tbody th { text-align: left; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.scores .gain { font-weight: 800; color: var(--grass); } .scores .tot { font-weight: 800; color: var(--gold); font-size: 1.1em; }
.scores tr.has-ewe th { color: var(--gold); }
.mc { display: inline-block; width: .7em; height: .95em; border-radius: .15em; background: repeating-linear-gradient(45deg, var(--meadow3) 0 .12em, var(--line) .12em .24em); border: .08em solid var(--wool); vertical-align: -.1em; margin-right: .2em; }
.wool { display: inline-block; width: 1em; height: .8em; border-radius: 50%; background: radial-gradient(circle at 30% 40%, var(--wool) 30%, var(--woolshade)); vertical-align: -.05em; margin-right: .25em; }

/* ---- 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-areas: "head" "pres" "table" "seats" "coach" "mine";
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; overflow: hidden; }
.g-head { grid-area: head; display: flex; align-items: center; gap: 10px; min-height: 40px; }
.g-title { font: 700 18px var(--display); color: var(--wool); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-score { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 700; font-size: 14px; } .g-score b { color: var(--gold); font-size: 1.35em; }
.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 #f2c94c55; } }
#cs-pres-slot { grid-area: pres; display: flex; justify-content: center; min-height: 0; }

.g-table { grid-area: table; min-height: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: auto auto; gap: 8px 12px;
  align-content: center; background: #00000026; border-radius: 16px; padding: 10px; overflow: hidden; }
.g-table .wheel { width: 104px; align-self: start; }
.g-tobeat { min-width: 0; display: grid; gap: 6px; align-content: start; }
.g-k { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.g-tobeat .play.big { font-size: 17px; } .g-tobeat .cd { font-size: 15px; }
.g-need { font-size: 13px; color: var(--grass); font-weight: 700; }
.g-need::before { content: "beaten by "; color: var(--dim); font-weight: 600; }
.g-lead { font: 700 20px var(--display); }
.g-side { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.g-stake { font-weight: 700; color: var(--dim); } .g-stake b { font: 800 26px var(--display); color: var(--wool); margin-right: 6px; }
.g-ewe { display: flex; align-items: center; gap: 8px; color: var(--dim); font-weight: 700; font-size: 14px; }
.g-ewe .ewe { width: 54px; }
.g-ewe.mine { color: var(--gold); font-size: 16px; } .g-ewe.mine .ewe { width: 72px; } .g-ewe.mine b { color: var(--gold); }
.g-table.round { display: block; overflow: auto; }
.g-round { font-size: 14px; }

.g-seats { grid-area: seats; display: grid; grid-template-columns: repeat(auto-fit, minmax(98px, 1fr)); gap: 6px; }
.g-seat { min-width: 0; background: #00000033; border: 1.5px solid transparent; border-radius: 10px; padding: 4px 7px; font-size: 13px; line-height: 1.25; }
.g-seat.up { border-color: var(--gold); background: #f2c94c1f; }
.g-seat.me .gs-name { color: var(--gold); }
.gs-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-nums { display: flex; justify-content: space-between; align-items: baseline; } .gs-nums b { font-size: 16px; }
.gs-cards { color: var(--dim); font-weight: 700; }
.gs-tag { color: var(--dim); font-size: 12px; font-weight: 700; }
.g-seat.t-passed .gs-tag { color: #ffffff80; } .g-seat.t-ontop .gs-tag { color: var(--gold); } .g-seat.up .gs-tag { color: var(--gold); }

.g-coach { grid-area: coach; background: var(--meadow2); border-left: 4px solid var(--gold); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 15px; line-height: 1.35; min-height: 58px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-mine { grid-area: mine; display: grid; gap: 8px; }
.g-hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.g.wildrow .g-hand, .g-hand:has(> :nth-child(6)) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stack { min-width: 0; display: grid; justify-items: center; align-content: start; gap: 2px; padding: 7px 3px 6px; border-radius: 12px; height: 96px;
  background: var(--meadow2); border: 2px solid var(--line); color: var(--ink); transition: transform .12s, box-shadow .12s; }
.stack .sm { width: 26px; height: 26px; background: var(--wool); border-radius: 7px; padding: 2px; }
.stack .st-n { font: 800 22px/1 var(--display); }
.stack .st-r { font-size: 10.5px; line-height: 1.25; color: var(--dim); text-align: center; overflow: hidden; max-height: 2.5em; word-break: break-word; }
.stack .st-r .sm { width: 11px; height: 11px; padding: 1px; background: var(--wool); border-radius: 3px; vertical-align: -1px; }
.stack.none { opacity: .45; }
.stack:disabled { opacity: 1; } .stack.none:disabled { opacity: .45; }
.g.mine .stack.can { background: var(--wool); color: var(--inkd); border-color: var(--grass); }
.g.mine .stack.can .st-r { color: #5d564a; }
.g.mine .stack:not(.can) { opacity: .5; }
.stack.picked { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--gold), 0 8px 18px #0008; }
.g-wildrow { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; color: var(--dim); font-weight: 700; }
.g-wildrow[hidden] { display: none; }
.g-wildrow button { width: 40px; height: 36px; padding: 0; } .g-wildrow b { min-width: 1.4em; text-align: center; font-size: 18px; color: var(--ink); }
.g-btns { display: grid; grid-template-columns: 1fr auto 1.7fr; gap: 8px; align-items: stretch; }
.g-btns > button { min-height: 50px; padding: 6px 8px; font-size: 16px; line-height: 1.15; }
.g-btns #g-play .set .sm { width: 1.2em; height: 1.2em; }
.g-step { display: flex; align-items: center; gap: 4px; }
.g-step button { width: 40px; height: 50px; padding: 0; font-size: 22px; }
.g-step b { min-width: 1.6em; text-align: center; font: 800 22px var(--display); }

/* 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 Play 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; }
@media (max-width: 380px) { .g-title { display: none; } }

/* A rig panel or a phone on its side: use the width. The table and the players left, your hand right.
   Nothing a player presses 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: 1fr 1fr; grid-template-areas: "head head" "pres pres" "table coach" "table mine" "seats mine";
    grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 16px; padding: 8px 16px 10px; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-head .g-title { max-width: 190px; }
  .g-table { align-content: start; }
  .g-coach { min-height: 48px; }
  .g-mine { align-content: end; }
  .stack { height: 104px; }
  .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(8, 18, 8, .84); }
.cm-ring { fill: none; stroke: var(--gold); stroke-width: 2; }
.cm-ln { stroke: var(--wool); 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(--meadow2); 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(--wool); }
.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: #10220ff7; 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(--meadow2); 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(.hero-ewe) { grid-column: 2; }
.hero-ewe { grid-row: 1 / span 5; width: clamp(110px, 22vw, 190px); }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } .hero > :not(.hero-ewe) { grid-column: 1; } .hero-ewe { grid-row: auto; width: 120px; } }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.credit { color: var(--wool); font-weight: 700; } .credit a { color: var(--gold); }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--wool); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--meadow2); 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(--meadow2); 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(--meadow2); 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(--meadow2); 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 .wheelbox { display: flex; align-items: center; gap: 18px; background: var(--meadow2); border-radius: 14px; padding: 12px 16px; }
.helppage .wheelbox .wheel { width: 150px; flex: none; }
.helppage table.ex { border-collapse: collapse; } .helppage table.ex td { padding: 3px 10px 3px 0; vertical-align: top; }
