:root {
  color-scheme: dark;
  --felt-center: #196844;
  --felt-mid: #124e33;
  --felt-edge: #0b3321;
  --surface-dark: rgba(8, 28, 19, 0.82);
  --surface-panel: rgba(12, 42, 29, 0.9);
  --surface-card: #ffffff;
  --border-subtle: rgba(255, 255, 255, 0.14);
  --border-gold: #e6c36a;
  --text-main: #f4f7f5;
  --text-muted: #b6cfc1;
  --suit-black: #182026;
  --suit-red: #c91d32;
  --strain-nt: #1e4b8f;
  --accent-gold: #f0c95c;
  --accent-gold-hover: #f7d87a;
  --danger: #e05252;
  --success: #34c77b;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.48);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: var(--felt-edge);
  background-image: radial-gradient(ellipse at 50% 42%, var(--felt-center) 0%, var(--felt-mid) 52%, var(--felt-edge) 100%);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100dvh;
  overflow: hidden;
}

/* Suit colors */
.suit-black { color: var(--suit-black); }
.suit-red { color: var(--suit-red); }
.strain-nt { color: var(--strain-nt); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-gold);
  color: #16241b;
  border-color: #d4ad42;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-gold-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-ghost:hover:not(:disabled),
.btn-ghost.btn-active {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--border-gold);
}

.btn-seat {
  background: rgba(240, 201, 92, 0.16);
  color: var(--accent-gold);
  border-color: rgba(240, 201, 92, 0.55);
  font-size: 0.75rem;
  padding: 4px 10px;
}

.btn-seat:hover:not(:disabled) {
  background: var(--accent-gold);
  color: #16241b;
}

