/* ============================================================
   game.css — in-round game-screen styles
   Split out of index.css (which kept lobby/waiting-room styles).
   CSS custom properties (--color-*, --card-width, etc.) are defined in
   index.css :root and apply here since both sheets load on the same page.
   ============================================================ */

/* ============================================================
   Game screen (in-round layout)
   ============================================================ */

/* Full-viewport grid: fixed status bar on top, table fills the rest */
.round-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--color-bg);
  overflow-y: auto;
}

.status-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  /* Extra right padding reserves room so the trailing rules icon clears the
     fixed scoreboard (16rem) floating over the top-right corner. */
  padding: 0.5rem 17rem 0.5rem 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  min-height: 2.75rem;
}

/* Inner wrapper that holds the dynamic spans; display:contents keeps them as
   direct flex items of .status-bar so gap/wrap are unchanged. */
.status-bar__content {
  display: contents;
}

.status-bar__phase {
  font-weight: 700;
  color: var(--color-primary-hover);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-bar__turn {
  color: var(--color-text);
}

.status-bar__bid {
  color: var(--color-text-muted);
}

.status-bar__declarer {
  color: var(--color-success);
}

.status-bar__attempt {
  color: var(--color-accent);
  font-weight: 600;
}

.status-bar__sell-winner {
  color: var(--color-success);
  font-weight: 600;
}

.status-bar__bid-winner {
  color: var(--color-success);
  font-weight: 600;
}

.status-bar__passed-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.status-bar__passed-label {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.status-bar__passed-chip {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.status-bar__disconnected {
  color: var(--color-accent);
  font-size: 0.8rem;
}

/* Card table area: center + opponent zones.
   The flexible row uses minmax(min-content, 1fr) so it fills spare space on tall
   screens but never collapses below its content on short ones — that collapse is
   what made rows render on top of each other. min-height:0 keeps the table inside
   its round-screen track so overflow-y can scroll it instead of overlapping. */
.game-table {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: minmax(min-content, 1fr) auto auto;
  gap: 0.5rem;
  padding: 1rem;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Prevent grid items from forcing column expansion beyond 1fr */
.game-table > * {
  min-width: 0;
  min-height: 0;
}

/* 3-player default: the 4th (across) seat is unused, so take it out of flow
   entirely. This keeps auto-placement at the documented "left | talon | right"
   row and prevents the empty seat from reserving a column. */
.game-table > .across-zone {
  display: none;
}

/* ------------------------------------------------------------
   4-player layout (FR-018, R-302): a top/across seat is added.
   A dedicated top row hosts the across seat (centred); the middle
   row carries left | talon | right; hand + stats span the bottom.
   Scoped under .game-table--four so 3-player is untouched.
   ------------------------------------------------------------ */
/* The across row uses minmax(min-content, auto), not plain auto: items carry
   min-height:0 (see .game-table > *), and an auto row sized from that zero
   minimum collapses on short viewports — the seat's absolutely-positioned
   stack cards then paint over the trump/status boxes below. min-content
   keeps the row at content height so the table scrolls instead. */
.game-table--four {
  grid-template-rows: minmax(min-content, auto) minmax(min-content, 1fr) auto auto;
}

.game-table--four > .across-zone {
  display: flex;
  grid-row: 1;
  grid-column: 1 / -1;
  justify-self: center;
}

.game-table--four > .opponent-view:not(.across-zone) {
  grid-row: 2;
}

/* left seat → middle-left, talon → middle-centre, right seat → middle-right.
   The talon-col already centres its contents; pin each to an explicit column. */
.game-table--four > .opponent-view:not(.across-zone):first-child {
  grid-column: 1;
}

.game-table--four > .talon-col {
  grid-row: 2;
  grid-column: 2;
}

.game-table--four > .opponent-view:not(.across-zone):nth-child(4) {
  grid-column: 3;
}

/* Controls bar at the bottom of the round screen */
.game-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: var(--touch-min);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-wrap: wrap;
}

/* Bid controls: stepper row inside .game-controls */
.bid-controls,
.sell-bid-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Sell selection controls: counter + action buttons inside .game-controls */
.sell-selection-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.sell-selection-controls__counter {
  padding-right: 1rem;
  margin-right: 0.5rem;
  border-right: 1px solid var(--color-border);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  min-width: 7rem;
  text-align: center;
}

.bid-controls__input {
  width: 5rem;
  text-align: center;
  font-size: 1rem;
  padding: 0.35rem 0.5rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
}

.bid-controls__input::-webkit-outer-spin-button,
.bid-controls__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bid-controls__input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.bid-controls__step {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0.35rem 0.65rem;
  font-size: 0.95rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  cursor: pointer;
}

.bid-controls__step:disabled,
.bid-controls__input:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Flash ring on a seat element when that player bids or passes */
.bid-flash {
  box-shadow: 0 0 0 2px var(--color-accent);
}

/* ============================================================
   Card sprite base styles
   ============================================================ */

/* CSS custom properties for card colours */
:root {
  --card-width: clamp(3.5rem, 5vw, 5.5rem);
  --card-height: clamp(4.9rem, 7vw, 7.7rem);
  --card-radius: 0.375rem;
  --card-color-red: #e94560;
  --card-color-black: #1a1a1a;
}

.card-sprite {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* Face-up: light surface; card image classes in cards.css override background-image */
.card-sprite--up {
  background-color: var(--color-card-face-bg);
  background-image: none;
  border: 1px solid var(--color-card-face-border);
}

/* Face-down: dark gradient echoing the table palette */
.card-sprite--back {
  background: var(--gradient-card-back);
  border: 1px solid var(--color-border);
}


/* ============================================================
   Opponent view — face-down opponent hand zone
   ============================================================ */

.opponent-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem;
}

.opponent-view__nickname {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
}

.opponent-view__stack {
  position: relative;
  height: var(--card-height);
  /* Fixed-height flex item: never let it compress — its cards are absolutely
     positioned and would overflow onto neighbouring boxes instead of clipping. */
  flex-shrink: 0;
}

.opponent-view__stack-card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  background: var(--gradient-card-back);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}


.opponent-view__count {
  display: none;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.opponent-view__disconnected {
  font-size: 0.75rem;
  color: var(--color-accent);
  text-align: center;
}

.opponent-view__last-action {
  font-size: 0.775rem;
  color: var(--color-text-muted);
  text-align: center;
}

.opponent-view__round-stats {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ============================================================
   Hand view — viewer's own sorted face-up hand
   ============================================================ */

/* Span all 3 grid columns so the hand centres across the full table width */
.game-table > .hand-view {
  grid-column: 1 / -1;
}

.game-table > .self-round-stats {
  grid-column: 1 / -1;
}

.self-round-stats {
  text-align: center;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  padding: 0.25rem 0;
}

.hand-view {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem;
  min-height: calc(var(--card-height) + 1rem);
}

/* Overrides card-sprite's position:absolute so cards flow in the flex row */
.hand-view__card {
  position: relative;
  cursor: default;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.hand-view__card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
}

.hand-view__card--selected {
  transform: translateY(-18px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), 0 0 0 2px var(--color-primary);
  z-index: 1;
}

.hand-view__card--selected:hover {
  transform: translateY(-20px);
}

.hand-view--selectable .hand-view__card {
  cursor: pointer;
}

/* ============================================================
   Talon column — center grid cell wrapping status box + talon
   ============================================================ */

.talon-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* center the group vertically so talon cards align with opponent stacks */
.talon-col::before {
  content: '';
  flex: 1;
}

.talon-col::after {
  content: '';
  flex: 1;
}

/* ============================================================
   Game status box — prominent label above talon cards
   ============================================================ */

.game-status-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.35rem 0.9rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-status-box--active {
  color: var(--color-primary-hover);
  border-color: var(--color-primary);
}

/* ============================================================
   Trump box — color-coded trump-suit display above the status box
   ============================================================ */

/* max-content + nowrap: the box sits in the narrow centre grid column, which
   otherwise squeezes it and wraps "No trump" onto two lines on small screens. */
.trump-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  max-width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.3rem 0.9rem;
}

.trump-box__label {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.trump-box__suit {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.trump-box__suit--red {
  color: var(--card-color-red);
}

.trump-box__suit--black {
  /* literal black is invisible on the dark table — use the light text color */
  color: var(--color-text);
}

.trump-box__suit--none {
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

/* ============================================================
   Last action box — spans all columns between opponents and hand
   ============================================================ */

.last-action-box {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.775rem;
  color: var(--color-text-muted);
}

/* ============================================================
   Talon view — central face-up card area
   ============================================================ */

.talon-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--card-height);
  overflow: hidden;
}

.talon-view .card-sprite {
  position: relative;
}

/* ============================================================
   Declarer controls and waiting message
   ============================================================ */

.declarer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.waiting {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* ============================================================
   Round-ready / round-aborted full-screen take-over (FR-019, FR-021)
   The status bar (z-index: 50) stays visible above this overlay.
   ============================================================ */

.round-ready-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  background: var(--color-surface);
}

.round-ready-screen__heading {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary-hover);
}

.round-ready-screen__body {
  color: var(--color-text-muted);
  font-size: 1rem;
  max-width: 32rem;
}

/* ============================================================
   Card exchange phase (.card-exchange__*)
   ============================================================ */

/* Row of destination seat buttons rendered below the hand */
.card-exchange__dest-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  flex-wrap: wrap;
}

/* Individual destination seat button */
.card-exchange__dest-btn {
  min-height: var(--touch-min);
  padding: 0 1.25rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.card-exchange__dest-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

.card-exchange__dest-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Centred waiting message shown to non-declarer players */
.card-exchange__waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* ============================================================
   Trick play (.trick-play__*)
   ============================================================ */

/* Greyed-out / unplayable card state. Dimmed via filter rather than opacity:
   in the ≤640px fan-stack the cards overlap, and a translucent card would let
   the card underneath bleed through, turning the stack into visual noise. */
.card--disabled {
  filter: grayscale(0.6) brightness(0.75);
  cursor: not-allowed;
}

/* Suppress hover lift on disabled cards in hand */
.hand-view__card.card--disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Pointer cursor on interactive hand cards (trick play / card exchange) */
.hand-view--interactive .hand-view__card {
  cursor: pointer;
}

.hand-view--interactive .hand-view__card.card--disabled {
  cursor: not-allowed;
}

/* Card animates off to its recipient during card exchange. Direction modifier
   classes (--leaving-left / --leaving-right) override the X translation. */
.hand-view__card--leaving {
  animation: card-leave-right 250ms ease-out forwards;
}

.hand-view__card--leaving-left {
  animation: card-leave-left 250ms ease-out forwards;
}

.hand-view__card--leaving-right {
  animation: card-leave-right 250ms ease-out forwards;
}

/* Card briefly highlights when received via exchange pass (recipient view). */
.hand-view__card--arriving {
  animation: card-arrive 400ms ease-out;
  box-shadow: 0 0 12px 4px rgba(110, 180, 255, 0.65);
}

/* Cards just absorbed from the talon stay marked (declarer's view) with a gentle
   gold pulse until the take/give decision clears them. The gold box-shadow does
   not compose with the --selected ring (also box-shadow), but the two states are
   mutually exclusive by phase, so they never apply to the same card at once. */
.hand-view__card--from-talon {
  box-shadow: 0 0 10px 3px rgba(245, 197, 66, 0.7);
  animation: talon-pulse 1.6s ease-in-out infinite;
}

@keyframes talon-pulse {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(245, 197, 66, 0.5); }
  50%      { box-shadow: 0 0 14px 5px rgba(245, 197, 66, 0.85); }
}

/* Trick centre — 3 absolutely-positioned slots inside the talon container
   during trick-play. Each slot holds one face-up card sprite mapped to the
   seat that played it (self at the bottom, left/right toward their players). */
.trick-center {
  position: relative;
  width: calc(var(--card-width) * 2.4);
  height: calc(var(--card-height) * 1.6);
  min-height: var(--card-height);
  overflow: visible;
}

.trick-center__slot {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
}

.trick-center__slot--self {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.trick-center__slot--left {
  top: 0;
  left: 0;
}

.trick-center__slot--right {
  top: 0;
  right: 0;
}

/* 4th (across) seat plays into the top-centre slot (FR-018). Only present in
   4-player; the centre is widened below so left/across/right don't overlap. */
.trick-center__slot--across {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* Four cards (self bottom-centre, left/across/right across the top) need more
   horizontal room than the default 2.4× width. Scope the wider centre to
   4-player so the 3-player trick-centre is unchanged. */
.game-table--four .trick-center {
  width: calc(var(--card-width) * 3.4);
}

.trick-center__slot .card-sprite {
  position: absolute;
  inset: 0;
}

/* Card-shaped clone flown across the page during the hand→centre and
   centre→winner-seat animations. position: fixed so we can drive it via
   client coordinates regardless of the source/destination layout context. */
.card-flight-clone {
  pointer-events: none;
}

/* ============================================================
   Round summary (.round-summary__*)
   ============================================================ */

/* Blocking centered overlay (continue / back-to-lobby handoff). Sits above the
   table + scoreboard (z-index 50) but below the four-nines / reconnect overlays. */
.round-summary {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  /* Slightly opaque so the table stays visible behind the blocking card. */
  background: rgba(13, 20, 16, 0.5);
}

.round-summary__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 30rem;
  padding: 1.25rem 1.5rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.round-summary__made-indicator,
.round-summary__missed-indicator {
  width: 100%;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.round-summary__made-indicator {
  color: var(--color-success);
}

.round-summary__missed-indicator {
  color: var(--color-error);
}

/* Full-width row that keeps the capped table centered on its own line. */
.round-summary__table-wrap {
  width: 100%;
}

/* Scoring results table — capped + centered so columns stay tight instead of
   spanning the full screen width (wastes space on large displays). */
.round-summary__table {
  width: auto;
  max-width: 640px;
  margin: 0.4rem auto;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.round-summary__table th,
.round-summary__table td {
  padding: 0.25rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
}

/* Player name column stays left-aligned; numbers read better right-aligned. */
.round-summary__table th:first-child,
.round-summary__table td:first-child {
  text-align: left;
  white-space: nowrap;
}

.round-summary__table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.round-summary__table td {
  color: var(--color-text);
}

/* Per-player data row */
.round-summary__player-row {
  transition: background var(--transition);
}

.round-summary__player-row:hover {
  background: var(--color-surface-alt);
}

/* Back-to-lobby button — reuses .btn base sizing */
.round-summary__back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0 1.5rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  margin-top: 0.5rem;
}

.round-summary__back-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

/* ============================================================
   Status bar — new Phase 3 fields (.status-bar__*)
   ============================================================ */

/* "Trick N of 8" indicator */
.status-bar__trick-number {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-family: monospace;
}

/* "N/2 cards passed" during exchange phase */
.status-bar__exchange-passes {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Wrapper row for per-seat score chips */
.status-bar__scores {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Trump suit indicator chip */
.status-bar__trump {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* ============================================================
   Marriage prompt modal
   ============================================================ */

/* Container for marriage declaration prompt — hidden by default */
.trick-play__marriage-prompt {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  min-width: 20rem;
}

/* Inner info text in marriage prompt */
.trick-play__marriage-prompt > div:first-child {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
  text-align: center;
}

/* Buttons in marriage prompt */
.trick-play__marriage-prompt button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 2.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  margin-bottom: 0.5rem;
}

.trick-play__marriage-prompt button:last-child {
  margin-bottom: 0;
}

/* Declare and play button — prominent success color */
.trick-play__marriage-prompt button[data-action="declare"] {
  background: var(--color-success);
  color: #fff;
}

.trick-play__marriage-prompt button[data-action="declare"]:hover {
  filter: brightness(1.1);
}

/* Play without declaring button — neutral secondary */
.trick-play__marriage-prompt button[data-action="play"] {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.trick-play__marriage-prompt button[data-action="play"]:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

/* Cancel button — muted red/error */
.trick-play__marriage-prompt button[data-action="cancel"] {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.trick-play__marriage-prompt button[data-action="cancel"]:hover {
  background: var(--color-accent);
  color: #fff;
}

/* ============================================================
   Crawl controls (feature 007) — declarer choice / opponent prompt
   ============================================================ */

.trick-play__crawl-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
}

.crawl-controls__text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
}

.trick-play__crawl-controls button {
  min-width: 12rem;
}

/* ============================================================
   Round summary marriage bonus column
   ============================================================ */

/* Marriage bonus cell in round summary table */
.round-summary__marriage-bonus {
  color: var(--color-success);
  font-weight: 500;
}

/* ============================================================
   Continue to Next Round button (.round-summary__continue-btn)
   ============================================================ */

.round-summary__continue-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0 1.5rem;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 0.5rem;
}

.round-summary__continue-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.round-summary__continue-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   Continued indicator (.round-summary__continued-indicator)
   ============================================================ */

.round-summary__continued-indicator {
  color: var(--color-success);
  font-weight: 600;
  margin-left: 0.35rem;
  white-space: nowrap;
}

/* ============================================================
   Barrel penalty row (.round-summary__penalty-row)
   ============================================================ */

.round-summary__penalty-row td {
  color: var(--color-error);
  font-size: 0.85rem;
  font-style: italic;
  padding-top: 0;
  padding-left: 1.5rem;
}

/* Four-nines bonus line item (.round-summary__four-nines-row) — a positive,
   distinct contribution separate from trick points and the made/missed delta. */
.round-summary__four-nines-row td {
  color: var(--color-success, #4caf50);
  font-size: 0.85rem;
  font-weight: 600;
  padding-top: 0;
  padding-left: 1.5rem;
}

/* Four-nines annotation on the final-results per-round history. */
.final-results__history-row--four-nines td {
  color: var(--color-success, #4caf50);
  font-size: 0.8rem;
  font-style: italic;
  padding-left: 1.5rem;
}

.final-results__history-cumulative--four-nines {
  font-weight: 700;
}

/* ============================================================
   On-barrel marker badge (.status-bar__barrel-marker)
   ============================================================ */

.status-bar__barrel-marker {
  background: #3d2a06;
  border: 1px solid #8a5c10;
  border-radius: var(--radius);
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
  color: #d4a843;
  white-space: nowrap;
  font-weight: 500;
}

/* ============================================================
   Final Results Screen (.final-results__*)
   ============================================================ */

/* Ranking section wrapper */
.final-results__ranking {
  width: 100%;
  max-width: 32rem;
  margin-bottom: 2rem;
}

/* Ranking row — displays player name and cumulative score */
.final-results__ranking-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: background var(--transition), border-color var(--transition);
}

/* Winner highlight with warm gold/yellow accent */
.final-results__ranking-row--winner {
  background: var(--color-surface);
  border-color: #d4a574;
  box-shadow: 0 0 12px rgba(212, 165, 116, 0.2);
}

/* Player nickname in ranking */
.final-results__ranking-nickname {
  font-weight: 600;
  color: var(--color-text);
}

/* Final score in ranking row */
.final-results__ranking-score {
  color: var(--color-primary-hover);
  font-weight: 700;
  font-size: 1.1rem;
  font-family: monospace;
}

/* History table for per-round results */
.final-results__history-table {
  width: 100%;
  max-width: 32rem;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.final-results__history-table tbody {
  display: block;
  overflow-x: auto;
  max-height: 20rem;
}

/* Header rows mirror the flex body rows so columns line up */
.final-results__history-table thead {
  display: block;
}

.final-results__history-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem 0.25rem;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.final-results__history-head-row--sub {
  padding-top: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* Player-name header spans that player's delta + cumulative columns */
.final-results__history-player {
  min-width: 7.5rem;
  text-align: center;
  color: var(--color-text);
}

/* Per-round history row */
.final-results__history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}

.final-results__history-row:hover {
  background: var(--color-surface-alt);
}

/* Round number cell */
.final-results__history-round {
  min-width: 4rem;
  text-align: center;
  color: var(--color-text-muted);
  font-family: monospace;
}

/* Declarer name cell */
.final-results__history-declarer {
  flex: 1;
  color: var(--color-text);
  font-weight: 500;
}

/* Bid amount cell */
.final-results__history-bid {
  min-width: 3.5rem;
  text-align: right;
  color: var(--color-text-muted);
}

/* Per-player delta (round points) */
.final-results__history-delta {
  min-width: 3.5rem;
  text-align: right;
  color: var(--color-text);
}

/* Per-player cumulative score after the round */
.final-results__history-cumulative {
  min-width: 4rem;
  text-align: right;
  color: var(--color-primary-hover);
  font-weight: 600;
}

/* Back to Lobby button */
.final-results__back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0 1.5rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  margin-top: 1.5rem;
}

.final-results__back-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

/* ============================================================
   Status bar Round Number display (.status-bar__round-number)
   ============================================================ */

.status-bar__round-number {
  color: var(--color-text);
  font-weight: 500;
}

/* ============================================================
   Play-phase animations
   ============================================================ */

@keyframes card-leave-right {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(200px); opacity: 0; }
}

@keyframes card-leave-left {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-200px); opacity: 0; }
}

@keyframes card-arrive {
  from { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  to   { transform: scale(1); opacity: 1; }
}

/* ============================================================
   Responsive breakpoints  (mobile-first)
   ============================================================ */

/* 480px — small phones */
@media (max-width: 480px) {
  .status-bar {
    font-size: 0.8rem;
    padding: 0.4rem 12rem 0.4rem 0.75rem;
  }

}

/* 640px — hand fan-stack + opponent single-card collapse */
@media (max-width: 640px) {
  .hand-view {
    flex-wrap: nowrap;
    justify-content: center;
  }

  .hand-view__card + .hand-view__card {
    margin-left: calc(-1 * var(--card-width) * 0.55);
  }

  /* Opponent: collapse stack to single card on narrow viewports.
     OpponentView writes inline styles for width/left, so !important is the only
     way to override them from CSS — refactoring to custom properties is tracked
     separately. */
  .opponent-view__stack {
    width: var(--card-width) !important;
  }

  .opponent-view__stack-card:not(:last-child) {
    display: none;
  }

  .opponent-view__stack-card:last-child {
    left: 0 !important;
  }

  .opponent-view__count {
    display: inline;
  }

  /* 4-player across seat: lay the collapsed card on its side — the top grid
     row shrinks from card-height to card-width, saving vertical space. The
     count badge is centred by the card's flex box, so it stays upright. */
  .game-table--four > .across-zone .opponent-view__stack {
    width: var(--card-height) !important;
    height: var(--card-width);
  }

  .game-table--four > .across-zone .opponent-view__stack-card {
    width: var(--card-height);
    height: var(--card-width);
  }
}

/* 600px — talon fan-stack (3 cards no longer fit side-by-side in center column) */
@media (max-width: 600px) {
  .talon-view {
    gap: 0;
  }

  .talon-view .card-sprite + .card-sprite {
    margin-left: calc(-1 * var(--card-width) * 0.5);
  }

  /* 4-player: the top row carries three opponent stacks (left/across/right);
     keep the across seat compact and let the centre overflow its narrow column
     rather than forcing it to expand the grid. */
  .game-table--four .trick-center {
    width: calc(var(--card-width) * 3);
    margin: 0 auto;
  }

  .game-table--four > .across-zone {
    padding: 0.25rem;
  }
}

/* 480px — small phones: with collapsed single-card opponent stacks the four
   trick-centre cards still must not overlap. The slots are card-width wide and
   anchored left / centre / right, so a 3× card-width centre fits them edge to
   edge; allow overflow:visible (set on .trick-center) to handle any rounding. */
@media (max-width: 480px) {
  .game-table--four .trick-center {
    width: calc(var(--card-width) * 3);
  }
}

/* ============================================================
   Live scoreboard panel (top-right overlay)
   ============================================================ */
.scoreboard {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 50;
  width: 16rem;
  max-width: calc(100vw - 1rem);
  background: rgba(20, 18, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  color: #e8e6f5;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.scoreboard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  cursor: default;
}

.scoreboard__title {
  font-weight: 600;
  /* With a 4th icon (language) in the row, let the title yield first on narrow
     widths rather than pushing the controls off the panel (FR-013). */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoreboard__controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.scoreboard__rules {
  flex-shrink: 0;
  color: inherit;
}

/* Language toggle in the in-game icon row, beside mute/rules (FR-004). */
.scoreboard__lang {
  flex-shrink: 0;
  color: inherit;
}

/* Mute toggle sits beside the rules icon. Reuses .icon-btn for the
   touch-friendly target (§VI / FR-012); the muted state is dimmed so the
   on/off distinction is visible at a glance. */
.scoreboard__mute {
  flex-shrink: 0;
  color: inherit;
}

.mute-btn[aria-pressed="true"] {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.scoreboard__toggle {
  min-width: 1.75rem;
  min-height: 1.75rem;
  border: none;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.scoreboard--collapsed .scoreboard__body {
  display: none;
}

.scoreboard__scroll {
  /* Show the 3 most recent rounds (2 rows each) plus the pinned header and
     TOTAL row; older rounds stay reachable by scrolling up. */
  max-height: 10rem;
  overflow-y: auto;
}

.scoreboard__table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.scoreboard__table th,
.scoreboard__table td {
  padding: 0.15rem 0.4rem;
}

/* Pin the entire header row — including the empty corner cell — so scrolled
   round rows (R1, R2…) slide behind an opaque band instead of bleeding through. */
.scoreboard__table thead th {
  position: sticky;
  top: 0;
  background: rgba(20, 18, 38, 0.98);
}

.scoreboard__col-head {
  font-weight: 600;
}

.scoreboard__label {
  text-align: left;
  color: #b6b2d6;
}

.scoreboard__round-num {
  font-weight: 600;
  color: #e8e6f5;
}

.scoreboard__rnd .scoreboard__val {
  color: #b6b2d6;
}

.scoreboard__total {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

@media (max-width: 480px) {
  .scoreboard {
    width: 11rem;
    font-size: 0.72rem;
  }
}

/* ============================================================
   Four-nines bonus modal (FR-003) — blocking announcement.
   Reuses .modal-overlay / .modal-card from index.css; this layer
   sits above the status bar so the table is fully gated.
   ============================================================ */
.four-nines-modal {
  z-index: 250;
  text-align: center;
}

.four-nines-modal__card {
  max-width: 22rem;
}

.four-nines-modal__text {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.four-nines-modal__progress {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  min-height: 1.1em;
}

/* ============================================================
   Marriage-declared notice — non-blocking, auto-closing popup
   shown to opponents. Reuses .modal-overlay / .modal-card.
   ============================================================ */
.marriage-notice {
  z-index: 250;
  text-align: center;
}

.marriage-notice__card {
  max-width: 22rem;
}

.marriage-notice__text {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

/* ============================================================
   Game history panel (bottom-left overlay) — feature 012.
   Base shell + anchor only; row/list, collapsed, and fixed-height
   scroll variants are layered in by later tasks.
   ============================================================ */
.history-panel {
  position: fixed;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 50;
  /* Expanded: the original readable width on every viewport (bounded only by the
     screen). The collapsed handle gets a fluid width below. */
  width: 16rem;
  max-width: calc(100vw - 1rem);
  background: rgba(20, 18, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  color: #e8e6f5;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.history-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  cursor: default;
}

.history-panel__title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
}

.history-panel__title-text {
  white-space: nowrap;
}

.history-panel__icon {
  display: block;
  flex: none;
}

.history-panel__toggle {
  flex: none;
  min-width: 1.75rem;
  min-height: 1.75rem;
  border: none;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

/* Fixed-footprint body: ~10 rows tall, older entries reachable by scrolling so
   the box never grows and displaces other game-screen UI (FR-011/FR-013). */
.history-panel__scroll {
  height: 14rem;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.history-panel__row,
.history-panel__empty {
  padding: 0.2rem 0.6rem;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}

.history-panel__row:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

.history-panel__empty {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Collapsed: hide the log body, leaving only the header handle. The handle gets
   a fluid width — fills the space left of the centred hand (which sits at roughly
   50vw − 19rem, 8 cards max), with a gap, capped at the 16rem expanded width and
   floored so the icon + toggle never overlap. */
.history-panel--collapsed {
  width: clamp(4.75rem, calc(50vw - 20rem), 16rem);
}

.history-panel--collapsed .history-panel__body {
  display: none;
}

/* When the collapsed handle is narrower than the "History" word needs (below
   ~960px it drops under that), make it icon-only so the label never clips. The
   expanded panel keeps its label since it stays 16rem wide. */
@media (max-width: 960px) {
  .history-panel--collapsed .history-panel__title-text {
    display: none;
  }
}

@media (max-width: 480px) {
  .history-panel {
    font-size: 0.72rem;
  }

  .history-panel__scroll {
    height: 9rem;
  }
}
