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

:root {
  --felt:       #1e4a2e;
  --felt-dark:  #152e1d;
  --felt-light: #255a37;
  --zone-bg:    rgba(0,0,0,0.25);
  --zone-border:rgba(0,0,0,0.4);

  --card-r:  #5a1418;  --card-r-border: #9b2335;
  --card-b:  #152040;  --card-b-border: #2566ab;
  --card-d:  #2e1c00;  --card-d-border: #8B6914;
  --card-s:  #252525;  --card-s-border: #666;
  --card-k:  #1e0e30;  --card-k-border: #7040b0;
  --card-x:  #141414;  --card-x-border: #333;

  --gold:  #dfb152;
  --str:   #c45433;
  --mag:   #8bb8e6;
  --vp:    #a060f0;
  --text:  #ddd;
  --muted: #888;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--felt-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  font-size: 16px;
}

/* ── Board ──────────────────────────────────────────────────────────── */
.board {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 55%, var(--felt-light) 0%, var(--felt) 40%, var(--felt-dark) 100%);
}

/* ── Zone layout ────────────────────────────────────────────────────── */

/* Top zone: full width, holds one or two opponent tableaus horizontally */
.zone-top {
  flex-shrink: 0;
  display: none;
  flex-direction: row;
  background: var(--zone-bg);
  border-bottom: 1px solid var(--zone-border);
  min-height: 0;
}
.board[data-layout="2"] .zone-top,
.board[data-layout="4"] .zone-top,
.board[data-layout="5"] .zone-top { display: flex; }

/* Middle row: left sidebar + center board + right sidebar */
.zone-middle {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

/* Side zones: fixed viewport-relative width, vertical tableau */
.zone-left,
.zone-right {
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  width: clamp(140px, 17vw, 210px);
  overflow: hidden;
  background: var(--zone-bg);
}
.zone-left  { border-right: 1px solid var(--zone-border); }
.zone-right { border-left:  1px solid var(--zone-border); }
.board[data-layout="3"] .zone-left,
.board[data-layout="3"] .zone-right,
.board[data-layout="4"] .zone-left,
.board[data-layout="4"] .zone-right,
.board[data-layout="5"] .zone-left,
.board[data-layout="5"] .zone-right { display: flex; }

/* Bottom zone: always visible, user tableau full width */
.zone-bottom {
  flex-shrink: 0;
  background: var(--zone-bg);
  border-top: 1px solid var(--zone-border);
}

/* ── Compact / mobile (narrow): one tableau at a time, swipe on header ─── */
.board.board--compact .zone-top,
.board.board--compact .zone-left,
.board.board--compact .zone-right {
  display: none !important;
}

.board--compact #zone-bottom {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tableau-carousel {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}

.tableau-carousel::-webkit-scrollbar {
  display: none;
}

.tableau-carousel-page {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  box-sizing: border-box;
  padding: 0 2px;
}

.tableau-carousel-page .seat {
  width: 100%;
  max-width: 100%;
}

.tableau-carousel-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.tableau-carousel-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 10px;
  flex-shrink: 0;
}

.tableau-carousel-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.tableau-carousel-dot.is-active {
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.board--compact .tableau-carousel .player-header {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  /* Native horizontal scroll on the carousel; do not block the browser scroller. */
  touch-action: pan-x;
}

/* ── Seats (now flex children of zones, not absolute) ───────────────── */
.seat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
}

/* Top zone: each seat fills an equal share of the full width */
.zone-top .seat {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--zone-border);
}
.zone-top .seat:last-child { border-right: none; }

/* Side zones: seat fills the full panel */
.zone-left .seat,
.zone-right .seat { flex: 1; overflow: hidden; }

/* Bottom zone: seat fills full width */
.zone-bottom .seat { width: 100%; }

/* ── Seat inner layout ──────────────────────────────────────────────── */
.seat-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  min-width: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.zone-bottom .seat-inner { width: 100%; overflow: visible; }
.zone-left   .seat-inner,
.zone-right  .seat-inner { overflow: hidden; }

/* Header + card row; green ring when it is this browser user’s turn (bottom seat only). */
.seat-tableau-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.zone-bottom .seat-tableau-frame {
  width: 100%;
}

