:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-elevated: #243044;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #3d9cf0;
  --accent-dim: #2a6fad;
  --gold: #f0c14b;
  --gold-dim: #b8922e;
  --danger: #e85d5d;
  --success: #3ecf8e;
  --warning: #f0a030;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --app-max: 480px;
  /* Tools row + single-row Canasta actions (5 dual/shared buttons) */
  --play-actions-h: 6.5rem;
  --comms-bg: #1e3a56;
  --comms-bg-elevated: #2a4d6e;
  --comms-bg-deep: #173049;
  --comms-border: rgba(120, 185, 240, 0.32);
  --comms-shadow: 0 10px 36px rgba(20, 60, 100, 0.45), 0 0 0 1px rgba(100, 175, 235, 0.12);
  /* Playing cards — overridden per viewport (desktop larger, phone compact) */
  --card-w: 2.7rem;
  --card-h: 3.75rem;
  --card-sm-w: 2.45rem;
  --card-sm-h: 3.4rem;
  --card-rank-size: 0.78rem;
  --card-sm-rank-size: 0.9rem;
  --stock-w: 2.85rem;
  --stock-h: 4rem;
  --stock-btn-w: 3.1rem;
  --stock-btn-h: 4.35rem;
  /* Hand always shows 2 card rows; extra rows scroll inside .hand-cards */
  --hand-label-h: 1.15rem;
  --hand-cards-gap: 0.18rem;
  --hand-pad-y: 0.5rem;
  --hand-2row-h: calc(
    var(--hand-label-h) + var(--hand-pad-y) + (var(--card-h) * 2) + var(--hand-cards-gap)
  );
}

/* ——— Play layout: lock to viewport; board flexes, actions stay visible ——— */
html:has(body.play-active),
body.play-active {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

body.play-active {
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center; /* keep max-width app centered */
}

body.play-active .app {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--app-max);
  height: 100%;
  max-height: 100%;
  min-height: 0 !important; /* beat generic .app { min-height: 100vh } */
  margin: 0 auto;
  overflow: hidden;
  padding: 0.25rem 0.55rem 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Keep platform bar visible; slightly tighter so play still fits */
body.play-active .games-platform-bar {
  display: block;
  flex: 0 0 auto;
}

body.play-active .games-platform-bar-inner {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

/* Top line: logo | volume | deal/code/link | conn */
body.play-active .brand {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem 0.65rem;
  text-align: left;
  padding: 0.15rem 0 0.25rem;
  margin: 0;
  flex: 0 0 auto;
}

body.play-active .brand h1 {
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  margin: 0;
  flex: 0 0 auto;
}

body.play-active .brand .sound-control {
  margin: 0;
  flex: 0 0 auto;
  transform: scale(0.9);
  transform-origin: left center;
}

body.play-active .brand-play-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
  font-size: 0.72rem;
}

body.play-active .brand-play-meta.hidden {
  display: none !important;
}

body.play-active .brand-deal {
  color: var(--muted);
  white-space: nowrap;
}

body.play-active .brand-code {
  font-weight: 700;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

body.play-active .brand .btn-copy-link {
  padding: 0.2rem 0.45rem;
  font-size: 0.68rem;
  border-radius: 6px;
}

body.play-active .brand .conn-status {
  margin: 0;
  font-size: 0.62rem;
  flex: 0 0 auto;
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.play-active #screen-play {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding-bottom: 0;
  overflow: hidden;
}

/*
 * Board column (between platform chrome and action dock):
 *   top chrome (fixed) → two meld panels (equal flex) → hand (fixed 2 rows)
 */
body.play-active .play-board-compact {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding-bottom: 0.05rem;
}

/* Banners / strips never steal flex from melds+hand */
body.play-active .play-board-compact > .spectator-banner,
body.play-active .play-board-compact > .spectators-strip,
body.play-active .play-board-compact > .vote-kick-banner,
body.play-active .play-board-compact > .play-top-block,
body.play-active .play-board-compact > .play-row-piles-status {
  flex: 0 0 auto;
}

/*
 * Top chrome grid — piles span status + turn so no dead gap under stock:
 *   [ piles  ] [ team1 | team2 ]
 *   [        ] [ turn  | last  ]
 *              [ meld-hint     ]
 */
.play-top-block.play-row-piles-status,
.play-row-piles-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  gap: 0.18rem 0.3rem;
  flex: 0 0 auto;
  align-items: stretch;
  min-height: 0;
  max-height: none;
}

.play-top-block .piles-panel {
  grid-column: 1;
  grid-row: 1 / 3; /* span team stats + turn row — removes empty under piles */
  align-self: stretch;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}

.play-top-block .team-stats-row {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.play-top-block .play-turn-row {
  grid-column: 2;
  grid-row: 2;
}

.play-top-block > .meld-hint-line {
  grid-column: 2;
  grid-row: 3;
  margin: 0;
  font-size: 0.62rem;
  min-height: 0;
  line-height: 1.2;
}

.play-top-block > .meld-hint-line:empty {
  display: none;
}

/* Hand: reserved height for exactly 2 visible card rows */
body.play-active .hand-area {
  flex: 0 0 auto;
  height: var(--hand-2row-h);
  min-height: var(--hand-2row-h);
  max-height: var(--hand-2row-h);
}

.piles-panel {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 0.35rem 0.45rem 0.4rem;
}

.team-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  min-width: 0;
}

.status-panel {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 0.28rem 0.4rem 0.32rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  justify-content: flex-start;
}

.status-panel-us {
  border-color: rgba(62, 207, 142, 0.4);
  box-shadow: inset 3px 0 0 rgba(62, 207, 142, 0.7);
  background: rgba(62, 207, 142, 0.06);
}

.status-panel-them {
  border-color: rgba(232, 93, 93, 0.35);
  box-shadow: inset 3px 0 0 rgba(232, 93, 93, 0.6);
  background: rgba(232, 93, 93, 0.05);
}

/* Name left · score right on one line */
.status-panel-head {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
  min-width: 0;
}

.status-panel-heading {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-panel-us .status-panel-heading {
  color: #7de0b0;
}

.status-panel-them .status-panel-heading {
  color: #f0a0a0;
}

.status-panel-score {
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}

.status-panel-us .status-panel-score {
  color: #9aecc4;
}

.status-panel-them .status-panel-score {
  color: #f0b0b0;
}

.status-panel-members {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.status-member {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 0.2rem 0.3rem;
  font-size: 0.68rem;
  line-height: 1.15;
  padding: 0.08rem 0.25rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.15);
  min-width: 0;
}

.status-member.is-turn {
  box-shadow: 0 0 0 1px var(--accent);
}

.status-member.is-you {
  background: rgba(62, 207, 142, 0.18);
}

.status-member.is-partner {
  background: rgba(61, 156, 240, 0.16);
}

.status-member-role {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex: 0 0 auto;
}

.status-member-name {
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-member-cards {
  color: var(--muted);
  font-size: 0.62rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.status-panel-meta {
  font-size: 0.58rem;
  color: var(--muted);
  line-height: 1.15;
}

/* Turn + last-action: compact equal columns under team1 / team2 */
.play-turn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.22rem;
  flex: 0 0 auto;
  min-height: 0;
  font-size: 0.72rem;
  align-items: center;
}

.play-turn-row .turn-banner {
  margin: 0;
  padding: 0.12rem 0.35rem;
  font-size: 0.68rem;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

.play-turn-row .last-action {
  margin: 0;
  padding: 0.12rem 0.35rem;
  font-size: 0.62rem;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-radius: 6px;
  color: var(--muted);
  min-width: 0;
  max-width: none;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.meld-hint-line {
  margin: 0;
  font-size: 0.62rem;
}

/* Sit-down / stand-up (Bank parity) */
.sit-down-panel {
  margin-top: 0.2rem;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  background: rgba(36, 48, 68, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-height: 5rem;
  overflow-y: auto;
}

.sit-down-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.sit-down-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sit-down-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.8rem;
}

.sit-down-row button {
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 8px;
  background: rgba(62, 207, 142, 0.2);
  color: var(--success);
  border: 1px solid rgba(62, 207, 142, 0.35);
  font-weight: 700;
}

/* Your-turn announce (Bank green) */
.turn-announce {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(6, 22, 16, 0.78);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.turn-announce.is-visible {
  opacity: 1;
  visibility: visible;
}

.turn-announce-card {
  text-align: center;
  max-width: min(92vw, 22rem);
  width: 100%;
  padding: 1.5rem 1.35rem 1.35rem;
  border-radius: 22px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(62, 207, 142, 0.4), transparent 60%),
    linear-gradient(165deg, #0f3d2a 0%, #122820 55%, #0a1812 100%);
  border: 2px solid rgba(62, 207, 142, 0.7);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 40px rgba(62, 207, 142, 0.25);
  transform: scale(0.9);
  transition: transform 0.35s cubic-bezier(0.22, 1.2, 0.36, 1);
}

.turn-announce.is-visible .turn-announce-card {
  transform: scale(1);
}

.turn-announce-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #7de0b0;
  margin-bottom: 0.35rem;
}

.turn-announce-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
}

.turn-announce-discard {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.turn-announce-discard.hidden {
  display: none !important;
}

.turn-announce-discard-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.turn-announce-discard-face .card-face {
  width: 3.6rem !important;
  height: 5rem !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.turn-announce-sub {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  color: #9ed4bc;
}

/* Idle turn reminder (amber) — always click-through; never blocks the table */
.turn-idle-announce {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: auto;
  inset: unset;
  z-index: 290;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4.25rem 0.75rem 0;
  background: transparent;
  pointer-events: none !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.turn-idle-announce.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: none !important;
}

.turn-idle-announce *,
.turn-idle-announce.is-visible * {
  pointer-events: none !important;
}

.turn-idle-announce-card {
  text-align: center;
  max-width: min(92vw, 22rem);
  width: 100%;
  padding: 1.1rem 1.2rem;
  border-radius: 16px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(240, 160, 48, 0.35), transparent 60%),
    linear-gradient(165deg, #3d2a10 0%, #1a2332 100%);
  border: 2px solid rgba(240, 160, 48, 0.65);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  pointer-events: none !important;
}

.turn-idle-announce-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--warning);
  margin-bottom: 0.3rem;
}

.turn-idle-announce-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.turn-idle-announce-sub {
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: #e8c98a;
}

.status-panel .scores-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
}

.status-panel .turn-banner {
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.2;
  min-height: 0;
}

.status-panel .last-action {
  margin: 0;
  padding: 0;
  font-size: 0.65rem;
  line-height: 1.15;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  opacity: 1;
}

.status-panel .meld-hint-line {
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.2;
}

.score-chip {
  background: var(--bg-elevated);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
}

.opponent-chip {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  font-size: 0.68rem;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
}

.opponent-chip.is-turn {
  border-color: var(--accent);
}

.opp-name {
  font-weight: 700;
}

.opp-meta {
  color: var(--muted);
  font-size: 0.65rem;
}

.turn-banner.is-you {
  color: var(--gold);
  font-weight: 700;
}

/* Stock = stacked card backs (sizes via --stock-* tokens) */
.stock-stack {
  position: relative;
  width: var(--stock-btn-w);
  height: var(--stock-btn-h);
  padding: 0;
  border: none;
  background: transparent;
  flex: 0 0 auto;
}

.stock-stack-layers {
  position: absolute;
  inset: 0;
}

.stock-stack .card-back.layer {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--stock-w);
  height: var(--stock-h);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 40%),
    repeating-linear-gradient(
      -32deg,
      #1a3a6a 0 3px,
      #24508f 3px 6px
    );
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.stock-stack .card-back.layer:nth-child(1) {
  transform: translate(0, 0);
  z-index: 1;
}
.stock-stack .card-back.layer:nth-child(2) {
  transform: translate(2px, -2px);
  z-index: 2;
}
.stock-stack .card-back.layer:nth-child(3) {
  transform: translate(4px, -4px);
  z-index: 3;
}

.stock-stack-count {
  position: absolute;
  left: 50%;
  bottom: -0.05rem;
  transform: translateX(-35%);
  z-index: 4;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  padding: 0 0.3rem;
  line-height: 1.3;
}

.stock-stack.is-empty {
  opacity: 0.4;
}

.discard-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem;
  border: none;
  background: transparent;
  min-width: calc(var(--stock-w) + 0.55rem);
  position: relative;
  pointer-events: none; /* display only — take via Take pile button */
  user-select: none;
}

.discard-top-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--stock-h);
  min-width: var(--stock-w);
  font-size: 0.7rem;
  color: var(--muted);
}

