/* Michigan Rummy's table, on the card room's felt (../cards/cards.css) and
   its table styles (../cards/themes.css): only what the card room doesn't
   already draw. No colors of its own; everything comes from the style's
   tokens, so it reads in all nine.

   Steadiness first, as in Contract Rummy: the table fills the window; the
   pile row, your hand and the bottom panel never change size; every
   player's tile is sized from the number of players and the window alone.
   Everything that comes and goes (a pile card lifting, a "Play here"
   button, badges) appears in space already set aside for it or floats over
   the table, so nothing you might be about to click moves. */

.felt.mrummy { position: relative; height: calc(100dvh - 2 * var(--frame)); min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.felt.mrummy.docked { grid-template-columns: minmax(0, 1fr) 300px; }
.mrummy .tablemain { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
.mrummy .logdock { min-height: 0; display: flex; flex-direction: column; }
.mrummy .logdock:empty { display: none; }
.mrummy .logdock .gamelog { flex: 1; }
.mrummy .gamelog.drawer {
  position: absolute; z-index: 30; right: 14px; top: 64px; bottom: 260px; width: min(340px, calc(100% - 28px));
  box-shadow: -10px 10px 30px rgba(0, 0, 0, .35);
}
.mrummy .logbtn.on { background: var(--pick-tint); box-shadow: var(--pick-ring); }

/* ── the board: the pile row over everyone's tiles ───────────────────── */
.mrummy .board { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; gap: 8px; }

/* The stock, then the discard pile spread out beside it. The pile's cards
   are a little smaller than your hand's, so the tiles keep their room. */
.mrummy .pilerow {
  --pw: clamp(40px, calc(var(--cw) * .78), 80px);
  flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: end;
  padding: 6px 8px 4px; border-radius: 14px; background: color-mix(in srgb, var(--panel) 55%, transparent);
}
.mrummy .stockspot { width: calc(var(--pw) + 24px); display: flex; justify-content: center; }
.mrummy .stockspot .pile { width: 100%; }
.mrummy .pilerow .card, .mrummy .pilerow .empty-slot { --cw: var(--pw); }
.mrummy .pilerow .empty-slot { width: var(--pw); height: calc(var(--pw) * 1.4); }
.mrummy .stockspot .pile .count { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrummy .spread { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* one line over the pile: how many, or what taking the card pointed at
   would bring (always one line, so the pile never moves) */
.mrummy .pilehead { height: 1.45em; font-size: var(--t-note); line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* (on a phone the pile's line is given two, always, so what the top card's free for isn't cut short and nothing moves) */
@media (max-width: 640px) { .mrummy .pilehead { height: 2.9em; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } }
.mrummy .pilehead .pcount { white-space: nowrap; }
.mrummy .pilehead .pickline { font-weight: 700; color: var(--ink); }
.mrummy .pilehead .pickline.no { color: var(--soft); font-weight: 600; }
/* The pile, oldest at the left: each card overlaps the one before by as
   much as the row needs (--step: how much of each shows; table.js fitFan),
   and the row scrolls once that's as tight as it reads. Room above for a
   card to lift, and below for the marks. */
.mrummy .pilefan {
  display: flex; align-items: flex-end; padding: 14px 4px 10px; min-height: calc(var(--pw) * 1.4 + 24px);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scroll-behavior: auto;
}
.mrummy .pilefan .card { transition: transform .12s ease, opacity .12s ease; }
.mrummy .pilefan .card + .card { margin-left: calc(var(--step, calc(var(--pw) * .6)) - var(--pw)); box-shadow: var(--card-shadow), -2px 0 3px -1px rgba(0, 0, 0, .35); }
.mrummy .pilefan .card:not(:last-child) .pip { visibility: hidden; }
.mrummy .pilefan.live .card { cursor: pointer; }
/* pointing at a card (or having chosen it): it and every card above it lift */
.mrummy .pilefan .card.coming { transform: translateY(-8px); }
.mrummy .pilefan .card.chosen { transform: translateY(-12px); }
.mrummy .pilefan .card.deepest { outline: 3px solid var(--turn); outline-offset: 1px; }
/* the helper: a turn-yellow bar under each card you could take, across the
   strip of it that shows */
.mrummy .pilefan .card.can::after {
  content: ''; position: absolute; left: 6%; bottom: -8px; width: min(calc(var(--step, 30px) - 8px), 88%); height: 4px; border-radius: 2px;
  background: var(--turn);
}
.mrummy .pilefan .card:last-child.can::after { width: 88%; }
.mrummy .pilefan .card.cant { filter: saturate(.75) brightness(.92); }
.mrummy .pilefan .card:focus-visible { outline: 2px solid var(--focus, var(--ink)); outline-offset: 3px; }
.mrummy .pilefan.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.mrummy .pilefan.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }
.mrummy .pilefan.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }

/* ── everyone's tiles: their melds, their score ───────────────────────── */
.mrummy .tilewrap {
  flex: 1; min-height: 0; min-width: 0; overflow: hidden auto; scrollbar-gutter: stable; scrollbar-width: thin;
  padding: 6px 6px 6px; display: flex; flex-direction: column; gap: 8px;
}
.mrummy .tile.me { background: color-mix(in srgb, var(--ink) 9%, var(--panel)); }
.mrummy .tile .youmark { font-weight: 400; color: var(--soft); }
.mrummy .tilehead { position: relative; }
.mrummy .tilehead .who { column-gap: .6em; }
.mrummy .tilehead .who > .name { min-width: min(5em, 100%); }
/* (the count is never cut: it keeps its width, the name gives way, and when even that won't fit it loses its "cards": fitCounts) */
.mrummy .tilehead .who > .count { min-width: auto; flex: none; overflow: visible; text-overflow: clip; }
.mrummy .tilehead .count.short .cw { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mrummy .tilehead .name.bare .youmark { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* the score: the total, and this hand's melded points beside it */
.mrummy :is(.tilehead, .seat) .pts { flex: none !important; min-width: 0 !important; font-variant-numeric: tabular-nums; font-size: 13px; }
.mrummy :is(.tilehead, .seat) .pts .house-figure { font-size: var(--t-figure); }
/* (a phone's chip is one of four in a row at 375px: its figure is a size smaller, still the heaviest thing on it) */
.mrummy .seat .pts .house-figure { font-size: var(--t-label); }
.mrummy :is(.tilehead, .seat) .pts small { color: var(--soft); font-weight: 700; font-size: 12px; }
/* the race to the target, a hairline under the header in the seat's color */
.mrummy .tilehead .meter { position: absolute !important; left: 30px; right: 0; bottom: -5px; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 14%, transparent); overflow: hidden; }
.mrummy .tilehead .meter::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: var(--seat); border-radius: 2px; }
.mrummy .seat .meter { display: none; }
.mrummy .tile.away :is(.face, .who) { opacity: .6; }
.mrummy .tilebody { overflow: hidden auto; scrollbar-width: thin; padding-top: 6px; }
.mrummy .notyet { margin: 0; height: 100%; display: grid; place-items: center; color: var(--soft); font-size: var(--t-note); }
.mrummy .landed { animation: landed 1.3s ease-out; }
@keyframes landed { 15%, 40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 70%, transparent), 0 0 22px 4px color-mix(in srgb, var(--ink) 30%, transparent); } }

/* melds: wrapped along the tile, cards the size the tiles allow (table.js layout) */
.mrummy .meldlist { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px 8px; }
.mrummy .meld { position: relative; padding: 2px; border-radius: 9px; border: 2px solid transparent; }
.mrummy .meld.target { border-color: var(--ink); }
.mrummy .meld.dim { opacity: .45; }
.mrummy .meld .cards { position: relative; }
.mrummy .meld .cards .card + .card { margin-left: calc(var(--step, calc(var(--cw-small) * .5)) - var(--cw-small)); }
.mrummy .landing { visibility: hidden; }
/* a card played by someone other than the meld's owner: a dot in their
   color, in the card's empty bottom-left corner (it scores for them) */
.mrummy .meld .card.laid::before {
  content: ''; position: absolute; left: 5%; bottom: 5%; width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot); box-shadow: 0 0 0 1.5px #111;
}
.mrummy .meld .plus {
  position: absolute; top: -7px; right: -7px; z-index: 3; pointer-events: none;
  font: 800 11px/1.35 var(--ui-font); padding: 0 5px; border-radius: 99px;
  background: var(--turn); color: #111; box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.mrummy .meldmoves { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); min-width: calc(100% - 4px); display: flex; flex-direction: column; gap: 3px; z-index: 4; }
.mrummy .meldmoves .btn { min-height: 28px; font-size: 12px; padding: 2px 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); white-space: nowrap; }
.mrummy .tablenote { margin: auto; font-size: 14px; text-align: center; color: var(--soft); }

/* seats on phones: fixed-width chips that never wrap */
.mrummy .seats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 6px; margin: -6px -6px 0; flex: none; }
.mrummy .seats::-webkit-scrollbar { display: none; }
@media (min-width: 641px) and (min-height: 521px) { .mrummy .seats { display: none; } }
.mrummy .seat { flex: 0 1 222px; min-width: 196px; display: grid; grid-template-columns: auto minmax(0, 1fr) 64px; gap: 8px; padding: 4px 6px 4px 4px; }
.mrummy .seat .face { position: relative; }
.mrummy .seat.me { background: color-mix(in srgb, var(--ink) 10%, var(--chip)); }
.mrummy .seat .youmark { font-weight: 400; color: var(--soft); }
.mrummy .seat .who { min-width: 0; display: flex; gap: 6px; align-items: baseline; }
/* a chip's count and score are never cut, whatever name is beside them (the name gives way, with its ellipsis): they keep their width, and the red dot of a low count is small */
.mrummy .seat .who :is(.count, .pts) { flex: none; overflow: visible; text-overflow: clip; white-space: nowrap; }
.mrummy .seat .count.low::before { content: '●'; font-size: .6em; margin-right: .3em; vertical-align: .18em; }
.mrummy .seat .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrummy .seat.away :is(.face, .who) { opacity: .6; }