.seat-tableau-frame.is-active-turn {
  border-radius: 10px;
  box-shadow: 0 0 0 5px #53d337;
}

/* ── Player header bar ──────────────────────────────────────────────── */
.player-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 5px;
  flex-shrink: 0;
}

.player-name {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  margin-right: 4px;
}

.player-name.is-first {
  display: inline-flex;
  align-items: center;
}

.player-first-star {
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
  margin-right: 4px;
  cursor: help;
}

.score-pill {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  background: rgba(0,0,0,0.4);
}

.score-pill-sym {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Side seats (3–5p): name full width, then Gold|Strength and Magic|VP two per row */
.zone-left .player-header,
.zone-right .player-header {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}

.zone-left .player-name,
.zone-right .player-name {
  flex: 1 0 100%;
  margin-right: 0;
  text-align: center;
}

.zone-left .score-pill,
.zone-right .score-pill {
  flex: 0 0 calc(50% - 2px);
  width: calc(50% - 2px);
  max-width: calc(50% - 2px);
  box-sizing: border-box;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px 4px;
  min-width: 0;
}

.score-pill-resource-icon {
  display: block;
  height: 1.15em;
  max-height: min(1.25em, 20px);
  width: auto;
  object-fit: contain;
}
.score-pill.gold     { color: var(--gold); }
.score-pill.strength { color: var(--str); }
.score-pill.magic    { color: var(--mag); }
.score-pill.victory  { color: var(--vp); }

/* Card row wrapper (ring chrome is on .seat-tableau-frame.is-active-turn) */
.tableau-ring-host {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tableau-ring-host .tableau-cards {
  position: relative;
  z-index: 1;
}

/* Approximate inactivity timeout (see server cleanup); resets on each state update */
.tableau-inactive-timer {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: rgba(255, 248, 220, 0.95);
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 0 1px rgba(240, 192, 64, 0.25);
  pointer-events: none;
}

.zone-bottom .tableau-inactive-timer {
  font-size: 13px;
  top: 6px;
  right: 8px;
}

.zone-top .tableau-inactive-timer,
.zone-left .tableau-inactive-timer,
.zone-right .tableau-inactive-timer {
  font-size: 10px;
  padding: 1px 5px;
  top: 3px;
  right: 4px;
}

/* ── Tableau cards ──────────────────────────────────────────────────── */
.tableau-cards {
  display: flex;
  flex-direction: row;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 4px;
  flex: 1;
  align-items: flex-start;
}

.zone-bottom .tableau-cards {
  justify-content: safe center;
}

@supports not (justify-content: safe center) {
  .zone-bottom .tableau-cards {
    justify-content: center;
  }
}

.tableau-cards::-webkit-scrollbar { height: 4px; }
.tableau-cards::-webkit-scrollbar-track { background: transparent; }
.tableau-cards::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Card group: horizontal by default (top zone, bottom zone) */
.card-group {
  display: flex;
  flex-direction: row;
  gap: 4px;
  padding-right: 6px;
  border-right: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.card-group:last-child { border-right: none; }

.card-group-label {
  writing-mode: vertical-rl;
  font-size: 11px;
  color: var(--muted);
  align-self: stretch;
  display: flex;
  align-items: center;
  margin-right: 2px;
  flex-shrink: 0;
}

/* Cards wrapper inside a card-group */
.card-group-cards {
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: flex-start;
}

/* ── Side zone tableaus: vertical layout with wrapping cards ─────────── */
.zone-left .tableau-cards,
.zone-right .tableau-cards {
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-x: hidden;
  overflow-y: auto;
  align-items: stretch;
  gap: 0;
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
}

.zone-left .tableau-cards::-webkit-scrollbar,
.zone-right .tableau-cards::-webkit-scrollbar { width: 4px; height: auto; }

.zone-left .card-group,
.zone-right .card-group {
  flex-direction: column;
  border-right: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-right: 0;
  padding-bottom: 5px;
  margin-bottom: 5px;
  flex-shrink: 0;
  gap: 3px;
}
.zone-left .card-group:last-child,
.zone-right .card-group:last-child { border-bottom: none; margin-bottom: 0; }

.zone-left .card-group-label,
.zone-right .card-group-label {
  writing-mode: horizontal-tb;
  font-size: 10px;
  margin-right: 0;
  margin-bottom: 3px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.zone-left .card-group-cards,
.zone-right .card-group-cards {
  flex-wrap: wrap;
  gap: 3px;
}

/* ── Individual card ────────────────────────────────────────────────── */
.card {
  border-radius: 5px;
  border: 1px solid;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
  cursor: default;
  user-select: none;
  overflow: hidden;
}
.card:hover { filter: brightness(1.2); }

/* Card with image — image fills card, overlay sits at bottom */
.card.card-has-image { padding: 0; }

.card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 18px 5px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,0.88) 55%);
  border-radius: 0 0 4px 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.card-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  color: #fff;
  word-break: break-word;
}

.card-sub {
  font-size: 16px;
  color: rgba(255,255,255,0.65);
  line-height: 1.2;
}

.card-extra {
  font-size: 16px;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

/* Bottom zone (user): full-size cards */
.zone-bottom .card { width: 108px; min-height: 118px; height: 158px; }
.zone-bottom .card:not(.card-has-image) { height: auto; min-height: 118px; }

/* Top zone (horizontal opponent bar): medium cards */
.zone-top .card.card-has-image { width: 78px; height: 114px; min-height: 114px; }
.zone-top .grid-stack .card { width: 78px; height: 114px; min-height: 91px; }
.zone-top .grid-stack .card:not(.card-has-image) { height: auto; min-height: 30px; }
/* 5-player: two top tableaus share width, need slightly smaller cards */
.board[data-layout="5"] .zone-top .card.card-has-image { width: 62px; height: 91px; min-height: 91px; }
.board[data-layout="5"] .zone-top .grid-stack .card { width: 62px; height: 91px; min-height: 74px; }

/* Side zones: smaller cards that can wrap */
.zone-left .card.card-has-image,
.zone-right .card.card-has-image { width: 68px; height: 100px; min-height: 100px; }
.zone-left .grid-stack .card,
.zone-right .grid-stack .card { width: 68px; height: 100px; min-height: 80px; }
.zone-left .grid-stack .card:not(.card-has-image),
.zone-right .grid-stack .card:not(.card-has-image) { height: auto; min-height: 28px; }

/* Non-image opponent cards: compact chips */
.zone-top .card:not(.card-has-image),
.zone-left .card:not(.card-has-image),
.zone-right .card:not(.card-has-image) {
  flex-direction: row;
  align-items: center;
  min-height: 28px;
  padding: 3px 6px;
  width: auto;
  min-width: 56px;
  max-width: 120px;
  height: auto;
}
.zone-top .card:not(.card-has-image) .card-name,
.zone-left .card:not(.card-has-image) .card-name,
.zone-right .card:not(.card-has-image) .card-name {
  font-size: 11px;
}

.zone-top .grid-stack .stack-depth,
.zone-left .grid-stack .stack-depth,
.zone-right .grid-stack .stack-depth {
  font-size: 13px;
  padding: 2px 4px;
  bottom: -1px;
  right: -1px;
}

/* Card type colors */
.card-monster  { background: var(--card-r); border-color: var(--card-r-border); }
.card-citizen  { background: var(--card-b); border-color: var(--card-b-border); }
.card-domain   { background: var(--card-d); border-color: var(--card-d-border); }
.card-starter  { background: var(--card-s); border-color: var(--card-s-border); }
.card-duke     { background: var(--card-k); border-color: var(--card-k-border); }
.card-exhausted{ background: var(--card-x); border-color: var(--card-x-border); }
.card-exhausted .card-name { color: #444; }

.card.flipped { opacity: 0.45; }

/* ── Center board ───────────────────────────────────────────────────── */
/* Now a flex child of .zone-middle — no absolute positioning */
.center-board {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.center-board-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Content wrapper: column by default (card grid above game log) */
.center-board-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 2-player: game log beside card grid on the right */
.board[data-layout="2"] .center-board-content {
  flex-direction: row;
  /* stretch so .center-board-scroll gets a real height budget; flex-start let the
     scroll area grow to content height so scrollHeight never exceeded clientHeight */
  align-items: stretch;
  min-height: 0;
}

/* Mirror spacer (left) = log width (right) so the card grid stays centered.
   Only shown in 2-player layout with enough viewport width. */
.board[data-layout="2"] .center-board-content::before {
  content: '';
  flex-shrink: 0;
  width: clamp(180px, 22vw, 260px);
}

/* Hide mirror spacer AND log on narrow viewports */
@media (max-width: 950px) {
  .board[data-layout="2"] .center-board-content::before { display: none; }
  .board[data-layout="2"] .center-board-content .game-log { display: none; }
}

/* Card grid: fills available space and centers its sections both H and V */
.center-board-scroll {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 0;
}

.board[data-layout="2"] .center-board-scroll {
  flex: 1 1 0%;
  align-self: stretch;
}

.board[data-layout="2"] .center-board-tabs {
  align-self: flex-start;
}

.center-board-scroll::-webkit-scrollbar { width: 6px; }
.center-board-scroll::-webkit-scrollbar-track { background: transparent; }
.center-board-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

/* ── Grid stacks ────────────────────────────────────────────────────── */
.grid-stack {
  position: relative;
  flex-shrink: 0;
}

/* Center board market cards */
.center-board .grid-stack .card { width: 128px; min-height: 150px; height: 188px; }
.center-board .grid-stack .card:not(.card-has-image) { height: auto; min-height: 150px; }

.stack-depth {
  position: absolute;
  bottom: -2px; right: -2px;
  background: rgba(0,0,0,0.5);
  color: #aaa;
  font-size: 18px;
  padding: 2px 5px;
  border-radius: 3px;
  pointer-events: none;
}

.center-board .card-slot-empty {
  width: 128px;
  min-height: 150px;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 5px;
  flex-shrink: 0;
}

/* ── Center board sections ──────────────────────────────────────────── */
.center-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 4px;
}

.section-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.grid-row {
  display: flex;
  flex-direction: row;
  gap: 5px;
  flex-wrap: nowrap;
}

.center-board .grid-row {
  gap: 6px;
}

.center-board .stack-depth {
  font-size: 18px;
}

/* ── Info bar ───────────────────────────────────────────────────────── */
.info-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  flex-wrap: nowrap;
  width: 100%;
  box-sizing: border-box;
}

.info-bar-primary {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.info-bar-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.phase-label {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.turn-label {
  font-size: 16px;
  color: var(--muted);
}

.dice-display {
  display: flex;
  align-items: center;
  gap: 5px;
}

.die {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: #f5f0e8;
  color: #111;
  border-radius: 5px;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.die-sum {
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
}

.info-bar-take-resource {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 0;
}

.info-bar-take-label {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
  white-space: nowrap;
}

.info-bar-take-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.info-bar-take-buttons .prompt-btn {
  padding: 5px 10px;
  font-size: 16px;
}

/* Tabbed center: hide lobby in info bar; dice + take-resource on second row */
.center-board.has-tabs .info-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.center-board.has-tabs .info-bar-primary {
  flex: 0 1 auto;
}

.center-board.has-tabs .info-bar-actions {
  margin-left: 0;
  justify-content: flex-start;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
}

.center-board.has-tabs .info-bar-lobby-btn {
  display: none !important;
}

/* ── Game log ───────────────────────────────────────────────────────── */
.game-log {
  flex-shrink: 0;
  margin: 0 0 8px;
  min-width: min(320px, 100%);
  max-width: min(680px, 100%);
  align-self: center;          /* centers below the card grid */
  box-sizing: border-box;
  background: rgba(0,0,0,0.3);
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.07);
  max-height: min(120px, 22vh);
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}

/* 2-player: log is a fixed-width column to the right of the centered card grid */
.board[data-layout="2"] .center-board-content .game-log {
  width: clamp(180px, 22vw, 260px);
  min-width: clamp(180px, 22vw, 260px);
  max-width: clamp(180px, 22vw, 260px);
  max-height: none;
  flex: none;
  align-self: stretch;
  min-height: 0;
  margin: 8px 8px 8px 0;
}

/* 3–5p: reclaim vertical space for the card grid before tab mode (see game.js) */
.center-board.hide-center-log .game-log {
  display: none;
}

.game-log::-webkit-scrollbar { width: 4px; }
.game-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.log-entry {
  font-size: 16px;
  color: rgba(255,255,255,0.55);
  line-height: 1.4;
}
.log-entry:first-child { color: rgba(255,255,255,0.85); }

/* ── Game over overlay ──────────────────────────────────────────────── */
.game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 400;
}

.game-over-panel {
  background: #1a2a1a;
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
  min-width: 360px;
}

.game-over-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 20px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 16px;
}
.score-row:last-child { border-bottom: none; }
.score-row .rank  { color: var(--gold); font-weight: 700; width: 32px; }
.score-row .sname { flex: 1; text-align: left; color: #fff; font-weight: 600; }
.score-row .total { color: var(--vp); font-weight: 900; font-size: 16px; }
.score-row .breakdown { color: var(--muted); font-size: 16px; }

.game-over-lobby-strip {
  max-width: min(92vw, 480px);
  padding: 14px 20px 18px;
  border-radius: 10px;
  background: rgba(10, 18, 12, 0.92);
  border: 1px solid rgba(240, 192, 64, 0.28);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.game-over-lobby-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
  margin-bottom: 10px;
}

.game-over-lobby-countdown {
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  text-align: center;
  margin-bottom: 12px;
}

.game-over-lobby-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(240, 192, 64, 0.45);
  background: linear-gradient(180deg, #c89830 0%, #a07820 100%);
  color: #1a1206;
}

.game-over-lobby-btn:hover {
  filter: brightness(1.06);
}

/* ── Root navigation ─────────────────────────────────────────────────── */
/* Fixed-position lobby button hidden — replaced by the in-info-bar button */
.game-lobby-btn { display: none; }

/* Lobby button inside the info bar */
.info-bar-lobby-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
  margin-left: 8px;  /* gap after the dice */
}
.info-bar-lobby-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
}

/* ── Connection status ──────────────────────────────────────────────── */
.conn-status {
  position: fixed;
  bottom: 8px; right: 10px;
  font-size: 16px;
  color: var(--muted);
  pointer-events: none;
  z-index: 50;
}
.conn-status.disconnected { color: var(--str); }

/* ── Lobby modal (no game_id / player_id) ───────────────────────────── */
.lobby-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, rgba(240, 192, 64, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 40%, rgba(37, 90, 55, 0.55) 0%, rgba(10, 22, 14, 0.92) 65%, rgba(5, 12, 8, 0.97) 100%);
  backdrop-filter: blur(14px) saturate(1.15);
}

