/* ===== Visual redesign v2 — gated behind body.theme-v2 =====
 *
 * Toggle via the "New UI" / "Classic UI" button in the status bar.
 * All rules scoped under body.theme-v2 — classic view is one click away.
 */

body.theme-v2 {
  --bg-board:        #131922;
  --bg-player-mat:   #0f1923;
  --bg-card:         #1c2332;
  --bg-card-hand:    #1a2540;
  --contract-border: #6b6040;
}


/* ============================================================
   LAYOUT — No scrolling, players left, hand bottom 1/4
   ============================================================ */

body.theme-v2 #game-wrapper {
  width: 1400px;                       /* fixed reference width — zoom fits it  */
  height: 1280px;                      /* fixed reference height — zoom fits it */
  margin: 0 auto;                      /* center when viewport is wider         */
  overflow: hidden;
  padding-bottom: 12px;
  box-sizing: border-box;
}

body.theme-v2 #game-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

body.theme-v2 #game-layout {
  flex: 1;
  min-height: 0;
  grid-template-columns: 1fr min(200px, 20vw);
  grid-template-rows: 1fr;
}
/* game-area: flex column — board fills top, player-zone keeps natural size */
body.theme-v2 #game-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* board-zone: 3-column grid, takes remaining space above player zone.
 * Contracts row is kept small so the pool row can hold a full card row. */
body.theme-v2 .board-zone {
  display: grid;
  grid-template-columns: min(200px, 20vw) min(130px, 14vw) 1fr;
  grid-template-rows: auto 130px minmax(0, 1fr);  /* events(auto), contracts(fixed), pool(rest) */
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* Players → narrow left column, spans all rows */
body.theme-v2 .board-zone > section:first-child {
  grid-column: 1;
  grid-row: 1 / 4;
  overflow-y: auto;
  padding: 4px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-board) 70%, var(--bg-canvas));
}

/* Ruler → col 2, spans all rows */
body.theme-v2 .board-zone > section:nth-child(2) {
  grid-column: 2;
  grid-row: 1 / 4;
  padding: 4px 8px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
body.theme-v2 .board-zone > section:nth-child(2) .market-ruler {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
body.theme-v2 .board-zone > section:nth-child(2) .ruler-track {
  height: 100%;                      /* track fills available ruler height  */
}

/* Event deck area → col 3, row 1 (auto-sized) */
body.theme-v2 .board-zone > #event-deck-area {
  grid-column: 3;
  grid-row: 1;
  padding: 4px 8px;
  overflow: hidden;
}

/* Contracts → col 3, row 2 */
body.theme-v2 .board-zone > section:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
  padding: 4px 8px;
  overflow: hidden;
  min-height: 0;
}

/* Pool → col 3, row 3 */
body.theme-v2 .board-zone > section:nth-child(5) {
  grid-column: 3;
  grid-row: 3;
  padding: 4px 8px;
  overflow: hidden;
  min-height: 0;
}

/* Player zone → below the board, natural content size, never shrinks */
body.theme-v2 .player-zone {
  flex-shrink: 0;
  background: var(--bg-player-mat);
  border-top: 2px solid rgba(88, 166, 255, 0.2);
  padding: 8px;
  overflow: hidden;
  border-radius: 6px;
}

body.theme-v2 #event-feed {
  background: color-mix(in srgb, var(--bg-elevated) 80%, var(--bg-canvas));
  border-left: 1px solid var(--border);
  font-size: 0.7rem;
  padding: 6px;
  overflow-y: auto;
  position: static;
}


/* ============================================================
   SECTION TITLES
   ============================================================ */

body.theme-v2 .section-title {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
}


/* ============================================================
   OPPONENTS — Compact vertical stack in left column
   ============================================================ */

body.theme-v2 .opponents-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;                    /* players don't shrink for feed       */
}

/* Hide players header */
body.theme-v2 .board-zone > section:first-child > .section-title {
  display: none;
}

