/* meld.css, owner: track D2. Holds: the meld board (render/meld.js), a seat's meld card, the meld peek during the tricks, the "in your meld" mark on hand cards, and where the side seats stand during the meld.
   Load order 12 of 15: base, primitives, frame, home, room, friends, center, table, rails, chat, coach, meld, peek, results, dialogs.
   The board's own panel (width, padding) is center.css; the fold steps (.fit-compact, .fit-more, .fit-paged) measure the content in render/table.js fitCenter, for Larger Text and for stages under 54rem.
   Where the side seats stand (9.7) is a container rule on the stage: beside the board when the stage is 54rem wide or more, in the row over it below that (a phone on its side keeps its own geometry, table.css). */

.center-panel.meld-board { gap: var(--sp-2); }
.meld-board-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "eyebrow link" "trump link"; align-items: center; justify-items: start;
  column-gap: var(--sp-3); row-gap: 0; text-align: left;
}
.meld-board-head .panel-eyebrow { grid-area: eyebrow; line-height: 1.3; text-align: left; }
.meld-board-head .meld-board-trump { grid-area: trump; margin: 0; font-size: max(1.05rem, 12px); font-weight: 800; }
.meld-board-trump .trump-glyph { font-size: 1.3em; }
.meld-board-head .meld-chart-link {
  grid-area: link; display: inline-flex; align-items: center; min-height: var(--hit); margin: 0; padding-inline: var(--sp-1); font-size: max(0.78rem, 12px);
}
.meld-teams { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.meld-team {
  display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; padding: var(--sp-2) var(--sp-2) var(--sp-3); border: 1px solid var(--hair);
  border-radius: var(--r-xl); background: var(--white-04);
}
.meld-team.is-bidding { border-color: var(--gold-line); }
.meld-team-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: max(0.78rem, 12px); font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.meld-team.team-ns .meld-team-head { color: var(--team-ns); }
.meld-team.team-ew .meld-team-head { color: var(--team-ew); }
.meld-team-name { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.meld-team-tag {
  padding: 0.125rem var(--sp-2); border: 1px solid currentcolor; border-radius: var(--r-full); font-size: max(0.75rem, 12px); letter-spacing: 0.06em;
}
.meld-team-total {
  color: var(--text); font-size: max(1.45rem, 12px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none;
}
.meld-team-status { margin-top: calc(var(--sp-1) * -0.5); font-size: max(0.78rem, 12px); font-weight: 600; line-height: 1.3; }
.meld-team-status.tone-gold { color: var(--gold-strong); }
.meld-team-status.tone-good { color: var(--good); }
.meld-team-status.tone-bad { color: var(--bad); }
.meld-team-status.tone-dim { color: var(--text-dim); }
/* The bar under the list: who is still to confirm on the left, Confirm Meld at the right (52 tall); Forfeit and Misdeal wrap to a row of their own */
.meld-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); }
.meld-board .meld-actions .btn { flex: 0 1 auto; width: auto; min-height: var(--hit); }
.meld-board .meld-actions .btn.meld-confirm { min-height: var(--hit-lg); margin-left: auto; }
.meld-board .meld-actions .meld-waiting { flex: 1 1 6rem; align-self: center; margin: 0; text-align: left; }
/* At Larger Text only Confirm Meld is pinned; the rest of the row (who is to confirm, Propose Forfeit, Declare Misdeal) is the last thing in the part that scrolls (render/table.js pinPrimary) */
.meld-actions-more { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); width: 100%; }
.meld-board .meld-actions-more .btn { flex: 0 1 auto; width: auto; min-height: var(--hit); }
.meld-board .meld-actions-more .meld-waiting { flex: 1 1 6rem; align-self: center; margin: 0; text-align: left; }
.meld-waiting { line-height: 1.3; }
/* Build 33 (Concede): the partner agreed; the line that says what finishes it is a row of its own above the buttons, so the bar never grows wider than the board (a long line beside two buttons squeezed the side seats at 1180 x 820) */
.meld-board :is(.meld-actions, .meld-actions-more) .concede-agreed { flex: 1 0 100%; order: -1; max-width: none; margin: 0; text-align: left; line-height: 1.3; contain: inline-size; }   /* (contain: it adds nothing to the board's natural width, which a flex row sizes by every item on one line) */