.lobby-overlay.lobby-overlay--open {
  display: flex;
}

.lobby-sheet {
  width: min(440px, 100%);
  padding: 30px 28px 24px;
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(52, 62, 74, 0.55) 0%, transparent 42%),
    linear-gradient(165deg, rgba(28, 34, 42, 0.97) 0%, rgba(14, 17, 22, 0.99) 100%);
  border: 1px solid rgba(240, 192, 64, 0.28);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 28px 90px rgba(0, 0, 0, 0.72),
    0 0 48px rgba(240, 192, 64, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.lobby-brand {
  margin-bottom: 22px;
  text-align: center;
}

.lobby-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lobby-tagline {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
}

.lobby-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 16px;
  color: #ffb8b8;
  background: rgba(224, 80, 80, 0.15);
  border: 1px solid rgba(224, 80, 80, 0.35);
}

.lobby-hidden {
  display: none !important;
}

.lobby-label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.lobby-join-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lobby-join-rooms-lead {
  margin-bottom: 8px;
}

.lobby-join-rooms {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 11rem;
  overflow-y: auto;
}

.lobby-table-pick {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font: inherit;
  cursor: pointer;
  line-height: 1.35;
}

.lobby-table-pick:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.lobby-table-pick.is-selected {
  border-color: rgba(120, 190, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(120, 190, 255, 0.25);
}

.lobby-switch-wrap {
  margin-bottom: 12px;
}

.lobby-switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.lobby-select {
  flex: 1;
  min-width: 12rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
}

.lobby-new-table-btn {
  margin-bottom: 12px;
  width: 100%;
}

.lobby-input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.lobby-input:focus {
  border-color: rgba(240, 192, 64, 0.45);
  box-shadow: 0 0 0 3px rgba(240, 192, 64, 0.12);
}

.lobby-btn {
  cursor: pointer;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  padding: 11px 18px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

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

.lobby-btn-primary {
  background: linear-gradient(180deg, #c89830 0%, #a07820 100%);
  color: #1a1206;
  border-color: rgba(255, 220, 120, 0.35);
}

.lobby-btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.lobby-btn-ready {
  flex: 1;
  background: rgba(64, 208, 128, 0.18);
  color: var(--vp);
  border-color: rgba(64, 208, 128, 0.35);
}

.lobby-btn-ready.is-cancel {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
}

.lobby-btn-ready:hover:not(:disabled) {
  filter: brightness(1.08);
}

.lobby-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.12);
}

.lobby-btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
}