/* Player cards: background tint, no colored left border, uniform text */
body.theme-v2 .opponent-card {
  padding: 6px 8px;
  font-size: 0.72rem;
  border-left: none !important;
  border: 1px solid var(--border);
  border-radius: 6px;
}

body.theme-v2 .opponent-card .opponent-name,
body.theme-v2 .opponent-card .opponent-nw,
body.theme-v2 .opponent-card .opponent-money {
  color: var(--text-primary) !important;     /* same color for all players */
}

body.theme-v2 .opponent-card.active-turn {
  background: color-mix(in srgb, var(--accent-blue) 15%, var(--bg-elevated)) !important;
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(88, 166, 255, 0.2);
}

body.theme-v2 .opponent-card.is-you {
  border-color: rgba(88, 166, 255, 0.3);
}

/* Player stats: clear rows, readable font */
body.theme-v2 .opponent-stats-v2 {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-primary);
}
body.theme-v2 .opponent-stats-v2 strong {
  font-weight: 700;
}

/* Turn indicator dot */
body.theme-v2 .turn-dot {
  color: var(--accent-green);
  font-size: 0.8rem;
  margin-right: 2px;
}

/* Rate chips already in turn-order sidebar — hide from player board */
body.theme-v2 .player-rates-grid {
  display: none;
}
body.theme-v2 #player-zone-title {
  display: none;
}

/* Move rate tracker into the board's right column (below pool) */
body.theme-v2 #mp-your-stats {
  font-size: 0.78rem;
}
body.theme-v2 .player-stats-money {
  font-size: 0.78rem;
}
body.theme-v2 .player-stats-v2 {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-primary);
  position: relative;
}
body.theme-v2 .player-stats-v2 strong {
  font-weight: 700;
}
body.theme-v2 .player-money-line {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  white-space: nowrap;
}
body.theme-v2 .player-nw-badge {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 1.1rem;
  font-weight: 800;
}
/* Reserve space for the built-buildings list so the player zone doesn't
 * grow as buildings come in — growth here pushes the board up and cuts
 * the pool bottom. 3 lines at 0.7rem ≈ 42px. */
body.theme-v2 .player-buildings-box {
  min-height: 48px;
  max-height: 48px;
  overflow: hidden;
}
body.theme-v2 .player-stats-buildings,
body.theme-v2 .player-stats-specials {
  font-size: 0.7rem;
}

/* Opponent rate chips: non-zero only, readable size */
body.theme-v2 .opponent-rates-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}
body.theme-v2 .opponent-rates-grid .rate-chip.sm {
  padding: 2px 5px;
  font-size: 0.68rem;
  border-radius: 3px;
}

/* Hide building lists in opponents to keep them compact */
body.theme-v2 .opponent-buildings {
  font-size: 0.6rem;
  max-height: 1.2em;
  overflow: hidden;
}


/* ============================================================
   MARKET — Chips stacked vertically left of a tall thin ruler
   ============================================================ */

/* Market header: underline to match other sections */
body.theme-v2 .board-zone > section:nth-child(2) > .section-title {
  padding-bottom: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Market chips (resource prices) — vertical stack, fill ruler height */
body.theme-v2 .market-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}
body.theme-v2 .market-cell {
  padding: 3px 5px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 3px;
  flex: 1;
}
body.theme-v2 .market-cell .res-name {
  font-size: 0.7rem;
  min-width: 28px;
}
body.theme-v2 .market-cell .res-price {
  font-size: 0.85rem;
  font-weight: 700;
}
/* Hide step dots in compact chips view */
body.theme-v2 .market-cell .dots-down,
body.theme-v2 .market-cell .dots-up {
  display: none;
}
body.theme-v2 .market-cell .res-price-wrap {
  position: static;
}

/* Vertical ruler — tall, thin, rate-tracker style */
body.theme-v2 .market-ruler {
  display: flex;
  flex: 0 0 110px;                    /* zoom scales uniformly               */
  margin-top: 0;
  padding: 2px;
}

body.theme-v2 .ruler-track {
  display: flex;
  flex-direction: column-reverse;   /* $1 at bottom, $10 at top */
  gap: 0;
  width: 100%;
}

