/* Layout: a card-room table. Felt fills the middle, bots sit on three sides,
   the player's dock (seat strip, action panel, hand) runs along the bottom,
   and a paper score sheet sits on the right (a drawer on phones).
   Single deliberate dark theme: the felt is the page. */
:root {
  --felt: #133a3b;
  --felt-deep: #0c2829;
  --felt-line: #2a5a59;
  --paper: #f6efdf;
  --paper-edge: #dccfb1;
  --ink: #1f1b16;
  --ink-soft: #5d5446;
  --brass: #c9a24a;
  --brass-bright: #e6c674;
  --red: #b4282a;
  --text: #e9e3d3;
  --text-dim: #a8b6ae;
  --good: #7fc79a;
  --bad: #ef8a7a;
  --shadow: rgba(0, 0, 0, .45);

  --f-display: "Alegreya SC", "Iowan Old Style", Georgia, serif;
  --f-body: "Alegreya Sans", "Gill Sans", "Segoe UI", system-ui, sans-serif;

  --cw: clamp(52px, 6.4vw, 88px);
  --ch: calc(var(--cw) * 1.55);
  --radius: calc(var(--cw) * .09);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--felt-deep);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
h2 { font-family: var(--f-display); font-weight: 500; letter-spacing: .04em; font-size: 1.05rem; margin: 0; color: var(--brass-bright); }

#app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "table side" "dock side";
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, .06), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 5px),
    var(--felt);
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--felt-line);
  background: rgba(0, 0, 0, .18);
  min-width: 0;
}
.brand { display: flex; align-items: baseline; gap: 8px; flex: none; }
.brand-mark {
  font-family: var(--f-display); font-weight: 700; font-size: .8rem;
  color: var(--ink); background: var(--paper); border: 1px solid var(--brass);
  padding: 1px 5px; border-radius: 3px;
}
.brand-name { font-family: var(--f-display); font-size: 1.35rem; letter-spacing: .06em; color: var(--paper); }
.status { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .9rem; color: var(--text-dim); }
.status b { color: var(--text); font-weight: 500; }
.status .chip { white-space: nowrap; }
.tools { display: flex; gap: 6px; flex: none; }

