/* Registered so ring turns can transition smoothly; kids and icons counter-rotate with the same value. */
@property --rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}

:root {
  --bg: #efe5d3;
  --panel: #fffaf1;
  --ink: #2b2420;
  --muted: #7a6f66;
  --line: #e2d5bf;
  --felt-1: #3b7363;
  --felt-2: #234a40;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
h1, h2, h3, h4 { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 600; margin: 0 0 0.4em; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.primary {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}
.primary:disabled { opacity: 0.45; cursor: not-allowed; font-weight: 500; }
.secondary {
  display: block;
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  background: transparent;
  font-weight: 700;
}
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; }
.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.35);
  vertical-align: -2px;
  margin-right: 6px;
}
.swatch.big { width: 22px; height: 22px; }

/* ---------- setup ---------- */
#setup { max-width: 640px; margin: 48px auto; padding: 0 16px; }
.setup-card {
  background: var(--panel);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(60, 40, 20, 0.14);
}
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.1em; font-size: 12px; color: var(--muted); }
.setup-card h1 { font-size: 40px; margin: 4px 0 10px; }
.lede { color: var(--muted); margin: 0 0 22px; }
.field { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 12px; }
select, input {
  font: inherit;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.prow { display: flex; align-items: center; margin-bottom: 8px; }
.prow input { flex: 1; }
.prow select { margin-left: 8px; font: inherit; padding: 6px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; }
.autoplay { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.autoplay select { font: inherit; border-radius: 6px; padding: 2px 4px; }
.house { margin: 18px 0; }
.house summary { cursor: pointer; font-weight: 600; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 12px; }
.rule-grid label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.rule-grid input { width: 72px; }
.rule-grid label.wide { grid-column: 1 / -1; }
.rule-grid label.wide input { width: 160px; }
.setup-actions { display: grid; gap: 10px; }

/* ---------- game layout ---------- */
#game { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: var(--ink);
  color: #f8efe2;
  flex-wrap: wrap;
}
.brand { font-family: 'Fredoka', system-ui, sans-serif; font-size: 18px; }
#status { font-size: 13px; opacity: 0.8; }
.spacer { flex: 1; }
.topbar button {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #f8efe2;
  border-radius: 8px;
  padding: 5px 10px;
}
.topbar button:disabled { opacity: 0.35; cursor: default; }
.table { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; }

/* ---------- the tabletop: dial in the middle, a mat at each seat, communal piles in the gaps ---------- */
.tabletop {
  /* The board is drawn at a fixed scale (the board script sets --board from its size) so a disc on it is
     exactly as big as a disc in the supply. It's much bigger than the mats around it; the table view
     shrinks the whole table to fit the window, and you zoom in to play. */
  --dial: var(--board, 1940px);
  display: grid;
  grid-template-columns: minmax(170px, 1fr) var(--dial) minmax(170px, 1fr);
  /* The middle row grows if the piles beside the board ever stand taller than it, rather than spilling. */
  grid-template-rows: auto minmax(var(--dial), auto) auto;
  grid-template-areas: 'tl top tr' 'left dial right' 'bl bottom br';
  gap: 14px;
  padding: 16px;
  height: 100%;
  align-content: safe center;
  justify-content: safe center;
  transform-origin: 0 0;
}
.table-view {
  position: relative;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background: #b98d5f url('art/board/table.jpg') center / 640px repeat;
}
.table-view.panning { cursor: grabbing; user-select: none; }
/* With 2-3 players the corners are free, so the top and bottom mats run the full width of the table. */
.tabletop:not([data-players='4']) { grid-template-areas: 'top top top' 'left dial right' 'bottom bottom bottom'; }
.slot { min-width: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; }
.slot:empty { display: none; }
[data-slot='tl'] { grid-area: tl; } [data-slot='top'] { grid-area: top; } [data-slot='tr'] { grid-area: tr; }
[data-slot='left'] { grid-area: left; } [data-slot='right'] { grid-area: right; }
[data-slot='bl'] { grid-area: bl; } [data-slot='bottom'] { grid-area: bottom; } [data-slot='br'] { grid-area: br; }
.dial { grid-area: dial; position: relative; width: var(--dial); height: var(--dial); align-self: center; }
#board { width: 100%; height: 100%; display: block; filter: drop-shadow(0 14px 22px rgba(30, 15, 0, 0.45)); }
#inspect {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translate(-50%, 100%);
  width: max-content;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 8px;
  color: #f8efe2;
  background: rgba(30, 20, 10, 0.72);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
#inspect:empty { display: none; }
#inspect .muted { color: rgba(248, 239, 226, 0.7); }

/* player mats: printed cardstock lying on the table */
.mat {
  width: 100%;
  max-width: calc(var(--dial) + 520px);
  border-radius: 10px;
  padding: 8px 12px 10px;
  background: #f6ecd6 var(--mat, none) center / cover;
  box-shadow: 0 8px 18px rgba(40, 20, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  border-top: 6px solid var(--pc);
  font-size: 12px;
}
.mat.cur { box-shadow: 0 0 0 4px #ffe066, 0 8px 18px rgba(40, 20, 0, 0.4); }
.mat .plate { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.mat .plate b { font-family: 'Fredoka', system-ui, sans-serif; font-size: 16px; }
.mat .tally { margin-left: auto; color: var(--muted); }
.mat-body { display: grid; grid-template-columns: auto auto minmax(90px, auto) minmax(240px, 1fr); gap: 8px; }
.seat-left .mat-body, .seat-right .mat-body, .mat.seat-left .mat-body, .mat.seat-right .mat-body { grid-template-columns: 1fr; }
.zone {
  position: relative;
  min-height: 64px;
  padding: 3px 6px 5px;
  border: 1.5px dashed rgba(23, 89, 99, 0.45);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.35);
}
.zone-label {
  position: absolute;
  top: 2px;
  left: 8px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(23, 89, 99, 0.85);
  font-weight: 700;
}
/* On a mat the label sits above its zone's contents, so a long one wraps instead of running under them. */
.zone > .zone-label { position: static; display: block; margin: 0 2px 4px; line-height: 13px; }
.zone .pieces, .zone .piles { display: flex; flex-wrap: wrap; gap: 2px 3px; align-items: center; }
.zone.pen .pens { display: grid; grid-template-columns: repeat(3, auto); gap: 4px; }
.round-pen { min-width: 58px; min-height: 52px; padding: 2px 3px 3px; border-radius: 6px; border: 1.5px dashed rgba(59, 48, 39, 0.35); background: rgba(255, 252, 244, 0.35); }
.round-pen small { display: block; font-size: 9px; font-weight: 700; color: #6b5a48; white-space: nowrap; }
.round-pen .pieces { display: grid; grid-template-columns: repeat(2, auto); gap: 1px; justify-content: start; }
.round-pen.cur { border-style: solid; border-color: var(--pc, #2b2420); background: rgba(255, 236, 160, 0.55); box-shadow: 0 0 0 2px rgba(255, 224, 102, 0.6); }
.round-pen.done { opacity: 0.45; }
.zone.out .pieces { max-width: calc(4 * 29px); }
.zone.discs .piles { display: grid; grid-template-columns: repeat(3, 38px); gap: 8px 6px; }
.zone.cheat ul { margin: 0; padding-left: 14px; font-size: 10px; line-height: 1.25; color: #3b3027; columns: 2; column-gap: 16px; }
.zone.cheat li { break-inside: avoid; }
.zone.cheat li { margin-bottom: 2px; }
.mat.seat-left .zone.cheat ul, .mat.seat-right .zone.cheat ul { columns: 1; }
.pawn { padding: 0; border: 0; background: none; line-height: 0; border-radius: 50%; cursor: pointer; }
button.pawn:hover { background: rgba(255, 224, 102, 0.6); }
.pawn.sel { background: #ffe066; box-shadow: 0 0 0 2px var(--ink); }
.packed { margin-top: 4px; font-size: 11.5px; }

/* the key: one row per danger and safe zone, each chip in the colour the board uses, symbol on a white middle */
.commons.key {
  display: block;
  width: 100%;
  max-width: 300px;
  min-width: 170px;
  padding: 28px 10px 10px;
  position: relative;
  border-radius: 10px;
  background: #fffaf0;
  box-shadow: 0 8px 18px rgba(40, 20, 0, 0.35), inset 0 0 0 2px rgba(94, 70, 48, 0.25);
}
.commons.key .zone-label { position: absolute; top: 6px; left: 0; right: 0; transform: none; text-align: center; color: #3b3027; text-shadow: none; }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.key-list li { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; font-size: 13px; }
.key-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.key-list small { color: #6b5a48; font-size: 11px; }
.key-chip {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--tc);
  border: 1.5px solid rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.key-chip span { width: 21px; height: 21px; border-radius: 50%; background: #fffdf7; display: grid; place-items: center; font-size: 13px; line-height: 1; }
.key-note { margin: 8px 0 0; font-size: 11px; color: #6b5a48; }

/* disc tokens: a little stack of glossy discs with the count on top */
.disc-pile {
  position: relative;
  width: 38px;
  height: 68px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.disc-pile:disabled { cursor: default; }
/* The count rides on the top disc of the stack, so it never pokes out above the pile. */
.disc-pile .count { top: auto; bottom: calc(36px + var(--top, 0) * 2.5px); }
.disc-token {
  position: absolute;
  left: 4px;
  bottom: calc(16px + var(--i) * 2.5px);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), transparent 45%), var(--tc);
  border: 1.5px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 1.5px 0 rgba(0, 0, 0, 0.35);
}
.disc-token.empty { background: none; border: 1.5px dashed rgba(0, 0, 0, 0.3); box-shadow: none; }
.disc-icon { position: absolute; left: 9px; bottom: calc(21px + var(--top, 0) * 2.5px); width: 20px; height: 20px; border-radius: 50%; background: #fffdf7; display: grid; place-items: center; font-size: 12px; line-height: 1; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #2b2420;
  color: #fff;
  font-size: 10.5px;
  line-height: 18px;
  text-align: center;
}
.disc-pile:not(:disabled):hover .disc-token { filter: brightness(1.12); }
.disc-name { position: absolute; left: -6px; right: -6px; bottom: 0; font-size: 9.5px; font-weight: 700; line-height: 13px; text-align: center; color: #3b3027; }

/* face-down hands by each mat */
.hand-fan { position: relative; width: 70px; height: 34px; margin-left: 8px; }
.fan-card {
  position: absolute;
  left: calc(var(--n) * (46px / max(var(--of), 1)));
  top: 2px;
  width: 20px;
  height: 30px;
  border-radius: 3px;
  background: #5f3dc4 center / cover;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transform: rotate(calc((var(--n) - var(--of) / 2) * 6deg));
}

/* communal piles */
.commons { display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; padding-top: 14px; }
.commons .zone-label { color: #fff8ec; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); left: 50%; transform: translateX(-50%); white-space: nowrap; }
.commons .piles { display: grid; grid-template-columns: repeat(3, 38px); gap: 6px; padding-top: 4px; }
.piles-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
.stack { position: relative; width: 84px; height: 118px; padding: 0; border: 0; background: none; cursor: pointer; margin-bottom: 18px; }
.stack.tile { width: 92px; height: 92px; }
.stack .sheet {
  position: absolute;
  inset: 0;
  transform: translate(calc(var(--i) * -0.8px), calc(var(--i) * -1.4px));
  border-radius: 6px;
  background: #1f6f78 center / cover;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.stack.empty { border: 2px dashed rgba(255, 248, 236, 0.5); border-radius: 6px; }
.stack .count { top: -10px; right: -10px; }
.stack-label { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); white-space: nowrap; font-size: 11px; color: #fff8ec; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
  background: #fffaf1;
  border: 4px solid var(--cc);
  font-size: 26px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}
.card-face small { font-size: 10px; padding: 0 4px; text-align: center; }
.tile-face { position: absolute; inset: 0; border-radius: 6px; background: #8a2b2b center / cover; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4); }

/* the Hall of Unfortunate Incidents: a velvet shadow box, one row of lost kids per caretaker */
.commons.hall { width: 100%; max-width: 300px; padding-top: 18px; }
.hall-box {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  padding: 11% 8% 7%;
  background: var(--hall, #1d1a19) center / 100% 100%;
  border-radius: 4px;
  box-shadow: 0 8px 18px rgba(40, 20, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hall-plaque {
  position: absolute;
  top: 1.3%;
  left: 37%;
  width: 26%;
  height: 6.4%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 clamp(7px, 1.1vw, 11px) / 1 Georgia, serif;
  color: #3b2a12;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5);
}
/* A long row of lost kids wraps and the box grows taller (the 3:2 shape is only its smallest), rather than
   squeezing the rows so the pawns spill over the plaque. */
.hall-row { display: flex; flex: none; align-items: center; gap: 4px; min-height: 24px; }
.hall-row .swatch { flex: none; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4); }
.hall-row > b { margin-left: auto; color: #d9cbb0; font-size: 11px; }
/* Just the pawns, faded, with a pale glow so even a black pawn reads against the velvet. */
.hall-kids { display: flex; flex-wrap: wrap; gap: 0; }
.hall-kids .pawn { margin-right: -7px; filter: saturate(0.6) drop-shadow(0 0 1.5px rgba(255, 240, 215, 0.85)); }
.hall-kids .pawn:hover { filter: drop-shadow(0 0 3px #fff3c4); }
.hall-kids .halo, .hall-kids .piece-shadow, .hall-kids .disc.bare { display: none; }
.facedown { position: relative; padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.era-row-down { display: flex; align-items: center; gap: 4px; color: #fff8ec; font-size: 11px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.era-row-down small { width: 84px; text-align: right; }
.mini-back { width: 16px; height: 24px; border-radius: 3px; border: 2px solid var(--pc); background: #5f3dc4 center / cover; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }

/* the era-steering board: its own little board on the table, one slot per era */
.steering {
  width: 100%;
  max-width: 300px;
  padding: 26px 10px 10px;
  position: relative;
  border-radius: 10px;
  background: linear-gradient(rgba(20, 60, 66, 0.82), rgba(14, 44, 49, 0.9)), url('art/board/wood.jpg') center / 400px;
  box-shadow: 0 8px 18px rgba(40, 20, 0, 0.45), inset 0 0 0 2px rgba(255, 236, 200, 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.steer-title {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f8e6c4;
}
.steer-slot {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1.5px dashed rgba(248, 230, 196, 0.45);
  background: rgba(0, 0, 0, 0.18);
  color: #f8e6c4;
  font: inherit;
  text-align: left;
}
.steer-slot.open { cursor: pointer; border-style: solid; border-color: #ffe066; animation: glow-border 0.9s ease-in-out infinite alternate; }
.steer-slot.open:hover { background: rgba(255, 224, 102, 0.22); }
@keyframes glow-border { from { box-shadow: 0 0 0 0 rgba(255, 224, 102, 0.6); } to { box-shadow: 0 0 0 4px rgba(255, 224, 102, 0); } }
.steer-era { font-size: 12px; font-weight: 600; }
.steer-cards { display: flex; flex-wrap: wrap; gap: 4px; }
.steer-card {
  width: 26px;
  height: 38px;
  border-radius: 4px;
  border: 2px solid var(--pc);
  background: #5f3dc4 center / cover;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
}
.steer-card.face {
  width: auto;
  min-width: 38px;
  padding: 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fffaf1;
  color: #2b2420;
  font-size: 14px;
  line-height: 1;
}
.steer-card.face small { font-size: 8.5px; margin-top: 2px; white-space: nowrap; }
.steer-card.face .rank { font-weight: 700; font-size: 10px; }
/* a card that lost its era to a higher rank */
.steer-card.beaten, .cardface.beaten { opacity: 0.45; text-decoration: line-through; }
.crank { display: inline-block; padding: 0 5px; border-radius: 8px; background: #2b2420; color: #fffaf1; font-size: 11px; vertical-align: 1px; }
.disc-btn { border: 2px solid var(--tc); border-radius: 999px; background: #fff; padding: 2px 9px; font: inherit; cursor: pointer; }
.disc-btn.sel { background: var(--tc); color: #fff; }
.disc-btn:disabled { opacity: 0.4; cursor: default; }
.disc-btn .n { margin-left: 2px; }
/* the disc's own colour, matching what the kids wear on the board */
.disc-dot { display: inline-block; width: 11px; height: 11px; margin-right: 4px; border-radius: 50%; background: var(--tc); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); vertical-align: -1px; }
.disc-btn.sel .disc-dot { box-shadow: 0 0 0 1.5px #fff; }
.dbtn.static { display: inline-block; cursor: default; }
.steer-total { font-family: 'Fredoka', system-ui, sans-serif; font-size: 15px; color: #ffe066; white-space: nowrap; }

/* the close-up view of any piece */
.zoom {
  max-width: min(1100px, 94vw);
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #fffaf1;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.zoom::backdrop { background: rgba(20, 12, 4, 0.72); }
.zoom-body { display: flex; flex-wrap: wrap; align-items: stretch; }
.zoom-art { width: min(78vh, 640px); max-width: 94vw; aspect-ratio: 1; object-fit: cover; display: block; }
.zoom-art.piece { display: flex; align-items: center; justify-content: center; background: radial-gradient(circle, #fff6e2, #e9d8b8); }
.zoom-art.piece img { max-width: 80%; max-height: 80%; border-radius: 10px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }
.zoom-text { flex: 1; min-width: 260px; max-width: 420px; padding: 28px 26px; }
.zoom-text.wide { max-width: 520px; }
.zoom-text .eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.zoom-text .flavor { font-size: 17px; line-height: 1.45; font-style: italic; }
.zoom-close { position: absolute; top: 10px; right: 12px; border: 0; background: rgba(255, 255, 255, 0.85); border-radius: 50%; width: 34px; height: 34px; font-size: 16px; }
.disc-big {
  width: 60%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 110px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.6), transparent 45%), var(--tc);
  border: 6px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}
.card-big {
  width: 58%;
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  border-radius: 18px;
  background: #fffaf1;
  border: 10px solid var(--cc);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.card-big span { font-size: 72px; }
.card-big b { font-family: 'Fredoka', system-ui, sans-serif; font-size: 26px; }
#side { overflow-y: auto; padding: 14px; border-left: 1px solid var(--line); }

/* ---------- side panels ---------- */
.panel {
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(60, 40, 20, 0.08);
}
.panel > .primary { margin-top: 10px; }
.turn { border-top: 6px solid var(--pc); }
.who { display: flex; align-items: center; gap: 4px; }
.who h2 { margin: 0; }
.steps { margin: 10px 0; padding-left: 20px; font-size: 13.5px; }
.steps li { margin-bottom: 3px; }
.steps li.todo { color: #c92a2a; }
.steps li.done { color: var(--muted); text-decoration: line-through; }
.tray .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 2px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12.5px;
}
.chip.sel { border-color: var(--ink); background: #fff3bf; }
.context {
  margin: 10px 0;
  padding: 10px;
  border-radius: 10px;
  background: #f6eedf;
}
.context-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.context p { margin: 4px 0; }
.hint { font-size: 13px; color: #1864ab; }
.forecast .spin { margin-top: 6px; }
.ring-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; margin: 4px 0; font-size: 13.5px; }
.ring-row button { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 12px; }
.ring-row button:hover { border-color: var(--ink); }
.supply { margin: 10px 0; }
.supply .row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.dbtn {
  min-width: 46px;
  padding: 2px 8px;
  border: 1.5px solid var(--tc);
  border-radius: 999px;
  background: color-mix(in srgb, var(--tc) 18%, white);
  font-size: 13px;
}
.dbtn:disabled { opacity: 0.35; cursor: default; }
.dbtn:not(:disabled):hover { background: color-mix(in srgb, var(--tc) 40%, white); }
.packed { margin-top: 6px; font-size: 13px; }
/* face-down spin cards */
.table-cards { margin: 10px 0; }
.era-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.era-line > span:last-child { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.cardback {
  display: inline-block;
  width: 18px;
  height: 26px;
  border-radius: 4px;
  border: 2px solid var(--pc);
  background: repeating-linear-gradient(45deg, #5f3dc4 0 4px, #7950f2 4px 8px);
}
.cardface { display: inline-block; padding: 1px 7px; border-radius: 6px; border: 2px solid var(--pc); background: #fff; font-size: 12px; }
.era-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.era-row button { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 10px; }
.era-row button:hover { border-color: var(--ink); }
/* A primary button in a row keeps its dark fill (and, for a caretaker's button, their colour on the left). */
.era-row button.primary { width: auto; background: var(--ink); color: #fff; border-color: var(--ink); }
.era-row button.primary[style*='--pc'] { border-left: 6px solid var(--pc); }
.revealed { margin: 8px 0; padding-left: 18px; font-size: 12.5px; }
.revealed li { margin-bottom: 4px; }
.picks { margin: 8px 0; padding: 8px 10px; border-radius: 10px; background: #fff3bf; font-size: 13px; }
.picks .row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.kid-card { display: flex; gap: 10px; align-items: center; }
.tags { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1.5px solid var(--tc);
  background: color-mix(in srgb, var(--tc) 18%, white);
}
.hand { margin-top: 12px; }
.card {
  display: grid;
  grid-template-columns: 34px 1fr;
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 9px;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-left: 6px solid var(--cc);
  border-radius: 10px;
}
.card:hover { border-color: #b9a88c; border-left-color: var(--cc); }
.card.sel { border-color: var(--ink); border-left-color: var(--cc); background: #fff9db; box-shadow: 0 0 0 2px var(--ink); }
.ci { grid-row: span 2; font-size: 22px; align-self: center; }
.cn { font-weight: 700; }
.ct { font-size: 12.5px; color: var(--muted); }
.spin { display: grid; grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap: 6px; margin: 8px 0; }
.spin span { display: grid; place-items: center; padding: 6px; border-radius: 8px; background: #fff; border: 1.5px solid var(--line); }
.spin b { font-size: 20px; }
.chaos { border-top: 6px solid #c92a2a; }
.events { list-style: none; padding: 0; margin: 8px 0; font-size: 13.5px; }
.events li { display: grid; grid-template-columns: 22px 1fr; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.ev-died { color: #c92a2a; }
.ev-saved { color: #2b8a3e; font-weight: 600; }
.standings { padding-left: 20px; }
.scores { width: 100%; border-collapse: collapse; font-size: 13px; }
.scores th { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.scores td, .scores th { padding: 4px; text-align: center; }
.scores td:first-child { text-align: left; }
.scores tr.cur td { font-weight: 700; }
.log summary { cursor: pointer; font-weight: 600; }
.log ol { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12.5px; max-height: 260px; overflow-y: auto; }
.log li { padding: 2px 0; }

/* ---------- board ---------- */
.rim { fill: #8a6a48; stroke: #5e4630; stroke-width: 6; }
.base { fill: #fbf3e4; }
.ring {
  transform: rotate(var(--rot));
  transition: --rot var(--spin-ms, 1100ms) cubic-bezier(0.45, -0.25, 0.3, 1.25);
}
.upright {
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(calc(-1 * var(--rot)));
}
.wedge { stroke: #fffaf0; stroke-width: 2; fill-opacity: 0.45; cursor: pointer; }
.wedge.safe, .wedge.nursery { fill-opacity: 1; }
.wedge.safe { stroke: #fffaf0; }
.wedge:hover { fill-opacity: 0.75; }
.wedge-half { fill-opacity: 0.45; stroke: none; pointer-events: none; }
/* photo tiles */
.wedge.art, .wedge.rug { fill-opacity: 0; stroke: none; }
.wedge.rug { stroke: rgba(43, 36, 32, 0.4); stroke-width: 1.5; }
.wedge.art:hover, .wedge.rug:hover { fill-opacity: 0.22; }
.band { pointer-events: none; stroke: rgba(0, 0, 0, 0.35); stroke-width: 1; }
.tile { pointer-events: none; }
.tile-edge { fill: none; stroke: rgba(255, 248, 235, 0.45); stroke-width: 1; }
.piece-shadow { fill: #1a0f05; opacity: 0.35; filter: blur(1.5px); }
.pawn-shadow { fill: #1a0f05; opacity: 0.45; }
/* On a wood board, tiles without a photo yet are solid so the grain doesn't muddy them. */
.wedge-layer.on-wood .wedge:not(.art):not(.rug):not(.mixed), .wedge-layer.on-wood .wedge-half { fill-opacity: 0.88; }
.badge-bg { fill: rgba(255, 250, 240, 0.92); stroke: rgba(43, 36, 32, 0.35); stroke-width: 1; pointer-events: none; }
/* printed tiles: white symbols on the colour strip (emoji flattened to a white silhouette) */
.band-chip { fill: #fffdf7; stroke: rgba(0, 0, 0, 0.35); stroke-width: 1.2; pointer-events: none; }
.band-icon { text-anchor: middle; dominant-baseline: central; pointer-events: none; user-select: none; }
.base.wood { fill: url(#wood); }
.rim.wood { fill: url(#wood); filter: brightness(0.7) saturate(0.6) sepia(0.3); }
.edge-layer.art .edge { stroke: #3d2b1c; stroke-width: 3; opacity: 0.6; }
.wedge.mixed { fill-opacity: 0; }
.wedge.mixed:hover { fill-opacity: 0.3; }
.mark {
  pointer-events: none;
  stroke-width: 4;
  stroke-linejoin: round;
  animation: glow 0.9s ease-in-out infinite alternate;
}
.mark.reach { fill: #ffffff; stroke: #1b1b1b; stroke-dasharray: 8 5; }
.mark.drop { fill: #ffe066; stroke: #b08900; }
/* Outward paths for a kid at a fork: green lives, red dies; the chosen one is solid and doesn't blink. */
.mark.path { stroke-dasharray: 8 5; }
.mark.path.live { fill: #8ce99a; stroke: #2b8a3e; }
.mark.path.die { fill: #ff8787; stroke: #c92a2a; }
.mark.path.hold { fill: #a5d8ff; stroke: #1864ab; }
.mark.path.chosen { stroke-dasharray: none; stroke-width: 6; animation: none; fill-opacity: 0.45; }
@keyframes glow { from { fill-opacity: 0.55; } to { fill-opacity: 0.15; } }
.wedge-layer .ring.hl .wedge { stroke: #212529; stroke-width: 3; fill-opacity: 0.8; }
.wedge-layer .ring.hl .wedge.mixed { fill-opacity: 0.15; }
.edge { fill: none; stroke: #5e4630; stroke-width: 3; pointer-events: none; }
/* The line down the middle of each era: young kids (already marched this round) inside it, mature ones outside. */
.age-line { fill: none; stroke: #fffaf0; stroke-width: 2.2; stroke-dasharray: 9 7; opacity: 0.85; pointer-events: none; }
.age-label { font-family: 'Fredoka', system-ui, sans-serif; font-size: 10px; font-style: italic; fill: #fffaf0; stroke: #2b2420; stroke-width: 3px; paint-order: stroke; text-anchor: middle; dominant-baseline: central; pointer-events: none; user-select: none; opacity: 0.9; }
.icon, .hub-label, .zone-label, .safe-label, .era-label, .badge { text-anchor: middle; dominant-baseline: central; pointer-events: none; user-select: none; }
.era-label {
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 12px;
  fill: #2b2420;
  stroke: #fffaf0;
  stroke-width: 3.5px;
  paint-order: stroke;
  letter-spacing: 0.04em;
}
.safe-label { font-family: 'Fredoka', system-ui, sans-serif; font-size: 10px; fill: #2b8a3e; }
.zone-label { font-family: 'Fredoka', system-ui, sans-serif; font-size: 13px; fill: #c4a57e; }
.hub-label { font-family: 'Fredoka', system-ui, sans-serif; font-size: 15px; fill: #a08060; }
.drops { pointer-events: none; }
.drop-disc { stroke: #fffdf7; stroke-width: 2; }
.drop-icon { text-anchor: middle; dominant-baseline: central; }
.drop-count { font-size: 12px; font-weight: 700; fill: #fff; stroke: #2b2420; stroke-width: 3px; paint-order: stroke; text-anchor: start; dominant-baseline: central; }
.badge { font-size: 9px; }
.kid { cursor: pointer; }
.kid.ghost { pointer-events: none; }
/* A kid's disc: a dark outline then a light one, so its colours stand off any tile photo. */
.kid .disc, .kid .disc-rim { stroke: #fffaf0; stroke-width: 1.4; paint-order: stroke; filter: drop-shadow(0 0 1.2px #1a0f05); }
.kid .disc-rim { fill: none; }
.kid .disc-seam { stroke: #fffaf0; stroke-width: 1.3; }
.kid .disc.bare { fill: #fffaf0; stroke: #8a7a6a; stroke-dasharray: 2.5 2; }
.kid .halo { fill: none; stroke: none; }
.kid .shield { fill: none; stroke: #f59f00; stroke-width: 2; stroke-dasharray: 3 2; }
.kid.movable .halo { stroke: #ffffff; stroke-width: 2; stroke-dasharray: 3 3; }
.kid.moved { opacity: 0.6; }
.kid.targetable .halo { stroke: #ffe066; stroke-width: 3; stroke-dasharray: none; animation: pulse 0.8s ease-in-out infinite alternate; }
.kid.selected .halo { stroke: #212529; stroke-width: 3.5; stroke-dasharray: none; }
.kid.forked .halo { stroke: #1864ab; stroke-width: 2.5; stroke-dasharray: 2 2; }
.kid.doomed .halo { stroke: #ff2a2a; stroke-width: 4; stroke-dasharray: none; animation: pulse 0.6s ease-in-out infinite alternate; }
@keyframes pulse { from { stroke-opacity: 1; } to { stroke-opacity: 0.3; } }

/* ---------- misc ---------- */
#rules-dialog {
  max-width: 620px;
  border: 0;
  border-radius: 16px;
  padding: 24px 28px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
#rules-dialog::backdrop { background: rgba(30, 20, 10, 0.5); }
#rules-dialog li { margin-bottom: 4px; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  #game { height: auto; }
  .table { grid-template-columns: 1fr; }
  .mat-body { grid-template-columns: 1fr 1fr; }
  .zone.cheat { grid-column: 1 / -1; }
  .table-view { overflow: visible; cursor: auto; }
  .tabletop { height: auto; }
  .tabletop { --dial: calc(100vw - 32px); grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: 'dial' 'bottom' 'top' 'left' 'right' 'tl' 'tr' 'bl' 'br'; }
  .dial { aspect-ratio: 1; }
  #side { border-left: 0; }
  .rule-grid { grid-template-columns: 1fr; }
}

/* online tables: the lobby, the Seats dialog and who's away */
.share { display: flex; gap: 8px; margin: 8px 0 16px; }
.share input { flex: 1; min-width: 0; font: inherit; padding: 6px 8px; border-radius: 6px; border: 1px solid #c9b48e; background: #fffaf0; }
.seats ul { list-style: none; margin: 10px 0 16px; padding: 0; display: grid; gap: 6px; }
.seat-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; border-radius: 8px; background: rgba(255, 252, 244, 0.6); }
.seat-row .seat-name { font-weight: 600; min-width: 7em; }
.seat-row .seat-state { margin-right: auto; }
.seat-row select { font: inherit; }
.away { color: #c92a2a; font-size: 0.85em; font-weight: 600; }
.seats-dialog { min-width: min(440px, 90vw); }
#willville { margin-right: 8px; color: inherit; }

/* the nursery phase: who still has kids to send out */
.nursery-progress { list-style: none; margin: 6px 0 10px; padding: 0; display: grid; gap: 3px; font-size: 13px; }

/* hovering a kid: what it's carrying, right above it */
#kid-tip { position: fixed; z-index: 60; display: none; pointer-events: none; transform: translate(-50%, calc(-100% - 8px)); padding: 5px 9px; border-radius: 8px; background: rgba(30, 20, 10, 0.9); color: #f8efe2; font-size: 13px; white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
#kid-tip.show { display: block; }
#kid-tip .tip-disc { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; background: var(--tc); color: #fff; font-weight: 600; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); }
#kid-tip .muted { color: rgba(248, 239, 226, 0.7); }

/* Swapping discs between rounds: each caretaker's kids sharing a tile, their discs as buttons that hand one on. */
.swap-player { border-left: 3px solid var(--pc); padding: 4px 0 4px 8px; margin: 6px 0; }
.swap-tile { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 6px; }
.swap-kid { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.swap-kid .pawn { display: inline-flex; }