.discard-top-slot .card-face {
  width: var(--stock-w) !important;
  height: var(--stock-h) !important;
}

.discard-stack-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.discard-stack-label {
  opacity: 0.75;
  text-transform: lowercase;
}

.freeze-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  /* Cool ice blue */
  background: linear-gradient(165deg, rgba(140, 210, 255, 0.95) 0%, rgba(70, 150, 230, 0.92) 55%, rgba(50, 120, 200, 0.95) 100%);
  color: #eaf6ff;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border: 1px solid rgba(200, 235, 255, 0.75);
  box-shadow:
    0 0 10px rgba(100, 190, 255, 0.45),
    0 2px 6px rgba(0, 40, 80, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 1px rgba(0, 40, 80, 0.35);
  z-index: 2;
}

.freeze-badge.hidden {
  display: none !important;
}

.discard-stack.is-frozen {
  outline: 2px solid rgba(120, 200, 255, 0.9);
  outline-offset: 2px;
  border-radius: 8px;
  background: rgba(80, 160, 230, 0.12);
  box-shadow: 0 0 16px rgba(100, 190, 255, 0.25);
}

.discard-stack.is-frozen .discard-top-slot {
  box-shadow: 0 0 14px rgba(100, 200, 255, 0.5);
}

/* Meld panels — equal share of remaining height under top chrome / above hand */
.meld-panel {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 0.18rem 0.32rem 0.22rem;
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  overflow: hidden;
}

.meld-panel.team-us {
  border-color: rgba(62, 207, 142, 0.35);
  box-shadow: inset 3px 0 0 rgba(62, 207, 142, 0.65);
}

.meld-panel.team-them {
  border-color: rgba(232, 93, 93, 0.3);
  box-shadow: inset 3px 0 0 rgba(232, 93, 93, 0.55);
}

.meld-panel-us {
  flex: 1 1 0;
  max-height: none;
}

.meld-panel-title {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  flex: 0 0 auto;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meld-panel.team-us .meld-panel-title {
  color: #7de0b0;
}

.meld-panel.team-them .meld-panel-title {
  color: #f0a0a0;
}

.melds-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  align-items: flex-start;
  align-content: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.melds-side-label {
  width: 100%;
  font-size: 0.62rem;
  color: var(--muted);
  margin: 0;
}

.meld-empty {
  margin: 0;
  font-size: 0.68rem;
  opacity: 0.75;
  line-height: 1.35;
}

.meld-empty .meld-empty-detail {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.62rem;
  opacity: 0.9;
  color: var(--muted);
}

.meld-pile,
button.meld-pile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.2rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.25rem 0.4rem 0.4rem;
  color: inherit;
  width: auto;
  height: auto !important;
  min-height: calc(var(--card-sm-h) + 1.35rem) !important;
  max-height: none !important;
  flex: 0 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
  line-height: 1.1;
  overflow: visible;
}

.meld-pile.selected {
  outline: 2px solid var(--accent);
}

.meld-pile.canasta-pure {
  border-color: rgba(240, 193, 75, 0.75);
  background: linear-gradient(165deg, rgba(240, 193, 75, 0.22) 0%, rgba(40, 32, 12, 0.55) 100%);
  box-shadow: 0 0 0 1px rgba(240, 193, 75, 0.4), inset 0 0 18px rgba(240, 193, 75, 0.08);
}

.meld-pile.canasta-mixed {
  border-color: rgba(140, 160, 210, 0.7);
  background: linear-gradient(165deg, rgba(120, 140, 190, 0.28) 0%, rgba(20, 24, 36, 0.55) 100%);
  box-shadow: 0 0 0 1px rgba(140, 160, 210, 0.35), inset 0 0 18px rgba(100, 120, 180, 0.1);
}

.meld-pile.canasta-collapsed {
  min-width: 3.4rem;
}

.meld-pile.canasta-pure .meld-pile-title {
  color: #f0c14b;
}

.meld-pile.canasta-mixed .meld-pile-title {
  color: #b8c8e8;
}

.canasta-count-badge {
  position: absolute;
  right: -0.15rem;
  bottom: -0.15rem;
  z-index: 20;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.15rem;
  text-align: center;
}

.meld-pile-static {
  cursor: default;
}

.meld-pile-title {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.1;
  flex: 0 0 auto;
}

/* Stacked cards — horizontal fan, never flex-squished */
.card-stack {
  position: relative;
  display: block;
  flex: 0 0 auto;
  padding-right: 0;
  overflow: visible;
  height: var(--card-sm-h) !important;
  min-height: var(--card-sm-h) !important;
  max-height: var(--card-sm-h) !important;
  width: calc(
    var(--card-sm-w) + (var(--stack-n, 1) - 1) * var(--card-sm-w) * 0.45
  );
}

.card-stack .card-face.card-stacked {
  position: absolute !important;
  top: 0;
  left: calc(var(--stack-i, 0) * (var(--card-sm-w) * 0.45));
  width: var(--card-sm-w) !important;
  height: var(--card-sm-h) !important;
  min-width: var(--card-sm-w) !important;
  min-height: var(--card-sm-h) !important;
  max-width: var(--card-sm-w) !important;
  max-height: var(--card-sm-h) !important;
  margin: 0 !important;
  z-index: calc(1 + var(--stack-i, 0));
  box-sizing: border-box;
  flex: none !important;
}

