/* Catch A Dragon By The Tail: the shared look for splash, phone and TV. A dragon market at dusk: deep jade,
   parchment eggs, temple gold and vermilion. The six dragon colours are the rules' own (green 1 ... red 6).
   No web fonts, no remote anything: the party rig is offline (test/pages.test.ts fails on an external URL). */
:root {
  --night: #10231f; --night2: #17322c; --night3: #214239; --line: #3a5f53;
  --ink: #f6ecd2; --dim: #b3c6b6; --paper: #f6ecd2; --inkd: #2a1a0e;
  --gold: #e5b53a; --gold2: #b8861b; --verm: #d8432e; --verm2: #a92f1f;
  --good: #7bd389; --bad: #ef6a52;
  --f1: #3e9a4a; --f2: #8d9096; --f3: #8a5a2f; --f4: #c9a227; --f5: #2f6fc0; --f6: #cf3a2c;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #214239 0%, #10231f 62%); --cs-end-fg: #f6ecd2; --cs-end-dim: #b3c6b6;
  --cs-end-accent: #e5b53a; --cs-end-win: #e5b53a; --cs-end-loss: #d8432e;
  --display: Georgia, "Times New Roman", 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(--night) radial-gradient(ellipse at 50% -10%, var(--night3), var(--night) 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(--paper); font-size: 20px; }
button { background: var(--night3); 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(--verm); border-color: var(--verm); color: #fff; }
button:disabled { opacity: .38; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--night2); 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(--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: #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; }

/* ---- shared pieces: an egg, the ring, the fame chips ---- */
.f1 { --c: var(--f1); } .f2 { --c: var(--f2); } .f3 { --c: var(--f3); } .f4 { --c: var(--f4); } .f5 { --c: var(--f5); } .f6 { --c: var(--f6); }
.eggs { display: flex; justify-content: center; align-items: flex-end; gap: calc(var(--egg) * .12); min-height: calc(var(--egg) * 1.25); padding-top: calc(var(--egg) * .16); }
.egg { --egg: 72px; position: relative; flex: none; display: inline-grid; place-items: center; width: var(--egg); height: calc(var(--egg) * 1.22);
  transition: transform .14s, opacity .2s, filter .2s; -webkit-user-select: none; user-select: none; }
.eggs .egg { --egg: inherit; }
.egg .e-shell { position: absolute; inset: 0; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 36% 28%, #fffdf6 0 8%, #f3e6c6 40%, #d8c18e 100%); border: calc(var(--egg) * .045) solid var(--c, #c9b68a);
  box-shadow: inset 0 calc(var(--egg) * -.06) calc(var(--egg) * .12) #0002, 0 calc(var(--egg) * .05) calc(var(--egg) * .12) #0007; }
.egg img { position: relative; width: 84%; margin-top: 8%; pointer-events: none; }
.egg .e-num { position: absolute; right: 2%; bottom: 4%; width: calc(var(--egg) * .3); height: calc(var(--egg) * .3); border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #fff; font: 800 calc(var(--egg) * .19)/1 var(--body); border: calc(var(--egg) * .025) solid #fff8; }
.egg.blank .e-shell { background: radial-gradient(circle at 30% 40%, #a08a5c 0 2.5%, transparent 3%), radial-gradient(circle at 62% 30%, #a08a5c 0 2%, transparent 2.5%),
  radial-gradient(circle at 55% 66%, #a08a5c 0 3%, transparent 3.5%), radial-gradient(circle at 36% 74%, #a08a5c 0 1.8%, transparent 2.3%),
  radial-gradient(circle at 36% 28%, #fffdf6 0 6%, #eadcb6 45%, #c3ad7c 100%); border-color: #c9b68a; opacity: .9; }
.egg.link .e-shell { box-shadow: 0 0 0 calc(var(--egg) * .05) var(--gold), 0 0 calc(var(--egg) * .25) var(--gold2), inset 0 -4px 8px #0002; }
.egg.can { cursor: pointer; }
.egg.can .e-shell { box-shadow: 0 0 0 calc(var(--egg) * .05) var(--gold), 0 0 calc(var(--egg) * .22) #e5b53aaa; }
.egg.dim { opacity: .32; filter: saturate(.4); }
.egg.picked { transform: translateY(calc(var(--egg) * -.14)); }
.egg.picked .e-shell { box-shadow: 0 0 0 calc(var(--egg) * .06) var(--good), 0 calc(var(--egg) * .14) calc(var(--egg) * .2) #000a; }
.egg.busted { filter: grayscale(.85) brightness(.8); animation: bustshake .5s ease-in-out 1; }
.egg.busted::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--bad); font: 900 calc(var(--egg) * .7)/1 var(--body); text-shadow: 0 0 6px #000; }
.egg.tumble { animation: tumble .32s linear infinite; }
.egg.land { animation: land .5s cubic-bezier(.3, 1.6, .5, 1) 1; }
@keyframes tumble { 0% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-14%) rotate(-14deg); } 50% { transform: translateY(0) rotate(0); } 75% { transform: translateY(-9%) rotate(12deg); } 100% { transform: translateY(0) rotate(0); } }
@keyframes land { 0% { transform: translateY(-18%) scale(1.06); } 100% { transform: none; } }
@keyframes bustshake { 20%, 60% { transform: translateX(-6%); } 40%, 80% { transform: translateX(6%); } }
.b-none { color: var(--dim); font-style: italic; align-self: center; }

.ring { display: flex; justify-content: center; }
.r-row { display: inline-flex; align-items: center; }
.r-dot { --d: 22px; width: var(--d); height: var(--d); border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff;
  font: 800 calc(var(--d) * .55)/1 var(--body); opacity: .4; border: 2px solid transparent; }
.r-dot.on { opacity: 1; border-color: #fff9; }
.r-dot.ghost { opacity: .22; border: 2px dashed #fff8; } .r-dot.ghost.on { opacity: .5; }
.r-link { width: calc(var(--d, 22px) * .6); height: 3px; background: #ffffff26; border-radius: 2px; }
.r-link.on { background: var(--gold); box-shadow: 0 0 6px var(--gold); }

.fame { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.fm { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: #0004; border: 1.5px solid var(--line); font-size: 14px; white-space: nowrap; }
.fm.up { border-color: var(--gold); background: #e5b53a22; }
.fm.win { border-color: var(--good); }
.fm .fm-n { color: var(--gold); font: 700 17px/1 var(--display); }
.fm .bot, .fm .off { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; padding: 1px 5px; border-radius: 99px; background: var(--night3); color: var(--dim); margin-right: 4px; vertical-align: middle; }
.rd { color: var(--dim); font-weight: 700; white-space: nowrap; } .rd b { color: var(--gold); } .rd.tie { color: var(--verm); }
.bust { color: var(--bad); font-weight: 800; }

/* ---- 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; 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 { 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; }
.g-round { margin-left: auto; white-space: nowrap; font-size: 14px; }
.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 #e5b53a55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--night2); border-left: 4px solid var(--gold); border-radius: 6px 12px 12px 6px; padding: 9px 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-table { --egg: min(19vw, 96px, 12.5vh); display: grid; grid-template-rows: auto auto auto auto; align-content: center; gap: 10px; min-height: 0;
  background: radial-gradient(ellipse at 50% 40%, #2a4f45 0%, #17322c 70%); border: 1.5px solid var(--line); border-radius: 18px; padding: 10px 8px; }
.g-who { text-align: center; font: 700 16px var(--display); color: var(--paper); }
.g:not(.mine) .g-who { color: var(--dim); }
.g-label { text-align: center; color: var(--dim); font-size: 13px; font-weight: 700; margin-bottom: 4px; } .g-label b { color: var(--gold); font-size: 1.15em; }
.g-batch .eggs { min-height: calc(var(--egg) * .9); }
.g-batch .eggs .egg { --egg: min(16vw, 72px, 9.5vh); }
.g-ring { margin-top: 4px; }
.g-btns { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr; gap: 8px; }
.g-btns button { min-height: 52px; padding: 6px 8px; font-size: 16px; line-height: 1.15; }
.g-btns .undo { font-size: 13px; }
.g-btns #g-stop:not(:disabled) { background: var(--gold); border-color: var(--gold); color: var(--inkd); }

/* The kit's pill (table-dock.ts) opens the sheet with what happened, and the phone's sound switches. Its own
   spot is the bottom right corner, where Stop lives, so it moves up beside "?" and the header keeps a gap. */
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 table left, the scores and buttons 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, 1.25fr) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 16px; padding: 8px 16px 10px; }
  .g-head { grid-column: 1 / -1; }
  .g-table { grid-column: 1; grid-row: 2 / -1; --egg: min(10vw, 92px, 17vh); }
  .g-batch .eggs .egg { --egg: min(7.5vw, 66px, 12vh); }
  .g-fame, #cs-pres-slot, .g-coach, .g-btns { grid-column: 2; }
  .g-fame { grid-row: 2; align-self: start; } #cs-pres-slot { grid-row: 3; } .g-coach { grid-row: 4; align-self: start; } .g-btns { grid-row: 5; }
  .g-table { gap: 6px; } .ring { margin-top: 6px; }
  .g-btns { grid-template-columns: 1fr 1fr; align-self: end; } .g-btns .undo { grid-column: 1 / -1; order: 3; min-height: 44px; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-head .g-title { max-width: 220px; }
  .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(4, 14, 11, .82); }
.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: 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(--night2); 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(--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: #0a1714f7; 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(--night2); 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(--night3); 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(--night2); 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(--night2); 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(--night2); 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; }
.hero-eggs { display: flex; gap: 10px; margin-bottom: 6px; } .hero-eggs img { width: 64px; height: 64px; filter: drop-shadow(0 3px 6px #0008); }
.ring.big { margin: 10px 0 4px; } .ring.big .r-dot { --d: 34px; }
