:root {
  --bg: #1d1714;
  --panel: #2a221d;
  --panel-2: #342a23;
  --ink: #f1e6d2;
  --muted: #b9a88e;
  --accent: #d9a441;
  --danger: #e06b5a;
  --gold: #d6a93a;
  --green: #2f8f5d;
  --red: #b83a3a;
  --target: #ffe066;
  --radius: 8px;
  --rail: 92px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 Georgia, 'Times New Roman', serif;
}

button {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid #5a4a3c;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #1d1714; border-color: var(--accent); font-weight: bold; }
button.quiet { background: none; border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--ink); }

/* ----- setup ----- */
.setup { max-width: 560px; margin: 8vh auto; padding: 24px; background: var(--panel); border-radius: var(--radius); }
.setup h1 { margin: 0 0 4px; font-size: 32px; }
.sub { color: var(--muted); margin-top: 0; }
.seats { display: grid; gap: 8px; margin: 16px 0; }
.seat { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; }
.seat[hidden] { display: none; }
.seat .name { flex: 1; }
.expansions { border: 1px solid #5a4a3c; border-radius: 6px; padding: 8px 12px 10px; margin: 0 0 16px; }
.expansions legend { color: var(--muted); padding: 0 4px; }
.expansions .check { color: var(--ink); }
.expansions small { display: block; color: var(--muted); margin-top: 4px; }
.seat select { font: inherit; background: var(--bg); color: var(--ink); border: 1px solid #5a4a3c; border-radius: 4px; padding: 3px; }
.seed { display: block; margin-bottom: 16px; color: var(--muted); }
.seed input { width: 100px; margin-left: 8px; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid #5a4a3c; border-radius: 4px; padding: 3px 6px; }
.error { color: var(--danger); }

/* ----- layout ----- */
.game {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--rail);
  grid-template-areas: "top top top" "left stage right" "me me me";
  gap: 10px;
  padding: 10px;
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 12px; background: var(--panel); border-radius: var(--radius); min-height: 44px; }
.topbar .turn { color: var(--muted); }
.topbar .who { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.topbar .spacer { flex: 1; }
.topbar .others { display: flex; gap: 8px; align-items: center; color: var(--muted); flex-wrap: wrap; }
/* Every bank in turn order; the one whose turn it is is marked. */
.seat-card {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 6px;
  background: var(--panel-2); border-left: 4px solid var(--pc); color: var(--ink); font-size: 14px;
}
.seat-card .order {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  font-size: 11px; color: var(--muted); border: 1px solid #5a4a3c;
}
.seat-card.now { box-shadow: 0 0 0 2px var(--pc); }
.seat-card.mine { background: #3d3129; }
.seat-card.now .order { background: var(--pc); color: #1d1714; border-color: var(--pc); }
.seat-card .fl { display: inline-flex; align-items: center; gap: 3px; color: var(--gold); font-weight: bold; }
.seat-card .fl .ico { width: 14px; height: 14px; }
.seat-card .bot-tag { display: inline-flex; color: var(--muted); }
.seat-card .bot-tag .ico { width: 15px; height: 15px; }
.seat-card .bot-tag.thinking { color: var(--pc); animation: think 1s ease-in-out infinite; }
@keyframes think { 50% { opacity: .3; } }
.topbar .chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; cursor: default; }
.topbar .chip .ico { width: 18px; height: 18px; }
.topbar .chip b { color: var(--ink); font-weight: normal; }
.rail { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.rail.left { grid-area: left; }
.rail.right { grid-area: right; }
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px; font-size: 13px; position: relative; background: var(--panel);
}
.rail-btn .icon { font-size: 26px; line-height: 1; }
.rail-btn.active { border-color: var(--accent); background: var(--panel-2); }
.rail-btn.glow { box-shadow: 0 0 0 2px var(--target), 0 0 16px rgba(255, 224, 102, .45); }
/* Secondary tools: small, low-contrast icon buttons. */
.rail-btn.quiet-rail {
  flex-direction: row; justify-content: center; gap: 6px; padding: 6px 4px; font-size: 12px;
  background: transparent; border-color: transparent; color: var(--muted);
}
.rail-btn.quiet-rail .icon { font-size: 15px; filter: grayscale(.6); opacity: .8; }
.rail-btn.quiet-rail:hover:not(:disabled) { color: var(--ink); background: var(--panel); }
.rail-btn.quiet-rail.active { color: var(--accent); background: var(--panel); border-color: transparent; }
.rail-btn.quiet-rail:disabled { opacity: .35; }
.rail.right { gap: 4px; }

/* End turn sits with the Ops, under your hand: muted until it's available, then the one
   bright button on screen. */
.ops-col { display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.ops-col .ops { padding: 0; }
.end-btn { padding: 10px 4px; font-size: 14px; }
.end-btn:disabled { background: transparent; border: 1px dashed #5a4a3c; color: var(--muted); opacity: .6; }
.end-btn:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #1d1714; font-weight: bold; box-shadow: 0 0 12px rgba(217, 164, 65, .45); }
.end-btn.pulse { animation: end-pulse 1.1s ease-in-out infinite; }
@keyframes end-pulse {
  50% { box-shadow: 0 0 0 4px var(--target), 0 0 26px rgba(255, 224, 102, .8); transform: scale(1.04); }
}
.rail-btn .count {
  position: absolute; top: 4px; right: 4px; background: var(--target); color: #1d1714;
  border-radius: 999px; font-size: 11px; padding: 0 6px; font-weight: bold;
}

/* ----- your stats (in the top bar) ----- */
/* Florins: a labelled gold pill next to your name. */
.topbar .florins {
  position: relative; display: inline-flex; align-items: baseline; gap: 4px;
  background: var(--gold); color: #2a1d08; border-radius: 999px; padding: 1px 12px 1px 10px; border: 2px solid #6b4f12;
}
.topbar .florins { align-items: center; }
.topbar .florins .ico { width: 18px; height: 18px; }
.topbar .florins .n { font-size: 20px; font-weight: bold; }
.topbar .florins.up { animation: gain 1.2s ease; }
.topbar .florins.down { animation: loss 1.2s ease; }
@keyframes gain { 20% { background: #7fd08a; transform: scale(1.1); } }
@keyframes loss { 20% { background: #e07a6a; transform: scale(1.1); } }
.topbar .delta { position: absolute; right: -10px; top: -10px; font-size: 12px; font-weight: bold; padding: 0 5px; border-radius: 999px; animation: rise 1.6s ease forwards; }
.topbar .delta.up { background: #2f8f5d; color: #fff; }
.topbar .delta.down { background: var(--red); color: #fff; }
@keyframes rise { to { transform: translateY(-12px); opacity: 0; } }

/* Stat blocks: a small caption over an icon and value. */
.mystats { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.mystats .stat { display: inline-flex; align-items: center; padding: 2px 10px; border-left: 1px solid #4a3d33; cursor: default; }
.mystats .stat:first-child { border-left: none; }
.mystats .val { display: inline-flex; align-items: center; gap: 5px; font-size: 16px; color: var(--ink); min-height: 24px; }
.mystats .val > .ico { width: 19px; height: 19px; color: var(--muted); }
.mystats .none { color: var(--muted); font-size: 13px; }
.mystats .pip { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--accent); }
.mystats .pip.on { background: var(--accent); }
.mystats .slot { width: 11px; height: 15px; border-radius: 2px; border: 2px solid #8a7a66; }
.mystats .slot.on { background: var(--ink); border-color: var(--ink); }
.mystats .slot.over { border-color: var(--danger); background: var(--danger); }
.mystats .num { font-size: 13px; color: var(--muted); margin-left: 2px; }
.mystats .warn .num { color: var(--target); }
.mystats .pr { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; }
.mystats .pr .g { font-size: 16px; }

/* ----- stage: map / market / players ----- */
.stage {
  grid-area: stage; position: relative; aspect-ratio: 1000 / 524;
  /* As wide as possible while leaving room for the top bar and the hand panel below,
     always keeping the map's proportions. */
  width: min(100%, calc((100vh - 306px) * 1000 / 524)); justify-self: center; margin: 0 auto; background: #120e0c; border-radius: var(--radius); overflow: hidden;
}
.viewport { position: absolute; inset: 0; overflow: hidden; }
.board { position: absolute; left: 0; top: 0; width: 1600px; height: 1600px; transform-origin: 0 0; transition: transform .45s ease; user-select: none; }
.board > img { width: 100%; height: 100%; display: block; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; }
#board-cards { pointer-events: none; }
#board-cards > * { pointer-events: auto; }
#board-cards .board-card { position: absolute; transform: translate(-50%, -50%); border-radius: 4%; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.board-square { position: absolute; transform: translate(-50%, -50%); border-radius: 6%; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.florins-badge {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--gold); color: #2a1d08; border-radius: 999px; font-weight: bold;
  padding: 0 8px; font-size: 22px; border: 2px solid #6b4f12; white-space: nowrap;
}
#board-svg { pointer-events: none; }
#board-svg .target, #board-svg .tok { pointer-events: auto; }
svg text { font-family: 'Segoe UI Symbol', 'Apple Symbols', 'DejaVu Sans', sans-serif; }
.ring { fill: none; stroke: none; pointer-events: none; }
.target { cursor: pointer; }
.target-ring { fill: none; stroke: var(--target); stroke-width: 5; animation: pulse 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes pulse { 50% { stroke-opacity: .25; } }
.html-target { outline: 4px solid var(--target); outline-offset: 2px; cursor: pointer; animation: pulse-outline 1.2s ease-in-out infinite; }
@keyframes pulse-outline { 50% { outline-color: rgba(255, 224, 102, .3); } }

/* Empire Squares slide in over the top and bottom edges of the map. */
.strip-toggle {
  position: absolute; left: 6px; z-index: 6; padding: 2px 12px; font-size: 12px; letter-spacing: .05em;
  background: rgba(42, 34, 29, .9); color: var(--muted); border-color: #5a4a3c;
}
.strip-toggle.top { top: 6px; }
.strip-toggle.bottom { bottom: 6px; }
.strip-toggle.open { color: var(--ink); border-color: var(--accent); }
.strip-toggle.glow { background: var(--target); color: #1d1714; border-color: var(--target); }
.empire-strip {
  position: absolute; left: 0; right: 0; z-index: 4;
  background: linear-gradient(rgba(29, 23, 20, .92), rgba(29, 23, 20, .82));
  transition: transform .25s ease; pointer-events: none;
}
.empire-strip.top { top: 0; transform: translateY(-101%); }
.empire-strip.bottom { bottom: 0; transform: translateY(101%); }
.empire-strip.open { transform: none; pointer-events: auto; }
.strip-square { position: absolute; top: 50%; aspect-ratio: 1; transform: translate(-50%, -50%); }
.strip-square .square-img { width: 100%; height: 100%; }
.strip-square .owner {
  position: absolute; left: 50%; bottom: -2px; transform: translate(-50%, 50%); white-space: nowrap;
  font-size: 12px; padding: 0 8px; border-radius: 999px; color: #1d1714; font-weight: bold; border: 1px solid #1d1714;
}
.strip-square.away .square-img { filter: grayscale(.6) brightness(.6); }

.overlay-view { position: absolute; inset: 0; z-index: 4; background: rgba(29, 23, 20, .94); }
.victory-view { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3%; align-items: center; padding: 3% 4%; }
.victory-view .vic { text-align: center; color: var(--muted); }
.victory-view .vic img { width: 100%; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.6); display: block; margin-bottom: 8px; }
.victory-view .vic.active { color: var(--ink); }

.players-view { position: absolute; inset: 0; overflow: auto; padding: 12px; display: grid; gap: 12px; align-content: start; background: var(--bg); }

.log-drawer { position: absolute; right: 0; top: 0; bottom: 0; width: min(380px, 80%); z-index: 6; background: rgba(42, 34, 29, .97); padding: 12px; overflow: auto; border-left: 1px solid #5a4a3c; }
.log-drawer h3 { margin: 0 0 6px; color: var(--muted); font-weight: normal; }
.log { margin: 0; padding-left: 22px; font-size: 13px; color: var(--ink); }

.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 7;
  background: var(--danger); color: #fff; padding: 6px 12px; border-radius: 6px;
}

/* ----- me: hand + own tableau ----- */
.me { grid-area: me; display: grid; gap: 10px; }
.hand-strip { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); gap: 10px; align-items: center; background: var(--panel); border-radius: var(--radius); padding: 8px 0 8px 14px; }
.hand-main { min-width: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 6px; }
/* Hand (narrow: at most 2 cards, usually) beside the Tableau. */
.hand-main { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; }
.zone h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: normal; }
.hand-zone { min-width: 300px; max-width: 560px; border-right: 1px solid #4a3c31; padding-right: 14px; }
.tableau-zone { min-width: 0; }
.pane { height: 176px; }
#my-tableau .row { height: 100%; padding: 0; align-items: center; }
#my-tableau .row { --w: 100px; }
.hand { display: flex; gap: 12px; overflow-x: auto; --w: 112px; min-height: 172px; align-items: center; }
.hand .empty { max-width: 200px; }
.ops { display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.ops .ops-btn { padding: 10px 4px; }
.ops .ops-btn.html-target { background: var(--accent); color: #1d1714; font-weight: bold; outline-offset: 0; }
.hand .empty { color: var(--muted); }

/* ----- cards ----- */
.card {
  width: var(--w, 96px);
  aspect-ratio: 653 / 1000;
  background-repeat: no-repeat;
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,.6);
  position: relative;
  flex: none;
}
.square-img { width: var(--w, 96px); aspect-ratio: 1; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.6); display: block; }
.badges { position: absolute; left: 2px; bottom: 2px; display: flex; flex-wrap: wrap; gap: 2px; max-width: 100%; }
.badge {
  min-width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 13px; color: #fff; border: 1px solid rgba(0,0,0,.6); padding: 0 2px;
}
.badge.catholic { background: var(--gold); color: #2a1d08; }
.badge.islamic { background: var(--green); }
.badge.reformist { background: var(--red); }
.badge sup { font-size: 9px; font-weight: bold; margin-left: 1px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); }

/* ----- tableaux ----- */
.tableau { background: var(--panel); border-radius: var(--radius); padding: 10px 12px; border-left: 6px solid var(--c, #888); }
.tableau.current { box-shadow: 0 0 0 2px var(--accent); }
.tableau header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.tableau header .name { font-size: 17px; font-weight: bold; }
.tableau header .stats { color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.row { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; padding: 6px 4px 8px; --w: 100px; }
.row .side { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; align-self: center; }
.row .side-label { color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.player-board {
  width: 108px; min-height: calc(100px * 1000 / 653); flex: none; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(160deg, #4a3a2c, #2a201a); border: 2px solid var(--c, #888); text-align: center; padding: 4px;
}
.player-board .maids { display: flex; gap: 2px; --w: 44px; }
/* With the banker's art the board is the picture; Old Maids sit along its bottom. */
.player-board { position: relative; overflow: hidden; }
.player-board .banker-art { display: none; }
.player-board.has-art { padding: 0; justify-content: flex-end; background: none; border: none; aspect-ratio: 1146 / 1608; min-height: 0; }
.player-board.has-art .banker-art { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.player-board.has-art > b, .player-board.has-art > small { display: none; }
.player-board.has-art .maids { position: relative; margin-bottom: 4px; }
.zoom .banker-big { display: block; width: 300px; border-radius: 10px; }
/* A bank's escutcheon, in place of its color dot. */
.shield { width: 16px; height: 18px; object-fit: contain; flex: none; filter: drop-shadow(0 0 1px rgba(0,0,0,.8)); }
.topbar .who .shield { width: 20px; height: 23px; }
.seat .shield { width: 18px; height: 21px; }
.stack { display: flex; flex-direction: column; gap: 4px; align-items: center; position: relative; }
.stack .queen { --w: 74px; }

/* ----- overlays ----- */
.zoom { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; --w: 340px; filter: drop-shadow(0 8px 20px rgba(0,0,0,.8)); }
.zoom .square-img { --w: 360px; }
.menu {
  position: fixed; z-index: 25; display: grid; gap: 4px; min-width: 220px; max-width: 360px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.menu button { text-align: left; }
.winner {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(0,0,0,.7); font-size: 32px; text-align: center;
}
.winner > div { background: var(--panel); padding: 30px 40px; border-radius: var(--radius); border: 2px solid var(--accent); }

@media (max-width: 900px) {
  :root { --rail: 64px; }
  .rail-btn { font-size: 11px; }
  .hand { --w: 100px; }
}

/* ----- question banner positions (chosen to avoid covering targets) ----- */
/* ----- what just happened ----- */
.ping { fill: none; stroke: var(--target); stroke-width: 6; transform-box: fill-box; transform-origin: center; animation: ping 1.6s ease-out forwards; pointer-events: none; }
@keyframes ping { 0% { transform: scale(.4); stroke-opacity: 1; } 100% { transform: scale(1.6); stroke-opacity: 0; } }
.changed { animation: changed 1.6s ease-out; }
@keyframes changed { 0%, 30% { box-shadow: 0 0 0 5px var(--target), 0 0 30px var(--target); } 100% { box-shadow: 0 0 0 0 transparent; } }
.entered { animation: entered .7s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes entered { from { transform: translateY(-40px) scale(.6); opacity: 0; } }
.others [data-player].changed { border-radius: 6px; }

.caption {
  position: absolute; left: 12px; bottom: 44px; z-index: 4; max-width: 46%;
  background: rgba(29, 23, 20, .9); border-left: 4px solid var(--accent); border-radius: 6px;
  padding: 6px 12px; font-size: 14px; pointer-events: none; opacity: 0;
}
.caption .sub { color: var(--muted); padding-left: 10px; font-size: 13px; }
.caption.show { animation: caption 4.5s ease forwards; }
@keyframes caption { 0% { opacity: 0; transform: translateY(8px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.summary {
  position: absolute; right: 12px; top: 12px; z-index: 6; width: min(420px, 60%); max-height: 80%; overflow: auto;
  background: rgba(42, 34, 29, .97); border: 2px solid var(--accent); border-radius: var(--radius); padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.summary h3 { margin: 0 0 6px; font-weight: normal; }
.summary ol { margin: 0 0 10px; padding-left: 20px; font-size: 13px; }
.summary .sub { list-style: none; color: var(--muted); }

/* Bot speed, at the foot of the right rail. */
.rail-speed { margin-top: auto; display: flex; flex-direction: column; gap: 3px; padding: 0 4px; }
.rail-speed { flex-direction: row; align-items: center; gap: 4px; color: var(--muted); }
.rail-speed .icon .ico { width: 16px; height: 16px; }
.rail-speed select { flex: 1; min-width: 0; }
.rail-speed select { font: inherit; font-size: 13px; background: var(--bg); color: var(--ink); border: 1px solid #5a4a3c; border-radius: 4px; }
img.card.back { object-fit: cover; }

/* ----- rules help ----- */
.zoom-box { display: flex; align-items: flex-start; gap: 10px; }
.zoom-box > .card, .zoom-box > .square-img { flex: none; }
.details {
  width: 300px; background: rgba(29, 23, 20, .97); border: 1px solid #5a4a3c; border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px;
}
.details h4 { margin: 0; font-size: 16px; font-weight: normal; }
.details .sub { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.details dl { margin: 0; }
.details dt { color: var(--accent); margin-top: 6px; }
.details dd { margin: 0; color: var(--ink); }
.details dt.blocked { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(224, 107, 90, .7); }
.details .why { margin-top: 2px; padding: 3px 6px; border-left: 3px solid var(--danger); background: rgba(224, 107, 90, .15); color: var(--ink); font-size: 12px; }
.details .note { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: rgba(224, 107, 90, .2); border-left: 3px solid var(--danger); }
.zoom { --w: 280px; }
.zoom .square-img { --w: 300px; }
.zoom .map-card-img { display: block; width: 240px; border-radius: 8px; }

.rules-view { overflow: auto; padding: 16px 20px; font-size: 13px; z-index: 8; background: rgba(29, 23, 20, .98); }
.rules-view { padding: 0; display: flex; flex-direction: column; }
.rules-tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid #4a3d33; position: sticky; top: 0; background: rgba(29, 23, 20, .98); z-index: 1; }
.rules-tabs button { padding: 4px 12px; background: transparent; border-color: transparent; color: var(--muted); }
.rules-tabs button.on { color: var(--ink); border-color: var(--accent); background: var(--panel-2); }
.rules-tabs .close { margin-left: auto; }
.rules-body { padding: 12px 20px 20px; }
/* The player aid pages: full width of the stage, scrolled. */
.rules-view .aid { display: block; width: 100%; height: auto; border-radius: 6px; }
.rules-view .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.rules-view h3 { margin: 6px 0 4px; font-weight: normal; color: var(--accent); }
.rules-view p { margin: 0 0 6px; }
.rules-view dt { font-weight: bold; margin-top: 4px; }
.rules-view dd { margin: 0 0 2px; color: var(--muted); }

/* A King with his Queen (and Vassals) must fit the panel's height. */
#my-tableau .stack { max-height: 100%; }
#my-tableau .stack:has(> .card, > .stack) .square-img { --w: 80px; }
#my-tableau .stack .queen { --w: 54px; }
#my-tableau .stack .stack .square-img { --w: 60px; }

/* ----- setup: continue / options ----- */
.setup h2 { font-size: 18px; font-weight: normal; margin: 18px 0 4px; color: var(--accent); }
.continue h2 { margin-top: 0; }
.saved { display: grid; gap: 6px; }
.saved-game { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; }
.saved-game > div { flex: 1; }
.saved-game small { color: var(--muted); }
.setup-options { display: flex; align-items: center; gap: 20px; margin-bottom: 14px; }
.setup-options .seed { margin: 0; }
.check { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.open-file { display: block; margin-top: 10px; color: var(--muted); font-size: 13px; cursor: pointer; }
.open-file input { font-size: 12px; margin-left: 6px; color: var(--muted); }

/* ----- placing pieces ----- */
/* The piece in hand follows the cursor over the board; the hint replaces your stats. */
.carry {
  position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none;
  width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; line-height: 1;
  border: 2.5px solid #1d1714; box-shadow: 0 6px 14px rgba(0, 0, 0, .55); opacity: .92;
}
.carry[hidden] { display: none; }
.carry sup, .hint-piece sup {
  position: absolute; right: -6px; bottom: -4px; font-size: 9px; font-weight: bold; line-height: 1;
  background: #f6efe0; color: #1d1714; border: 1px solid #1d1714; border-radius: 6px; padding: 1px 3px;
}
.carrying #stage, .carrying #stage .target { cursor: none; }
.hint { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 10px 2px 4px; border-left: 3px solid var(--c, var(--accent)); }
.hint b { font-weight: normal; font-size: 16px; }
.hint button { padding: 4px 10px; }
.hint-piece {
  position: relative; width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 17px; line-height: 1; border: 2px solid #1d1714;
}

/* ----- questions about one thing: a callout beside it ----- */
.ask {
  position: fixed; z-index: 15; display: flex; gap: 14px; align-items: flex-start; max-width: min(640px, 94vw);
  background: rgba(42, 34, 29, .97); border: 2px solid var(--c, var(--accent)); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, .6); animation: lift .18s ease-out;
}
.ask[hidden] { display: none; }
@keyframes lift { from { transform: translateY(10px) scale(.96); opacity: 0; } }
.ask .ask-card { --w: 170px; flex: none; }
.ask .square-img { --w: 170px; flex: none; }
.ask-side { display: grid; gap: 10px; min-width: 200px; }
.ask-title { font-size: 16px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-chips button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; }
.ask-chips button:first-child { border-color: var(--c, var(--accent)); }
.chip-piece {
  position: relative; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 16px; line-height: 1; border: 2px solid #1d1714; flex: none;
}
.chip-piece sup {
  position: absolute; right: -6px; bottom: -4px; font-size: 8px; font-weight: bold; line-height: 1;
  background: #f6efe0; color: #1d1714; border: 1px solid #1d1714; border-radius: 6px; padding: 1px 3px;
}
.battle { display: grid; gap: 8px; }
.battle-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; opacity: .75; }
.battle-line.choose { opacity: 1; }
.battle-label { color: var(--muted); font-size: 12px; min-width: 96px; }
.battle-piece { background: none; border: 2px solid transparent; border-radius: 50%; padding: 2px; }
button.battle-piece { cursor: pointer; border-color: var(--target); }
button.battle-piece:hover { background: rgba(255, 224, 102, .2); }
.battle-note { color: var(--muted); font-size: 12px; }
.spotlight { position: fixed; z-index: 14; pointer-events: none; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 0 0 3px rgba(0, 0, 0, .5), 0 0 22px #fff; }
.spotlight[hidden] { display: none; }

/* ----- a bot buys a card: it lifts out of the market and fades ----- */
#board-cards .board-card.leaving { z-index: 3; animation: leave var(--leave, 1200ms) ease-in forwards; }
@keyframes leave {
  /* Board cards are centred with translate(-50%, -50%); keep that. */
  0% { transform: translate(-50%, -50%); }
  35% { transform: translate(-50%, -58%) scale(1.08); box-shadow: 0 0 0 4px var(--target), 0 0 28px var(--target); opacity: 1; }
  100% { transform: translate(-50%, -95%) scale(.8); box-shadow: 0 0 0 4px var(--target), 0 0 28px var(--target); opacity: 0; }
}

/* ----- music player (left rail): one quiet button; controls in a popover ----- */
.music { margin-top: auto; }
.music-btn.playing { color: var(--accent); }
.music-btn.playing .icon { filter: none; opacity: 1; animation: sway 2.4s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(-10deg); } }
.music-pop {
  position: fixed; z-index: 60; width: 240px; display: grid; gap: 8px;
  background: rgba(29, 23, 20, .97); border: 1px solid #5a4a3c; border-radius: var(--radius); padding: 10px 12px;
}
.music-pop[hidden] { display: none; }
.music-now { font-size: 14px; color: var(--ink); }
.music-suite { font-size: 11px; color: var(--muted); margin-top: -6px; }
.music-row { display: flex; gap: 6px; }
.music-mini { flex: 1; padding: 4px 0; font-size: 14px; }
.music-vol-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.music-vol-row span { width: 44px; }
.sfx-vol { flex: 1; height: 14px; accent-color: var(--accent); cursor: pointer; }
.music-vol { flex: 1; height: 14px; accent-color: var(--accent); cursor: pointer; }
.music-album { justify-self: start; padding: 2px 0; font-size: 12px; }

.music-list {
  position: fixed; z-index: 60; width: 320px; max-height: 80vh; overflow: auto;
  background: rgba(29, 23, 20, .97); border: 1px solid #5a4a3c; border-radius: var(--radius);
  padding: 8px 10px 10px; font-size: 13px;
}
.music-list header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.music-list header b { flex: 1; }
.music-list header .quiet.on { color: var(--accent); }
.music-list h4 { margin: 10px 0 2px; font-size: 12px; color: var(--muted); font-weight: normal; }
.music-track {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left;
  padding: 3px 6px; border-color: transparent; background: none; font-size: 12px;
}
.music-track:hover { background: var(--panel-2); }
.music-track .n { width: 18px; color: var(--muted); text-align: right; flex: none; }
.music-track .t { flex: 1; }
.music-track .d { color: var(--muted); flex: none; }
.music-track.current { color: var(--accent); }
.music-track.playing .n::after { content: ' ♪'; }

/* ----- icons (web/icons.js): one line style everywhere ----- */
.ico { width: 1em; height: 1em; flex: none; vertical-align: -.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico.solid { fill: currentColor; stroke: none; }
.rail-btn .icon { display: inline-flex; }
.rail-btn .icon .ico { width: 26px; height: 26px; }
.rail-btn.quiet-rail .icon .ico { width: 16px; height: 16px; }
.rail-btn.quiet-rail .icon { filter: none; opacity: .85; }
.tableau header .stats span { display: inline-flex; align-items: center; gap: 3px; }
.tableau header .stats .ico { width: 15px; height: 15px; }
.mystats .pr .g .ico, .tableau header .stats .ico.solid { width: 16px; height: 16px; }
.winner .ico.win { width: 34px; height: 34px; color: var(--accent); vertical-align: -.2em; }
.rules-view .ico { width: 15px; height: 15px; }
.ico.glyph { width: .9em; height: .9em; vertical-align: -.1em; }
.seat-card .shield { width: 18px; height: 21px; }

/* ----- hot seat: the pass-the-device screen ----- */
.pass { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(18, 14, 12, .97); }
.pass[hidden] { display: none; }
.pass-card { text-align: center; max-width: 420px; padding: 28px 36px; background: var(--panel); border-radius: var(--radius); border-top: 5px solid var(--pc); }
.pass-card h2 { margin: 8px 0; font-weight: normal; font-size: 28px; }
.pass-card p { color: var(--muted); margin: 0 0 18px; }
.pass-shield .shield { width: 56px; height: 64px; }
.pass-shield .dot { width: 40px; height: 40px; }
/* Keep hands out of the page (and of hover previews) until revealed. */
.passing #me, .passing #zoom { visibility: hidden; }
.seat-card.out { opacity: .4; filter: grayscale(1); }

/* ----- first-game tips (coach.js) ----- */
.coach {
  position: fixed; z-index: 25; width: 300px; padding: 12px 14px; border-radius: var(--radius);
  background: #f3e7c9; color: #2a1d08; box-shadow: 0 10px 28px rgba(0,0,0,.55); font-size: 14px; line-height: 1.4;
}
.coach[hidden] { display: none; }
.coach::before {
  content: ''; position: absolute; left: calc(var(--ax, 50%) - 8px); width: 0; height: 0;
  border: 8px solid transparent;
}
.coach[data-side="below"]::before { top: -16px; border-bottom-color: #f3e7c9; }
.coach[data-side="above"]::before { bottom: -16px; border-top-color: #f3e7c9; }
.coach-text b { color: #6b3d00; }
.coach-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.coach-row .quiet { color: #6b5a44; }
.coach-target { box-shadow: 0 0 0 3px #f3e7c9, 0 0 18px rgba(243, 231, 201, .7) !important; border-radius: 6px; }

/* ----- market refill: cards slide down the row; drawn cards fly in from the pile ----- */
#board-cards .board-card.arrive { z-index: 2; animation: arrive .55s cubic-bezier(.3, .7, .3, 1) both; }
@keyframes arrive {
  from { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))); }
  to { transform: translate(-50%, -50%); }
}
/* A drawn card starts face down on the pile and turns over as it lands. */
#board-cards .board-card.arrive.drawn { animation: draw .7s cubic-bezier(.3, .7, .3, 1) both; }
@keyframes draw {
  0% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotateY(90deg) scale(.9); filter: brightness(.4); }
  45% { filter: brightness(.7); }
  100% { transform: translate(-50%, -50%) rotateY(0) scale(1); filter: none; box-shadow: 0 0 0 3px var(--target), 0 2px 6px rgba(0,0,0,.6); }
}
.seed #reroll { padding: 2px 8px; margin-left: 4px; font-size: 16px; }

/* ----- online play ----- */
.online-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); }
.online-row input { width: 110px; font: inherit; text-transform: uppercase; background: var(--bg); color: var(--ink); border: 1px solid #5a4a3c; border-radius: 4px; padding: 3px 6px; margin: 0 6px; }
.lobby-link { display: flex; gap: 8px; margin: 8px 0 16px; }
.lobby-link input { flex: 1; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid #5a4a3c; border-radius: 4px; padding: 4px 8px; }
.lobby .seat .who { color: var(--muted); }
.lobby .seat button { margin-left: 8px; }
.net-status { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--danger); color: #fff; padding: 6px 14px; border-radius: 6px; }
.net-status[hidden] { display: none; }
