/* ==========================================================================
   Game Night: one design system for every game (the card games add games.css).
   Felt table, ivory tiles, plastic racks; Fredoka for titles and buttons,
   Atkinson Hyperlegible (made for low vision) for tiles and reading text.
   ========================================================================== */

:root {
  --zoom: 1;

  /* table */
  --felt: #10704a;
  --felt-mid: #0b5436;
  --felt-dark: #063522;
  --bg: #04190f;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* surfaces (dark glass over the felt) */
  --glass: rgba(3, 22, 14, .8);
  --glass-hi: rgba(8, 38, 25, .88);
  --well: rgba(0, 0, 0, .26);
  --line: rgba(255, 255, 255, .12);
  --line-strong: rgba(255, 255, 255, .26);

  /* text */
  --ink: #ffffff;
  --muted: #d2e6da;
  --soft: #a3c2b1;

  /* accents */
  --gold: #ffcf33;
  --gold-hi: #ffe58a;
  --gold-deep: #b98a00;
  --green: #22b35e;
  --green-hi: #3fce78;
  --green-deep: #0f6e37;
  --blue: #2f74e6;
  --blue-hi: #5591fb;
  --blue-deep: #1a428e;
  --bad: #ff4d40;
  --bad-deep: #a3241b;
  --pick: #1e7bff;

  /* tiles */
  --tile-face: #fffdf6;
  --tile-mid: #fbf3df;
  --tile-low: #efe3c4;
  --tile-side: #d9caa2;
  --tile-side-dark: #b6a47a;
  --t0: #111111;   /* black */
  --t1: #d4001a;   /* red */
  --t2: #2f9be6;   /* baby blue, a little darker so it reads well */
  --t3: #e05a00;   /* orange */

  /* rack plastic; each rack overrides these with its owner's chosen color */
  --rk-hi: #ffe14d;
  --rk: #f7c600;
  --rk-lo: #d9a800;
  --rk-deep: #a67f00;
  --rk-ink: #8f6c00;
  --rk-text: #3a2c00;

  /* sizes */
  --tw: calc(clamp(40px, min(11vw, 6.6vh), 58px) * var(--zoom));
  --th: calc(var(--tw) * 1.34);
  --bw: calc(var(--tw) * 0.92);
  --bh: calc(var(--bw) * 1.34);
  --r-lg: 20px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-1: 0 2px 6px rgba(0, 0, 0, .28);
  --shadow-2: 0 10px 26px rgba(0, 0, 0, .38);
  --shadow-3: 0 22px 48px rgba(0, 0, 0, .5);

  --font: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --display: 'Fredoka', 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

/* dark mode (Settings): the felt and the glass over it turn dark grey, nearly black, in every game */
html.dark {
  --felt: #2b2d2f;
  --felt-mid: #1c1d1f;
  --felt-dark: #0e0e0f;
  --bg: #080809;
  --glass: rgba(14, 14, 16, .82);
  --glass-hi: rgba(30, 31, 34, .9);
  --muted: #dcdcdc;
  --soft: #b0b0b0;
}
html.dark .seat { background: linear-gradient(180deg, rgba(30,31,34,.92), rgba(12,12,14,.94)); }
html.dark .face, html.dark .avatar { background-color: #111; }
html.dark .stcard { background: linear-gradient(180deg, #26272a, #141416); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: calc(19px * var(--zoom)); line-height: 1.35;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
b, strong { font-weight: 700; }

.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#i-sortcol circle, #i-settings circle { fill: currentColor; }

/* thin, quiet scrollbars wherever something scrolls */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.28) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.26); border-radius: 999px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* felt: a soft pool of light in the middle, darker edges, fine cloth grain */
#join, #game {
  background:
    var(--noise),
    radial-gradient(ellipse 85% 75% at 50% 40%, var(--felt) 0%, var(--felt-mid) 55%, var(--felt-dark) 100%);
}

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--glass-hi), var(--glass));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), var(--shadow-3);
  -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
}