/* Collapsed canasta stack */
.card-stack.card-stack-canasta {
  width: calc(var(--card-sm-w) + var(--card-sm-w) * 0.35) !important;
  height: var(--card-sm-h) !important;
  min-height: var(--card-sm-h) !important;
}

.red-threes-pile .meld-pile-title {
  color: #f28b8b;
}

/* Roster chips — clear You / Partner / Opponent */
.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
}

.roster-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.35rem;
  border-radius: 8px;
  padding: 0.15rem 0.4rem;
  font-size: 0.68rem;
  border: 1px solid transparent;
  line-height: 1.2;
}

.roster-chip.is-turn {
  box-shadow: 0 0 0 1px var(--accent);
}

.roster-you {
  background: rgba(62, 207, 142, 0.15);
  border-color: rgba(62, 207, 142, 0.4);
}

.roster-partner {
  background: rgba(61, 156, 240, 0.15);
  border-color: rgba(61, 156, 240, 0.45);
}

.roster-opp {
  background: rgba(232, 93, 93, 0.12);
  border-color: rgba(232, 93, 93, 0.35);
}

.roster-role {
  font-weight: 800;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.roster-you .roster-role {
  color: #7de0b0;
}
.roster-partner .roster-role {
  color: #7eb8f0;
}
.roster-opp .roster-role {
  color: #f0a0a0;
}

.roster-name {
  font-weight: 700;
}

.roster-meta {
  color: var(--muted);
  font-size: 0.62rem;
}

.score-chip {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  align-items: flex-start;
  max-width: 100%;
}

.score-chip-us {
  background: rgba(62, 207, 142, 0.14) !important;
  border-color: rgba(62, 207, 142, 0.4) !important;
}

.score-chip-them {
  background: rgba(232, 93, 93, 0.12) !important;
  border-color: rgba(232, 93, 93, 0.35) !important;
}

.score-chip-label {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.score-chip-us .score-chip-label {
  color: #7de0b0;
}
.score-chip-them .score-chip-label {
  color: #f0a0a0;
}

.score-chip-score {
  font-weight: 700;
  font-size: 0.8rem;
}

.score-chip-members {
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11rem;
}

.turn-banner.is-partner {
  color: #7eb8f0;
  font-weight: 700;
}

.lobby-team-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.lobby-team-0 {
  background: rgba(62, 207, 142, 0.2);
  color: #7de0b0;
  border: 1px solid rgba(62, 207, 142, 0.4);
}

.lobby-team-1 {
  background: rgba(232, 93, 93, 0.18);
  color: #f0a0a0;
  border: 1px solid rgba(232, 93, 93, 0.4);
}

.lobby-team-none {
  background: rgba(139, 155, 180, 0.15);
  color: var(--muted);
  border: 1px solid rgba(139, 155, 180, 0.3);
}

/* Lobby team picker */
.lobby-teams {
  margin: 0.85rem 0 0.5rem;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.lobby-teams-heading {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.lobby-teams-hint {
  margin: 0 0 0.45rem;
  font-size: 0.65rem;
  line-height: 1.3;
  color: var(--muted);
  opacity: 0.9;
}

.lobby-teams-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.lobby-team-card {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  min-width: 0;
}

.lobby-team-card[data-team='0'] {
  border-color: rgba(62, 207, 142, 0.35);
  box-shadow: inset 3px 0 0 rgba(62, 207, 142, 0.65);
}

.lobby-team-card[data-team='1'] {
  border-color: rgba(232, 93, 93, 0.3);
  box-shadow: inset 3px 0 0 rgba(232, 93, 93, 0.55);
}

.lobby-team-card.is-yours {
  outline: 2px solid rgba(61, 156, 240, 0.55);
}

.lobby-team-card-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.lobby-team-name-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

.lobby-team-name-input.is-readonly {
  opacity: 0.85;
  cursor: default;
}

.lobby-team-join {
  flex: 0 0 auto;
  white-space: nowrap;
}

.lobby-team-join.is-on-team {
  background: rgba(61, 156, 240, 0.2);
  color: var(--accent);
  border-color: rgba(61, 156, 240, 0.4);
}

.lobby-team-members {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 2.5rem;
}

.lobby-team-member {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  min-width: 0;
}

.lobby-team-member.is-you {
  font-weight: 700;
}

.lobby-team-member-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex: 0 0 auto;
}

.lobby-team-empty {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.lobby-team-ready {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--success);
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

.lobby-team-slots {
  margin: 0.4rem 0 0;
  font-size: 0.72rem;
}

.lobby-team-member-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Keep Swap / Move on the same row as the player name */
.lobby-team-member-actions {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
  width: auto;
  margin: 0;
  margin-left: auto;
  flex: 0 0 auto;
}

.lobby-team-member-actions .btn-ghost-sm {
  padding: 0.15rem 0.4rem;
  font-size: 0.65rem;
  line-height: 1.2;
  white-space: nowrap;
}

.lobby-swap-pending {
  font-size: 0.68rem;
  color: var(--warning);
  font-weight: 700;
}

.lobby-swap-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(240, 160, 48, 0.12);
  border: 1px solid rgba(240, 160, 48, 0.4);
  font-size: 0.85rem;
}

.lobby-swap-banner.hidden {
  display: none !important;
}

.lobby-swap-actions {
  display: flex;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.lobby-swap-actions .btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  width: auto;
}

@media (max-width: 420px) {
  .lobby-teams-grid {
    grid-template-columns: 1fr;
  }
}

.card-face {
  width: var(--card-w);
  height: var(--card-h);
  background: #fffcf5;
  color: #141414;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0.12rem 0.18rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  opacity: 1 !important; /* never inherit button:disabled dimming */
  cursor: pointer;
  line-height: 1.05;
}

/* Meld / discard display cards — full brightness, not clickable */
.card-face.card-face-static {
  cursor: default;
  pointer-events: none;
  opacity: 1 !important;
  filter: none;
}

.card-face.is-red,
.card-face.card-red-three,
.card-face.is-red .card-rank,
.card-face.is-red .card-suit,
.card-face.card-red-three .card-rank,
.card-face.card-red-three .card-suit {
  color: #c62828 !important;
}

.card-face.selected {
  outline: 2px solid var(--accent);
  transform: translateY(-2px);
}

.card-face.card-face-sm {
  width: var(--card-sm-w);
  height: var(--card-sm-h);
  padding: 0.12rem 0.16rem;
  font-size: 0.85rem;
  border-radius: 6px;
  background: #fffcf5;
  color: #141414;
}

.card-face.card-wild {
  background: linear-gradient(145deg, #fffdf0, #ffe8b8);
}

.card-face.card-red-three {
  background: #ffe8eb;
}

.card-face.card-black-three {
  background: #e8eef2;
  color: #141414 !important;
}

.card-face.card-black-three .card-rank,
.card-face.card-black-three .card-suit {
  color: #141414 !important;
}

.card-rank,
.card-suit {
  font-weight: 700;
  font-size: var(--card-rank-size);
  line-height: 1.05;
  color: inherit;
}

.card-face.card-face-sm .card-rank,
.card-face.card-face-sm .card-suit {
  font-size: var(--card-sm-rank-size);
  font-weight: 800;
  line-height: 1.05;
}

.card-face.card-stacked {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.02rem;
}



/* Discard pile face stays bright */
.discard-top-slot .card-face {
  background: #fffcf5;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.meld-pile .card-face {
  background: #fffcf5;
}

.hand-area {
  margin-top: 0 !important;
  padding: 0.22rem 0.35rem !important;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.hand-label-row {
  font-size: 0.68rem !important;
  margin-bottom: 0.1rem !important;
  flex: 0 0 auto;
  height: var(--hand-label-h);
  line-height: var(--hand-label-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 2 rows visible; further rows scroll */
.hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hand-cards-gap);
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  align-content: flex-start;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

/* 5 actions: Draw|Discard, Take pile, Meld, Add, Ask|Go out */
.play-actions-canasta {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
  width: 100%;
  flex: 0 0 auto;
}

.play-actions-canasta .btn-primary,
.play-actions-canasta .btn-secondary,
.play-actions-canasta .btn-ghost-sm {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none;
  flex: none !important;
  margin: 0;
  padding: 0.5rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
  border-radius: 8px;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  box-sizing: border-box;
}

.deal-end-summary {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.deal-end-hands {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.deal-end-hands-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.deal-end-hand-block {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-elevated);
  border-radius: 10px;
}

.deal-end-hand-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: baseline;
  font-size: 0.8rem;
}

.deal-end-hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.deal-end-hand-cards .card-face {
  width: 2.1rem !important;
  height: 2.95rem !important;
  font-size: 0.65rem;
}

.deal-end-row {
  padding: 0.65rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: 10px;
  font-size: 0.9rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Tighter dock on play — stays in flex flow under board */
body.play-active .play-actions {
  position: relative;
  left: auto;
  transform: none;
  bottom: auto;
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
  padding: 0.3rem 0 calc(0.3rem + env(safe-area-inset-bottom, 0px));
  gap: 0.25rem;
  background: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 5;
}

body.play-active .play-actions-tools .play-tool-btn {
  padding: 0.28rem 0.25rem;
  font-size: 0.7rem;
}

body.play-active #screen-play {
  /* dock is inside section, not fixed over content */
  padding-bottom: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 156, 240, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(240, 193, 75, 0.08), transparent),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 16px rgba(61, 156, 240, 0.35);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-ghost-sm,
.btn-sm,
.btn-copy-link,
.btn-copy-icon,
.btn-danger-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  width: auto;
}

.btn-danger-sm {
  background: rgba(232, 93, 93, 0.2);
  color: var(--danger);
  border: 1px solid rgba(232, 93, 93, 0.4);
}

.app {
  max-width: var(--app-max);
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  min-height: 100vh;
}

/* Match games.jonheaton.com: title + volume centered in the header */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.25rem 0 0.5rem;
  margin-bottom: 0.5rem;
}

.brand h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 55%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand .sound-control {
  margin: 0.5rem auto 0;
  justify-self: center;
}

.brand .conn-status {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.conn-status.is-live {
  color: var(--success);
}

.conn-status.is-down {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input,
.field select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg);
  color: var(--text);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.5rem 0;
}

.home-history-link,
.home-footer-links {
  text-align: center;
  margin-top: 1.25rem;
  line-height: 1.5;
}

.home-history-link a,
.home-footer-links a {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.home-footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.home-footer-sep {
  color: var(--muted);
  opacity: 0.55;
  margin: 0 0.35rem;
  user-select: none;
}

/* ---------- Static help pages (rules / how-to-play) ---------- */
.doc-page {
  padding-bottom: 3rem;
}

.doc-back {
  display: inline-block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.doc-back:hover {
  color: var(--text);
  text-decoration: underline;
}

.doc-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.85rem;
  margin: 0.25rem 0 1rem;
  font-size: 0.88rem;
}

.doc-nav a {
  color: var(--muted);
  text-decoration: none;
}

.doc-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.doc-nav a[aria-current='page'] {
  color: var(--gold);
  font-weight: 600;
}

.doc-article h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.doc-article h3 {
  margin: 1.35rem 0 0.45rem;
  font-size: 1.05rem;
  color: var(--gold);
  font-weight: 700;
}

.doc-article h4 {
  margin: 0 0 0.4rem;
  font-size: 0.98rem;
  color: var(--text);
}

.doc-article p,
.doc-article li,
.doc-article dd {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.doc-article ul,
.doc-article ol {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.25rem;
}

.doc-article li {
  margin-bottom: 0.35rem;
}

.doc-article a {
  color: var(--accent);
}

.doc-lead {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 0 0.75rem;
}

.doc-dl {
  margin: 0.5rem 0 0.85rem;
}

.doc-dl dt {
  font-weight: 700;
  margin-top: 0.55rem;
  color: var(--text);
}

.doc-dl dd {
  margin: 0.2rem 0 0.35rem 0;
  color: var(--muted);
  line-height: 1.5;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  font-size: 0.92rem;
}

.doc-table th,
.doc-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-table td:last-child {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--gold);
  font-weight: 600;
}

.doc-callout {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  background: rgba(61, 156, 240, 0.08);
  border: 1px solid rgba(61, 156, 240, 0.28);
}

.doc-callout p:last-child {
  margin-bottom: 0;
}

.doc-example {
  margin: 0.5rem 0 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.doc-example p {
  margin: 0.35rem 0;
  color: var(--muted);
}

.doc-example p:first-child {
  margin-top: 0;
}

.doc-example p:last-child {
  margin-bottom: 0;
}

.doc-example strong {
  color: var(--text);
}

.doc-footer-links {
  margin: 1.5rem 0 0.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-footer-links a {
  font-weight: 600;
}

/* Avatar swatches come from platform-shell (one row). */

.color-swatch.is-selected {
  border-color: #fff;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.4),
    0 1px 4px rgba(0, 0, 0, 0.35);
  transform: scale(1.08);
  z-index: 1;
}

.color-swatch.is-taken {
  opacity: 1;
  cursor: not-allowed;
}

/* ——— Lobby: balanced spacing (not cramped, avoid needless scroll) ——— */
body.lobby-active {
  overflow: auto;
}

body.lobby-active .app {
  --app-max: 480px;
  max-width: 480px;
  max-height: none;
  min-height: 100dvh;
  overflow: visible;
  padding: 1rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
}

body.lobby-active .games-platform-bar {
  flex: 0 0 auto;
}

body.lobby-active .games-platform-bar-inner {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

body.lobby-active .brand {
  flex: 0 0 auto;
  padding: 0.35rem 0 0.45rem;
  margin: 0;
}

body.lobby-active .brand h1 {
  font-size: 1.35rem;
  letter-spacing: 0.16em;
  margin: 0;
}

body.lobby-active .brand .sound-control {
  margin: 0.35rem 0 0;
  transform: none;
}

body.lobby-active .brand .conn-status {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
}

body.lobby-active #screen-lobby {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  gap: 0.75rem;
}

body.lobby-active .room-code-box {
  flex: 0 0 auto;
  padding: 0.75rem 0.9rem 0.8rem;
  margin-bottom: 0;
  border-radius: 12px;
}

body.lobby-active .room-code-box .label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

body.lobby-active .room-code-box .code {
  font-size: 1.85rem;
  letter-spacing: 0.24em;
  margin: 0.2rem 0;
  line-height: 1.2;
}

body.lobby-active .room-code-box .hint {
  font-size: 0.78rem;
  margin: 0.15rem 0 0;
}

body.lobby-active .invite-link-heading {
  display: none;
}

body.lobby-active .invite-link-row {
  margin-top: 0.5rem;
  gap: 0.4rem;
}

body.lobby-active .room-code-box .invite-link {
  padding: 0.35rem 0.5rem;
  font-size: 0.68rem;
  border-radius: 7px;
}

body.lobby-active .btn-copy-icon {
  width: auto;
  min-width: 4.5rem;
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  gap: 0.3rem;
}

body.lobby-active .lobby-card.card {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem 0.95rem 0.95rem;
  margin-bottom: 0;
  border-radius: 14px;
}

body.lobby-active .lobby-color-field {
  flex: 0 0 auto;
  margin: 0;
}

body.lobby-active .lobby-color-field label {
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body.lobby-active .lobby-waiting {
  flex: 0 0 auto;
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  min-height: 1.15em;
  line-height: 1.35;
}

body.lobby-active .lobby-actions {
  flex: 0 0 auto;
  margin-top: 0.25rem;
  gap: 0.45rem;
}

body.lobby-active .lobby-actions .btn-primary,
body.lobby-active .lobby-actions .btn-secondary {
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  border-radius: 10px;
  line-height: 1.25;
}

body.lobby-active .lobby-btn-row {
  gap: 0.45rem;
}

body.lobby-active .lobby-teams {
  flex: 0 0 auto;
  margin: 0.25rem 0 0;
  padding: 0.65rem 0.7rem 0.7rem;
  border-radius: 12px;
}

body.lobby-active .lobby-teams-heading {
  margin: 0 0 0.2rem;
  font-size: 0.9rem;
}

body.lobby-active .lobby-teams-hint {
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  line-height: 1.35;
}

body.lobby-active .lobby-teams-grid {
  gap: 0.5rem;
}

body.lobby-active .lobby-team-card {
  padding: 0.5rem 0.55rem 0.5rem;
  border-radius: 10px;
  min-height: 0;
}

body.lobby-active .lobby-team-card-head {
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

body.lobby-active .lobby-team-name-input {
  font-size: 0.82rem;
  padding: 0.3rem 0.45rem;
  min-height: 0;
  height: 1.9rem;
}

body.lobby-active .lobby-team-join {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
}

body.lobby-active .lobby-team-members {
  min-height: 1.6rem;
  gap: 0.25rem;
}

body.lobby-active .lobby-team-member {
  font-size: 0.8rem;
  gap: 0.3rem;
}

body.lobby-active .lobby-team-slots {
  margin: 0.3rem 0 0;
  font-size: 0.68rem;
}

body.lobby-active .lobby-players-section {
  flex: 0 0 auto;
  min-height: 0;
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

body.lobby-active .lobby-players-section h2 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

body.lobby-active .player-list {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

body.lobby-active .player-list li {
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.25rem;
  border-radius: 8px;
  gap: 0.3rem;
}

body.lobby-active .player-list .lobby-avatar {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.55rem;
}

body.lobby-active .player-list .badge,
body.lobby-active .player-list .lobby-team-badge {
  font-size: 0.58rem;
  padding: 0.08rem 0.3rem;
}

body.lobby-active .btn-player-icon {
  width: 1.4rem;
  height: 1.4rem;
}

/* Chat FAB sits lower; keep lobby clear of page scroll */
body.lobby-active .chat-toggle,
body.lobby-active #chat-toggle {
  bottom: 0.55rem;
}

/* —— Cut for 100 mini-game (4p) —— */
.cut-overlay {
  position: fixed;
  inset: 0;
  /* Above Your Turn announce (300) so cut result is never covered */
  z-index: 340;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(6, 14, 28, 0.88);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cut-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cut-overlay.is-showing-result {
  pointer-events: auto;
}

.cut-overlay-card {
  width: min(92vw, 22rem);
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 18px;
  background: linear-gradient(165deg, #152238 0%, #0e1624 100%);
  border: 1px solid rgba(120, 190, 255, 0.35);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5), 0 0 32px rgba(80, 160, 240, 0.12);
  text-align: center;
}

.cut-kicker {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #7ec8ff;
  margin-bottom: 0.35rem;
}

.cut-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.cut-sub {
  margin: 0.35rem 0 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.cut-deck-wrap {
  position: relative;
  height: 16.5rem;
  margin: 0 auto 1rem;
  max-width: 11rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.cut-deck {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 8%;
  bottom: 8%;
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
}

.cut-card-edge {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 252, 245, 0.35) 8%,
    rgba(255, 252, 245, 0.85) 50%,
    rgba(255, 252, 245, 0.35) 92%,
    transparent 100%
  );
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.15);
  flex: 0 0 auto;
}

.cut-card-edge.is-perfect {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(100, 210, 255, 0.2) 10%,
    rgba(140, 220, 255, 0.55) 50%,
    rgba(100, 210, 255, 0.2) 90%,
    transparent 100%
  );
}

.cut-blade {
  position: absolute;
  left: 4%;
  right: 4%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, #5ec8ff, #e8f7ff 40%, #5ec8ff);
  box-shadow: 0 0 12px rgba(100, 200, 255, 0.85), 0 0 2px #fff;
  z-index: 3;
  top: 50%;
  transition: none;
}

.cut-blade.is-frozen {
  background: linear-gradient(90deg, #f0c14b, #fff4c8 45%, #f0c14b);
  box-shadow: 0 0 14px rgba(240, 193, 75, 0.75);
}

.cut-blade.is-success {
  background: linear-gradient(90deg, #3ecf8e, #c8ffe0 45%, #3ecf8e);
  box-shadow: 0 0 18px rgba(62, 207, 142, 0.85);
}

.cut-deck-label {
  position: absolute;
  right: 0.35rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  z-index: 2;
}

.cut-deck-label-top {
  top: 0.35rem;
}

.cut-deck-label-bottom {
  bottom: 0.35rem;
}

.cut-perfect-mark {
  position: absolute;
  left: 2%;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid rgba(100, 210, 255, 0.75);
  z-index: 2;
  /* Default: 44th of 104 from bottom — JS updates for live cut.perfectFromBottom */
  bottom: calc(8% + (43.5 / 104) * 84%);
  transform: translateY(50%);
}

.cut-btn {
  width: 100%;
  max-width: 12rem;
  margin: 0 auto;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.7rem 1rem;
}

.cut-btn.hidden,
.cut-watch-hint.hidden,
.cut-result.hidden {
  display: none !important;
}

.cut-watch-hint {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
}

.cut-result {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.95rem;
}

.cut-result.is-success {
  background: rgba(62, 207, 142, 0.18);
  border: 1px solid rgba(62, 207, 142, 0.45);
  color: #7de0b0;
}

.cut-result.is-miss {
  background: rgba(139, 155, 180, 0.12);
  border: 1px solid rgba(139, 155, 180, 0.3);
  color: #c5d0e0;
}

.public-games-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.public-games-list {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0;
}

/* Keep horizontal padding — do not zero it out (shell uses .public-game-row) */
.public-games-list li,
.public-games-list .public-game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.45rem;
  box-sizing: border-box;
}

.public-games-list li:last-child,
.public-games-list .public-game-row:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.visibility-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-label,
.checkbox-label {
  display: flex;
  flex-direction: row;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

/*
 * .field label { display: block } and .field input { width: 100% } would otherwise
 * stack checkbox/radio above the description and stretch the control full-width.
 */
.field label.checkbox-label,
.field label.radio-label {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.35;
  cursor: pointer;
}

.field label.checkbox-label input[type='checkbox'],
.field label.radio-label input[type='radio'],
.field .checkbox-label input[type='checkbox'],
.field .radio-label input[type='radio'] {
  width: auto;
  min-width: 1.1rem;
  height: auto;
  margin: 0.2rem 0 0;
  padding: 0;
  flex: 0 0 auto;
  align-self: flex-start;
  accent-color: var(--accent);
  border: none;
  background: transparent;
  box-shadow: none;
}

.field label.checkbox-label > span,
.field label.radio-label > span {
  flex: 1 1 auto;
  min-width: 0;
}

/* Room code panel comes from platform-shell. */

.invite-link-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
}

.invite-link {
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
  max-width: 70%;
}

/* Lobby player rows — keep in sync with platform-shell/shell-lobby.css.
   Do not zero horizontal padding (clips avatars / team badges on the pill). */
.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.4rem;
  border-radius: 10px;
  background: var(--bg-elevated);
  border-bottom: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.player-list .name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.player-list .lobby-avatar {
  flex-shrink: 0;
}

.player-list .meta {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 58%;
  overflow: hidden;
}

.player-list .player-badges {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player-list .lobby-team-badge {
  margin-left: 0;
  flex-shrink: 0;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--muted);
  margin-left: 0;
  flex-shrink: 0;
}

.badge.ready {
  background: rgba(62, 207, 142, 0.2);
  color: var(--success);
}

.badge.host {
  background: rgba(240, 193, 75, 0.2);
  color: var(--gold);
}

.lobby-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.lobby-btn-row .btn-primary,
.lobby-btn-row .btn-secondary {
  width: 100%;
}

.game-start-banner,
.vote-kick-banner,
.spectator-banner {
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.game-start-banner {
  background: rgba(61, 156, 240, 0.2);
  border: 1px solid rgba(61, 156, 240, 0.4);
}

/* —— Pre-game start countdown (Bank parity) —— */
.game-start-announce {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-start-announce.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.game-start-announce-card {
  text-align: center;
  max-width: min(92vw, 22rem);
  padding: 1.75rem 1.5rem 1.5rem;
  border-radius: 20px;
  background: linear-gradient(165deg, #1c2838 0%, #121a24 100%);
  border: 1px solid rgba(240, 193, 75, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  transform: scale(0.92);
  transition: transform 0.28s ease;
}

.game-start-announce.is-visible .game-start-announce-card {
  transform: scale(1);
}

.game-start-announce-message {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 1rem;
}

.game-start-announce-caption {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.game-start-announce-count {
  font-size: 4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(240, 193, 75, 0.35);
}

/* —— Drawn card center reveal —— */
.draw-reveal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 12, 18, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.draw-reveal.is-visible {
  opacity: 1;
  pointer-events: none;
}

.draw-reveal-card {
  text-align: center;
  padding: 1.1rem 1.25rem 1.25rem;
  border-radius: 16px;
  background: linear-gradient(165deg, #1c2838 0%, #121a24 100%);
  border: 1px solid rgba(61, 156, 240, 0.35);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transform: scale(0.9);
  transition: transform 0.22s ease;
}

.draw-reveal.is-visible .draw-reveal-card {
  transform: scale(1);
}

.draw-reveal-caption {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.draw-reveal-face {
  display: flex;
  justify-content: center;
}

.draw-reveal-face .card-face {
  width: 4.5rem !important;
  height: 6.25rem !important;
  font-size: 1.1rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.draw-reveal-face .card-rank {
  font-size: 1.15rem !important;
}

.vote-kick-banner {
  background: rgba(240, 160, 48, 0.15);
  border: 1px solid rgba(240, 160, 48, 0.4);
}

/* One compact line: "Spectating · message" */
.spectator-banner {
  background: rgba(139, 155, 180, 0.15);
  border: 1px solid rgba(139, 155, 180, 0.3);
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  padding: 0.28rem 0.55rem;
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  line-height: 1.25;
  min-width: 0;
}

.spectator-banner strong {
  flex: 0 0 auto;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: #c4b5fd;
}

.spectator-banner #spectator-banner-text,
.spectator-banner span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #d4c4fc;
}

/* Override platform-shell column layout */
body.play-active .spectator-banner {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.4rem 0.55rem;
  margin-bottom: 0.3rem;
}

body.play-active .spectators-strip {
  margin: 0 0 0.3rem;
  padding: 0.2rem 0.1rem 0.3rem;
  font-size: 0.68rem;
}

/* Play */
#screen-play {
  padding-bottom: calc(var(--play-actions-h) + 0.5rem);
}

/* Fixed play action dock (Bank pattern: tools + primary row) */
.play-actions {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--app-max);
  z-index: 320;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  background: linear-gradient(
    to top,
    var(--bg) 0%,
    var(--bg) 78%,
    rgba(15, 20, 25, 0.92) 92%,
    transparent 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.play-actions-secondary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 0 1 auto;
  min-height: 0;
}

.play-actions-tools {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.4rem;
  width: 100%;
}

.play-actions-tools .play-tool-btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  margin-top: 0;
  padding: 0.45rem 0.4rem;
  font-size: 0.82rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}

.play-actions-tools .play-tool-btn .chat-unread {
  min-width: 1.1rem;
  height: 1.1rem;
  font-size: 0.65rem;
}

.play-actions-row {
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
  width: 100%;
  flex: 0 0 auto;
}

.play-actions-row .btn-primary,
.play-actions-row .btn-secondary,
.play-actions-row .btn-ghost-sm {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0.75rem 0.35rem;
  font-size: 0.88rem;
}

.play-actions .is-ghost,
.play-actions .hidden {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

/* Play chrome: deal left, room code right (sound lives under brand title) */
.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 0.65rem;
  color: var(--muted);
  gap: 0.4rem 0.5rem;
}

#play-deal {
  justify-self: start;
  min-width: 0;
}

.top-bar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  justify-self: end;
  min-width: 0;
}

.turn-banner {
  text-align: center;
  font-weight: 700;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: 10px;
  background: var(--bg-elevated);
}

.turn-banner.is-you {
  background: rgba(62, 207, 142, 0.18);
  color: var(--success);
}

.last-action {
  display: block;
  width: 100%;
  text-align: center;
  margin: 0 0 0.65rem;
  min-height: 1.2em;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: default;
}

.last-action.is-peekable {
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.last-action.is-peekable:hover {
  border-color: rgba(61, 156, 240, 0.4);
  background: rgba(61, 156, 240, 0.1);
  color: var(--accent);
}

.last-action:disabled {
  opacity: 1;
  cursor: default;
}

.score-chip.is-turn {
  border-color: var(--success);
}

.opponent-seat {
  flex: 1;
  min-width: 5rem;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.opponent-seat.is-turn {
  border-color: var(--success);
}

.table-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.hand-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.hand-sweeps {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: none;
  white-space: nowrap;
}

.table-cards,
.hand-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: var(--card-h);
  align-items: flex-start;
}

.playing-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 9px;
  background: #f7f4ef;
  color: #121212;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  font-weight: 800;
  font-size: 1.25rem;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding: 0.2rem 0.1rem 0.25rem;
  line-height: 1;
}

.playing-card.red {
  color: #c62828;
}

.playing-card.black {
  color: #0a0a0a;
}

/* Black suits share the same high-contrast black (green club tint hurt legibility) */
.playing-card.suit-C:not(.red) .suit,
.playing-card.suit-S:not(.red) .suit {
  color: #0a0a0a;
}

.playing-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(61, 156, 240, 0.45);
  transform: translateY(-4px);
}

.playing-card.special::after {
  content: "★";
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.65rem;
  color: var(--gold-dim);
}

.playing-card .rank {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.playing-card .rank.rank-10 {
  font-size: 1.15rem;
  letter-spacing: -0.06em;
}

.playing-card .suit {
  font-size: 1.7rem;
  line-height: 1;
  font-weight: 700;
  margin-top: 0.02rem;
}

.build-card {
  width: auto;
  min-width: calc(var(--card-w) * 1.35);
  height: var(--card-h);
  border-radius: 8px;
  background: linear-gradient(145deg, #2a3d55, #1a2838);
  border: 2px solid var(--gold);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.25rem;
}

.build-card.selected {
  box-shadow: 0 0 0 2px var(--accent);
}

.build-card .build-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold);
}

.card-back {
  width: 1.4rem;
  height: 2rem;
  border-radius: 4px;
  background: linear-gradient(135deg, #2a5a8c, #1a3a5c);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: inline-block;
  margin: 0 1px;
  vertical-align: top;
}

.opponent-backs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  min-height: 2rem;
  margin: 0.2rem 0;
}

/* Deal-out animation: cards fly in staggered from above the pile */
@keyframes deal-fly-in {
  0% {
    opacity: 0;
    transform: translateY(-2.75rem) scale(0.45) rotate(-12deg);
  }
  55% {
    opacity: 1;
    transform: translateY(0.12rem) scale(1.06) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

/* Hand refill: slightly longer arc so mid-round deals are obvious */
@keyframes deal-fly-in-hand {
  0% {
    opacity: 0;
    transform: translateY(-3.25rem) scale(0.4) rotate(-14deg);
  }
  50% {
    opacity: 1;
    transform: translateY(0.18rem) scale(1.08) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.playing-card.deal-in,
.build-card.deal-in,
.card-back.deal-in {
  /* Disable button transform transition so it does not fight keyframes */
  transition: none;
  animation: deal-fly-in 0.45s cubic-bezier(0.22, 1.15, 0.36, 1) both;
  animation-delay: calc(var(--deal-i, 0) * 75ms);
}

.playing-card.deal-in.deal-in-hand {
  animation-name: deal-fly-in-hand;
  animation-duration: 0.52s;
  animation-delay: calc(var(--deal-i, 0) * 90ms);
}

.hand-area.is-dealing {
  box-shadow: 0 0 0 1px rgba(240, 193, 75, 0.35), 0 0 20px rgba(240, 193, 75, 0.12);
  border-color: rgba(240, 193, 75, 0.4);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .playing-card.deal-in,
  .playing-card.deal-in.deal-in-hand,
  .build-card.deal-in,
  .card-back.deal-in {
    animation: none;
  }
}

.hand-area.is-turn {
  border-color: var(--success);
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.35), 0 0 12px rgba(62, 207, 142, 0.12);
}

.standings {
  margin: 0;
  padding-left: 1.25rem;
}

.standings li {
  margin: 0.4rem 0;
}

/*
 * Toast — must not set both top and bottom (that stretches the box full-screen).
 * Platform-shell uses .show / .error; keep width content-sized.
 */
.toast {
  position: fixed;
  left: 50%;
  right: auto;
  top: auto;
  bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(120%);
  width: max-content;
  max-width: min(90vw, 22rem);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  z-index: 400;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.toast.error,
.toast.is-error {
  border-color: rgba(232, 93, 93, 0.5);
  background: #3a1f24;
}

/* Chat/voice panel styles: see /css/comms.css (Bank communications UI) */

/* Build value chooser (tap targets, no keyboard) */
.build-modal-card {
  width: min(22rem, 100%);
}

.build-value-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.85rem 0 0.75rem;
}

.build-value-options:has(> :only-child) {
  grid-template-columns: 1fr;
}

.build-value-btn {
  width: 100%;
  margin: 0;
  padding: 0.95rem 0.75rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.build-modal-empty {
  margin: 0.75rem 0;
  text-align: center;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: min(20rem, 100%);
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 0.5rem;
}

.modal-card input[type="number"],
.modal-card input[type="text"] {
  width: 100%;
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--bg);
  color: var(--text);
}

/* Capture preview overlay */
.capture-preview {
  pointer-events: none;
  z-index: 70;
}

.capture-preview.is-peek {
  pointer-events: auto;
}

.capture-preview-close {
  width: 100%;
  margin-top: 0.85rem;
}

/* Last hand of the deal — "CARDS!" */
.cards-exclaim {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(ellipse 55% 40% at 50% 45%, rgba(240, 193, 75, 0.22), transparent 70%);
}

.cards-exclaim.hidden {
  display: none;
}

.cards-exclaim-burst {
  font-size: clamp(2.75rem, 12vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow:
    0 0 24px rgba(240, 193, 75, 0.65),
    0 4px 0 rgba(0, 0, 0, 0.35),
    0 8px 28px rgba(0, 0, 0, 0.45);
  transform: scale(0.6);
  opacity: 0;
}

.cards-exclaim-burst.is-anim {
  animation: cards-exclaim-pop 2.6s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

@keyframes cards-exclaim-pop {
  0% {
    opacity: 0;
    transform: scale(0.45) rotate(-6deg);
  }
  12% {
    opacity: 1;
    transform: scale(1.18) rotate(2deg);
  }
  28% {
    transform: scale(0.96) rotate(-1deg);
  }
  40% {
    transform: scale(1.05) rotate(0deg);
  }
  75% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.08) translateY(-0.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cards-exclaim-burst.is-anim {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

.capture-preview-card {
  width: min(22rem, 100%);
  text-align: center;
  border: 1px solid rgba(62, 207, 142, 0.35);
  animation: capture-pop 0.25s ease-out;
}

@keyframes capture-pop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.capture-preview-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0.85rem 0 0.5rem;
  min-height: var(--card-h);
}

.capture-preview-cards .playing-card {
  cursor: default;
  pointer-events: none;
}

.capture-preview-cards .playing-card.is-played {
  box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(240, 193, 75, 0.35);
}

.capture-preview-points {
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

.capture-preview-points .points-total {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.capture-preview-points .points-line {
  color: var(--muted);
  font-size: 0.82rem;
}

.capture-preview-points .points-none {
  color: var(--muted);
  font-size: 0.85rem;
}

/* End-of-deal score tally */
.deal-summary {
  z-index: 75;
  align-items: flex-start;
  overflow-y: auto;
  padding: 1rem 1rem 2rem;
}

.deal-summary-card {
  width: min(26rem, 100%);
  margin: auto;
}

.deal-summary-players {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.85rem 0 1rem;
}

.deal-player-card {
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  text-align: left;
}

.deal-player-card.is-you {
  border-color: rgba(61, 156, 240, 0.45);
}

.deal-player-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.deal-player-name {
  font-weight: 700;
}

.deal-player-pts {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--gold);
  white-space: nowrap;
}

.deal-player-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.deal-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.65rem;
  font-size: 0.82rem;
}

.deal-stat-grid.deal-stat-grid-split {
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.85rem;
  align-items: start;
}

.deal-stat-col {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.deal-stat {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  color: var(--muted);
  padding: 0.15rem 0;
}

.deal-stat .stat-label {
  min-width: 0;
}

.deal-stat .stat-val {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.deal-stat.deal-stat-round {
  margin-top: 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 600;
}

.deal-stat.deal-stat-round .stat-val {
  color: var(--gold);
  font-weight: 800;
}

.deal-stat.is-highlight {
  background: rgba(240, 193, 75, 0.12);
  border: 1px solid rgba(240, 193, 75, 0.35);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  color: var(--gold);
  font-weight: 700;
}

.deal-stat.is-highlight .stat-val {
  color: var(--gold);
  font-weight: 800;
}

.deal-stat.is-highlight.little {
  background: rgba(125, 207, 255, 0.1);
  border-color: rgba(125, 207, 255, 0.35);
  color: #9ad4ff;
}

.deal-stat.is-highlight.little .stat-val {
  color: #c5e8ff;
}

.deal-stat.is-winner .stat-val {
  color: var(--success);
}

.deal-stat.is-empty {
  opacity: 0.5;
}

.deal-stat.is-empty .stat-val {
  color: var(--muted);
  font-weight: 500;
}

.deal-summary-ready-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  justify-content: center;
}

.deal-ready-chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg);
  color: var(--muted);
}

.deal-ready-chip.is-ready {
  border-color: rgba(62, 207, 142, 0.45);
  color: var(--success);
  background: rgba(62, 207, 142, 0.12);
}

.deal-summary-wait {
  text-align: center;
  margin: 0.55rem 0 0;
}

/* ===== Final play-mode overrides (must win over Casino leftovers) ===== */
body.play-active #screen-play {
  padding-bottom: 0 !important;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.play-active .play-actions {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  width: 100% !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  z-index: 5;
  background: transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.3rem 0 calc(0.25rem + env(safe-area-inset-bottom, 0px)) !important;
}

/*
 * Fill vertical space between top chrome and action dock:
 *   melds: equal flex share of leftover
 *   hand: fixed 2-row height (scroll inside for more cards)
 */
body.play-active .meld-panel,
body.play-active .meld-panel-us {
  min-height: 0 !important;
  flex: 1 1 0 !important;
  max-height: none !important;
  overflow: hidden !important;
}

body.play-active .melds-row {
  flex-wrap: wrap !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  min-height: 0 !important;
  flex: 1 1 auto !important;
  align-content: flex-start !important;
}

body.play-active .card-stack {
  min-height: var(--card-sm-h) !important;
  height: var(--card-sm-h) !important;
  max-height: var(--card-sm-h) !important;
  overflow: visible !important;
}

body.play-active .meld-pile,
body.play-active button.meld-pile {
  min-height: calc(var(--card-sm-h) + 1.2rem) !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  flex-shrink: 0 !important;
}

body.play-active .card-stack .card-face.card-stacked {
  width: var(--card-sm-w) !important;
  height: var(--card-sm-h) !important;
  min-width: var(--card-sm-w) !important;
  min-height: var(--card-sm-h) !important;
}

body.play-active .play-row-piles-status,
body.play-active .play-top-block {
  max-height: none !important;
  flex: 0 0 auto !important;
  min-height: 0 !important;
  overflow: visible;
}

body.play-active .play-turn-row {
  flex: 0 0 auto !important;
}

body.play-active .hand-area {
  flex: 0 0 auto !important;
  height: var(--hand-2row-h) !important;
  min-height: var(--hand-2row-h) !important;
  max-height: var(--hand-2row-h) !important;
  overflow: hidden !important;
}

body.play-active .hand-cards {
  overflow-y: auto !important;
  min-height: 0 !important;
  flex: 1 1 auto !important;
}

/* —— Canasta action dock: beat generic .play-actions-row rules —— */
body.play-active .play-actions-row.play-actions-canasta,
.play-actions-row.play-actions-canasta {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
  width: 100%;
  flex: 0 0 auto;
}

body.play-active .play-actions-canasta .btn-primary,
body.play-active .play-actions-canasta .btn-secondary,
body.play-active .play-actions-canasta .btn-ghost-sm,
.play-actions-row.play-actions-canasta .btn-primary,
.play-actions-row.play-actions-canasta .btn-secondary,
.play-actions-row.play-actions-canasta .btn-ghost-sm {
  width: 100% !important;
  min-width: 0 !important;
  flex: none !important;
  margin: 0 !important;
  padding: 0.48rem 0.1rem !important;
  font-size: clamp(0.62rem, 2.9vw, 0.78rem) !important;
  line-height: 1.15 !important;
  border-radius: 8px;
  white-space: normal !important;
  overflow-wrap: break-word;
  text-align: center;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  height: auto;
  box-sizing: border-box;
}

/* ==========================================================================
   PLAY LAYOUT: Desktop (large screens) vs Phone (small screens)
   Breakpoint: 768px
   Height rule: body/app/screen-play lock to 100dvh; melds flex with min-height:0
   so action dock always stays on-screen.
   ========================================================================== */

/* ——— Desktop / large screens ——— */
@media (min-width: 768px) {
  :root {
    /* Card sizes only. Lobby/home stay 480px. */
    --app-max: 480px;
    /* Larger faces for readability — still constrained enough to fit 100dvh */
    --card-w: 3.15rem;
    --card-h: 4.35rem;
    --card-sm-w: 2.75rem;
    --card-sm-h: 3.8rem;
    --card-rank-size: 1.02rem;
    --card-sm-rank-size: 1.08rem;
    --stock-w: 3.15rem;
    --stock-h: 4.35rem;
    --stock-btn-w: 3.4rem;
    --stock-btn-h: 4.65rem;
    --play-actions-h: 6.75rem;
  }

  body.play-active {
    --app-max: 720px;
  }

  body.play-active .app {
    max-width: var(--app-max);
    padding: 0.35rem 0.75rem 0;
  }

  body.play-active .brand {
    padding: 0.12rem 0 0.22rem;
    gap: 0.5rem 0.65rem;
  }

  body.play-active .brand h1 {
    font-size: 1.1rem;
    letter-spacing: 0.12em;
  }

  body.play-active .brand-play-meta {
    font-size: 0.78rem;
  }

  body.play-active .play-board-compact {
    gap: 0.35rem;
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }

  /* Piles + scores + turn under teams — content-sized, not height-capped */
  body.play-active .play-row-piles-status,
  body.play-active .play-top-block {
    max-height: none !important;
    flex: 0 0 auto !important;
    gap: 0.35rem 0.45rem;
  }

  body.play-active .piles-panel {
    padding: 0.4rem 0.5rem 0.45rem;
    gap: 0.55rem;
    border-radius: 12px;
  }

  body.play-active .status-panel {
    padding: 0.32rem 0.45rem;
    gap: 0.12rem;
    border-radius: 12px;
  }

  body.play-active .status-panel-heading {
    font-size: 0.7rem;
  }

  body.play-active .status-panel-score {
    font-size: 1.05rem;
  }

  body.play-active .status-member {
    font-size: 0.78rem;
    padding: 0.12rem 0.3rem;
  }

  body.play-active .status-member-role {
    font-size: 0.6rem;
  }

  body.play-active .status-panel-meta {
    font-size: 0.68rem;
  }

  body.play-active .play-turn-row {
    font-size: 0.85rem;
    flex: 0 0 auto !important;
  }

  body.play-active .play-turn-row .turn-banner {
    font-size: 0.82rem;
    padding: 0.28rem 0.45rem;
  }

  body.play-active .play-turn-row .last-action {
    font-size: 0.72rem;
    padding: 0.28rem 0.45rem;
  }

  /* Melds: equal leftover height; hand fixed at 2 card rows */
  body.play-active .meld-panel,
  body.play-active .meld-panel-us {
    min-height: 0 !important;
    flex: 1 1 0 !important;
    max-height: none !important;
    padding: 0.28rem 0.4rem 0.32rem;
    gap: 0.2rem;
    border-radius: 12px;
  }

  body.play-active .meld-panel-title {
    font-size: 0.78rem;
  }

  body.play-active .melds-row {
    min-height: 0 !important;
    gap: 0.45rem 0.5rem;
  }

  body.play-active .meld-pile,
  body.play-active button.meld-pile {
    min-height: calc(var(--card-sm-h) + 1.35rem) !important;
    padding: 0.28rem 0.4rem 0.4rem;
  }

  body.play-active .hand-area {
    flex: 0 0 auto !important;
    height: var(--hand-2row-h) !important;
    min-height: var(--hand-2row-h) !important;
    max-height: var(--hand-2row-h) !important;
    padding: 0.3rem 0.45rem !important;
    border-radius: 12px;
  }

  body.play-active .hand-label-row {
    font-size: 0.76rem !important;
    margin-bottom: 0.2rem !important;
  }

  body.play-active .hand-cards {
    gap: 0.26rem;
  }

  body.play-active .card-face {
    border-radius: 8px;
    padding: 0.14rem 0.2rem;
  }

  body.play-active .card-face.card-face-sm {
    padding: 0.12rem 0.16rem;
    border-radius: 7px;
  }

  body.play-active .play-actions {
    flex: 0 0 auto !important;
    gap: 0.3rem !important;
    padding: 0.3rem 0 calc(0.3rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.play-active .play-actions-tools .play-tool-btn {
    padding: 0.38rem 0.45rem;
    font-size: 0.84rem;
  }

  body.play-active .play-actions-canasta {
    gap: 0.35rem;
  }

  body.play-active .play-actions-canasta .btn-primary,
  body.play-active .play-actions-canasta .btn-secondary,
  body.play-active .play-actions-canasta .btn-ghost-sm {
    padding: 0.55rem 0.3rem !important;
    font-size: 0.88rem !important;
    min-height: 2.65rem;
    border-radius: 10px;
  }

  body.play-active .stock-stack-count {
    font-size: 0.72rem;
  }

  body.play-active .discard-stack-meta {
    font-size: 0.72rem;
  }

  body.play-active .freeze-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }
}

/* Very wide desktops */
@media (min-width: 1100px) {
  :root {
    --app-max: 480px;
    --card-w: 3.35rem;
    --card-h: 4.6rem;
    --card-sm-w: 2.9rem;
    --card-sm-h: 4rem;
    --card-rank-size: 1.08rem;
    --card-sm-rank-size: 1.14rem;
    --stock-w: 3.35rem;
    --stock-h: 4.6rem;
    --stock-btn-w: 3.6rem;
    --stock-btn-h: 4.9rem;
  }

  body.play-active {
    --app-max: 800px;
  }
}

/* ——— Phones / small screens ———
   Compact piles + status; melds equal leftover; hand fixed 2 rows. */
@media (max-width: 767px) {
  :root {
    --card-w: 2.45rem;
    --card-h: 3.4rem;
    --card-sm-w: 2.15rem;
    --card-sm-h: 3rem;
    --card-rank-size: 0.78rem;
    --card-sm-rank-size: 0.88rem;
    --stock-w: 2.15rem;
    --stock-h: 3rem;
    --stock-btn-w: 2.35rem;
    --stock-btn-h: 3.25rem;
    --play-actions-h: 6.1rem;
  }

  body.play-active .app {
    padding: 0.1rem 0.4rem 0;
    /* height chain comes from base play-active rules */
  }

  body.play-active .brand {
    gap: 0.25rem 0.35rem;
    padding: 0.04rem 0 0.1rem;
  }

  body.play-active .brand h1 {
    font-size: 0.82rem;
  }

  body.play-active .brand-play-meta {
    font-size: 0.65rem;
  }

  body.play-active .brand .conn-status {
    font-size: 0.55rem;
    max-width: 4.5rem;
  }

  body.play-active #screen-play {
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }

  body.play-active .play-board-compact {
    gap: 0.16rem;
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }

  /* Compact top chrome: piles + scores + turn under teams */
  body.play-active .play-row-piles-status,
  body.play-active .play-top-block {
    max-height: none !important;
    flex: 0 0 auto !important;
    gap: 0.14rem 0.2rem;
  }

  body.play-active .piles-panel {
    padding: 0.12rem 0.2rem 0.15rem;
    gap: 0.2rem;
    border-radius: 8px;
    align-items: flex-end;
  }

  body.play-active .status-panel {
    padding: 0.1rem 0.22rem 0.12rem;
    gap: 0.04rem;
    border-radius: 8px;
  }

  body.play-active .status-panel-heading {
    font-size: 0.5rem;
    letter-spacing: 0.03em;
  }

  body.play-active .status-panel-score {
    font-size: 0.82rem;
    line-height: 1.05;
  }

  body.play-active .status-member {
    font-size: 0.52rem;
    padding: 0.03rem 0.15rem;
    gap: 0.1rem 0.18rem;
    line-height: 1.1;
  }

  body.play-active .status-member-role {
    font-size: 0.46rem;
  }

  body.play-active .status-member-cards {
    font-size: 0.5rem;
  }

  body.play-active .status-panel-meta {
    font-size: 0.48rem;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  body.play-active .stock-stack-count {
    font-size: 0.52rem;
    padding: 0 0.2rem;
  }

  body.play-active .discard-stack {
    gap: 0.06rem;
    padding: 0.04rem;
  }

  body.play-active .discard-stack-meta {
    font-size: 0.52rem;
    gap: 0.12rem;
  }

  body.play-active .freeze-badge {
    font-size: 0.46rem;
    padding: 0.08rem 0.25rem;
    letter-spacing: 0.04em;
  }

  body.play-active .play-turn-row {
    font-size: 0.66rem;
    gap: 0.12rem 0.2rem;
    flex: 0 0 auto !important;
  }

  body.play-active .play-turn-row .turn-banner {
    font-size: 0.62rem;
    padding: 0.14rem 0.28rem;
  }

  body.play-active .play-turn-row .last-action {
    font-size: 0.55rem;
    padding: 0.14rem 0.28rem;
  }

  body.play-active .play-top-block > .meld-hint-line {
    font-size: 0.52rem;
  }

  /* Melds equal share; hand always 2 visible rows */
  body.play-active .meld-panel,
  body.play-active .meld-panel-us {
    min-height: 0 !important;
    flex: 1 1 0 !important;
    max-height: none !important;
    padding: 0.12rem 0.2rem 0.14rem;
    gap: 0.08rem;
  }

  body.play-active .meld-panel-title {
    font-size: 0.6rem;
  }

  body.play-active .melds-row {
    min-height: 0 !important;
    gap: 0.22rem 0.28rem;
  }

  body.play-active .meld-pile,
  body.play-active button.meld-pile {
    min-height: calc(var(--card-sm-h) + 0.95rem) !important;
    padding: 0.12rem 0.25rem 0.25rem;
  }

  body.play-active .hand-area {
    flex: 0 0 auto !important;
    height: var(--hand-2row-h) !important;
    min-height: var(--hand-2row-h) !important;
    max-height: var(--hand-2row-h) !important;
    padding: 0.14rem 0.2rem !important;
  }

  body.play-active .hand-label-row {
    font-size: 0.58rem !important;
    margin-bottom: 0.06rem !important;
  }

  body.play-active .hand-cards {
    gap: 0.12rem;
  }

  body.play-active .play-actions {
    flex: 0 0 auto !important;
    gap: 0.14rem !important;
    padding: 0.12rem 0 calc(0.12rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.play-active .play-actions-tools .play-tool-btn {
    padding: 0.2rem 0.16rem;
    font-size: 0.64rem;
  }

  body.play-active .play-actions-canasta {
    gap: 0.2rem;
  }

  body.play-active .play-actions-canasta .btn-primary,
  body.play-active .play-actions-canasta .btn-secondary,
  body.play-active .play-actions-canasta .btn-ghost-sm {
    padding: 0.34rem 0.06rem !important;
    font-size: 0.64rem !important;
    min-height: 2.2rem;
  }
}

/* Extra-narrow phones — card tokens shrink; --hand-2row-h follows --card-h */
@media (max-width: 380px) {
  :root {
    --card-w: 2.25rem;
    --card-h: 3.15rem;
    --card-sm-w: 2rem;
    --card-sm-h: 2.8rem;
    --card-rank-size: 0.72rem;
    --card-sm-rank-size: 0.82rem;
    --stock-w: 1.95rem;
    --stock-h: 2.75rem;
    --stock-btn-w: 2.15rem;
    --stock-btn-h: 3rem;
  }
}

/* Short landscape phones */
@media (max-height: 700px) and (max-width: 767px) {
  body.play-active .play-actions-canasta .btn-primary,
  body.play-active .play-actions-canasta .btn-secondary,
  body.play-active .play-actions-canasta .btn-ghost-sm {
    min-height: 2rem;
    padding: 0.26rem 0.05rem !important;
    font-size: 0.58rem !important;
  }
}