/* ── the bottom panel: status, tools and moves, always the same size ─── */
.mrummy .dock {
  flex: none; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px 10px;
  border-radius: 14px; background: var(--panel); border: 2px solid transparent; transition: border-color .2s, background-color .2s;
}
.mrummy .dock.yours { border-color: var(--turn); background: color-mix(in srgb, var(--turn) 9%, var(--panel)); }
.mrummy .status { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 4px 12px; }
.mrummy .saybox { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mrummy .sayline { min-height: 2.9em; display: flex; align-items: flex-start; gap: 8px; }
.mrummy .say {
  margin: 0; font-size: var(--t-body); line-height: 1.45; min-width: 0; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mrummy .say b { color: var(--turn); }
.mrummy .saylink { flex: none; }
.mrummy .saylink .btn { margin-top: -6px; }
.mrummy .controls { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mrummy .toolrow { display: flex; gap: 14px; align-items: center; min-width: 0; order: -1; }
.mrummy .tgroup { display: flex; gap: var(--s2, 8px); align-items: center; flex-wrap: nowrap; }
.mrummy .tool { min-height: var(--tool-h); font-size: var(--t-small); padding: 4px 12px; }
.mrummy .tool.mover { min-width: 40px; font-size: 18px; padding: 0; }
.mrummy .tool.allbtn { min-width: 10.4em; }
.mrummy .sorters kbd { opacity: .7; }
.mrummy .actions { display: grid; grid-template-columns: 260px 260px; gap: 8px; margin-left: auto; flex: none; }
.mrummy .act { width: 100%; min-width: 0; padding-inline: 10px; }
.mrummy .act .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrummy .btn.slot.act.confirm, .mrummy .btn.slot.act.confirm.alt {
  background: var(--btn2); color: var(--btn2-ink); border: 2.5px solid var(--confirm, var(--bad));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--confirm, var(--bad)) 40%, transparent);
}
.mrummy .dock { container-type: inline-size; }
@container (max-width: 1060px) {
  .mrummy .toolrow { gap: 8px; }
  .mrummy .sorters .sortlabel { display: none; }
}
@container (max-width: 990px) { .mrummy .actions { grid-template-columns: 220px 220px; } }
@container (max-width: 920px) {
  .mrummy .controls { flex-wrap: wrap; }
  .mrummy .actions { grid-template-columns: repeat(2, minmax(0, 260px)); margin-left: auto; }
}
.mrummy .tool, .mrummy .tool .label { white-space: nowrap; }

/* your hand: after you draw with nothing picked, a turn-yellow ring inside it */
.mrummy .handwrap { position: relative; flex: none; min-width: 0; order: 2; }
.mrummy .hand { border-radius: 12px; transition: box-shadow .15s, background-color .15s; padding: 18px 8px 8px; min-height: calc(var(--cw) * 1.4 + 26px); }
.mrummy .hand.cue { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--turn) 75%, transparent); background-color: color-mix(in srgb, var(--turn) 8%, transparent); }
/* the card you took from the pile: it has to be melded first */
/* the helper: a dot on each card that could meld now, under its index, in
   the strip that shows when the hand overlaps */