.lobby-btn-danger {
  background: rgba(224, 80, 80, 0.18);
  color: #ffb8b8;
  border-color: rgba(224, 80, 80, 0.45);
}

.lobby-btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

.lobby-parked-lead {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.lobby-parked-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}

.lobby-parked-actions .lobby-btn {
  flex: 1 1 140px;
  min-width: 120px;
}

.lobby-parked-hint {
  text-align: center;
  margin-bottom: 0;
}

.lobby-ended-lead {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 12px;
  text-align: center;
}

.lobby-ended-countdown {
  font-size: 13px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 18px;
}

#lobby-ended-go {
  display: block;
  width: 100%;
}

.lobby-hint {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

.lobby-player-list {
  list-style: none;
  max-height: min(220px, 40vh);
  overflow-y: auto;
  margin-bottom: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
}

.lobby-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 16px;
}

.lobby-player-row:last-child {
  border-bottom: none;
}

.lobby-player-row.is-self {
  background: rgba(240, 192, 64, 0.07);
}

.lobby-p-name {
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-p-status {
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.lobby-p-status.is-ready {
  background: rgba(64, 208, 128, 0.2);
  color: var(--vp);
}

.lobby-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.lobby-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.lobby-live {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.lobby-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.85;
}

.lobby-live--ok {
  color: rgba(180, 245, 200, 0.95);
}

.lobby-live--ok::before {
  background: var(--vp);
  box-shadow: 0 0 10px rgba(64, 208, 128, 0.55);
  animation: lobby-pulse 2.4s ease-in-out infinite;
}

.lobby-live--warn::before {
  background: var(--gold);
  animation: lobby-pulse 1.2s ease-in-out infinite;
}

.lobby-live--off::before {
  background: var(--str);
  animation: none;
  opacity: 1;
}

@keyframes lobby-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.92); }
}