/* ---------- buttons ---------- */
.btn {
  --b-top: #ffffff; --b-bot: #e9efeb; --b-edge: #9fb0a6; --b-ink: #12241a;
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 48px; padding: .4em 1em; border: 0; border-radius: var(--r-md);
  font-family: var(--display); font-weight: 600; font-size: 1em; letter-spacing: .005em; line-height: 1.1;
  color: var(--b-ink); background: linear-gradient(180deg, var(--b-top), var(--b-bot));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 3px 0 var(--b-edge), 0 6px 12px rgba(0,0,0,.24);
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease, background-color .15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 1px 0 var(--b-edge), 0 2px 5px rgba(0,0,0,.22); }
.btn:focus-visible, input:focus-visible, .swatch:focus-visible, .iconbtn:focus-visible, .sortbtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn[disabled] {
  --b-top: rgba(255,255,255,.1); --b-bot: rgba(255,255,255,.1); --b-ink: rgba(255,255,255,.42);
  cursor: default; filter: none; transform: none; box-shadow: inset 0 0 0 1px var(--line); text-shadow: none;
}
.btn.go { --b-top: var(--green-hi); --b-bot: var(--green); --b-edge: var(--green-deep); --b-ink: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn.draw { --b-top: var(--blue-hi); --b-bot: var(--blue); --b-edge: var(--blue-deep); --b-ink: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn.on { --b-top: var(--gold-hi); --b-bot: var(--gold); --b-edge: var(--gold-deep); --b-ink: #2a1f00; }
.btn.muted { --b-top: #ff7a6e; --b-bot: var(--bad); --b-edge: var(--bad-deep); --b-ink: #fff; }
.btn.small { min-height: 42px; padding: .3em .75em; font-size: .9em; }
.btn.huge { width: 100%; min-height: 60px; font-size: 1.25em; margin-top: .4em; border-radius: 14px; }
.btn .ic { width: 1.2em; height: 1.2em; }

/* quiet buttons: glass instead of a raised key (header, turn tools) */
.hbtn, #controls .btn:not(.go):not(.draw) {
  background: rgba(255,255,255,.1); color: #fff; text-shadow: none;
  box-shadow: inset 0 0 0 1px var(--line);
}
.hbtn:hover, #controls .btn:not(.go):not(.draw):not([disabled]):hover { background: rgba(255,255,255,.18); filter: none; }
.hbtn:active, #controls .btn:not(.go):not(.draw):active { transform: translateY(1px); box-shadow: inset 0 0 0 1px var(--line); }
.hbtn.on { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1f00; box-shadow: none; }
.hbtn.muted { background: linear-gradient(180deg, #ff7a6e, var(--bad)); color: #fff; box-shadow: none; }

.iconbtn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); border: 0;
  background: rgba(255,255,255,.08); color: #fff; cursor: pointer; transition: background-color .15s ease;
}
.iconbtn:hover { background: rgba(255,255,255,.18); }

/* ---------- join screen ---------- */
/* centred, but scrolls from the top when the screen is shorter than the card */
#join { height: 100%; overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 24px 16px; gap: 16px; }
/* centred whatever is shown; spacers (not auto margins) so a hidden footer cannot pull the card down */
#join::before, #join::after { content: ''; flex: 1 0 0; }
#join > * { flex: none; }
.joinbox { width: min(480px, 100%); display: flex; flex-direction: column; gap: 6px; padding: 30px 30px 28px; }
.logo { display: flex; justify-content: center; gap: 6px; margin: -2px 0 8px; --tw: 62px; --th: 83px; }
.logo .tile { cursor: default; }
.logo .tile:nth-child(1) { transform: rotate(-9deg) translateY(7px); }
.logo .tile:nth-child(3) { transform: rotate(9deg) translateY(7px); }
.title {
  font-family: var(--display); font-weight: 700; font-size: 2.5em; line-height: 1; margin: 8px 0 4px; text-align: center;
  color: var(--gold); text-shadow: 0 2px 0 #8a6400, 0 8px 20px rgba(0,0,0,.4); letter-spacing: .005em;
}
.tagline { margin: 0 0 14px; text-align: center; color: var(--muted); font-size: .95em; text-wrap: balance; }
.joinbox label { font-family: var(--display); font-weight: 600; font-size: .95em; color: var(--muted); margin-top: 12px; }
.joinbox input:not([type]), .joinbox input[type=text] {
  font-size: 1.3em; padding: .42em .65em; border-radius: var(--r-md); border: 2px solid transparent; width: 100%;
  background: #fff; color: #0c1a12; box-shadow: inset 0 2px 3px rgba(0,0,0,.14), 0 1px 0 rgba(255,255,255,.08);
  transition: border-color .15s ease;
}
.joinbox input:focus { border-color: var(--gold); outline: none; }
.joinbox input::placeholder { color: #93a199; }
.fieldhint { margin: 3px 0 0; color: var(--soft); font-size: .85em; }
.err { color: #ffb4ae; font-weight: 700; margin: 6px 0 0; }
.err:empty { display: none; }
.joinbox .btn.huge { margin-top: 12px; }
.joinfoot { color: var(--soft); font-size: .85em; margin: 0; text-align: center; }

/* ---------- game frame ---------- */
#game {
  height: 100dvh; display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) minmax(150px, 220px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head head head" "left main right" "left foot right";
}
header { grid-area: head; }
#seatsL { grid-area: left; }
#seatsR { grid-area: right; }
/* the faces stack from the top, but your own stays down in the bottom left corner */
@media (min-width: 1100px) { #seatsL > .seat.me { margin-top: auto; } }
main { grid-area: main; }
footer { grid-area: foot; }

/* No band across the top: its buttons float in their places over the table, which runs right up to the top.
   The players' columns start below the buttons. */
#game { position: relative; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "left main right" "left foot right"; }
header {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  pointer-events: none;   /* only the buttons themselves catch taps; the table shows (and works) between them */
}
header > * { pointer-events: auto; }
header > .spacer { pointer-events: none; }
.seats:not(:empty) { padding-top: 62px; }
/* just the buttons: no game or lobby name, and the connection only shows when something is wrong */
header .gname, header .tname, header .status.good { display: none !important; }
/* camera and settings together are no wider than the webcam column under them, and line up with it */
header { padding-right: 10px; }
.hright { display: flex; gap: 8px; justify-content: flex-end; width: 200px; flex: none; }
.hright .hbtn { min-width: 0; justify-content: center; }
.hright #camBtn { flex: none; overflow: hidden; padding-left: .7em; padding-right: .7em; }
.hright #camBtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hright #setBtn, .hright #micBtn { flex: none; padding-left: .7em; padding-right: .7em; }
.hright #setBtn .hlabel, .hright #micBtn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brandname { font-family: var(--display); font-weight: 700; font-size: 1.2em; color: var(--gold); letter-spacing: .005em; }
.mark { display: inline-flex; gap: 2px; }
.mark i { display: block; width: 11px; height: 15px; border-radius: 3px; background: linear-gradient(#fff, #efe3c4); box-shadow: 0 2px 0 #b6a47a; }
.mark i:nth-child(1) { transform: rotate(-10deg); border-top: 4px solid var(--t1); }
.mark i:nth-child(2) { border-top: 4px solid var(--t2); }
.mark i:nth-child(3) { transform: rotate(10deg); border-top: 4px solid var(--t3); }
.chip {
  display: inline-flex; align-items: center; gap: .4em; padding: .2em .75em; border-radius: 999px;
  background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--muted); font-size: .85em;
}
.chip b { color: #fff; }
.status { display: inline-flex; align-items: center; gap: .45em; font-weight: 700; font-size: .85em; color: var(--muted); }
.status i { width: 9px; height: 9px; border-radius: 50%; background: #f0a020; box-shadow: 0 0 0 3px rgba(240,160,32,.22); }
.status.good i { background: #3ddc84; box-shadow: 0 0 0 3px rgba(61,220,132,.2); }
.status.good span { display: none; }
.spacer { flex: 1; }
.hbtn { min-height: 42px; padding: .3em .85em; font-size: .9em; border-radius: 11px; }

/* settings popover */
.popover { position: absolute; z-index: 40; right: 12px; top: 62px; width: min(420px, calc(100vw - 24px)); padding: 8px 18px 16px; }
.pophead { display: flex; align-items: center; justify-content: space-between; font-family: var(--display); font-size: 1.15em; padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.pophead .iconbtn { margin-right: -8px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.setrow:last-child { border-bottom: 0; }
.setlabel { display: inline-flex; align-items: center; gap: .6em; font-weight: 700; }
.setlabel .ic { color: var(--soft); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .btn { min-height: 40px; min-width: 48px; padding: 0 .6em; }
.stepper b { min-width: 3.2em; text-align: center; font-variant-numeric: tabular-nums; }
.setgroup { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
#volList { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.volrow { display: grid; grid-template-columns: minmax(70px, 30%) 1fr 3.2em; align-items: center; gap: 10px; min-height: 40px; }
.volrow .vname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.volrow b { text-align: right; font-size: .9em; font-variant-numeric: tabular-nums; }
.volrow input[type=range] { width: 100%; height: 34px; accent-color: var(--gold); cursor: pointer; }
.vidme { margin: 6px 0 4px; color: var(--soft); font-size: .9em; }
.vidme .vwarn { display: block; color: #ffb020; margin-top: 2px; }
.vidrow { padding: 6px 0; border-top: 1px solid var(--line); }
.vidtop { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; min-height: 40px; }
.vidtop .vname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vchip { padding: .2em .7em; border-radius: 999px; font-size: .85em; white-space: nowrap; }
.vchip.good { background: #1f8f4e; color: #fff; }
.vchip.warn { background: #ffb020; color: #2a1f00; }
.vchip.bad { background: #d93a30; color: #fff; }
.vchip.off { background: rgba(127,127,127,.25); color: inherit; }
.viddet { display: flex; flex-direction: column; gap: 1px; color: var(--soft); font-size: .82em; font-variant-numeric: tabular-nums; }
#vidCopy { margin-top: 8px; }
.setactions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 14px; }
.setactions .btn { width: 100%; min-height: 46px; font-size: .88em; padding: .3em .5em; }
#closeAllBtn.armed { --b-top: #ffd0cc; --b-bot: #ffb4ae; --b-ink: #7a1008; animation: armed .6s ease-in-out infinite alternate; }
@keyframes armed { to { filter: brightness(1.12); } }
.lobby .leave { flex: none; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 54px; height: 32px; border-radius: 999px; background: rgba(255,255,255,.2); position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.35); transition: transform .15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(22px); }

/* the playing area; during a game the table is a felt mat exactly as big as the space tiles can go */
main { min-height: 0; overflow: auto; padding: 12px 14px; position: relative; }
main.mat { margin: 10px 0 0; padding-bottom: 18px; }   /* room for the table's edge and a strip of felt above the rack */
#game:has(main.mat) footer { padding-top: 0; }
main.mat .board {
  --edge: 10px; border-radius: 8px; background: rgba(0, 0, 0, .2);
  box-shadow: 0 0 0 var(--edge) rgba(0, 0, 0, .2), 0 0 0 calc(var(--edge) + 1.5px) rgba(255,255,255,.12), 0 6px 30px calc(var(--edge) - 4px) rgba(0,0,0,.25);
}
/* the waiting room and the results sit in the middle of the table */
main:not(.mat) #center { min-height: 100%; display: grid; align-items: center; }
.panel { text-align: center; font-family: var(--display); color: var(--muted); }
.seats { display: flex; flex-direction: column; gap: 10px; padding: 10px; min-height: 0; }
.seats:empty { padding: 0; }

/* ---------- seats: faces and mini racks ---------- */
.seat {
  flex: 1 1 0; min-height: 0; max-height: 280px; display: flex; flex-direction: column; gap: 5px;
  background: linear-gradient(180deg, rgba(8,36,23,.9), rgba(3,20,12,.92));
  border: 1px solid var(--line); border-radius: 16px; padding: 5px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-2);
  transition: border-color .2s, box-shadow .2s, opacity .2s;
}
.seat.off { opacity: .5; }
.face { flex: 1 1 auto; min-height: 36px; position: relative; border-radius: 11px; overflow: hidden; background: #0b1510; container-type: size; }
.face video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.face video.mirror { transform: scaleX(-1); }
/* Josh's L, over his forehead (placed by js/lmark.js) */
.face .lmark {
  position: absolute; z-index: 2; pointer-events: none; line-height: .85;
  font-family: var(--display); font-weight: 700; color: #ff3b30;
  -webkit-text-stroke: max(1.5px, .05em) #fff; paint-order: stroke fill;
  text-shadow: 0 .04em .12em rgba(0,0,0,.55);
  transition: left .1s linear, top .1s linear, font-size .2s;
}
/* the winner's crown, on their head for 2 minutes (placed by js/lmark.js; sized by font-size) */
.face .crownmark {
  position: absolute; z-index: 3; pointer-events: none; width: 1em; height: .7em;
  filter: drop-shadow(0 .03em .06em rgba(0,0,0,.6));
  transition: left .1s linear, top .1s linear, font-size .2s;
  animation: crown-drop .6s cubic-bezier(.3,1.5,.5,1);
}
.face .crownmark svg { display: block; width: 100%; height: 100%; overflow: visible; }
@keyframes crown-drop { from { opacity: 0; margin-top: -.6em; } to { opacity: 1; margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { .face .crownmark { animation: none; } }
/* no camera: their initial (or a robot) on a disc in their rack color */
.avatar {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5cqh;
  background: radial-gradient(130% 100% at 50% 0%, color-mix(in srgb, var(--rk) 40%, #0c1712) 0%, #0c1712 80%);
}
.avatar .mono {
  --d: min(46cqh, 58cqw); display: grid; place-items: center; width: var(--d); height: var(--d); flex: none; border-radius: 50%;
  background: linear-gradient(160deg, var(--rk-hi), var(--rk) 55%, var(--rk-lo)); color: var(--rk-text);
  font-family: var(--display); font-weight: 700; font-size: min(26cqh, 32cqw); line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 3px rgba(255,255,255,.16), 0 6px 14px rgba(0,0,0,.4);
}
.avatar .mono .ic { width: 58%; height: 58%; stroke-width: 2; }
.avatar small { font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.face.waiting::after { content: 'Video loading…'; position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: .75em; color: #fff; text-shadow: 0 1px 2px #000; }
.seat.mic-off .face::before {
  content: ''; position: absolute; bottom: 6px; right: 6px; z-index: 2; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bad) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M3 3l18 18'/%3E%3C/svg%3E") center / 15px no-repeat;
  box-shadow: var(--shadow-1);
}
.tag { font-family: var(--display); font-weight: 600; font-size: .8em; text-align: center; color: var(--muted); min-height: 1.2em; }
.seats .seat .tag:empty { display: none; }
.tag .ic { width: 1em; height: 1em; vertical-align: -.12em; color: var(--gold); }

/* whose turn: a flag on the picture and a glowing gold frame; everyone else a little dimmer */
.flag {
  display: none; position: absolute; top: 6px; left: 6px; z-index: 3; padding: 2px 9px 2px 7px; border-radius: 999px;
  background: linear-gradient(var(--gold-hi), var(--gold)); color: #2a1f00; font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .04em;
  box-shadow: var(--shadow-1);
}
.seat.turn .flag { display: block; }
.seatwins {
  position: absolute; top: 6px; left: 6px; z-index: 3; display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: 999px;
  background: rgba(0,0,0,.62); color: #fff; font-family: var(--display); font-weight: 700; font-size: 13px; line-height: 1.3; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.seatwins[hidden] { display: none; }
.seatwins .ic { width: 1em; height: 1em; color: var(--gold-hi); }
.seat.turn .seatwins { top: 32px; }
.seat.turn { border-color: var(--gold); animation: seatpulse 1.8s ease-in-out infinite; }
.seat.turn .tag { color: var(--gold); }
@keyframes seatpulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 0 5px rgba(255,207,51,.18), var(--shadow-2); }
  50% { box-shadow: 0 0 0 2px var(--gold), 0 0 0 7px rgba(255,207,51,.28), 0 0 30px rgba(255,207,51,.55); }
}
.seat.idle .face { filter: brightness(.82) saturate(.9); }

/* the player's rack in miniature, as if it were standing on the table in front of them: the sloped back
   leans away (seen in perspective, so the back rows are further off), each row of tile backs stands on its
   own ledge, and the name is pressed into the front edge */
.minirack { flex: none; margin-bottom: 3px; position: relative; perspective: 260px; perspective-origin: 50% -40%; }
.minirack::after {   /* the shadow it casts on the table */
  content: ''; position: absolute; left: 6%; right: 6%; bottom: -5px; height: 10px; z-index: -1;
  border-radius: 50%; background: rgba(0,0,0,.45); filter: blur(5px);
}
.minirack .backs {
  --rowh: 12px; --rowgap: 3px;
  display: grid; grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr)); grid-auto-rows: var(--rowh); align-content: end;
  gap: var(--rowgap) 2px; min-height: 22px; padding: 5px 7px 2px;
  border-radius: 8px 8px 0 0;
  transform: rotateX(32deg); transform-origin: 50% 100%; transform-style: preserve-3d;
  /* the slope, with a ledge under each row of tiles; shade gets darker towards the back */
  background:
    linear-gradient(rgba(0,0,0,.28), rgba(0,0,0,0) 70%),
    repeating-linear-gradient(180deg,
      var(--rk-lo) 0, var(--rk) 35%, var(--rk-hi) calc(var(--rowh) - 1px),
      var(--rk-deep) calc(var(--rowh) - 1px), var(--rk-deep) calc(var(--rowh) + 1px),
      var(--rk-hi) calc(var(--rowh) + 1px), var(--rk-lo) calc(var(--rowh) + var(--rowgap)));
  background-origin: content-box;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 2px 0 0 rgba(255,255,255,.12), inset -2px 0 0 rgba(0,0,0,.18);
}
.minirack .backs b { display: block; }
/* a tile back standing in its groove: a lit top edge, a darker underside, and its shadow on the slope */
.minirack .backs i {
  transform: rotateX(-34deg); transform-origin: 50% 100%;   /* standing up out of the slope */
  border-radius: 2px 2px 1px 1px;
  background: linear-gradient(180deg, #fff 0, var(--tile-face) 18%, var(--tile-low) 70%, var(--tile-side) 100%);
  box-shadow: inset 0 0 0 .5px rgba(120,95,40,.35), 0 1px 0 var(--tile-side-dark), 0 -2px 3px rgba(0,0,0,.28);
}
.minirack .mini-edge {
  position: relative; height: 19px; border-radius: 0 0 8px 8px;
  background: linear-gradient(var(--rk-hi), var(--rk) 30%, var(--rk-lo));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 2px 0 var(--rk-deep), 0 5px 8px rgba(0,0,0,.4);
  display: flex; align-items: center; padding: 0 9px; overflow: hidden;
}
.minirack .engr { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the "first 30" badge: a padlock until a player has made their opening play, then a green tick.
   On my own rack it fills up as the tiles I have put down add up towards 30. */
.open30 {
  display: none; position: absolute; top: 6px; right: 6px; z-index: 3; align-items: center; gap: 3px;
  padding: 2px 9px 2px 6px; border-radius: 999px; font-family: var(--display); font-weight: 600; font-size: 13px; line-height: 1.3;
  background: rgba(0,0,0,.62); color: #dbe8e0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.open30.show { display: inline-flex; }
.open30.yes { background: var(--green); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), var(--shadow-1); }
.open30 .ic { width: 1em; height: 1em; stroke-width: 3; }
#rackInfo .open30 { position: static; font-size: .92em; padding: 3px 11px 3px 8px; background: rgba(0,0,0,.7); color: #fff; }
#rackInfo .open30.yes { background: var(--green); }
#rackInfo .open30.meter { background: linear-gradient(90deg, var(--gold-deep) var(--p, 0%), rgba(0,0,0,.72) var(--p, 0%)); }
#rackInfo .open30.meter.yes { background: var(--green); }

.engr {
  font-weight: 700; font-style: italic; letter-spacing: .02em; color: var(--rk-text);
  text-shadow: 0 1px 0 var(--rk-hi), 0 -1px 0 rgba(0,0,0,.3);
}
.nm { display: none; position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 5px 1px; z-index: 2;
  background: linear-gradient(transparent, rgba(0,0,0,.82)); color: #fff; font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- the table: tiles sit wherever they are put; a bar under each set shows where it starts and ends ---------- */
.board { position: relative; margin: 0 auto; }
.board .tile { position: absolute; }
.board .tile.lifted { opacity: .3; }
.board .tile::before {
  content: ''; position: absolute; left: -2px; right: -2px; bottom: -10px; height: 4px;
  background: rgba(255,255,255,.24); pointer-events: none;
}
.board .tile.seg-start::before { left: 2px; border-radius: 3px 0 0 3px; }
.board .tile.seg-end::before { right: 2px; border-radius: 0 3px 3px 0; }
.board .tile.seg-start.seg-end::before { border-radius: 3px; }
.board .tile.seg-ok::before { background: #3ddc84; }
.board .tile.seg-bad::before { background: var(--bad); height: 5px; }
.board .tile.seg-bad { box-shadow: inset 0 1px 0 #fff, 0 0 0 2.5px var(--bad), 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.32); }
.board .tile.sel { outline: 3px solid var(--pick); outline-offset: 0; }

/* ---------- tiles: ivory with a little thickness ---------- */
.tile {
  width: var(--tw); height: var(--th); flex: none;
  background: linear-gradient(180deg, var(--tile-face) 0%, var(--tile-mid) 62%, var(--tile-low) 100%);
  border-radius: calc(var(--tw) * .16);
  box-shadow: inset 0 1px 0 #fff, inset 0 0 0 1px rgba(150,125,70,.16), 0 2px 0 var(--tile-side), 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.32);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; cursor: pointer; position: relative;
  touch-action: none;
}
/* the 0 comes from Inter (only that one character is loaded), so the 10 has a plain zero with no slash.
   Inter's figures stand about 9% taller than the tile font's, so it is drawn at 92% to match the 1. */
.z { font-family: 'Inter', var(--font); font-size: .92em; }
.tile .num { font-weight: 700; font-size: calc(var(--tw) * .66); line-height: 1; letter-spacing: -.03em; font-variant-numeric: lining-nums; }
.tile .sym { font-size: calc(var(--tw) * .26); line-height: 1; margin-top: calc(var(--tw) * .04); }
/* the color shape: a solid, crisp shape in the tile's color with a fine darker edge */
.tile svg.sym { display: block; width: calc(var(--tw) * .27); height: calc(var(--tw) * .27); fill: currentColor; stroke: rgba(0,0,0,.28); stroke-width: .9; stroke-linejoin: round; margin-top: calc(var(--tw) * .03); }
.tile.c0 { color: var(--t0); }
.tile.c1 { color: var(--t1); }
.tile.c2 { color: var(--t2); }
.tile.c3 { color: var(--t3); }
/* the joker: a photo in a red ring, with JOKER under it */
.jface { display: block; border-radius: 50%; background: #fff url(img/joker.jpg) center / cover no-repeat; }
.jface.j2 { background-image: url(img/joker2.jpg); }
.tile .jface { width: calc(var(--tw) * .7); height: calc(var(--tw) * .7); box-shadow: 0 0 0 calc(var(--tw) * .035) var(--t1), 0 1px 2px rgba(0,0,0,.3); margin-bottom: calc(var(--tw) * .08); }
.tile.joker .sym { color: var(--t0); font-size: calc(var(--tw) * .16); font-weight: 700; letter-spacing: .04em; }
.tile.sel {
  outline: 3px solid var(--pick); outline-offset: 0; transform: translateY(-6px);
  background: linear-gradient(#f4f9ff, #dceaff); box-shadow: 0 3px 0 #9db8e0, 0 12px 16px rgba(0,0,0,.42);
}
.tile.sel::after {
  content: ''; position: absolute; top: -10px; right: -9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--pick) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
  border: 2px solid #fff; box-shadow: var(--shadow-1);
}
/* tiles put down this turn */
/* tiles played this turn: a thick, bright gold ring with a soft glow, easy to spot */
.tile.placed { box-shadow: inset 0 0 0 2px #ffd21f, inset 0 1px 0 3px rgba(255,255,255,.6), 0 0 0 6px #ffd21f, 0 0 0 8px #6b4600, 0 0 18px 7px rgba(255, 210, 31, .6), 0 4px 0 var(--tile-side-dark), 0 7px 10px rgba(0,0,0,.35); }
/* played this turn but not in a legal set yet: the same thick glowing ring, in red */
.board .tile.placed.seg-bad { box-shadow: inset 0 0 0 2px var(--bad), inset 0 1px 0 3px rgba(255,255,255,.6), 0 0 0 6px var(--bad), 0 0 0 8px var(--bad-deep), 0 0 18px 7px rgba(255, 77, 64, .6), 0 4px 0 var(--tile-side-dark), 0 7px 10px rgba(0,0,0,.35); }
.tile.fresh { animation: fresh .9s ease-in-out 2; }
/* the one oversized red 4: drawn a little bigger, taking up the same slot as any other tile */
.tile.big { scale: 1.12; z-index: 1; }
.ghost .tile.big { scale: 1.12; }
@keyframes fresh { 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 20px var(--gold); } }
/* the tile being held, a little above the table, with a soft shadow that moves with it */
.ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; display: block; --gap: 4px; --rgap: 12px; opacity: .97; filter: drop-shadow(4px 12px 9px rgba(0,0,0,.4)) drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.ghost .tile { transform: none; }
body.dragging { cursor: grabbing; }

/* ---------- my rack and the turn buttons under it ---------- */
footer {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: end;
  padding: 8px 0 max(10px, env(safe-area-inset-bottom));
}
#mySeat:empty { display: none; }
.mine { min-width: 0; }
/* The turn buttons don't take a row of their own: they float over the bottom edge of the table, just above
   the rack, so the table reaches all the way down to it. Done / Draw are chunky keys that look raised off the
   screen, each with its own shadow. */
footer { position: relative; }
#controls {
  position: absolute; z-index: 25; left: 50%; bottom: calc(100% + 26px); transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; justify-content: center; max-width: 100%; width: max-content;
}
#controls:empty { display: none; }
/* out of the way while tiles are being moved */
body.moving #controls { display: none; }
#controls .btn { min-height: 40px; padding: .15em .85em; font-size: .85em; border-radius: 10px; gap: .4em; white-space: nowrap; }
#controls .btn.go, #controls .btn.draw {
  min-width: 7.2em; min-height: 52px; font-size: 1em; padding: .15em 1.1em; border-radius: 13px; transform: translateY(-3px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 -2px 0 rgba(0,0,0,.12), 0 5px 0 var(--b-edge), 0 12px 18px -2px rgba(0,0,0,.55);
}
#controls .btn.go:active, #controls .btn.draw:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 var(--b-edge), 0 2px 4px rgba(0,0,0,.4); }
#controls .btn[disabled] { background: transparent; color: rgba(255,255,255,.32); box-shadow: none; }
#controls .btn .ic { width: 1.15em; height: 1.15em; }
#controls .cnt { font-size: .85em; padding: .05em .5em; border-radius: 999px; background: rgba(0,0,0,.26); font-variant-numeric: tabular-nums; }
.turnchip, .poolchip {
  display: inline-flex; align-items: center; gap: .4em; min-height: 40px; padding: 0 .85em; border-radius: 10px;
  font-family: var(--display); font-weight: 600; font-size: .85em; white-space: nowrap;
}
.turnchip { background: linear-gradient(var(--rk-hi), var(--rk)); color: var(--rk-text); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 2px 0 var(--rk-deep); max-width: 14em; overflow: hidden; text-overflow: ellipsis; }
.turnchip::before { content: '▶'; font-size: .75em; }
.poolchip { background: rgba(255,255,255,.08); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); font-variant-numeric: tabular-nums; }
.poolchip b { color: #fff; }
.turnchip .ic, .poolchip .ic { width: 1.1em; height: 1.1em; }

/* the wedge rack (modelled on the one in the family's photo); it lights up when it is my turn */
.rack {
  /* the rack's own tile size: the usual size times the slider on its edge (--rz) */
  --tw: calc(clamp(40px, min(11vw, 6.6vh), 58px) * var(--zoom) * var(--rz, 1));
  --th: calc(var(--tw) * 1.34);
  position: relative; border-radius: 16px 16px 10px 10px; padding: 10px 14px 0;
  background:
    linear-gradient(165deg, rgba(255,255,255,.34) 0%, rgba(255,255,255,0) 26%),
    linear-gradient(180deg, var(--rk-hi) 0%, var(--rk) 40%, var(--rk) 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.55), inset 0 -2px 0 var(--rk-lo), var(--shadow-2);
}
.rack .grooves {
  --row: calc(var(--th) + 12px);
  position: relative;
  /* a fixed grid of slots, three rows deep; tiles can sit anywhere and leave gaps */
  display: grid; grid-auto-rows: var(--row); column-gap: 5px; align-content: start;
  min-height: calc(var(--row) * 3 + 14px); padding-top: 14px;
  /* one dark channel per row that the tiles stand in (behind them, so every tile stays fully visible),
     with a light lip on its front edge; only under the rows, none above */
  background-image: linear-gradient(to bottom,
    transparent 0, transparent calc(var(--th) - 4px),
    var(--rk-deep) calc(var(--th) - 4px), var(--rk-deep) calc(var(--th) + 5px),
    var(--rk-lo) calc(var(--th) + 5px), var(--rk-hi) calc(var(--th) + 7px), transparent calc(var(--th) + 8px));
  background-size: 100% var(--row); background-repeat: repeat-y;
  background-origin: content-box; background-clip: content-box;
}
.rack .grooves .tile { margin-bottom: 12px; }
/* Matt's slot numbers: the rows spread apart to leave a strip under each groove, and the numbers are cut
   into it (dark, with a light edge below and a shadow above, like the lip of the groove) */
.rack.numbered .grooves { --row: calc(var(--th) + 30px); }
.rack .slotnums { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.rack .slotnums span {
  position: absolute; text-align: center; line-height: 1;
  font-family: var(--display); font-weight: 800; font-size: max(12px, calc(var(--tw) * .3)); font-variant-numeric: tabular-nums;
  color: var(--rk-deep); opacity: .85;
  text-shadow: 0 1px 0 rgba(255,255,255,.55), 0 -1px 0 rgba(0,0,0,.35);
}
.rack .grooves .tile.sel { transform: translateY(-6px); }
.rack .cell { width: var(--tw); height: var(--th); border-radius: calc(var(--tw) * .16); }
/* empty slots are invisible, but still there: tap one (while holding tiles) to put them there */
.rack.picking .cell { cursor: pointer; }
/* where a dragged tile will land: an open space (its neighbours move aside); the only shadow is the one
   that moves with the tile being held (.ghost) */
.rack .tile.landing { visibility: hidden; animation: none; }
.rackmsg { grid-column: 1 / -1; color: var(--rk-text); font-family: var(--display); font-weight: 600; padding: 18px 6px; font-size: 1.1em; }
.rack .edge {
  margin: 0 -14px; height: 46px; border-radius: 0 0 10px 10px; gap: 12px;
  background: linear-gradient(180deg, var(--rk) 0%, var(--rk-lo) 65%, color-mix(in srgb, var(--rk-lo), var(--rk-deep)));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 0 var(--rk-deep);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
}
#rackInfo { display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--rk-text); font-family: var(--display); font-weight: 600; font-size: .9em; white-space: nowrap; }
#sorts { display: flex; gap: 8px; flex: none; }
.sortbtn {
  display: inline-flex; align-items: center; gap: .4em; white-space: nowrap;
  font-family: var(--display); font-weight: 600; font-size: .82em; color: var(--rk-text); cursor: pointer;
  background: linear-gradient(var(--rk-hi), var(--rk)); border: 0; border-radius: 9px; padding: .2em .8em; min-height: 32px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 2px 0 var(--rk-deep);
}
.sortbtn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--rk-deep); }
.sortbtn .ic { width: 1.05em; height: 1.05em; }
.sortbtn.undo { background: #fff; color: #14261c; box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 0 2px var(--rk-deep); }
#rackTools { display: flex; gap: 8px; flex: none; margin-left: auto; }
#rackSizeBox { display: flex; align-items: center; gap: 6px; flex: 0 1 140px; min-width: 56px; color: var(--rk-text); }
#rackSizeBox .ic { width: 1.1em; height: 1.1em; flex: none; opacity: .8; }
#rackSizeBox input { width: 100%; min-width: 0; height: 28px; accent-color: var(--rk-text); cursor: pointer; }
#rackTools:empty { display: none; }
.sortbtn[disabled] { opacity: .45; cursor: default; transform: none; box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.sortbtn.on { background: linear-gradient(var(--gold-hi), var(--gold)); color: #2a1f00; box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 2px 0 var(--gold-deep); }

/* ---------- waiting room ---------- */
.lobby, .over { width: 100%; max-width: 560px; margin: 0 auto; padding: 24px 26px 26px; }
.lobby { max-width: calc(1000px * var(--zoom)); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; padding: 22px 26px 24px; }
.lcol { min-width: 0; display: flex; flex-direction: column; }
.lobby .section { margin-top: 14px; }
.lobby .lcol:last-child .section:first-child { margin-top: 0; }
.lobby .btn.huge { margin-top: 18px; }
.lobbyfoot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.lobbyfoot .tip { margin: 0; flex: 1 1 0; min-width: 0; font-size: .85em; }
.tip > span { min-width: 0; }
.panelhead { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.panelhead .badge { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; flex: none; background: linear-gradient(var(--gold-hi), var(--gold)); color: #2a1f00; box-shadow: 0 3px 0 var(--gold-deep); }
.panelhead .badge .ic { width: 28px; height: 28px; }
.panelhead h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.6em; line-height: 1.1; }
.panelhead p { margin: 2px 0 0; color: var(--muted); font-size: .92em; }
.panelhead .ph { min-width: 0; flex: 1; }
.panelhead .ph h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.headact { display: none; gap: 6px; flex: none; }
.section { margin-top: 18px; }
.section h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 600; font-size: .82em; color: var(--soft); letter-spacing: .07em; text-transform: uppercase; }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.linkrow .btn { flex: 1 0 auto; }
.linkrow input { flex: 1 1 220px; min-width: 0; padding: .45em .7em; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--well); color: var(--muted); font-size: .9em; }
.players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pchip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; min-width: 0;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
}
.pchip .av {
  position: relative; width: calc(40px * var(--zoom)); height: calc(40px * var(--zoom)); border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--rk-hi), var(--rk) 55%, var(--rk-lo)); color: var(--rk-text); font-family: var(--display); font-weight: 700; font-size: 1.15em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 2px rgba(255,255,255,.14);
}
.pchip .pn { min-width: 0; font-weight: 700; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchip .hostcrown { display: inline-flex; vertical-align: -.12em; margin-right: .35em; color: var(--gold); }
.pchip .hostcrown .ic { width: 1.05em; height: 1.05em; }
.pchip .pt { display: block; white-space: normal; color: var(--soft); font-size: .78em; font-weight: 400; }
.pchip.cpu .av .ic { width: 24px; height: 24px; stroke-width: 2.1; }
.pchip .rm { margin-left: auto; width: calc(36px * var(--zoom)); height: calc(36px * var(--zoom)); flex: none; border-radius: 50%; background: transparent; color: var(--soft); }
.pchip .rm:hover { background: rgba(255,255,255,.14); color: #fff; }
.pchip .av .lvl { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; border-radius: 9px; font-style: normal; font-size: 11px; line-height: 18px; text-align: center; background: #fff; color: #14261c; box-shadow: 0 0 0 2px #0a2618; }
.pchip.empty-seat { border-style: dashed; border-color: var(--line-strong); background: transparent; color: var(--soft); justify-content: center; min-height: 58px; font-size: .92em; }
.cpuadd { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cpuadd .btn { justify-content: flex-start; text-align: left; min-height: 60px; padding: .5em .8em; }
.cpuadd .btn span { display: flex; flex-direction: column; line-height: 1.15; }
.cpuadd .btn small { font-family: var(--font); font-weight: 400; font-size: .76em; opacity: .7; }
.tip { display: flex; align-items: center; gap: 8px; color: var(--soft); font-size: .9em; margin: 14px 0 0; }

/* ---------- results ---------- */
.over { text-align: center; }
.winner { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 16px; }
.winner .cup { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold) 60%, var(--gold-deep)); color: #2a1f00; box-shadow: 0 5px 0 #8a6400, 0 0 40px rgba(255,207,51,.45); animation: cup .6s cubic-bezier(.2,1.5,.4,1) both; }
.winner .cup .ic { width: 48px; height: 48px; stroke-width: 2.2; }
@keyframes cup { from { transform: scale(.3) rotate(-20deg); opacity: 0; } }
.winner h2 { margin: 4px 0 0; font-family: var(--display); font-weight: 700; font-size: 2.1em; line-height: 1.1; color: var(--gold); text-shadow: 0 2px 0 #6e5000; text-wrap: balance; }
.wins { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; font-size: 1.05em; }
.winrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 16px; border-radius: var(--r-md); background: rgba(255,255,255,.06); border: 1px solid transparent; font-weight: 700; }
.winrow .wn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winrow .wc { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.winrow.win { background: rgba(255,207,51,.14); border-color: rgba(255,207,51,.4); color: var(--gold-hi); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }

/* ---------- rack color picker ---------- */
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 4px 0 6px; }
.swatches.row8 { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.swatch {
  padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-1); transition: transform .12s ease, box-shadow .12s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch .sw-top { height: 20px; background: linear-gradient(var(--rk-hi), var(--rk)); box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.swatch .sw-edge { flex: 1 0 auto; height: 24px; background: linear-gradient(var(--rk), var(--rk-lo)); color: var(--rk-text); font-family: var(--display); font-weight: 600; font-size: 11px; display: grid; place-items: center; }
.swatch.on { box-shadow: 0 0 0 2px #06231a, 0 0 0 5px var(--gold); }
@media (max-width: 520px) { .swatches.row8 .sw-edge { font-size: 0; height: 16px; } .swatches.row8 .sw-top { height: 12px; } }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: rgba(6, 18, 12, .96); color: #fff; border: 1px solid var(--line-strong); border-radius: 14px;
  padding: .7em 1.1em; font-weight: 700; font-size: 1.02em; max-width: min(90vw, 560px); text-align: left;
  box-shadow: var(--shadow-3); animation: toastin .2s ease-out;
}
#toast .ic { color: var(--gold); width: 1.4em; height: 1.4em; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- the MJ signature move ---------- */
#mj {
  position: fixed; inset: 0; z-index: 80; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 65%);
}
#mj .sig {
  font-family: 'Yellowtail', 'Brush Script MT', cursive; font-size: min(42vw, 260px); line-height: 1;
  color: var(--gold); transform: rotate(-8deg);
  text-shadow: 0 4px 0 #a66f00, 0 0 24px rgba(255,212,0,.8), 0 8px 18px rgba(0,0,0,.6);
  -webkit-text-stroke: 3px #3a2400; padding: 0 .2em;
}
#mj .swoosh { width: min(70vw, 420px); margin-top: -2vw; transform: rotate(-6deg); overflow: visible; }
#mj .swoosh path { fill: none; stroke: var(--gold); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 340; stroke-dashoffset: 340; filter: drop-shadow(0 2px 2px rgba(0,0,0,.6)); }
#mj .by { margin-top: 10px; font-family: var(--display); font-size: 1.4em; font-weight: 700; color: #fff; background: rgba(0,0,0,.85); border: 2px solid var(--gold); border-radius: 999px; padding: .25em 1em; }
#mj.play .sig { animation: mjin .55s cubic-bezier(.2, 1.6, .4, 1) both, mjout .4s ease-in 2.75s forwards; }
#mj.play .swoosh path { animation: sign .5s ease-out .35s forwards; }
#mj.play .swoosh, #mj.play .by { animation: mjout .4s ease-in 2.75s forwards; }
/* "3 tiles left" / "Last tile!": a card in that player's rack colour drops in near the top of the screen,
   their remaining tiles standing on it, holds for a moment, then lifts away. The last tile also glows gold. */
/* someone drew a tile: a quick pop-up in their rack colour, with a face-down tile dropping in */
#drewPop { position: fixed; left: 0; right: 0; top: 34%; z-index: 77; pointer-events: none; display: flex; justify-content: center; padding: 0 16px; }
#drewPop .dp-card {
  display: flex; align-items: center; gap: 14px; padding: 10px 22px 10px 12px; border-radius: 18px; max-width: 460px;
  background: linear-gradient(180deg, var(--rk-hi) 0%, var(--rk) 50%, var(--rk-lo) 100%); color: var(--rk-text);
  border: 2px solid var(--rk-deep); box-shadow: 0 14px 32px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.4);
}
#drewPop .dp-tile {
  flex: none; display: grid; place-items: center; width: 34px; height: 46px; border-radius: 7px; color: #8a6b2b;
  background: linear-gradient(180deg, #fff 0, var(--tile-face) 20%, var(--tile-low) 75%, var(--tile-side) 100%);
  box-shadow: inset 0 0 0 1px rgba(120,95,40,.25), 0 3px 0 var(--tile-side-dark), 0 5px 8px rgba(0,0,0,.35);
  font-family: var(--display); font-size: 1.3em;
}
#drewPop .dp-tile .ic { width: 20px; height: 20px; }
#drewPop .dp-text { font-family: var(--display); font-weight: 700; font-size: 1.45em; line-height: 1.1; overflow-wrap: anywhere; }
#drewPop .dp-text small { display: block; font-family: inherit; font-weight: 600; font-size: .55em; opacity: .8; }
#drewPop.play .dp-card { animation: alin .45s cubic-bezier(.2, 1.5, .4, 1) both, alout .4s ease-in 1.75s forwards; }
#drewPop.play .dp-tile { animation: dpdrop .55s cubic-bezier(.2, 1.6, .4, 1) .1s both; }
@keyframes dpdrop { from { transform: translateY(-30px) rotate(-14deg); opacity: 0; } to { transform: none; opacity: 1; } }

#alert {
  position: fixed; left: 0; right: 0; top: 30%; z-index: 78; pointer-events: none;
  display: flex; justify-content: center; padding: 0 16px;
}
#alert .al-card {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 18px;
  padding: 14px 28px 14px 18px; border-radius: 22px; max-width: 560px;
  background: linear-gradient(180deg, var(--rk-hi) 0%, var(--rk) 45%, var(--rk-lo) 100%);
  color: var(--rk-text); border: 2px solid rgba(255,255,255,.45);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.55), inset 0 -4px 0 var(--rk-deep), 0 4px 0 var(--rk-deep), 0 18px 40px rgba(0,0,0,.55);
}
#alert .al-tiles { display: flex; gap: 5px; flex: none; padding: 6px 8px 8px; border-radius: 12px; background: rgba(0,0,0,.18); box-shadow: inset 0 2px 6px rgba(0,0,0,.3); }
#alert .al-tiles i {
  width: 30px; height: 40px; border-radius: 6px;
  background: linear-gradient(180deg, #fff 0, var(--tile-face) 20%, var(--tile-low) 75%, var(--tile-side) 100%);
  box-shadow: inset 0 0 0 1px rgba(120,95,40,.25), 0 3px 0 var(--tile-side-dark), 0 5px 8px rgba(0,0,0,.35);
}
#alert .al-text { display: flex; flex-direction: column; min-width: 0; }
#alert .al-text b { font-family: var(--display); font-weight: 700; font-size: 2.1em; line-height: 1.05; letter-spacing: .01em; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
#alert .al-text span { font-weight: 700; font-size: 1em; opacity: .85; overflow-wrap: anywhere; }
#alert .al-shine {
  position: absolute; inset: 0; pointer-events: none; transform: translateX(-120%);
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
}
#alert.one .al-card { border-color: var(--gold); }
#alert.one .al-tiles i { width: 38px; height: 51px; }
#alert.play .al-card { animation: alin .6s cubic-bezier(.2, 1.5, .4, 1) both, alout .45s ease-in 2.6s forwards; }
#alert.one.play .al-card { animation: alin .6s cubic-bezier(.2, 1.5, .4, 1) both, alglow 1s ease-in-out .6s 2, alout .45s ease-in 3.1s forwards; }
#alert.play .al-tiles i { animation: altile .5s cubic-bezier(.2, 1.6, .4, 1) both; }
#alert.play .al-tiles i:nth-child(2) { animation-delay: .08s; }
#alert.play .al-tiles i:nth-child(3) { animation-delay: .16s; }
#alert.one.play .al-tiles i { animation: altile .5s cubic-bezier(.2, 1.6, .4, 1) both, albob .5s ease-in-out .6s 4 alternate; }
#alert.play .al-shine { animation: alshine .9s ease-out .45s both; }
@keyframes alin { from { transform: translateY(-60px) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes alout { to { transform: translateY(-40px) scale(.9); opacity: 0; } }
@keyframes altile { from { transform: translateY(-24px) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes albob { to { transform: translateY(-5px); } }
@keyframes alglow { 50% { box-shadow: inset 0 2px 0 rgba(255,255,255,.55), inset 0 -4px 0 var(--rk-deep), 0 4px 0 var(--rk-deep), 0 0 0 6px rgba(255,207,51,.55), 0 0 40px rgba(255,207,51,.8); } }
@keyframes alshine { to { transform: translateX(120%); } }
@media (max-width: 640px) {
  #alert { top: 27%; }
  #alert .al-card { gap: 12px; padding: 10px 18px 10px 12px; border-radius: 18px; }
  #alert .al-text b { font-size: 1.6em; }
  #alert .al-tiles i { width: 22px; height: 30px; }
  #alert.one .al-tiles i { width: 30px; height: 40px; }
}
@keyframes mjin { from { transform: scale(.2) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(-8deg); opacity: 1; } }
@keyframes sign { to { stroke-dashoffset: 0; } }
@keyframes mjout { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .seat.turn, .winner .cup, #toast, .tile.fresh { animation: none; }
  .seat.turn { box-shadow: 0 0 0 2px var(--gold), var(--shadow-2); }
  #mj.play .sig { animation: mjout .4s ease-in 2.75s forwards; }
  #mj .swoosh path { stroke-dashoffset: 0; }
  #alert.play .al-card, #alert.one.play .al-card, #alert.play .al-tiles i, #alert.one.play .al-tiles i, #alert.play .al-shine { animation: none; }
  #alert.play .al-shine { display: none; }
  #confetti { display: none; }
}

/* ---------- short screens: the join card tightens so it never needs scrolling ---------- */
@media (max-height: 860px) {
  #join { padding: 12px 16px; gap: 8px; }
  .joinbox { padding: 18px 22px 20px; gap: 4px; }
  .logo { --tw: 46px; --th: 62px; margin: 0 0 2px; }
  .title { font-size: 2em; }
  .joinbox label { margin-top: 8px; }
  .joinbox input:not([type]) { font-size: 1.2em; padding: .35em .6em; }
  .tagline, .fieldhint, .joinfoot { display: none; }
  .joinbox .swatches .sw-top { height: 12px; }
  .joinbox .swatches .sw-edge { height: 18px; }
  .btn.huge { min-height: 54px; }
  .winner { flex-direction: row; justify-content: center; gap: 12px; }
  .winner .cup { width: 46px; height: 46px; box-shadow: 0 3px 0 #8a6400; }
  .winner .cup .ic { width: 26px; height: 26px; }
  .winner h2 { font-size: 1.45em; margin: 0; }
  .over .btn.huge { min-height: 50px; margin-top: 4px; }
}

/* ---------- phones, tablets and narrow windows: one slim strip of faces across the top ---------- */
@media (max-width: 1099px) {
  body { font-size: calc(17px * var(--zoom)); }
  header { padding: 6px 8px; gap: 8px; position: relative; }
  .hright { width: auto; }   /* phones: the faces strip sits just under the buttons */
  .brandname, .tname, .hlabel { display: none; }
  .hbtn { min-height: 40px; padding: .25em .7em; font-size: .88em; }
  .popover { top: 54px; right: 8px; padding: 6px 14px 12px; }
  #game { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "head" "left" "main" "foot"; }
  #seatsR { display: none; }
  #seatsL { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, clamp(92px, 13vw, 132px)); justify-content: center; gap: 6px; padding: 8px 8px 0; }
  .seat { padding: 3px; gap: 3px; border-radius: 12px; max-height: none; box-shadow: var(--shadow-1); }
  .face { flex: none; height: calc(clamp(54px, 8vw, 78px) * var(--zoom)); min-height: 0; border-radius: 9px; }
  .avatar { justify-content: flex-start; padding-top: 7cqh; }
  .avatar .mono { --d: min(50cqh, 44cqw); font-size: min(30cqh, 26cqw); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 2px rgba(255,255,255,.16); }
  .avatar small { display: none; }
  .nm { display: block; }
  .minirack { margin: 0; }
  .minirack .mini-edge { display: none; }
  .minirack { perspective: 160px; }
  .minirack::after { bottom: -3px; height: 6px; filter: blur(3px); }
  .minirack .backs { --rowh: 6px; --rowgap: 2px; min-height: 12px; padding: 2px 3px 1px; gap: var(--rowgap) 1px; border-radius: 4px 4px 2px 2px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 0 var(--rk-deep); }
  .minirack .backs i { border-radius: 1px; box-shadow: 0 1px 0 var(--tile-side-dark); }
  .open30 { top: auto; bottom: 3px; right: 3px; font-size: 10.5px; padding: 0 6px 0 4px; gap: 2px; }
  .face:has(.open30.show) .nm { padding-right: 44px; }
  .seat .tag, .seats .seat .tag { display: none; }
  .seat.mic-off .face::before { bottom: auto; top: 3px; right: 3px; width: 18px; height: 18px; background-size: 12px; }
  .seat.turn .flag { display: none; }
  .seatwins, .seat.turn .seatwins { top: 3px; left: 3px; font-size: 10.5px; padding: 0 5px 0 3px; gap: 2px; }
  main { padding: 8px; }
  main.mat { margin: 8px 8px 0; }
  main.mat .board { --edge: 6px; border-radius: 6px; }
  footer { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
  #mySeat { display: none; }
  .rack { padding: 8px 8px 0; border-radius: 14px 14px 10px 10px; }
  .rack .edge { margin: 0 -8px; height: 38px; padding: 0 10px; gap: 8px; }
  .sortbtn { font-size: .78em; padding: .1em .55em; min-height: 28px; }
  #rackTools { gap: 6px; }
  .setrow { padding: 7px 0; }
  .volrow { min-height: 32px; }
  .volrow input[type=range] { height: 30px; }
  .panelhead .badge { width: 46px; height: 46px; }
  .title { font-size: 2.2em; }
  .logo { --tw: 54px; --th: 72px; }
}
/* phones: the turn buttons fill one row, the small ones as icons */
@media (max-width: 640px) {
  #controls { left: 12px; right: 12px; width: auto; transform: none; gap: 8px; }
  #controls .btn { padding: 0 .4em; min-width: 34px; flex: 0 1 auto; }
  #controls .btn.go, #controls .btn.draw { min-width: 0; padding: 0 .5em; min-height: 48px; }
  #rackTools .long { display: none; }
  #rackTools .sortbtn .ic { display: block; }
  #rackSizeBox .ic { display: none; }
  #rackTools .sortbtn { padding: .1em .45em; }
  #controls .btn.draw .cnt { display: none; }
  #controls .btn.go, #controls .btn.draw { flex: 1 1 0; }
  #controls .long, #rackInfo .long { display: none; }
  #controls .turnchip { flex: 0 1 auto; min-width: 0; }
  #controls .poolchip { margin-right: auto; }
  .sortbtn .ic { display: none; }
  .sortbtn.undo .ic { display: block; }
}

/* The waiting room and results size themselves to the space in the middle of the table (which is narrow on a
   laptop with faces down both sides), not to the whole screen. The script sets .compact when that space is
   under 960px times the text size, so bigger text switches to one column sooner instead of spilling over. */
  main.compact .lobby, main.compact .over { padding: 16px 16px 18px; }
  main.compact .lobby { grid-template-columns: minmax(0, 1fr); max-width: calc(520px * var(--zoom)); }
  main.compact .lobby .panelhead { margin-bottom: 0; gap: 10px; }
  main.compact .lobby .panelhead p, main.compact .lobby .panelhead .badge, main.compact .lobby .invite, main.compact .lobbyfoot, main.compact .cpusec.full { display: none; }
  main.compact .headact { display: flex; }
  main.compact .headact .btn { min-height: 42px; }
  main.compact .pchip .pt { display: none; }
  main.compact .players { gap: 6px; }
  main.compact .lobby .panelhead h2 { font-size: 1.35em; }
  main.compact .lobby .section, main.compact .lobby .lcol:last-child .section:first-child { margin-top: 12px; }
  main.compact .lobby .section h3 { margin-bottom: 6px; }
  main.compact .pchip { padding: 5px 8px; gap: 8px; min-height: 44px; }
  main.compact .pchip .av { width: calc(30px * var(--zoom)); height: calc(30px * var(--zoom)); font-size: 1em; }
  main.compact .pchip.cpu .av .ic { width: 19px; height: 19px; }
  main.compact .pchip .av .lvl { min-width: 15px; height: 15px; line-height: 15px; font-size: 9.5px; right: -5px; bottom: -5px; }
  main.compact .pchip .pn { font-size: .95em; }
  main.compact .pchip .rm { width: calc(32px * var(--zoom)); height: calc(32px * var(--zoom)); }
  main.compact .pchip.empty-seat { min-height: 44px; }
  main.compact .cpuadd { gap: 6px; }
  main.compact .cpuadd .btn { min-height: 46px; padding: .3em .5em; justify-content: center; }
  main.compact .cpuadd .btn small { display: none; }
  main.compact .swatches.row8 { gap: 5px; }
  main.compact .swatches.row8 .sw-top { height: 12px; }
  main.compact .swatches.row8 .sw-edge { height: 16px; font-size: 0; }
  main.compact .lobby .btn.huge { margin-top: 14px; min-height: 54px; font-size: 1.15em; }
  main.compact .winner { gap: 6px; margin-bottom: 8px; }
  main.compact .winner .cup { width: 64px; height: 64px; }
  main.compact .winner .cup .ic { width: 36px; height: 36px; }
  main.compact .winner h2 { font-size: 1.6em; }
  main.compact .over .btn.huge { min-height: 54px; }
/* shorter screens squeeze a little more, so these screens never need scrolling */
@media (max-height: 700px) {
  main.compact .lobby .section, main.compact .lobby .lcol:last-child .section:first-child { margin-top: 8px; }
  main.compact .lobby .section h3 { margin-bottom: 4px; }
  main.compact .pchip, main.compact .pchip.empty-seat { min-height: 38px; padding: 3px 8px; }
  main.compact .pchip .av { width: calc(28px * var(--zoom)); height: calc(28px * var(--zoom)); }
  main.compact .pchip .rm { width: calc(30px * var(--zoom)); height: calc(30px * var(--zoom)); }
  main.compact .cpuadd .btn { min-height: 42px; }
  main.compact .lobby .btn.huge { margin-top: 10px; min-height: 50px; }
}

/* ---------- helper view: sign-in in Settings, the notice, and the viewer ---------- */
#helpBox { padding: 8px 0 10px; }
#helpBox:empty { display: none; }
.helpin summary { display: flex; align-items: center; gap: .6em; cursor: pointer; color: var(--soft); font-size: .88em; list-style: none; min-height: 28px; }
.helpin summary::-webkit-details-marker { display: none; }
.helpin summary .ic { width: 1.1em; height: 1.1em; }
#helpForm { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 6px; }
#helpForm input { min-width: 0; font: inherit; font-size: .95em; padding: .4em .6em; border-radius: var(--r-sm); border: 2px solid transparent; background: #fff; color: #111; }
#helpForm input:focus { outline: none; border-color: var(--gold); }
#helpForm .btn { min-height: 38px; font-size: .88em; padding: 0 .9em; }
#helpBox .setlabel { display: flex; }
.linkbtn { margin-left: auto; background: none; border: 0; padding: 4px 0; color: var(--soft); font: inherit; font-size: .85em; font-weight: 400; text-decoration: underline; cursor: pointer; }
.helplist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.helplist .btn { min-height: 38px; font-size: .9em; padding: 0 .9em; }
.helpnone { color: var(--soft); font-size: .9em; }
.helpshare { margin-top: 10px; }
.helpshare .btn { min-height: 40px; font-size: .9em; padding: 0 1em; }
.helpshare .btn.on { --b-top: #ffd0cc; --b-bot: #ffb4ae; --b-ink: #7a1008; }

/* the helper's screen, shared with everyone: big over the table, or small in the bottom right corner */
#shareView { position: fixed; inset: 12px; z-index: 80; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden;
  background: rgba(3, 14, 10, .96); box-shadow: 0 0 0 3px var(--gold), var(--shadow-3); }
#shareView[hidden] { display: none; }
.shhead { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; }
.shtitle { flex: 1 1 0; min-width: 0; font-family: var(--display); font-weight: 700; font-size: 1.15em; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shhead .btn { min-height: 40px; padding: 0 1em; font-size: .9em; flex: none; }
.shstage { position: relative; flex: 1 1 0; min-height: 0; background: #000; display: grid; place-items: center; overflow: hidden; }
.shnote { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.shnote[hidden], .shwrap[hidden] { display: none; }
.shwrap { position: relative; overflow: hidden; }
.shwrap iframe { display: block; border: 0; transform-origin: 0 0; pointer-events: none; }
/* their mouse: a big white arrow with a dark edge and a gold glow, easy to follow; it pulses when they click */
.shptr { position: absolute; left: 0; top: 0; z-index: 2; width: 46px; height: 46px; margin: -3px 0 0 -6px; pointer-events: none;
  fill: #fff; stroke: #111; stroke-width: 2; stroke-linejoin: round; overflow: visible;
  filter: drop-shadow(0 0 5px rgba(255,207,51,.95)) drop-shadow(0 3px 4px rgba(0,0,0,.6));
  transform-origin: 6px 3px; transition: left .07s linear, top .07s linear; }
.shptr[hidden] { display: none; }
.shptr.down { animation: ptrdown .45s ease-out; }
@keyframes ptrdown { 0% { transform: scale(1); } 30% { transform: scale(.78); fill: var(--gold); } 100% { transform: scale(1); } }
#shareView.small { inset: auto 12px 12px auto; width: min(340px, 45vw); height: auto; }
#shareView.small .shhead { padding: 4px 4px 4px 10px; }
#shareView.small .shtitle { font-size: .85em; }
#shareView.small .shhead .btn { min-height: 32px; font-size: .8em; }
#shareView.small .shstage { flex: none; aspect-ratio: var(--ar, 16 / 10); cursor: zoom-in; }
#shareView.small .shptr { width: 30px; height: 30px; }
#shareMine {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 85; max-width: calc(100vw - 16px);
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: #fff7d6; color: #2a2000; border: 2px solid var(--gold); box-shadow: var(--shadow-2); font-size: .9em;
}
#shareMine[hidden] { display: none; }
#shareMine .ic { width: 1.2em; height: 1.2em; vertical-align: -.22em; margin-right: .45em; }
#shareMine .btn { min-height: 34px; padding: 0 1em; font-size: .9em; flex: none; }
#helpBox .helpstats { margin-top: 10px; padding-bottom: 0; border-top: 1px solid var(--line); border-bottom: 0; }
#statsBtn:disabled { opacity: .5; cursor: not-allowed; }

#helpBanner {
  position: fixed; left: 50%; top: 8px; transform: translateX(-50%); z-index: 85; max-width: calc(100vw - 16px);
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: #fff7d6; color: #2a2000; border: 2px solid var(--gold); box-shadow: var(--shadow-2); font-size: .9em; line-height: 1.25;
}
#helpBanner span { display: block; }
#helpBanner .ic { width: 1.2em; height: 1.2em; vertical-align: -.22em; margin-right: .45em; }
#helpBanner .btn { min-height: 34px; padding: 0 1em; font-size: .9em; flex: none; }

#viewer { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: rgba(3, 14, 10, .94); backdrop-filter: blur(6px); }
.vhead { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.vtitle { font-family: var(--display); font-weight: 700; font-size: 1.15em; color: var(--gold); white-space: nowrap; }
.vinfo { flex: 1 1 0; min-width: 0; color: var(--muted); font-size: .82em; line-height: 1.3; }
.vhead .btn { min-height: 40px; padding: 0 .9em; font-size: .9em; flex: none; }
.vstage { flex: 1 1 0; min-height: 0; display: grid; place-items: center; padding: 12px; overflow: hidden; }
.vnote { color: var(--muted); text-align: center; max-width: 30em; text-wrap: balance; }
.vwrap { position: relative; overflow: hidden; border-radius: 10px; box-shadow: 0 0 0 2px var(--gold), var(--shadow-3); background: #000; }
.vwrap iframe { display: block; border: 0; transform-origin: 0 0; pointer-events: none; }
/* what the helper sees in place of a tile in the hand, or a camera picture */
.tile.hid { background: repeating-linear-gradient(135deg, #e9dfc4 0 6px, #ded2b2 6px 12px); cursor: default; }
.vidph { position: absolute; inset: 0; display: grid; place-items: center; background: #1c2a25; color: var(--soft); font-size: .75em; text-align: center; }
/* on a phone the notice sits under the top bar, so Camera and Settings stay reachable */
@media (max-width: 640px) {
  #helpBanner { top: 56px; border-radius: 16px; width: calc(100vw - 16px); justify-content: space-between; font-size: .85em; }
  .vhead { flex-wrap: wrap; gap: 4px 10px; }
  .vinfo { order: 3; flex-basis: 100%; }
  .vhead .btn { margin-left: auto; }
  #helpForm { grid-template-columns: 1fr 1fr; }
  #helpForm .btn { grid-column: 1 / -1; }
}

/* ---------- statistics (the statistics login) ---------- */
#stats { position: fixed; inset: 0; z-index: 88; display: grid; place-items: center; padding: 16px; background: rgba(2, 12, 8, .6); }
.stcard { width: min(760px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; padding: 8px 20px 18px; background: linear-gradient(180deg, #123b2c, #0b281d); }
.stcard .pophead b { display: inline-flex; align-items: center; gap: .45em; color: var(--gold); }
.stbody { overflow: auto; margin: 0 -8px; padding: 0 8px; }
.stbody h3 { margin: 18px 0 8px; font-family: var(--display); font-size: .78em; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stbox { padding: 10px 12px; border-radius: var(--r-md); background: rgba(255,255,255,.06); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.stbox span { color: var(--soft); font-size: .78em; }
.stbox b { font-family: var(--display); font-size: 1.45em; line-height: 1.1; }
.stbox b small { font-family: var(--font); font-size: .55em; font-weight: 400; color: var(--soft); }
.sttable { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line); }
.sttable table { width: 100%; border-collapse: collapse; font-size: .85em; }
.sttable th, .sttable td { padding: 7px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sttable thead th { color: var(--soft); font-weight: 400; font-size: .85em; }
.sttable tbody th { text-align: left; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.sttable tbody tr:last-child > * { border-bottom: 0; }
.sttable tr.me { background: rgba(255, 207, 51, .1); }
.sttable .ic { width: 1.1em; height: 1.1em; color: #3ddc84; }
.sturn { font-style: normal; color: var(--gold); font-size: .8em; }
.coach { display: flex; flex-direction: column; gap: 4px; }
.strow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border-radius: var(--r-md); background: rgba(255,255,255,.05); border: 1px solid var(--line); cursor: default; }
label.strow { cursor: pointer; }
.strow > div { display: flex; flex-direction: column; min-width: 0; }
.strow span { color: var(--soft); font-size: .82em; }
.strow .btn { flex: none; min-height: 40px; font-size: .88em; padding: 0 1em; }
.stnote { color: var(--muted); margin: 10px 0; display: flex; align-items: center; gap: .5em; }
.sthint { color: var(--soft); font-size: .8em; margin: 4px 2px 6px; }
.stres { padding: 4px 4px 10px; }
.stres p { margin: 8px 0 6px; }
.stgood b { color: #5ee89a; }
.stbad b { color: #ffcf33; }
.stres .btn.small { min-height: 34px; font-size: .82em; }
.stres .sthow { display: none; }
.stres.open .sthow { display: block; }
.msets { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; }
.mset { display: flex; gap: 2px; padding: 4px; border-radius: 8px; background: rgba(0,0,0,.18); }
.mset.changed { box-shadow: inset 0 0 0 1px rgba(255, 207, 51, .45); }
.mt {
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; letter-spacing: -.04em; width: 24px; height: 32px; border-radius: 4px;
  background: linear-gradient(180deg, var(--tile-face), var(--tile-low)); box-shadow: 0 2px 0 var(--tile-side-dark);
  font-family: var(--font); font-weight: 700; font-size: 15px; line-height: 1;
}
.mt.c0 { color: var(--t0); } .mt.c1 { color: var(--t1); } .mt.c2 { color: var(--t2); } .mt.c3 { color: var(--t3); }
.mt.joker { color: var(--t1); }
.mt .jface { width: 80%; aspect-ratio: 1; box-shadow: 0 0 0 1.5px var(--t1); }
.mt.hi { box-shadow: 0 0 0 2px var(--gold), 0 2px 0 var(--tile-side-dark); }

/* the best play, shown during each of my turns */
#coachCard {
  position: fixed; left: 12px; z-index: 30; width: min(380px, calc(100vw - 24px)); max-height: 40vh; overflow: auto;
  padding: 8px 12px 10px; border-radius: 16px; background: rgba(8, 30, 22, .94); border: 1px solid rgba(255, 207, 51, .45);
  box-shadow: var(--shadow-3);
}
/* tiles can still be dropped on the table underneath it; only its button takes clicks */
#coachCard { pointer-events: none; }
#coachCard .iconbtn { pointer-events: auto; }
.cchead { display: flex; align-items: center; gap: 10px; }
.cchead b { display: inline-flex; align-items: center; gap: .4em; color: var(--gold); font-family: var(--display); }
.cchead span { flex: 1; color: var(--muted); font-size: .85em; }
.cchead .iconbtn { width: 32px; height: 32px; transform: rotate(90deg); transition: transform .15s; }
#coachCard.folded .cchead .iconbtn { transform: rotate(-90deg); }
#coachCard.folded .msets, #coachCard.folded .sthint { display: none; }
#coachCard .mt { width: 20px; height: 27px; font-size: 13px; }
@media (max-width: 640px) {
  .stcard { padding: 6px 12px 12px; }
  .stgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strow { flex-wrap: wrap; }
  #coachCard { left: 8px; right: 8px; width: auto; max-height: 30vh; }
}

/* the tile count beside each player's little rack */
.minirack .mcount {
  position: absolute; right: -6px; top: -8px; z-index: 2; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 15px; line-height: 1;
  background: #fff; color: #14261c; box-shadow: 0 0 0 2px var(--rk-deep), 0 3px 6px rgba(0,0,0,.4);
}
@media (max-width: 1099px) {
  .minirack .mcount { right: -3px; top: -6px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 4px; }
}

/* a cheater: a red stamp across their face, for everyone */
.face .stamp { display: none; }
.seat.cheat .face .stamp {
  display: block; position: absolute; left: 50%; top: 46%; z-index: 4; transform: translate(-50%, -50%) rotate(-14deg);
  padding: .1em .45em; border: 3px solid #e3262a; border-radius: 6px; background: rgba(255,255,255,.88);
  color: #d4001a; font-family: var(--display); font-weight: 700; font-size: min(22cqh, 15cqw); letter-spacing: .08em; text-transform: uppercase;
  box-shadow: 0 3px 10px rgba(0,0,0,.4); pointer-events: none;
}
/* the end of the game: how many times each player switched on cheat mode */
.cheattally { display: flex; flex-direction: column; gap: 4px; margin: -2px 0 14px; padding: 10px 14px; border-radius: var(--r-md); background: rgba(212,0,26,.14); border: 1px solid rgba(255,80,90,.45); text-align: left; }
.cheattally > b { display: flex; align-items: center; gap: .5em; color: #ff8a92; font-size: .85em; text-transform: uppercase; letter-spacing: .06em; }
.cheattally > b .ic { width: 1.1em; height: 1.1em; }
.cheattally span { font-size: .95em; }
.cheattally span b { color: #ff8a92; font-size: 1.15em; }
.cheattag { font-style: normal; font-size: .72em; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: #d4001a; border-radius: 5px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
#shame {
  position: fixed; inset: 0; z-index: 82; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(80,0,0,.55) 0%, rgba(0,0,0,0) 65%);
}
#shame .sh-stamp {
  font-family: var(--display); font-weight: 700; font-size: min(18vw, 130px); line-height: 1; text-transform: uppercase; letter-spacing: .06em;
  color: #e3262a; padding: .05em .3em; border: .07em solid #e3262a; border-radius: .12em; background: rgba(255,255,255,.92);
  transform: rotate(-10deg); box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#shame .sh-by { margin-top: 26px; font-family: var(--display); font-size: 1.3em; font-weight: 700; color: #fff; background: rgba(0,0,0,.85); border: 2px solid #e3262a; border-radius: 999px; padding: .25em 1em; text-align: center; max-width: calc(100vw - 32px); }
#shame.play .sh-stamp { animation: shin .5s cubic-bezier(.2, 1.5, .4, 1) both, mjout .4s ease-in 2.9s forwards; }
#shame.play .sh-by { animation: mjout .4s ease-in 2.9s forwards; }
@keyframes shin { from { transform: scale(2.6) rotate(-25deg); opacity: 0; } to { transform: scale(1) rotate(-10deg); opacity: 1; } }

/* statistics: the coach on top, a plain yes or no, and the replay */
.stbody h3.first { margin-top: 14px; }
.strow .warn { display: block; font-style: normal; color: #ff8a80; font-weight: 700; margin-top: 2px; }
.stanswer { padding: 10px 4px 8px; }
.stanswer b { display: inline-block; font-family: var(--display); font-size: 1.6em; padding: .1em .8em; border-radius: 12px; }
.stanswer.yes b { background: #25a84e; color: #fff; }
.stanswer.no b { background: rgba(255,255,255,.1); color: #ffcf33; }
.replay { margin-top: 6px; padding: 10px 12px 12px; border-radius: var(--r-md); background: rgba(0,0,0,.22); border: 1px solid var(--line); }
.rp-cap { margin: 0 0 10px; font-weight: 700; min-height: 2.6em; }
.rp-table { display: flex; flex-wrap: wrap; gap: 8px 12px; min-height: 44px; align-items: flex-start; }
.rp-rack { margin-top: 12px; padding: 8px 10px 10px; border-radius: 10px; background: linear-gradient(180deg, #4a4a4a, #2a2a2a); }
.rp-rack > span { display: block; font-size: .75em; color: rgba(255,255,255,.75); margin-bottom: 4px; }
.rp-rack { --mtw: 24px; overflow-x: auto; }
.rp-grid { display: grid; gap: 4px 3px; }
.rp-grid .mt, .rp-slot { width: var(--mtw); }
.rp-slot { display: block; height: 32px; border-radius: 4px; background: rgba(0,0,0,.22); box-shadow: inset 0 1px 3px rgba(0,0,0,.35); }
.replay .mt { position: relative; }
.replay .mt.moving { z-index: 2; }
.rp-ctl { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.rp-sp { flex: 1; }
.rp-arrow { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.1); }
.rp-arrow:not(.next) .ic { transform: scaleX(-1); }
.rp-arrow[disabled] { opacity: .3; cursor: default; }
.rp-dots { display: flex; gap: 6px; }
.rp-dots button { width: 12px; height: 12px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.25); cursor: pointer; }
.rp-dots button.on { background: var(--gold); }

/* the Fit button while the table is zoomed out */
#controls .btn.on { background: linear-gradient(var(--gold-hi), var(--gold)); color: #2a1f00; border-color: var(--gold-deep); }

/* the box drawn with the mouse to choose several tiles */
.marquee { position: fixed; z-index: 45; pointer-events: none; border: 2px solid var(--pick); background: rgba(30, 123, 255, .14); border-radius: 4px; }
body.banding, body.banding * { cursor: crosshair !important; user-select: none !important; }

/* the Statistics row in Settings */
.setlink { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); color: inherit; font: inherit; text-align: left; }
.setlink:hover .setlabel { color: var(--gold-hi); }
.setlink > .ic { color: var(--soft); width: 1.1em; height: 1.1em; }

/* the Space tile, in the bottom-right corner of the rack: dotted, in the rack's own printing color */
.spacetile {
  position: absolute; z-index: 3; width: var(--tw); height: var(--th); box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--tw) * .06);
  border: 3px dashed currentColor; border-radius: calc(var(--tw) * .16); color: var(--rk-text);
  background: rgba(255,255,255,.14); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  opacity: .85; transition: opacity .15s, transform .15s;
}
.spacetile:hover { opacity: 1; transform: translateY(-2px); }
.spacetile .ic { width: calc(var(--tw) * .5); height: calc(var(--tw) * .5); stroke-width: 2.4; }
.spacetile small { font-family: var(--display); font-weight: 700; font-size: calc(var(--tw) * .2); letter-spacing: .06em; line-height: 1; }
.spacetile.away { opacity: .3; }
.spacetile.carried {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; cursor: grabbing; opacity: .97;
  transition: none;   /* follows the pointer straight away, like a carried tile */
  color: #1e7bff; background: rgba(255,255,255,.85);
  filter: drop-shadow(4px 12px 9px rgba(0,0,0,.4)) drop-shadow(0 2px 2px rgba(0,0,0,.2));
}
/* where the space will open: a blue bar down the left side of the tile */
.tile.spacemark { box-shadow: -7px 0 0 -1px #1e7bff, 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.32) !important; }

/* who put tiles down: each tile outlined in their rack colour, and their name across the bottom of their tiles */
.tile .byring {
  position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; z-index: 1;
  box-shadow: 0 0 0 3.5px var(--rk), 0 0 0 5px var(--rk-deep), 0 0 14px 4px var(--rk);
}
.board .byname, .pickboard .byname {
  position: absolute; z-index: 4; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  max-width: 12em; overflow: hidden; text-overflow: ellipsis;
  padding: 2px 9px; border-radius: 999px; background: linear-gradient(var(--rk-hi), var(--rk)); color: var(--rk-text);
  box-shadow: 0 0 0 1.5px var(--rk-deep), 0 3px 6px rgba(0,0,0,.4);
  font-family: var(--display); font-weight: 800; font-size: max(11px, calc(var(--tw) * .24)); line-height: 1.15;
}
@keyframes byOut { to { opacity: 0; } }

/* drawing for who goes first: face-down tiles scattered over the table, turned over one by one */
.pickboard { position: relative; margin: 0 auto; border-radius: 8px; background: rgba(0, 0, 0, .2);
  box-shadow: 0 0 0 10px rgba(0, 0, 0, .2), 0 0 0 11.5px rgba(255,255,255,.12); }
.pkmsg { position: absolute; left: 0; right: 0; top: 12px; z-index: 6; text-align: center; pointer-events: none;
  font-family: var(--display); font-weight: 700; font-size: clamp(20px, 3.2vw, 34px); color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.pkmsg b { color: var(--gold); }
.pkmsg.won { animation: pkpop .5s ease both; }
@keyframes pkpop { from { transform: scale(.7); opacity: 0; } }
.pkw { position: absolute; width: var(--tw); height: var(--th); }
.pk { position: absolute; inset: 0; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit;
  transform: rotate(var(--rot)); perspective: 700px; cursor: default; transition: transform .25s; }
.pkw.up .pk, .pkw.anim .pk { transform: rotate(0deg); }   /* turned over: straightened up so it reads easily */
.pkw.can .pk { cursor: pointer; }
.pkw.can .pk:hover, .pkw.can .pk:focus-visible { transform: rotate(var(--rot)) translateY(-6px) scale(1.06); outline: none; }
.pkw.can .pk-back { box-shadow: inset 0 0 0 2px rgba(255,207,51,.0), 0 2px 0 var(--tile-side), 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.32); }
.pkw.can .pk:hover .pk-back { box-shadow: 0 0 0 3px var(--gold), 0 3px 0 var(--tile-side-dark), 0 0 18px rgba(255,207,51,.6); }
.pk-in { position: absolute; inset: 0; transform-style: preserve-3d; }
.pkw.up .pk-in { transform: rotateY(180deg); }
.pkw.anim .pk-in { animation: pkflip 1.1s cubic-bezier(.3,.7,.3,1) var(--age, 0ms) both; }
@keyframes pkflip {
  0% { transform: translateZ(0) rotateY(0); }
  35% { transform: translateZ(90px) rotateY(80deg); }
  70% { transform: translateZ(40px) rotateY(195deg); }
  100% { transform: translateZ(0) rotateY(180deg); }
}
.pk-back, .pk-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.pk-front { transform: rotateY(180deg); }
.pk-front .tile { cursor: default; }
.pk-back {
  border-radius: calc(var(--tw) * .16);
  background: radial-gradient(circle at 50% 50%, rgba(0,0,0,.08) 0 18%, transparent 19%), repeating-linear-gradient(135deg, #efe5ca 0 6px, #e2d6b5 6px 12px);
  box-shadow: inset 0 1px 0 #fff, inset 0 0 0 1px rgba(150,125,70,.25), 0 2px 0 var(--tile-side), 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.32);
}
.pkname { left: 50%; top: calc(100% + 14px); }
.pkw.anim .pkname { animation: pkname .3s ease calc(var(--age, 0ms) + .8s) both; }
@keyframes pkname { from { opacity: 0; } }
.pkw.old { opacity: .4; }
.pkw.lose { opacity: .55; }
.pkw.win { z-index: 5; }
.pkw.win .pk-front .tile { box-shadow: 0 0 0 4px var(--gold), 0 0 26px 8px rgba(255,207,51,.7), 0 4px 0 var(--tile-side-dark); }
.pkw.tie .pk-front .tile { box-shadow: 0 0 0 3px #ff9a3d, 0 0 16px 4px rgba(255,154,61,.6), 0 4px 0 var(--tile-side-dark); }
/* someone else's turn: the tiles they are carrying, and the faded spots they were lifted from */
.board .tile.peerlifted { opacity: .3; }
.peerhand { position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; transition: transform .1s linear; filter: drop-shadow(4px 12px 9px rgba(0,0,0,.4)); }
.peerhand .tile { position: absolute; }

/* (kept last so it wins over the normal tile styles; highlights like a selected or just-placed tile still show) */
/* dark tiles: charcoal faces with light numbers; the black tiles' numbers turn white, the colors brighten a little */
html.dark {
  --tile-face: #3a3c40;
  --tile-mid: #303236;
  --tile-low: #26282b;
  --tile-side: #17181a;
  --tile-side-dark: #050506;
  --t0: #f4f4f4;
  --t1: #ff4d5e;
  --t2: #5cb8ff;
  --t3: #ff8a33;
}
:where(html.dark) .tile { box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 1px rgba(255,255,255,.08), 0 2px 0 var(--tile-side), 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.5); }
:where(html.dark) .tile.sel { background: linear-gradient(#24364f, #1a2a40); box-shadow: 0 3px 0 #0c1626, 0 12px 16px rgba(0,0,0,.55); }
:where(html.dark) .tile.hid { background: repeating-linear-gradient(135deg, #34363a 0 6px, #2a2c2f 6px 12px); }
html.dark .pk-back { background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.06) 0 18%, transparent 19%), repeating-linear-gradient(135deg, #36383c 0 6px, #2b2d30 6px 12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 1px rgba(255,255,255,.08), 0 2px 0 var(--tile-side), 0 3px 0 var(--tile-side-dark), 0 5px 7px rgba(0,0,0,.5); }
html.dark .minirack .backs i, html.dark #drewPop .dp-tile, html.dark #alert .al-tiles i {
  background: linear-gradient(180deg, #55585d 0, var(--tile-face) 20%, var(--tile-low) 75%, var(--tile-side) 100%);
}
html.dark #drewPop .dp-tile { color: #d8c79a; }

/* dark mode: a dark tint over your rack's color (the plastic, its edge and its buttons), with light writing */
html.dark .rack {
  background:
    linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,.55)),
    linear-gradient(165deg, rgba(255,255,255,.34) 0%, rgba(255,255,255,0) 26%),
    linear-gradient(180deg, var(--rk-hi) 0%, var(--rk) 40%, var(--rk) 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.18), inset 0 -2px 0 rgba(0,0,0,.4), var(--shadow-2);
}
html.dark .rack .edge {
  background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,.55)), linear-gradient(180deg, var(--rk) 0%, var(--rk-lo) 65%, color-mix(in srgb, var(--rk-lo), var(--rk-deep)));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 4px 0 color-mix(in srgb, var(--rk-deep), #000 55%);
}
html.dark .sortbtn:not(.on):not(.undo) {
  background: linear-gradient(rgba(0,0,0,.45), rgba(0,0,0,.45)), linear-gradient(var(--rk-hi), var(--rk));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 2px 0 color-mix(in srgb, var(--rk-deep), #000 55%);
}
html.dark .rack .rackmsg, html.dark #rackInfo, html.dark .sortbtn:not(.on):not(.undo), html.dark #rackSizeBox { color: #f2f2f2; }
html.dark #rackSizeBox input { accent-color: #f2f2f2; }

/* Settings scroll when they're taller than the screen */
#settings { max-height: calc(100vh - 74px); max-height: calc(100dvh - 74px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (max-width: 1099px) { #settings { max-height: calc(100vh - 62px); max-height: calc(100dvh - 62px); } }

/* Settings: which microphone, and its test */
.micsel { width: 100%; margin-top: 8px; font: inherit; font-size: .95em; padding: .45em .6em; border-radius: var(--r-sm); border: 2px solid transparent; background: #fff; color: #111; min-height: 40px; }
.micsel:focus { outline: none; border-color: var(--gold); }
.mictest { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin-top: 8px; }
.mictest .btn { min-height: 38px; font-size: .9em; padding: 0 .9em; }
.micmeter { height: 12px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.micmsg { margin: 6px 0 0; color: var(--soft); font-size: .85em; }
.micmeter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2fa35a, var(--gold)); transition: width .06s linear; }

/* Big Z's list: view a screen, mute or unmute */
.helprows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.helprow { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.helprow .btn { min-height: 38px; font-size: .9em; padding: 0 .9em; }
.helprow .btn[data-view] { justify-content: flex-start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.helprow .hmic { min-width: 7.5em; justify-content: center; }

/* Nina: her own tiles face down on her screen */
#rack.hidetiles .grooves .tile > *, .hand.hidetiles .ttile .dm > * { visibility: hidden; }
#rack.hidetiles .grooves .tile { background: repeating-linear-gradient(45deg, var(--tile-mid) 0 6px, var(--tile-low) 6px 12px); }
.hand.hidetiles .ttile .dm { background: repeating-linear-gradient(45deg, #eee6d2 0 6px, #d9cfb6 6px 12px); }

/* Audrey's quick peek */
.peekbox { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.45); }
.peekbox[hidden] { display: none; }
.peekcard { max-width: min(96vw, 900px); max-height: 90vh; overflow: auto; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px; --tw: 40px; --dw: 24px; }
.peekhead { display: flex; align-items: center; gap: .5em; font-family: var(--display); font-size: 1.15em; }
.peekhead .ic { width: 1.2em; height: 1.2em; color: var(--gold); }
.peekgrid { display: grid; gap: 5px; justify-content: center; }
.peekgrid .tile { cursor: default; }
.peekdm { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.peekrow { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.peekgap { width: calc(var(--dw) * 2.2); }
.peekbar { height: 5px; border-radius: 999px; background: rgba(0,0,0,.2); overflow: hidden; }
.peekbar i { display: block; height: 100%; background: var(--gold); animation: peekdown var(--peekms, 5000ms) linear forwards; }
@keyframes peekdown { from { width: 100%; } to { width: 0; } }
@media (max-width: 640px) { .peekcard { --tw: 28px; --dw: 16px; } }