.btn-danger-outline {
  background: rgba(224, 82, 82, 0.14);
  color: #ff9c9c;
  border-color: rgba(224, 82, 82, 0.55);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-lg {
  font-size: 0.95rem;
  padding: 11px 22px;
  border-radius: var(--radius-md);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 6px 10px;
}

.btn-xs {
  font-size: 0.75rem;
  padding: 4px 8px;
}

.btn-confirm {
  box-shadow: 0 0 0 2px rgba(240, 201, 92, 0.35), var(--shadow-sm);
}

.input {
  width: 100%;
  background: rgba(6, 22, 15, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
}

.input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(240, 201, 92, 0.25);
}

.input::placeholder {
  color: rgba(182, 207, 193, 0.6);
}

.inline-error {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(224, 82, 82, 0.2);
  border: 1px solid rgba(224, 82, 82, 0.5);
  color: #ffc2c2;
  font-size: 0.85rem;
}

/* ===== Lobby ===== */
.lobby-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lobby-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.lobby-suits {
  display: inline-flex;
  gap: 10px;
  padding: 6px 16px;
  background: #ffffff;
  border-radius: 999px;
  font-size: 1.35rem;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.lobby-title {
  margin: 0 0 8px;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.lobby-subtitle {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.45;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lobby-divider::before,
.lobby-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.lobby-join-form {
  display: flex;
  gap: 8px;
}

/* ===== Table Shell & Top Bar ===== */
.table-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.topbar {
  background: var(--surface-dark);
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 14px;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-row-2 {
  display: none;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-center-desktop {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-btn {
  background: none;
  border: none;
  color: var(--accent-gold);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 2px 4px;
}

.table-code-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--text-main);
}

.topbar-contract {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
}

.contract-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: #ffffff;
  border-radius: 5px;
  font-weight: 800;
  font-size: 0.85rem;
}

.topbar-tricks {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.82rem;
}

.topbar-tricks strong {
  color: var(--text-main);
}

.spectating-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(86, 174, 255, 0.2);
  color: #9ad0ff;
  border: 1px solid rgba(86, 174, 255, 0.4);
  padding: 2px 7px;
  border-radius: 999px;
}

.spectating-badge-btn {
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.spectating-badge-btn:hover {
  background: rgba(86, 174, 255, 0.34);
  border-color: rgba(154, 208, 255, 0.75);
}

.btn-icon-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn-icon-edit:hover {
  color: var(--accent-gold);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(240, 201, 92, 0.4);
}

.spectator-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #888;
}

.conn-connected .conn-dot { background: var(--success); }
.conn-connecting .conn-dot,
.conn-reconnecting .conn-dot { background: var(--accent-gold); }
.conn-disconnected .conn-dot { background: var(--danger); }

.reconnect-banner {
  background: rgba(240, 201, 92, 0.2);
  border-bottom: 1px solid rgba(240, 201, 92, 0.5);
  color: var(--accent-gold);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  flex-shrink: 0;
}

/* ===== Desktop 3x3 Compass Grid ===== */
.table-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(165px, 235px) 1fr minmax(165px, 235px);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    ". top ."
    "left center right"
    "bottom bottom bottom";
  gap: 8px;
  padding: 10px 14px 12px;
  overflow: hidden;
}

.mobile-opponents-strip,
.dummy-mobile-bar {
  display: none;
}

.compass-top {
  grid-area: top;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.compass-left {
  grid-area: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
}

.compass-right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
}

.compass-center {
  grid-area: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.compass-bottom {
  grid-area: bottom;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* ===== Seat Nameplates ===== */
.seat-plate {
  background: var(--surface-dark);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 145px;
  max-width: 230px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.seat-plate.seat-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(240, 201, 92, 0.35), var(--shadow-md);
}

.seat-plate.seat-me {
  background: rgba(16, 56, 38, 0.92);
}

.seat-plate-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.seat-dir {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-online { background: var(--success); }
.dot-offline { background: #8c9690; }

.seat-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-empty-label {
  color: var(--text-muted);
  font-style: italic;
}

.seat-cards-count {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--text-muted);
}

.seat-plate-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.seat-plate-meta:empty {
  display: none;
}

.role-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.role-dealer { background: var(--accent-gold); color: #16241b; }
.role-declarer { background: #3b82f6; color: #fff; }
.role-dummy { background: #8b5cf6; color: #fff; }

/* ===== Playing Cards ===== */
.playing-card {
  position: relative;
  width: 62px;
  height: 88px;
  background: var(--surface-card);
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  padding: 0;
  user-select: none;
  flex-shrink: 0;
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease, border-color 0.14s ease;
}

.playing-card.card-sm {
  width: 44px;
  height: 62px;
  border-radius: 5px;
}

.playing-card.card-xs {
  width: 38px;
  height: 54px;
  border-radius: 4px;
}

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-weight: 800;
}

.card-corner-tl {
  top: 4px;
  left: 5px;
}

.card-corner-br {
  bottom: 4px;
  right: 5px;
  transform: rotate(180deg);
}

.card-rank {
  font-size: 0.92rem;
  letter-spacing: -0.04em;
}

.card-suit {
  font-size: 0.82rem;
}

.card-center-suit {
  font-size: 1.75rem;
  line-height: 1;
}

.card-sm .card-rank,
.card-xs .card-rank { font-size: 0.78rem; }
.card-sm .card-suit,
.card-xs .card-suit { display: none; }
.card-sm .card-center-suit,
.card-xs .card-center-suit {
  font-size: 1.25rem;
  transform: translateY(16%);
}
.card-sm .card-corner-br,
.card-xs .card-corner-br { display: none; }

.playing-card.card-playable {
  cursor: pointer;
  border-color: #eab308;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(240, 201, 92, 0.65);
}

.playing-card.card-playable:hover {
  transform: translateY(-10px);
  z-index: 5;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.48), 0 0 0 2px var(--accent-gold);
}

.playing-card.card-selected {
  transform: translateY(-14px) !important;
  z-index: 10;
  border: 2px solid var(--accent-gold);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.52), 0 0 0 3px rgba(240, 201, 92, 0.6);
}

.playing-card:disabled,
.playing-card.card-dimmed {
  opacity: 1;
  background: #c3ccc7;
  border-color: #8f9b95;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  cursor: not-allowed;
}

.playing-card.card-dimmed.suit-black,
.playing-card:disabled.suit-black {
  color: #4a545b;
}

.playing-card.card-dimmed.suit-red,
.playing-card:disabled.suit-red {
  color: #9e4852;
}

.playing-card.card-winner {
  border: 2.5px solid var(--accent-gold);
  box-shadow: 0 0 18px rgba(240, 201, 92, 0.75), var(--shadow-md);
}

/* ===== Hand Fan (Desktop single row) ===== */
.hand-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.play-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
}

.play-confirm-hint {
  font-size: 0.8rem;
  color: var(--accent-gold);
  background: rgba(8, 28, 19, 0.72);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(240, 201, 92, 0.35);
}

.hand-fan {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px 12px 2px;
  max-width: 100%;
}

.hand-fan .playing-card {
  margin-left: -14px;
}

.hand-fan .playing-card:first-child {
  margin-left: 0;
}

/* ===== Dummy Hand (Desktop Compass) ===== */
.compass-seat-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.compass-seat-left { align-items: flex-start; }
.compass-seat-right { align-items: flex-end; }

.dummy-compass-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(8, 28, 19, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  max-width: 240px;
}

.compass-seat-top .dummy-compass-hand {
  max-width: 560px;
  flex-wrap: nowrap;
}

.dummy-compass-hand.dummy-active-turn,
.dummy-mobile-bar.dummy-active-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(240, 201, 92, 0.35);
}

.dummy-suit-col {
  display: flex;
  align-items: center;
}

.dummy-suit-col .playing-card {
  margin-left: -20px;
}

.dummy-suit-col .playing-card:first-child {
  margin-left: 0;
}

.dummy-void {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ===== Waiting Panel ===== */
.waiting-panel {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  text-align: center;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.waiting-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.waiting-status {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.waiting-dealer {
  margin: 0 0 18px;
  font-size: 0.88rem;
}

.waiting-note {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== Auction Box ===== */
.auction-box {
  background: var(--surface-panel);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.auction-box.auction-my-turn {
  border-color: var(--accent-gold);
}

.auction-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auction-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.auction-turn-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-turn {
  background: rgba(240, 201, 92, 0.22);
  color: var(--accent-gold);
  border: 1px solid rgba(240, 201, 92, 0.5);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.auction-body {
  display: flex;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.auction-history-wrap {
  flex: 1;
  min-width: 165px;
  max-height: 260px;
  overflow-y: auto;
  background: rgba(5, 20, 14, 0.55);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.auction-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: center;
}

.auction-table th {
  position: sticky;
  top: 0;
  background: #0c3121;
  padding: 5px 4px;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-subtle);
}

.auction-th-turn {
  color: var(--accent-gold);
}

.dealer-tag {
  display: inline-block;
  font-size: 0.65rem;
  background: var(--accent-gold);
  color: #16241b;
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 2px;
}

.auction-table td {
  padding: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.auction-cell-empty {
  color: rgba(255, 255, 255, 0.25);
}

.auction-empty-msg {
  color: var(--text-muted);
  padding: 14px 6px !important;
  font-style: italic;
}

.call-bid {
  display: inline-block;
  background: #ffffff;
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 800;
  font-size: 0.8rem;
}

.call-pass { color: var(--text-muted); font-weight: 600; }
.call-dbl { color: #ff7b7b; font-weight: 800; }
.call-rdbl { color: #7cc4ff; font-weight: 800; }

.auction-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.bid-pad-desktop {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bid-pad-mobile {
  display: none;
}

.bid-matrix {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bid-matrix-row {
  display: grid;
  grid-template-columns: repeat(5, 42px);
  gap: 3px;
}

.bid-btn {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 2px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.bid-btn:hover:not(:disabled) {
  border-color: var(--accent-gold);
  background: #fffbeb;
}

.bid-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.bid-btn-selected {
  border-color: var(--accent-gold) !important;
  background: #fef08a !important;
  box-shadow: 0 0 0 2px rgba(240, 201, 92, 0.55);
}

.bid-special-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 4px;
  margin-top: 2px;
}

.bid-btn-pass {
  background: #e2e8f0;
  color: #1e293b;
}

.bid-btn-dbl {
  background: #fee2e2;
  color: #b91c1c;
}

.bid-btn-rdbl {
  background: #dbeafe;
  color: #1d4ed8;
}

.bid-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
}

.confirm-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== Trick Area ===== */
.trick-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  position: relative;
}

.trick-banner {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(8, 28, 19, 0.75);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.trick-banner-turn {
  color: var(--accent-gold);
  border-color: rgba(240, 201, 92, 0.55);
}

.trick-banner-winner {
  color: #ffffff;
  background: rgba(24, 118, 68, 0.9);
  border-color: var(--accent-gold);
}

.trick-felt-stage {
  display: flex;
  align-items: center;
  justify-content: center;
}

.trick-cross {
  display: grid;
  grid-template-columns: 72px 72px 72px;
  grid-template-rows: 92px 92px 92px;
  grid-template-areas:
    ". top ."
    "left . right"
    ". bottom .";
  align-items: center;
  justify-items: center;
  gap: 4px;
}

.trick-slot-top { grid-area: top; }
.trick-slot-left { grid-area: left; }
.trick-slot-right { grid-area: right; }
.trick-slot-bottom { grid-area: bottom; }

.last-trick-popover {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(9, 32, 22, 0.96);
  border: 1.5px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.last-trick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent-gold);
}

/* ===== Round Summary ===== */
.round-summary {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.summary-banner {
  text-align: center;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
}

.summary-banner.outcome-made {
  background: rgba(52, 199, 123, 0.16);
  border-color: rgba(52, 199, 123, 0.5);
}

.summary-banner.outcome-down {
  background: rgba(224, 82, 82, 0.16);
  border-color: rgba(224, 82, 82, 0.5);
}

.summary-headline {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.summary-subline {
  font-size: 0.9rem;
  color: var(--text-main);
}

.summary-detail {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.revealed-hands-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.revealed-hand-card {
  background: rgba(5, 20, 14, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.8rem;
}

.revealed-hand-header {
  margin-bottom: 5px;
  color: var(--accent-gold);
}

.revealed-suit-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.45;
}

.revealed-suit-sym {
  display: inline-block;
  width: 16px;
  text-align: center;
  background: #ffffff;
  border-radius: 3px;
  font-size: 0.78rem;
  line-height: 1.15;
}

.revealed-suit-ranks {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.summary-note {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== Modal & Toasts ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 14, 9, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: #0e3826;
  border: 1.5px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 1.3rem;
}

.modal-subtitle {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  max-width: 320px;
}

.toast-error {
  background: #7f1d1d;
  border: 1px solid #f87171;
  color: #fee2e2;
}

.toast-info {
  background: #14532d;
  border: 1px solid var(--accent-gold);
  color: #f0fdf4;
}

/* ===== Mobile Responsive (< 768px) ===== */
@media (max-width: 767px) {
  .table-shell {
    position: fixed;
    inset: 0;
    height: 100dvh;
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  .table-shell:has(.reconnect-banner) {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .topbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 4px;
    background: #0b3321;
    overflow: hidden;
  }

  .topbar-row {
    gap: 4px;
    min-width: 0;
  }

  .topbar-left,
  .topbar-right {
    gap: 4px;
    min-width: 0;
  }

  .brand-btn {
    font-size: 0.85rem;
    padding: 2px;
  }

  .table-code-pill {
    font-size: 0.72rem;
    padding: 2px 6px;
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .btn-xs {
    font-size: 0.7rem;
    padding: 3px 6px;
  }

  .spectator-count {
    font-size: 0.74rem;
  }

  .conn-badge {
    padding: 3px 5px;
  }

  .topbar-center-desktop,
  .desktop-only-btn,
  .conn-text {
    display: none;
  }

  .topbar-row-2 {
    display: flex;
    margin-top: 3px;
    padding-top: 3px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: clamp(0.72rem, 2.2vw, 0.82rem);
  }

  /* Strict proportional vertical CSS Grid:
     auto opponents | (optional bounded dummy) | minmax(0, 1fr) center | bounded bottom hand */
  .table-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 4px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: clamp(3px, 0.7dvh, 6px);
    overflow: hidden;
  }

  .table-board:has(.dummy-mobile-bar) {
    grid-template-rows: auto minmax(0, auto) minmax(0, 1fr) auto;
  }

  .compass-top,
  .compass-left,
  .compass-right {
    display: none;
  }

  .mobile-opponents-strip {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
  }

  .seat-plate.seat-plate-compact {
    min-width: 0;
    max-width: none;
    width: 100%;
    padding: clamp(2px, 0.45dvh, 4px) 5px;
    gap: 2px;
    overflow: hidden;
  }

  .seat-plate-compact .seat-plate-main {
    font-size: clamp(0.68rem, 2vw, 0.76rem);
    gap: 3px;
    min-width: 0;
  }

  .seat-plate-compact .seat-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .seat-plate-compact .seat-dir {
    width: 16px;
    height: 16px;
    font-size: 0.64rem;
  }

  .dummy-mobile-bar {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.4dvh, 4px);
    background: rgba(8, 28, 19, 0.75);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: clamp(3px, 0.55dvh, 5px) 6px;
    max-height: 18dvh;
    overflow: hidden;
  }

  .dummy-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: clamp(0.66rem, 1.9vw, 0.74rem);
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.1;
  }

  .dummy-mobile-suits {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .dummy-mobile-suit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
  }

  .dummy-suit-pip {
    background: #ffffff;
    border-radius: 3px;
    padding: 0 4px;
    font-size: clamp(0.65rem, 1.8vw, 0.74rem);
    line-height: 1.15;
  }

  .dummy-mobile-cards {
    --dummy-card-h: clamp(36px, 6.4dvh, 54px);
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    max-width: 100%;
    padding: 2px 0;
  }

  .dummy-mobile-cards .playing-card.card-sm {
    height: var(--dummy-card-h);
    width: auto;
    aspect-ratio: 5 / 7;
    margin-left: calc(var(--dummy-card-h) * -0.34);
    border-radius: 4px;
  }

  .dummy-mobile-cards .playing-card.card-sm:first-child {
    margin-left: 0;
  }

  .playing-card .card-suit,
  .playing-card .card-corner-br {
    display: none;
  }

  .playing-card .card-center-suit {
    transform: translateY(16%);
  }

  .dummy-mobile-cards .card-sm .card-corner-tl {
    top: 2px;
    left: 3px;
  }

  .dummy-mobile-cards .card-sm .card-rank { font-size: clamp(0.66rem, 1.8dvh, 0.8rem); }
  .dummy-mobile-cards .card-sm .card-center-suit { font-size: clamp(0.95rem, 2.5dvh, 1.3rem); }

  .compass-center {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .table-board:has(.dummy-mobile-bar) .compass-center {
    grid-row: 3;
  }

  .round-summary,
  .auction-history-wrap {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Container-queried trick stage: 4 played cards scale fluidly to never clip or overlap */
  .trick-area {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    justify-items: center;
    align-items: center;
    gap: clamp(2px, 0.6dvh, 6px);
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 2px 0;
  }

  .trick-banner {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    padding: 3px 10px;
  }

  .trick-felt-stage {
    container-type: size;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .trick-cross {
    --trick-card-h: clamp(40px, min(44cqh, 34cqw), 92px);
    --trick-card-w: calc(var(--trick-card-h) * 5 / 7);
    display: grid;
    grid-template-columns: var(--trick-card-w) var(--trick-card-w) var(--trick-card-w);
    grid-template-rows: calc(var(--trick-card-h) * 0.56) var(--trick-card-h) calc(var(--trick-card-h) * 0.56);
    grid-template-areas: none;
    gap: 0 clamp(4px, 1.5cqw, 10px);
    align-items: center;
    justify-items: center;
  }

  .last-trick-popover .trick-cross {
    --trick-card-h: clamp(46px, 8dvh, 68px);
    --trick-card-w: calc(var(--trick-card-h) * 5 / 7);
    gap: 0 6px;
  }

  .trick-slot-top {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: start;
  }

  .trick-slot-left {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
  }

  .trick-slot-right {
    grid-column: 3;
    grid-row: 2;
    align-self: center;
  }

  .trick-slot-bottom {
    grid-column: 2;
    grid-row: 2 / 4;
    align-self: end;
  }

  .trick-cross .playing-card {
    height: var(--trick-card-h);
    width: auto;
    aspect-ratio: 5 / 7;
    border-radius: clamp(4px, calc(var(--trick-card-h) * 0.08), 7px);
  }

  .trick-cross .card-corner-tl {
    top: 3px;
    left: 4px;
  }

  .trick-cross .card-corner-br {
    display: none;
  }

  .trick-cross .card-rank { font-size: clamp(0.7rem, calc(var(--trick-card-h) * 0.22), 0.96rem); }
  .trick-cross .card-suit { font-size: clamp(0.62rem, calc(var(--trick-card-h) * 0.19), 0.84rem); }
  .trick-cross .card-center-suit { font-size: clamp(1.05rem, calc(var(--trick-card-h) * 0.34), 1.75rem); }

  /* Mobile 2-row auction picker */
  .auction-box {
    padding: 8px 10px;
    gap: 6px;
  }

  .auction-body {
    flex-direction: column;
    gap: 6px;
  }

  .auction-history-wrap {
    max-height: clamp(72px, 14dvh, 130px);
  }

  .bid-pad-desktop {
    display: none;
  }

  .bid-pad-mobile {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .bid-mobile-levels {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }

  .bid-lvl-btn {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    padding: clamp(5px, 0.9dvh, 8px) 0;
    cursor: pointer;
  }

  .bid-lvl-btn.bid-lvl-active {
    background: var(--accent-gold);
    color: #16241b;
    border-color: var(--accent-gold);
  }

  .bid-lvl-btn:disabled {
    opacity: 0.25;
  }

  .bid-mobile-strains {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .bid-pad-mobile .bid-btn {
    padding: clamp(6px, 1dvh, 9px) 2px;
    font-size: 0.85rem;
  }

  /* Mobile 2-row hand */
  .compass-bottom {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: clamp(2px, 0.5dvh, 4px);
    position: relative;
    z-index: 5;
    overflow: hidden;
  }

  .table-board:has(.dummy-mobile-bar) .compass-bottom {
    grid-row: 4;
  }

  .compass-bottom > .seat-plate {
    min-width: 0;
    max-width: none;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: clamp(2px, 0.45dvh, 4px) 8px;
  }

  .hand-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: clamp(3px, 0.5dvh, 6px);
  }

  .play-confirm-bar {
    min-height: clamp(24px, 3.6dvh, 32px);
  }

  .play-confirm-hint {
    font-size: clamp(0.68rem, 1.9vw, 0.76rem);
    padding: 3px 10px;
  }

  .play-confirm-bar .btn-confirm {
    width: 100%;
    max-width: 240px;
    padding: clamp(5px, 0.8dvh, 8px) 12px;
    font-size: clamp(0.78rem, 2.2vw, 0.88rem);
  }

  .hand-fan {
    --hand-card-h: clamp(48px, 8.6dvh, 70px);
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: clamp(2px, 0.45dvh, 4px) 3px;
    padding: 5px 2px 2px;
  }

  .hand-fan .playing-card {
    height: auto;
    width: min(calc((100% - 22px) / 7), calc(var(--hand-card-h) * 5 / 7));
    aspect-ratio: 5 / 7;
    margin-left: 0;
    border-radius: 5px;
  }

  .hand-fan .playing-card:nth-child(8) {
    margin-left: 0;
  }

  .hand-fan .playing-card.card-playable:hover {
    transform: translateY(-4px);
  }

  .hand-fan .playing-card.card-selected,
  .dummy-mobile-cards .playing-card.card-selected {
    transform: translateY(-6px) !important;
  }

  .hand-fan .card-corner-tl {
    top: 3px;
    left: 4px;
  }

  .hand-fan .card-rank { font-size: clamp(0.72rem, 1.9dvh, 0.88rem); }
  .hand-fan .card-suit { font-size: clamp(0.64rem, 1.7dvh, 0.78rem); }
  .hand-fan .card-center-suit { font-size: clamp(1.05rem, 2.6dvh, 1.45rem); }
  .hand-fan .card-corner-br { display: none; }

  .revealed-hands-grid {
    grid-template-columns: 1fr;
  }
}