/* ISSUES 153: the partner's concession question stands on the meld board (under the headline, above both teams' meld), never over it */
.meld-board .concede-question { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-1) var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--gold-line); border-radius: var(--r-lg); background: var(--gold-wash); }
.concede-question-line { flex: 1 1 12rem; min-width: 0; margin: 0; color: var(--text); font: var(--t-label); line-height: 1.3; }
.concede-question-buttons { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.meld-board .concede-question-buttons .btn { flex: 0 1 auto; width: auto; min-height: var(--hit); }
/* One seat's card */
.meld-seat {
  display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; padding: var(--sp-1) var(--sp-2); container-type: inline-size;
  border: 1px solid var(--hair); border-radius: var(--r-lg); background: var(--white-04);
}
.meld-seat-head {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-width: 0; padding: 0; border: 0; background: none; color: var(--text); font: inherit;
  text-align: left;
}
/* 44 tall in a 24 tall row: the head's hit area reaches into the card's padding */
button.meld-seat-head {
  min-height: var(--hit); margin-block: calc(var(--sp-2) * -1.25); cursor: pointer;
}
.meld-seat-avatar {
  display: grid; flex: none; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--team-ew); color: var(--ink-0);
  font-size: max(0.78rem, 12px); font-weight: 800;
}
.meld-seat.team-ns .meld-seat-avatar { background: var(--team-ns); }
.meld-seat-name { min-width: 0; overflow: hidden; font-size: max(0.9rem, 12px); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.meld-seat-ready { color: var(--good); font-weight: 800; }
.meld-seat-total { margin-left: auto; font-size: max(1.3rem, 12px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.meld-seat.is-empty .meld-seat-total { color: var(--text-dim); }
.meld-groups { display: flex; flex-direction: column; gap: var(--sp-1); list-style: none; }
.meld-group {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title score" "cards cards"; align-items: center; gap: 0.125rem var(--sp-2);
  min-width: 0;
}
.nowrap-pair { white-space: nowrap; }   /* the last word of a meld's name and its suit (suit-mark.js appendMeldTitle) */
.meld-group-title { grid-area: title; color: var(--text); font-size: max(0.8rem, 12px); font-weight: 600; }
.meld-group-cards { display: flex; flex-wrap: wrap; grid-area: cards; gap: 0.125rem; min-width: 0; }
.meld-group-score {
  grid-area: score; min-width: 1.6em; margin-left: auto; color: var(--gold-strong); font-size: max(0.86rem, 12px); font-weight: 800;
  font-variant-numeric: tabular-nums; text-align: right;
}
@container (max-width: 11.25rem) { .meld-seat-avatar { display: none; } }   /* a seat card in four columns across a narrow board gives the name the avatar's room */
@container (min-width: 250px) { .meld-group { grid-template-columns: minmax(5.6em, max-content) minmax(0, 1fr) auto; grid-template-areas: "title cards score"; } }
@container (min-width: 500px) { .meld-groups:has(> .meld-group:nth-child(5)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-1) var(--sp-5); } .meld-groups > .meld-group.is-hidden { grid-column: 1 / -1; } }
.meld-chip { min-width: 1.625rem; padding: 0.125rem var(--sp-1); border-radius: var(--r-xs); font-size: max(0.82rem, 12px); line-height: 1.35; }
.meld-chip.is-played { opacity: 0.38; box-shadow: none; text-decoration: line-through; }
.meld-group.is-private { opacity: 0.62; }
.meld-group.is-private .meld-group-title::before { content: "\1F441\FE0E\00a0"; }
.meld-group.is-hidden, .meld-group.is-none { display: block; color: var(--text-dim); font-size: max(0.76rem, 12px); font-style: italic; }
.meld-group.is-hidden { align-self: flex-start; padding: 0.125rem var(--sp-2); border: 1px dashed var(--line); border-radius: var(--r-md); }
.meld-private-note { color: var(--text-dim); font-size: max(0.75rem, 12px); line-height: 1.3; }
/* Folded (fitCenter adds fit-compact when room is short): the labels on one or two lines beside the name; press to open */
.meld-seat-summary {
  display: none; flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--text-dim); font-size: max(0.75rem, 12px); font-weight: 500; line-height: 1.25;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.meld-board.fit-compact .meld-seat:not(.is-open) :is(.meld-groups, .meld-private-note) { display: none; }
.meld-board.fit-compact .meld-seat:not(.is-open) .meld-seat-summary { display: -webkit-box; }
.meld-board.fit-compact .meld-seat:not(.is-open) .meld-seat-name { flex: none; max-width: 40%; }
.meld-board.fit-compact .meld-seat:not(.is-open) .meld-seat-total { margin-left: 0; font-size: max(1.1rem, 12px); }
.meld-board.fit-compact .meld-seat:not(.is-open) button.meld-seat-head::after { color: var(--text-dim); rotate: -90deg; }   /* (the chevron itself: table.css) */
.meld-board.fit-compact .meld-seat.is-open { border-color: var(--gold-line); }
.meld-board.fit-compact, .meld-board.fit-compact .meld-teams { gap: var(--sp-2); }
.meld-board.fit-compact .meld-team { gap: var(--sp-1); padding: var(--sp-2); }
/* Last step before scaling: a long meld shows its four best combinations and a Show All button for the rest */
.meld-seat-more { display: none; align-self: flex-start; }
.meld-board.fit-more .meld-seat.is-open .meld-group:nth-child(n+5):not(.is-hidden) { display: none; }
.meld-board.fit-more .meld-seat.is-open .meld-seat-more { display: inline-flex; }
/* The smallest phones: one team at a time, its total on a tab (44 tall; the focus ring is the page's, 2 px gold-strong with a 2 px offset, AC-28) */
.meld-pages { display: none; gap: var(--sp-2); }
.meld-board.fit-paged .meld-pages { display: flex; }
.meld-board.fit-paged .meld-team:not(.is-page), .meld-board.fit-paged .meld-waiting, .meld-board.fit-paged .meld-team-head { display: none; }
.meld-page-name { display: inline-flex; align-items: center; gap: var(--sp-2); }
.meld-page-tab {
  display: flex; flex: 1 1 0; align-items: baseline; justify-content: space-between; gap: var(--sp-2); min-height: var(--hit);
  margin-block: calc(var(--sp-1) * -1.25); padding: var(--sp-1) var(--sp-3); border: 1px solid var(--hair); border-radius: var(--r-lg);
  background: var(--white-04); color: var(--text-dim); font: inherit; font-size: max(0.8rem, 12px); font-weight: 700; cursor: pointer;
}
.meld-page-tab[data-team="NS"] .meld-page-name { color: var(--team-ns); }
.meld-page-tab[data-team="EW"] .meld-page-name { color: var(--team-ew); }
.meld-page-total { color: var(--text); font-size: max(1.05rem, 12px); font-variant-numeric: tabular-nums; }
.meld-page-tab.is-on { border-color: var(--white-edge); background: var(--wash-press); }
.meld-page-tab.is-on:focus-visible, .meld-page-tab:focus-visible { outline: 2px solid var(--gold-strong); outline-offset: 2px; }
body.easy-view .meld-group-title { font-size: max(0.95rem, 12px); }
body.easy-view .meld-seat-name { font-size: max(1.05rem, 12px); }

/* Where the side seats stand (9.7): the row over the board when the stage is narrower than 54rem (and tall enough to be more than a phone on its side);
   beside it from 54rem, as the felt draws them */
@container stage (max-width: 53.99rem) and (min-height: 24rem) {
  .game-table.phase-meld { grid-template-areas: "left top right" "center center center" ". bottom ."; }
  /* (naming the grid area again takes back only the area's rows from a phone-on-its-side window's full-height seats, and leaves the template to place them;
     and no cap on their height) */
  .game-table.phase-meld .player-left { grid-area: left; align-self: start; justify-self: start; max-height: none; }
  .game-table.phase-meld .player-right { grid-area: right; align-self: start; justify-self: end; max-height: none; }
}
@container stage (min-width: 54rem) {
  .meld-board .meld-team { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
  .meld-board .meld-team > .meld-team-head, .meld-board .meld-team > .meld-team-status { grid-column: 1 / -1; }
  .meld-board .meld-team > .meld-seat { align-self: start; }
  .meld-board.fit-compact .meld-team > .meld-seat { grid-column: 1 / -1; }
  .meld-board.fit-stack .meld-team { display: flex; flex-direction: column; }
  .meld-board.fit-stack .meld-team > .meld-seat { align-self: stretch; width: 100%; }   /* (a seat is a size container: with no width of its own it shrank to 18 px) */   /* one card per seat, set by fitCenter while the board fits the felt that way (fix round 3 M1) */
}
@container stage (max-width: 37.49rem) { .meld-teams { grid-template-columns: 1fr; } .center-panel.meld-board { padding: var(--sp-3) var(--sp-3) var(--sp-2); gap: var(--sp-2); } }   /* a phone: the board gives its room to the cards (as it did) */
/* A phone on its side (fix round 3 M3): the center is about 165 px tall and the pinned buttons take 52 of it. The board's head is one line (the bar's chips already say who won the bid and
   at what), there are no team tabs (both teams run in one scroll, fitCenter does not page the board on this window), and what is left, 60 px or more, is the list. */
@media (max-height: 500px) and (orientation: landscape) {
  .meld-teams { grid-template-columns: 1fr; }
  .meld-board-head { grid-template-areas: "trump link"; }
  .meld-board-head .panel-eyebrow { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .meld-board-head .meld-chart-link { margin-block: calc((var(--hit) - 1.4rem) / -2); }   /* the 44 px target reaches past the one-line head (AC-03) */
  .center-panel.meld-board { padding-block: var(--sp-1); gap: var(--sp-1); }
  /* The pinned row is one row: the plates over the felt already show who has confirmed, so the "waiting on" line goes, and the agreed line stands beside the buttons, not over them. */
  .meld-board .meld-actions .meld-waiting { display: none; }
  .meld-board :is(.meld-actions, .meld-actions-more) .concede-agreed { flex: 1 1 8rem; order: 0; font-size: max(0.75rem, 12px); line-height: 1.2; }
}
@container stage (max-width: 37.49rem) and (max-height: 32rem) { .game-table.phase-meld :is(.player-left, .player-right) .seat-avatar { display: none; } }
/* The smallest phones (320 x 568): Propose Forfeit and Confirm Meld share one pinned row, not two (the part that scrolls had 42 px, fix round 3 AC-40). */
@container stage (max-width: 22rem) { .meld-board .meld-actions:not(:has(.concede-agreed)) { flex-wrap: nowrap; } .meld-board .meld-actions .btn { min-width: 0; padding-inline: var(--sp-3); } }   /* (not with the agreed line, which takes a row of its own) */

/* Your hand: a card that is part of your meld (meld and tricks) */
.hand .card.in-meld::before {
  content: "M"; position: absolute; bottom: 0.1875rem; left: 0.1875rem; z-index: 3; padding: 0 var(--sp-1); border-radius: var(--r-xs); background: var(--gold);
  color: var(--ink-on-gold); font: 800 max(11px, calc(var(--card-width, 60px) * 0.13))/1.3 var(--font-sans); pointer-events: none;
}

/* Trick play: a seat's meld beside its plate (render/meld.js toggleMeldPeek) */
.meld-peek {
  position: fixed; z-index: var(--z-drawer); display: flex; flex-direction: column; gap: var(--sp-2); max-height: calc(100dvh - 1rem); padding: var(--sp-3);
  overflow: auto; border: 1px solid var(--hair); border-radius: var(--r-xl); background: var(--panel); box-shadow: var(--e-2);
}
.meld-peek .meld-seat { padding: 0; border: 0; background: none; }
.meld-peek.is-sheet { top: 50%; left: 50%; translate: -50% -50%; }
.meld-peek .meld-seat-head { padding-right: var(--sp-6); }
.meld-peek-played { color: var(--text-dim); font-size: max(0.75rem, 12px); }
.meld-peek-close {
  position: absolute; top: var(--sp-1); right: var(--sp-1); width: var(--hit-sm); height: var(--hit-sm); border: 0; border-radius: 50%;
  background: var(--white-08); color: var(--text); cursor: pointer;
}
@media (any-pointer: coarse) { .meld-peek-close { width: var(--hit); height: var(--hit); } }
.game-table.phase-tricking .seat-plate.is-meld-tap { cursor: pointer; }   /* (only the plates that open a meld: your own plate is not a button, and a pointer over it made AC-03 count it as a touch target of 34 to 42 px) */
