* { box-sizing: border-box; }
:root {
  --bg: #0f2e1d;
  --felt: #14472c;
  --edge: #1e5c3a;
  --card-bg: #fafafa;
  --card-edge: #444;
  --text: #f4f4f4;
  --muted: #9db6a8;
  --gold: #e5c158;
  --red: #d43f3f;
  --blue: #3f8cd4;
  --green: #3fbf6d;
}
html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9em; }
.status { min-height: 1em; color: var(--gold); margin-top: 0.5rem; }

/* ---------- Lobby ---------- */
.lobby {
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.lobby h1 { font-size: 2.2rem; margin: 0 0 0.2rem; }
.lobby .sub { color: var(--muted); margin-bottom: 1.5rem; }
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.feedback-btn {
  background: var(--felt);
  border: 1px solid var(--edge);
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
}
.feedback-btn:hover { background: var(--edge); color: var(--text); }
.lobby .card p { line-height: 1.45; margin: 0 0 0.8rem; }
.lobby .card p:last-child { margin-bottom: 0; }
.lobby .card ul, .lobby .card ol { margin: 0 0 0.6rem 1.2rem; padding: 0; line-height: 1.5; }
.lobby .card ul li, .lobby .card ol li { margin-bottom: 0.3rem; }

.rules-link {
  display: inline-block;
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  padding: 0.45rem 0;
}
.rules-link:hover { text-decoration: underline; }

.rules-page .rank-row {
  background: rgba(0,0,0,0.25);
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}
.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.rules-table th, .rules-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: top;
}
.rules-table th { color: var(--gold); font-weight: 600; }
.rules-table td:first-child { white-space: nowrap; font-weight: 600; }
.rules-table tr:last-child td { border-bottom: none; }
@media (max-width: 600px) {
  .rules-table { font-size: 0.85rem; }
  .rules-table th, .rules-table td { padding: 0.35rem 0.35rem; }
}
.card {
  background: var(--felt);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.card h2 { margin: 0 0 0.8rem; font-size: 1.1rem; }
.card label {
  display: block;
  margin-bottom: 0.7rem;
  font-size: 0.95rem;
}
.card input, .card select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid var(--edge);
  background: #0b2315;
  color: var(--text);
}
button {
  cursor: pointer;
  font-size: 1rem;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--edge);
  background: #245e3d;
  color: var(--text);
}
button.primary { background: var(--gold); color: #222; border-color: #b38d2a; font-weight: 600; }
button.secondary { background: #1e5c3a; }
button.danger { background: #7a2323; color: #fff; border-color: #a23d3d; font-weight: 600; }
button.danger:hover { background: #8f2b2b; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Name prompt overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 1rem;
}
.overlay .card { width: 100%; max-width: 360px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  background: #0a2315;
  border-bottom: 1px solid var(--edge);
  gap: 0.6rem;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.topbar .share { display: flex; gap: 0.5rem; align-items: center; }
.home-btn {
  background: #1e5c3a;
  color: var(--text);
  border: 1px solid var(--edge);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}
.home-btn:hover { background: #245e3d; }

/* ---------- Game layout ---------- */
.game-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 52px);
}
.top-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  min-height: 400px;
}
/* Tablet / narrow desktop: tighten side-by-side layout. */
@media (max-width: 900px) and (min-width: 601px) {
  .top-row { grid-template-columns: 1fr 200px; gap: 0.5rem; min-height: 320px; }
  .game-root { padding: 0.5rem; gap: 0.5rem; }
  .table-area { padding: 0.6rem; gap: 0.5rem; }
  .hand-row { padding: 0.6rem; }
  .log-box { padding: 0.5rem; }
  .log-box h3 { font-size: 0.85rem; }
  #log { font-size: 0.72rem; min-height: 120px; max-height: 220px; }
  .chat-form input { font-size: 0.8rem; padding: 0.35rem 0.45rem; }
  .chat-form button { padding: 0.35rem 0.55rem; font-size: 0.8rem; }
  .seats { gap: 0.3rem; }
  .seat { padding: 0.25rem 0.35rem; font-size: 0.72rem; }
  .seat .name { font-size: 0.75rem; }
  .seat .role { font-size: 0.6rem; }
  .seat .count { font-size: 0.65rem; }
  .seat .dollars { font-size: 0.78rem; }
  .turn-arrow { top: -7px; font-size: 0.8rem; }
  .card-face { width: 44px; height: 64px; font-size: 0.75rem; }
  .card-face .corner-rank { font-size: 0.55rem; }
  .card-face .corner-suit { font-size: 0.45rem; }
  .card-face .suit-big { font-size: 1rem; }
  .card-face .pip { font-size: 0.4rem; }
  .card-face .card-pips { top: 13px; bottom: 13px; left: 10px; right: 10px; }
  .card-back { width: 44px; height: 62px; }
  .card-mini { width: 30px; height: 44px; font-size: 0.65rem; }
  .pot-row { font-size: 0.8rem; flex-wrap: wrap; gap: 0.5rem; }
  .topbar { padding: 0.5rem 0.7rem; font-size: 0.9rem; }
  .share button { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
}

/* Phone-size: vertical stack — seats + table (squeezed), then YOUR HAND
   (prominent, wrapping in multiple rows, no scroll), then log at bottom.
   display:contents flattens .top-row so we can reorder its children under
   .game-root with flex `order`. */
@media (max-width: 600px) {
  body { overflow-x: hidden; }
  .game-root {
    padding: 0.35rem;
    gap: 0.35rem;
    display: flex;
    flex-direction: column;
  }
  .topbar { padding: 0.4rem 0.55rem; font-size: 0.85rem; gap: 0.4rem; }
  .topbar strong { font-size: 0.9rem; }
  .home-btn { padding: 0.3rem 0.55rem; font-size: 0.78rem; }
  .share button { padding: 0.3rem 0.55rem; font-size: 0.75rem; }
  #copy-status { display: none; }

  .top-row   { display: contents; }

  /* Squeeze the table area — minimal vertical real estate. */
  .table-area {
    order: 1;
    padding: 0.4rem;
    gap: 0.35rem;
    border-radius: 10px;
  }
  .play-area { min-height: 80px; gap: 0.4rem; }
  .middle-cards, .trick-area { min-height: 56px; }
  .pot-row { font-size: 0.75rem; gap: 0.5rem; flex-wrap: wrap; }
  .pot { font-size: 0.9rem; }

  .seats { gap: 0.25rem; }
  .seat {
    padding: 0.25rem 0.3rem;
    font-size: 0.68rem;
    line-height: 1.1;
    min-width: 0;
    border-radius: 6px;
  }
  .seat .name { font-size: 0.72rem; gap: 0.2rem; }
  .seat .role { font-size: 0.58rem; }
  .seat .count { font-size: 0.62rem; }
  .seat .dollars { font-size: 0.75rem; }
  .turn-arrow { top: -7px; font-size: 0.75rem; }
  .conn-dot { width: 6px; height: 6px; }

  /* HAND — raised high in the flow, cards wrap in multiple rows. */
  .hand-row {
    order: 2;
    padding: 0.5rem 0.4rem;
    border-radius: 10px;
  }
  .hand-header { margin-bottom: 0.35rem; gap: 0.5rem; }
  .hand-header h3 { font-size: 0.85rem; }
  .combo-preview { font-size: 0.78rem; }
  .hand-row .hand {
    min-height: 60px;
    max-height: none;
    flex-wrap: wrap;            /* multi-row instead of horizontal scroll */
    overflow: visible;
    justify-content: center;
    gap: 3px;
    padding: 0.15rem 0;
    row-gap: 6px;
  }

  /* Action bar sits between hand and log so it's reachable with thumb. */
  .action-bar { order: 3; gap: 0.4rem; }
  .action-bar button { padding: 0.45rem 0.8rem; font-size: 0.9rem; }

  /* Log last, compact. */
  .log-area { order: 4; }
  .log-box { padding: 0.5rem; border-radius: 10px; }
  .log-box h3 { font-size: 0.8rem; margin-bottom: 0.3rem; }
  #log { font-size: 0.7rem; min-height: 80px; max-height: 160px; }
  .chat-form input { font-size: 0.78rem; padding: 0.35rem 0.5rem; }
  .chat-form button { padding: 0.35rem 0.55rem; font-size: 0.78rem; }

  /* Cards on phone — small enough for 17 in ~3 rows. */
  .card-face {
    width: 40px;
    height: 58px;
    font-size: 0.7rem;
    border-radius: 5px;
  }
  .card-face .corner-rank { font-size: 0.5rem; }
  .card-face .corner-suit { font-size: 0.4rem; }
  .card-face .suit-big { font-size: 0.95rem; }
  .card-face .pip { font-size: 0.38rem; }
  .card-face .card-pips { top: 11px; bottom: 11px; left: 8px; right: 8px; }
  .card-face.selected { transform: translateY(-6px); }
  .card-back { width: 38px; height: 54px; border-radius: 5px; }
  .card-mini { width: 30px; height: 44px; font-size: 0.65rem; }
  .reveal-cards .card-face { width: 52px; height: 74px; font-size: 0.85rem; }
  .reveal-cards .card-face .suit-big { font-size: 1.3rem; }

  /* On phone, let cards fill the full row so they wrap naturally. */
  .hand-row .hand { max-width: 100%; }
}

/* Very narrow (<360px): one more squeeze so 17-card hand still shows 4 rows. */
@media (max-width: 360px) {
  .card-face, .card-back { width: 36px; height: 52px; font-size: 0.65rem; }
  .card-face .corner-rank { font-size: 0.45rem; }
  .card-face .corner-suit { font-size: 0.35rem; }
  .card-face .suit-big { font-size: 0.8rem; }
  .card-face .pip { font-size: 0.3rem; }
  .card-face .card-pips { top: 9px; bottom: 9px; left: 6px; right: 6px; }
  .seat { font-size: 0.62rem; }
  .seat .name { font-size: 0.66rem; }
  .seat .dollars { font-size: 0.7rem; }
}

.table-area {
  background: radial-gradient(ellipse at center, #1a5a38 0%, #0d3b24 70%);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.play-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
}
.log-area { display: flex; flex-direction: column; }
.hand-row {
  background: var(--felt);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 0.8rem 1rem;
}
/* Desktop-only: sticky hand so the cards + action buttons are always in
   view even if the table area fills the screen. Mobile already reorders
   via flex `order` (see the phone media query below) — sticky there would
   obscure the seats/trick. */
@media (min-width: 721px) {
  .hand-row {
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.35);
  }
}
.hand-row .action-bar {
  margin-top: 0.6rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 0.6rem;
}
.hand-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.hand-header h3 { margin: 0; }
.hand-row .hand {
  min-height: 170px;
  max-height: none;
  overflow: visible;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  row-gap: 8px;
  padding: 0.4rem 0.2rem;
  max-width: 720px;      /* 17 cards → 2 rows; 21 landlord cards → 2 rows. */
  margin: 0 auto;
}

/* Seats row */
.seats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.seat {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  text-align: center;
  position: relative;
  font-size: 0.85rem;
  line-height: 1.25;
}
.seat.current { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.seat.me { background: rgba(63,140,212,0.22); }
.seat .name {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.seat .role { font-size: 0.7rem; color: var(--muted); }
.seat .role.landlord { color: var(--gold); font-weight: 600; }
.seat .role.host { color: var(--blue); font-weight: 600; }
.seat .role.bot { color: #c084fc; font-weight: 600; }
.seat .count { font-size: 0.75rem; color: var(--muted); }
.seat .dollars { color: var(--gold); font-weight: 600; font-size: 0.9rem; }
.seat.disconnected { opacity: 0.55; }

/* Connection dot */
.conn-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conn-dot.online {
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
  animation: pulse-green 1.6s ease-out infinite;
}
.conn-dot.offline {
  background: #6b7280;
}
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,0.7); }
  70%  { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* "thinking..." label under a bot seat while MCTS is deciding.
   Uses a CSS content animation on ::after to cycle dots without JS timers. */
.thinking {
  color: var(--gold);
  font-size: 0.78rem;
  font-style: italic;
  margin-top: 0.15rem;
  min-height: 1em;
}
.thinking::after {
  content: '';
  display: inline-block;
  width: 1.3em;
  text-align: left;
  animation: thinking-dots 1.5s steps(4, end) infinite;
}
@keyframes thinking-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Turn indicator */
.turn-arrow {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  font-size: 1rem;
  animation: bob 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-3px); }
}

/* Full-screen "your turn" flash */
.turn-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  border: 0 solid rgba(229, 193, 88, 0.9);
  box-shadow: inset 0 0 140px 30px rgba(229, 193, 88, 0.55);
  animation: turn-flash-anim 1.1s ease-out forwards;
}
@keyframes turn-flash-anim {
  0%   { opacity: 0; transform: scale(1.02); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}
.turn-flash .banner {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, 0);
  background: var(--gold);
  color: #222;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
  animation: banner-pop 1.1s ease-out forwards;
}
@keyframes banner-pop {
  0%   { transform: translate(-50%, -20px); opacity: 0; }
  25%  { transform: translate(-50%, 0);     opacity: 1; }
  75%  { transform: translate(-50%, 0);     opacity: 1; }
  100% { transform: translate(-50%, -12px); opacity: 0; }
}

/* Middle / trick area */
.middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.priority-draw {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.priority-draw .chip {
  background: rgba(0,0,0,0.3);
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.middle-cards, .trick-area, .landlord-took {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}
.middle-cards, .trick-area { min-height: 60px; }
/* Trick area cards are compact — the history strip below already shows the
   current lead with card details, so the trick area itself just needs to
   give a "something is on the table" cue, not dominate the screen. */
.trick-area .card-face {
  width: 48px;
  height: 68px;
  font-size: 0.78rem;
  border-radius: 5px;
}
.trick-area .card-face .corner-rank { font-size: 0.55rem; }
.trick-area .card-face .corner-suit { font-size: 0.45rem; }
.trick-area .card-face .suit-big { font-size: 1.1rem; }
.trick-area .card-face .pip { font-size: 0.4rem; }
.trick-area .card-face .card-pips { top: 13px; bottom: 13px; left: 10px; right: 10px; }
.landlord-took {
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.landlord-took .card-row,
.trick-area .card-row {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}
.trick-area > .muted { width: 100%; text-align: center; }
.landlord-took > .muted { width: 100%; text-align: center; color: var(--gold); }

/* Drag-and-drop states (SortableJS) */
.card-drag-ghost { opacity: 0.35; }
.card-drag-chosen { transform: translateY(-6px) scale(1.04); box-shadow: 0 4px 12px rgba(0,0,0,0.5); }

/* Reveal modal: larger card row */
.reveal-cards {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.8rem 0 1rem;
}
.reveal-cards .card-face {
  width: 64px;
  height: 92px;
  font-size: 1rem;
}
.reveal-cards .card-face .suit-big { font-size: 1.6rem; }
.pot-row {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}
.pot { color: var(--gold); font-weight: 700; font-size: 1.1rem; }

/* Settlement panel (room closed) */
.settlements {
  width: 100%;
  max-width: 520px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 0.6rem;
}
.settlements h3 { margin: 0 0 0.6rem; color: var(--gold); }
.settlements ul { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.settlements .balances li { display: flex; justify-content: space-between; padding: 0.25rem 0; border-bottom: 1px dashed rgba(255,255,255,0.08); }
.settlements .balances li.win { color: var(--green); }
.settlements .balances li.loss { color: var(--red); }
.settlements .balances li.even { color: var(--muted); }
.settlements .payments li { padding: 0.3rem 0; }
.settlements .payments strong { color: var(--gold); }

/* Landlord banner */
.landlord-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(229, 193, 88, 0.12);
  border: 1px solid var(--gold);
  border-radius: 10px;
  font-size: 0.92rem;
  text-align: center;
  color: var(--text);
}
.landlord-banner strong { color: var(--gold); font-weight: 700; }
.landlord-banner .crown { font-size: 1.3rem; line-height: 1; }
.landlord-banner.me {
  background: linear-gradient(90deg, rgba(229, 193, 88, 0.22), rgba(229, 193, 88, 0.12));
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold) inset;
}
.landlord-banner.me strong { color: #fff8d6; }
@media (max-width: 720px) {
  .landlord-banner { font-size: 0.88rem; padding: 0.5rem 0.7rem; }
  .landlord-banner .crown { font-size: 1.05rem; }
}

/* Play history strip (below trick area) */
.history-strip {
  display: none !important;
}
/* Inline one-row layout: both recent plays sit side-by-side to keep the
   hand above the fold on desktop. Title is hidden by default — icons/labels
   convey the meaning inline. */
.history-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 1rem;
  max-width: 720px;
}
.history-strip .history-title {
  display: none;  /* redundant; each row has its own inline label */
}
.history-strip .history-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  min-height: 30px;
}
.history-strip .history-row.pass { opacity: 0.75; }
.history-strip .history-col-label { font-size: 0.8rem; }
.history-strip .history-label { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.history-strip .history-label.me { color: var(--blue); }
.history-strip .history-current {
  background: var(--gold);
  color: #222;
  padding: 1px 0.3rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.history-strip .history-cards {
  display: inline-flex;
  gap: 2px;
}
.history-strip .history-pass {
  color: var(--muted);
  font-style: italic;
  font-size: 0.8rem;
}
/* Small clean cards — tall enough to read the top rank+suit. */
.history-strip .history-card {
  width: 34px;
  height: 50px;
  font-size: 0.7rem;
  padding: 2px 3px;
  border-radius: 4px;
}
.history-strip .history-card .suit-big { font-size: 0.88rem; }
.history-strip .history-card .bottom { display: none; }  /* Skip rotated dup */
/* Dim the older (non-current) row */
.history-strip .history-row:not(:first-child) .card-face {
  opacity: 0.6;
  filter: saturate(0.7);
}

/* Final hands (revealed at round_over) */
.final-hands {
  width: 100%;
  max-width: 620px;
  margin: 0.5rem auto 0;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}
.final-hands-title {
  font-size: 0.78rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.final-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.final-row:last-child { border-bottom: none; }
.final-name {
  min-width: 150px;
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.final-role {
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  padding: 0 0.35rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.final-role.landlord { color: var(--gold); background: rgba(229, 193, 88, 0.12); }
.final-count { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.final-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}
.final-card {
  width: 40px;
  height: 56px;
  font-size: 0.7rem;
  padding: 2px 3px;
  border-radius: 5px;
  cursor: default !important;
}
.final-card .suit-big { font-size: 0.95rem; }
.final-card .bottom { font-size: 0.6rem; }
.final-empty { color: var(--gold); font-style: italic; font-size: 0.82rem; }
.final-row.landlord .final-name { color: var(--gold); }
.final-row.me .final-name { color: var(--blue); }
@media (max-width: 720px) {
  .final-hands { padding: 0.5rem 0.6rem; }
  .final-name { min-width: 120px; font-size: 0.8rem; }
  .final-card { width: 34px; height: 48px; font-size: 0.62rem; }
  .final-card .suit-big { font-size: 0.85rem; }
}

/* Round summary (MCTS review of a human's moves, shown at round_over) */
.round-summary {
  width: 100%;
  max-width: 620px;
  margin: 0.6rem auto 0;
}
#round-summary-toggle {
  background: rgba(63, 140, 212, 0.18);
  color: var(--text);
  border: 1px solid rgba(63, 140, 212, 0.6);
  font-weight: 600;
  padding: 0.5rem 0.9rem;
}
#round-summary-toggle:hover { background: rgba(63, 140, 212, 0.3); }
#round-summary-body {
  margin-top: 0.5rem;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}
.summary-title {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.summary-row {
  margin-bottom: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--edge);
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.summary-row.best { border-left-color: var(--green); }
.summary-row.worst { border-left-color: var(--red); }
.summary-row .summary-label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}
.summary-row.best .summary-label { color: var(--green); }
.summary-row.worst .summary-label { color: var(--red); }
.summary-row .summary-detail { font-size: 0.92rem; line-height: 1.4; }
.summary-row .muted { font-size: 0.82rem; }
.summary-cards {
  display: flex;
  gap: 4px;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.summary-cards-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 0.5rem;
}
.summary-subhead {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.summary-card {
  width: 42px !important;
  height: 60px !important;
  font-size: 0.72rem !important;
  cursor: default !important;
}
.summary-card .suit-big { font-size: 0.95rem !important; }
.summary-card .bottom { display: none !important; }
.summary-footer { margin-top: 0.5rem; font-size: 0.78rem; }

/* Action bar */
.action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Topbar end-game slot — small, compact danger button. */
.topbar-end-slot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.topbar-end-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 6px;
  font-weight: 600;
}
.topbar-end-btn:disabled { opacity: 0.7; }
.end-game-note { font-size: 0.78rem; }

@media (max-width: 720px) {
  .topbar-end-btn {
    padding: 0.28rem 0.55rem;
    font-size: 0.78rem;
  }
  .end-game-note { display: none; }   /* Name list hidden on small screens to save room. */
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
}
.log-box {
  background: var(--felt);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.log-box h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.hand-box h3 { margin: 0; font-size: 0.95rem; }

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.2rem;
}
.combo-preview {
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  min-height: 1em;
}
.combo-preview.valid { color: var(--green); }
.combo-preview.invalid { color: var(--red); }

/* Slug join inputs (3-word) */
.slug-inputs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0 0.7rem;
}
.slug-inputs input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.55rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid var(--edge);
  background: #0b2315;
  color: var(--text);
  text-align: center;
}
.slug-inputs .slug-dash {
  color: var(--muted);
  font-size: 1.1rem;
  user-select: none;
}

/* Bot difficulty radio group */
fieldset.difficulty {
  border: 1px dashed var(--edge);
  border-radius: 8px;
  padding: 0.5rem 0.8rem 0.6rem;
  margin: 0.4rem 0 0.9rem;
}
fieldset.difficulty legend {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0 0.4rem;
}
fieldset.difficulty label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0;
  font-size: 0.9rem;
  cursor: pointer;
}
fieldset.difficulty input[type="radio"] {
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--gold);
}
fieldset.difficulty .muted { font-size: 0.82rem; }

/* Beginner checkbox (lobby/create/join forms) */
.card label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin: 0.3rem 0 0.7rem;
  color: var(--muted);
  cursor: pointer;
}
.card label.checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--gold);
}

