/* Root Machine Notation — analysis bench
   Palette: woodland parchment + faction accents. */

:root {
  --ink: #16241b;
  --ink-soft: #3a5142;
  --paper: #f4eee0;
  --paper-2: #eae0cb;
  --paper-3: #dccfb2;
  --line: rgba(22, 36, 27, 0.16);
  --line-strong: rgba(22, 36, 27, 0.42);

  --mc: #b5471f; /* Marquise  */
  --ed: #28527a; /* Eyrie     */
  --wa: #4f6b4a; /* Alliance  */
  --vb: #9a7614; /* Vagabond  */
  --crimson: #8f2b23;
  --gold: #a8791b;

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  --shadow: 3px 3px 0 rgba(22, 36, 27, 0.10);
  --shadow-lift: 4px 5px 0 rgba(22, 36, 27, 0.16);
  --header-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--display);
  background:
    radial-gradient(1100px 560px at 8% -10%, rgba(181, 71, 31, 0.10), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(40, 82, 122, 0.10), transparent 55%),
    var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: repeating-linear-gradient(0deg, rgba(22, 36, 27, 0.03) 0 1px, transparent 1px 4px);
}

/* ---------- Header (full-bleed, sticky) ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 120; /* above the landing/lobby overlays so Log out is always reachable */
  width: 100%;
  border-bottom: 2px solid var(--line-strong);
  background: rgba(244, 238, 224, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.masthead-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  width: 100%;
  padding: 0.65rem clamp(0.8rem, 2vw, 1.6rem);
}