body.theme-v2 .ruler-pip {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;      /* pips left-biased, number stays right */
  position: relative;
  padding: 2px 4px;
  min-height: 28px;
  gap: 2px;
  border-radius: 3px;
}

/* Price as large background number — centered in cell */
body.theme-v2 .ruler-price {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-muted);
  opacity: 0.45;
  z-index: 0;
  min-width: 0;
}

/* Resource dots on top of the background numbers */
body.theme-v2 .ruler-dots-row {
  display: flex;
  gap: 2px;
  align-items: center;
  z-index: 1;
  position: relative;
}

/* Ruler dots: font fills the pip; .ruler-long shrinks for 4-char FOOD */
body.theme-v2 .ruler-res-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 900;
  color: #000;
  line-height: 1;
}
body.theme-v2 .ruler-res-dot.ruler-long {
  font-size: 0.48rem;
}
body.theme-v2 .ruler-res-dot.selected {
  width: 26px;
  height: 26px;
  opacity: 1;
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
  font-size: 0.72rem;
}
body.theme-v2 .ruler-res-dot.selected.ruler-long {
  font-size: 0.55rem;
}

/* Rate tracker dots: bigger square pips — largest font that fits */
body.theme-v2 .rnl-dot {
  width: 26px;
  height: 26px;
  font-size: 0.72rem;
  border-radius: 5px;
}
body.theme-v2 .rnl-dot.rnl-long {
  font-size: 0.55rem;                /* FOOD fits in 26px pip                */
}

/* Rate tracker: top track tall enough for 3 stacked 26px pips */
body.theme-v2 .rnl-track:first-child .rnl-slot {
  min-height: 88px;
}

body.theme-v2 .ruler-pip.current {
  background: rgba(255,255,255,0.06);
}
body.theme-v2 .ruler-pip.current .ruler-price {
  opacity: 0.6;
  color: var(--text-primary);
}

/* Grouped ruler: price sections. Each group takes flex:N where N is its
 * number of positions, so all 17 subsections across all groups divide the
 * ruler's total height equally (each sub = 1/17 of the ruler). Parent
 * group borders are the MAJOR dividers between prices. */
body.theme-v2 .ruler-group {
  position: relative;
  border: 1px solid rgba(255,255,255,0.35);   /* major border — between prices */
  border-radius: 4px;
  margin-bottom: 2px;
  overflow: hidden;
  container-type: size;
  min-height: 0;
}

/* Large background price spanning the full group height */
body.theme-v2 .ruler-group-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50cqh;                  /* scales with container height        */
  font-weight: 900;
  color: var(--text-muted);
  opacity: 0.3;
  z-index: 0;
  pointer-events: none;
}

/* Sub-slots: transparent, dots sit on top of the background number.
 * column-reverse so higher PRICE_TRACK positions visually appear higher
 * within the group, matching the outer ruler-track direction. Without
 * this, a resource moving from pos 1 to pos 2 in the $1 group appears
 * to move DOWN in the ruler, which looks like it didn't update. */
body.theme-v2 .ruler-group-slots {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column-reverse;
  height: 100%;
}
/* Subsections divide their parent group equally via flex:1. Combined with
 * group flex:N (N = position count), every sub ends up 1/17 of the ruler.
 * Minor sub borders — major dividers live on .ruler-group. */
body.theme-v2 .ruler-sub {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 1px 3px;
  flex: 1 1 0;
  min-height: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-radius: 0;
  box-sizing: border-box;
}
body.theme-v2 .ruler-sub:last-child {
  border-top: none;                  /* no divider at group edge (topmost in
                                        column-reverse is the last DOM child) */
}
body.theme-v2 .ruler-sub.current {
  background: rgba(88, 166, 255, 0.1);
}

/* ============================================================
   EVENT DECK — card-like, above contracts
   ============================================================ */

body.theme-v2 #event-deck-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
  align-items: stretch;
}
body.theme-v2 #event-deck-area::before {
  content: "EVENTS";
  display: block;
  width: 100%;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-bottom: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

