/* Secret Hitler companion — styles */
:root {
  --bg: #14100e;
  --panel: #1f1a16;
  --panel-2: #2a231d;
  --ink: #f2e8d5;
  --muted: #b8a888;
  --lib: #1f8fb0;      /* liberal blue */
  --lib-2: #45b8d6;
  --fac: #c0392b;      /* fascist red */
  --fac-2: #e0553c;
  --gold: #d9a441;
  --silver: #c9d0d6;
  --bronze: #cd7f32;
  --coal: #2b2b2b;
  --line: #3a3029;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  --r: 12px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden; /* the whole page fits; never allow the document to scroll/drag */
  overscroll-behavior: none;
}
body {
  margin: 0;
  position: fixed; /* lock the viewport on iOS (no rubber-band drag / white borders) */
  inset: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 50% -10%, #241c16 0%, var(--bg) 60%);
  color: var(--ink);
  touch-action: manipulation; /* disable double-tap-to-zoom */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1, h2, h3 { font-family: "Georgia", serif; letter-spacing: 0.3px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 12px; height: 100%; display: flex; flex-direction: column; }
/* non-game screens scroll internally if their content is taller than the viewport */
#setupScreen:not(.hidden), #statsScreen:not(.hidden), #endScreen:not(.hidden),
#rulesScreen:not(.hidden), #theoryScreen:not(.hidden), #onlineScreen:not(.hidden) { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.topbar { flex: 0 0 auto; }

/* the active game screen fills the viewport (no page scrolling) */
#gameScreen:not(.hidden) { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; gap: 8px; }
#gameScreen, #playTab, .tab-panel, .table-panel, .controls, .rounds-bar { min-width: 0; max-width: 100%; }
.controls, .ratio-pick { overflow: hidden; }
.turn-info { overflow-wrap: anywhere; }
.tabbar { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; align-items: center; }

/* ---------- the one back affordance: a left arrow, always upper-left ---------- */
.backbtn {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 6px 10px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--ink); line-height: 1; cursor: pointer;
}
.backbtn:hover:not(:disabled) { background: #37302a; border-color: var(--gold); }
.backbtn:disabled { opacity: 0.35; cursor: not-allowed; }
.backbtn .arw { font-size: 18px; line-height: 1; }
.backbtn .backlbl { display: none; font-size: 13px; }
.backbtn.labeled .backlbl { display: inline; } /* "undo" only during play */
/* pinned to the upper-left of an overlay box */
.overlay-box .backbtn.ovl { position: absolute; top: 10px; left: 10px; }
.screen-head { display: flex; align-items: center; margin-bottom: 12px; }

/* short button labels on phones so the top row never wraps */
.t-short { display: none; }

/* ---------- toast (replaces native alert) ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--gold); color: var(--ink);
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 700; font-size: 14px; max-width: 90vw; text-align: center;
}
.confirm-body { font-size: 14px; line-height: 1.45; }
button.danger { background: var(--fac); border-color: var(--fac-2); color: #fff; font-weight: 600; }
button.danger:hover { background: var(--fac-2); }
.tab { padding: 7px 16px; border-radius: 8px 8px 0 0; background: var(--panel-2); font-weight: 600; }
.tab.sel { background: var(--panel); border-color: var(--gold); color: var(--gold); }
.tab-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.tab-panel.hidden { display: none; }
#historyTab, #statsTab { overflow: auto; }
#playTab { gap: 6px; }
#playTab .rounds-bar { flex: 0 0 auto; margin: 0; }
#playMain { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; gap: 8px; }
#playMain .table-panel { flex: 1 1 auto; min-width: 0; min-height: 0; position: relative; overflow: hidden; }
#playMain .table-area { position: absolute; inset: 0; width: auto; height: auto; aspect-ratio: auto !important; max-height: none; margin: 0; }
.controls { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.hint { font-size: 12px; color: var(--fac-2); text-align: center; min-height: 0; }

/* wide screens: controls stacked vertically on the right of the table */
@media (min-width: 641px) {
  /* right column: rounds (bounded, scrolls) on top, then the 4 ratios + actions —
     all four policy options must stay on screen without scrolling the column */
  .controls {
    width: 232px; overflow-y: auto; overflow-x: hidden;
    display: flex; flex-direction: column; gap: 8px; margin-top: 0;
  }
  /* .controls-prefixed so these win over the base ratio rules defined later in the file */
  .controls .rounds-slot { flex: 0 0 auto; }
  .controls .ratio-pick { grid-template-columns: 1fr; flex: 0 0 auto; gap: 6px; }
  .controls .ratio-cell { gap: 1px; }
  .controls .ratio-pct { font-size: 12px; }
  .controls .ratio-btn { padding: 5px 6px; gap: 1px; }
  .controls .ratio-btn .ratio-name { font-size: 14px; line-height: 1.15; }
  .controls .ratio-btn .ratio-sub { font-size: 10px; line-height: 1.1; }
  .controls .control-row { flex: 0 0 auto; flex-direction: column; margin-top: 0; gap: 5px; }
  .controls .control-row button { width: 100%; padding: 6px 10px; }
  /* Conflict + Veto share one row so the extra toggles cost no vertical space */
  .controls .control-row .btn-pair { display: flex; gap: 5px; width: 100%; }
  .controls .control-row .btn-pair button { width: auto; flex: 1 1 0; min-width: 0; }
}

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border-bottom: 2px solid var(--line); padding-bottom: 12px; margin-bottom: 16px;
}
.topbar h1 { margin: 0; font-size: 24px; color: var(--gold); }
.topbar .spacer { flex: 1; }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); padding: 8px 14px;
  border-radius: 8px; transition: 0.15s;
}
button:hover { background: #37302a; border-color: var(--gold); }
button.primary { background: var(--fac); border-color: var(--fac-2); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--fac-2); }
button.warn { background: #6b4a12; border-color: #9c6f1e; color: #ffe9c2; }
button.warn:hover { background: #855c17; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

input, select {
  font: inherit; background: #120e0b; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }

/* ---------- Main menu (home hub) ---------- */
.menu-screen {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 6px 4px 24px;
}
.menu-top { width: 100%; max-width: 460px; display: flex; align-items: center; justify-content: space-between; }
.menu-corner {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  padding: 8px 12px; border-radius: 10px;
}
.menu-corner:hover { border-color: var(--gold); background: #2a231d; }
.menu-corner.icon { font-size: 18px; line-height: 1; }
.menu-hero { text-align: center; margin: 12px 0 2px; }
.menu-title {
  margin: 0; font-family: Georgia, serif; color: var(--gold);
  font-size: clamp(42px, 13vw, 76px); line-height: 0.92; letter-spacing: 1px;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.55);
}
.menu-tagline {
  margin-top: 8px; text-transform: uppercase; letter-spacing: 6px;
  font-size: 12px; color: var(--muted);
}
.menu-group {
  width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 2px;
  text-align: left; padding: 12px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--gold);
}
.menu-group:hover { background: #2a231d; }
.menu-group .mg-top { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.menu-group .mg-name { font-size: 18px; font-weight: 700; color: var(--ink); }
.menu-group .mg-hint { font-size: 12px; color: var(--gold); margin-top: 1px; }
.menu-options { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.menu-option {
  display: flex; align-items: center; gap: 16px; text-align: left;
  padding: 18px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line);
}
.menu-option:hover { border-color: var(--gold); background: #33291f; }
.menu-option.start { border-color: var(--fac-2); background: #3a201b; }
.menu-option.start:hover { background: #4a2620; }
.menu-option .mo-icon {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px; background: rgba(0, 0, 0, 0.25);
}
.menu-option .mo-text { display: flex; flex-direction: column; }
.menu-option .mo-title { font-size: 19px; font-weight: 700; font-family: Georgia, serif; }
.menu-option .mo-sub { font-size: 13px; color: var(--muted); }

/* ---------- Setup screen ---------- */
#playerList { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
#playerList li { display: flex; align-items: center; gap: 10px; background: var(--panel-2); padding: 8px 12px; border-radius: 8px; }
#playerList .seat { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #1a1410; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
#playerList button { padding: 4px 10px; }

/* ---------- Table view ---------- */
.table-area { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 580px; margin: 8px auto; }
/* rectangular table — seats sit around its 4 edges (top/bottom only on phones) */
.felt {
  position: absolute; inset: 25% 15% 27% 15%; border-radius: 16px;
  background: radial-gradient(ellipse at 50% 40%, #2f4a3a, #15271e 85%);
  border: 10px solid #3b2a1c; box-shadow: inset 0 0 60px rgba(0,0,0,0.6), var(--shadow);
}
.seatNode {
  position: absolute; transform: translate(-50%, -50%);
  width: 108px; text-align: center; z-index: 4;
  --pres-slot: 82px;
  display: flex; flex-direction: column; align-items: center;
}
/* reserved presidency area — always room for 3; a taller stack is scaled to fit (JS) */
.seatNode .seat-pres {
  width: 100%; max-height: var(--pres-slot); overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
}
/* intrinsic width so wide rows overflow the box (caught by the fit-to-slot scaler) */
.seatNode .pres-stack {
  display: flex; flex-direction: column; align-items: center; width: max-content;
  max-width: 200px; transform-origin: top center;
}
/* top-edge seats grow their presidency rows upward so they never cover the board */
.seatNode.edge-top { flex-direction: column-reverse; transform: translate(-50%, -100%); }
.seatNode.edge-top .seat-pres { justify-content: flex-end; }
.seatNode.edge-top .pres-stack { transform-origin: bottom center; }
.seatNode.edge-bottom { transform: translate(-50%, 0); }
.seatNode.edge-left, .seatNode.edge-right { transform: translate(-50%, -50%); }
.seatNode .avatar {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 4px;
  background: var(--panel-2); border: 2px solid var(--line);
  display: grid; place-items: center; font-weight: 700; color: var(--ink);
  position: relative;
}
.seatNode.pres .avatar { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,164,65,0.35); }
.seatNode.chan .avatar { border-color: var(--lib-2); box-shadow: 0 0 0 3px rgba(69,184,214,0.35); }
.seatNode.dead .avatar { opacity: 0.4; }
/* term-limited: ineligible as Chancellor this turn (last elected government) */
.seatNode.termed .avatar { border-style: dashed; opacity: 0.62; }
.seatNode.termed .name { opacity: 0.62; }
.seatNode.dead .skull { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; z-index: 6; }
.seatNode .invest-tag { font-size: 10px; color: var(--muted); margin-top: 1px; }
.seatNode .invest-tag .p-fac { color: var(--fac-2); font-weight: 700; }
.seatNode .invest-tag .p-lib { color: var(--lib-2); font-weight: 700; }
.seatNode .badge { position: absolute; top: -6px; right: -6px; font-size: 13px; }
.seatNode .name { font-size: 13px; font-weight: 600; }

/* per-presidency rows under a seat: [3 cards | odds + details] */
.pres-row { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 3px; }
.miniHand { display: flex; gap: 2px; }
.miniCard { width: 12px; height: 17px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.5); }
.miniCard.L { background: linear-gradient(160deg, var(--lib-2), var(--lib)); }
.miniCard.F { background: linear-gradient(160deg, var(--fac-2), var(--fac)); }
.pres-side { text-align: left; line-height: 1.15; }
.pres-side .odds { font-size: 10px; color: var(--gold); font-weight: 700; }
.pres-detail { font-size: 9px; color: var(--muted); white-space: nowrap; }
.pres-detail.c-fac { color: var(--fac-2); }
.pres-detail.c-lib { color: var(--lib-2); }
.pres-detail.c-gold { color: var(--gold); }
.seatNode .fail-x { color: var(--fac-2); font-weight: 800; font-size: 16px; line-height: 1; }
.pres-row.fail-row { gap: 3px; } /* consecutive fails: ✕✕ side by side */

/* ---------- Secret-Hitler-style boards ---------- */
.center-boards {
  position: absolute; left: 50%; top: 49%; transform: translate(-50%, -50%);
  width: 55%; min-width: 0; max-width: 418px; display: flex; align-items: center;
  justify-content: center; gap: 6px; z-index: 3;
}
.boards-col { flex: 1 1 auto; display: grid; gap: 7px; min-width: 0; }
.sh-board { border-radius: 9px; padding: 6px 7px 7px; border: 2px solid rgba(0,0,0,0.5); box-shadow: var(--shadow); }

/* draw / discard piles as face-down card rectangles */
.pile-col { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.pile-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink); }
.pile-body { display: flex; align-items: center; gap: 4px; }
.pile-card {
  width: 26px; height: 37px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, #8f8f8f, #8f8f8f 3px, #7c7c7c 3px, #7c7c7c 6px);
  border: 1px solid #5a5a5a; box-shadow: 1px 1px 0 #6b6b6b, 2px 2px 0 #5c5c5c, 3px 3px 5px rgba(0,0,0,0.5);
}
.pile-counts { display: flex; flex-direction: column; gap: 1px; font-size: 11px; font-weight: 700; line-height: 1.1; }
.pile-counts .cf { color: var(--fac-2); }
.pile-counts .cl { color: var(--lib-2); }
.sh-board.fascist { background: linear-gradient(150deg, #7c2417 0%, #b5321f 45%, #46201a 100%); }
.sh-board.liberal { background: linear-gradient(150deg, #14607a 0%, #1f8fb0 45%, #123a49 100%); }
.sh-board-head { font-family: Georgia, serif; font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #fff2e0; margin-bottom: 6px; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.sh-emblem { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; margin-right: 4px; vertical-align: -3px; }
.sh-emblem.fac { background: #1a1a1a; color: #e0553c; }
.sh-emblem.lib { background: #fff; color: #14607a; }

.sh-powers { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin-bottom: 3px; }
.sh-power {
  text-align: center; font-size: 7px; line-height: 1.05; min-height: 18px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.2px; color: #000; display: flex;
  align-items: flex-end; justify-content: center; padding: 0 1px;
}
.sh-power.empty { opacity: 0; }

.sh-track { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.sh-slot {
  aspect-ratio: 5 / 7; border-radius: 5px; border: 1px dashed rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.22); display: grid; place-items: center;
  position: relative; overflow: hidden;
}
/* empty fascist slots inside "Hitler territory" (3+ fascist policies) */
.sh-slot.hitler { background: #4a0d07; border-color: #7c1a10; }
.sh-slot.win { border-style: solid; border-color: var(--gold); }
.sh-slot .win-x { color: rgba(255,255,255,0.4); font-weight: 800; font-size: 10px; }

/* enacted policy tiles: light grey with a coloured border */
.policy-card {
  position: absolute; inset: 0; border-radius: 4px; display: grid; place-items: center;
  font-weight: 800; font-family: Georgia, serif; background: #d9d6cf;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.policy-card.F { border: 3px solid var(--fac); }
.policy-card.L { border: 3px solid var(--lib); }
.policy-card .glyph { font-size: 15px; }
.policy-card.F .glyph { color: var(--fac); }
.policy-card.L .glyph { color: var(--lib); }

.fly-card {
  position: fixed; width: 28px; height: 39px; border-radius: 5px; z-index: 999; background: #d9d6cf;
  transition: transform 0.72s cubic-bezier(.5,-0.2,.3,1.2), opacity 0.72s ease;
  pointer-events: none; display: grid; place-items: center; font-weight: 800;
  box-shadow: 0 6px 16px rgba(0,0,0,0.6);
}
.fly-card.F { border: 3px solid var(--fac); color: var(--fac); }
.fly-card.L { border: 3px solid var(--lib); color: var(--lib); }
@keyframes slotpop { 0% { transform: scale(0.4); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
.policy-card.pop { animation: slotpop 0.28s ease-out; }

/* election tracker */
.sh-tracker { display: flex; gap: 7px; justify-content: center; margin-top: 6px; }
.sh-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.55); background: rgba(0,0,0,0.25); }
.sh-dot.on { background: #ffd98a; border-color: #ffd98a; box-shadow: 0 0 6px rgba(255,217,138,0.7); }
.sh-dot.chaos { background: var(--fac-2); border-color: var(--fac-2); }

/* veto sign on the 5th fascist slot — horizontal, readable on light OR dark slots */
.veto-sign {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 8px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  color: #fff; background: rgba(0, 0, 0, 0.72); padding: 1px 4px; border-radius: 4px;
  white-space: nowrap; line-height: 1.3; z-index: 3;
}

.piles { text-align: center; margin-top: 4px; font-size: 11px; color: var(--ink); }
.piles b { color: var(--gold); }

/* role tiles resting on the table */
.role-tile {
  position: absolute; transform: translate(-50%, -50%); z-index: 5;
  font-family: Georgia, serif; font-size: 10px; font-weight: 800; letter-spacing: 0.5px;
  padding: 3px 7px; border-radius: 5px; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0,0,0,0.55); border: 1px solid rgba(0,0,0,0.4);
}
.role-tile.president { background: linear-gradient(160deg, #f0c04a, #c8901f); color: #241a08; }
.role-tile.chancellor { background: linear-gradient(160deg, #5fc7e2, #1f8fb0); color: #06222b; }

/* ---------- per-round blocks ---------- */
.rounds-bar { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
/* one compact row per round: [Round N] [bottom cards] [ − mod + ] — no label */
.round-block {
  flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 10px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px;
}
.round-block.current { border-color: var(--gold); }
.round-head { display: flex; align-items: center; gap: 7px; }
.round-title { font-family: Georgia, serif; font-weight: 700; font-size: 14px; color: var(--gold); white-space: nowrap; }
.round-mod { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.round-mod button { padding: 2px 9px; }
.round-mod b { min-width: 22px; display: inline-block; text-align: center; }
.round-bottom { display: flex; gap: 3px; align-items: center; }
.round-bottom .miniCard { width: 13px; height: 19px; }
/* phone strip: slightly tighter spacing so two round blocks fit side by side at
   375–393px — otherwise the strip scrolls to the current round and cuts off Round 1 */
@media (max-width: 640px) {
  .rounds-bar { gap: 5px; }
  .round-block { padding: 5px 6px; gap: 6px; }
  .round-head { gap: 5px; }
  .round-mod { gap: 4px; }
  .round-mod button { padding: 2px 6px; }
  .round-mod b { min-width: 20px; }
}

/* desktop: the rounds bar sits in the right control column, above the policy options */
.rounds-slot { display: none; }
@media (min-width: 641px) {
  .rounds-slot { display: block; }
  /* bounded height so it never crowds out the policy options; newest round on top
     (column-reverse) stays visible, older rounds scroll below */
  .controls .rounds-bar {
    margin: 0; flex-direction: column; gap: 5px;
    overflow-x: visible; max-height: 116px; overflow-y: auto;
  }
  .controls .round-block { width: 100%; padding: 3px 9px; }
  .controls .round-mod button { padding: 1px 8px; }
}

/* ---------- Round / modifier bar ---------- */
.roundbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { padding: 4px 10px; }
.bottomcards { display: flex; gap: 4px; align-items: center; }
.bottomcards .miniCard { width: 18px; height: 26px; }

/* ---------- Controls (below the table) ---------- */
.controls { margin-top: 14px; }
.turn-info { font-size: 15px; margin-bottom: 10px; text-align: center; }
.turn-info b { color: var(--gold); }
.turn-info .chan-name { color: var(--lib-2); }
.turn-info.flash { color: var(--fac-2); font-weight: 700; }
.control-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }

/* ---------- Ratio pick buttons (with draw % above) ---------- */
.ratio-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ratio-cell { display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.ratio-pct { text-align: center; font-size: 15px; font-weight: 700; color: var(--gold); }
/* policy option labels are black so they read against the light button fills */
.ratio-btn {
  padding: 12px 4px; border-radius: 9px; border: 2px solid transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: #000;
}
.ratio-btn .ratio-name { font-weight: 800; font-family: Georgia, serif; font-size: 15px; color: #000; }
.ratio-btn .ratio-sub { font-size: 11px; color: #000; opacity: 0.72; }
.ratio-btn.armed { border-color: var(--fac-2); box-shadow: 0 0 0 2px rgba(224,85,60,0.5); }
.ratio-name.golden, .ratio-name.silver, .ratio-name.bronze, .ratio-name.coal {
  color: #000; text-shadow: none;
}

.ratio-btn:focus, .ratio-btn:focus-visible { outline: none; }
.power-title .c-lib { color: var(--lib-2); }
.power-title .c-fac { color: var(--fac-2); }

.conflict-btn { background: #3a2320; border-color: #6b3a30; color: #f0c9c1; }
.conflict-btn:hover:not(:disabled) { background: var(--fac); border-color: var(--fac-2); color: #fff; }
.conflict-btn.on { background: var(--fac); border-color: #fff; color: #fff; font-weight: 700; }

/* Veto (unlocked at 5 fascist policies) — armed like Conflict, then pick the hand */
.veto-btn { background: #34291a; border-color: #6b552a; color: #f0dfb8; }
.veto-btn:hover:not(:disabled) { background: #6b552a; border-color: var(--gold); color: #fff; }
.veto-btn.on { background: var(--gold); border-color: #fff; color: #241a08; font-weight: 700; }
/* declaring the elected Chancellor was Hitler (only from 3 fascist policies) */
.hitler-btn { background: #241a16; border-color: #55403a; color: #e9d5cd; }
.hitler-btn:hover:not(:disabled) { background: #000; border-color: #fff; color: #fff; }

/* a vetoed hand: cards were drawn and discarded, nothing was enacted */
.miniHand.vetoed { opacity: 0.5; filter: grayscale(0.5); }
.pres-detail.stale { opacity: 0.55; text-decoration: line-through; }

/* ---------- Full-screen blocking overlays (chaos / powers) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 4, 3, 0.82);
  -webkit-backdrop-filter: blur(2px); /* Safari / iOS */
  backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.overlay-box {
  position: relative;
  background: var(--panel); border: 2px solid var(--gold); border-radius: 14px;
  padding: 46px 20px 20px; max-width: 460px; width: 100%; box-shadow: var(--shadow);
  max-height: 90dvh; overflow: auto;
}

/* role badge on the avatar (replaces free-floating tiles; never overlaps names) */
.seatNode .role-badge {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; z-index: 7;
  border: 2px solid var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.seatNode .role-badge.p { background: var(--gold); color: #241a08; }
.seatNode .role-badge.c { background: var(--lib-2); color: #06222b; }
.seatNode .name {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Presidential power modal ---------- */
.power-title { font-family: Georgia, serif; font-size: 17px; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.power-title .who { color: var(--ink); }
.power-field { margin: 10px 0; }
.peek-cards { display: flex; gap: 12px; justify-content: center; margin: 12px 0; }
.peek-card { text-align: center; }
.peek-card .peek-pos { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 4px; }
.peek-card .peek-face {
  width: 52px; height: 74px; border-radius: 6px; background: #d9d6cf; display: grid; place-items: center;
  font-size: 24px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,0.5);
  -webkit-user-select: none; /* Safari / iOS */
  user-select: none;
}
.peek-card .peek-face.F { border: 4px solid var(--fac); color: var(--fac); }
.peek-card .peek-face.L { border: 4px solid var(--lib); color: var(--lib); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button.sel.F { background: var(--fac); color: #fff; }
.seg button.sel.L { background: var(--lib); color: #fff; }

/* ---------- Role coloring on the table ---------- */
.seatNode.role-hitler .avatar { border-color: #000; box-shadow: 0 0 0 3px #000, 0 0 0 5px rgba(255,255,255,0.55); }
.seatNode.role-fascist .avatar { border-color: var(--fac); box-shadow: 0 0 0 3px rgba(192,57,43,0.6); }
.seatNode.role-liberal .avatar { border-color: var(--lib); box-shadow: 0 0 0 3px rgba(31,143,176,0.5); }

/* ---------- Role recording panel ---------- */
.role-title { font-family: Georgia, serif; font-weight: 700; color: var(--gold); font-size: 16px; margin-bottom: 6px; }
.role-winner { font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.role-winner.c-fac { color: var(--fac-2); }
.role-winner.c-lib { color: var(--lib-2); }
.role-field { margin: 9px 0; }
.role-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.role-pick { padding: 6px 10px; font-size: 13px; }
.role-pick.hitler.sel { background: #000; border-color: #000; color: #fff; }
.role-pick.fascist.sel { background: var(--fac); border-color: var(--fac-2); color: #fff; }

/* ---------- Review panel ---------- */
.review-panel .role-winner { margin-bottom: 10px; }
.review-panel .review-stat { margin: 5px 0; font-size: 14px; }
.review-panel .c-fac { color: var(--fac-2); }
.review-panel .c-hit { color: #e8e8e8; }
.review-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid #3a3129; display: flex; flex-wrap: wrap; gap: 8px; }
.review-actions #btnFavGame, .review-actions #btnLabelGame { flex: 1 1 0; min-width: 0; }
.review-label { font-family: Georgia, serif; font-size: 16px; color: var(--gold); margin: 6px 0 2px; text-align: center; }
/* a quieter, outlined danger button — deletion is deliberate but not the focus */
.ghost-danger { background: transparent; border-color: var(--fac-2); color: var(--fac-2); font-weight: 600; width: 100%; }
.ghost-danger:hover { background: var(--fac); border-color: var(--fac-2); color: #fff; }

/* ---------- "In the night" narration ---------- */
/* (the tabbar's global .t-full / .t-short rules already swap "🌙 Night" ⇄ "🌙") */
#nightBox { max-height: 86vh; overflow-y: auto; }
.night-voices { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 10px; }
.night-voice {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  padding: 9px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
}
.night-voice:hover { border-color: var(--gold); }
.night-voice.sel { border-color: var(--gold); background: #33291f; }
.night-voice .nv-dot {
  flex: 0 0 auto; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent;
}
.night-voice.sel .nv-dot { border-color: var(--gold); background: var(--gold); box-shadow: inset 0 0 0 3px var(--panel); }
.night-voice .nv-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.night-voice .nv-name { font-weight: 700; font-size: 14px; }
.night-voice .nv-sub { font-size: 12px; color: var(--muted); }
.night-voice .nv-warn { font-size: 12px; color: var(--fac-2); }
.night-voice .nv-del { flex: 0 0 auto; padding: 2px 6px; border-radius: 6px; font-size: 14px; opacity: 0.7; }
.night-voice .nv-del:hover { opacity: 1; background: rgba(0,0,0,0.3); }
.night-voice .nv-share {
  flex: 0 0 auto; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--lib-2); border: 1px solid var(--lib); background: transparent;
}
.night-voice .nv-share:hover { background: var(--lib); color: #fff; }
.night-voice .nv-badge {
  flex: 0 0 auto; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  color: #0d2b33; background: var(--lib-2);
}
.night-share-opt { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin: 4px 2px 2px; cursor: pointer; }
.night-share-opt input { margin-top: 2px; }
.night-step { text-align: center; font-size: 13px; color: var(--gold); margin: 2px 0 8px; font-weight: 600; }
.night-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.night-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.night-card .nv-ok { color: var(--lib-2); font-size: 13px; font-weight: 600; }
.night-card .nv-rec { color: var(--fac-2); font-size: 13px; font-weight: 700; }
.night-script {
  white-space: pre-wrap; font-family: inherit; font-size: 12.5px; line-height: 1.5;
  color: var(--ink); background: #171310; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin: 0 0 8px; max-height: 168px; overflow-y: auto;
}
.night-prev { width: 100%; margin-top: 8px; height: 34px; }

/* ---------- Review playback stepper ---------- */
.pb-controls { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 10px; }
.pb-btn {
  min-width: 34px; padding: 6px 8px; font-size: 15px; line-height: 1;
  background: #2a221a; border: 1px solid #4a3f30; border-radius: 8px; color: var(--gold); cursor: pointer;
}
.pb-btn:hover:not(:disabled) { background: #3a3024; }
.pb-btn:disabled { opacity: 0.35; cursor: default; }
.pb-step { flex: 0 0 auto; min-width: 52px; text-align: center; font-weight: 700; font-size: 13px; color: #cdbb9a; }
.pb-caption {
  text-align: left; font-size: 13.5px; line-height: 1.5; margin-bottom: 8px;
  padding: 8px 10px; background: #241d16; border: 1px solid #3a3129; border-radius: 8px;
}
.pb-caption .c-fac { color: var(--fac-2); }
.pb-caption .c-lib { color: var(--lib-2); }
.pb-caption .c-gold { color: var(--gold); }
.pb-round { display: inline-block; font-weight: 700; color: var(--gold); font-size: 11px; margin-right: 4px; }
.pb-role { font-size: 10px; font-weight: 700; color: #241a08; background: var(--gold); border-radius: 4px; padding: 0 3px; vertical-align: middle; }
.pb-hint { margin-top: 8px; font-size: 12px; color: #8a7f70; text-align: left; }
.ro-lib { flex: 0 0 34px; text-align: right; font-weight: 700; font-size: 11.5px; color: var(--lib-2); }

/* ---------- All-games list ---------- */
.games-list { display: flex; flex-wrap: wrap; gap: 10px; }
.game-box { position: relative; flex: 0 0 auto; width: 132px; text-align: center; padding: 10px 8px; border-radius: 10px; cursor: pointer; border: 2px solid; }
.game-box.gl-lib { background: rgba(31,143,176,0.18); border-color: var(--lib); }
.game-box.gl-fac { background: rgba(192,57,43,0.2); border-color: var(--fac); }
.game-box:hover { filter: brightness(1.15); }
.game-box.fav { box-shadow: 0 0 0 1px var(--gold) inset; }
.gl-star {
  position: absolute; top: 3px; left: 5px; font-size: 16px; line-height: 1;
  color: var(--muted); cursor: pointer; -webkit-user-select: none; user-select: none; padding: 2px;
}
.gl-star:hover { color: var(--gold); }
.gl-star.on { color: var(--gold); }
.gl-label { font-family: Georgia, serif; font-size: 12px; color: var(--gold); margin: 2px 0 5px; padding: 0 10px; line-height: 1.2; word-break: break-word; }
.gl-win { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.gl-lib .gl-win { color: var(--lib-2); }
.gl-fac .gl-win { color: var(--fac-2); }
.gl-hitler { font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--ink); }
.gl-facs { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; font-size: 11px; color: var(--muted); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .wrap { padding: 6px; }
  #playMain { flex-direction: column; }
  .controls { width: auto; }
  .tab { padding: 6px 11px; font-size: 13px; }
  .tabbar button.ghost { padding: 6px 10px; font-size: 13px; }
  /* phone: board runs nearly the full width — draw pile hugs the left edge,
     discard hugs the right; players live only above & below it. Bottom seats
     straddle the felt's bottom edge so their presidencies have room below. */
  .felt { inset: 26% 1.5% 24% 1.5%; }
  .center-boards { width: 98%; max-width: none; min-width: 0; gap: 5px; }
  .pile-card { width: 26px; height: 37px; }
  .pile-counts { font-size: 11px; }
  .pile-label { font-size: 9px; }
  .sh-power { font-size: 6px; min-height: 14px; }
  .seatNode { width: 66px; --pres-slot: 78px; }
  .seatNode .avatar { width: 34px; height: 34px; font-size: 12px; }
  .seatNode .name { font-size: 11px; }
  .seatNode .miniCard { width: 10px; height: 15px; }
  .ratio-btn { padding: 9px 3px; }
  .ratio-btn .ratio-name { font-size: 12px; }
  .ratio-btn .ratio-sub { font-size: 9px; }
  .ratio-pct { font-size: 13px; }
  .control-row button { padding: 7px 10px; font-size: 13px; }
  .topbar { padding-bottom: 8px; margin-bottom: 8px; gap: 8px; }
  .topbar h1 { font-size: 17px; }
  .topbar h1 span { display: none; } /* hide "companion" subtitle */
  #btnStats { display: none; } /* Stats is a tab on mobile */
  .t-full { display: none; }
  .t-short { display: inline; }
  .backbtn { padding: 6px 8px; }
  /* stats: one full-width column so values sit at the panel edge.
     .stats-body-scoped so these beat the base stats rules defined later in the file */
  .stats-body .kv-grid { grid-template-columns: 1fr; }
  .stats-body .statgrid { grid-template-columns: repeat(auto-fit, minmax(92px,1fr)); }
  .stats-body .pstat-quick { font-size: 10.5px; }
  .round-block { min-width: 88px; padding: 6px 7px; }
  .tab { padding: 6px 13px; }
}
@media (min-width: 641px) and (max-height: 560px) {
  .center-boards { width: 46%; }
  .seatNode { width: 92px; }
}

/* ---------- History table ---------- */
table.hist { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
table.hist th, table.hist td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
table.hist th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.tag-round { font-size: 11px; color: var(--muted); }
tr.ev-fail td { color: var(--muted); font-style: italic; }
tr.ev-chaos td { color: #ffd98a; }

/* ---------- Stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px,1fr)); gap: 8px; }
.stat-tile { background: var(--panel-2); border-radius: 10px; padding: 9px 8px; text-align: center; }
.stat-tile .big { font-size: 21px; color: var(--gold); font-weight: 700; line-height: 1.15; }
.stat-tile .lbl { font-size: 11px; color: var(--muted); }

/* ---------- statistics layout (compact; the section itself scrolls) ---------- */
.stats-body { display: flex; flex-direction: column; gap: 10px; }
.stats-body .panel { padding: 12px; }
.sec-title { margin: 0 0 9px; font-size: 14px; color: var(--gold); font-weight: 700; }
.sec-note { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }

/* label → value pairs, two-up on anything wider than a phone */
/* columns are capped so a label never drifts far from its value on wide screens */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px,232px));
           justify-content: start; gap: 0 18px; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
      font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.055); }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; color: var(--ink); white-space: nowrap; }

/* single-series magnitude bars — one accent hue, every row directly labelled */
.bar-list { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(84px,auto) 1fr minmax(58px,auto);
           align-items: center; gap: 10px; font-size: 12.5px; }
.bar-lbl { color: var(--ink); white-space: nowrap; }
.bar-track { background: rgba(255,255,255,0.07); border-radius: 4px; height: 11px; }
.bar-fill { display: block; height: 100%; background: #b3852f; border-radius: 4px; min-width: 2px; }
.bar-val { text-align: right; color: var(--muted); white-space: nowrap; }

/* expandable per-player breakdown */
.player-list { display: flex; flex-direction: column; gap: 6px; }
.pstat { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel-2); }
.pstat-head { width: 100%; display: flex; align-items: center; gap: 10px; background: none;
              border: 0; border-radius: 0; padding: 8px 11px; text-align: left; color: var(--ink); }
.pstat-head:hover { background: #37302a; }
.pstat-name { font-weight: 700; font-size: 13.5px; }
.pstat-quick { color: var(--muted); font-size: 11.5px; margin-left: auto; text-align: right; }
.pstat-chev { color: var(--gold); font-size: 14px; line-height: 1; transition: transform 0.15s; }
.pstat-head.open .pstat-chev { transform: rotate(180deg); }
.pstat-detail { padding: 2px 11px 10px; }
.sub-head { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
            color: var(--gold); margin: 9px 0 2px; }

.next-draw { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.nd-item { background: var(--panel-2); border-radius: 8px; padding: 8px 12px; text-align: center; min-width: 84px; }
.nd-item .p { font-size: 18px; font-weight: 700; color: var(--gold); }
.nd-item .l { font-size: 11px; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: 12px; margin: 24px 0; }

/* Visually hidden, still announced by screen readers (and keeps <section>
   elements validly headed without changing the visible design). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- small utilities (replacing inline style attributes) ----------
   Appended last so single-class rules here win over earlier ones of equal
   specificity (e.g. .btn-lib over .primary). */
.brand-sub   { font-size: 14px; }
.hist-title  { margin-top: 0; }
.hist-note   { font-size: 13px; }
.scroll-x    { overflow-x: auto; }
.stats-tools { margin-top: 12px; }
/* Must match `button.primary`'s specificity (element+class) to override it —
   being later in the file is not enough. The :hover pair is needed because the
   inline style this replaced also beat `button.primary:hover`. */
button.btn-lib,
button.btn-lib:hover { background: var(--lib); border-color: var(--lib-2); }

/* ---------- account / sync (phase 1 backend) ---------- */
.acct-btn { display: inline-flex; align-items: center; gap: 7px; }
.acct-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  flex: 0 0 auto; transition: background 0.2s;
}
.acct-dot.on      { background: #4caf50; }                 /* signed in, synced */
.acct-dot.pending { background: var(--gold); }             /* queued uploads */
.acct-dot.syncing { background: var(--gold); animation: acctPulse 1s infinite; }
.acct-dot.err     { background: var(--fac-2); }
@keyframes acctPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.acct-panel { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.acct-panel .acct-who {
  font-size: 18px; font-weight: 600; color: var(--ink); word-break: break-word;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.acct-panel .acct-who .muted { font-weight: 400; font-size: 15px; }
.acct-editname {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.acct-editname:hover { color: var(--ink); border-color: var(--muted); }
.acct-panel .acct-sub { font-size: 13px; color: var(--muted); word-break: break-all; margin-top: -6px; }
.acct-panel .acct-state { font-size: 13px; }
.acct-field { display: flex; flex-direction: column; gap: 4px; }
.acct-field input { width: 100%; }
.acct-msg { font-size: 13px; min-height: 1em; }
.acct-msg.bad { color: var(--fac-2); }
.acct-msg.good { color: var(--lib-2); }
.acct-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.acct-sep::before, .acct-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.acct-google { background: #fff; color: #222; border-color: #ccc; font-weight: 600; }
.acct-google:hover { background: #f1f1f1; border-color: #999; }
.acct-toggle { background: none; border: none; color: var(--gold); text-decoration: underline; padding: 0; font-size: 13px; }
.acct-toggle:hover { background: none; }

/* ---------- groups (phase 2) ---------- */
/* The confirm/prompt dialog must sit ABOVE the account overlay, which appears
   later in the document and would otherwise win the stacking contest. */
#confirmModal { z-index: 620; }

.group-banner {
  font-size: 13px; color: var(--gold); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; margin: 0 0 10px;
}
.roster-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 0; }
.roster-lbl { font-size: 12px; }
.roster-chip { padding: 4px 10px; font-size: 13px; border-radius: 999px; }

.grp-head { font-size: 13px; color: var(--ink); font-weight: 600; margin-top: 4px; }
.grp-head .muted { font-weight: 400; font-size: 12px; }
.grp-list { display: flex; flex-direction: column; gap: 6px; max-height: 168px; overflow-y: auto; }
.grp-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; width: 100%; padding: 7px 10px;
}
.grp-row.sel { border-color: var(--gold); background: #37302a; }
.grp-row .grp-name { font-weight: 600; font-size: 14px; }
.grp-row .grp-meta { font-size: 12px; color: var(--muted); }

.mem-list { display: flex; flex-direction: column; gap: 5px; max-height: 240px; overflow-y: auto; }
.mem-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px;
}
.mem-row .mem-name { font-size: 14px; }
.mem-row .mem-tag { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- history entry editing ---------- */
.hist-fix { width: 34px; text-align: center; }
.fix-btn {
  padding: 2px 7px; font-size: 13px; line-height: 1.2;
  background: transparent; border-color: transparent; color: var(--muted);
}
.fix-btn:hover { color: var(--gold); border-color: var(--line); background: var(--panel-2); }
.ed-ratios { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.ed-ratio {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 4px; border: 2px solid transparent; border-radius: 8px;
}
.ed-ratio.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217,164,65,0.28); }
.ed-ratio .ratio-name { font-size: 13px; }
.ed-ratio .ratio-sub { font-size: 10px; }
@media (max-width: 480px) { .ed-ratios { grid-template-columns: repeat(2, 1fr); } }
/* selected chaos policy in the entry editor (the .on styles above are scoped
   to the conflict/veto buttons, which these are not) */
button.primary.on { outline: 2px solid var(--gold); outline-offset: 1px; font-weight: 700; }

/* ---------- roster actions, invitations, people picker ---------- */
.mem-act {
  padding: 3px 9px; font-size: 12px; border-radius: 6px; flex: 0 0 auto;
}
.mem-act.claim { border-color: var(--gold); color: var(--gold); }
.mem-act.del { color: var(--muted); padding: 3px 7px; }
.mem-act.del:hover { color: var(--fac-2); border-color: var(--fac-2); }

.inv-box { display: flex; flex-direction: column; gap: 6px; }
.inv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--gold);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.inv-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.inv-yes, .inv-no { padding: 3px 10px; font-size: 12px; }
.inv-yes { background: var(--gold); color: #241a08; font-weight: 700; border-color: var(--gold); }

.inv-people { display: flex; flex-wrap: wrap; gap: 6px; }
.person-chip { padding: 5px 12px; font-size: 13px; border-radius: 999px; }
.person-chip:disabled { opacity: 0.5; }

/* ===================== lie detection (opt-in) =============================
   Every element the honesty model adds carries `.lie-col`. It is hidden unless
   the body has `.lie-on`, so with the setting off the feature leaves no trace.
   See HONESTY_MODEL.md.                                                     */
.lie-col { display: none; }
body.lie-on th.lie-col, body.lie-on td.lie-col { display: table-cell; }
body.lie-on div.lie-col:not(.hidden) { display: block; }
body.lie-on span.lie-col { display: inline; }

/* the inline verdict badge in the Event cell — always on screen, no side-scroll */
.lie-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #241d16; border: 1px solid #3a3129; white-space: nowrap;
  vertical-align: middle;
}
.lie-badge .lie-bad,
.lie-badge .lie-warn,
.lie-badge .lie-good { border-bottom: none; }

.lie-summary {
  margin: 0 0 8px; padding: 8px 10px; border-radius: 8px;
  background: #241d16; border: 1px solid #3a3129;
  font-size: 12.5px; line-height: 1.5;
}
.lie-summary div + div { margin-top: 3px; }

.lie-bad  { color: var(--fac-2); font-weight: 700; }
.lie-warn { color: var(--gold); font-weight: 700; }
.lie-good { color: var(--lib-2); font-weight: 700; }
/* these carry an explanatory title — hint that they are hoverable */
.hist .lie-col span[title] { cursor: help; border-bottom: 1px dotted currentColor; }

/* settings panel */
.set-row { display: flex; align-items: flex-start; gap: 12px; margin-top: 6px; text-align: left; }
.set-text { flex: 1; min-width: 0; }
.set-name { font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.set-desc { font-size: 12.5px; line-height: 1.5; color: #c3b6a6; }
.toggle-btn { min-width: 62px; flex: 0 0 auto; }
.toggle-btn.on { background: var(--gold); border-color: var(--gold); color: #241a08; font-weight: 700; }

/* role posterior — the stored fascist-odds read, shown in a game review */
.role-odds { margin-top: 10px; padding-top: 8px; border-top: 1px solid #3a3129; text-align: left; }
.ro-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.ro-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 12.5px; }
.ro-name { flex: 0 0 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ro-bar { flex: 1; height: 8px; border-radius: 999px; background: #2a221a; overflow: hidden; }
.ro-fill { display: block; height: 100%; border-radius: 999px; }
.ro-fill.lie-bad { background: var(--fac-2); }
.ro-fill.lie-warn { background: var(--gold); }
.ro-fill.lie-good { background: var(--lib-2); }
.ro-pct { flex: 0 0 34px; text-align: right; font-weight: 700; }
.ro-hit { flex: 0 0 auto; color: var(--fac-2); font-weight: 700; font-size: 11px; }
.ro-miss { flex: 0 0 auto; color: var(--lib-2); font-weight: 700; font-size: 11px; }

/* live fascist-odds chip on a player's circle (opt-in board setting) */
.seat-odds {
  display: inline-block; margin-top: 2px; padding: 0 6px;
  border-radius: 999px; font-size: 10.5px; font-weight: 700; line-height: 1.5;
  border: 1px solid #3a3129; background: #241d16; white-space: nowrap;
}
.seat-odds.hi { color: #fff; background: var(--fac); border-color: var(--fac-2); }
.seat-odds.mid { color: #241a08; background: var(--gold); border-color: var(--gold); }
.seat-odds.lo { color: var(--lib-2); }

/* ==================== Rules / Game Theory handbook ==================== */
.ref-screen { padding-bottom: 24px; }
.ref-head { margin: 4px 0 12px; }
.ref-title { margin: 0; font-family: Georgia, serif; font-size: 26px; }
.ref-tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.ref-searchwrap { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 6px 0 10px; }
.ref-search {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); font-size: 15px;
}
.ref-search:focus { outline: none; border-color: var(--gold); }
.ref-results { display: flex; flex-direction: column; gap: 8px; }
.ref-count { font-size: 12px; color: var(--muted); margin: 2px 0; }
.ref-empty { color: var(--muted); font-size: 14px; padding: 16px 4px; }

/* category / subcategory cards (drill-down) */
.ref-cat {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 14px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
}
.ref-cat:hover { border-color: var(--gold); background: #33291f; }
.ref-cat.sub { padding: 12px 16px; }
.ref-cat-title { font-size: 16px; font-weight: 700; font-family: Georgia, serif; }
.ref-cat-meta { font-size: 12px; color: var(--muted); }

/* breadcrumb */
.ref-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 2px 0 8px; font-size: 13px; }
.ref-crumb-link { background: none; border: none; padding: 2px 4px; color: var(--gold); font-size: 13px; cursor: pointer; }
.ref-crumb-link:hover { text-decoration: underline; }
.ref-crumb-sep { color: var(--muted); }
.ref-crumb-cur { color: var(--muted); padding: 2px 4px; }

/* item ("bullet") cards */
.ref-item { border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.ref-item.open { border-color: var(--gold); }
.ref-item-head {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 13px 15px; background: none; border: none; color: var(--ink); cursor: pointer;
}
.ref-item-head:hover { background: rgba(217,164,65,0.06); }
.ref-item-crumb { flex: 0 0 100%; order: -1; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.ref-item-title { flex: 1; font-size: 15px; font-weight: 600; }
.ref-item-caret { color: var(--gold); font-size: 13px; }
.ref-item-body { padding: 0 15px 14px; }
.ref-item-text { margin: 2px 0 12px; font-size: 14px; line-height: 1.5; color: var(--ink); }

/* community notes */
.ref-notes-head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.ref-notes-loading, .ref-notes-empty, .ref-notes-signedout { font-size: 13px; color: var(--muted); }
.ref-notes-signedout { display: flex; gap: 6px; align-items: center; }
.linklike { background: none; border: none; color: var(--gold); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }
.note-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.note { background: rgba(0,0,0,0.22); border-radius: 9px; padding: 8px 11px; }
.note-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.note-author { font-weight: 700; font-size: 13px; color: var(--gold); }
.note-time { font-size: 11px; color: var(--muted); }
.note-del { margin-left: auto; background: none; border: none; color: var(--fac-2); font-size: 11px; cursor: pointer; padding: 0 2px; }
.note-del:hover { text-decoration: underline; }
.note-text { font-size: 14px; line-height: 1.45; white-space: normal; word-break: break-word; }
.note-add { display: flex; flex-direction: column; gap: 6px; }
.note-input {
  width: 100%; resize: vertical; min-height: 40px; padding: 9px 11px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink); font-size: 14px; font-family: inherit;
}
.note-input:focus { outline: none; border-color: var(--gold); }
.note-post { align-self: flex-end; padding: 7px 16px; }

/* ==================== Online play ==================== */
.online-body { display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; width: 100%; padding-bottom: 24px; }
.online-head { margin: 2px 0 4px; }
.online-title { margin: 0; font-family: Georgia, serif; font-size: 26px; }
.online-tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.online-sub { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 4px; }
.online-hint { font-size: 13px; color: var(--ink); background: rgba(217,164,65,0.1); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; line-height: 1.45; }
.online-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.online-card-title { font-weight: 700; font-family: Georgia, serif; font-size: 17px; }

/* joinable games */
.ol-join-list { display: flex; flex-direction: column; gap: 8px; }
.ol-join { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 13px 15px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.ol-join:hover { border-color: var(--gold); background: #33291f; }
.ol-join-host { font-weight: 700; font-size: 15px; }
.ol-join-meta { font-size: 12px; color: var(--muted); }

/* lobby / seat lists */
.ol-seats { display: flex; flex-direction: column; gap: 6px; }
.ol-seat { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); font-size: 15px; }
.ol-seat.first { border-color: var(--gold); }
.ol-seat-n { width: 22px; height: 22px; border-radius: 50%; background: var(--gold); color: #1a1410; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: 0 0 auto; }
.ol-badge { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: auto; }
.ol-badge.you { color: var(--gold); border-color: var(--gold); margin-left: 6px; }

/* the secret role reveal */
.ol-role { border-radius: 14px; padding: 20px 18px; text-align: center; border: 2px solid var(--line); }
.ol-role.loading { color: var(--muted); }
.ol-role.liberal { background: rgba(31,143,176,0.16); border-color: var(--lib); }
.ol-role.fascist { background: rgba(192,57,43,0.18); border-color: var(--fac); }
.ol-role.hitler { background: rgba(20,16,14,0.85); border-color: #111; }
.ol-role-name { font-family: Georgia, serif; font-size: 24px; margin-bottom: 6px; }
.ol-role.liberal .ol-role-name b { color: var(--lib-2); }
.ol-role.fascist .ol-role-name b { color: var(--fac-2); }
.ol-role.hitler .ol-role-name b { color: #f2e8d5; }
.ol-role-sub { font-size: 14px; line-height: 1.5; color: var(--ink); }

/* ---- online live game ---- */
.ol-board { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ol-track { display: flex; align-items: center; gap: 10px; }
.ol-track-lbl { width: 58px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ol-slots { display: flex; gap: 5px; flex: 1; }
.olp { flex: 1; height: 26px; border-radius: 5px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 9px; font-weight: 700; color: #fff; background: rgba(0,0,0,0.2); }
.olp.f.on { background: var(--fac); border-color: var(--fac-2); }
.olp.l.on { background: var(--lib); border-color: var(--lib-2); }
.olp.f { border-color: rgba(192,57,43,0.4); }
.ol-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.oltrk { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--muted); display: inline-block; margin-left: 3px; }
.oltrk.on { background: var(--fac-2); border-color: var(--fac-2); }

.ol-players { display: flex; flex-direction: column; gap: 5px; }
.ol-player { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 11px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.ol-player.dead { opacity: 0.5; }
.ol-player.r-lib { border-color: var(--lib); }
.ol-player.r-fac { border-color: var(--fac); }
.ol-player.r-hit { border-color: #000; background: rgba(0,0,0,0.5); }
.ol-pn { font-size: 14px; font-weight: 600; }
.ol-pbadges { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.ol-b { font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 6px; }
.ol-b.p { background: var(--gold); color: #1a1410; }
.ol-b.c { background: var(--lib-2); color: #06222b; }
.ol-b.n { background: rgba(217,164,65,0.25); color: var(--gold); }
.ol-b.tl { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.ol-rt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.ol-vote { font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 6px; }
.ol-vote.ja { background: rgba(69,184,214,0.2); color: var(--lib-2); }
.ol-vote.nein { background: rgba(224,85,60,0.2); color: var(--fac-2); }
.ol-odds { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.ol-odds.hi { background: var(--fac); color: #fff; }
.ol-odds.mid { background: var(--gold); color: #241a08; }
.ol-odds.lo { background: rgba(69,184,214,0.18); color: var(--lib-2); }

.ol-action { background: rgba(217,164,65,0.08); border: 1px solid var(--line); border-radius: 12px; padding: 13px; display: flex; flex-direction: column; gap: 10px; }
.ol-prompt { font-size: 15px; font-weight: 600; line-height: 1.4; }
.ol-choices { display: flex; flex-wrap: wrap; gap: 7px; }
.ol-choice { padding: 9px 14px; }
.ol-choice.truth { border-color: var(--lib-2); }
.ol-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.ol-card { flex: 1; min-width: 92px; padding: 16px 10px; font-weight: 700; border-radius: 10px; }
.ol-card.f { background: rgba(192,57,43,0.25); border-color: var(--fac); color: #fff; }
.ol-card.l { background: rgba(31,143,176,0.25); border-color: var(--lib); color: #fff; }
.ol-over { font-family: Georgia, serif; font-size: 22px; text-align: center; }
.ol-myrole { font-size: 13px; padding: 9px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.ol-myrole.hitler { background: rgba(0,0,0,0.4); }
.ol-learned { font-size: 13px; padding: 7px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.ol-history { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.ol-hrow { padding: 6px 10px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line); }
.ol-action .c-fac, .ol-hrow .c-fac, .ol-learned .c-fac { color: var(--fac-2); }
.ol-action .c-lib, .ol-hrow .c-lib, .ol-learned .c-lib { color: var(--lib-2); }

/* ---- Accessibility: visible keyboard focus (session 44) --------------------
   Several controls set `outline:none`; restore a clear focus ring for keyboard
   users only (:focus-visible), so a mouse/touch tap stays clean but Tab is
   always visible. A global default plus overrides for the controls that opted
   out and for the keyboard-operable seats. */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ratio-btn:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.ref-search:focus-visible, .note-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.seatNode[role="button"]:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 12px; }

/* Fit-lie-rates panel: the "was NN%" sub-line under a fitted tile (session 44). */
.statgrid .sub { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.fit-result:empty { display: none; }

/* ---- Game theory: categories -> page of bullets + per-category chat (session 45) */
.thy-cats { display: flex; flex-direction: column; gap: 8px; }
.thy-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left; padding: 14px 16px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); cursor: pointer;
}
.thy-cat:hover { border-color: var(--gold); background: #322a22; }
.thy-cat-title { font-weight: 700; font-size: 16px; }
.thy-cat-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }

.thy-back {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 13px; padding: 2px 0; margin-bottom: 6px;
}
.thy-back:hover { color: var(--gold); }
.thy-page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.thy-title { margin: 0; flex: 1; font-size: 20px; color: var(--gold); }
.thy-chat-toggle {
  flex: none; width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; line-height: 1;
}
.thy-chat-toggle[aria-expanded="true"] { border-color: var(--gold); background: #322a22; }
.thy-blurb { color: var(--muted); margin: 0 0 12px; font-size: 14px; }

.thy-list, .thy-sublist { list-style: none; margin: 0; padding: 0; }
.thy-list > .thy-bullet { padding: 10px 0; border-top: 1px solid var(--line); }
.thy-list > .thy-bullet:first-child { border-top: none; }
.thy-b-text { display: block; line-height: 1.5; }
.thy-bullet.wip > .thy-b-text { color: #e6b9a0; }
.thy-wip {
  font-size: 11px; color: #d98a5a; border: 1px solid #7a4a30; border-radius: 999px;
  padding: 0 7px; margin-left: 4px; vertical-align: middle; white-space: nowrap;
}
.thy-sublist { margin: 8px 0 2px; padding-left: 18px; border-left: 2px solid var(--line); }
.thy-sublist .thy-bullet { padding: 6px 0; }
.thy-sublist .thy-b-text { color: var(--muted); font-size: 14px; }

.thy-chat {
  background: #171310; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 14px;
}
.thy-msgs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; max-height: 40vh; overflow-y: auto; }
.thy-msg-meta { font-size: 12px; margin-bottom: 2px; }
.thy-msg-text { line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.thy-msg-del { background: none; border: none; color: #d98a5a; cursor: pointer; font-size: 12px; padding: 0 4px; }
.thy-chat-add { display: flex; gap: 8px; align-items: flex-end; }
.thy-chat-input { flex: 1; resize: vertical; min-height: 40px; }
.thy-send { flex: none; }

/* ---- Game theory: admin editing (session 46) ------------------------------ */
.thy-cat-row { display: flex; align-items: stretch; gap: 6px; }
.thy-cat-row .thy-cat { flex: 1; }
.thy-cat-move { display: flex; flex-direction: column; gap: 4px; }
.thy-mv {
  width: 34px; flex: 1; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--ink); cursor: pointer; font-size: 13px; line-height: 1;
}
.thy-mv:hover:not(:disabled) { border-color: var(--gold); }
.thy-mv:disabled { opacity: 0.35; cursor: default; }
.thy-add { align-self: flex-start; }
.thy-edit {
  flex: none; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.thy-edit:hover { border-color: var(--gold); }

.thy-editor { display: flex; flex-direction: column; gap: 12px; }
.thy-editor label { display: block; font-size: 13px; color: var(--muted); }
.thy-editor input, .thy-editor textarea {
  width: 100%; margin-top: 4px; box-sizing: border-box;
  font: inherit; background: #120e0b; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.thy-editor textarea {
  min-height: 220px; resize: vertical; line-height: 1.5;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 13px; white-space: pre;
}
.thy-ed-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.thy-ed-actions .thy-ed-del { margin-left: auto; }
