/* =============== MUD (ladder rummy): shared =============== */
:root { --mud-stage: #f5c542; --mud-stage-ink: #2a1e00; }
.mud-stg { --s: 16px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: var(--s); height: var(--s);
  border-radius: 50%; background: var(--mud-stage); color: var(--mud-stage-ink); font-style: normal; font-weight: 900; font-size: calc(var(--s) * 0.62);
  line-height: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.card.mud-joker { background: linear-gradient(150deg, #fff6d6, #f5c542 70%, #e0a92a); color: #5b2a86; }
.card.mud-joker .rank { font-size: calc(var(--w) * 0.5); }
.card.mud-joker .suit { font-size: calc(var(--w) * 0.17); font-weight: 900; letter-spacing: 0.5px; }
.mud-mini { display: inline-flex; align-items: center; justify-content: center; position: relative; background: #fff; color: #1a1a1a;
  border-radius: 5px; font-weight: 900; line-height: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); white-space: nowrap; }
.mud-mini.red { color: #d7263d; }
.mud-mini.wild { background: linear-gradient(150deg, #fff6d6, #f5c542); color: #5b2a86; }
.mud-mini i { position: absolute; bottom: -2px; right: -3px; font-style: normal; font-size: 0.6em; background: #5b2a86; color: #fff;
  border-radius: 4px; padding: 1px 2px; }
.mud-empty { color: rgba(255, 255, 255, 0.7); font-weight: 700; font-size: 13px; text-align: center; padding: 10px; margin: auto; }

/* =============== MUD: phone =============== */
#mud.screen { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; padding: 10px 12px 8px; gap: 6px; }
#mud .bj-status { flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 52px; height: 28px; line-height: 28px; }
#mud .header .chips { white-space: nowrap; }
#mudTimer { flex-shrink: 0; min-height: 6px; margin-bottom: 2px; } /* room for the emote and timeout bubbles beside the status and timer */
.mud-body {
  flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px;
  border-radius: 20px; border: 5px solid var(--rail); background: radial-gradient(ellipse at 50% 40%, var(--felt-1), var(--felt-2) 90%);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.5); overflow: hidden;
}
.mud-opps { display: flex; gap: 4px; flex-shrink: 0; min-height: 34px; }
.mud-opp { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px 3px;
  border-radius: 9px; background: rgba(0, 0, 0, 0.25); border: 2px solid transparent; line-height: 1.15; }
.mud-opp b { font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mud-opp span { display: flex; align-items: center; gap: 4px; font-size: 11px; color: rgba(255, 255, 255, 0.85); font-weight: 800; white-space: nowrap; max-width: 100%; overflow: hidden; }
.mud-opp .mud-stg { --s: 17px; }
.mud-cc { font-style: normal; }
.mud-tick { font-style: normal; color: #59d98e; margin-right: 2px; }
.mud-cc::before { content: ''; display: inline-block; width: 6px; height: 9px; border-radius: 1.5px; background: #fff; margin-right: 2px; vertical-align: -1px; }
.mud-opp.turn { border-color: var(--accent); background: rgba(245, 197, 66, 0.15); }
.mud-tabs { display: flex; gap: 4px; flex-shrink: 0; }
.mud-tab { flex: 1 1 0; min-width: 0; height: 30px; padding: 0 4px; border-radius: 9px; font-size: 13px; font-weight: 800;
  background: rgba(0, 0, 0, 0.3); color: rgba(255, 255, 255, 0.85); border: 2px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mud-tab.on { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.45); color: #fff; }
/* My stage: the stage gold, with your stage number in its circle */
.mud-tab.stage-tab { color: var(--mud-stage); display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.mud-tab.stage-tab.on { border-color: var(--mud-stage); background: rgba(245, 197, 66, 0.16); color: var(--mud-stage); }
.mud-tab .mud-stg { --s: 18px; }
#mudPanel { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; container-type: size; overflow: hidden;
  border-radius: 12px; background: rgba(0, 0, 0, 0.18); padding: 6px; }

/* the discard pile: a row you swipe through; the deck on the left, the newest card on the right */
.mud-pile-row { display: flex; align-items: center; height: 100%; min-width: 0; }
.mud-pile-strip { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 0; overflow-x: auto; overflow-y: hidden; height: 100%; padding: 8px 6px 4px;
  scrollbar-width: none; touch-action: pan-x; }
.mud-pile-strip::-webkit-scrollbar { display: none; }
.mud-pile-row .card { --w: min(17vw, 76px, 56cqh); }
.mud-deck { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 9px; margin-right: 6px; padding-left: 2px; font-size: 11px; font-weight: 800;
  color: rgba(255, 255, 255, 0.8); }
.mud-deck.can .card { box-shadow: 0 0 0 3px var(--accent), 0 3px 8px rgba(0, 0, 0, 0.4); }
.mud-pile-card { flex-shrink: 0; position: relative; margin-left: calc(min(17vw, 76px, 56cqh) * -0.4); transition: transform 0.15s; }
.mud-pile-card:first-child { margin-left: 0; }
.mud-pile-card.picked { transform: translateY(-7px); }
.mud-pile-card.picked .card { box-shadow: 0 0 0 3px var(--accent), 0 4px 10px rgba(0, 0, 0, 0.5); }
.mud-pile-card.first .card { box-shadow: 0 0 0 4px #fff, 0 0 16px rgba(245, 197, 66, 0.9); }
.mud-pile-card.blocked:not(.picked) .card { filter: grayscale(0.7) brightness(0.65); }
.mud-top { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 900; color: var(--accent); }

/* your stage: one space per part, cards go in by tapping */
.mud-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12.5px; font-weight: 800; min-height: 26px; flex-shrink: 0; }
.mud-stage-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mud-fill { flex-shrink: 0; height: 26px; padding: 0 9px; border-radius: 13px; font-size: 12px; font-weight: 800; background: var(--accent); color: #1a1a1a; }
.mud-spaces { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; overscroll-behavior: contain; }
.mud-spaces > :first-child { margin-top: auto; }
.mud-spaces > :last-child { margin-bottom: auto; }
.mud-space { flex-shrink: 0; }
.mud-space { border-radius: 10px; border: 2px dashed rgba(255, 255, 255, 0.25); padding: 3px 6px 5px; min-height: 0; }
.mud-space.active { border-style: solid; border-color: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.06); }
.mud-space.ok { border-color: #59d98e; }
.mud-space-label { font-size: 11px; font-weight: 800; color: rgba(255, 255, 255, 0.8); line-height: 1.2; }
.mud-slots { display: flex; gap: 0; flex-wrap: nowrap; overflow: visible; }
.mud-slots .card + .card { margin-left: min(3px, calc((100% - var(--n) * var(--w)) / max(1, var(--n) - 1))); }
.mud-slots .card { --w: min(8.6vw, 34px, 15cqh); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.mud-slots .card .rank, .mud-slots .card .suit { font-size: calc(var(--w) * 0.42); }
.mud-stage-done { font-size: 12.5px; font-weight: 800; color: #9ff0bd; margin-bottom: 6px; flex-shrink: 0; }

/* the groups on the table (tap a lit one to add your picked card) */
.mud-groups { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; overflow-y: auto; min-height: 0; flex: 1 1 0; }
#mudPanel .mud-group { flex: 1 1 140px; min-width: 0; border-radius: 8px; padding: 3px 4px; background: rgba(0, 0, 0, 0.25); border: 2px solid transparent; }
#mudPanel .mud-group.lit { border-color: var(--accent); background: rgba(245, 197, 66, 0.18); animation: mud-lit 1.1s ease-in-out infinite; }
@keyframes mud-lit { 50% { box-shadow: 0 0 12px rgba(245, 197, 66, 0.7); } }
.reduce-motion #mudPanel .mud-group.lit { animation: none; }
#mudPanel .mud-group-who { font-size: 10.5px; font-weight: 800; color: rgba(255, 255, 255, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52px; align-self: center; margin-right: 2px; }
#mudPanel .mud-minis { display: flex; flex-wrap: wrap; gap: 2px; }
#mudPanel .mud-mini { font-size: 11px; padding: 3px 2px; min-width: 21px; }

/* your hand: a row you swipe through; hold a card to drag it */
.mud-handbar { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-shrink: 0; position: relative; height: 26px; }
#mudHandInfo { font-size: 12px; font-weight: 800; color: rgba(255, 255, 255, 0.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#mudSort { height: 26px; padding: 0 12px; border-radius: 13px; font-size: 12px; font-weight: 800; background: rgba(0, 0, 0, 0.35); color: #fff; flex-shrink: 0; border: 2px solid transparent; }
#mudSort.on { border-color: var(--accent); color: var(--accent); }
/* Phase 10: Take back, in the hand bar beside Sort (it never moves the buttons below). Cards you can take back glow on the table. */
.mud-hb-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mud-back-btn { height: 26px; padding: 0 12px; border-radius: 13px; font-size: 12px; font-weight: 800; background: rgba(0, 0, 0, 0.35); color: var(--accent); border: 2px solid var(--accent); white-space: nowrap; }
.mud-back-btn[hidden] { display: none; }
.card.mud-can-back { outline: 2px dashed var(--accent); outline-offset: 1px; cursor: pointer; }
.mud-sort-menu { position: absolute; right: 0; bottom: 30px; z-index: 30; display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--panel, #1d2b24); border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6); }
.mud-sort-menu button { height: 36px; padding: 0 14px; border-radius: 9px; font-size: 14px; font-weight: 800; text-align: left; }
.mud-sort-menu button:disabled { opacity: 0.4; }
/* the hand never scrolls: every card is placed by mud-phone.js (mudLayout), evenly spaced; hold to spread */
#mudHand { --cw: min(17vw, 70px); position: relative; flex-shrink: 0; height: calc(var(--cw) * 1.4 + 22px); margin: 0 -4px; overflow: visible;
  touch-action: none; cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#mudHand .card { --w: var(--cw); position: absolute; left: 0; bottom: 4px; --pick: 0px; --near: 0;
  --lift: 0px; transform: translateY(calc(-1 * (var(--pick) + var(--lift)))); transform-origin: 50% 100%;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.35);
  transition: translate 0.18s ease-out, transform 0.18s ease-out, opacity 0.15s; }
#mudHand.instant .card { transition: none; }
/* while you slide your finger, follow it closely (a shorter ease) */
#mudHand.holding .card { transition-duration: 0.09s, 0.09s, 0.15s; --lift: calc(var(--near) * 16px); }
.reduce-motion #mudHand .card { transition: none; }
/* the rank and suit sit in the top left corner, so they show when the cards overlap */
#mudHand .card:not(.back) { align-items: flex-start; justify-content: flex-start; padding: calc(var(--w) * 0.05) 0 0 calc(var(--w) * 0.07); gap: 0; }
#mudHand .card .rank { font-size: calc(var(--w) * 0.3); font-weight: 900; letter-spacing: -0.04em; }
#mudHand .card .suit { font-size: calc(var(--w) * 0.26); padding-left: 0.04em; }
#mudHand .card.mud-joker .rank { font-size: calc(var(--w) * 0.3); }
#mudHand .card.mud-joker .suit { font-size: calc(var(--w) * 0.13); padding-left: 0; }
#mudHand .card.sel { --pick: 12px; box-shadow: 0 0 0 3px var(--accent), 0 6px 14px rgba(0, 0, 0, 0.5); }
#mudHand .card.spaced { opacity: 0.4; --pick: -2px; }
#mudHand .card.drawn { box-shadow: 0 0 0 3px #5fb8ff, -2px 0 5px rgba(0, 0, 0, 0.35); }
#mudHand .card.dug { box-shadow: 0 0 0 3px #ff7a45, 0 0 14px rgba(255, 122, 69, 0.8); }
#mudHand .card.sel.drawn, #mudHand .card.sel.dug { box-shadow: 0 0 0 3px var(--accent), 0 6px 14px rgba(0, 0, 0, 0.5); }
/* a card lifted out to move: it follows your finger, raised and outlined */
#mudHand .card.dragging { --lift: 12px; opacity: 1; transition: transform 0.12s ease-out; box-shadow: 0 0 0 3px #fff, 0 10px 20px rgba(0, 0, 0, 0.6); }

.mud-dock { flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.mud-line { text-align: center; font-weight: 800; font-size: 13px; height: 34px; overflow: hidden; line-height: 1.3; display: flex; align-items: center; justify-content: center; }
.mud-buttons { display: flex; gap: 8px; }
.mud-buttons .big-button { flex: 1 1 0; min-width: 0; height: 62px; font-size: 19px; font-weight: 900; border-radius: 16px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mudLeft.ready { box-shadow: 0 0 0 3px #59d98e, 0 0 18px rgba(89, 217, 142, 0.7); }
#mudError { min-height: 16px; }
@media (max-height: 680px) {
  #mud.screen { padding-top: 6px; gap: 4px; }
  #mudTimer { margin-bottom: 4px; }
  .mud-buttons .big-button { height: 54px; font-size: 18px; }
  .mud-line { height: 32px; font-size: 12px; }
  #mudHand { --cw: min(16vw, 62px); height: calc(var(--cw) * 1.4 + 18px); }
}

/* the Pile tab: the deck and the discard pile as a stack (tap it to look through) */
#mudPanel .mud-pile-row { justify-content: center; gap: 28px; }
.mud-discard { display: flex; flex-direction: column; align-items: center; gap: 9px; font-size: 11px; font-weight: 800; color: rgba(255, 255, 255, 0.8); cursor: pointer; }
.mud-discard-stack { position: relative; display: flex; align-items: flex-end; }
.mud-discard-stack .card { --w: min(17vw, 76px, 56cqh); }
.mud-discard-stack .card.under { position: absolute; bottom: 0; right: 0; translate: calc(var(--k) * -14px) 0; opacity: 0.9; }
.mud-discard-stack .card.topcard { position: relative; z-index: 2; }
.mud-discard-stack .card.under:not(.back) { align-items: flex-start; justify-content: flex-start; padding: calc(var(--w) * 0.05) 0 0 calc(var(--w) * 0.06); gap: 0; }
.mud-discard-stack .card.under .rank { font-size: calc(var(--w) * 0.26); }
.mud-discard-stack .card.under .suit { font-size: calc(var(--w) * 0.22); }
.mud-discard.can .card.topcard { box-shadow: 0 0 0 3px var(--accent), 0 4px 10px rgba(0, 0, 0, 0.5); }
.mud-discard-stack:has(.under) { padding-left: 42px; }

/* the Table tab: one row per player (one border each), a list that scrolls; tap a row to open it */
.mud-prows { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; overscroll-behavior: contain; }
.mud-prow { flex-shrink: 0; border-radius: 10px; border: 2px solid rgba(255, 255, 255, 0.18); background: rgba(0, 0, 0, 0.22); }
.mud-prow.lit { border-color: var(--accent); background: rgba(245, 197, 66, 0.12); }
.mud-prow-head { display: flex; align-items: center; gap: 6px; padding: 5px 6px; cursor: pointer; min-height: 30px; }
.mud-prow-who { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; max-width: 38%; min-width: 0; }
.mud-prow-who b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mud-prow-who .mud-stg { --s: 18px; }
.mud-prow-chips { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; overflow: hidden; }
.mud-prow-chips .mud-minis { display: flex; flex-wrap: nowrap; }
.mud-prow-chips .mud-mini { font-size: 11px; padding: 3px 2px; min-width: 21px; margin-left: -5px; }
.mud-prow-chips .mud-mini:first-child { margin-left: 0; }
.mud-prow-caret { flex: 0 0 auto; margin-left: auto; color: rgba(255, 255, 255, 0.6); font-size: 13px; width: 12px; text-align: center; }
.mud-prow-sets { display: flex; flex-direction: column; gap: 6px; padding: 0 6px 7px; }
.mud-bigset { border-radius: 8px; padding: 3px 4px 5px; border: 2px solid transparent; background: rgba(0, 0, 0, 0.18); }
.mud-bigset.lit { border-color: var(--accent); background: rgba(245, 197, 66, 0.18); animation: mud-lit 1.1s ease-in-out infinite; cursor: pointer; }
.reduce-motion .mud-bigset.lit { animation: none; }
.mud-bigset-kind { display: block; font-size: 10px; font-weight: 800; color: rgba(255, 255, 255, 0.7); margin-bottom: 2px; }
.mud-bigset-cards { display: flex; align-items: flex-end; }
/* real cards at real proportions, the rank in the corner so it shows when they overlap */
.mud-bigset-cards .card { --w: 38px; box-shadow: -1px 0 4px rgba(0, 0, 0, 0.35); align-items: flex-start; justify-content: flex-start; padding: 2px 0 0 3px; gap: 0; }
.mud-bigset-cards .card .rank { font-size: 12px; font-weight: 900; }
.mud-bigset-cards .card .suit { font-size: 11px; }
.mud-bigset-cards .card.mud-joker .suit { font-size: 5.5px; }

/* the discard pile popped out: big cards over a faded screen; tap outside the box to put it away */
.mud-dig { position: fixed; inset: 0; z-index: 90; background: rgba(6, 8, 8, 0.78); display: flex; align-items: center; justify-content: center;
  padding: 12px; animation: dialog-fade 0.15s ease-out; }
.mud-dig.hidden { display: none; }
.mud-dig-box { width: 100%; max-width: 520px; border-radius: 18px; padding: 12px 10px 12px; background: radial-gradient(ellipse at 50% 30%, var(--felt-1), var(--felt-2) 95%);
  border: 4px solid var(--rail); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7); display: flex; flex-direction: column; gap: 8px; }
.mud-dig-title { font-weight: 900; font-size: 16px; text-align: center; }
.mud-dig-title span { display: block; font-size: 11.5px; font-weight: 700; color: rgba(255, 255, 255, 0.7); }
.mud-dig-fan { --cw: min(24vw, 100px); position: relative; height: calc(var(--cw) * 1.4 + 30px); touch-action: none; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mud-dig-fan .card { --w: var(--cw); position: absolute; left: 0; bottom: 6px; --near: 0; --lift: 0px; --pick: 0px;
  transform: translateY(calc(-1 * (var(--pick) + var(--lift)))); box-shadow: -2px 0 6px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.35);
  transition: translate 0.18s ease-out, transform 0.18s ease-out; align-items: flex-start; justify-content: flex-start;
  padding: calc(var(--w) * 0.05) 0 0 calc(var(--w) * 0.07); gap: 0; }
.mud-dig-fan .card .rank { font-size: calc(var(--w) * 0.3); font-weight: 900; }
.mud-dig-fan .card .suit { font-size: calc(var(--w) * 0.26); }
.mud-dig-fan .card.mud-joker .suit { font-size: calc(var(--w) * 0.13); }
.mud-dig-fan.instant .card { transition: none; }
.mud-dig-fan.holding .card { transition-duration: 0.09s; --lift: calc(var(--near) * 16px); }
.mud-dig-fan .card.picked { --pick: 12px; box-shadow: 0 0 0 3px var(--accent), 0 6px 12px rgba(0, 0, 0, 0.5); }
.mud-dig-fan .card.first { box-shadow: 0 0 0 3px #fff, 0 0 16px rgba(245, 197, 66, 0.9); }
.mud-dig-fan .card.blocked { filter: grayscale(0.7) brightness(0.6); }
.reduce-motion .mud-dig-fan .card { transition: none; }
.mud-dig-line { text-align: center; font-size: 13px; font-weight: 800; min-height: 34px; line-height: 1.3; display: flex; align-items: center; justify-content: center; }
.mud-dig-buttons { display: flex; gap: 8px; }
.mud-dig-buttons button { flex: 1 1 0; height: 54px; font-size: 18px; font-weight: 900; border-radius: 14px; }
.mud-dig-buttons .secondary { flex: 0 0 34%; }

/* "Your turn": big, gold and glowing, so it's clear at a glance */
#mud .bj-status.mine { color: var(--accent); font-size: 21px; font-weight: 900; letter-spacing: 0.02em; text-shadow: 0 0 14px rgba(245, 197, 66, 0.55); }
/* your stage in short, under the status line */
.mud-stage-line { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; font-weight: 900;
  color: var(--mud-stage); min-height: 20px; padding: 0 52px; white-space: nowrap; overflow: hidden; }
.mud-stage-line .mud-stg { --s: 18px; }
.mud-stage-line .mud-down { font-size: 12px; }
/* cards in your stage stay in your hand, dimmed with a gold mark; locked cards carry a 🔒 */
#mudHand .card.spaced { opacity: 0.55; --pick: -2px; }
#mudHand .card.spaced::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; border-radius: 0 0 4px 4px; background: var(--mud-stage); }
#mudHand .card.locked::after { content: '🔒'; position: absolute; right: 2px; top: 2px; font-size: calc(var(--w) * 0.2); line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
#mudHand .card.landing { opacity: 0; }
#mudHand .card.dragging { pointer-events: none; }
/* the stage: ghost cards (still in your hand); drag one out to take it back */
.mud-slots .card.ghost { opacity: 0.7; outline: 2px dashed rgba(255, 255, 255, 0.6); outline-offset: -2px; cursor: grab; touch-action: none; }
.mud-slots .card.ghost.leaving { opacity: 0.25; }
.mud-drag-ghost { position: fixed; z-index: 95; pointer-events: none; transform: translate(-50%, -60%) rotate(-4deg); }
.mud-drag-ghost .card { --w: 46px; box-shadow: 0 0 0 2px #fff, 0 8px 18px rgba(0, 0, 0, 0.6); }
/* a drawn card flying into your hand */
.mud-fly { position: fixed; z-index: 92; pointer-events: none; transition: left 0.42s cubic-bezier(0.3, 0.7, 0.3, 1), top 0.42s cubic-bezier(0.3, 0.7, 0.3, 1), transform 0.42s; transform: rotate(-8deg) scale(1.05); }
.mud-fly.go { transform: none; }
.mud-fly .card { --w: inherit; width: 100%; height: auto; aspect-ratio: 1 / 1.4; }
.reduce-motion .mud-fly { display: none; }
/* on the TV: the cards a player has set up for their stage, face down where it will go down */
.mud-zone .mud-staged { display: flex; gap: calc(var(--u) * 0.8); }
.mud-zone .mud-staged-part { display: flex; }
.mud-zone .mud-staged-part .card { --w: calc(var(--u) * 2.2); margin-left: calc(var(--u) * -1.3); box-shadow: -1px 0 3px rgba(0, 0, 0, 0.4); }
.mud-zone .mud-staged-part .card:first-child { margin-left: 0; }
/* on the TV: cards flying from the deck or the pile to a seat */
.mud-tv-fly { position: fixed; z-index: 30; pointer-events: none; transition: left 0.55s cubic-bezier(0.3, 0.7, 0.3, 1), top 0.55s cubic-bezier(0.3, 0.7, 0.3, 1), transform 0.55s; }
.reduce-motion .mud-tv-fly { display: none; }

/* the discard pop-out is a plain row you swipe through; the cards near the middle splay apart; tap one to pick it */
.mud-dig-fan { overflow-x: auto; overflow-y: hidden; touch-action: pan-x; scrollbar-width: none; cursor: default; }
.mud-dig-fan::-webkit-scrollbar { display: none; }
.mud-dig-row { position: relative; height: 100%; }
.mud-dig-fan .card { transition: translate 0.1s ease-out, transform 0.18s ease-out; cursor: pointer; }
/* a set on a compact Table row that your card fits */
.mud-prow-chips .mud-minis.lit { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 5px; }
/* the end of a hand: the host's Deal next hand takes the whole button row */
.mud-buttons #mudDeal { flex: 1 1 100%; animation: deal-pop 0.25s ease-out; }
.mud-buttons .hidden { display: none !important; }
/* the draw: animated with the Web Animations API (up above the hand, turn over, pause, into place) */
.mud-fly { transition: none; transform: none; transform-origin: 50% 50%; }
.mud-fly .card { width: 100%; height: 100%; }

/* the big window over the table: your stage, or a player's sets; everything shows at once, Done closes it */
.mud-zoom { position: fixed; z-index: 40; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px 10px; border-radius: 18px;
  border: 3px solid var(--mud-stage); background: radial-gradient(ellipse at 50% 30%, var(--felt-1), var(--felt-2) 95%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7); animation: dialog-fade 0.15s ease-out; }
.mud-zoom.hidden { display: none; }
.mud-zoom-head { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; font-weight: 900; flex-shrink: 0; }
.mud-zoom-title { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.mud-zoom-head span { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mud-zoom-head .mud-stg { --s: 20px; }
.mud-zoom-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: space-evenly; gap: 6px; overflow: hidden; }
.mud-zoom .mud-space { flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 4px 6px; }
.mud-zoom .mud-space-label { flex: 0 0 52px; white-space: normal; }
.mud-zoom .mud-slots { flex: 1 1 0; min-width: 0; }
.mud-zoom .mud-slots .card { --w: var(--zw); }
.mud-zoom .mud-slots .card .rank, .mud-zoom .mud-slots .card .suit { font-size: calc(var(--w) * 0.4); }
.mud-zoom .mud-bigset-cards .card { --w: var(--zw); }
.mud-zoom .mud-bigset-cards .card .rank { font-size: calc(var(--w) * 0.32); }
.mud-zoom .mud-bigset-cards .card .suit { font-size: calc(var(--w) * 0.28); }
#mudZoomDone { flex: 0 0 auto; height: 36px; min-height: 0; padding: 0 16px; font-size: 15px; font-weight: 900; border-radius: 12px; width: auto; }

/* =============== MUD: TV =============== */
/* laid out like Craps: the table on the left, a side panel off the felt on the right */
.mud-tv { display: flex; flex-direction: column; overflow: hidden; position: relative; }
/* the oval table, like Hold'em, as big as the screen allows: it fills its whole area right to the screen's left and
   bottom edges, and the felt is drawn bigger still, so its rail runs off the screen and every seat sits on the felt.
   --u is 1% of the area's width (or height, when that's tighter), so everything on it scales together. */
.mud-oval-wrap { min-width: 0; min-height: 0; container-type: size; position: relative; }
.mud-oval { position: absolute; inset: 0; --u: min(1cqw, 1.65cqh); }
.mud-felt { position: absolute; inset: 0; border-radius: 11% / 18%; border: calc(var(--u) * 1.3) solid var(--rail);
  background: radial-gradient(ellipse at center, var(--felt-1), var(--felt-2) 75%); box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5), 0 10px 40px rgba(0, 0, 0, 0.6); }
.mud-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: flex-end; gap: calc(var(--u) * 1.6); }
.mud-tv-deck, .mud-tv-pile { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1);
  font-size: calc(var(--u) * 0.95); font-weight: 800; color: rgba(255, 255, 255, 0.75); }
.mud-center .card { --w: calc(var(--u) * 6.2); }
/* the pile on the TV: the top card with the 4 under it peeking out to its left (rank in the corner) */
.mud-tv-stack { position: relative; display: flex; align-items: flex-end; }
.mud-tv-stack:has(.under) { padding-left: calc(var(--u) * 7.6); }
.mud-tv-stack .card.under { position: absolute; bottom: 0; right: 0; translate: calc(var(--k) * var(--u) * -1.9) 0;
  align-items: flex-start; justify-content: flex-start; padding: calc(var(--w) * 0.05) 0 0 calc(var(--w) * 0.06); gap: 0; }
.mud-tv-stack .card.under .rank { font-size: calc(var(--w) * 0.24); }
.mud-tv-stack .card.under .suit { font-size: calc(var(--w) * 0.2); }
.mud-tv-stack .card.under.mud-joker .suit { font-size: calc(var(--w) * 0.1); }
.mud-tv-stack .card.top { position: relative; z-index: 2; }
.mud-tv-pile .card.top { box-shadow: 0 0 0 calc(var(--u) * 0.3) var(--accent), 0 0.4vh 1vh rgba(0, 0, 0, 0.5); }
.mud-tv-pile .card.fresh { animation: deal 0.35s ease-out; }
.mud-older { position: absolute; left: 50%; top: 59%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: flex-end; gap: calc(var(--u) * 0.3); max-width: 44%; }
.mud-older-label { font-size: calc(var(--u) * 0.85); font-weight: 800; color: rgba(255, 255, 255, 0.6); white-space: nowrap; }
.mud-older-row { display: flex; align-items: flex-start; gap: calc(var(--u) * 0.35); }
.mud-older-chip { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.15); }
.mud-older-chip i { font-style: normal; font-size: calc(var(--u) * 0.7); font-weight: 800; color: rgba(255, 255, 255, 0.5); }
.mud-older .mud-mini { font-size: calc(var(--u) * 1.1); padding: calc(var(--u) * 0.35) calc(var(--u) * 0.25); min-width: calc(var(--u) * 2.1); }
.mud-more { font-size: calc(var(--u) * 0.9); font-weight: 800; color: rgba(255, 255, 255, 0.6); margin-right: calc(var(--u) * 0.3); }
/* a seat on the rail: stage number, name, what the stage is, then the cards face down with the count above */
.mud-seat { position: absolute; transform: translate(-50%, -50%); width: calc(var(--u) * 16); z-index: 2;
  background: var(--panel); border-radius: calc(var(--u) * 1); padding: calc(var(--u) * 0.6) calc(var(--u) * 0.7) calc(var(--u) * 0.7);
  border: calc(var(--u) * 0.25) solid transparent; box-shadow: inset 0 calc(var(--u) * 0.35) 0 var(--c, transparent), 0 0.6vh 1.6vh rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.25); transition: border-color 0.2s, box-shadow 0.2s; }
.mud-seat.turn { border-color: var(--accent); box-shadow: inset 0 calc(var(--u) * 0.35) 0 var(--c, transparent), 0 0 2vw rgba(245, 197, 66, 0.55); }
.mud-seat-head { display: flex; align-items: center; gap: calc(var(--u) * 0.5); max-width: 100%; }
.mud-seat-name { font-size: calc(var(--u) * 1.5); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mud-seat .mud-stg { --s: calc(var(--u) * 2.1); }
.mud-down { color: #59d98e; font-weight: 900; font-size: calc(var(--u) * 1.4); }
.mud-stage-text { font-size: calc(var(--u) * 1.05); font-weight: 900; color: var(--mud-stage); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mud-hand-count { font-size: calc(var(--u) * 1.15); font-weight: 900; line-height: 1; margin-top: calc(var(--u) * 0.2); }
.mud-backs { position: relative; height: calc(var(--u) * 2.8 * 1.4); width: calc(var(--u) * 2.8 + (var(--n, 1) - 1) * var(--u) * 0.7); }
.mud-backs .card { --w: calc(var(--u) * 2.8); position: absolute; left: calc(var(--k) * var(--u) * 0.7); bottom: 0; box-shadow: -1px 0 3px rgba(0, 0, 0, 0.4); }
.mud-backs.empty { width: 0; }
/* the groups a player has laid down, on the felt in front of their seat */
.mud-zone { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.4); max-width: calc(var(--u) * 22); }
.mud-zone .mud-minis { display: flex; flex-wrap: nowrap; }
.mud-zone .mud-mini { font-size: calc(var(--u) * 1.2); padding: calc(var(--u) * 0.4) calc(var(--u) * 0.25); min-width: calc(var(--u) * 2.5); margin-left: calc(var(--u) * -0.45); }
.mud-zone .mud-mini:first-child { margin-left: 0; }
.mud-zone .mud-group.new .mud-minis { animation: mud-drop 0.6s ease-out; }
@keyframes mud-drop { from { transform: translateY(-2vh); opacity: 0; } to { transform: none; opacity: 1; } }
/* the side panel */
.mud-side { display: flex; flex-direction: column; gap: 1vh; min-height: 0; min-width: 0; }
.mud-side .panel-box { background: var(--panel); border-radius: 14px; padding: 1vh 1vw; }
.mud-msg { text-align: center; font-size: 1.5vw; font-weight: 900; line-height: 1.2; min-height: 4.6vw; display: flex; flex-direction: column; justify-content: center; }
.mud-msg .sub { display: block; font-size: 1vw; color: rgba(255, 255, 255, 0.75); font-weight: 700; margin-top: 0.3vh; }
.mud-tv-timer { margin-top: 0.6vh; }
.mud-players { display: flex; flex-direction: column; gap: 0.5vh; flex-shrink: 0; }
.mud-player { display: flex; align-items: center; gap: 0.6vw; background: var(--panel); border-radius: 10px; padding: 0.6vh 0.8vw; font-size: 1vw; font-weight: 700;
  border-left: 0.4vw solid var(--c); }
.mud-player.turn { box-shadow: 0 0 0 2px var(--accent); }
.mud-player .mud-stg { --s: 1.6vw; }
.mud-player .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mud-player .cc { color: var(--muted); font-size: 0.85vw; white-space: nowrap; }
.mud-player .pts { font-weight: 900; white-space: nowrap; min-width: 4.4vw; text-align: right; }
.mud-ladder-box { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.5vh; overflow: hidden; }
.mud-side-title { font-size: 1.05vw; font-weight: 900; color: var(--mud-stage); flex-shrink: 0; }
.mud-ladder { display: flex; flex-direction: column; gap: 0.3vh; min-height: 0; }
.mud-rung { display: flex; align-items: center; gap: 0.5vw; font-size: 0.9vw; font-weight: 700; line-height: 1.2; padding: 0.15vh 0.3vw; border-radius: 0.5vw; }
.mud-rung .mud-stg { --s: 1.35vw; opacity: 0.55; }
.mud-rung.has { background: rgba(255, 255, 255, 0.07); }
.mud-rung.has .mud-stg { opacity: 1; }
.mud-rung .txt { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mud-rung .who { display: flex; gap: 0.2vw; flex-shrink: 0; }
.mud-rung .who i { font-style: normal; width: 1.3vw; height: 1.3vw; border-radius: 50%; font-size: 0.75vw; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; color: #111; }
.mud-log { flex-shrink: 0; display: flex; flex-direction: column; gap: 0.3vh; font-size: 0.9vw; font-weight: 700; color: rgba(255, 255, 255, 0.7); }
.mud-log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mud-log div:first-child { color: #fff; }
/* the score table between hands */
.mud-scores { position: absolute; top: 34vh; left: 6vw; right: 33vw; max-height: 62vh; overflow: hidden; z-index: 20; background: rgba(10, 20, 15, 0.94); border-radius: 2vw; border: 0.3vw solid var(--accent);
  padding: 3vh 2.5vw; display: flex; flex-direction: column; gap: 1.2vh; box-shadow: 0 2vh 6vh rgba(0, 0, 0, 0.6); }
.mud-scores h2 { margin: 0; font-size: 2.4vw; text-align: center; }
.mud-scores .row { display: grid; grid-template-columns: 1fr 9vw 7vw 8vw; gap: 1vw; font-size: 1.5vw; font-weight: 800; align-items: center; padding: 0.6vh 1vw; border-radius: 1vw; background: rgba(255, 255, 255, 0.06); }
.mud-scores .row.head { background: none; font-size: 1.05vw; color: rgba(255, 255, 255, 0.6); }
.mud-scores .up { color: #59d98e; }
.mud-scores .stay { color: rgba(255, 255, 255, 0.55); }
.mud-tv .hidden { display: none !important; }

.mud-dig-fan.grabbing { cursor: grabbing; }
.mud-dig-fan { cursor: grab; }


/* Phase 8: points on each player chip (item 13) */
.mud-pts { font-style: normal; color: var(--accent); }
#mudOpps .mud-opp span { gap: 3px; }
/* the score table on the phone: handover, the Scores tab, Last hand (items 11 and 15) */
.mud-scores-ph { width: 100%; font-size: 13px; }
.mud-scores-ph h3 { margin: 0 0 6px; font-size: 14px; text-align: center; color: var(--accent); }
.mud-scores-ph .row { display: grid; grid-template-columns: 1.6fr 1.2fr 0.9fr 0.8fr; gap: 6px; padding: 5px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); align-items: center; }
.mud-scores-ph .row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mud-scores-ph .row span:not(:first-child) { text-align: center; }
.mud-scores-ph .row.head { font-size: 11px; color: rgba(255, 255, 255, 0.6); font-weight: 800; }
.mud-scores-ph .row.me { background: rgba(245, 197, 66, 0.12); border-radius: 6px; }
.mud-scores-ph .up { color: #59d98e; font-weight: 800; }
.mud-scores-ph .stay { color: rgba(255, 255, 255, 0.7); }
#mudOpps:has(.mud-opp:nth-child(5)) .mud-opp span { font-size: 10px; gap: 2px; }
#mudOpps:has(.mud-opp:nth-child(5)) .mud-opp .mud-stg { --s: 15px; }

/* ---------- TV: the house frame (tv-frame.js). The seats are a name pill over the stage and the cards face down (no box);
   the game's name is printed on the felt just under the deck and pile; the side panel's extra is the ladder. ---------- */
.mud-tv .mud-seat { background: none; border: 0; box-shadow: none; padding: 0; gap: calc(var(--u) * 0.3); }
.mud-tv .mud-seat .hf-name { font-size: calc(var(--u) * 1.5); max-width: 100%; }
.mud-tv .mud-stage-text { display: flex; align-items: center; gap: calc(var(--u) * 0.4); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.mud-tv .mud-stage-text .mud-stg { --s: calc(var(--u) * 1.6); }
.mud-tv .mud-stage-text .mud-down { font-size: calc(var(--u) * 1.2); }
.mud-tv .mud-hand-count { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.mud-tv .hf-felt-name { top: 61%; --hf-name: 2.2vw; }
/* the panel: the stage number in each row, the ladder and (between hands) the score table in the extra */
.mud-tv .hf-row .hf-nm .mud-stg { --s: 1.35vw; margin-right: 0.45vw; vertical-align: middle; }
.mud-tv .hf-extra .mud-ladder { display: flex; flex-direction: column; gap: 0.3vh; }
.mud-tv .hf-extra .mud-rung { color: var(--text); }
.mud-tv .hf-extra h4 { text-transform: none; letter-spacing: 0.02em; font-size: 0.95vw; }
.mud-scores-tv .row { display: grid; grid-template-columns: minmax(0, 1fr) 7vw 4.4vw 4.4vw; gap: 0.6vw; font-size: 0.95vw; font-weight: 800; color: var(--text);
  align-items: center; padding: 0.4vh 0.5vw; border-radius: 0.6vw; background: rgba(255, 255, 255, 0.05); margin-bottom: 0.4vh; }
.mud-scores-tv .row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mud-scores-tv .row span:not(:first-child) { text-align: center; }
.mud-scores-tv .row.head { background: none; font-size: 0.8vw; color: var(--muted); }
.mud-scores-tv .up { color: #59d98e; }
.mud-scores-tv .stay { color: var(--muted); }
/* Scan to join in the side panel: anyone who scans in mid-game watches, then is dealt in at the next hand */
#joinCornerMud .jc-title::after { content: ' · WATCH'; color: var(--accent); }