body.theme-v2 .event-card-back {
  min-width: 50px;
  min-height: 50px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

body.theme-v2 .event-card-face {
  min-width: 80px;
  min-height: 50px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  padding: 6px;
}


/* Hide sell picker entirely in v2 — resource is picked via on-card pips,
 * and Hacker Array config lives in the Special Actions panel. */
body.theme-v2 #mp-sell-picker {
  display: none !important;
}
body.theme-v2 #market-chart-wrap {
  display: none !important;
}
body.theme-v2 .market-grid {
  display: none !important;
}


/* ============================================================
   CARDS — Solid, readable
   ============================================================ */

body.theme-v2 .pool-card,
body.theme-v2 .hand-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

/* Resource pip: circles for resources, squares for rates.
 * Font sizes are the largest that keep 3-char text inside the pip; 4-char
 * "FOOD" gets its own scaled-down rule below. */
body.theme-v2 .res-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;               /* circle = resource/cost              */
  font-weight: 700;                  /* match rate tracker pip weight        */
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  font-size: 0.5rem;                 /* 3-char fits in 18px; FOOD via .long */
}
body.theme-v2 .res-pip-rate {
  border-radius: 4px;
}
/* FOOD (4 chars) — scaled per context to fit alongside 3-char normal pips. */
body.theme-v2 .res-pip-long {
  font-size: 0.38rem !important;
}
body.theme-v2 .card-rates .res-pip-long {
  font-size: 3.5cqh !important;      /* FOOD fits in 10cqh pip               */
}
body.theme-v2 .card-costs .res-pip-long {
  font-size: 3cqh !important;
}
body.theme-v2 .contract-req-line .res-pip-long {
  font-size: 0.58rem !important;
}

/* Card costs: pips scale with card; font fills the pip */
body.theme-v2 .card-costs .res-pip {
  width: 9cqh;
  height: 9cqh;
  font-size: 4.5cqh;                 /* 3-char fits in 9cqh pip              */
}
/* Card rates: square pips sized so 4 fit beneath a 2-line title without
 * overflowing the card bounds (e.g. Electronics Factory). */
body.theme-v2 .card-rates .res-pip {
  width: 10cqh;
  height: 10cqh;
  font-size: 5cqh;                   /* 3-char fits in 10cqh pip             */
}

/* Contract requirements: square pips match card rate pip sizing */
body.theme-v2 .contract-req-line .res-pip {
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
}

/* Card sections: fixed heights so all cards align identically */
body.theme-v2 .card-costs {
  font-size: 7cqh;
  color: var(--text-muted);
  min-height: 1.4em;
}
body.theme-v2 .card-name {
  font-weight: 600;
  font-size: 8cqh;
  min-height: 1.3em;
  margin-bottom: 5cqh;
}
body.theme-v2 .card-rates {
  font-size: 7cqh;
  min-height: 1.3em;
}
/* Cost number (for >4 of one resource) */
body.theme-v2 .cost-num {
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 2px;
}

/* Number + pip: fixed-width number so pips always align vertically */
body.theme-v2 .rate-line {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
body.theme-v2 .rate-num {
  display: inline-block;
  width: 2em;
  text-align: right;
  font-weight: 700;
  font-size: 8cqh;
}
body.theme-v2 .card-effect {
  font-size: 6cqh;
  color: var(--accent-violet);
  font-style: italic;
  min-height: 1.1em;
}
body.theme-v2 .card-bottom {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Pool: wrap if needed */
body.theme-v2 .pool-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
body.theme-v2 .pool-card {
  font-size: 0.8rem;
}

/* ============================================================
   SPLIT CARD — build half (top) + sell half (bottom)
   ============================================================ */

body.theme-v2 .card-build-half,
body.theme-v2 .card-sell-half {
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

body.theme-v2 .card-build-half {
  flex: 1;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

body.theme-v2 .card-sell-half {
  padding: 6px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Hover hints */
body.theme-v2 .hand-card:not(.inactive) .card-build-half:hover {
  background: rgba(88, 166, 255, 0.06);
}
body.theme-v2 .hand-card:not(.inactive) .card-sell-half:hover {
  background: rgba(63, 185, 80, 0.06);
}

/* Intent highlighting on selected card */
body.theme-v2 .hand-card.intent-build .card-build-half {
  background: rgba(88, 166, 255, 0.1);
  border-color: var(--accent-blue);
}
body.theme-v2 .hand-card.intent-sell .card-sell-half {
  background: rgba(63, 185, 80, 0.1);
}

/* No-sell placeholder */
body.theme-v2 .card-no-sell {
  color: var(--text-subtle);
  font-size: 0.65rem;
}

/* On-card sell buttons */
body.theme-v2 .card-sell-row {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
}
/* Sell pips: colored background circles like tracker/ruler dots */
body.theme-v2 .card-sell-btn {
  width: 12cqh;
  height: 12cqh;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.4rem;
  font-weight: 900;
  color: #000;
  line-height: 1;
  border: 2px solid transparent;
  cursor: default;
  transition: opacity 0.15s, border-color 0.15s;
}
body.theme-v2 .card-sell-btn.dimmed {
  opacity: 0.35;
}
body.theme-v2 .card-sell-btn.active {
  opacity: 0.7;
  cursor: pointer;
}
body.theme-v2 .card-sell-btn.active:hover {
  opacity: 1;
  border-color: rgba(255,255,255,0.5);
}
body.theme-v2 .card-sell-btn.chosen {
  opacity: 1;
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

/* All cards: fixed px proportions — zoom scales them uniformly.
 * Sized so 4 pool cards fit side-by-side in the board's pool column. */
body.theme-v2 .hand-card,
body.theme-v2 .pool-card {
  height: 275px;
  width: 195px;
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  container-type: size;
}

/* Contracts: taller, reward big + centered, white text */
body.theme-v2 .contracts-grid {
  display: flex;
  gap: 4px;
}
body.theme-v2 .contracts-grid .contract-card {
  flex: 1;                          /* all contracts same width            */
}
body.theme-v2 .contract-card {
  background: var(--bg-card);
  border-left: 2px solid var(--contract-border);
  padding: 8px;
  font-size: 0.8rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}

/* Requirements row — horizontal across the top */
body.theme-v2 .contract-reqs-v2 {
  min-height: 2em;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
body.theme-v2 .contract-req-line {
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}
body.theme-v2 .contract-req-line.met {
  color: var(--accent-green);
}
body.theme-v2 .contract-req-line.unmet {
  color: var(--accent-red);
}

/* Reward always in the same position */
body.theme-v2 .contract-card .contract-reward {
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 800;
  margin-top: auto;                 /* push to bottom of card              */
}
body.theme-v2 .contract-card.selected {
  border-color: var(--accent-blue);
  background: var(--bg-selected);
}


/* ============================================================
   HAND — Big clear cards, uniform size, rate tracker visible
   ============================================================ */

body.theme-v2 .hand-grid {
  display: flex;
  justify-content: center;
  align-items: stretch;        /* uniform height */
  gap: 8px;
  padding: 6px 0;
}

body.theme-v2 .hand-card {
  background: var(--bg-card-hand);
  border-color: rgba(88, 166, 255, 0.18);
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body.theme-v2 .hand-card:hover:not(.inactive) {
  transform: translateY(-6px);
  z-index: 10;
  border-color: var(--accent-blue);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

body.theme-v2 .hand-card.selected {
  transform: translateY(-8px);
  z-index: 11;
  border-color: var(--accent-blue);
  background: color-mix(in srgb, var(--accent-blue) 10%, var(--bg-card-hand));
  box-shadow: 0 4px 16px rgba(88, 166, 255, 0.2);
}

body.theme-v2 .hand-card.inactive {
  opacity: 0.5;
}

/* RATE TRACKER — centered in player zone.
 * Normal cells fit 2 pips wide × 3 tall; center (zero) cell fits 3×3. */
body.theme-v2 .rate-number-line {
  display: block;
  max-width: 760px;
  margin: 0 auto;                   /* centered horizontally in player zone */
}
body.theme-v2 .rnl-slot-wrap {
  min-width: 62px;                   /* 2 × 26px pip + padding/gap          */
}
body.theme-v2 .rnl-slot-wrap.rnl-zero {
  min-width: 92px;                   /* 3 × 26px pip + padding/gap          */
}
body.theme-v2 .rnl-bg-num {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Mute zero-rate chips, not gone */
body.theme-v2 .rate-chip.rate-zero {
  opacity: 0.12;
}

/* Player stats compact */
body.theme-v2 #mp-your-stats {
  font-size: 0.78rem;
  flex-shrink: 0;
}
body.theme-v2 .player-rates-grid {
  gap: 3px;
}


/* ============================================================
   ACTION BAR — above the hand, End Turn bottom-right
   ============================================================ */

/* Action section BEFORE hand, with special actions area above buttons */
body.theme-v2 #action-section {
  order: -1;
}

/* Special building actions: dedicated area above the hand */
body.theme-v2 #mp-patent-actions,
body.theme-v2 #mp-special-toggles {
  margin-bottom: 4px;
  font-size: 0.75rem;
}

/* Reserve space for special actions even when empty */
body.theme-v2 #mp-patent-actions {
  min-height: 0;
}

body.theme-v2 .action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;         /* Build + End Turn both on the right  */
  flex: 1;
}
body.theme-v2 .action-btn {
  padding: 5px 14px;
  font-size: 0.8rem;
}

/* V2: hide individual action buttons, show only the adaptive confirm */
body.theme-v2 #mp-sell-btn,
body.theme-v2 #mp-contract-btn {
  display: none;
}


/* ============================================================
   SPECIAL ACTIONS PANEL — always shows all 6 special actions,
   grayed out when the corresponding patent/building isn't built.
   Sits to the LEFT of the hand.
   ============================================================ */

/* Hand section is a two-column flex row:
 *   - LEFT: #mp-special-panel runs full height of the player zone.
 *   - RIGHT: stats + rate tracker (centered in the remaining width) + hand cards.
 * The special panel pushes the rate tracker to the right on purpose. */
body.theme-v2 #hand-section {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: stretch;
}
body.theme-v2 #mp-special-panel {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
}
body.theme-v2 .player-main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* Reserve fixed space for the build cost / already-built message so the
 * player zone doesn't grow when a card is selected — growth here would
 * push the board up and cut off the bottom of the pool. */
body.theme-v2 #mp-build-estimate {
  min-height: 36px;
  max-height: 36px;
  overflow: hidden;
  margin-top: 6px;
}
body.theme-v2 .special-heading {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 6px 0 2px;
  font-weight: 700;
}
body.theme-v2 .patent-action-row {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.7rem;
  line-height: 1.3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
body.theme-v2 .patent-action-row.locked {
  opacity: 0.35;                     /* not built yet — grayed out          */
  filter: grayscale(1);
  cursor: not-allowed;
}
body.theme-v2 .patent-action-row.inactive {
  opacity: 0.65;                     /* built but not usable this turn      */
}
body.theme-v2 .patent-action-row .action-btn {
  padding: 2px 8px;
  font-size: 0.68rem;
  margin-left: auto;
}
body.theme-v2 .patent-action-row .toggle-select {
  font-size: 0.68rem;
  padding: 1px 4px;
}


/* ============================================================
   FLYING CARD CLONES
   ============================================================ */

/* Clones are appended to <body> outside #game-wrapper, so card-name/card-rates
 * `cqh` units fall back to the viewport (hundreds of px) instead of the card.
 * Giving the clone itself `container-type: size` anchors cqh to its own fixed
 * inline width/height, so animated text matches real cards. */
body.theme-v2 .flying-card {
  container-type: size;
  overflow: hidden;
}


/* ============================================================
   TOGGLE BUTTON
   ============================================================ */

#theme-toggle-btn {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  margin-left: auto;
}
#theme-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
}
body.theme-v2 #theme-toggle-btn {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}