.lobby-meta {
  margin: 0;
  flex: 1 1 auto;
  text-align: right;
  font-size: 16px;
  color: var(--muted);
  min-width: min(100%, 200px);
}

@media (max-width: 380px) {
  .lobby-meta {
    text-align: left;
    width: 100%;
  }
}

/* ── Card hover preview ─────────────────────────────────────────────── */
.card-preview {
  display: none;
  position: fixed;
  z-index: 200;
  pointer-events: none;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  /* show at native resolution — no width/height override */
}

/* ── Card click modal ───────────────────────────────────────────────── */
.card-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.card-modal {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-start;
  justify-content: center;
  background: #1a1a2a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 28px;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100vw - 24px);
  max-height: 90vh;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 0 16px 64px rgba(0,0,0,0.8);
}

.card-modal-img {
  display: block;
  width: auto;
  height: auto;
  max-height: 75vh;
  max-width: min(560px, calc(100vw - 120px));
  border-radius: 6px;
  flex-shrink: 1;
  object-fit: contain;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}

.card-modal-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 260px;
  min-width: 0;
  max-width: min(520px, calc(100vw - 48px));
}

.modal-card-name {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.modal-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 16px;
}

.modal-stat-label {
  color: var(--muted);
  white-space: nowrap;
}

.modal-stat-value          { color: var(--text); font-weight: 600; min-width: 0; text-align: right; overflow-wrap: break-word; }
.modal-stat-value.modal-gold { color: var(--gold); }
.modal-stat-value.modal-str  { color: var(--str);  }
.modal-stat-value.modal-mag  { color: var(--mag);  }
.modal-stat-value.modal-vp   { color: var(--vp);   }