.mrummy .hand .card.melds::before {
  content: ''; position: absolute; left: 11%; top: 50%; width: 10px; height: 10px; border-radius: 50%;
  background: var(--turn); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .55);
}
/* the card you took from the pile: it has to be melded first (its tag sits
   inside the card's strip that shows, under the index, since the card is
   often picked and lifted; it takes the "New" tag's place) */
.mrummy .hand .card.must { box-shadow: var(--card-shadow), 0 0 0 3px var(--turn); }
.mrummy .hand .card.must::before {
  content: 'Meld'; position: absolute; left: 3px; top: 50%; width: auto; height: auto; z-index: 2; box-shadow: none;
  font: 800 9px/1.3 var(--ui-font); letter-spacing: .05em; text-transform: uppercase; padding: 1px 5px; border-radius: 6px;
  background: var(--turn); color: var(--turn-ink); white-space: nowrap;
}
.mrummy .hand .card.must.fresh::after { display: none; }
.felt.mrummy.dealing .hand .card, .felt.mrummy.dealing .pilefan .card { visibility: hidden; }

/* the title says the hand; clicking it replays the intro */
.mrummy .titlebtn {
  appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left;
  display: inline-block; max-width: 100%; cursor: pointer; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
}
.mrummy .titlebtn:hover { text-decoration: underline dotted; text-underline-offset: 4px; }
.mrummy .titlebtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.mrummy .bar .title { overflow: visible; }