.btn {
  border: 1px solid var(--brass); background: var(--brass); color: var(--ink);
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-weight: 500;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--brass-bright); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--felt-line); }
.btn.ghost:hover { border-color: var(--brass); color: var(--brass-bright); background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible, .card:focus-visible, .group:focus-visible { outline: 2px solid var(--brass-bright); outline-offset: 2px; }

/* ------------------------------------------------------------------ table */
.table {
  grid-area: table;
  position: relative;
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(0, 3fr) minmax(90px, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tl top tr" "left center right";
  padding: 10px 16px 0;
  min-height: 0;
}
.seat-top { grid-area: top; justify-self: center; }
.seat-left { grid-area: left; align-self: center; justify-self: start; }
.seat-right { grid-area: right; align-self: center; justify-self: end; }
.center { grid-area: center; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }

.seat {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative; text-align: center;
}
.nameplate {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px; border-radius: 999px;
  background: rgba(0, 0, 0, .28); border: 1px solid var(--felt-line);
  transition: border-color .2s, box-shadow .2s;
}
.seat.turn .nameplate { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(201, 162, 74, .25); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; color: var(--ink);
  background: var(--paper); border: 2px solid var(--paper-edge);
}
.seat.turn .avatar { border-color: var(--brass); }
.who { text-align: left; line-height: 1.15; }
.who .nm { font-weight: 700; color: var(--paper); }
.who .meta { font-size: .78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.role { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: 1px 6px; border-radius: 3px; margin-left: 4px; vertical-align: 1px; }
.role.decl { background: var(--brass); color: var(--ink); }
.role.partner { background: var(--paper); color: var(--ink); }
.role.def { border: 1px solid var(--felt-line); color: var(--text-dim); }
.radl { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: -1px; }
.radl i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--brass-bright); display: inline-block; }

.backs { display: flex; height: calc(var(--ch) * .5); }
.backs .card { --cw: calc(clamp(52px, 6.4vw, 88px) * .5); margin-left: calc(var(--cw) * -.72); }
.backs .card:first-child { margin-left: 0; }
.seat-left .backs, .seat-right .backs { order: 2; }
.open-hand { display: flex; flex-wrap: wrap; justify-content: center; max-width: calc(var(--cw) * 4.4); gap: 2px; }
.open-hand .card { --cw: calc(clamp(52px, 6.4vw, 88px) * .52); }

.bubble {
  position: absolute; z-index: 20; white-space: nowrap;
  background: var(--paper); color: var(--ink); font-weight: 700;
  padding: 4px 10px; border-radius: 10px; box-shadow: 0 4px 12px var(--shadow);
  animation: pop .25s ease-out;
  pointer-events: none;
}
.seat-top .bubble { top: 100%; margin-top: 6px; }
.seat-left .bubble { left: 0; top: -34px; }
.seat-right .bubble { right: 0; top: -34px; }
.seat-bottom .bubble { bottom: 100%; margin-bottom: 6px; left: 50%; transform: translateX(-50%); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.seat-bottom .bubble { animation: none; }

/* ------------------------------------------------------------------ cards */
.card {
  --fs: calc(var(--cw) * .2);
  position: relative; flex: none;
  width: var(--cw); height: calc(var(--cw) * 1.55);
  border-radius: calc(var(--cw) * .09); /* per card, so small cards get small corners */
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  box-shadow: 0 2px 5px var(--shadow);
  color: var(--ink);
  font-family: var(--f-display);
  user-select: none;
  overflow: hidden;
  isolation: isolate; /* the index and name plate stay inside their own card when cards overlap */
}
.card.red { color: var(--red); }
.card .ix { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: .95; font-size: var(--fs); font-weight: 700; }
.card .ix i { font-style: normal; font-family: var(--f-body); font-size: calc(var(--fs) * .95); }
.card .tl { top: calc(var(--cw) * .05); left: calc(var(--cw) * .06); }
.card .br { bottom: calc(var(--cw) * .05); right: calc(var(--cw) * .06); transform: rotate(180deg); }
.card .ix { z-index: 1; padding: calc(var(--cw) * .015) calc(var(--cw) * .02); border-radius: calc(var(--cw) * .04); background: var(--card-bg, var(--paper)); }
.card { --card-bg: var(--paper); }
/* Long tarok numerals are set narrower so they still fit the strip a fanned hand shows. */
.card .ix.l3 b { font-size: calc(var(--fs) * .9); }
.card .ix.l4 b { font-size: calc(var(--fs) * .78); letter-spacing: -.03em; }
.card .ix.l5 b { font-size: calc(var(--fs) * .68); letter-spacing: -.04em; }
.card.tarok {
  --card-bg: #f8f0dc;
  background: linear-gradient(180deg, #fbf5e6, #efe2c2);
  box-shadow: inset 0 0 0 calc(var(--cw) * .045) var(--paper), inset 0 0 0 calc(var(--cw) * .06) #b89a5a, 0 2px 5px var(--shadow);
}
/* The trula's name sits on a plate over the foot of the picture, clear of the corner index. */
.card.tarok .tname {
  position: absolute; z-index: 1; left: 50%; bottom: 16.5%; transform: translateX(-50%);
  padding: calc(var(--cw) * .012) calc(var(--cw) * .05); border: 1px solid #a8802c; border-radius: calc(var(--cw) * .03);
  background: var(--card-bg); color: #6b4b10;
  font-size: calc(var(--cw) * .12); font-weight: 700; line-height: 1.1; white-space: nowrap;
}
.card.trula { --card-bg: #fbefcc; background: linear-gradient(180deg, #fff6dc, #ecd396); }

/* Illustrations (js/art.js): a 100 x 120 drawing centred on the card. */
.card .art { position: absolute; left: 8%; top: 50%; width: 84%; height: auto; transform: translateY(-50%); overflow: visible; }
.card .art.pip-art { left: 22%; width: 56%; }
.art {
  --a-ink: #2a2118; --a-gold: #d9a93f; --a-yellow: #f0c64a; --a-red: #b8352d; --a-blue: #3f74a8; --a-green: #5d9147;
  --a-green2: #9cc46f; --a-white: #fbf7ee; --a-wood: #9a6b3c; --a-sky: #e6eef1; --a-night: #22324c;
}
.art .fr { fill: var(--a-sky); stroke: #b89a5a; stroke-width: 1.6; }
.art .fr.night { fill: var(--a-night); }
.art .fr.court { fill: #f3e6c8; }
.art.trula-art .fr { stroke: #a8802c; stroke-width: 2.2; }
.art [class] { stroke-linejoin: round; stroke-linecap: round; }
.art .k, .art .kl, .art .kt, .art .kd { fill: none; stroke: var(--a-ink); stroke-width: 1.6; }
.art .kl { stroke-width: 1; }
.art .kt { stroke-width: 3; }
.art .kd { stroke-width: 1.2; }
.art .ks { fill: none; stroke: #8a6a2c; stroke-width: 2.4; }
.art .kv { fill: none; stroke: #3f6e33; stroke-width: 1.6; }
.art .kw { fill: none; stroke: #fff; stroke-width: 1.4; }
.art .rl { fill: none; stroke: var(--a-red); stroke-width: 1.6; }
.art .ant { fill: none; stroke: #7a5530; stroke-width: 3.2; }
.art .ray { fill: none; stroke: #e0a530; stroke-width: 2.6; }
.art .kf { fill: var(--a-ink); }
.art .g, .art .y, .art .r, .art .b, .art .v, .art .v2, .art .w, .art .wd, .art .m, .art .gd, .art .gr, .art .p, .art .st, .art .beard, .art .nv {
  stroke: var(--a-ink); stroke-width: 1.3;
}
.art .g { fill: var(--a-gold); }
.art .y { fill: var(--a-yellow); }
.art .r { fill: var(--a-red); }
.art .b { fill: var(--a-blue); }
.art .v { fill: var(--a-green); }
.art .v2 { fill: var(--a-green2); }
.art .w { fill: var(--a-white); }
.art .wd { fill: var(--a-wood); }
.art .m { fill: #a6b5c3; }
.art .gd { fill: #cddba3; }
.art .gr { fill: #8d8f93; }
.art .p { fill: #6b3b74; }
.art .st { fill: #b9c0c8; }
.art .beard { fill: #ece6dc; }
.art .nv { fill: #2f4a3a; }
.art .hl { fill: #fff; opacity: .55; }
.art .beam { fill: var(--a-yellow); opacity: .32; }
.art .cheek { fill: #e88a7a; opacity: .55; }
.art .hornout { fill: none; stroke: var(--a-ink); stroke-width: 8; }
.art .hornin { fill: none; stroke: var(--a-gold); stroke-width: 5.4; }
.art .dot { fill: #fff; }
.art .pr { fill: var(--red); }
.art .pk { fill: var(--ink); }
.card.back {
  background:
    radial-gradient(circle at 50% 50%, transparent 30%, rgba(0, 0, 0, .18) 31% 33%, transparent 34%),
    repeating-linear-gradient(45deg, #1d4d4c 0 3px, #163d3c 3px 6px);
  border: 2px solid var(--paper-edge);
  box-shadow: inset 0 0 0 2px #163d3c, inset 0 0 0 3px var(--brass), 0 2px 4px var(--shadow);
}
.card.mini { --cw: 34px; box-shadow: 0 1px 2px var(--shadow); }
.card.mini .ix.br { display: none; }
.card.mini .tname { display: none; }
/* Mini cards (reviews, talon): a larger index on top, the picture below it. */
.card.mini { --fs: calc(var(--cw) * .3); }
.card.mini .ix { padding: 0 1px; line-height: 1.05; }
.card.mini .tl { top: 2px; left: 2px; }
.card.mini .art { left: 10%; width: 80%; top: auto; bottom: 5%; transform: none; }
.card.mini.pips .art { left: 26%; width: 56%; }
.card.mini.pips .ix i { display: none; }

/* ------------------------------------------------------------- center area */
.trick {
  position: relative;
  width: calc(var(--cw) * 3.9); height: calc(var(--cw) * 1.55 * 2.1);
}
.trick .card { position: absolute; left: 50%; top: 50%; margin-left: calc(var(--cw) * -.5); margin-top: calc(var(--cw) * -.775); }
.trick .s0 { transform: translate(0, 46%); }
.trick .s1 { transform: translate(92%, 0) rotate(5deg); }
.trick .s2 { transform: translate(0, -46%); }
.trick .s3 { transform: translate(-92%, 0) rotate(-5deg); }
.trick .card.enter { animation: enter .28s ease-out; }
.trick .s0.enter { --fx: 0; --fy: 160%; }
.trick .s1.enter { --fx: 260%; --fy: 0; }
.trick .s2.enter { --fx: 0; --fy: -160%; }
.trick .s3.enter { --fx: -260%; --fy: 0; }
@keyframes enter { from { translate: var(--fx) var(--fy); opacity: .2; } to { translate: 0 0; opacity: 1; } }
.trick .card.win { box-shadow: 0 0 0 2px var(--brass-bright), 0 6px 16px var(--shadow); z-index: 5; }
.trick.sweep { animation: sweep .42s ease-in forwards; }
.trick.sweep .card.enter { animation: none; }
.trick.sweep.to0 { --sx: 0; --sy: 70%; }
.trick.sweep.to1 { --sx: 80%; --sy: 0; }
.trick.sweep.to2 { --sx: 0; --sy: -70%; }
.trick.sweep.to3 { --sx: -80%; --sy: 0; }
@keyframes sweep { to { translate: var(--sx) var(--sy); scale: .6; opacity: 0; } }

.talon-view { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.talon-view .caption { color: var(--text-dim); font-size: .9rem; }
.groups { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.group {
  display: flex; gap: 3px; padding: 6px; border-radius: 10px;
  border: 1px dashed var(--felt-line); background: rgba(0, 0, 0, .15);
}
.group.pickable { cursor: pointer; border-style: solid; }
.group.pickable:hover { border-color: var(--brass); background: rgba(201, 162, 74, .12); transform: translateY(-2px); }
.group.chosen { border: 2px solid var(--brass-bright); background: rgba(201, 162, 74, .18); }
.group.rejected { opacity: .45; }
.groups .card { --cw: clamp(44px, 5vw, 70px); }
.center-note { max-width: 28rem; text-align: center; color: var(--text-dim); }
.center-note h3 { font-family: var(--f-display); color: var(--paper); font-weight: 500; font-size: 1.4rem; margin: 0 0 4px; }
.talon-strip { position: absolute; left: 0; top: 4px; display: flex; gap: 3px; align-items: center; font-size: .75rem; color: var(--text-dim); }

/* -------------------------------------------------------------------- dock */
.dock { grid-area: dock; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 16px 12px; min-width: 0; }
.seat-bottom { flex-direction: row; }
.panel {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  min-height: 40px; max-width: 100%;
}
.panel .prompt { color: var(--paper); font-weight: 500; margin-right: 4px; }
.panel .hint { color: var(--text-dim); font-size: .88rem; }
.bidbtn { display: flex; flex-direction: column; align-items: center; line-height: 1.05; padding: 5px 12px; }
.bidbtn small { font-size: .72rem; opacity: .75; font-weight: 400; }
.annopt { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--felt-line); border-radius: 6px; cursor: pointer; background: rgba(0, 0, 0, .2); }
.annopt:has(input:checked) { border-color: var(--brass); background: rgba(201, 162, 74, .16); }
.annopt input { accent-color: var(--brass); }

.hand { position: relative; height: calc(var(--cw) * 1.55 + 16px); width: 100%; max-width: 1100px; }
.hand .card { position: absolute; bottom: 0; transition: transform .15s, filter .15s, opacity .15s; }
.hand .card.playable { cursor: pointer; }
.hand .card.playable:hover { transform: translateY(-12px); }
.hand.myturn .card:not(.playable) { filter: brightness(.62) saturate(.6); }
.hand .card.selected { transform: translateY(-14px); box-shadow: 0 0 0 2px var(--brass-bright), 0 6px 14px var(--shadow); }
.hand .card.suggest { box-shadow: 0 0 0 3px var(--good), 0 6px 14px var(--shadow); transform: translateY(-8px); }
.hand .card.dealt { animation: deal .35s ease-out backwards; }
@keyframes deal { from { transform: translateY(40px); opacity: 0; } }

/* ----------------------------------------------------------------- sidebar */
.sidebar {
  grid-area: side; min-height: 0; overflow-y: auto;
  background: var(--paper); color: var(--ink);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  border-left: 1px solid var(--paper-edge);
}
.sidebar h2 { color: var(--ink); border-bottom: 1px solid var(--paper-edge); padding-bottom: 4px; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; }
.sidebar-head h2 { border: 0; padding: 0; }
.close-side { display: none; color: var(--ink); border-color: var(--paper-edge); }
.sheet { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .86rem; }
.sheet th { font-family: var(--f-display); font-weight: 500; text-align: right; padding: 2px 4px; border-bottom: 1.5px solid var(--ink); }
.sheet th:first-child, .sheet td:first-child { text-align: left; }
.sheet td { text-align: right; padding: 2px 4px; border-bottom: 1px solid var(--paper-edge); }
.sheet th:first-child { width: 34%; }
.sheet td.c { color: var(--ink-soft); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet tr.total td { font-weight: 700; font-size: 1rem; border-bottom: 0; border-top: 1.5px solid var(--ink); }
.sheet tr.radl td { border: 0; }
.sheet .pos { color: #1f7a45; }
.sheet .neg { color: var(--red); }
.sheet .radl i { border-color: var(--ink); width: 8px; height: 8px; }
.sheet-wrap { max-height: 46vh; overflow-y: auto; overflow-x: hidden; }
.cc { display: inline-block; font-family: var(--f-display); font-weight: 700; color: var(--ink); background: #fffaf0; border: 1px solid var(--paper-edge); border-radius: 3px; padding: 0 3px; line-height: 1.25; font-size: .8rem; }
.cc.red { color: var(--red); }
.cc.tk { background: #f3e6c4; }
.minis { display: inline-flex; flex-wrap: wrap; gap: 2px; vertical-align: middle; }
.log { list-style: none; margin: 0; padding: 0; font-size: .84rem; display: flex; flex-direction: column; gap: 3px; color: var(--ink-soft); }
.log li b { color: var(--ink); font-weight: 700; }
.log li.sep { margin-top: 6px; font-family: var(--f-display); color: var(--ink); border-top: 1px dashed var(--paper-edge); padding-top: 4px; }

/* ------------------------------------------------------------------- modal */
.modal-back { position: fixed; inset: 0; background: rgba(4, 16, 16, .66); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal {
  background: var(--paper); color: var(--ink); border-radius: 12px;
  width: min(640px, 100%); max-height: 100%; overflow-y: auto;
  padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  border: 1px solid var(--brass);
}
.modal h2 { font-size: 1.6rem; color: var(--ink); text-wrap: balance; margin-bottom: 6px; }
.modal h3 { font-family: var(--f-display); font-weight: 500; margin: 16px 0 6px; font-size: 1.1rem; }
.modal p { margin: 6px 0; max-width: 65ch; }
.modal .sub { color: var(--ink-soft); }
.modal .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal .btn.ghost { color: var(--ink); border-color: var(--paper-edge); }
.modal .btn.ghost:hover { border-color: var(--brass); color: var(--ink); }
.lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lines td { padding: 4px 2px; border-bottom: 1px solid var(--paper-edge); }
.lines td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.deltas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.deltas div { border: 1px solid var(--paper-edge); border-radius: 8px; padding: 6px 8px; text-align: center; }
.deltas .n { font-size: .8rem; color: var(--ink-soft); }
.deltas .v { font-family: var(--f-display); font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.v.pos { color: #1f7a45; } .v.neg { color: var(--red); }
.form { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: center; }
.form select, .form input { font: inherit; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--paper-edge); background: #fffaf0; color: var(--ink); color-scheme: light; }
.rules { font-size: .94rem; }
.rules ul { margin: 4px 0 8px; padding-left: 20px; }
.rules table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .9rem; }
.rules td, .rules th { border-bottom: 1px solid var(--paper-edge); padding: 3px 6px; text-align: left; }
.trick-review { display: flex; flex-direction: column; gap: 4px; }
.trick-review .row { display: flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--ink-soft); }
.trick-review .row > span:first-child { width: 7.5rem; flex: none; }
.trick-review .card.mini.w { box-shadow: 0 0 0 2px var(--brass); }
details summary { cursor: pointer; font-family: var(--f-display); margin-top: 12px; }

/* ----------------------------------------------------------------- phones */
@media (max-width: 860px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "table" "dock"; }
  .sidebar { position: fixed; inset: 0 0 0 auto; width: min(340px, 92vw); z-index: 60; transform: translateX(105%); transition: transform .25s; box-shadow: -10px 0 30px var(--shadow); }
  .sidebar.open { transform: none; }
  .close-side { display: inline-block; }
  .brand-name { display: none; }
}
@media (min-width: 861px) { #btn-scores { display: none; } }
@media (max-width: 600px) {
  :root { --cw: clamp(40px, 11.5vw, 58px); }
  body { font-size: 14px; }
  .topbar { flex-wrap: wrap; gap: 6px 10px; padding: 6px 12px; }
  .status { order: 3; flex-basis: 100%; font-size: .8rem; }
  .tools .btn { padding: 4px 8px; font-size: .82rem; }
  .table { grid-template-columns: minmax(64px, 1fr) minmax(0, 2.6fr) minmax(64px, 1fr); padding: 6px 8px 0; }
  .who .meta { display: none; }
  .nameplate { flex-direction: column; padding: 4px 6px; border-radius: 10px; gap: 2px; }
  .who { text-align: center; }
  .role { margin-left: 0; display: table; margin-inline: auto; margin-top: 2px; }
  .who br { display: none; }
  .trick { width: calc(var(--cw) * 3.2); }
  .trick .s1 { transform: translate(64%, 0) rotate(5deg); }
  .trick .s3 { transform: translate(-64%, 0) rotate(-5deg); }
  .backs { display: none; }
  .dock { padding: 4px 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------- multiplayer */
.tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-left: 5px; }
.seatbtn {
  margin-left: 4px; padding: 2px 8px; border-radius: 999px; cursor: pointer; font-size: .75rem;
  border: 1px solid var(--brass); background: transparent; color: var(--brass-bright);
}
.seatbtn:hover { background: var(--brass); color: var(--ink); }
.seatbtn:focus-visible, .linkbtn:focus-visible { outline: 2px solid var(--brass-bright); outline-offset: 2px; }
.linkbtn { border: 0; background: none; padding: 0 0 0 4px; color: var(--brass-bright); cursor: pointer; text-decoration: underline; font-size: inherit; }
.tables { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.table-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--paper-edge); border-radius: 8px; padding: 6px 6px 6px 10px; }
.table-row span { min-width: 0; }
.modal .note { background: #f3e6c4; border-radius: 6px; padding: 6px 10px; }
.copyfield { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--paper-edge); border-radius: 6px; background: #fffaf0; color: var(--ink); color-scheme: light; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 200;
  background: var(--paper); color: var(--ink); padding: 8px 14px; border-radius: 8px; box-shadow: 0 6px 20px var(--shadow); font-weight: 500;
}
.modal .actions .sub { margin-right: auto; align-self: center; }