.brand { flex: 1 1 260px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: clamp(1.05rem, 1.4vw + 0.6rem, 1.4rem);
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.sub {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  font-size: clamp(0.56rem, 0.5vw + 0.4rem, 0.66rem);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.turnbar {
  flex: 0 1 auto;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: right;
  white-space: nowrap;
}
.turnbar b { color: var(--mc); }

.topactions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.btn {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.42rem 0.7rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--paper-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }

/* ---------- Layout ---------- */

.bench {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(200px, 232px) minmax(420px, 1.7fr) minmax(330px, 1fr);
  gap: 1rem;
  width: 100%;
  padding: 1rem clamp(0.8rem, 2vw, 1.6rem) 1.4rem;
  align-items: start;
}

.rightcol { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }

/* ---------- Panels ---------- */

.panel {
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1.5px solid var(--line-strong);
  background: var(--paper-2);
}
.panel-head h2 { margin: 0; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; }
.hint { font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Players ---------- */

.players { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }

.pcard {
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pcard.current { outline: 3px solid var(--ink); outline-offset: -1px; }
.pcard .phead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1.5px solid var(--line-strong);
  background: var(--paper-2);
}
.pcard .phead .f { font-family: var(--mono); font-weight: 700; letter-spacing: 0.04em; }
.pcard .phead .vp { font-family: var(--mono); font-weight: 700; }
.pcard.MC .f, .pcard.MC .vp { color: var(--mc); }
.pcard.ED .f, .pcard.ED .vp { color: var(--ed); }
.pcard.WA .f, .pcard.WA .vp { color: var(--wa); }
.pcard.VB .f, .pcard.VB .vp { color: var(--vb); }

.pbody { padding: 0.4rem 0.55rem; font-family: var(--mono); font-size: 0.66rem; line-height: 1.5; color: var(--ink-soft); }
.pbody .row { display: flex; justify-content: space-between; gap: 0.5rem; }
.pbody .cards { color: var(--ink); text-align: right; word-break: break-word; }
.pbody .tags { display: flex; flex-wrap: wrap; gap: 0.16rem; margin-top: 0.25rem; }
.tag { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.02rem 0.28rem; font-size: 0.6rem; }
.tag.hostile { color: var(--crimson); border-color: var(--crimson); }

/* ---------- Hand cards ---------- */

.hand { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.35rem 0.55rem 0.55rem; border-top: 1px dashed var(--line); }
.hand .hempty { font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft); }
.hcard { border: 1px solid var(--line-strong); border-left: 4px solid #5b6472; border-radius: var(--radius); background: var(--paper); padding: 0.24rem 0.38rem; }
.hcard.suit-F { border-left-color: var(--mc); }
.hcard.suit-R { border-left-color: var(--vb); }
.hcard.suit-M { border-left-color: #5b6472; }
.hcard.suit-B { border-left-color: var(--ed); }
.hcard .hname { display: flex; justify-content: space-between; gap: 0.3rem; font-family: var(--mono); font-size: 0.64rem; font-weight: 700; }
.hcard .hid { opacity: 0.6; font-weight: 400; }
.hcard .hcost { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.hcard .hdesc { font-size: 0.66rem; line-height: 1.25; color: var(--ink-soft); }

/* ---------- Board ---------- */

.boardwrap { min-width: 0; }

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  min-height: clamp(420px, 52vh, 640px);
  margin-top: 0.2rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(closest-side at 50% 40%, rgba(79, 107, 74, 0.06), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05));
}

.roads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.roads line.casing { stroke: var(--paper-3); stroke-width: 7; vector-effect: non-scaling-stroke; }
.roads line.road { stroke: #7a5a37; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.roads line.hot line.road, .roads line.hot.casing { stroke: var(--mc); }

.clearing {
  position: absolute;
  width: 14%;
  min-width: 74px;
  transform: translate(-50%, -50%);
  padding: 0.3rem 0.35rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  min-height: 4.6rem;
  cursor: pointer;
  z-index: 2;
  transition: box-shadow 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.clearing:hover { box-shadow: var(--shadow-lift); border-color: var(--ink); z-index: 3; transform: translate(-50%, -50%) translateY(-2px); }
.clearing.hl { outline: 3px solid var(--mc); outline-offset: 1px; }

.cid { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 0.7rem; font-weight: 700; }
.suit { width: 1.1rem; height: 1.1rem; display: grid; place-items: center; border-radius: 50%; color: #fff; font-size: 0.62rem; font-weight: 700; }
.suit.F { background: var(--mc); }
.suit.R { background: var(--vb); }
.suit.M { background: #5b6472; }

.crowd { display: flex; flex-wrap: wrap; gap: 0.16rem; margin-top: 0.28rem; }
.chip { font-family: var(--mono); font-size: 0.58rem; padding: 0.05rem 0.26rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-2); }
.chip.MC { border-color: var(--mc); color: var(--mc); }
.chip.ED { border-color: var(--ed); color: var(--ed); }
.chip.WA { border-color: var(--wa); color: var(--wa); }
.chip.VB { border-color: var(--vb); color: var(--vb); }
.wood { font-family: var(--mono); font-size: 0.58rem; color: var(--vb); }
/* Building slots */
.slots { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.28rem; font-family: var(--mono); font-size: 0.55rem; color: var(--ink-soft); }
.slotpips { display: inline-flex; gap: 2px; }
.slot { width: 0.5rem; height: 0.5rem; display: inline-block; border: 1px solid var(--line-strong); border-radius: 1px; }
.slot.used { background: var(--ink-soft); border-color: var(--ink-soft); }
.slot.free { background: transparent; }
.slot.ruinslot { border-color: var(--crimson); background: repeating-linear-gradient(45deg, var(--crimson) 0 2px, transparent 2px 4px); }
.slotnum { opacity: 0.8; }
.ruin { color: var(--crimson); opacity: 0.85; }

.forest {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0.1rem 0.4rem;
  border: 1px dashed rgba(79, 107, 74, 0.5);
  border-radius: 999px;
  background: rgba(79, 107, 74, 0.10);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--wa);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

.pawn {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 2.2rem;
  padding: 0.28rem 0.2rem;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--vb);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 1px 3px rgba(22, 36, 27, 0.4);
  pointer-events: none;
  z-index: 4;
}

.boardfoot {
  padding: 0.45rem 0.2rem 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.5;
  color: var(--ink-soft);
  word-break: break-word;
}

/* ---------- Actions ---------- */

.actions { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.55rem; max-height: 40vh; overflow: auto; }
.actions button {
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.42rem 0.55rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, transform 0.1s ease;
}
.actions button:hover { background: var(--ink); color: var(--paper); }
.actions button:active { transform: translateY(1px); }
.actions button.pass { border-style: dashed; color: var(--ink-soft); }
.actions button.battle, .actions button.decree-battle { border-color: var(--crimson); }
.actions button.craft, .actions button.mc-build, .actions button.decree-build { border-color: var(--ed); }

.battlebar {
  border: 1.5px solid var(--crimson);
  border-radius: var(--radius);
  background: rgba(143, 43, 35, 0.08);
  padding: 0.45rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
}
.battlebar .step { color: var(--crimson); font-weight: 700; }
.battlebar .hint { color: var(--ink-soft); font-size: 0.62rem; }

.winner { padding: 0.6rem; font-family: var(--mono); font-weight: 700; color: var(--wa); }

/* ---------- Logs ---------- */

.log, .rmn { list-style: none; margin: 0; padding: 0.55rem; overflow: auto; }
.log { max-height: 36vh; }
.rmn { max-height: 28vh; }

.log li {
  display: grid;
  grid-template-columns: 2rem 2.4rem 2rem 1fr;
  gap: 0.3rem;
  padding: 0.22rem 0.35rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.66rem;
}
.log .seq { opacity: 0.6; }
.log .act.MC { color: var(--mc); }
.log .act.ED { color: var(--ed); }
.log .act.WA { color: var(--wa); }
.log .act.VB { color: var(--vb); }
.log li.battle, .log li.turmoil, .log li.ambush { background: rgba(143, 43, 35, 0.10); }
.log li.win { background: rgba(79, 107, 74, 0.16); }
.log li.score { background: rgba(168, 121, 27, 0.12); }

.rmn li {
  padding: 0.18rem 0.3rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.64rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.rmn li:nth-child(odd) { background: rgba(255, 255, 255, 0.35); }
.rmn .rmnempty { color: var(--ink-soft); }

/* ---------- Footer ---------- */

.sitefoot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  width: 100%;
  padding: 0.7rem clamp(0.8rem, 2vw, 1.6rem);
  border-top: 1px solid var(--line);
  background: rgba(244, 238, 224, 0.7);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-soft);
}
.sitefoot a { color: var(--ed); text-decoration: none; }
.sitefoot a:hover { text-decoration: underline; }

/* ---------- Focus & motion ---------- */

button:focus-visible, a:focus-visible, .clearing:focus-visible {
  outline: 2px solid var(--mc);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Minimap (graph view for small viewports) ---------- */

.minimap { display: none; }

.minimap .mm-svg { display: block; width: 100%; height: auto; }
.minimap .mm-road { stroke: #7a5a37; stroke-width: 1.6; stroke-linecap: round; opacity: 0.85; }
.minimap .mm-node { fill: var(--paper); stroke: var(--ink); stroke-width: 1; }
.minimap .mm-node.mm-suit-F { fill: #eccfc2; stroke: var(--mc); }
.minimap .mm-node.mm-suit-R { fill: #ece2c2; stroke: var(--vb); }
.minimap .mm-node.mm-suit-M { fill: #d9dde1; stroke: #5b6472; }
.minimap .mm-node.mm-suit-B { fill: #cfdbe8; stroke: var(--ed); }
.minimap .mm-node.mm-hl { stroke-width: 2.6; }
.minimap .mm-label { font-family: var(--mono); font-size: 6px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: var(--ink); }
.minimap .mm-forest { font-family: var(--mono); font-size: 4.2px; text-anchor: middle; fill: var(--wa); opacity: 0.7; }
.minimap .mm-pawn { fill: var(--vb); stroke: var(--paper); stroke-width: 0.8; }

/* ---------- Page-load fade ---------- */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.masthead { animation: fadeIn 0.3s ease both; }
.bench { animation: fadeIn 0.45s ease both; animation-delay: 0.05s; }
.sitefoot { animation: fadeIn 0.45s ease both; animation-delay: 0.1s; }

/* Players drawer toggle (hidden on wide screens) */
#toggleplayers { display: none; }
/* Transparent click-catcher: closes the drawer without dimming the page. */
.drawer-backdrop { position: fixed; inset: 0; z-index: 125; background: transparent; }

/* ---------- Responsive ---------- */

@media (max-width: 1400px) {
  .bench { grid-template-columns: minmax(190px, 220px) minmax(380px, 1.6fr) minmax(300px, 1fr); }
}

/* Medium: players stay visible beside the board; the right column drops below. */
@media (max-width: 1180px) {
  .bench { grid-template-columns: minmax(190px, 220px) minmax(0, 1fr); }
  .players { grid-column: 1; grid-row: 1 / span 2; }
  .boardwrap { grid-column: 2; grid-row: 1; }
  .rightcol { grid-column: 2; grid-row: 2; }
}

/* Small: the players list collapses into a drawer. */
@media (max-width: 900px) {
  .bench { grid-template-columns: minmax(0, 1fr); }
  .players, .boardwrap, .rightcol { grid-column: 1; grid-row: auto; }

  #toggleplayers { display: inline-block; }

  .players {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 130;
    width: min(340px, 88vw);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.9rem;
    overflow: auto;
    background: var(--paper);
    box-shadow: 6px 0 18px rgba(22, 36, 27, 0.25);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }
  .players::before {
    content: "Players";
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }
  .players-open .players { transform: none; }
  .drawer-backdrop[hidden] { display: none; }

  .turnbar { margin-left: 0; text-align: left; white-space: normal; }
  .brand { flex-basis: 100%; }
  .actions { max-height: 46vh; }
  .log, .rmn { max-height: 40vh; }
}

/* Table layout (with minimap) below 720px. */
@media (max-width: 720px) {
  .minimap {
    display: block;
    margin-bottom: 0.6rem;
    padding: 0.5rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.05));
  }
  .board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    gap: 0.5rem;
    aspect-ratio: auto;
    min-height: 0;
    padding: 0.5rem;
  }
  .clearing { position: static; width: auto; min-width: 0; transform: none; }
  .clearing:hover { transform: none; }
  .roads, .forest, .pawn { display: none; }
}

@media (max-width: 420px) {
  .board { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ---------- Multiplayer additions ---------- */

.header-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.header-controls label { font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft); display: flex; align-items: center; gap: 0.3rem; }
.header-controls input[type="number"] { width: 4.2rem; font-family: var(--mono); font-size: 0.7rem; padding: 0.28rem 0.35rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--crimson); display: inline-block; }
.dot.on { background: var(--wa); }

.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem;
  background: rgba(244, 238, 224, 0.96); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.overlay[hidden] { display: none; }
.card { width: min(560px, 96vw); border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow-lift); padding: 1rem 1.1rem; }
.card h2 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.card p { margin: 0 0 0.8rem; font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); line-height: 1.5; }
.card label { display: block; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); margin: 0.6rem 0 0.2rem; }
.card input, .card select, .card textarea { width: 100%; font-family: var(--mono); font-size: 0.8rem; padding: 0.45rem 0.55rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.card .row2 { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.card .row2 > * { flex: 1 1 8rem; }
.card .btn { margin-top: 0.9rem; }
.toklist { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.tokrow { display: flex; align-items: center; gap: 0.4rem; }
.tokrow code { flex: 1; font-family: var(--mono); font-size: 0.66rem; padding: 0.3rem 0.4rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roomlist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.4rem;
  max-height: 54vh;
  overflow: auto;
  padding: 0.2rem;
}
.roomempty { padding: 0.3rem 0; font-family: var(--mono); font-size: 0.66rem; color: var(--ink-soft); }

/* A host's table: name + status over the pixel-art board. */
.roomtable {
  flex: 1 1 210px;
  min-width: 190px;
  max-width: 290px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.1));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rt-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1.5px solid var(--line-strong);
  background: var(--paper-2);
}
.rt-name { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-meta { font-family: var(--mono); font-size: 0.58rem; color: var(--ink-soft); white-space: nowrap; }

/* Pixel-art table: crisp edges, chunky blocks, top-down. */
.ptable { display: block; width: 100%; height: auto; shape-rendering: crispEdges; background: var(--paper); }
.ptable .wood-dark { fill: #8a5a2b; }
.ptable .wood-hi { fill: #a06b36; }
.ptable .felt { fill: #4f6b4a; }
.ptable .plaque { fill: #dccfb2; }
.ptable .ptable-id { font-family: var(--mono); font-size: 6px; font-weight: 700; text-anchor: middle; fill: var(--ink); }

.pseat { cursor: default; }
.pseat.free { cursor: pointer; }
.pseat .seat-shadow { fill: rgba(22, 36, 27, 0.22); }
.pseat .seat-body { fill: #6f4520; }
.pseat .seat-back { fill: #5a3718; }
.pseat .seat-cushion { fill: var(--ink-soft); }
.pseat .pseat-label { font-family: var(--mono); font-size: 6px; font-weight: 700; text-anchor: middle; fill: var(--paper); pointer-events: none; }
.pseat.free .pseat-label { fill: var(--paper-3); }
.pseat.free:hover .seat-body, .pseat.free:focus-visible .seat-body { fill: var(--gold); }
.pseat.free:hover .seat-back, .pseat.free:focus-visible .seat-back { fill: #7a5410; }
.pseat.free:hover .pseat-label, .pseat.free:focus-visible .pseat-label { fill: var(--ink); }
.pseat.busy { opacity: 0.45; }
.pseat.empty { opacity: 0.4; }
.pseat.empty .seat-body { fill: #7b6a55; }
.pseat.empty .seat-back { fill: #63543f; }
.pseat.empty .pseat-label { fill: var(--paper-2); }
.pseat.MC .seat-cushion { fill: var(--mc); }
.pseat.ED .seat-cushion { fill: var(--ed); }
.pseat.WA .seat-cushion { fill: var(--wa); }
.pseat.VB .seat-cushion { fill: var(--vb); }
.pseat.bot .seat-back { fill: var(--gold); }
.pseat.bot .pseat-label { font-weight: 700; }

.card-wide { width: min(900px, 96vw); }
.landingfoot { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.9rem; }
.landingfoot .btn { margin-top: 0; }
.landingfoot input { flex: 1 1 12rem; width: auto; }
.landingfoot .landingsep { color: var(--line-strong); }
.factionpick { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.factionpick button { flex: 1 1 6rem; font-family: var(--mono); font-size: 0.75rem; padding: 0.6rem; border: 1.5px solid var(--line-strong);
  border-radius: var(--radius); background: var(--paper); cursor: pointer; }
.factionpick button:hover { background: var(--ink); color: var(--paper); }
.factionpick button.MC { border-color: var(--mc); color: var(--mc); }
.factionpick button.ED { border-color: var(--ed); color: var(--ed); }
.factionpick button.WA { border-color: var(--wa); color: var(--wa); }
.factionpick button.VB { border-color: var(--vb); color: var(--vb); }
.factionpick button.taken { opacity: 0.4; cursor: not-allowed; }
.factionpick button:disabled:hover { background: var(--paper); color: inherit; }
.hidden-card { border: 1px solid var(--line-strong); border-left: 4px solid #5b6472; border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, rgba(91,100,114,.15) 0 4px, transparent 4px 8px); padding: 0.24rem 0.38rem;
  font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft); }
.banner { margin: 0.5rem 0; padding: 0.5rem 0.6rem; border: 1.5px solid var(--ed); border-radius: var(--radius);
  background: rgba(40,82,122,.08); font-family: var(--mono); font-size: 0.72rem; }
.banner.you { border-color: var(--wa); background: rgba(79,107,74,.10); }

/* ---------- Turn indicator ---------- */

.turnbanner {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem clamp(0.8rem, 2vw, 1.6rem);
  border-bottom: 2px solid var(--line-strong);
  background: var(--paper-2);
  font-family: var(--mono);
  text-align: center;
}
.turnbanner[hidden] { display: none; }
.turnbanner .tb-who { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.turnbanner .tb-label { font-size: 0.68rem; color: var(--ink-soft); }
.turnbanner.MC { border-bottom-color: var(--mc); }
.turnbanner.MC .tb-who { color: var(--mc); }
.turnbanner.ED { border-bottom-color: var(--ed); }
.turnbanner.ED .tb-who { color: var(--ed); }
.turnbanner.WA { border-bottom-color: var(--wa); }
.turnbanner.WA .tb-who { color: var(--wa); }
.turnbanner.VB { border-bottom-color: var(--vb); }
.turnbanner.VB .tb-who { color: var(--vb); }
.turnbanner.your { background: rgba(79, 107, 74, 0.16); border-bottom-color: var(--wa); }
.turnbanner.your .tb-who { color: var(--wa); animation: turnPulse 1.8s ease-in-out infinite; }
.turnbanner.win { background: rgba(168, 121, 27, 0.16); border-bottom-color: var(--gold); }
.turnbanner.win .tb-who { color: var(--gold); }

@keyframes turnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#logoutmodal { z-index: 140; }
#logoutmodal code { display: block; max-height: 8rem; overflow: auto; word-break: break-all; }