/* ── the hand intro: which hand, who deals, the race ─────────────────── */
.introcard:has(.mintro) { min-width: min(440px, calc(100vw - 24px)); padding-bottom: 58px; }
.mintro { display: flex; flex-direction: column; align-items: center; }
.mintro .kicker { margin: 0; font: 800 15px/1.2 var(--ui-font); letter-spacing: .16em; text-transform: uppercase; color: var(--ink); }
.mintro .kicker .pip { opacity: .75; margin: 0 .5em; letter-spacing: .25em; }
.mintro .dealer { margin: 6px 0 0; font-size: 13px; color: var(--ink); opacity: .85; }
.mintro .headline { margin: 4px 0 0; font: var(--display-weight) 44px/1.05 var(--display); color: var(--turn); text-shadow: 0 2px 0 rgba(0, 0, 0, .25); text-align: center; }
.mintro .lastrule { margin: 14px 0 0; max-width: 26em; font-size: 15px; line-height: 1.4; text-align: center; }
.mintro .race { margin-top: 16px; width: min(340px, 80vw); }
/* the race: a lane each, a track to the target in the seat's color */
.race { display: flex; flex-direction: column; gap: 6px; }
.race .lane { display: grid; grid-template-columns: 7em minmax(0, 1fr) 3.2em; align-items: center; gap: 10px; font-size: 14px; }
.race .lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race .ltrack { position: relative; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 16%, transparent); overflow: hidden; }
.race .ltrack i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--seat); }
.race .lpts { text-align: right; font-variant-numeric: tabular-nums; }
.race .lane.lead .lpts { color: var(--turn); }
.mintro .chipspot { position: absolute; left: 50%; bottom: -46px; width: 92px; height: 92px; margin-left: -46px; }
.mintro .burst {
  position: absolute; inset: -34px; border-radius: 50%; opacity: 0; clip-path: inset(44% 0 0 0);
  background: repeating-conic-gradient(from -4deg, var(--turn) 0 8deg, transparent 8deg 36deg);
  -webkit-mask: radial-gradient(circle, transparent 0 52%, #000 53% 70%, transparent 71%);
  mask: radial-gradient(circle, transparent 0 52%, #000 53% 70%, transparent 71%);
}
.mintro .chip {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; color: #111; rotate: -12deg;
  background: radial-gradient(circle, var(--turn) 0 57%, transparent 57.5%), repeating-conic-gradient(from 6deg, #fff 0 14deg, var(--turn) 14deg 45deg);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .45), inset 0 0 0 2px rgba(0, 0, 0, .25);
}
.mintro .chip::before { content: ''; position: absolute; inset: 15px; border-radius: 50%; border: 2px dashed color-mix(in srgb, #000 30%, transparent); }
.mintro .chip span { font: 900 15px/1.02 var(--display); text-transform: uppercase; letter-spacing: .02em; }

/* the host's "Start without waiting" waits a moment before it can be pressed */
.later { animation: later 0s 1s both; }
@keyframes later { from { visibility: hidden; } to { visibility: visible; } }

/* ── the score sheet: the hand just played, the race, every hand ───────── */
.house-scrim-result .house-sheet.mr-result { --house-sheet-width: 760px; max-height: min(88dvh, calc(100dvh - 2 * var(--s3, 16px))); }
.scoresheet { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.house-result .scoresheet { align-self: stretch; text-align: left; }
.house-result .house-post:empty { display: none; }
.scoresheet .scroll { overflow-x: auto; }
.scoresheet .legend { font-size: var(--t-note); margin: 0; }
.handsum { display: flex; flex-direction: column; gap: 8px; --cw-small: 34px; }
.hsrow { display: grid; grid-template-columns: 8.5em 4.6em 4.6em 4.6em minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 5%, transparent); }
.hsrow.out { background: color-mix(in srgb, var(--turn) 14%, transparent); }
.hswho { display: flex; flex-direction: column; min-width: 0; }
.hswho .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.hswho .outtag { font-size: 12px; font-weight: 800; color: var(--turn); text-transform: uppercase; letter-spacing: .04em; }
.hsfig { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.hsfig .soft { font-size: 12px; }
.hsnet b { font-size: 18px; }
.hsleft { min-width: 0; overflow-x: auto; }
.hsleft .cards .card + .card { margin-left: calc(var(--cw-small) * -0.45); }
table.scores { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums lining-nums; }
table.scores th, table.scores td { padding: 6px 7px; text-align: right; border-bottom: 1px solid color-mix(in srgb, currentColor 16%, transparent); white-space: nowrap; }
table.scores th[scope="row"], table.scores thead th:nth-child(1), table.scores td.place + th { text-align: left; }
table.scores th[scope="row"] { max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
table.scores .now { background: color-mix(in srgb, var(--ink) 7%, transparent); }
table.scores td.total { font-weight: 800; }
table.scores tr.win th, table.scores tr.win td { color: var(--turn); font-weight: 800; }
table.scores td.place { text-align: left; font-weight: 700; color: var(--soft); }
table.contracts td:nth-child(2), table.contracts th:nth-child(2) { text-align: left; white-space: normal; }
.rulesheet ul, .rulesheet ol { padding-left: 1.2em; }
/* How to play's example: the pile, the card you'd dig to, what comes with it */
.mr-example { margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; --cw-small: 40px; }
.mr-example .cards { padding-top: 10px; }
.mr-example .cards .card + .card { margin-left: calc(var(--cw-small) * -0.35); }
.mr-example .card.taking { transform: translateY(-8px); }
.mr-example .card.deepest { outline: 3px solid var(--turn); outline-offset: 1px; }
.mr-example figcaption { font-size: var(--t-note); }
.rulesheet .mr-example { margin-bottom: 4px; }
.rulesheet table.scores td:first-child { text-align: left; }

/* ── the front door: six table settings still fit 1280×800 ──────────── */
@media (min-width: 900px) {
  .lobby:has(.choices) .choices { grid-template-columns: 2fr 1fr; }
}
.lobby .choice > .bots > .bots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2) var(--s3); }
.lobby .choice > .bots > .bots > .setting { flex-direction: column; align-items: stretch; gap: var(--s1); }
.lobby .choice > .bots > .bots > .setting > div:first-child { flex: none; }
.lobby .choice > .bots > .bots > .setting .seg { display: grid; }
.lobby .choice > .bots > .bots > .setting .seg button { min-width: 0; min-height: 32px; padding-block: 3px; }
@media (pointer: coarse) { .lobby .choice > .bots > .bots > .setting .seg button { min-height: 44px; } }
/* (one to a row wherever the bots' panel is half a window: under 900px it shares the row with the friends', so three would be cramped) */
@media (max-width: 899px) {
  .lobby .choice > .bots > .bots { grid-template-columns: 1fr; }
}

/* ── phones (and phones on their side) ──────────────────────────────── */
@media (max-width: 640px), (max-height: 520px) {
  .mrummy .seat .youmark { display: none; }
  .mrummy .seat .count .cw { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mrummy .pilerow { --pw: 38px; gap: 8px; padding: 4px 6px 2px; }
  .mrummy .pilefan { padding: 10px 2px 8px; }
  .mrummy .tilewrap { padding: 4px; gap: 6px; }
  .mrummy .tiles { gap: 6px; }
  .mrummy .tiles.list .tilebody { overflow: visible; }
  .mrummy .tiles.list .tile.me {
    position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -8px 14px -6px rgb(0 0 0 / .45);
    background: linear-gradient(color-mix(in srgb, var(--ink) 9%, var(--panel)), color-mix(in srgb, var(--ink) 9%, var(--panel))), var(--room);
  }
}
@media (max-width: 640px) {
  .introcard:has(.mintro) { padding: 16px 16px 46px; }
  .mintro .kicker { font-size: 13px; letter-spacing: .12em; white-space: nowrap; }
  .mintro .headline { font-size: 30px; }
  .mintro .chipspot { bottom: -36px; width: 72px; height: 72px; margin-left: -36px; }
  .mintro .burst { inset: -26px; }
  .mintro .chip::before { inset: 12px; }
  .mintro .chip span { font-size: 12px; }
  .felt.mrummy { height: 100dvh; gap: 0; }
  .felt.mrummy .bar .tools { display: none; }
  .felt.mrummy .bar .more { display: inline-flex; min-width: 44px; }
  /* a chip says its cards and its score: "7 · 212" */
  .mrummy .seat .who { display: grid; grid-template-columns: auto auto; justify-content: start; column-gap: 4px; }
  .mrummy .seat .who .name { grid-column: 1 / -1; }
  .mrummy .seat .pts::before { content: '· '; color: var(--soft); font-weight: 400; }
  .mrummy .seat .pts small { display: none; }
  .mrummy .tablemain { gap: 6px; }
  .mrummy .seats { gap: 5px; }
  /* (a chip is at least as wide as its count and score, "13 · -145": they never run out of it; the name, which gives way, adds nothing to its width) */
  .mrummy .seat { flex: 1 0 76px; width: auto; min-width: max-content; grid-template-columns: auto minmax(0, 1fr); min-height: 40px; padding: 3px 6px 3px 3px; gap: 5px; border-radius: 12px; }
  .mrummy .seat .face { width: 24px; height: 24px; box-shadow: 0 0 0 2px var(--chip); }
  .mrummy .seat .who { font-size: 11px; line-height: 1.2; flex-wrap: wrap; column-gap: 4px; }
  .mrummy .seat .name { font-size: 12px; max-width: 100%; width: 0; min-width: 100%; }
  .mrummy .seat .badge:not(button) { display: none; }
  .mrummy .seat button.badge { position: absolute; right: 4px; bottom: -9px; width: auto; min-height: 0; height: 15px; padding: 0 5px; font-size: 9.5px; line-height: 1; z-index: 1; }
  .mrummy .seat .dealer { right: -5px; bottom: -5px; }
  .mrummy .seat.is-ready .face { box-shadow: 0 0 0 2px var(--chip), 0 0 0 4px var(--good); }
  .mrummy .dock { padding: 8px 8px 8px; gap: 6px; }
  .mrummy .sayline { min-height: calc(2 * 1.45 * 14px); }
  .mrummy .say { font-size: 14px; }
  .mrummy .controls { flex-direction: column; align-items: stretch; gap: 6px; }
  .mrummy .toolrow { justify-content: space-between; gap: 6px; }
  .mrummy .sorters .sortlabel, .mrummy .sorters kbd { display: none; }
  .mrummy .sorters { position: relative; }
  .mrummy .tool.mover { position: absolute; top: 0; min-width: 48px; }
  .mrummy .tool.mleft { left: 0; }
  .mrummy .tool.mright { left: 56px; }
  .mrummy .dock.picking .sorters .seg { visibility: hidden; }
  .mrummy .seg.small button { padding: 2px 8px; font-size: 12px; min-height: 38px; white-space: nowrap; }
  .mrummy .tool.allbtn { min-width: 0; }
  .mrummy .gamelog.drawer { right: 10px; width: calc(100% - 20px); }
  .mrummy .tool { padding: 4px 8px; font-size: 14px; min-height: 38px; }
  .mrummy .act { font-size: 15px; }
  .mrummy .actions { width: 100%; grid-template-columns: 1fr 1fr; margin-left: 0; }
  .mrummy .meldmoves .btn { min-height: 34px; }
  .bar .more { min-height: 44px; min-width: 44px; }
  .hsrow { grid-template-columns: minmax(0, 1fr) 3.6em 3.6em 3.6em; gap: 6px; }
  .hsleft { grid-column: 1 / -1; }
  table.scores th, table.scores td { padding: 6px 3px; font-size: 13px; }
  table.scores td.total, table.scores thead th:last-child { position: sticky; right: 0; background: var(--sheet); box-shadow: -8px 0 8px -6px rgba(0, 0, 0, .45); }
  table.scores th[scope="row"] { max-width: 5.5em; }
  .race .lane { grid-template-columns: 5.5em minmax(0, 1fr) 3em; }
}
@media (max-width: 400px) {
  .mrummy .seg.small button { padding: 2px 6px; }
  .mrummy .toolrow, .mrummy .tgroup { gap: 4px; }
  .mrummy .tool { padding: 4px 6px; }
  .mrummy .act { font-size: 14px; padding-inline: 6px; }
  table.scores td.place, table.scores thead th:empty { display: none; }
}
@media (max-width: 340px) {
  /* (four chips and their scores still fit in a row: a little less room between and round them) */
  .mrummy .seats { gap: 4px; }
  .mrummy .seat { flex-basis: 66px; min-width: max-content; gap: 4px; padding-right: 4px; }
  .mrummy .pilerow { --pw: 34px; }
}

/* short screens (phones on their side): one compact row of moves, the
   tools behind the menu, and every spare pixel to the table */
@media (max-height: 520px) {
  body { --cw: 44px; --cw-small: 30px; }
  #app { padding: 0; }
  .felt.mrummy { height: 100dvh; padding: 6px 10px; border: 0; border-radius: 0; gap: 0; }
  .mrummy .tablemain { gap: 4px; }
  .mrummy .bar .title { font-size: 14px; }
  .mrummy .seat { flex: 0 0 140px; min-width: 140px; width: 140px; grid-template-columns: auto minmax(0, 1fr); min-height: 32px; padding: 2px 6px 2px 2px; }
  .mrummy .seat .badge:not(button) { display: none; }
  /* (a chip is two short lines, as on a portrait phone, so the row of seats
     stays about 40px tall: three lines would push the pile under the moves) */
  .mrummy .seat .who { display: grid; grid-template-columns: auto auto; justify-content: start; column-gap: 4px; font-size: 11px; line-height: 1.2; }
  .mrummy .seat .who .name { grid-column: 1 / -1; font-size: 12px; max-width: 100%; }
  .mrummy .seat .pts::before { content: '· '; color: var(--soft); font-weight: 400; }
  .mrummy .seat .pts small { display: none; }
  .mrummy .seat .face { width: 24px; height: 24px; }
  .mrummy .pilefan { padding: 8px 2px 6px; min-height: calc(var(--pw) * 1.4 + 14px); }
  .mrummy .board { flex-direction: row; }
  .mrummy .pilerow { width: 46%; flex: none; align-items: center; }
  .felt.mrummy .bar .tools { display: none; }
  .felt.mrummy .bar .more { display: inline-flex; min-height: 34px; }
  .mrummy .dock { padding: 4px 8px 6px; gap: 4px; }
  .mrummy .sayline { min-height: 1.45em; }
  .mrummy .say { -webkit-line-clamp: 1; font-size: 13px; }
  .mrummy .controls { flex-wrap: nowrap; flex-direction: row; gap: 6px; }
  .mrummy .actions { width: auto; grid-template-columns: 150px 150px; }
  .mrummy .tool, .mrummy .act { min-height: 36px; font-size: 14px; }
  .mrummy .hand { min-height: calc(var(--cw) * 1.4 + 20px); padding-top: 12px; }
  .mrummy .dock kbd { display: none; }
  .mrummy .sorters .sortlabel { display: none; }
}
/* (375px tall, a phone on its side: the table's whole height is the bar, a
   row of seats, the pile and its tiles, the moves and your hand, so the
   last line of the log goes, the cards shrink a little, and the pile row
   never asks for more than the board has) */
@media (max-height: 400px) {
  body { --cw: 38px; --cw-small: 28px; }
  .mrummy .pilerow { --pw: 34px; }
  .mrummy .seats { padding-block: 4px; }
}
@media (max-height: 340px) {
  body { --cw: 34px; --cw-small: 24px; }
  .mrummy .pilerow { --pw: 28px; }
  .mrummy .pilefan { padding: 6px 2px 5px; min-height: calc(var(--pw) * 1.4 + 11px); }
  .mrummy .seats { display: none; }
  .mrummy .sorters { display: none; }
  .mrummy .actions { grid-template-columns: 128px 128px; }
  .mrummy .tool, .mrummy .act { min-height: 32px; }
}
@media (pointer: coarse) {
  .mrummy .seg.small button, .mrummy .tool, .mrummy .tool.mover, .mrummy .act { min-height: 44px; }
  .felt.mrummy .bar .btn { min-height: 44px; }
  .bar .more { min-width: 44px; }
}
@media (pointer: coarse) and (max-height: 400px) {
  .mrummy .tool, .mrummy .tool.mover, .mrummy .act, .mrummy .seg.small button { min-height: 40px; }
}
/* (a dig's "took 4" badge has no room on a phone's chip: its face rings hot instead, as Contract Rummy's buyer's does) */
.mrummy .seat[class*="is-took"] .face { box-shadow: 0 0 0 2px var(--chip), 0 0 0 4px var(--turn); }
@media (prefers-reduced-motion: reduce) {
  .mrummy .dock, .mrummy .hand, .mrummy .pilefan .card { transition: none; }
}