.modal-resource-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
}

.modal-resource-icon {
  display: block;
  height: 1.15em;
  max-height: min(1.25em, 22px);
  width: auto;
  object-fit: contain;
}

.modal-card-text {
  font-size: 16px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  overflow-wrap: break-word;
  word-break: break-word;
}

.card-modal--market {
  max-width: calc(100vw - 24px);
}

.card-modal--market .card-modal-info {
  flex: 1 1 320px;
  min-width: 0;
  max-width: min(600px, calc(100vw - 48px));
}

.market-rules-extra {
  border-top-color: rgba(255,255,255,0.06);
}

.market-action-panel {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.market-action-heading {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.market-resources-row {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.72);
}

.market-resources-row--strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.market-resources-intro {
  color: rgba(255,255,255,0.72);
  margin-right: 2px;
}

.market-effects-banner {
  font-size: 16px;
  line-height: 1.4;
  color: rgba(255,255,255,0.8);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(240,192,64,0.25);
  background: rgba(240,192,64,0.08);
}

.market-block-note {
  font-size: 16px;
  font-weight: 700;
  color: var(--str);
}

.market-cost-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  color: rgba(255,255,255,0.75);
  line-height: 1.45;
  overflow-wrap: break-word;
}

.market-afford-ok {
  font-size: 16px;
  font-weight: 700;
  color: var(--vp);
}