/* Tips panel (beginner mode) */
.tips-panel {
  background: linear-gradient(135deg, rgba(63, 191, 109, 0.12), rgba(63, 191, 109, 0.04));
  border: 1px solid rgba(63, 191, 109, 0.45);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.6rem;
  color: #e8ffe8;
  font-size: 0.92rem;
  line-height: 1.4;
}
.tips-panel .tips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.tips-panel .tips-header strong { color: var(--green); font-size: 0.92rem; }
.tips-panel .tips-auto {
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
  background: var(--green);
  color: #062613;
  border-color: #2f9e5a;
  font-weight: 600;
}
.tips-panel .tips-auto:hover { background: #5cd48a; }
.tips-list {
  list-style: disc inside;
  margin: 0;
  padding: 0;
}
.tips-list li { padding: 0.12rem 0; }

/* Mobile: tips panel appears above the action bar naturally via source order,
   but the action bar is flex-ordered on phones — so also raise tips there. */
@media (max-width: 720px) {
  .tips-panel {
    font-size: 0.88rem;
    padding: 0.55rem 0.7rem;
  }
}
@media (max-width: 600px) {
  .hand-row { order: 2; }
  /* Put tips right under the hand; action bar is order:3 so tips naturally
     land between hand and action buttons because tips-panel is inside hand-row. */
}

/* ---------- Cards ---------- */
.card-face {
  width: 56px;
  height: 80px;
  background: var(--card-bg);
  color: #222;
  border: 1px solid var(--card-edge);
  border-radius: 7px;
  padding: 0;
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  user-select: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  overflow: hidden;
}
.card-face:hover { transform: translateY(-3px); }
.card-face.selected { transform: translateY(-10px); box-shadow: 0 0 0 2px var(--gold); }
.card-face.red { color: #d32f2f; }
.card-face.black { color: #1a1a1a; }
.card-face.joker-bw { background: linear-gradient(135deg, #fff 50%, #999 50%); }
.card-face.joker-color { background: linear-gradient(135deg, #ffd447 0%, #ff7aa2 50%, #72c8ff 100%); color: #222; }
.card-face.wild { background: repeating-linear-gradient(45deg, #c47aff, #c47aff 8px, #ffd447 8px, #ffd447 16px); color: #222; }

/* Corner labels — top-left and bottom-right, like real cards */
.card-face .corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 0;
}
.card-face .corner.tl { top: 2px; left: 3px; }
.card-face .corner.br { bottom: 2px; right: 3px; transform: rotate(180deg); }
.card-face .corner-rank { font-size: 0.65rem; font-weight: 700; display: block; line-height: 1.1; }
.card-face .corner-suit { font-size: 0.55rem; display: block; line-height: 1; }

/* Center area for face cards / jokers */
.card-face .card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-face .suit-big { font-size: 1.4rem; line-height: 1; }

/* Pip layout for number cards */
.card-face .card-pips {
  position: absolute;
  top: 16px; bottom: 16px;
  left: 14px; right: 14px;
}
.card-face .pip {
  position: absolute;
  font-size: 0.5rem;
  line-height: 1;
  transform: translateY(-50%);
}
.card-face .pip-left { left: 0; }
.card-face .pip-center { left: 50%; transform: translate(-50%, -50%); }
.card-face .pip-right { right: 0; }
.card-face .pip-flip { transform: translateY(-50%) rotate(180deg); }
.card-face .pip-center.pip-flip { transform: translate(-50%, -50%) rotate(180deg); }

/* Legacy .bottom class — no longer used but keep for compat */
.card-face .bottom { display: none; }

.card-back {
  width: 52px;
  height: 74px;
  background: repeating-linear-gradient(45deg, #1e5c3a, #1e5c3a 8px, #245e3d 8px, #245e3d 16px);
  border: 1px solid #0b2315;
  border-radius: 6px;
}
.card-mini {
  width: 38px;
  height: 54px;
  font-size: 0.75rem;
}

/* ---------- Log ---------- */
#log {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  min-height: 200px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--muted);
}
#log li { padding: 0.2rem 0; border-bottom: 1px dashed rgba(255,255,255,0.05); }
#log li:last-child { border-bottom: none; }
#log li.highlight { color: var(--text); }
#log li.chat {
  color: #7dd3fc;          /* sky-300 — chat stands out clearly from game events */
  background: rgba(125, 211, 252, 0.07);
  border-left: 3px solid #7dd3fc;
  padding-left: 0.4rem;
  margin: 0.15rem 0;
  border-radius: 3px;
}

.chat-form {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.chat-form input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--edge);
  background: #0b2315;
  color: var(--text);
  font-size: 0.9rem;
}

/* Opponent card-back fans: hidden by default, shown only in the landscape
   media query below. Populated by renderOpponentFans() in room.js. */
.opponent-fans { display: none; }

/* Landscape phone: short viewport, wide. Hide log, shrink banner to a pill,
   compact seats into a single strip, pin hand as a single row across the
   bottom with Suggest/Pass stacked to its right. Placed last so it beats
   earlier equal-specificity rules in the cascade.

   Threshold is 600px: iPhone 17 Pro Max landscape is 956×440 CSS px, so
   440 fits comfortably; tablets in landscape are taller (≥768) so they
   fall through to the desktop layout. We also OR in (pointer: coarse)
   AND (max-width: 1100px) so touch devices whose reported height exceeds
   600 due to Safari chrome quirks still pick up the landscape layout. */
@media (orientation: landscape) and (max-height: 600px),
       (orientation: landscape) and (pointer: coarse) and (max-width: 1100px) {
  /* Make body a flex column so game-root fills the remaining viewport below
     the topbar — otherwise min-height: 100dvh on game-root + topbar height
     overflows and leaves blank space below the hand. */
  html, body { height: 100dvh; margin: 0; overflow-x: hidden; }
  body {
    display: flex;
    flex-direction: column;
    /* Keep UI clear of the Dynamic Island / notch in landscape. On phones
       without a notch these evaluate to 0. */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .topbar { flex-shrink: 0; }
  .game-root {
    padding: 0.3rem;
    gap: 0.3rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  /* Let the table-area grow so the trick is vertically centered in the
     middle of the screen, and the hand pins to the bottom. */
  .table-area { flex: 1; justify-content: center; }
  .hand-row { margin-top: auto; }
  .topbar { padding: 0.3rem 0.55rem; font-size: 0.8rem; gap: 0.4rem; }
  .topbar strong { font-size: 0.85rem; }
  .home-btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
  .share button { padding: 0.25rem 0.5rem; font-size: 0.72rem; }
  #copy-status, #room-code { display: none; }

  .landlord-banner {
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    width: fit-content;
    margin: 0 auto;
  }
  .landlord-banner .crown { font-size: 0.85rem; }

  /* Middle row: log panel pinned to the left, table-area (trick + pot) fills
     the rest. Sits between the banner and the hand-row, growing to fill. */
  .top-row {
    display: flex;
    flex-direction: row;
    gap: 0.3rem;
    order: 1;
    flex: 1;
    min-height: 0;
  }
  .log-area {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 200px;
    order: 0;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--edge);
    border-radius: 8px;
    padding: 0.35rem 0.45rem;
    overflow: hidden;
  }
  .log-area .log-box { padding: 0; background: transparent; border: none; min-height: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .log-area h3 { font-size: 0.7rem; margin: 0 0 0.25rem; }
  .log-area #log {
    font-size: 0.62rem;
    line-height: 1.25;
    min-height: 0;
    max-height: none;
    flex: 1;
    overflow-y: auto;
    padding: 0;
  }
  .log-area #log li { padding: 1px 0; }
  .log-area .chat-form { display: none; }

  /* Hide tile-style seats in landscape — opponent info moves to the card-back
     fans at the top corners. My own seat info is redundant next to my hand. */
  .seats { display: none; }

  .opponent-fans {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    order: 0;
    padding: 0 0.3rem;
    min-height: 58px;
  }
  .opponent-fan {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 48%;
    gap: 2px;
  }
  .opponent-fan--right { align-items: flex-end; }
  .opponent-fan-cards {
    display: flex;
    flex-direction: row;
  }
  .opponent-fan--right .opponent-fan-cards { flex-direction: row-reverse; }
  .opponent-fan-cards .card-back {
    width: 32px;
    height: 46px;
    border-radius: 4px;
    margin-left: -22px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.35);
  }
  .opponent-fan--right .opponent-fan-cards .card-back {
    margin-left: 0;
    margin-right: -22px;
  }
  .opponent-fan--left  .opponent-fan-cards .card-back:first-child { margin-left: 0; }
  .opponent-fan--right .opponent-fan-cards .card-back:first-child { margin-right: 0; }
  .opponent-fan-label {
    font-size: 0.62rem;
    color: var(--muted);
    white-space: nowrap;
    padding: 0 2px;
  }
  .opponent-fan.landlord .opponent-fan-label { color: var(--gold); font-weight: 600; }
  /* Historical plays stacked under each opponent. Latest on top with a
     subtle gold accent; older play dimmed. */
  .opponent-fan-history {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 2px;
    max-width: 100%;
  }
  .opponent-fan--right .opponent-fan-history { align-items: flex-end; }
  .opponent-fan-history .hist-row {
    display: flex;
    flex-direction: row;
    gap: 0;
    align-items: center;
    opacity: 0.55;
  }
  .opponent-fan-history .hist-row--latest { opacity: 1; }
  .opponent-fan--right .opponent-fan-history .hist-row { flex-direction: row-reverse; }
  .opponent-fan-history .hist-card {
    width: 18px !important;
    height: 26px !important;
    font-size: 0.48rem !important;
    padding: 1px 2px !important;
    border-radius: 3px !important;
    margin-left: -8px;
    flex-shrink: 0;
  }
  .opponent-fan--right .opponent-fan-history .hist-card {
    margin-left: 0;
    margin-right: -8px;
  }
  .opponent-fan--left  .opponent-fan-history .hist-row .hist-card:first-child { margin-left: 0; }
  .opponent-fan--right .opponent-fan-history .hist-row .hist-card:first-child { margin-right: 0; }
  .opponent-fan-history .hist-card .suit-big { display: none; }
  .opponent-fan-history .hist-card .bottom { display: none; }
  .opponent-fan-history .hist-pass {
    font-size: 0.55rem;
    color: var(--muted);
    font-style: italic;
  }

  .table-area {
    order: 1;
    padding: 0.3rem;
    gap: 0.3rem;
    border-radius: 8px;
  }
  .play-area { min-height: 0; gap: 0.2rem; }
  .middle-cards, .trick-area { min-height: 0; padding: 0; }
  .trick-area .card-face {
    width: 32px;
    height: 46px;
    font-size: 0.55rem;
    border-radius: 4px;
  }
  .trick-area .card-face .corner-rank { font-size: 0.42rem; }
  .trick-area .card-face .corner-suit { font-size: 0.33rem; }
  .trick-area .card-face .suit-big { font-size: 0.7rem; }
  .trick-area .card-face .pip { font-size: 0.28rem; }
  .trick-area .card-face .card-pips { top: 8px; bottom: 8px; left: 6px; right: 6px; }
  .history-strip { display: none !important; }
  .landlord-took .card-face { width: 28px; height: 40px; font-size: 0.58rem; }
  /* Compact pot pill centered, not a full-width bar. */
  .pot-row {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    padding: 2px 10px;
    background: rgba(0,0,0,0.35);
    border-radius: 999px;
    font-size: 0.62rem;
    gap: 0.35rem;
    flex-wrap: wrap;
  }

  /* End-of-round final-hands reveal: each player's hand is a single
     horizontal row of small cards (no wrapping). Uses the same overlap
     trick as the player's own fan so all 17–21 cards fit on one line. */
  .final-hands { padding: 0.3rem 0.5rem; margin: 0; max-width: none; }
  .final-hands-title { font-size: 0.62rem; margin-bottom: 0.25rem; }
  .final-row { padding: 0.15rem 0; gap: 0.4rem; }
  .final-name { min-width: 90px; font-size: 0.7rem; flex-wrap: nowrap; }
  .final-role { font-size: 0.52rem; padding: 0 0.3rem; }
  .final-count { font-size: 0.6rem; }
  .final-cards {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0;
    scrollbar-width: none;
    min-width: 0;
    flex: 1;
  }
  .final-cards::-webkit-scrollbar { display: none; }
  .final-card {
    width: 22px !important;
    height: 32px !important;
    font-size: 0.5rem !important;
    padding: 1px 2px !important;
    border-radius: 3px !important;
    margin-left: -10px;
    flex-shrink: 0;
  }
  .final-cards .final-card:first-child { margin-left: 0; }
  .final-card .suit-big { font-size: 0.65rem !important; }
  .final-card .bottom { display: none !important; }
  .pot-row .pot { font-size: 0.72rem; }

  .seats { gap: 0.3rem; }
  .seat {
    padding: 0.2rem 0.35rem;
    font-size: 0.62rem;
    line-height: 1.1;
    border-radius: 6px;
  }
  .seat .name { font-size: 0.68rem; gap: 0.2rem; }
  .seat .role { font-size: 0.55rem; }
  .seat .count { font-size: 0.6rem; }
  .seat .dollars { font-size: 0.68rem; }
  .turn-arrow { top: -6px; font-size: 0.7rem; }

  /* Hand row becomes a horizontal strip: cards on the left, action buttons
     stacked vertically on the right. Drop the header + tips to save space.
     Cards are sized so the landlord's 21-card hand fits in one row even on
     the smallest landscape phones (~667px wide). */
  .hand-row {
    order: 2;
    padding: 0.2rem 0.3rem;
    border-radius: 8px;
    position: sticky;
    bottom: 0;
    box-shadow: 0 -6px 14px rgba(0, 0, 0, 0.35);
  }
  .hand-row .hand-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
  }
  .hand-row .hand-header { display: none; }
  .hand-row .tips-panel { display: none; }
  .hand-row .hand {
    flex: 1;
    min-width: 0;
    min-height: 90px;
    max-height: none;
    max-width: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    /* flex-end, not center: if cards overflow the available width, the
       rightmost card (the important one — shows fully) stays pinned to the
       right edge and overflow is on the left. Centering clipped both sides. */
    justify-content: flex-end;
    gap: 0;
    row-gap: 0;
    padding: 0.5rem 0;
    margin: 0;
    scrollbar-width: none;
    order: 1;
  }
  .hand-row .hand::-webkit-scrollbar { display: none; }
  /* Overlapping fan: each card slides ~28px under the next so you see only
     the rank/suit corner of every card except the last. The last card shows
     in full, leaving room for the selected-lift hover state. */
  .hand-row .hand .card-face,
  .hand-row .hand .card-back {
    margin-left: -28px;
  }
  .hand-row .hand .card-face:first-child,
  .hand-row .hand .card-back:first-child {
    margin-left: 0;
  }
  /* Do NOT raise z-index on selected cards: natural DOM stacking puts each
     later card above its left neighbor, so raising z-index would hide the
     next card's tap-target sliver and make it unselectable. The lift +
     gold border (from .card-face.selected) is enough visual distinction. */
  .hand-row .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-shrink: 0;
    min-width: 84px;
    max-width: 110px;
    order: 0;
  }
  /* Long button text (e.g., "Take the 4 middle cards (become Landlord)")
     wraps instead of stretching the column. */
  .hand-row .action-bar button {
    padding: 0.35rem 0.4rem;
    font-size: 0.68rem;
    line-height: 1.15;
    white-space: normal;
    word-break: break-word;
  }

  .card-face {
    width: 62px;
    height: 90px;
    font-size: 0.95rem;
    border-radius: 7px;
    flex-shrink: 0;
  }
  .card-face .corner-rank { font-size: 0.7rem; }
  .card-face .corner-suit { font-size: 0.6rem; }
  .card-face .suit-big { font-size: 1.5rem; }
  .card-face .pip { font-size: 0.6rem; }
  .card-face .card-pips { top: 19px; bottom: 19px; left: 16px; right: 16px; }
  .card-face.selected { transform: translateY(-12px); }
  .card-back { width: 60px; height: 86px; border-radius: 6px; flex-shrink: 0; }
  .card-mini { width: 22px; height: 32px; font-size: 0.55rem; }
}

/* ---------- Changelog popup ---------- */
.changelog-overlay {
  z-index: 100;
  animation: changelog-fadein 0.25s ease;
}
.changelog-card {
  max-width: 420px !important;
  width: 100%;
}
.changelog-card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}
.changelog-card ul {
  margin: 0 0 1rem 0;
  padding: 0 0 0 1.1rem;
  line-height: 1.55;
}
.changelog-card li {
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
  color: var(--text);
}
.changelog-card li strong {
  color: var(--gold);
}
.changelog-footer {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
  font-style: italic;
}
.changelog-dismiss {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.7rem 1rem;
}
@keyframes changelog-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.changelog-fadeout {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ---------- Connection indicator ---------- */
.conn-indicator {
  font-size: 0.7rem;
  margin-left: 0.4rem;
  transition: color 0.3s;
}
.conn-indicator.conn-ok { color: #4caf50; }
.conn-indicator.conn-lost { color: #f44336; animation: conn-blink 1s infinite; }
@keyframes conn-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
/* Frozen-button overlay banner */
.conn-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(180, 40, 40, 0.92);
  color: #fff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 50;
  animation: conn-slide-up 0.3s ease;
}
@keyframes conn-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ---------- Full-width table when log is hidden (impossible bot mode) ---------- */
.table-area.full-width {
  max-width: 100% !important;
  width: 100% !important;
}
.top-row.full-width {
  grid-template-columns: 1fr !important;
}
