/* ═══════════════════════════════════════════════════════════
   SPADES · JJDD — Design v2 (light cream theme)
   ═══════════════════════════════════════════════════════════ */

/* ── Custom properties ──────────────────────────────────── */
:root {
  /* Typography */
  --f-display: "Fraunces", Georgia, "Times New Roman", serif;
  --f-ui:      "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono:    "JetBrains Mono", "Fira Code", "Courier New", monospace;

  /* Cream palette */
  --cream:     #f7f4ec;   /* main background */
  --cream-2:   #ede9da;   /* panel / card in cream */
  --paper:     #fdfcf9;   /* near-white surfaces */
  --ink:       #1c1914;   /* primary text */
  --ink-2:     #3d3828;   /* secondary text */
  --ink-3:     #7a7060;   /* muted / label text */
  --line:      #dbd5c4;   /* default border */
  --line-2:    #c8c1ab;   /* stronger border */

  /* Accent (lime) */
  --accent:    #a8d846;
  --accent-dk: #4a7016;
  --accent-bg: #edf8c3;

  /* Teams */
  --team-a:    #5ba3d8;   /* sky blue */
  --team-b:    #e8704e;   /* coral */

  /* Board */
  --felt:   #1e6640;
  --felt-texture: none;

  /* Cards */
  --card-w: 62px;
  --card-h: 90px;

  /* Suits */
  --heart:   #d10000;
  --diamond: #d10000;
  --club:    #0d0d0d;
  --spade:   #0d0d0d;
  --joker:   #7d3c98;

  /* Table sizing (preserved from v1) */
  --table-scale:         0.825;
  --table-area-min:      680px;
  --table-surface-size:  980px;

  /* Legacy aliases so game.js data-attrs keep working */
  --bg:          var(--cream);
  --panel:       var(--paper);
  --panel-light: var(--cream-2);
  --text:        var(--ink);
  --muted:       var(--ink-3);
  --border:      var(--line);
}

/* ── Reset / base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Prevent iOS auto-zoom on focus (font-size must be ≥ 16px) */
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
select, textarea { font-size: max(1em, 16px); }

/* Fast taps, no flash */
button, summary, input[type="checkbox"], input[type="radio"],
input[type="range"], select, label { touch-action: manipulation; }

/* Momentum scroll on iOS */
.chat-messages, .side-body, .rulebook, .modal-content,
.score-history, .side-pane { -webkit-overflow-scrolling: touch; }

body {
  margin: 0;
  font-family: var(--f-ui);
  background: var(--cream);
  color: var(--ink);
  /* Flex column so topbar + .table fill viewport exactly */
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button { font-family: var(--f-ui); cursor: pointer; }
h1, h2, h3 { font-family: var(--f-display); }

/* ── data-mode display rules ─────────────────────────────── */
body[data-mode="local"]    .network-only  { display: none; }
body[data-mode="computer"] .network-only  { display: none; }
body[data-mode="network"]  .local-only    { display: none; }
/* computer mode shares local-only buttons — no extra hiding needed */
body[data-mode="computer"] .local-only    { display: none; }
body:not(.show-server)     .server-address-group { display: none; }

/* ── Avatar controls: lobby-only ─────────────────────────── */
.seat .avatar-picker, .seat .avatar-upload, .seat .avatar-clear { display: none; }
body[data-phase="lobby"] .seat .avatar-picker,
body[data-phase="lobby"] .seat .avatar-upload,
body[data-phase="lobby"] .seat .avatar-clear { display: block; }

/* ── Large cards ─────────────────────────────────────────── */
body[data-large-cards="true"] {
  --card-w: 80px;
  --card-h: 116px;
}

/* ── High contrast ──────────────────────────────────────── */
body[data-contrast="high"] {
  --cream:   #f0ede4;
  --ink:     #000000;
  --ink-3:   #333333;
  --line:    #999999;
  --accent:  #1a7a0a;
}

/* ── Suit patterns ──────────────────────────────────────── */
body[data-suit-patterns="true"] .card.pattern-spade {
  background-image: repeating-linear-gradient(135deg, rgba(30,30,60,0.08) 0 4px, transparent 4px 8px);
}
body[data-suit-patterns="true"] .card.pattern-heart {
  background-image: repeating-linear-gradient(45deg, rgba(192,57,43,0.1) 0 4px, transparent 4px 8px);
}
body[data-suit-patterns="true"] .card.pattern-diamond {
  background-image: repeating-linear-gradient(0deg, rgba(230,126,34,0.1) 0 6px, transparent 6px 12px);
}
body[data-suit-patterns="true"] .card.pattern-club {
  background-image: repeating-linear-gradient(90deg, rgba(26,82,118,0.08) 0 5px, transparent 5px 10px);
}

/* ════════════════════════════════════════════════════════════
   TOPBAR  — dark
   ════════════════════════════════════════════════════════════ */
.topbar {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 52px;
  background: #100f0e;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  padding: 6px 4px;
  cursor: pointer;
  font-family: var(--f-display);
  font-size: 17px;
  font-weight: 600;
  color: #fdfcf9;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { color: rgba(255,255,255,0.72); }

.mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fdfcf9;
  font-size: 14px;
  flex-shrink: 0;
}

.eyebrow {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
  white-space: nowrap;
  padding: 3px 8px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
}

.flex-spacer { flex: 1; }

/* ── Score strip inside topbar ── */
/* score-strip / score-item — moved to bottom of file under FIX – SCORE STRIP LEGIBILITY */

/* ── Topbar action buttons ── */
.topbar-actions { display: flex; gap: 6px; align-items: center; }
.tb-btn {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: #fdfcf9;
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.tb-btn:hover { border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.18); }
.tb-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Show Deal only in lobby/game-over phases */
#start-hand { display: none; }
body[data-phase="lobby"] #start-hand,
body[data-phase="game-over"] #start-hand { display: inline-flex; align-items: center; }

/* Show Next Hand only in hand-over/game-over */
#next-hand { display: none; }
body[data-phase="hand-over"] #next-hand,
body[data-phase="game-over"] #next-hand { display: inline-flex; align-items: center; }

/* Icon button (?) */
.iconbtn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.iconbtn:hover { border-color: rgba(255,255,255,0.35); color: #fff; }

/* Spades-broken badge (rendered into score-strip) */
.spades-broken-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(168,216,70,0.18);
  border: 1px solid rgba(168,216,70,0.35);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

/* ── Hero shim (game.js references this to toggle .compact) ── */
.hero { display: none; }

/* ════════════════════════════════════════════════════════════
   MAIN TABLE CONTAINER
   ════════════════════════════════════════════════════════════ */
.table {
  flex: 1;          /* fill remaining body height below topbar */
  min-height: 0;    /* allow flex shrink past content size */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════════
   LOBBY
   ════════════════════════════════════════════════════════════ */
.lobby {
  display: grid;
  grid-template-columns: 1fr 440px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Hero / left column ──────────────────────────────────── */
.lobby-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 52px 56px 48px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 18% 22%, rgba(168,216,70,0.26) 0%, transparent 52%),
    radial-gradient(ellipse at 82% 82%, rgba(220,135,95,0.18) 0%, transparent 50%),
    var(--cream);
}

.lobby-hero-content { flex: 1; }

.lobby-kicker {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 18px;
}

.lobby-hero h1 {
  font-family: var(--f-display);
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 500;
  line-height: 1.06;
  color: var(--ink);
  margin: 0 0 18px;
}
.lobby-hero h1 em { font-style: italic; color: var(--accent-dk); }

.lobby-lede {
  font-size: 14px;
  color: var(--ink-3);
  line-height: 1.65;
  margin: 0;
  max-width: 400px;
}

/* Variant selector — pinned to bottom of hero */
.lobby-variant {
  margin-top: auto;
  padding-top: 40px;
  position: relative;
  z-index: 1;
}
.variant-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.variant-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line-2);
  background: rgba(253,252,249,0.75);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--f-ui);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  backdrop-filter: blur(6px);
}
.variant-pill:hover { border-color: var(--ink-3); }
.variant-pill[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}
.variant-pill .tag {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.6;
}
.variant-desc {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin: 0;
}
.variant-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}
.variant-list li {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.4;
}
.variant-list li strong {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--accent-dk);
  display: inline-block;
  min-width: 54px;
  margin-right: 4px;
}
@media (max-width: 720px) {
  .variant-list { grid-template-columns: 1fr; }
}

/* Brand question-mark accent (lobby h1 + topbar) */
.brand-q {
  color: var(--accent);
  font-weight: 700;
  margin-left: 1px;
}
.brand-q-big {
  color: var(--accent-dk);
  font-style: normal;
  margin-left: 2px;
}

/* Decorative SVG cards (bottom-right of hero) */
.lobby-deco {
  position: absolute;
  right: -8px;
  bottom: 80px;
  width: 260px;
  height: 260px;
  pointer-events: none;
  opacity: 0.95;
}

/* Minimised-only button */
.toggle-lobby { display: none; }
.lobby.minimized .toggle-lobby {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--cream-2);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Right column: start a table ─────────────────────────── */
.lobby-right {
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 40px 36px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.lobby-right-title {
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 4px;
}
.lobby-right-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin: 0;
}

/* ── Mode cards ──────────────────────────────────────────── */
.mode-cards { display: flex; flex-direction: column; gap: 8px; }
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--f-ui);
}
.mode-card:hover { border-color: var(--line-2); }
.mode-card[aria-pressed="true"] {
  border-color: var(--accent-dk);
  background: var(--accent-bg);
}
.mode-ico {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.mode-card[aria-pressed="true"] .mode-ico {
  background: var(--accent);
  border-color: var(--accent);
}
.mode-meta { flex: 1; min-width: 0; }
.mode-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  margin: 0 0 2px;
  line-height: 1.3;
}
.mode-desc {
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.4;
}
.mode-check {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.mode-card[aria-pressed="true"] .mode-check {
  background: var(--accent-dk);
  border-color: var(--accent-dk);
}
.mode-card[aria-pressed="true"] .mode-check::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}

/* ── Field + input ───────────────────────────────────────── */
.lobby-field { display: grid; gap: 5px; }
.lobby-field label,
.lobby-field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  display: block;
}
.lobby-input {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.lobby-input:focus { outline: none; border-color: var(--accent-dk); }

/* ── CTA buttons ─────────────────────────────────────────── */
.lobby-cta { display: flex; flex-direction: column; gap: 8px; }

.lobby-btn-primary {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: var(--accent-dk);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--f-ui);
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: filter 0.15s, transform 0.1s;
}
.lobby-btn-primary:hover { filter: brightness(1.06); }
.lobby-btn-primary:active { transform: scale(0.99); }
.lobby-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.lobby-btn-secondary {
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--cream-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--f-ui);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.lobby-btn-secondary:hover { border-color: var(--line-2); background: var(--line); }
.lobby-btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.lobby-btn-ghost {
  width: 100%;
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  font-family: var(--f-ui);
  cursor: pointer;
  transition: color 0.15s;
}
.lobby-btn-ghost:hover { color: var(--ink); }

/* AI opponents toggle row (Local / Solo mode) */
.local-ai-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.local-ai-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent, #a8d846);
  cursor: pointer;
  flex-shrink: 0;
}

/* Connection status + tips */
.conn-status {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin: 0;
}
.lobby-tips {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.6;
}

/* ── Minimized lobby (game in progress) ──────────────────── */
.lobby.minimized {
  flex: 0 0 auto;
  min-height: 0;
  grid-template-columns: 1fr;
}
.lobby.minimized .lobby-hero {
  flex-direction: row;
  align-items: center;
  padding: 10px 16px;
  gap: 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  min-height: 0;
  justify-content: flex-start;
}
.lobby.minimized .lobby-hero > *:not(.toggle-lobby) { display: none !important; }
.lobby.minimized .lobby-right { display: none; }

/* ── Lobby drawer — visible when "Show Lobby" is clicked mid-game ── */
.lobby.minimized.expanded {
  position: fixed;
  top: 0; left: 0;
  width: min(480px, 100vw);
  height: 100dvh;
  background: var(--cream);
  border-right: 1px solid var(--line);
  box-shadow: 6px 0 32px rgba(0,0,0,0.22);
  z-index: 300;
  overflow-y: auto;
  display: flex !important;
  flex-direction: column;
  grid-template-columns: unset !important;
}
/* Scrim behind the drawer */
.lobby.minimized.expanded::before {
  content: "";
  position: fixed;
  inset: 0;
  left: min(480px, 100vw);
  background: rgba(0,0,0,0.35);
  z-index: -1;
}
.lobby.minimized.expanded .lobby-hero {
  flex-direction: column !important;
  align-items: flex-start !important;
  padding: 16px !important;
  gap: 6px !important;
  background: var(--cream) !important;
  border-bottom: 1px solid var(--line) !important;
  min-height: unset !important;
  justify-content: flex-start !important;
}
.lobby.minimized.expanded .lobby-hero > * { display: flex !important; }
.lobby.minimized.expanded .toggle-lobby {
  order: -1;
  margin-bottom: 4px;
}
.lobby.minimized.expanded .lobby-right {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

/* QR / invite panel */
.server-address-group { display: grid; gap: 10px; }
.invite-panel { display: grid; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--cream); }
.invite-panel input { width: 100%; }
.invite-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-buttons button { flex: 1; }
.qr-panel { display: none; align-items: center; justify-items: center; gap: 8px; padding: 10px; border-radius: 12px; border: 1px dashed var(--line-2); background: var(--cream-2); text-align: center; }
.qr-panel.show { display: grid; }
.qr-code { width: 180px; height: 180px; display: grid; place-items: center; background: #fff; padding: 6px; border-radius: 10px; }
.qr-code img, .qr-code canvas { width: 100%; height: 100%; display: block; }
.qr-note { font-size: 12px; color: var(--ink-3); margin: 0; }

/* ════════════════════════════════════════════════════════════
   TABLE WRAP: play + side panel
   ════════════════════════════════════════════════════════════ */
.table-wrap {
  flex: 1;
  min-height: 0;
  display: none;           /* hidden in lobby; shown by phase selectors below */
  grid-template-columns: 1fr 280px;
  overflow: hidden;
}

/* Show the play area only when a game is active */
body[data-phase="bidding"]   .table-wrap,
body[data-phase="playing"]   .table-wrap,
body[data-phase="hand-over"] .table-wrap,
body[data-phase="game-over"] .table-wrap { display: grid; }

/* ── Play column ─────────────────────────────────────────── */
.play {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  /* Cream padding so the felt table floats — matches prototype */
  padding: 16px 20px 0;
  gap: 12px;
  background: var(--cream);
}

/* Status bar — rounded bordered box like prototype's .status-bar */
.status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.4;
  box-shadow: var(--sh-1, 0 1px 2px rgba(20,30,25,0.06), 0 2px 6px rgba(20,30,25,0.04));
}
.status:empty { display: none; }
/* Pulsing green dot before turn label — prototype's .turn-pip */
.status-main {
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-main::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent, #a8d846);
  box-shadow: 0 0 0 4px rgba(168,216,70,0.3);
  animation: turn-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes turn-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(168,216,70,0.35); }
  50%       { box-shadow: 0 0 0 7px rgba(168,216,70,0); }
}
.status-note { color: var(--accent-dk); font-weight: 600; }
/* Separator dot */
.status .sep { color: var(--line-2, #c8c1ab); }
/* Right-aligned hand/round info */
.status .round {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
/* Trick count chip */
.tricks-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--cream-2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.tricks-chip .trk {
  font-family: var(--f-mono);
  font-weight: 700;
  color: var(--ink);
}

/* ── Felt table area ─────────────────────────────────────── */
.table-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #14172a;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 1;
}

.table-surface {
  position: relative;
  width: min(100%, calc(var(--table-surface-size) * var(--table-scale)));
  aspect-ratio: 4/3;
  border-radius: 28px;
  /* Default: classic casino green felt */
  background: radial-gradient(ellipse at center, #2a6640 0%, #1c4a2c 55%, #0f2a18 100%);
  border: none;
  display: grid;
  place-items: center;
  padding: 20px;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.2),
    inset 0 8px 30px rgba(0,0,0,0.4),
    0 14px 40px rgba(0,0,0,0.45),
    0 4px 10px rgba(0,0,0,0.2);
  transition: width 180ms ease;
  overflow: hidden;
}

/* Subtle dashed inner ring */
.table-surface::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 18px;
  pointer-events: none;
  z-index: 1;
}

/* Top-left glow highlight */
.table-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.07) 0%, transparent 55%);
  pointer-events: none;
  z-index: 1;
}

/* ── Board colour themes ──────────────────────────────── */
body[data-board="navy"] .table-surface {
  background: radial-gradient(ellipse at center, #1a3a72 0%, #0f2250 55%, #070f2a 100%);
}
body[data-board="red"] .table-surface {
  background: radial-gradient(ellipse at center, #7a1f1f 0%, #561010 55%, #300808 100%);
}
body[data-board="purple"] .table-surface {
  background: radial-gradient(ellipse at center, #4a1870 0%, #300e50 55%, #180630 100%);
}
body[data-board="dark"] .table-surface {
  background-color: #1e2130;
  background-image:
    linear-gradient(30deg,  #272b3e 12%, transparent 12.5%, transparent 87%, #272b3e 87.5%, #272b3e),
    linear-gradient(150deg, #272b3e 12%, transparent 12.5%, transparent 87%, #272b3e 87.5%, #272b3e),
    linear-gradient(30deg,  #272b3e 12%, transparent 12.5%, transparent 87%, #272b3e 87.5%, #272b3e),
    linear-gradient(150deg, #272b3e 12%, transparent 12.5%, transparent 87%, #272b3e 87.5%, #272b3e),
    linear-gradient(60deg,  #13162a 25%, transparent 25.5%, transparent 75%, #13162a 75%, #13162a),
    linear-gradient(60deg,  #13162a 25%, transparent 25.5%, transparent 75%, #13162a 75%, #13162a);
  background-size: 48px 84px;
  background-position: 0 0, 0 0, 24px 42px, 24px 42px, 0 0, 24px 42px;
  border-radius: 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.3);
}
body[data-board="dark"] .table-surface::before { display: none; }

@keyframes table-sweep {
  0%   { transform: rotate(0deg); }
  50%  { transform: rotate(5deg); }
  100% { transform: rotate(0deg); }
}

/* Sparkle / fabric texture layer */
.sparkle-layer {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    135deg,
    rgba(255,255,255,0.018) 0,
    rgba(255,255,255,0.018) 2px,
    rgba(0,0,0,0.012) 2px,
    rgba(0,0,0,0.012) 4px
  );
  opacity: 0.7;
}

/* Deck (corner decoration) */
.deck {
  position: absolute;
  width: 38px;
  height: 54px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0f2218, #1f3f31);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 8px 16px rgba(0,0,0,0.45);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translate(120px, 90px);
  z-index: 2;
}
body[data-hide-deck="true"] .deck { display: none; }
.deck::before, .deck::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #0e1f16, #1c3b2d);
  border: 1px solid rgba(255,255,255,0.1);
}
.deck::before { transform: translate(-3px, -3px); opacity: 0.7; }
.deck::after  { transform: translate(-6px, -6px); opacity: 0.45; }

/* Deal animation layer */
.deal-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.deal-card {
  position: absolute;
  width: 30px;
  height: 44px;
  border-radius: 5px;
  background: linear-gradient(135deg, #1a3828, #2c5240);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 6px 12px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  animation: deal-to-seat var(--deal-duration, 320ms) ease-out forwards;
  animation-delay: var(--deal-delay, 0ms);
}
.deal-card::before {
  content: "♠";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: rgba(255,255,255,0.15);
}

@keyframes deal-to-seat {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  10%  { opacity: 1; }
  100% { opacity: 1; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.95); }
}

/* ── Seat panels ─────────────────────────────────────────── */
.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 5;
}

/* Active turn — glowing ring on the avatar */
.seat.active .avatar,
.seat[data-active="true"] .avatar {
  box-shadow:
    0 0 0 3px var(--accent, #a8d846),
    0 0 0 7px rgba(168,216,70,0.28),
    0 4px 12px rgba(0,0,0,0.28);
  transform: scale(1.06);
}

.seat-top    { top: 8px;    left: 50%; transform: translateX(-50%); }
.seat-right  { right: 8px;  top: 50%; transform: translateY(-50%); }
.seat-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.seat-left   { left: 8px;   top: 50%; transform: translateY(-50%); }

/* Avatar circle — matches prototype */
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 22px;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.26);
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}
.avatar.team-a { color: #1a5a8c; }
.avatar.team-b { color: #8c2e14; }

/* Seat badge (S1/S2/S3/S4) — bottom-right of avatar */
.seat-badge {
  position: absolute;
  bottom: -5px; right: -5px;
  background: var(--ink, #1c1914);
  color: var(--cream, #f7f4ec);
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 999px;
  border: 2px solid #1c4a2c; /* match felt */
  line-height: 1;
}
.seat.team-a .seat-badge { background: #1a5a8c; }
.seat.team-b .seat-badge { background: #8c2e14; }

/* Name pill on the felt */
.seat-name {
  color: rgba(240,235,220,0.92);
  font-size: 12px;
  font-weight: 600;
  background: rgba(0,0,0,0.28);
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat-name .bid {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent, #a8d846);
  font-weight: 700;
}

/* Legacy seat structure support (game.js may still use these) */
.seat-info    { display: grid; gap: 4px; width: 100%; text-align: center; }
.seat-name-input {
  width: 100%; background: transparent; border: none;
  border-bottom: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.9);
  font-size: 12px; padding: 2px 0; text-align: center;
}
.seat-status {
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  color: rgba(212,245,160,0.8);
}

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: bold; font-size: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  color: #0d1014; flex-shrink: 0;
}
.avatar-image img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-rose   { background: #f29ca3; }
.avatar-ocean  { background: #8fd3ff; }
.avatar-gold   { background: #f2d398; }
.avatar-forest { background: #9cd7b5; }
.avatar-slate  { background: #c2c8d0; }
.avatar-ember  { background: #f0a06a; }
.avatar-grape  { background: #c4a8f0; }
.avatar-teal   { background: #72d4c8; }

.avatar-picker, .avatar-upload {
  width: 100%; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(10,24,18,0.5); color: rgba(255,255,255,0.7);
  padding: 5px 8px; font-size: 11px;
}
.avatar-clear {
  width: 100%; padding: 5px 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,24,18,0.5); color: rgba(255,255,255,0.6);
  font-size: 11px; cursor: pointer;
}
.seat .avatar-picker, .seat .avatar-upload, .seat .avatar-clear { font-size: 10px; }

/* Fan (mini hand for opponents) */
.fan { display: flex; align-items: center; justify-content: center; gap: 0; margin-top: 6px; }
.fan-card {
  width: 14px; height: 22px; border-radius: 3px;
  background: linear-gradient(135deg, #1a3828, #2c5240);
  border: 1px solid rgba(255,255,255,0.12);
  margin-left: -7px;
  transform-origin: bottom center;
  transform: rotate(calc(var(--i) * 5deg - 12deg));
}
.fan-count { font-size: 11px; color: rgba(255,255,255,0.5); margin-left: 6px; }

/* ── Turn badge ──────────────────────────────────────────── */
.turn-badge {
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(10,20,14,0.94);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 10px 16px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  display: none; z-index: 4;
  min-width: 160px;
  backdrop-filter: blur(8px);
}
.turn-badge.show { display: block; }
.turn-label {
  display: block; font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: rgba(255,255,255,0.45);
  margin-bottom: 3px; font-weight: 600;
}
.turn-text { display: block; font-size: 13px; font-weight: 600; color: #fff; line-height: 1.3; }

/* Table notice */
.table-notice {
  background: rgba(10,20,14,0.88);
  border: 1px solid rgba(255,255,255,0.2);
  color: #d4f5a0;
  border-radius: 12px;
  padding: 18px 28px;
  font-size: 28px;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: none; text-align: center; max-width: 80%;
  opacity: 0; transition: opacity 0.6s ease;
}
.table-notice.show { display: block; opacity: 1; }

/* ── Trick pile ──────────────────────────────────────────── */
.trick {
  background: transparent; border-radius: 0; border: none; padding: 0;
  display: block; position: absolute; inset: 0;
  width: 100%; height: 100%; min-height: 0;
  z-index: 4; pointer-events: none;
}

.trick .card {
  position: absolute;
  width: 78px; height: 112px; min-width: 78px;
  padding: 5px 6px;
}
.trick .card .card-rank   { font-size: 13px; }
.trick .card .card-center-pip { font-size: 22px; }

.trick .card.seat-0 { left: 50%; top: 50%; margin-left: -39px; margin-top: 18px;   z-index: 2; }
.trick .card.seat-2 { left: 50%; top: 50%; margin-left: -39px; margin-top: -130px; z-index: 2; }
.trick .card.seat-1 { left: 50%; top: 50%; margin-left: -140px; margin-top: -56px; z-index: 1; }
.trick .card.seat-3 { left: 50%; top: 50%; margin-left: 62px;   margin-top: -56px; z-index: 1; }

/* ── Bidding overlay ─────────────────────────────────────── */
.bidding {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  background: rgba(24,28,46,0.97);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 18px;
  z-index: 8;
  backdrop-filter: blur(12px);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3), 0 20px 40px rgba(0,0,0,0.4);
  max-height: 60%;
  overflow-y: auto;
  color: rgba(240,235,220,0.95);
}
.bidding:empty { display: none; }
.bid-panel h3 { margin-top: 0; color: var(--ink); font-family: var(--f-display); }
.bid-buttons {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  margin-top: 12px;
}
.bid-buttons button {
  padding: 10px 6px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.07); color: rgba(240,235,220,0.9);
  font-size: 14px; font-weight: 600;
  transition: border-color 0.12s, background 0.12s;
}
.bid-buttons button:hover   { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.18); color: #fff; }
.bid-buttons button.selected { background: rgba(255,255,255,0.9); color: #111; border-color: #fff; }
.bid-buttons button:disabled { opacity: 0.35; cursor: not-allowed; filter: grayscale(0.4); }

/* ── Hand dock ───────────────────────────────────────────── */
.hand-dock {
  flex-shrink: 0;   /* always visible — never squeezed by .table-area */
  background: #0e1020;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 12px 16px 16px;
  position: relative;
  z-index: 2;
  min-height: 130px;
}

.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.hand-header h3 {
  margin: 0;
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 500;
  color: rgba(220,215,200,0.7);
}
#hand-controls {
  font-size: 12px;
  color: rgba(220,215,200,0.4);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Hand cards row (fan style) */
.hand {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;   /* always centred, even as cards are played */
  gap: 0;
  overflow-x: auto;
  padding-top: 28px;         /* extra room for fan arc top */
  padding-bottom: 12px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
  align-items: flex-end;     /* fan arc aligns to a common base-line */
}
.hand .card {
  width: calc(var(--card-w) * var(--table-scale));
  height: calc(var(--card-h) * var(--table-scale));
  min-width: calc(var(--card-w) * var(--table-scale));
  padding: calc(4px * var(--table-scale)) calc(5px * var(--table-scale));
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  margin-left: calc(-16px * var(--table-scale));
  position: relative;
  flex-shrink: 0;
  /* Fan rotation set per-card by JS via --fan-angle */
  transform: rotate(var(--fan-angle, 0deg));
  transform-origin: 50% 130%;   /* pivot just below card bottom for arc */
  opacity: 1;
}
.hand .card .card-rank       { font-size: calc(12px * var(--table-scale)); }
.hand .card .card-pip-sm     { font-size: calc(9px * var(--table-scale)); }
.hand .card .card-center-pip { font-size: calc(20px * var(--table-scale)); }
.hand .card:first-child { margin-left: 0; }
.hand .card:hover, .hand .card:focus-within {
  /* Keep the fan angle, then lift and scale */
  transform: rotate(var(--fan-angle, 0deg)) translateY(-18px) scale(1.08);
  transform-origin: 50% 130%;
  z-index: 20;
  opacity: 1;
  box-shadow: 0 18px 36px rgba(0,0,0,0.35);
}

/* Hand locked overlay */
.hand-locked {
  position: absolute;
  inset: 0;
  background: rgba(253,252,249,0.9);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
  border-radius: 4px;
}
.hand-locked.visible { display: flex; }
#reveal-hand {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--cream);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#reveal-hand:hover { background: var(--ink-2); }

/* ════════════════════════════════════════════════════════════
   SIDE PANEL
   ════════════════════════════════════════════════════════════ */
.side {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--paper);
  overflow: hidden;
}

.side-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--cream-2);
  flex-shrink: 0;
}
.side-tab {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--f-ui);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.side-tab:hover { color: var(--ink); }
.side-tab[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
  background: var(--paper);
}
/* Count badge inside tab label */
.side-tab .count {
  font-family: var(--f-mono);
  font-size: 10px;
  background: var(--cream-2);
  color: var(--ink-2);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.side-tab[aria-pressed="true"] .count {
  background: var(--accent, #a8d846);
  color: var(--accent-dk, #4a7016);
}

.side-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-pane {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side-pane[hidden] { display: none; }

/* ── Teams pane ─────────────────────────────────────────── */
.team {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.team h3 {
  margin: 0 0 6px;
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 500;
}
.team p { margin: 3px 0; font-size: 12.5px; color: var(--ink-2); }
.team strong { color: var(--ink); font-weight: 600; }
.team input[type="text"] {
  width: 100%; margin: 4px 0 8px;
  padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper); color: var(--ink);
  font-size: 13px;
}

/* ── Chat pane ──────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 8px; }
.chat h3 { margin: 0 0 4px; font-size: 13px; font-family: var(--f-display); }
.chat-messages {
  max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px;
}
.chat-message {
  padding: 6px 9px;
  background: var(--cream);
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.emote-row {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.emote-btn {
  padding: 4px 8px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--cream-2); color: var(--ink);
  font-size: 11px; cursor: pointer;
}
.emote-btn:hover { background: var(--line); }
.chat-input { display: flex; gap: 6px; }
.chat-input input {
  flex: 1; padding: 7px 10px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--cream); color: var(--ink);
  font-size: 13px;
}
.chat-input input:focus { outline: none; border-color: var(--line-2); }
#chat-send {
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--ink); color: var(--cream);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
#chat-send:hover { background: var(--ink-2); }

/* ── Books pane (score-history + history) ── */
.score-history {
  background: transparent;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
  overflow-x: auto;
}
.score-history:empty { display: none; }
.score-history-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 8px;
}
.score-history-header h3 {
  margin: 0; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3);
  font-family: var(--f-mono);
}
.score-history-clear {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-3); cursor: pointer;
}
.score-history-clear:hover { border-color: var(--line-2); color: var(--ink); }
.score-history-table {
  width: 100%; border-collapse: collapse; font-size: 12px; min-width: 240px;
}
.score-history-table th {
  text-align: left; padding: 4px 6px; color: var(--ink-3);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
  font-family: var(--f-mono);
}
.score-history-table td {
  padding: 5px 6px; border-bottom: 1px solid rgba(0,0,0,0.05); vertical-align: middle;
}
.score-history-table tr:last-child td { border-bottom: none; }
.score-history-table tr:hover td { background: var(--cream); }
.sh-hand   { color: var(--ink-3); font-size: 11px; font-weight: 600; width: 30px; }
.sh-score  { font-weight: 600; font-size: 13px; color: var(--ink); }
.sh-delta  { font-size: 11px; font-weight: 700; min-width: 40px; text-align: right; padding-right: 10px; }
.sh-delta.pos  { color: #2e8b4c; }
.sh-delta.neg  { color: #c0392b; }
.sh-delta.zero { color: var(--ink-3); }
.sh-detail { font-size: 10px; color: var(--ink-3); white-space: nowrap; }
.sh-detail.sh-made { color: #2e8b4c; }
.sh-detail.sh-over { color: #e67e22; }
.sh-detail.sh-set  { color: #c0392b; }
.sh-penalty { display: block; font-size: 9px; color: #c0392b; font-weight: 700; white-space: nowrap; margin-top: 2px; }

/* History (book-by-book replay) */
.history {
  background: transparent;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
}
.history h3 { margin-top: 0; font-size: 13px; font-family: var(--f-display); }
.history h4 { margin: 8px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-family: var(--f-mono); }
.history-empty { margin: 4px 0 0; font-size: 12px; color: var(--ink-3); }
.history-section { margin-bottom: 14px; }

.book-timeline { display: flex; flex-wrap: wrap; gap: 5px; }
.timeline-item {
  padding: 3px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--cream);
  font-size: 11px; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 5px;
}
.timeline-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--cream-2); border: 1px solid var(--line); font-size: 11px;
}
.timeline-icon.suit-spades   { color: var(--spade); }
.timeline-icon.suit-hearts   { color: var(--heart); }
.timeline-icon.suit-diamonds { color: var(--diamond); }
.timeline-icon.suit-clubs    { color: var(--club); }
.timeline-icon.suit-joker    { color: var(--joker); }

.timeline-item.team-a { border-color: rgba(91,163,216,0.5); color: #1a5a8c; }
.timeline-item.team-b { border-color: rgba(232,112,78,0.5); color: #8c2e14; }

.play-log { display: grid; gap: 5px; font-size: 11px; color: var(--ink-3); }
.play-log-item {
  padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--cream);
}
.history button {
  margin: 6px 0; background: var(--cream-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 12px;
}
.history-list { display: grid; gap: 6px; }
.history-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; background: var(--cream); cursor: pointer; font-size: 12px;
}
.history-item.active { border-color: var(--ink); }
.history-cards { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.history-cards .card { min-width: 60px; }

/* ── Settings in lobby ──────────────────────────────────── */
/* Settings live in the lobby-right now; always visible regardless of game.js */
#settings,
#settings.hidden { display: grid !important; }

/* Lobby settings wrapper */
.lobby-settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

/* Lobby settings section header */
.lobby-settings-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Lock banner — shown when game is active */
.settings-lock-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
}
.settings-lock-banner .lock-icon { font-size: 14px; flex-shrink: 0; }

/* Show lock banner and disable settings during active game phases */
body[data-phase="bidding"] .settings-lock-banner,
body[data-phase="playing"] .settings-lock-banner,
body[data-phase="hand-over"] .settings-lock-banner { display: flex; }

body[data-phase="bidding"] #settings,
body[data-phase="playing"] #settings,
body[data-phase="hand-over"] #settings {
  pointer-events: none;
  opacity: 0.52;
  user-select: none;
}

/* Settings pane in side panel: just a note */
/* ── In-game Settings pane ────────────────────────────── */
.side-settings-wrap {
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.side-settings-heading {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.side-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}
.side-setting label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  flex: 1;
}
.side-setting select {
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--cream-2);
  color: var(--ink);
  flex-shrink: 0;
  max-width: 150px;
}
.side-settings-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2px 0;
}
.side-open-lobby-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--cream-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s;
}
.side-open-lobby-btn:hover { background: var(--line); }

.settings {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr;
}
.settings-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.settings-group summary {
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--cream-2);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  min-height: 40px;
}
.settings-group summary::-webkit-details-marker { display: none; }
.chev {
  font-size: 14px;
  color: var(--ink-3);
  transition: transform 0.2s ease;
  margin-left: auto;
}
.settings-group[open] .chev { transform: rotate(90deg); }
.count-pill {
  font-family: var(--f-mono);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-3);
  margin-left: 6px;
}
.settings-group-content {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  padding: 10px;
  background: var(--paper);
}
body[data-mode="network"] .settings-group.computer-only { display: none; }

.setting label {
  display: flex; gap: 8px; align-items: center;
  font-size: 13px; line-height: 1.3; color: var(--ink-2);
}
.setting label.stacked { display: grid; align-items: start; gap: 5px; }
.setting select {
  width: 100%; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--cream);
  color: var(--ink); font-size: 13px; min-height: 34px;
}
.setting select:focus { outline: none; border-color: var(--line-2); }
.setting input[type="range"] { width: 100%; accent-color: var(--ink); }
.setting input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--ink); flex-shrink: 0; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input[type="range"] { width: 100%; }
.range-row span { min-width: 40px; text-align: right; font-size: 11px; color: var(--ink-3); font-family: var(--f-mono); }

/* ════════════════════════════════════════════════════════════
   CARDS (preserved from v1, adapted for light background)
   ════════════════════════════════════════════════════════════ */
.card {
  background: #ffffff;
  color: #111111;
  border-radius: 7px;
  border: 1px solid #d0ccc0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  padding: 4px 5px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
  transform: rotate(var(--card-rotation, 0deg));
  cursor: default;
}

.card.heart   { color: var(--heart); }
.card.diamond { color: var(--diamond); }
.card.club    { color: var(--club); }
.card.spade   { color: var(--spade); }
.card.joker   { color: var(--joker); background: #fff8ff; }

.card-tl {
  display: flex; flex-direction: column;
  align-items: flex-start; line-height: 1.05; gap: 0;
}
.card-br {
  display: flex; flex-direction: column;
  align-items: flex-end; line-height: 1.05; gap: 0;
  transform: rotate(180deg); align-self: flex-end;
}
.card-rank { font-size: 14px; font-weight: 900; display: block; letter-spacing: -0.04em; line-height: 1; font-family: var(--f-display); }
.card-pip-sm { font-size: 11px; display: block; line-height: 1.1; }
.card-center-pip { font-size: 26px; text-align: center; flex: 1; display: flex; align-items: center; justify-content: center; line-height: 1; pointer-events: none; }

/* Ace — oversized centre suit */
.card-pip-ace { font-size: 40px !important; }

/* ── Pip grid for number cards 2–10 ─────────────────── */
.card-pip-grid {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.card-pip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 10px;
  line-height: 1;
  display: block;
  pointer-events: none;
  user-select: none;
}
.card-pip.card-pip-r {
  transform: translate(-50%, -50%) rotate(180deg);
}
/* Scale pip size for trick + hand contexts */
.trick .card .card-pip         { font-size: 13px; }
.hand  .card .card-pip         { font-size: calc(9px * var(--table-scale)); }

/* ── Face cards (J / Q / K) ─────────────────────────── */
.card-pip-face {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; overflow: hidden;
}
.card-face-top, .card-face-bot {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
}
.card-face-bot {
  transform: rotate(180deg);
  border-top: 1px solid currentColor;
  opacity: 0.9;
}
/* Subtle tint per face type */
.card-pip-face-j .card-face-top,
.card-pip-face-j .card-face-bot { background: rgba(180,210,255,0.18); }
.card-pip-face-q .card-face-top,
.card-pip-face-q .card-face-bot { background: rgba(255,180,200,0.18); }
.card-pip-face-k .card-face-top,
.card-pip-face-k .card-face-bot { background: rgba(255,230,160,0.18); }

.card-face-letter {
  font-size: 20px; font-weight: 900; line-height: 1;
  font-family: var(--f-display);
}
.card-face-suit { font-size: 12px; line-height: 1.1; }

/* Scale face letter for different card sizes */
.trick .card .card-face-letter { font-size: 24px; }
.hand  .card .card-face-letter { font-size: calc(18px * var(--table-scale)); }
.hand  .card .card-face-suit   { font-size: calc(10px * var(--table-scale)); }

/* Joker centre */
.card-pip-joker { font-size: 32px !important; }
.card-rank-joker { font-size: 10px !important; letter-spacing: 0 !important; }

.card-owner {
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  font-size: 7px; font-weight: 600; color: rgba(0,0,0,0.2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 90%; line-height: 1; letter-spacing: 0.02em; pointer-events: none;
}
.card-label { font-size: 18px; font-weight: 600; letter-spacing: 0.02em; }

/* Card back — classic blue lattice */
.card.hidden {
  background-color: #1a55b8;
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.07) 0, rgba(255,255,255,0.07) 2px, transparent 2px, transparent 9px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.07) 0, rgba(255,255,255,0.07) 2px, transparent 2px, transparent 9px);
  border: 1px solid rgba(255,255,255,0.15);
  color: transparent;
}
/* Inset border on card back */
.card.hidden::before {
  content: "";
  position: absolute; inset: 5px;
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  pointer-events: none;
  z-index: 1;
}
/* Remove old spade watermark */
.card.hidden::after { display: none; }

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

/* Deck / back styles — data-deck overrides */
body[data-deck="classic"] .card {
  background: #fffef8;
  border-color: rgba(60,40,20,0.3);
}
body[data-deck="classic"] .card.heart,
body[data-deck="classic"] .card.diamond { color: #cc0000; }
body[data-deck="classic"] .card.club,
body[data-deck="classic"] .card.spade   { color: #111111; }

body[data-deck="modern"] .card {
  background: #f8f9fb;
  border-color: rgba(180,190,210,0.5);
}
body[data-deck="modern"] .card.heart,
body[data-deck="modern"] .card.diamond { color: #d10000; }
body[data-deck="modern"] .card.club,
body[data-deck="modern"] .card.spade   { color: #111111; }

/* ── Card animations ─────────────────────────────────────── */
@keyframes played-pop {
  0%   { opacity: 0; transform: translateY(8px) scale(0.9); }
  70%  { opacity: 1; transform: translateY(-2px) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes played-bounce {
  0%   { opacity: 0; transform: translateY(12px) scale(0.9); }
  60%  { opacity: 1; transform: translateY(-6px) scale(1.03); }
  80%  { transform: translateY(2px) scale(0.99); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes played-shake {
  0%   { opacity: 0; transform: translateX(0) scale(0.95); }
  25%  { opacity: 1; transform: translateX(-6px) scale(1); }
  50%  { transform: translateX(6px) scale(1); }
  75%  { transform: translateX(-3px) scale(1); }
  100% { transform: translateX(0) scale(1); }
}
@keyframes played-sweep {
  0%   { opacity: 0; transform: translateX(24px) translateY(8px) scale(0.92); }
  100% { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}
@keyframes from-bottom {
  from { opacity: 0.2; transform: translateY(30px) scale(0.95) rotate(var(--card-rotation, 0deg)); }
  to   { opacity: 1; transform: translateY(0) scale(1) rotate(var(--card-rotation, 0deg)); }
}
@keyframes from-top {
  from { opacity: 0.2; transform: translateY(-30px) scale(0.95) rotate(var(--card-rotation, 0deg)); }
  to   { opacity: 1; transform: translateY(0) scale(1) rotate(var(--card-rotation, 0deg)); }
}
@keyframes from-left {
  from { opacity: 0.2; transform: translateX(-30px) scale(0.95) rotate(var(--card-rotation, 0deg)); }
  to   { opacity: 1; transform: translateX(0) scale(1) rotate(var(--card-rotation, 0deg)); }
}
@keyframes from-right {
  from { opacity: 0.2; transform: translateX(30px) scale(0.95) rotate(var(--card-rotation, 0deg)); }
  to   { opacity: 1; transform: translateX(0) scale(1) rotate(var(--card-rotation, 0deg)); }
}
@keyframes deal {
  from { opacity: 0; transform: translateY(10px) scale(0.97) rotate(var(--card-rotation, 0deg)); }
  to   { opacity: 1; transform: translateY(0) scale(1) rotate(var(--card-rotation, 0deg)); }
}

.played-pop    { animation: played-pop    0.45s ease both; }
.played-bounce { animation: played-bounce 0.5s  ease both; }
.played-shake  { animation: played-shake  0.45s ease both; }
.played-sweep  { animation: played-sweep  0.4s  ease both; }

.card.live.seat-0 { animation: from-bottom 0.3s ease both; }
.card.live.seat-1 { animation: from-left   0.3s ease both; }
.card.live.seat-2 { animation: from-top    0.3s ease both; }
.card.live.seat-3 { animation: from-right  0.3s ease both; }
.card.replay      { animation: deal 0.35s ease both; }

/* ════════════════════════════════════════════════════════════
   WINNER OVERLAY
   ════════════════════════════════════════════════════════════ */
.winner-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28,25,20,0.7);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease; z-index: 70;
}
.winner-overlay.show { opacity: 1; pointer-events: auto; }

.winner-card {
  position: relative; z-index: 2;
  background: var(--paper);
  border-radius: 22px;
  border: 1px solid var(--line);
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  min-width: min(480px, 90vw);
  animation: winner-pop 0.6s ease;
}
.winner-kicker {
  text-transform: uppercase; letter-spacing: 0.2em;
  font-size: 11px; font-family: var(--f-mono);
  color: var(--ink-3); margin: 0 0 10px;
}
.winner-card h2 {
  margin: 0 0 14px;
  font-size: clamp(32px, 6vw, 60px);
  color: var(--ink);
  font-family: var(--f-display);
}
.winner-card p { margin: 8px 0 20px; font-size: 15px; color: var(--ink-2); }
.winner-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.winner-btns button, .winner-card button {
  padding: 10px 20px; border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--cream-2); color: var(--ink);
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.winner-btns button:first-child { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.winner-btns button:hover { opacity: 0.85; }
#winner-scorecard { font-size: 13px; }

.winner-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.winner-confetti span {
  position: absolute; width: 10px; height: 18px;
  left: var(--x); top: -20px; background: var(--c);
  opacity: 0.9; transform: rotate(var(--r));
  animation: confetti-fall 2.6s linear infinite;
  animation-delay: var(--d); border-radius: 2px;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(var(--r)); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(calc(var(--r) + 180deg)); opacity: 0; }
}
@keyframes winner-pop {
  0%   { transform: scale(0.88); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0;
  background: rgba(28,25,20,0.5);
  display: none; align-items: center; justify-content: center;
  padding: 24px; z-index: 60;
}
.modal.open { display: flex; }
.modal-content {
  width: min(900px, 95vw); max-height: 90vh; overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 20px;
  box-shadow: 0 24px 50px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.modal-header h2 { margin: 0; font-family: var(--f-display); }
#rules-close, #scorecard-close {
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--cream-2);
  color: var(--ink); cursor: pointer; font-size: 13px;
}

/* ── Feature 5: Scorecard modal ──────────────────────────── */
.scorecard-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  color: var(--ink-2);
}
.scorecard-table th {
  padding: 6px 10px; border-bottom: 2px solid var(--line);
  text-align: center; font-weight: 600; color: var(--ink);
  font-size: 12px; white-space: nowrap;
}
.scorecard-table td {
  padding: 5px 10px; border-bottom: 1px solid var(--line);
  text-align: center; white-space: nowrap;
}
.scorecard-table tr:last-child td { border-bottom: none; font-weight: 600; }
.scorecard-table .sc-pos { color: #4caf50; }
.scorecard-table .sc-neg { color: #e53935; }
.scorecard-table .sc-penalty { color: #e53935; font-size: 11px; }
.sc-team-header { font-size: 13px; font-weight: 700; color: var(--ink); margin: 14px 0 6px; }
.sc-player-row { display: flex; justify-content: space-between; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.sc-player-row:last-child { border-bottom: none; }
.sc-player-name { font-weight: 600; }
.sc-bid-hit { color: #4caf50; }
.sc-bid-miss { color: #e53935; }

/* ── Feature 4: Mobile two-tap card selection ─────────────── */
.hand .card.selected {
  transform: rotate(var(--fan-angle, 0deg)) translateY(-26px) scale(1.1) !important;
  transform-origin: 50% 130%;
  z-index: 25 !important;
  opacity: 1 !important;
  box-shadow: 0 0 0 2px #a8d846, 0 22px 40px rgba(0,0,0,0.45) !important;
}

/* ── Feature 2: Trick sweep animation ────────────────────── */
.trick.sweeping .card {
  pointer-events: none;
}

/* ── Feature 10: AI coaching hint bar ────────────────────── */
.coaching-hint {
  margin: 4px 12px 2px;
  padding: 6px 12px;
  background: rgba(168,216,70,0.1);
  border: 1px solid rgba(168,216,70,0.3);
  border-radius: 8px;
  font-size: 12px;
  color: rgba(240,235,220,0.8);
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.coaching-hint[hidden] { display: none; }
.ch-label { color: rgba(168,216,70,0.75); font-weight: 600; white-space: nowrap; }
.ch-card  { font-weight: 700; color: #a8d846; font-family: var(--f-mono); }
.ch-reason { color: rgba(255,255,255,0.45); font-style: italic; }

/* ── Feature 6: Spectator all-hands view ─────────────────── */
.spectator-hands {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 12px;
}
.spectator-hands[hidden] { display: none; }
.spec-seat-panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
}
.spec-seat-label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em;
}
.spec-hand-cards {
  display: flex; flex-wrap: wrap; gap: 2px;
}
.spec-hand-cards .card {
  width: calc(var(--card-w, 48px) * 0.55 * var(--table-scale, 1));
  font-size: 10px;
  cursor: default !important;
  opacity: 1 !important;
  transform: none !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
  pointer-events: none;
}

/* ── Feature 8: SVG face cards ───────────────────────────── */
.card-face-svg {
  flex: 1;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}
.card-face-svg svg {
  width: 100%;
  height: 100%;
}

.rulebook { line-height: 1.6; font-size: 14px; color: var(--ink-2); }
.rulebook h2 { margin-top: 0; font-family: var(--f-display); }
.rulebook .howto { color: var(--ink-3); }

/* ════════════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--cream);
  border-radius: 10px; padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80; font-size: 13px; font-weight: 500;
  white-space: nowrap; max-width: calc(100vw - 48px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ════════════════════════════════════════════════════════════
   MISC / UTILITY
   ════════════════════════════════════════════════════════════ */
.spectators { display: none; } /* hidden in new design */
.players { display: none; }

/* Preserve legacy .trick-winner appearance */
.trick-winner {
  background: rgba(10,20,14,0.88); border: 1px solid rgba(255,255,255,0.2);
  color: #d4f5a0; border-radius: 10px; padding: 18px 28px; font-size: 32px;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3;
}

/* History drawer (legacy, no longer used in new layout) */
.history-drawer { display: none; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════════════ */

/* ── Laptop / narrow (≤ 1200px) ─────────────────────────── */
@media (max-width: 1200px) {
  .table-wrap { grid-template-columns: 1fr 260px; }
  :root { --table-surface-size: 900px; --table-area-min: 600px; }
}

/* ── Tablet (≤ 960px) ───────────────────────────────────── */
@media (max-width: 960px) {
  :root { --table-surface-size: 760px; --table-area-min: 500px; }

  .table-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .side {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: 360px;
  }
  .side-body { max-height: 300px; }

  /* Stack lobby hero + right on tablet */
  .lobby {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .lobby-hero {
    padding: 36px 32px 32px;
  }
  .lobby-deco { width: 180px; height: 180px; bottom: 50px; right: 0; }
  .lobby-right { border-left: none; border-top: 1px solid var(--line); }
}

/* ── Mobile (≤ 720px) ───────────────────────────────────── */
@media (max-width: 720px) {
  :root { --table-surface-size: 620px; --table-area-min: 420px; }

  .topbar { padding: 0 12px; gap: 6px; }
  .brand span:not(.mark) { display: none; } /* hide text, keep spade icon */

  .lobby-hero { padding: 28px 20px 24px; }
  .lobby-hero h1 { font-size: 28px; }
  .lobby-deco { display: none; } /* too cramped */
  .lobby-right { padding: 28px 20px; }
  .lobby-team-names { grid-template-columns: 1fr; } /* stack on small screens */
  .ai-diff-grid { grid-template-columns: repeat(3, 1fr); }
  .ai-diff-btn { padding: 8px 4px; }
  .diff-desc { display: none; } /* too small to read */

  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
  select, textarea { font-size: 16px; } /* iOS zoom prevention */

  button, .settings-group summary { min-height: 44px; }
  .lobby-input { padding: 10px 12px; min-height: 44px; }

  .hand-dock { padding: 10px 12px 14px; }
  .settings-group-content { grid-template-columns: 1fr; }
  .seat { width: 130px; font-size: 11px; padding: 5px 6px; }

  /* Hand summary full-width on mobile */
  .hand-summary-card { border-radius: 14px; }
  .hs-scores { gap: 8px; }
  .hs-chip-delta { font-size: 22px; }
}

/* ── Small phone (≤ 480px) ──────────────────────────────── */
@media (max-width: 480px) {
  :root { --table-surface-size: 480px; --table-area-min: 360px; }

  .topbar { height: 46px; }
  .score-strip { display: none !important; } /* too cramped on tiny screens */
  .topbar-actions .tb-btn { padding: 4px 8px; font-size: 11px; }

  .seat { width: 110px; font-size: 10px; padding: 4px 5px; }

  .lobby-hero { padding: 20px 16px; }
  .lobby-hero h1 { font-size: 24px; }
  .lobby-right { padding: 20px 16px; }

  .hand .card { margin-left: calc(-22px * var(--table-scale)); }
}

/* ── iPhone SE / tiny (≤ 390px) ────────────────────────── */
@media (max-width: 390px) {
  :root { --table-surface-size: 420px; --table-area-min: 310px; }
  .seat { width: 96px; font-size: 10px; }
  .lobby-hero { padding: 16px 14px; }
  .lobby-right { padding: 16px 14px; }
}

/* ════════════════════════════════════════════════════════════
   FIX – SCORE STRIP LEGIBILITY
   ════════════════════════════════════════════════════════════ */
.score-strip {
  display: none;
  gap: 6px;
  align-items: center;
}
.score-strip.show { display: flex; }

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 6px;
  background: rgba(255,255,255,0.09);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  white-space: nowrap;
}
.score-divider {
  display: flex;
  align-items: center;
  padding: 0 2px;
}
.score-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-a { background: var(--team-a, #1a5a8c); }
.dot-b { background: var(--team-b, #8c2e14); }
.score-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  letter-spacing: 0.01em;
}
.score-number {
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 700;
  color: #fdfcf9;
  letter-spacing: -0.03em;
  line-height: 1;
}
.score-bid {
  font-size: 11px;
  color: rgba(255,255,255,0.48);
  font-weight: 500;
}
.score-bags {
  font-size: 10px;
  color: #f0a06a;
  font-weight: 600;
}
.score-phase-label {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.04em;
}
/* Keep old classes working */
.score-meta { font-size: 10px; color: rgba(255,255,255,0.32); }
.score-team { display: none; } /* replaced by .score-dot + .score-name */

/* ════════════════════════════════════════════════════════════
   FEATURE 2 – BOOKS NEEDED TRACKER
   ════════════════════════════════════════════════════════════ */
.seat-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}
.seat-books {
  font-family: var(--f-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.02em;
  transition: color 0.25s;
}
.seat-books.made {
  color: #a8d846;
  font-weight: 700;
}
.seat-cards {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
}
/* Progress pip row under bid display */
.seat-pip-row {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: 2px;
}
.seat-pip {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  transition: background 0.2s;
}
.seat-pip.won { background: #a8d846; }
.seat-pip.needed { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2); }

/* ════════════════════════════════════════════════════════════
   FEATURE 4 – TEAM NAMES IN LOBBY
   ════════════════════════════════════════════════════════════ */
.lobby-team-names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.team-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 4px;
}
.team-swatch-a { background: var(--team-a, #1a5a8c); }
.team-swatch-b { background: var(--team-b, #8c2e14); }

/* ════════════════════════════════════════════════════════════
   FEATURE 7 – AI DIFFICULTY BUTTONS
   ════════════════════════════════════════════════════════════ */
.ai-diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ai-diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  color: var(--ink);
}
.ai-diff-btn:hover {
  border-color: var(--accent-dk);
  background: var(--cream-2);
}
.ai-diff-btn[aria-pressed="true"] {
  border-color: var(--accent-dk);
  background: color-mix(in srgb, var(--accent-dk) 10%, var(--paper));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-dk) 18%, transparent);
}
.diff-icon { font-size: 18px; line-height: 1; }
.diff-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  display: block;
}
.diff-desc {
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.3;
  display: block;
}

/* ════════════════════════════════════════════════════════════
   FEATURE 1 – HAND SUMMARY OVERLAY
   ════════════════════════════════════════════════════════════ */
.hand-summary {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,15,12,0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.hand-summary.show {
  opacity: 1;
  pointer-events: all;
}
.hand-summary-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(10,20,15,0.22), 0 2px 6px rgba(10,20,15,0.10);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.25s;
}
.hand-summary.show .hand-summary-card {
  transform: translateY(0) scale(1);
}
.hand-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.hand-summary-title {
  font-family: var(--f-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.hand-summary-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--cream-2);
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.hand-summary-close:hover { background: var(--line); }
.hand-summary-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
/* Score chips row */
.hs-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.hs-score-chip {
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
  border: 1.5px solid transparent;
}
.hs-score-chip.hs-a {
  background: color-mix(in srgb, var(--team-a, #1a5a8c) 12%, var(--cream-2));
  border-color: color-mix(in srgb, var(--team-a, #1a5a8c) 30%, transparent);
}
.hs-score-chip.hs-b {
  background: color-mix(in srgb, var(--team-b, #8c2e14) 12%, var(--cream-2));
  border-color: color-mix(in srgb, var(--team-b, #8c2e14) 30%, transparent);
}
.hs-chip-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.hs-chip-delta {
  font-family: var(--f-mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.hs-chip-delta.pos { color: #4a9e4f; }
.hs-chip-delta.neg { color: #c0392b; }
.hs-chip-total {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}
/* Player result table */
.hs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.hs-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.hs-table td {
  padding: 8px 8px;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.hs-table tr:last-child td { border-bottom: none; }
.hs-team-tag {
  display: inline-block;
  font-size: 10px;
  color: var(--ink-3);
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  font-weight: 500;
}
.hs-made { color: #4a9e4f; font-weight: 600; }
.hs-set  { color: #c0392b; font-weight: 600; }
/* Footer */
.hand-summary-footer {
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}
.hand-summary-next {
  padding: 8px 20px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.hand-summary-next:hover { opacity: 0.85; }

/* ════════════════════════════════════════════════════════════
   FEATURE 3 – CARD ANIMATION IMPROVEMENTS
   ════════════════════════════════════════════════════════════ */
/* Trick winner banner */
.trick-winner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 28px;
  border-radius: 14px;
  background: rgba(10,20,15,0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  animation: tw-pop 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
  pointer-events: none;
  min-width: 140px;
  text-align: center;
}
@keyframes tw-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.tw-name {
  color: #fdfcf9;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}
.tw-team {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.trick-winner.team-a .tw-name { color: #8fd3ff; }
.trick-winner.team-b .tw-name { color: #f29ca3; }

/* Cards sweep out gently when paused */
.trick.trick-paused .card {
  animation: card-dim 0.25s ease forwards;
}
@keyframes card-dim {
  from { filter: brightness(1); }
  to   { filter: brightness(0.65) saturate(0.7); }
}

/* ════════════════════════════════════════════════════════════
   FEATURE 5 – PER-PLAYER STATS (Books pane)
   ════════════════════════════════════════════════════════════ */
.player-stats-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.player-stats-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.player-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.player-stats-table th {
  text-align: left;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.player-stats-table td {
  padding: 6px 6px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.player-stats-table tr:last-child td { border-bottom: none; }
.ps-pct  { color: var(--ink-3); font-size: 10px; }
.ps-neg  { color: #c0392b; }

/* ════════════════════════════════════════════════════════════
   FIX – SCORE ON BOARD DURING HAND-OVER
   ════════════════════════════════════════════════════════════ */
.hand-over-board {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 18px 22px 16px;
  background: rgba(8,18,12,0.92);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  min-width: 300px;
  max-width: min(460px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
}
.hand-over-board.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: all;
}
/* Board header */
.hob-header {
  font-family: var(--f-display);
  font-size: 15px;
  font-weight: 600;
  color: rgba(255,255,255,0.65);
  text-align: center;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 10px;
  margin-bottom: 2px;
}
.hob-scores {
  display: flex;
  align-items: center;
  gap: 18px;
}
.hob-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.hob-team-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  margin-bottom: 2px;
}
.hob-a .hob-team-dot { background: #8fd3ff; }
.hob-b .hob-team-dot { background: #f29ca3; }
.hob-team-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.55);
}
.hob-score {
  font-family: var(--f-display);
  font-size: 40px;
  font-weight: 700;
  color: #fdfcf9;
  letter-spacing: -0.04em;
  line-height: 1;
}
.hob-delta {
  font-family: var(--f-mono);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.hob-pos  { color: #a8d846; }
.hob-neg  { color: #e87070; }
.hob-zero { color: rgba(255,255,255,0.35); }
.hob-sep {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 4px;
}
.hob-next-btn {
  padding: 9px 24px;
  border-radius: 10px;
  background: #a8d846;
  border: none;
  color: #0e1f0c;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.hob-next-btn:hover  { filter: brightness(1.08); }
.hob-next-btn:active { transform: scale(0.98); }
.hob-next-btn { align-self: center; margin-top: 4px; }

/* Clickable / editable team name on board */
.hob-name-editable {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.22);
  transition: border-color 0.15s, color 0.15s;
}
.hob-name-editable:hover { color: #fff; border-color: rgba(255,255,255,0.5); }
.hob-name-input {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 5px;
  width: 90px;
  outline: none;
}
.hob-name-input:focus { border-color: #a8d846; }

/* Player table inside board */
.hob-table-wrap {
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 8px 0;
}
.hob-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.hob-table th {
  text-align: left;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}
.hob-table td {
  padding: 6px 6px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.hob-table tr:last-child td { border-bottom: none; }
.hob-pname { color: rgba(255,255,255,0.9); font-weight: 500; margin-right: 6px; }
.hob-ptag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
}
.hob-tag-a { background: rgba(143,211,255,0.15); color: #8fd3ff; }
.hob-tag-b { background: rgba(242,156,163,0.15); color: #f29ca3; }
.hob-bid   { color: rgba(255,255,255,0.55); text-align: center; }
.hob-res   { color: rgba(255,255,255,0.75); }
.hob-made  { color: #a8d846; font-weight: 600; }
.hob-set   { color: #e87070; font-weight: 600; }

/* ════════════════════════════════════════════════════════════
   FIX – LOBBY AVATAR PICKER
   ════════════════════════════════════════════════════════════ */
.lobby-avatar-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.lap-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.lap-swatch:hover { transform: scale(1.15); }
.lap-swatch[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 18%, transparent);
  transform: scale(1.1);
}
.lap-rose   { background: #f29ca3; }
.lap-ocean  { background: #8fd3ff; }
.lap-gold   { background: #f2d398; }
.lap-forest { background: #9cd7b5; }
.lap-slate  { background: #c2c8d0; }
.lap-ember  { background: #f0a06a; }
.lap-grape  { background: #c4a8f0; }
.lap-teal   { background: #72d4c8; }

/* Upload-photo swatch */
.lap-upload {
  background: rgba(255,255,255,0.08);
  border: 2px dashed rgba(255,255,255,0.28) !important;
  color: rgba(255,255,255,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.lap-upload:hover {
  background: rgba(168,216,70,0.15);
  border-color: #a8d846 !important;
  color: #a8d846;
}
.lap-upload[aria-pressed="true"] {
  background: rgba(168,216,70,0.2);
  border-color: #a8d846 !important;
  box-shadow: 0 0 0 2px #a8d846;
  color: #a8d846;
}

/* ════════════════════════════════════════════════════════════
   FIX – DEAL BUTTON PROMINENCE IN LOBBY
   ════════════════════════════════════════════════════════════ */
.lobby-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding: 12px 0 8px;
  margin: 0 -4px;
  z-index: 2;
}
/* Primary start buttons get bigger and bolder */
.lobby-btn-primary {
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 12px;
  background: var(--accent-dk, #3d7a2e);
  color: #fdfcf9;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: 0 3px 10px rgba(61,122,46,0.35), 0 1px 3px rgba(61,122,46,0.2);
}
.lobby-btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 5px 16px rgba(61,122,46,0.4);
}
.lobby-btn-primary:active { transform: scale(0.98); }
.lobby-btn-primary:disabled { opacity: 0.42; cursor: not-allowed; filter: none; box-shadow: none; }

/* ════════════════════════════════════════════════════════════
   FIX – HAND CARDS DARKER
   ════════════════════════════════════════════════════════════ */
/* Slightly darker base card (less blinding on the cream background) */
.card {
  background: #f0ead8;
  border-color: #b8b09a;
}
/* Hand cards get a gentle shadow-darkening for felt contrast */
.hand .card {
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.22));
}

/* ════════════════════════════════════════════════════════════
   FEATURE 6 – MOBILE LAYOUT IMPROVEMENTS
   ════════════════════════════════════════════════════════════ */
/* Improved tablet breakpoint */
@media (max-width: 860px) {
  .lobby { grid-template-columns: 1fr; }
  .lobby-hero { min-height: auto; }
  .lobby-right { border-left: none; border-top: 1px solid var(--line); }
  .lobby-team-names { grid-template-columns: 1fr 1fr; }
  .ai-diff-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ════════════════════════════════════════════════════════════
   AVATAR PICKER – EMOJI ICONS + UPLOAD AREA
   ════════════════════════════════════════════════════════════ */

/* Small label above each picker row */
.lap-row-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin: 0 0 5px;
}

/* Emoji / icon swatches — dark navy background so emojis always pop */
.lap-icon {
  background: #2c3554;
  border: 2px solid rgba(0,0,0,0.15) !important;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.lap-icon:hover {
  background: #38437a;
  border-color: rgba(0,0,0,0.25) !important;
  transform: scale(1.15);
}
.lap-icon[aria-pressed="true"] {
  background: #2c3554;
  border-color: #3d7a2e !important;
  box-shadow: 0 0 0 3px rgba(61,122,46,0.35);
  transform: scale(1.1);
}

/* In-game emoji-icon avatar background */
[class*="avatar-ico-"] { background: #1b2234; }

/* Upload photo area */
.lap-upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
/* Upload button: always visible — solid neutral style that turns green when active */
.lap-upload-main {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  /* solid border + subtle shadow makes it visible on any background */
  background: #2c3554;
  border: 1.5px solid rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.14);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.lap-upload-main:hover,
.lap-upload-main.drag-over {
  background: #38437a;
  border-color: #5a7ad8;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.lap-upload-main[aria-pressed="true"] {
  background: rgba(61,122,46,0.85);
  border-color: #3d7a2e;
  border-style: solid;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(61,122,46,0.3);
}

/* ════════════════════════════════════════════════════════════
   IN-GAME AVATAR EDIT
   ════════════════════════════════════════════════════════════ */
/* Avatar rendered as a clickable button during play */
button.avatar-editable {
  position: relative;
  cursor: pointer;
  border: none;
  padding: 0;
  background: none;
  display: block;
}
button.avatar-editable:hover .avatar-edit-hint { opacity: 1; }
.avatar-edit-hint {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(30,40,30,0.85);
  color: rgba(255,255,255,0.8);
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.2);
}

/* Avatar popup (in-game picker) */
.avatar-popup {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.avatar-popup.open {
  opacity: 1;
  pointer-events: all;
}
.avp-inner {
  background: var(--paper, #1c2820);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 18px 20px 20px;
  width: min(340px, 92vw);
  box-shadow: 0 16px 50px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.avp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.avp-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink, #fdfcf9);
}
.avp-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}
.avp-close:hover { color: #fff; }
.avp-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* CTA disclaimer line below Start & Deal buttons */
.cta-disclaimer {
  font-size: 11px;
  color: var(--ink-3, rgba(255,255,255,0.38));
  margin: -2px 0 0;
  text-align: center;
  line-height: 1.4;
}

/* ════════════════════════════════════════════════════════════
   HAND – DRAG TO REORDER CARDS
   ════════════════════════════════════════════════════════════ */
.hand .card[draggable="true"] { cursor: grab; }
.hand .card[draggable="true"]:active { cursor: grabbing; }
.hand .card.hand-drag-src { opacity: 0.35; }
.hand .card.hand-drag-over {
  transform: translateY(-10px) scale(1.04);
  box-shadow: 0 6px 18px rgba(168,216,70,0.35);
  border-color: #a8d846;
  z-index: 5;
}

/* ── Safe area insets (iPhone notch / home bar) ─────────── */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
  }
  .hand-dock {
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }
  .toast {
    bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
}

/* ════════════════════════════════════════════════════════════
   FEATURE 2 — EMOJI FLOAT LAYER
   ════════════════════════════════════════════════════════════ */
#emoji-float-layer {
  position: fixed;
  bottom: 80px;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 9999;
}
.emoji-float {
  position: absolute;
  font-size: 2.2rem;
  animation: floatUp 2s ease-out forwards;
  user-select: none;
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(-120px) scale(1.3); opacity: 0; }
}

/* ════════════════════════════════════════════════════════════
   FEATURE 4 — PLAYER STATS PANE
   ════════════════════════════════════════════════════════════ */
.stats-content { padding: 10px; }
.stats-empty { color: var(--ink-3); font-size: 13px; padding: 16px 0; text-align: center; }
.stat-block { background: rgba(255,255,255,.06); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.stat-name { font-weight: 700; font-size: 13px; color: rgba(255,255,255,.95); margin-bottom: 6px; }
.stat-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); padding: 2px 0; }
.stat-row span:last-child { color: rgba(255,255,255,.9); font-variant-numeric: tabular-nums; }

/* ════════════════════════════════════════════════════════════
   FEATURE 6 — KEYBOARD SHORTCUTS MODAL
   ════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8000;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface, #1c1914);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 24px;
  max-width: 92vw;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.modal-title { font-size: 16px; font-family: var(--f-display); margin: 0 0 4px; color: #fff; }
.modal-close-btn {
  margin-top: 16px;
  padding: 7px 18px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  font-size: 13px;
}
.modal-close-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.shortcuts-box { max-width: 420px; }
.shortcuts-table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.shortcuts-table td { padding: 6px 8px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.07); color: rgba(255,255,255,.75); }
.shortcuts-table td:first-child { white-space: nowrap; color: rgba(255,255,255,.95); }
kbd {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.35);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--f-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  line-height: 1.6;
}

/* ════════════════════════════════════════════════════════════
   FEATURE 7 — SCORE STRIP HELP BUTTON
   ════════════════════════════════════════════════════════════ */
.score-strip-help {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  color: var(--ink-2);
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.score-strip-help:hover { background: rgba(255,255,255,.25); }

/* ════════════════════════════════════════════════════════════
   FEATURE 8 — HAND REPLAY BUTTONS
   ════════════════════════════════════════════════════════════ */
.history-replay-btn {
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px;
  color: var(--ink-2);
  cursor: pointer;
  margin-left: 8px;
}
.history-replay-btn:hover { background: rgba(255,255,255,.2); }
.history-replay-label { font-size: 12px; color: var(--ink-3); padding: 6px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.history-replay-label button { font-size: 12px; padding: 1px 6px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 3px; color: var(--ink-2); cursor: pointer; }

/* ════════════════════════════════════════════════════════════
   FEATURE 9 — EXPORT GAME LOG BUTTON
   ════════════════════════════════════════════════════════════ */
.export-btn {
  font-size: 12px;
  padding: 5px 12px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
}
.export-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ════════════════════════════════════════════════════════════
   FEATURE 10 — LANDSCAPE LAYOUT
   ════════════════════════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 520px) {
  .table-wrap {
    flex-direction: row;
    align-items: flex-start;
    height: 100vh;
    overflow: hidden;
  }
  .play-col {
    flex: 1 1 auto;
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .side {
    width: 200px;
    min-width: 160px;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
  }
  .table-surface {
    min-height: 200px;
  }
  .hand { min-height: 70px; }
  .score-strip { font-size: 10px; }
  .bidding-panel { padding: 6px; }
}