.market-afford-bad {
  font-size: 16px;
  font-weight: 700;
  color: rgba(224,80,80,0.95);
}

.market-pay-fields {
  margin-top: 4px;
}

.market-pay-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.market-pay-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.market-pay-field-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.market-pay-field-label--gold { color: var(--gold); text-transform: none; letter-spacing: normal; }
.market-pay-field-label--strength { color: var(--str); text-transform: none; letter-spacing: normal; }
.market-pay-field-label--magic { color: var(--mag); text-transform: none; letter-spacing: normal; }

.market-pay-label-icon {
  display: block;
  height: 1.15em;
  max-height: 20px;
  width: auto;
  object-fit: contain;
}

.market-pay-input {
  width: 64px;
  padding: 8px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.market-pay-input:focus {
  outline: none;
  border-color: rgba(240,192,64,0.45);
}

.market-pay-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.market-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.market-action-help {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.4;
}

.prompt-btn:disabled,
.prompt-btn-secondary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* ── Required-choice modal (reuses card-modal shell) ─────────────────── */
.game-prompt-overlay {
  z-index: 320;
}

.card-modal--prompt {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 18px;
  width: auto;
  min-width: min(92vw, 360px);
  max-width: min(calc(100vw - 24px), 720px);
}

.prompt-modal-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-modal-title {
  margin: 0;
}

.prompt-modal-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

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

.prompt-modal-note {
  font-size: 16px;
  color: rgba(255,255,255,0.72);
  line-height: 1.45;
  overflow-wrap: break-word;
}

.prompt-modal-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.prompt-modal-footer {
  padding-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.prompt-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.prompt-modal-actions--wrap {
  justify-content: flex-start;
}

.prompt-modal-dice-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.prompt-turn-chip {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.prompt-turn-chip.is-on-turn {
  border-color: rgba(64,208,128,0.45);
  background: rgba(64,208,128,0.12);
  color: var(--vp);
}

.prompt-btn {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  color: #fff;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.prompt-btn:hover {
  border-color: rgba(240,192,64,0.45);
  background: linear-gradient(180deg, rgba(240,192,64,0.2), rgba(240,192,64,0.08));
}

.prompt-btn-secondary {
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  font-weight: 600;
  color: var(--muted);
}

.prompt-btn-secondary:hover {
  border-color: rgba(255,255,255,0.22);
  color: var(--text);
}

.prompt-choice-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 52vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.prompt-choice-card {
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 14px 16px;
}

.prompt-choice-card-inner {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

.prompt-choice-card-img-wrap {
  flex-shrink: 0;
}

.prompt-choice-card-img {
  display: block;
  width: auto;
  height: auto;
  max-height: min(36vh, 240px);
  max-width: min(100%, 240px);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
}

.prompt-choice-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 520px) {
  .prompt-choice-card-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .prompt-choice-card-img {
    max-width: 100%;
    max-height: min(40vh, 260px);
    margin: 0 auto;
  }
}

.prompt-choice-card-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.prompt-choice-card-scaling {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.prompt-choice-card-meta {
  font-size: 16px;
  color: var(--muted);
  margin-top: 4px;
}

.prompt-choice-card-text {
  font-size: 16px;
  color: rgba(255,255,255,0.62);
  line-height: 1.45;
  margin-top: 8px;
  white-space: pre-wrap;
}

.prompt-choice-card-actions {
  margin-top: 12px;
}

/* cards are now interactive */
.card { cursor: pointer; }

/* ── Center board section label sizing ─────────────────────────────── */
.section-label { font-size: 11px; }

/* ── Center board tab bar ───────────────────────────────────────────── */
.center-board-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
/* Hide tab bar when not in tab mode */
.center-board:not(.has-tabs) .center-board-tabs { display: none; }

.center-tab-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.center-tab-btn:hover { color: var(--text); }
.center-tab-btn.active {
  color: #fff;
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
}

/* Hide non-active sections when tab mode is on */
.center-board.has-tabs .center-section { display: none; }
.center-board.has-tabs .center-section.tab-active { display: flex; }

/* Tabbed market: five columns share full width; cards scale with column width */
.center-board.has-tabs .center-board-scroll {
  align-items: stretch;
}

.center-board.has-tabs .center-section.tab-active {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.center-board.has-tabs .grid-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  align-items: start;
}

.center-board.has-tabs .grid-stack {
  flex-shrink: 1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.center-board.has-tabs .grid-stack .card {
  flex-shrink: 1;
  box-sizing: border-box;
}

.center-board.has-tabs .grid-stack .card.card-has-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 128 / 188;
}

.center-board.has-tabs .grid-stack .card:not(.card-has-image) {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: min(150px, 32vw);
  max-height: none;
  font-size: clamp(10px, 2.8vw, 15px);
}

.center-board.has-tabs .card-slot-empty {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  aspect-ratio: 128 / 188;
}

.center-board.has-tabs .stack-depth {
  font-size: clamp(10px, 3.2vw, 18px);
  padding: 1px 4px;
}

.center-board.has-tabs .grid-stack .card-has-image .card-overlay {
  padding: 10px 4px 4px;
}

.center-board.has-tabs .grid-stack .card .card-name {
  font-size: clamp(9px, 2.8vw, 15px);
}

.center-board.has-tabs .grid-stack .card .card-sub,
.center-board.has-tabs .grid-stack .card .card-extra {
  font-size: clamp(8px, 2.4vw, 14px);
}

/* ── Player info modal ──────────────────────────────────────────────── */
.player-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 350;
  padding: 16px;
}

.player-modal {
  background: #1a2a1a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 24px 28px;
  width: min(480px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 64px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-modal-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.player-modal-badge {
  font-size: 14px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(240,192,64,0.35);
  color: var(--gold);
  background: rgba(240,192,64,0.1);
}

.player-modal-badge.is-active {
  border-color: rgba(64,208,128,0.45);
  color: var(--vp);
  background: rgba(64,208,128,0.12);
}

.player-modal-resources {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.player-modal-resource {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  flex: 1;
  min-width: 64px;
}

.player-modal-resource-val {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.player-modal-resource-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.player-modal-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.player-modal-counts {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.player-modal-count-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}
.player-modal-count-row:last-child { border-bottom: none; }
.player-modal-count-label { color: var(--muted); }
.player-modal-count-val   { color: #fff; font-weight: 600; }

.player-modal-close {
  font: inherit;
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  align-self: flex-end;
  margin-top: 4px;
}
.player-modal-close:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }
