/* The System — "indelible ink on ballot paper"
   Structure & officialdom: indigo ink on paper stock.
   Party noise: four screen-print spot colors.
   Type: Archivo Black (poster) / Public Sans (bureau) / Courier Prime (voter roll). */

:root {
  --ink: #2a2456;
  --ink-press: #1d1840; /* ink where it pools: hovers, banner fills */
  --muted: #6e6884;
  --paper: #f0ebdd;
  --paper2: #e5dec9;
  --line: #c9c2ab;

  --green: #1e7a46;
  --red: #c03a2b;
  --blue: #1d5fa0;
  --yellow: #dea815;
  --purple: #6c3fa0;
  --funds: #1e7a46;
  --clout: #c03a2b;
  --media: #1d5fa0;
  --trust: #dea815;

  --display: 'Archivo Black', 'Arial Black', sans-serif;
  --body: 'Public Sans', system-ui, sans-serif;
  --mono: 'Courier Prime', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
/* No double-tap-zoom delay on anything you tap during play. */
button, select, label, .zone, .slot, .voter-card, .player-card, .chip { touch-action: manipulation; }
.hidden { display: none !important; }
.screen { min-height: 100vh; min-height: 100dvh; }

button {
  font-family: var(--body);
  font-weight: 700;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
}
button:hover { background: var(--paper2); }
button.primary {
  background: var(--ink);
  color: var(--paper);
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 100%;
  margin-top: 8px;
}
button.primary:hover { background: var(--ink-press); }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }

/* ---------- Home / Lobby ---------- */
#screen-home, #screen-lobby {
  display: flex; align-items: center; justify-content: center;
}
.home-box {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 40px 48px;
  text-align: center;
  width: 380px;
}
.home-box h1 {
  font-family: var(--display);
  font-size: 3.4rem;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--ink);
  /* misregistered overprint: red and blue plates a hair off the ink plate */
  text-shadow: 3px 2px 0 var(--red), -3px -2px 0 var(--blue);
}
.home-box h2 { font-family: var(--display); font-size: 1.4rem; letter-spacing: 1px; }
.tagline { color: var(--muted); margin: 10px 0 22px; font-size: 0.9rem; }
.home-box input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  color: var(--ink); font-size: 1rem; text-align: center;
  font-family: var(--body);
}
.home-box input::placeholder { color: var(--muted); }
/* Credit to the original game: one link, styled as a stamped ticket. */
.credit {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 12px;
  margin-top: 18px; padding: 10px 12px;
  border: 1.5px solid var(--ink); border-radius: 2px;
  background: var(--paper2); color: var(--ink);
  text-decoration: none; text-align: left;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
}
.credit:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.credit:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.credit:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.credit-stamp {
  flex: none; padding: 3px 5px;
  border: 1.5px solid var(--red); border-radius: 2px; color: var(--red);
  font-family: var(--mono); font-weight: 700; font-size: 0.58rem;
  line-height: 1.15; letter-spacing: .5px; text-transform: uppercase; text-align: center;
  transform: rotate(-6deg);
  grid-row: span 2;
}
.credit-text { min-width: 0; font-size: 0.85rem; line-height: 1.3; }
.credit-text b { font-family: var(--display); font-weight: 400; letter-spacing: .5px; }
.credit-text small { display: block; color: var(--muted); font-size: 0.68rem; }
.credit-cta {
  justify-self: start; padding: 4px 8px; border-radius: 2px;
  background: var(--ink); color: var(--paper);
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}
.credit:hover .credit-cta { background: var(--red); }
#code-input { text-transform: uppercase; letter-spacing: 4px; font-family: var(--mono); font-weight: 700; }
.join-row { display: flex; gap: 8px; margin-top: 12px; }
.join-row input { flex: 1; margin: 0; }
.error { color: var(--red); margin-top: 10px; min-height: 1.2em; font-size: 0.85rem; font-weight: 600; }
.code { font-family: var(--mono); font-weight: 700; letter-spacing: 5px; color: var(--red); }
#lobby-players { list-style: none; margin: 12px 0 20px; text-align: left; }
#lobby-players li {
  padding: 8px 12px; margin-bottom: 6px;
  background: var(--paper2);
  border-left: 4px solid var(--ink);
  font-weight: 600;
}
#lobby-players li .host-tag {
  font-family: var(--mono); font-size: 0.75rem; font-weight: 700;
  color: var(--red); letter-spacing: 1px;
}
#lobby-players li.disconnected { opacity: 0.4; }

/* Home: three choices (create / open tables / code), plus the invite card from a shared link */
#screen-home, #screen-tables { display: flex; align-items: center; justify-content: center; }
.choices { display: grid; gap: 10px; margin-top: 4px; }
.choice {
  position: relative; display: block; width: 100%; margin: 0; padding: 12px 14px;
  text-align: left; border: 2px solid var(--ink); background: var(--paper2); color: var(--ink);
}
.choice b { display: block; font-size: 1rem; }
.choice small { display: block; font-weight: 400; font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.choice.primary { background: var(--ink); color: var(--paper); }
.choice:not(.primary):not(.choice-code):hover { box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -1px); }
.choice.primary small { text-transform: none; letter-spacing: 0;  color: color-mix(in srgb, var(--paper) 75%, transparent); }
.choice-arrow { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; }
.choice-code { background: transparent; border-style: dashed; cursor: default; }
.choice-code .join-row { margin-top: 6px; }
.ot-count { margin-left: 6px; padding: 1px 6px; font-size: 0.72rem; font-family: var(--mono); background: var(--green); color: var(--paper); vertical-align: 2px; }
.ot-count:empty { display: none; }
.invite-card { margin: 4px 0 6px; padding: 12px 14px; border: 2px solid var(--yellow); background: color-mix(in srgb, var(--yellow) 18%, var(--paper)); }
.invite-card p { margin: 0; font-size: 0.9rem; }
.invite-card .primary { margin-top: 10px; }
.choice-or { margin: 14px 0 0 !important; font-size: 0.75rem !important; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* Open tables screen */
.tables-box { text-align: left; position: relative; }
.tables-box h2, .tables-box .tagline { text-align: center; }
.back-btn { padding: 4px 0; font-size: 0.85rem; margin-bottom: 8px; }
.ot-you { font-size: 0.85rem; color: var(--muted); margin: -10px 0 14px; text-align: center; }
.ot-you .link-btn { padding: 0; font-size: 0.85rem; text-decoration: underline; }
.ot-empty { color: var(--muted); font-size: 0.85rem; margin: 4px 0 14px; text-align: center; }
#open-tables-list { list-style: none; margin: 0 0 12px; max-height: 50vh; overflow-y: auto; }
#open-tables-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 12px; margin-bottom: 8px;
  background: var(--paper2); border-left: 4px solid var(--green);
}
.ot-host { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-seats { font-family: var(--mono); font-weight: 700; color: var(--muted); }
#open-tables-list button { padding: 6px 14px; margin: 0; }
.open-row {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; cursor: pointer;
  padding: 10px 12px; margin: 0 0 16px; border: 2px dashed var(--line); font-size: 0.9rem;
}
.home-box .open-row input { margin: 3px 0 0; padding: 0; width: 18px; height: 18px; accent-color: var(--ink); flex: none; }
.open-row small { color: var(--muted); }
.open-note { color: var(--green); font-weight: 600; font-size: 0.85rem; margin: 0 0 16px; }

/* ---------- Game layout ---------- */
#phase-banner {
  text-align: center; padding: 12px 10px;
  font-family: var(--display);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: var(--paper);
  color: var(--ink);
  border-bottom: 3px solid var(--ink);
}
#phase-banner.your-turn {
  background: var(--ink);
  color: var(--paper);
  border-bottom-color: var(--yellow);
}
#game-layout {
  display: grid; grid-template-columns: 240px 1fr 270px;
  gap: 14px; padding: 14px; max-width: 1400px; margin: 0 auto;
}
/* minmax(0, …) so a wide child (the phone's swipeable dossier strip) scrolls inside
   its track instead of stretching the whole column past the screen. */
@media (max-width: 1000px) { #game-layout { grid-template-columns: minmax(0, 1fr); } }
#left-col, #board-wrap, #log-panel { min-width: 0; }

/* Players panel — party dossiers */
#left-col { display: flex; flex-direction: column; gap: 14px; }
#players-panel { display: flex; flex-direction: column; gap: 10px; }
.player-card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-left-width: 8px;
  border-radius: 2px;
  padding: 10px 12px;
}
.player-card { position: relative; }
.player-card.active { box-shadow: 4px 4px 0 var(--ink); background: #f6f0de; }
.turn-tag {
  position: absolute; top: -9px; right: 8px;
  background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  padding: 1px 6px; border-radius: 2px;
}
.score-row { font-size: 0.75rem; color: var(--muted); margin: -2px 0 6px; font-variant-numeric: tabular-nums; }
.score-row b { color: var(--ink); font-weight: 800; }
.res-total { font-size: 0.75rem; color: var(--muted); }
.player-card .pname { font-weight: 800; margin-bottom: 6px; }
.player-card .you-tag {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 1px; color: var(--red);
}
.res-row { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.8rem; align-items: center; }
.res-chip {
  padding: 2px 8px; border-radius: 2px;
  color: var(--paper); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.res-chip.funds { background: var(--funds); }
.res-chip.clout { background: var(--clout); }
.res-chip.media { background: var(--media); }
.res-chip.trust { background: var(--trust); color: var(--ink-press); }
.manifesto-row { margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
.cap-warn, .res-total.cap-warn { color: var(--red); font-size: 0.75rem; font-weight: 700; }

/* ---------- Board — the constituency map ----------
   A surveyed electoral map, not a diagram: relief, rivers, woods and roads in a
   static terrain sheet (map-terrain.svg, built by scripts/build-terrain.js), the
   districts as translucent washes over it, and an ink layer on top with the sea,
   cased district borders and the held-seat bands. District SHAPES live in
   client.js (ZONE_SKELETON → irregular ZONE_POLY); the client applies each one
   as an inline clip-path and draws the same points as ink, so the click boundary
   and the drawn border can never drift apart. */
#board {
  position: relative;
  aspect-ratio: 1;
  /* Sized to the viewport too, so on a laptop screen the market sits under the board
     without scrolling between "pick a card" and "pick a constituency". */
  max-width: min(680px, max(420px, calc(100vh - 250px)));
  margin: 0 auto;
  border: 3px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 3px;
  background: #ebe3c8 url('map-terrain.svg') center / 100% 100% no-repeat;
  box-shadow: 8px 8px 0 color-mix(in srgb, var(--ink) 18%, transparent);
}
/* Each zone spans the whole sheet, clipped (inline, from client.js) to its territory.
   clip-path clips pointer events too, so each shape is its own click target.
   Fills are washes, so the terrain reads through. */
.zone { position: absolute; inset: 0; transition: background-color 0.25s; }
.zone[data-zone='NW'], .zone[data-zone='Z6'] { background-color: rgba(214, 190, 128, 0.42); }
.zone[data-zone='N'],  .zone[data-zone='Z1'] { background-color: rgba(156, 182, 120, 0.40); }
.zone[data-zone='NE'], .zone[data-zone='Z2'] { background-color: rgba(222, 160, 120, 0.38); }
.zone[data-zone='W'],  .zone[data-zone='Z5'] { background-color: rgba(184, 170, 206, 0.38); }
.zone[data-zone='C'],  .zone[data-zone='Z7'] { background-color: rgba(120, 110, 150, 0.30); }
.zone[data-zone='E'],  .zone[data-zone='Z3'] { background-color: rgba(140, 186, 180, 0.40); }
.zone[data-zone='SW'], .zone[data-zone='Z4'] { background-color: rgba(206, 206, 130, 0.40); }
.zone[data-zone='S']                          { background-color: rgba(226, 184, 140, 0.38); }
.zone[data-zone='SE']                         { background-color: rgba(200, 150, 170, 0.36); }

/* Ink layer: sea, held-seat bands and borders. Above the fills, below labels/pegs. */
.map-ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; overflow: visible; }
.map-ink .msea { fill: #9fbccd; }
/* Depth rings: the coastline stroked wide and faint, clipped to the sea. */
.map-ink .mdepth { fill: none; stroke: #e3eef3; stroke-linejoin: round; }
.map-ink .mdepth.d1 { stroke-width: 1.4; opacity: 0.55; }
.map-ink .mdepth.d2 { stroke-width: 3.2; opacity: 0.28; }
.map-ink .mdepth.d3 { stroke-width: 5.6; opacity: 0.16; }
.map-ink .mdepth.d4 { stroke-width: 9; opacity: 0.10; }
.map-ink .msea-waves { fill: url(#mwaves); }
.map-ink .mcoast { fill: none; stroke: #2f4a63; stroke-width: 0.45; stroke-linejoin: round; }
.map-ink .mborder-casing { fill: none; stroke: #f4eedc; stroke-width: 1.15; opacity: 0.75; stroke-linejoin: round; stroke-linecap: round; }
.map-ink .mborder { fill: none; stroke: var(--ink); stroke-width: 0.55; stroke-linejoin: round; stroke-linecap: round; }
/* A held seat gets a broad inner band in the holder's colour, like a marked-up map. */
.map-ink .mband { fill: none; stroke-width: 2.6; opacity: 0.55; stroke-linejoin: round; }
.map-ink .band-green  { stroke: var(--green); }
.map-ink .band-red    { stroke: var(--red); }
.map-ink .band-blue   { stroke: var(--blue); }
.map-ink .band-yellow { stroke: var(--yellow); }
.map-ink .band-purple { stroke: var(--purple); }

.zgroup[data-zone='Z1'] .zbody { left: 50%; top: 7%;  transform: translateX(-50%); text-align: center; }
.zgroup[data-zone='Z2'] .zbody { right: 9%; top: 9%;  text-align: right; }
.zgroup[data-zone='Z3'] .zbody { right: 9%; top: 79%; text-align: right; }
.zgroup[data-zone='Z4'] .zbody { left: 50%; top: 84%; transform: translateX(-50%); text-align: center; }
.zgroup[data-zone='Z5'] .zbody { left: 9%;  top: 79%; }
.zgroup[data-zone='Z6'] .zbody { left: 9%;  top: 9%;  }
.zgroup[data-zone='Z7'] .zbody { left: 50%; top: 42%; transform: translateX(-50%); text-align: center; }

/* Election-night wash: the majority holder tints the whole territory.
   Each owned-* class only declares its ideology color (--zc); the actual
   wash is one shared color-mix rule, so palette retunes propagate. */
.zone.owned-green  { --zc: var(--green); }
.zone.owned-red    { --zc: var(--red); }
.zone.owned-blue   { --zc: var(--blue); }
.zone.owned-yellow { --zc: var(--yellow); }
.zone.owned-purple { --zc: var(--purple); }
.zone[class*='owned-'] { background-color: color-mix(in srgb, var(--zc) 24%, transparent); }

/* Legal targets light up (placement, gerrymander destinations, perks).
   Owned zones keep their ideology tint mixed INTO the highlight, so
   ownership stays readable while targeting. background-color only —
   never the background shorthand, or the .blocked hatch image is erased. */
.zone.selectable { cursor: pointer; background-color: rgba(245, 222, 120, 0.5); }
.zone.selectable:hover { background-color: rgba(240, 206, 80, 0.62); }
.zone.selectable[class*='owned-'] { background-color: color-mix(in srgb, var(--zc) 22%, rgba(245, 222, 120, 0.5)); }
.zone.selectable[class*='owned-']:hover { background-color: color-mix(in srgb, var(--zc) 22%, rgba(240, 206, 80, 0.62)); }

/* Labels + pegs ride in an UNCLIPPED overlay above the fills, so long district
   names and edge pegs are never cut off by a territory's clip-path. Only the
   peg dots take clicks; everything else lets clicks fall through to the map. */
#board-overlay { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.zgroup { position: absolute; inset: 0; }

/* Zone label plates, pinned near each territory's outer corner on a translucent
   ballot-paper chit so they read over pegs and colour washes alike. */
.zone .zbody, /* legacy mobile-fallback selector */
.zgroup .zbody {
  position: absolute;
  z-index: 2; /* label plates ride above the pegs so text is never occluded */
  background: rgba(240, 235, 221, 0.82);
  padding: 2px 6px; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(42, 36, 86, 0.12);
}
.zgroup[data-zone='NW'] .zbody { left: 10%; top: 11%;  }
.zgroup[data-zone='N']  .zbody { left: 50%; top: 17%;  transform: translateX(-50%); text-align: center; }
.zgroup[data-zone='NE'] .zbody { right: 10%; top: 11%;  text-align: right; }
.zgroup[data-zone='W']  .zbody { left: 6.5%; top: 25%; }
.zgroup[data-zone='C']  .zbody { left: 50%; top: 34%; transform: translateX(-50%); text-align: center; }
.zgroup[data-zone='E']  .zbody { right: 6.5%; top: 33%; text-align: right; }
.zgroup[data-zone='SW'] .zbody { left: 10%; bottom: 11%; }
.zgroup[data-zone='S']  .zbody { left: 50%; top: 63%; transform: translateX(-50%); text-align: center; }
.zgroup[data-zone='SE'] .zbody { right: 10%; bottom: 11%; text-align: right; }

.zgroup .zname {
  font-weight: 800; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 1.2px;
}
.zgroup[data-zone='C'] .zname { font-size: 0.64rem; letter-spacing: 0.5px; }
.zgroup .zreq {
  font-family: var(--mono);
  color: var(--muted); font-size: 0.62rem;
}

/* Scattered voter pegs — one full-board overlay per zone; dots re-enable clicks. */
.zgroup .zpegs { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
/* The returning officer's stamp: outlined, inked, slightly off-square.
   Prefixed with .zgroup so it outranks the generic .bg-* fill utility the tag
   also carries (which we want only for its colour, not its background). */
.zgroup .captured-tag {
  display: inline-block; margin-top: 3px;
  font-family: var(--display);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 7px;
  transform: rotate(-4deg);
  border: 2px solid currentColor;
  border-radius: 3px;
  background: transparent;
}
.captured-tag.bg-green  { color: var(--green); }
.captured-tag.bg-red    { color: var(--red); }
.captured-tag.bg-blue   { color: var(--blue); }
.captured-tag.bg-yellow { color: #a87d0a; }
.captured-tag.bg-purple { color: var(--purple); }

/* Coalition stamp: one tag, two party colours, joint custody (DD-23). */
.zgroup .coalition-tag { padding: 0; border-color: var(--ink); color: var(--ink); pointer-events: auto; }
.coalition-tag > span { display: inline-block; padding: 2px 5px; background: transparent; }
.coalition-tag > span.bg-green  { color: var(--green); }
.coalition-tag > span.bg-red    { color: var(--red); }
.coalition-tag > span.bg-blue   { color: var(--blue); }
.coalition-tag > span.bg-yellow { color: #a87d0a; }
.coalition-tag > span.bg-purple { color: var(--purple); }
.coalition-tag > span + span { border-left: 2px solid currentColor; }
.coalition-leave {
  border: none; background: transparent; color: var(--ink);
  font-size: 0.6rem; padding: 2px 5px; cursor: pointer; min-height: 0;
}
.coalition-leave:hover { color: var(--red); }

/* Home turf chip: the zone's local power, cursive like a ward boss's ledger note (DD-24). */
.zgroup .turf-chip {
  display: inline-block; margin-top: 2px;
  font-size: 0.58rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  color: var(--ink);
  pointer-events: auto;
  cursor: help;
}
.turf-use {
  border: 1px solid var(--ink); background: var(--paper2); color: var(--ink);
  font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 5px; margin-left: 3px; border-radius: 6px; cursor: pointer; min-height: 0;
}
.turf-use:hover { background: var(--ink); color: var(--paper); }

/* Zone requirement chip: the ward's terms of capture, pinned like a court notice (DD-26). */
.zgroup .req-chip {
  display: inline-block; margin-top: 2px;
  font-size: 0.58rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: color-mix(in srgb, var(--paper2) 80%, transparent);
  color: var(--ink);
  pointer-events: auto;
  cursor: help;
}
#requirement-panel .conspiracy-card.picked { outline: 2px solid var(--ink); }
#req-hand { display: flex; flex-wrap: wrap; gap: 8px; }

/* Hidden objective: a folded note only its owner reads (DD-25). */
#objective-card {
  background: var(--paper2);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 8px;
}
.objective-title { font-family: var(--display); text-transform: uppercase; letter-spacing: 1px; font-size: 0.8rem; }
.objective-text { font-size: 0.72rem; margin: 3px 0; }
.objective-bonus { font-size: 0.62rem; opacity: 0.7; font-style: italic; }
.result-objective { font-size: 0.72rem; opacity: 0.85; margin: -4px 0 6px 12px; }

.slot {
  position: absolute;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--paper2);
  border: 1.5px solid var(--line);
  /* inert pegs let a click fall through to the territory (so you can still place
     a voter in a zone that already holds pegs); only interactive pegs grab it. */
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 1px rgba(29, 24, 64, 0.25);
}
.slot.majority { box-shadow: 0 0 0 2px var(--ink), 0 1px 1px rgba(29, 24, 64, 0.25); }
/* Volatile Area — the black circle. Dangerous ground. */
.slot.volatile {
  border: 2px solid var(--ink-press);
  background: repeating-linear-gradient(45deg, var(--paper2), var(--paper2) 2px, var(--ink-press) 2px, var(--ink-press) 3.5px);
}
.slot.volatile.peg-green  { background: var(--green); }
.slot.volatile.peg-red    { background: var(--red); }
.slot.volatile.peg-blue   { background: var(--blue); }
.slot.volatile.peg-yellow { background: var(--yellow); }
.slot.volatile.peg-purple { background: var(--purple); }
/* Gerrymander: pegs you may pick up, and the one in hand */
.slot.movable { cursor: pointer; outline: 2px dashed var(--ink); outline-offset: 1px; pointer-events: auto; z-index: 5; }
.slot.movable:hover { transform: translate(-50%, -50%) scale(1.35); z-index: 6; }
.slot.picked { outline: 3px solid var(--red); outline-offset: 1px; transform: translate(-50%, -50%) scale(1.35); pointer-events: auto; z-index: 6; }
/* Interactive pegs get an invisible 36px hit area — the dot itself is 12–15px,
   far below a fingertip. */
.slot.movable::after, .slot.picked::after, .slot.trap-target::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 36px; height: 36px; transform: translate(-50%, -50%); border-radius: 50%;
}
/* Volatile Area as a gerrymander trap destination */
.slot.trap-target { cursor: pointer; outline: 2px dashed var(--red); outline-offset: 2px; animation: trap-pulse 1s ease-in-out infinite; pointer-events: auto; z-index: 5; }
.slot.trap-target:hover { transform: translate(-50%, -50%) scale(1.4); z-index: 6; }
@keyframes trap-pulse {
  0%, 100% { outline-color: var(--red); }
  50% { outline-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .slot.trap-target { animation: none; }
}
.peg-green  { background: var(--green);  border-color: var(--green); }
.peg-red    { background: var(--red);    border-color: var(--red); }
.peg-blue   { background: var(--blue);   border-color: var(--blue); }
.peg-yellow { background: var(--yellow); border-color: var(--yellow); }
.peg-purple { background: var(--purple); border-color: var(--purple); }
.border-green  { border-left-color: var(--green) !important; }
.border-red    { border-left-color: var(--red) !important; }
.border-blue   { border-left-color: var(--blue) !important; }
.border-yellow { border-left-color: var(--yellow) !important; }
.border-purple { border-left-color: var(--purple) !important; }
.bg-green  { background: var(--green); }
.bg-red    { background: var(--red); }
.bg-blue   { background: var(--blue); }
.bg-yellow { background: var(--yellow); }
.bg-purple { background: var(--purple); }

/* Policy outcome — the gazette notice */
#policy-outcome {
  margin-top: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 12px;
}
#policy-outcome .outcome-line { font-size: 0.85rem; margin-bottom: 8px; }

/* The Market — the ballot counter */
#hq-mat {
  margin-top: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 12px;
}
.hq-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
#hq-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.voter-card {
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-top-style: dashed; /* tear-off ballot chit */
  border-radius: 2px;
  padding: 10px 14px; min-width: 120px; text-align: center;
}
.voter-card .vcount { font-family: var(--display); font-size: 1.35rem; }
.voter-card .vcost { margin-top: 6px; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.voter-card.buyable { cursor: pointer; }
.voter-card.buyable:hover { background: #efe4bb; }
.voter-card.selected { background: #efe4bb; box-shadow: 4px 4px 0 var(--ink); }
.voter-card.unaffordable { opacity: 0.4; border-color: var(--line); }
#action-bar { margin-top: 12px; display: flex; align-items: center; gap: 14px; }
#action-hint { color: var(--muted); font-size: 0.85rem; flex: 1; }
#btn-end-turn { width: auto; margin: 0; }

/* Log — the typewritten campaign trail */
#log-panel {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 12px; max-height: 75vh;
}
#log {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  overflow-y: auto; max-height: 65vh;
  display: flex; flex-direction: column-reverse;
}
#log p { padding: 4px 0; border-bottom: 1px dotted var(--line); }

/* Modals — dealt onto the table */
.modal {
  position: fixed; inset: 0;
  background: rgba(29, 24, 64, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink-press);
  padding: 28px 32px; width: 400px; text-align: center;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  animation: deal 0.22s ease-out;
}
@keyframes deal {
  from { transform: translateY(14px) rotate(-0.5deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .modal-box { animation: none; }
}
.modal-box.wide { width: 560px; max-width: 92vw; }
.modal-box { position: relative; }
.modal-close {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; padding: 0;
  border: none; background: transparent;
  font-size: 1rem; font-weight: 700; color: var(--muted);
  line-height: 1;
}
.modal-close:hover { background: var(--paper2); color: var(--ink); }
.modal-box h3 {
  font-family: var(--display);
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
.question { font-size: 1.05rem; margin: 14px 0 18px; line-height: 1.5; font-weight: 600; }
#policy-options { display: flex; flex-direction: column; gap: 10px; }
.policy-btn { padding: 14px; text-align: left; line-height: 1.4; font-weight: 600; }
.policy-btn:hover:enabled { background: var(--paper2); box-shadow: 3px 3px 0 var(--ink); }
.policy-btn:disabled { cursor: default; }
.policy-btn.spectator { border-style: dashed; color: var(--ink); opacity: 0.85; }
.policy-btn.chosen { background: #f3ecd2; box-shadow: 4px 4px 0 var(--ink); }
.policy-btn.dimmed { opacity: 0.4; border-color: var(--line); }
.policy-btn .btn-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; font-size: 0.8rem; }
#policy-note { font-family: var(--mono); font-size: 0.78rem; }
.resource-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.res-btn { font-weight: 700; color: var(--paper); border-color: transparent; }
.res-btn.funds { background: var(--funds); }
.res-btn.clout { background: var(--clout); }
.res-btn.media { background: var(--media); }
.res-btn.trust { background: var(--trust); color: var(--ink-press); }
.res-btn:hover { border-color: var(--ink); }
.res-btn { position: relative; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.res-btn.picked { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset, 0 2px 6px rgba(0,0,0,0.25); transform: translateY(-1px); }
.res-count { display: inline-block; margin-left: 6px; font-size: 0.78rem; font-weight: 900; }
.discard-row { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.discard-row .stepper { display: flex; gap: 8px; align-items: center; }
.discard-row .stepper b { font-variant-numeric: tabular-nums; min-width: 1.5ch; }
.discard-row button { padding: 4px 12px; }
#results { margin: 16px 0; }
.result-row {
  display: flex; justify-content: space-between;
  padding: 8px 12px; background: var(--paper2);
  border-left: 4px solid var(--line);
  margin-bottom: 6px; font-weight: 600;
}
.result-row.winner { border-left-color: var(--red); background: #f3ecd2; }

/* Action bar extras */
#volatile-toggle {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}
#btn-skip-gerry, #btn-trade { width: auto; margin: 0; white-space: nowrap; }

/* Trade offers — telegrams pinned to the left column */
#trade-offers {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 12px;
}
.trade-offer {
  border: 1px dashed var(--line);
  padding: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.trade-offer .offer-line { margin-bottom: 4px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.trade-offer .offer-actions { display: flex; gap: 6px; margin-top: 6px; }
.trade-offer .offer-actions button { padding: 4px 10px; font-size: 0.75rem; width: auto; margin: 0; }

/* Trade modal */
.trade-partner-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 10px 0 16px; font-weight: 700; }
#trade-partner {
  font-family: var(--body); font-weight: 700; font-size: 0.95rem;
  padding: 6px 10px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--paper); color: var(--ink);
}
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: left; }
@media (max-width: 600px) { .trade-cols { grid-template-columns: 1fr; } }

/* Conspiracies — the back room */
#conspiracy-panel {
  margin-top: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 12px;
}
#conspiracy-hand { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.conspiracy-card {
  background: #efe9d6;
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 8px 10px;
  width: 160px;
  position: relative;
}
.conspiracy-card.reaction { border-style: dashed; background: #eae4f2; }
.cons-title { font-family: var(--display); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.cons-text { font-size: 0.72rem; color: var(--muted); line-height: 1.35; margin-bottom: 6px; }
.cons-tag { font-family: var(--mono); font-size: 0.62rem; font-weight: 700; color: var(--purple); }
.cons-play { width: 100%; margin: 0; padding: 5px; font-size: 0.78rem; background: var(--ink); color: var(--paper); }
.cons-play:hover { background: var(--ink-press); }
.cons-buy { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.res-pick { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.res-pick .res-btn { padding: 4px 9px; font-size: 0.72rem; width: auto; margin: 0; }
.res-pick .res-btn:disabled { opacity: 0.4; }
.target-banner {
  background: var(--ink); color: var(--paper);
  font-weight: 700; font-size: 0.82rem;
  padding: 8px 10px; border-radius: 2px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.target-banner button { padding: 3px 10px; font-size: 0.72rem; width: auto; margin: 0; }
.peek-note { font-family: var(--mono); font-size: 0.78rem; margin-bottom: 8px; }

/* Perks — the party machine */
#perks-bar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 0.82rem;
}
#perks-bar button { padding: 5px 12px; font-size: 0.78rem; width: auto; margin: 0; }
#perks-bar select {
  font-family: var(--body); font-weight: 700; font-size: 0.78rem;
  padding: 3px 6px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--paper); color: var(--ink);
}
.bank-trade { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.perk-hint { font-family: var(--mono); font-weight: 700; font-size: 0.78rem; display: inline-flex; align-items: center; gap: 8px; }

/* Manifesto tracks with unlocked-perk pips */
.manifesto-row .track { margin-right: 6px; white-space: nowrap; }
.manifesto-row .track.funds { color: var(--funds); }
.manifesto-row .track.clout { color: var(--clout); }
.manifesto-row .track.media { color: var(--media); }
.manifesto-row .track.trust { color: #a87d0a; }
.perk-pips {
  font-family: var(--mono); font-size: 0.62rem;
  border: 1px solid currentColor; border-radius: 2px;
  padding: 0 3px;
}
.discount-tag { color: var(--green); font-weight: 800; margin-left: 2px; }

/* Elites — the inner circle */
#elite-panel {
  margin-top: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 12px;
}
#elite-list { display: flex; gap: 10px; flex-wrap: wrap; }
.elite-card {
  background: #f1ead4;
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 8px 10px;
  width: 170px;
}
.elite-card.mine {
  border-width: 3px; box-shadow: 4px 4px 0 var(--ink); width: auto; max-width: 340px;
  background: #f7e9b0; border-color: #a8791a;
}
.elite-card.eligible { border-color: var(--red); }
.elite-req { font-family: var(--mono); font-size: 0.66rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.elite-flow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 6px; font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
}
.elite-flow select { font-family: var(--mono); font-size: 0.72rem; }
.chip {
  padding: 3px 8px; border: 2px solid var(--ink); border-radius: 2px;
  background: var(--paper); font-family: var(--mono); font-size: 0.7rem; font-weight: 700; cursor: pointer;
}
.chip.on { background: var(--ink); color: var(--paper); }
.spy-hands { margin-top: 8px; border-top: 1px dashed var(--muted); padding-top: 6px; }
.cons-subtitle { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; color: var(--purple); margin-bottom: 4px; }
.spy-row { font-size: 0.74rem; margin: 2px 0; }
#reckoning {
  margin: 14px 0; padding: 12px 14px; border: 3px solid var(--ink);
  background: #1c1a17; color: var(--paper); border-radius: 2px;
}
.reck-title { font-weight: 800; font-size: 0.95rem; margin-bottom: 6px; }
.reck-text { font-size: 0.86rem; line-height: 1.4; font-style: italic; }
.reck-who { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; color: var(--gold, #d8b24a); margin-top: 6px; }
.link-btn {
  border: none; background: none; padding: 0; margin-left: 8px;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
  text-decoration: underline; cursor: pointer; color: var(--muted);
}
.link-btn:hover { color: var(--ink); background: none; }

/* Mini badges on player dossiers */
.mini-badge {
  font-family: var(--mono); font-size: 0.62rem; font-weight: 700;
  padding: 1px 5px; border-radius: 2px; margin-left: 4px;
  border: 1px solid var(--ink);
}
.mini-badge.conspiracy { background: #eae4f2; color: var(--purple); border-color: var(--purple); }
.mini-badge.iou { background: var(--red); color: var(--paper); border-color: var(--ink-press); }
.player-card.targetable { cursor: pointer; outline: 2px dashed var(--red); outline-offset: 2px; }
.player-card.targetable:hover { background: #f3ecd2; }

/* Frozen (conspiracy-blocked) zone — hatched over whatever wash it carries */
.zone.blocked { background-image: repeating-linear-gradient(45deg, transparent, transparent 6px, color-mix(in srgb, var(--ink) 10%, transparent) 6px, color-mix(in srgb, var(--ink) 10%, transparent) 12px); }

/* Trade card checkboxes + chips */
.trade-cards { margin-top: 10px; }
.cards-label { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.card-check { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; margin-bottom: 3px; cursor: pointer; }
.res-chip.conspiracy-chip { background: var(--purple); }
.muted-chip { color: var(--muted); font-size: 0.78rem; }

/* Auction modal */
#modal-auction { z-index: 64; }
.auction-buttons { display: flex; gap: 10px; margin-top: 12px; }
.auction-buttons #btn-bid { flex: 1; margin: 0; }
.auction-buttons #btn-pass { width: auto; margin: 0; }
#bid-amount { font-variant-numeric: tabular-nums; min-width: 2ch; display: inline-block; text-align: center; }

/* Reaction modal */
#modal-reaction { z-index: 65; }
#reaction-cards { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.react-btn { width: 100%; margin: 0; }

/* Headline modal — stop the presses */
#modal-headline { z-index: 60; }
.headline-box { border-width: 4px; }
.headline-masthead {
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 4px;
  border-bottom: 3px double var(--ink);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.headline-box h3 { font-size: 1.5rem; }
.headline-summary { font-family: var(--mono); font-weight: 700; font-size: 0.85rem; }

/* Toast — the urgent telegram */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: var(--paper);
  font-family: var(--mono); font-weight: 700;
  padding: 10px 22px; border-radius: 2px;
  border: 2px solid var(--ink-press);
  z-index: 100; font-size: 0.85rem;
}

/* Notifications — dispatches pinned to the corner; urgent ones want your move. */
#notify-stack {
  position: fixed; top: 64px; right: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}
.notice {
  pointer-events: auto; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--ink); border-left-width: 8px; border-radius: 2px;
  padding: 9px 12px;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.35;
  box-shadow: 3px 3px 0 var(--ink-press);
  animation: deal 0.25s ease-out;
}
.notice.urgent { border-left-color: var(--red); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .notice { animation: none; } }
@media (max-width: 600px), (max-height: 500px) {
  #notify-stack { top: 48px; left: 12px; right: 12px; width: auto; }
}

/* Connection lost: say so, rather than let a stale table pass for a quiet one. */
#conn-status {
  position: fixed; top: 0; left: 0; right: 0; z-index: 110;
  background: var(--ink-press); color: var(--paper);
  font-family: var(--mono); font-weight: 700; font-size: 0.8rem;
  text-align: center; padding: 6px 12px;
}

/* Log lines that just arrived */
#log p.fresh { background: color-mix(in srgb, var(--yellow) 30%, transparent); font-weight: 700; }

/* Small screens: the map stays a scaled square that fills the column, with
   smaller pegs and labels so the scatter still reads. */
@media (max-width: 760px) {
  #board { max-width: none; }
  .slot { width: 12px; height: 12px; }
  .zgroup .zname { font-size: 0.6rem; letter-spacing: 0.6px; }
  .zgroup .zreq { font-size: 0.54rem; }
  .zgroup .zbody { padding: 1px 4px; }
}

@media (max-width: 600px) {
  .home-box { width: 92vw; padding: 28px 20px; }
  #game-layout { padding: 10px; gap: 10px; }
  #phase-banner { font-size: 0.78rem; letter-spacing: 1px; padding: 9px 8px; }
  /* Elite catalogue scrolls sideways instead of stacking a dozen cards. */
  #elite-list { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .elite-card { flex: 0 0 170px; }
  #log-panel { max-height: 45vh; }
  #log { max-height: 36vh; }
  .voter-card .vcount { font-size: 1.1rem; }
  .modal-box { padding: 22px 16px; }
  .modal-box.wide { max-width: calc(100vw - 24px); }
}

/* ---------- Phones (portrait, or any landscape phone) ----------
   The turn is played as: pick a market card, then tap the board. Keep both close:
   the market sits directly under the board, and the action bar (hint + End Turn)
   is docked to the bottom of the screen instead of scrolling away. */
@media (max-width: 600px), (max-height: 500px) {
  /* Dossiers become a swipeable strip so the board is on screen without scrolling
     past every player first. */
  #players-panel {
    flex-direction: row; overflow-x: auto; gap: 8px;
    scroll-snap-type: x proximity; padding: 10px 2px 6px;
  }
  .player-card { flex: 0 0 min(250px, 78vw); scroll-snap-align: start; }
  #board-wrap { display: flex; flex-direction: column; }
  /* Three market cards across instead of two-and-an-orphan. */
  #hq-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .voter-card { min-width: 0; }
  #action-bar { flex-wrap: wrap; gap: 8px; }
  #action-hint { flex-basis: 100%; }
  #policy-outcome { order: 1; }
  #requirement-panel, #conspiracy-panel, #elite-panel { order: 2; }
  #board { width: 100%; scroll-margin-top: 60px; } /* flex child with auto margins won't stretch on its own */
  #hq-mat { padding: 10px; }
  #hq-mat .hq-title { margin-bottom: 8px; }
  .voter-card { padding: 6px; }
  .voter-card .vcost { margin-top: 4px; }

  /* Toasts drop from under the banner so they never cover the dock. */
  #toast { top: 64px; bottom: auto; max-width: calc(100vw - 24px); text-align: center; }
  /* iOS zooms the page on focusing any field under 16px. */
  select, input { font-size: 16px !important; }
  .stepper button, .discard-row button { min-width: 44px; min-height: 40px; }
  .discard-row { margin: 4px 0; }
  /* Long modals scroll; their confirm button stays reachable at the bottom. */
  #btn-propose-trade, #btn-propose-coalition, #btn-discard {
    position: sticky; bottom: 0;
    box-shadow: 0 -10px 0 var(--paper); /* paper strip so scrolled rows don't show through */
  }
}

/* Portrait phones: dock the action bar to the bottom of the screen. */
@media (max-width: 600px) and (min-height: 501px) {
  #action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 3px solid var(--ink);
    box-shadow: 0 -4px 12px rgba(29, 24, 64, 0.15);
    flex-wrap: wrap; gap: 8px;
  }
  #action-bar.idle { display: none; }
  #action-hint { flex-basis: 100%; color: var(--ink); font-size: 0.8rem; font-weight: 600; }
  #action-hint:empty { display: none; }
  #action-bar button { flex: 1 1 auto; min-height: 44px; padding: 8px 12px; }
  #btn-end-turn { flex: 1 1 40%; }
  #screen-game { padding-bottom: 130px; }
}

/* Landscape phones: board on the left at full screen height, market and
   everything else beside it — pick a card and a zone without scrolling at all. */
@media (max-height: 500px) {
  #phase-banner { padding: 6px 8px; font-size: 0.75rem; letter-spacing: 1px; }
  #board-wrap {
    display: grid; grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px; align-items: start;
  }
  #board {
    grid-column: 1; grid-row: 1 / span 6; margin: 0;
    width: calc(100vh - 56px); width: calc(100svh - 56px); max-width: none;
    scroll-margin-top: 36px;
  }
  #board-wrap > :not(#board) { grid-column: 2; }
  #board-wrap > #hq-mat { margin-top: 0; }
  #toast { top: 40px; }
}

/* Lobby invite QR — white quiet zone so phone cameras can read it on the dark theme */
.lobby-qr { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 6px; }

/* Conspiracy explanations: the rule is always visible; strategy + flavour tap to expand. */
.cons-does { font-size: 0.74rem; line-height: 1.35; margin-bottom: 6px; }
.cons-more { margin-bottom: 6px; }
.cons-more summary { font-family: var(--mono); font-size: 0.66rem; font-weight: 700; color: var(--purple); cursor: pointer; padding: 2px 0; }
.cons-why { font-size: 0.72rem; line-height: 1.35; margin: 4px 0; }
.cons-more .cons-text { font-style: italic; margin: 4px 0 0; }
.reaction-explain { font-size: 0.85rem; background: #efe9d6; border-left: 3px solid var(--purple); padding: 6px 10px; margin: 8px 0; }
@media (max-width: 600px) { .conspiracy-card { width: 100%; } }

/* ⓘ explanations — a small stamped "i" beside every section; one shared sheet (help.js) */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; margin: 0 0 0 4px;
  border: 1.5px solid currentColor; border-radius: 50%;
  background: transparent; color: inherit;
  font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-weight: 700;
  font-size: 0.78rem; line-height: 1; letter-spacing: 0; text-transform: none;
  vertical-align: middle; flex-shrink: 0; cursor: pointer; opacity: 0.75;
}
.info-btn:hover { opacity: 1; background: var(--paper2); color: var(--ink); }
/* Bigger hit area on touch screens without a bigger glyph */
@media (pointer: coarse) { .info-btn { position: relative; } .info-btn::after { content: ''; position: absolute; inset: -9px; } }
/* The row (banner + its ⓘ) stays pinned so "whose turn / what now" is visible while
   scrolling the market or log. Sticky must sit on the row: the banner alone is
   confined to this row's box and would scroll away with it. */
#banner-row {
  display: flex; align-items: stretch;
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
}
#banner-row #phase-banner { flex: 1; }
#banner-row > .info-btn { align-self: center; margin: 0 8px; width: 28px; height: 28px; font-size: 0.95rem; }
.notify-btn {
  align-self: center; margin: 0 0 0 8px; padding: 0;
  width: 32px; height: 32px; font-size: 1rem; line-height: 1;
  background: transparent; border: 1.5px solid var(--ink); border-radius: 50%; cursor: pointer;
}
#perks-bar > .info-btn:first-child { margin: 0 6px 0 0; }
#modal-info { z-index: 90; }
.info-box { text-align: left; max-height: 86vh; display: flex; flex-direction: column; }
.info-box h3 { padding-right: 36px; }
#info-body { overflow-y: auto; font-size: 0.92rem; line-height: 1.5; }
#info-body p { margin: 0 0 10px; }
#info-body ul, #info-body ol { margin: 0 0 10px 20px; }
#info-body li { margin-bottom: 5px; }
.info-req { font-family: var(--mono); font-weight: 700; font-size: 0.85rem; }
.info-status { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.info-status.on { color: var(--green); font-weight: 700; }
.info-flavour { font-style: italic; color: var(--muted); }
.info-see { border-top: 1px dotted var(--line); padding-top: 8px; margin-top: 4px; font-size: 0.82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.info-see .link-btn { padding: 2px 0; font-size: 0.82rem; text-decoration: underline; }
/* Feedback sheet (HELP.feedback): three big tap targets. */
.feedback-btn { margin-top: 14px; }
.source-link { display: block; margin-top: 10px; text-align: center; font-size: 0.85rem; color: inherit; opacity: 0.7; }
.source-link:hover, .source-link:focus-visible { opacity: 1; }
.feedback-links { display: grid; gap: 8px; margin: 4px 0 12px; }
.feedback-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper2);
  color: var(--ink); text-decoration: none; box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
}
.feedback-link > span:first-child { font-size: 1.3rem; }
.feedback-link b { display: block; }
.feedback-link small { display: block; color: var(--muted); font-size: 0.78rem; }
.feedback-link:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.feedback-link:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.feedback-link.coffee { background: color-mix(in srgb, var(--yellow) 22%, var(--paper)); }
@media (max-width: 600px) { .modal-box.info-box { padding: 22px 18px; } }

/* ---------- First-time walkthrough (help.js WALKTHROUGH) ---------- */
.howto-btn {
  display: block; width: 100%; margin-top: 14px; padding: 8px 10px;
  border: 1.5px dashed var(--line); background: transparent;
  font-weight: 400; font-size: 0.85rem; color: var(--muted);
}
.howto-btn b { color: var(--ink); }
.howto-btn:hover { border-color: var(--ink); color: var(--ink); background: transparent; }
/* Never opened yet: make the way in obvious. */
.howto-btn.fresh { border: 2px solid var(--yellow); background: color-mix(in srgb, var(--yellow) 18%, var(--paper)); color: var(--ink); }
#modal-walkthrough { z-index: 95; }
.wt-box { text-align: left; }
.wt-box h3 { font-size: 1.4rem; padding-right: 36px; margin-bottom: 14px; }
.wt-kicker {
  font-family: var(--mono); font-weight: 700; font-size: 0.75rem;
  letter-spacing: 1px; text-transform: uppercase; color: var(--red); margin-bottom: 6px;
}
#wt-body { font-size: 0.95rem; line-height: 1.55; min-height: 190px; }
#wt-body p { margin: 0 0 10px; }
#wt-body ol { margin: 0 0 10px 20px; }
#wt-body li { margin-bottom: 6px; }
.wt-funds { color: var(--funds); }
.wt-clout { color: var(--clout); }
.wt-media { color: var(--media); }
.wt-trust { color: #9a7200; } /* the spot yellow is too light to read as text on paper */
.wt-ready { border-left: 3px solid var(--yellow); padding-left: 10px; font-weight: 600; }
.wt-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: 1.5px solid currentColor; border-radius: 50%;
  font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-weight: 700; font-size: 0.7rem;
}
.wt-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.wt-nav button.primary { width: auto; margin: 0; min-width: 120px; }
.wt-nav .invisible { visibility: hidden; }
.wt-dots { display: flex; gap: 6px; }
.wt-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.wt-dots span.on { background: var(--ink); }

/* ---------- Coach tips (help.js COACH) — placed in the flow right above their target ---------- */
#coach {
  margin: 0 0 12px; text-align: left;
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--ink); border-top: 6px solid var(--yellow); border-radius: 2px;
  box-shadow: 4px 4px 0 var(--ink-press);
  padding: 12px 14px;
  animation: deal 0.25s ease-out;
}
#modal-policy #coach { margin-bottom: 14px; }
.coach-title { font-family: var(--display); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.coach-body { font-size: 0.86rem; line-height: 1.45; }
.coach-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 4px; margin-top: 10px; }
.coach-actions button.primary { width: auto; margin: 0 6px 0 0; padding: 6px 14px; font-size: 0.8rem; }
.coach-actions .link-btn { margin-left: 8px; }
.coach-spot { outline: 3px solid var(--yellow); outline-offset: 3px; animation: coach-pulse 1.6s ease-in-out infinite; }
@keyframes coach-pulse { 50% { outline-color: color-mix(in srgb, var(--yellow) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { #coach, .coach-spot { animation: none; } }
@media (max-width: 600px) and (min-height: 501px) { #wt-body { min-height: 0; } }

/* ---------- Chat — table talk and private lines ----------
   A drawer on the right (full screen on phones). It sits above the game's modals so a
   deal can still be argued mid-auction, and below the rule sheets and toasts. */
#chat-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 71;
  width: 52px; height: 52px; padding: 0; border-radius: 50%;
  font-size: 1.35rem; line-height: 1;
  background: var(--paper); box-shadow: 3px 3px 0 var(--ink-press);
}
#chat-badge {
  position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 11px; background: var(--red); color: var(--paper); border: 2px solid var(--paper);
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700; line-height: 18px; text-align: center;
}
#chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 72;
  width: min(380px, 100vw);
  display: flex; flex-direction: column;
  background: var(--paper); border-left: 3px solid var(--ink);
  box-shadow: -6px 0 18px rgba(29, 24, 64, 0.25);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.chat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chat-title { font-family: var(--display); font-size: 1.1rem; letter-spacing: 1px; text-transform: uppercase; }
#chat-panel .modal-close { position: static; }
#chat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; flex-shrink: 0; }
.chat-tab {
  flex: 0 0 auto; padding: 6px 10px; font-size: 0.8rem; white-space: nowrap;
  border-width: 2px; border-left-width: 6px;
}
.chat-tab.on { background: var(--ink); color: var(--paper); }
.chat-tab.offline { opacity: 0.6; }
.chat-tab .chat-unread {
  display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: var(--paper); font-family: var(--mono); font-size: 0.7rem; text-align: center;
}
.chat-scope { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin: 2px 0 6px; }
#chat-msgs {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  border: 2px solid var(--ink); padding: 8px; background: #f6f1e4;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-line { max-width: 88%; align-self: flex-start; padding: 6px 9px; border: 1.5px solid var(--line); border-left: 5px solid var(--ink); background: var(--paper); border-radius: 2px; font-size: 0.88rem; line-height: 1.35; overflow-wrap: anywhere; }
.chat-line.mine { align-self: flex-end; background: #ebe3c8; border-left-color: var(--line); border-right: 5px solid var(--ink); }
.chat-line .chat-who { display: block; font-weight: 800; font-size: 0.75rem; }
.chat-line .chat-when { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); margin-left: 6px; font-weight: 400; }
.chat-empty { color: var(--muted); font-size: 0.85rem; text-align: center; margin: auto 0; padding: 12px; }
#chat-form { display: flex; gap: 8px; margin-top: 8px; flex-shrink: 0; }
#chat-input { flex: 1; min-width: 0; padding: 10px; border: 2px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 0.95rem; }
#chat-form .primary { width: auto; margin: 0; }
.dm-btn { padding: 0 6px; font-size: 0.75rem; border-width: 1.5px; margin-left: 4px; vertical-align: middle; }
/* Ideology accents on chat names and tabs */
.chat-c-green { border-left-color: var(--green) !important; } .chat-n-green { color: var(--green); }
.chat-c-red { border-left-color: var(--red) !important; } .chat-n-red { color: var(--red); }
.chat-c-blue { border-left-color: var(--blue) !important; } .chat-n-blue { color: var(--blue); }
.chat-c-yellow { border-left-color: var(--yellow) !important; } .chat-n-yellow { color: #8a6800; }
.chat-c-purple { border-left-color: var(--purple) !important; } .chat-n-purple { color: var(--purple); }
@media (max-width: 600px), (max-height: 500px) {
  #chat-panel { width: 100vw; border-left: 0; }
  #chat-fab { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
}
