:root {
  --bg: #f3efe6;
  --panel: #fffdf8;
  --ink: #23302f;
  --muted: #6c7775;
  --line: #ddd6c6;
  --accent: #1f6f78;
  --water: #2c5b62;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.35 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

#app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 6px 10px 12px;
}

header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h1 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--accent);
}

h2 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

p {
  margin: 0 0 10px;
}

.conn {
  color: var(--muted);
  font-size: 13px;
}

.lede {
  max-width: 440px;
  font-size: 16px;
}

.card {
  display: grid;
  gap: 12px;
  max-width: 440px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
button,
.button {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

button,
.button {
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.link {
  flex: 1;
  min-width: 0;
}

.notice {
  padding: 7px 10px;
  border-radius: 8px;
  background: #fbe9e4;
  color: #8f2c14;
}

/* ---- game table ---- */

.table {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 370px);
  gap: 10px;
  align-items: start;
}

.board-wrap {
  width: 100%;
  aspect-ratio: 1;
  box-sizing: border-box;
  padding: 6px;
  background: var(--water);
  border-radius: 16px;
}

.board {
  display: block;
  width: 100%;
  height: 100%;
}

.tile.land,
.corner,
.link {
  cursor: pointer;
}

.tile polygon {
  stroke: #efe6cf;
  stroke-width: 2;
}

.tile.water polygon {
  stroke: none;
}

.tile.hint > polygon:first-child,
.tile.selected > polygon:first-child {
  stroke: #fff;
  stroke-width: 4;
}

.hit {
  fill: transparent;
}

/* Free corners and edges stay quiet until they are playable or hovered. */
.corner .mark {
  fill: #fff;
  stroke: rgba(0, 0, 0, 0.45);
  opacity: 0;
}

.link .mark {
  stroke: #fff;
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0;
}

.corner.placeable:hover .mark,
.link.placeable:hover .mark {
  opacity: 0.55;
}

.corner.hint .mark,
.link.hint .mark {
  opacity: 0.9;
}

.link.hint .mark {
  stroke-dasharray: 2 7;
}

.corner.placeable.selected .mark,
.link.placeable.selected .mark {
  opacity: 1;
  stroke-dasharray: none;
}

.corner.selected .mark {
  stroke: #000;
  stroke-width: 2;
}

.link .placement-outline {
  stroke: #173e46;
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0;
  pointer-events: none;
}

.link.placeable:hover .placement-outline,
.link.placeable.selected .placement-outline {
  opacity: 1;
}

.link.placeable:hover .mark,
.link.placeable.selected .mark {
  stroke: #94d6ce;
  stroke-width: 4;
  stroke-dasharray: none;
  opacity: 1;
}

.road-edge {
  stroke: #fff;
  stroke-width: 9;
  stroke-linecap: round;
}

.road {
  stroke-width: 6;
  stroke-linecap: round;
}

.link.selected .road-edge {
  stroke: #000;
}

.corner.hint .piece,
.corner.selected .piece {
  stroke-width: 3.5;
}

.corner.selected .piece {
  stroke: #000;
}

.die {
  fill: #fffdf5;
  stroke: rgba(0, 0, 0, 0.4);
}

.die-text {
  font: 700 15px system-ui, sans-serif;
  text-anchor: middle;
  fill: #23302f;
  pointer-events: none;
}

.piece {
  stroke: #fff;
  stroke-width: 2;
  stroke-linejoin: round;
}

.raider {
  fill: rgba(31, 79, 140, 0.55);
  stroke: none;
  pointer-events: none;
}

.raider-text {
  font: 700 9px system-ui, sans-serif;
  text-anchor: middle;
  fill: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

aside {
  display: grid;
  gap: 10px;
}

aside section,
aside details {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.status {
  padding: 10px 12px;
  border-radius: 12px;
  background: #e6e1d4;
  font-weight: 600;
}

.status.mine {
  background: var(--accent);
  color: #fff;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.players li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
}

.players li.active {
  background: #ece7da;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

em {
  font-style: normal;
  font-weight: 500;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e6e1d4;
  color: var(--muted);
}

.score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cards {
  font-size: 12px;
  color: var(--muted);
}

.chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.chip {
  padding: 5px 4px;
  border-radius: 8px;
  border-bottom: 4px solid var(--c);
  background: #f4f0e6;
  text-align: center;
  font-size: 12px;
}

.chip b {
  display: block;
  font-size: 18px;
}

.dice {
  display: flex;
  gap: 4px;
}

.dice b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

aside section.row button {
  flex: 1;
}

.offers li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.trade-form {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
}

.qtys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.qty input {
  width: 100%;
  border-bottom: 4px solid var(--c);
}

.supply {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.log {
  max-height: 180px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--muted);
}

.log li:first-child {
  color: var(--ink);
}

@media (max-width: 740px) {
  .table {
    grid-template-columns: 1fr;
  }
}

.players li { flex-wrap: wrap; }
.players .cards { flex-basis: 100%; }

/* Trading Post labels must not intercept the coastal edge beneath them. */
.post { pointer-events: none; }
.post text { fill: #d7e0dc; font: 700 10px system-ui, sans-serif; }
.post-connector { stroke: #bbcfc9; stroke-width: 1.25; stroke-dasharray: 3 4; opacity: 0.65; }
.post-badge { fill: #244e52; stroke: none; }

.setup-controls { padding: 12px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.setup-controls p { margin-bottom: 8px; }
.setup-controls button { width: 100%; }
.edge-hit { fill: transparent; stroke: none; pointer-events: all; }

.discard-banner {
  margin: 0 0 16px;
  padding: 20px;
  border: 3px solid #ad431c;
  border-radius: 12px;
  background: #fff0db;
  box-shadow: 0 4px 20px #ad431c20;
  scroll-margin-top: 12px;
}
.discard-banner h2 { color: #842d10; font-size: 21px; letter-spacing: 0; text-transform: none; }
.discard-banner .qtys { max-width: 650px; margin: 16px 0; }
.discard-banner .qty { color: var(--ink); font-weight: 700; }
.discard-banner .qty span { font-size: 12px; font-weight: 400; }
.discard-banner .qty input { min-height: 44px; }
.discard-banner .primary { background: #943710; border-color: #943710; }
.discard-banner.waiting { border-color: #b18b43; background: #fff7e8; }
#discard-progress { font-weight: 700; }
@media (max-width: 480px) { .discard-banner .qtys { grid-template-columns: repeat(3, 1fr); } }

.production-token { pointer-events: none; }
.probability-dots { fill: var(--ink); }
.production-token.frequent .die-text,
.production-token.frequent .probability-dots { fill: #ad3026; }

.special-hand { border-top: 4px solid #705597; }
.special-hand h2 { color: #594174; }
.hand-privacy, .empty-hand, .draw-special p { color: var(--muted); font-size: 13px; }
.special-card-grid { display: grid; gap: 10px; }
.special-card { padding: 14px; border: 1px solid #c9b8dd; border-radius: 10px; background: #f8f3ff; }
.special-card h3, .card-options h3 { margin: 4px 0 8px; font-size: 17px; }
.special-card p { font-size: 13px; }
.special-card .card-type { color: #594174; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.special-card .card-status { color: #594174; font-weight: 600; }
.special-card button { width: 100%; }
.special-card:focus { outline: 3px solid #705597; outline-offset: 2px; }
.played-card { background: #f2f0eb; border-color: var(--line); }
.card-options { padding: 12px; border: 2px solid #705597; border-radius: 10px; }
.draw-special { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

.turn-controls { margin-top: 12px; padding: 16px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; }
.turn-controls.my-turn { border-color: var(--accent); background: #e8f3f2; box-shadow: 0 0 0 2px #1f6f7820; }
.turn-controls.my-turn .turn-title { color: var(--accent); }
.turn-status { font-weight: 700; margin-bottom: 12px; }
.turn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.turn-actions button { flex: 1; min-height: 48px; min-width: 110px; font-size: 16px; }
.turn-dice { display: flex; align-items: center; gap: 10px; }
.roll-pending { color: var(--muted); }
@media (max-width: 480px) { .turn-dice, .roll-pending { flex-basis: 100%; } }

.raider-banner { padding: 20px; margin-bottom: 12px; border: 3px solid #705597; border-radius: 12px; background: #f2eafa; scroll-margin-top: 12px; }
.raider-banner h2 { color: #50336f; font-size: 21px; letter-spacing: 0; text-transform: none; }
.raider-banner label { color: var(--ink); font-weight: 700; margin: 12px 0; }
.raider-banner button { width: 100%; min-height: 48px; margin-top: 8px; background: #654583; border-color: #654583; }
.raider-banner.waiting { border-width: 1px; background: #f6f2fa; }
.raider-help { font-size: 13px; color: #594174; }
.raider-step { font-weight: 700; }

.supply-options { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.supply-options > p { color: var(--muted); font-size: 12px; }
.supply-option { padding: 10px; margin-top: 8px; border: 1px solid var(--line); border-radius: 9px; }
.supply-offer { display: grid; gap: 2px; margin-bottom: 8px; }
.supply-offer span { font-size: 12px; color: var(--muted); }
.supply-option .row { align-items: end; }
.supply-option label { flex: 1; min-width: 0; }
.supply-option select { width: 100%; }

.shared-panel { padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-top: 12px; }
.player-panel { margin: 0 0 12px; }
.player-panel .players { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.player-panel .players li { align-content: start; padding: 8px; border: 1px solid var(--line); }
.player-panel .players .cards { line-height: 1.5; }

/* Compact play layout keeps the board controls and shared information in view. */
p { margin-bottom: 6px; }
h2 { margin-bottom: 4px; }
input, select, button, .button { padding: 5px 7px; min-height: 32px; border-radius: 6px; }
aside { gap: 6px; }
aside section, aside details { padding: 8px; border-radius: 9px; }
.row { gap: 6px; }
.chips, .qtys { gap: 4px; }
.chip { padding: 3px; border-bottom-width: 3px; }
.chip b { display: inline; font-size: 16px; margin-right: 3px; }
.shared-panel { padding: 7px 9px; margin-top: 6px; }
.player-panel { margin: 0 0 6px; }
.player-panel .players { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 5px; }
.player-panel .players li { padding: 5px; gap: 4px; }
.player-panel .players .cards { font-size: 11px; line-height: 1.3; }
.played-summary { flex-basis: 100%; font-size: 11px; line-height: 1.35; color: var(--muted); }
.turn-controls { margin-top: 6px; padding: 8px 10px; }
.turn-status { margin-bottom: 6px; font-size: 13px; }
.turn-actions { gap: 8px; }
.turn-actions button { min-height: 36px; font-size: 14px; }
.dice b { width: 28px; height: 28px; }
.special-card-grid { gap: 6px; }
.special-card { padding: 8px; border-radius: 8px; }
.special-card h3, .card-options h3 { font-size: 14px; margin: 2px 0 4px; }
.special-card p { font-size: 12px; margin-bottom: 4px; }
.special-card .card-type { font-size: 10px; }
.special-card button { padding: 4px 7px; }
.draw-special { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; padding-top: 6px; }
.draw-cost { font-size: 11px; color: var(--muted); }
.compact-details { margin: 6px 0 0; }
.compact-details summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.compact-details[open] summary { margin-bottom: 6px; }
.special-hand .compact-details { border: 0; padding: 0; }
.supply-options { margin-top: 8px; padding-top: 8px; }
.supply-option { padding: 6px; margin-top: 5px; }
.supply-offer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin-bottom: 4px; }
.supply-offer strong { font-size: 12px; }
.supply-offer span { font-size: 11px; }
.supply-option label { font-size: 11px; gap: 2px; }
.trade-form { margin: 6px 0; gap: 4px; }
.log-panel { margin: 0; }
.log { max-height: 220px; overflow-y: auto; }
@media (max-width: 740px) {
  .board { max-height: none; }
  .table { gap: 8px; }
}
@media (pointer: coarse) { button, select, input { min-height: 40px; } }

.special-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; }
.special-card .card-type { grid-column: 1; grid-row: 1; }
.special-card h3 { grid-column: 1; grid-row: 2; }
.special-card p { grid-column: 1 / -1; }
.special-card button { grid-column: 2; grid-row: 1 / 3; width: auto; max-width: 145px; align-self: center; font-size: 12px; }

/* Shared information, board, and private actions each get their own column. */
#app { max-width: 1900px; }
.table { grid-template-columns: 310px minmax(0, 1fr) 330px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "public turns personal" "public board personal"; }
.turn-bar { grid-area: turns; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; align-items: stretch; }
.turn-bar .turn-controls, .turn-bar .player-panel { margin: 0; }
.turn-bar .player-panel { min-width: 0; }
.turn-bar .player-panel .players { grid-template-columns: repeat(auto-fit, minmax(min(100%, 105px), 1fr)); }
.turn-bar .players li { min-width: 0; overflow-wrap: anywhere; }
.turn-bar .turn-controls { border-left: 5px solid var(--turn-color); display: flex; flex-direction: column; }
.turn-bar .turn-controls .turn-actions { margin-top: auto; }
.turn-bar .turn-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 38px 36px; gap: 8px; }
.turn-bar .turn-dice { justify-content: center; }
.turn-bar .dice { gap: 8px; }
.turn-bar .dice b { width: 38px; height: 38px; font-size: 21px; }
.turn-bar .turn-actions > .turn-dice, .turn-bar .turn-actions > .roll-pending { grid-column: 1 / -1; }
.turn-bar .turn-actions button { min-width: 0; min-height: 36px; font-size: 13px; }
.public-sidebar { grid-area: public; }
.sidebars { display: contents; }
.personal-sidebar { grid-area: personal; }
.board-area { grid-area: board; }
.public-sidebar .player-panel { margin: 0; }
.public-sidebar .players { grid-template-columns: 1fr; }
.public-sidebar .shared-panel { margin-top: 0; }
.public-sidebar .chips { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.public-sidebar .chips .chip:last-child { grid-column: auto; }
.public-sidebar .qtys { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.public-sidebar .qtys .qty:last-child { grid-column: 1 / -1; }
.public-sidebar .discard-banner, .public-sidebar .raider-banner, .public-sidebar .setup-controls { margin: 0; padding: 10px; }
.public-sidebar .discard-banner h2, .public-sidebar .raider-banner h2 { font-size: 17px; }
.public-sidebar .discard-banner .qtys { margin: 10px 0; }
.public-sidebar .discard-banner input { min-height: 34px; }
.public-sidebar select { width: 100%; min-width: 0; }
.public-sidebar p { font-size: 12px; }
.public-sidebar .raider-banner button { min-height: 38px; }
@media (min-width: 741px) and (min-height: 500px) {
  #app.game-open { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .game-open > header { flex: 0 0 auto; }
  .game-open > .table { flex: 1; min-height: 0; align-items: stretch; }
  .game-open .board-area { display: flex; flex-direction: column; align-items: center; container-type: size; min-width: 0; min-height: 0; }
  .game-open .board-wrap { flex: 0 0 auto; width: min(100cqw, 135cqh); height: min(100cqh, 110cqw); aspect-ratio: auto; min-height: 0; overflow: hidden; }
  .game-open .board { height: 100%; max-height: none; }
  .game-open .turn-controls { flex: 0 0 auto; }
  .game-open aside { min-height: 0; overflow-y: auto; align-content: start; padding-right: 3px; scrollbar-gutter: stable; }
  .game-open .personal-sidebar { display: flex; flex-direction: column; }
  .game-open .personal-sidebar > * { flex-shrink: 0; }
  .game-open .log-panel[open] { position: relative; flex: 1 0 255px; }
  .game-open .log-panel[open] .log { position: absolute; top: 34px; right: 8px; bottom: 8px; left: 8px; margin: 0; max-height: none; overflow-y: auto; }
}
@media (min-width: 741px) and (max-width: 1099px) {
  .table { grid-template-columns: minmax(0, 1fr) 310px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "turns side" "board side"; }
  .sidebars { grid-area: side; display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; }
  .game-open .sidebars aside { flex: 0 0 auto; overflow: visible; padding-right: 0; }
  .game-open .sidebars .personal-sidebar { flex: 1 0 auto; }
}
@media (max-width: 740px) {
  .table { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "turns" "public" "board" "personal"; }
  .turn-bar { grid-template-columns: minmax(0, 1fr); }
  .public-sidebar .players { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .public-sidebar .chips { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .public-sidebar .chips .chip:last-child { grid-column: auto; }
  .public-sidebar .qtys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .public-sidebar .qtys .qty:last-child { grid-column: auto; }
}

.board-area > .turn-controls { margin-top: 0; margin-bottom: 6px; }
.board-area > .turn-controls { border-left: 5px solid var(--turn-color); }
.turn-controls .turn-status { display: flex; align-items: flex-start; gap: 9px; height: 3.75em; overflow-y: auto; overflow-wrap: anywhere; font-size: clamp(16px, 1.3vw, 19px); line-height: 1.25; margin: 0 0 9px; font-weight: 800; }
.turn-status .turn-player-dot { margin-top: 4px; }
.turn-title { display: block; }
.turn-phase { display: block; white-space: nowrap; margin-top: 3px; font-size: 13px; font-weight: 500; color: var(--muted); }
.dice-pending { color: var(--muted); }
.turn-player-dot { flex: 0 0 14px; width: 14px; height: 14px; border-radius: 50%; background: var(--turn-color); border: 1px solid #23302f55; }

.costs-panel dl { margin: 0; font-size: 12px; }
.costs-panel dl > div + div { border-top: 1px solid var(--line); margin-top: 7px; padding-top: 7px; }
.costs-panel dt { font-weight: 700; }
.costs-panel dd { margin: 2px 0 0; color: var(--muted); line-height: 1.4; }
.costs-panel dd { display: flex; flex-wrap: wrap; gap: 3px 10px; }
.cost-resource { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cost-resource i { width: 9px; height: 9px; border-radius: 2px; border: 1px solid #23302f25; }
.trade-resource-labels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; font-size: 12px; text-align: center; margin-bottom: 5px; }

/* Keep resource counts and names aligned, including the longer timber label. */
.chip b { display: block; margin: 0; line-height: 1.15; }
.chip { white-space: nowrap; }
.qtys select { width: 100%; min-width: 0; min-height: 36px; border-bottom: 3px solid var(--c); }
.trade-form .qtys select, .resource-select { border-bottom: 3px solid var(--c); background-color: #f4f0e6; }
#trade-feedback { font-size: 12px; color: var(--muted); }
.raider-preview { pointer-events: none; }
.raider-preview polygon { fill: #bfa1e744; stroke: #fff; stroke-width: 4; stroke-dasharray: 6 3; }
.raider-preview text { fill: #fff; stroke: #50336f; stroke-width: 2px; paint-order: stroke; font: 700 8px system-ui, sans-serif; text-anchor: middle; }
.raider-confirmation { border-top: 1px solid #bda8d3; margin-top: 10px; padding-top: 8px; }
.raider-confirmation h3 { margin: 0 0 6px; font-size: 16px; }
.raider-confirmation .row button { flex: 1; width: auto; }
.raider-confirmation button[data-act="cancelRaid"] { color: var(--ink); background: var(--panel); border-color: var(--line); }

.revealed-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.played-summary { min-width: 0; max-width: 100%; }
.player-panel .revealed-more { padding: 0; min-height: 0; border: 0; background: transparent; color: var(--accent); font-size: 11px; font-weight: 600; text-decoration: underline; }
.revealed-dialog { width: min(360px, calc(100vw - 32px)); max-height: 80dvh; overflow-y: auto; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); }
.revealed-dialog::backdrop { background: #152e3866; }
.revealed-dialog ul { padding-left: 20px; margin: 16px 0; }
.revealed-dialog li { margin: 8px 0; }
.revealed-dialog form { text-align: right; }

.public-sidebar .discard-banner .qtys { grid-template-columns: minmax(0, 1fr); gap: 6px; }
.public-sidebar .discard-banner .qtys .qty { grid-column: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto 72px; align-items: center; gap: 10px; padding-left: 8px; border-left: 3px solid var(--c); }
.public-sidebar .discard-banner .qty .discard-resource { font-size: 13px; font-weight: 700; }
.public-sidebar .discard-banner .qty input { width: 100%; min-width: 0; min-height: 34px; }
.public-sidebar .discard-banner .primary { width: 100%; }

.player-heading { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 5px; width: 100%; }
.player-heading .name { min-width: 0; overflow-wrap: anywhere; }
.player-heading .score { white-space: nowrap; }
.player-badges { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.player-badges span { white-space: nowrap; font-size: 10px; line-height: 1.4; padding: 1px 5px; border-radius: 8px; background: #e8e3d7; color: var(--muted); font-weight: 600; }

[data-card-kind="patrol"] { --card-accent: #436c9b; --card-tint: #edf3fa; }
[data-card-kind="connections"] { --card-accent: #9b6a35; --card-tint: #f8f1e7; }
[data-card-kind="discovery"] { --card-accent: #52865b; --card-tint: #eef6ed; }
[data-card-kind="seizure"] { --card-accent: #a25454; --card-tint: #fbefed; }
[data-card-kind="achievement"] { --card-accent: #927522; --card-tint: #faf5df; }
.special-card[data-card-kind], .revealed-card { border-left: 4px solid var(--card-accent); background: var(--card-tint); }
.revealed-hand { margin-top: 10px; }
.revealed-hand h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.revealed-card-grid { display: grid; gap: 6px; }
.revealed-card { padding: 7px 9px; border-radius: 6px; }
.revealed-card strong { display: block; font-size: 13px; }
.revealed-card span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.build-cost { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.build-cost span { white-space: nowrap; }

.selection-panel > button { display: block; margin: 12px auto 0; }
.corner-production { margin: 8px 0 12px; }
.production-label { display: block; margin-bottom: 6px; font-size: 11px; color: var(--muted); }
.production-resources { display: flex; flex-wrap: wrap; gap: 6px; }
.production-resource { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; background: #f4f0e6; border-radius: 5px; font-size: 12px; white-space: nowrap; }
.production-resource i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.production-resource strong { margin-left: 3px; }

.draw-special { justify-content: center; }
.special-description { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 12px; margin: 4px 0; }

.my-resources-panel .chip { position: relative; }
.my-resources-panel .resource-received { background: #e6f3df; box-shadow: inset 0 0 0 2px #6c9954; }
.resource-gain { position: absolute; top: -7px; right: -2px; padding: 1px 4px; border-radius: 8px; background: #397043; color: white; font-size: 10px; line-height: 1.3; font-weight: 700; pointer-events: none; }
.my-resources-panel .resource-spent { background: #f9e9e4; box-shadow: inset 0 0 0 2px #b9624c; }
.resource-spent .resource-gain { background: #a34031; }
.resource-loss { margin: 8px 0 0; padding: 7px 10px; border-radius: 8px; border-left: 4px solid #7d8b88; background: #eef2f1; font-size: 13px; line-height: 1.4; color: var(--ink); }

.card-options .discovery-choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.discovery-choices label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.discovery-choices select { width: 100%; min-width: 0; min-height: 36px; }
.card-options > .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
.card-options > .row button { width: 100%; }

.resource-picker-label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
aside details.resource-picker { padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #f4f0e6; }
.resource-picker summary { padding: 8px; cursor: pointer; font-size: 13px; }
.resource-picker summary > span { display: inline-flex; align-items: center; gap: 7px; }
.resource-picker i { display: inline-block; flex: 0 0 12px; width: 12px; height: 12px; border: 1px solid #23302f25; border-radius: 2px; }
.resource-picker-options { padding: 4px; border-top: 1px solid var(--line); }
.resource-picker-options button { display: flex; align-items: center; gap: 7px; width: 100%; border: 0; background: var(--panel); text-align: left; margin: 2px 0; }
.resource-picker-options button small { margin-left: auto; color: var(--muted); }

.log li { padding: 5px 0; line-height: 1.4; }
.log li + li { border-top: 1px solid #ded7c966; }

.turn-bar.without-turn-controls { grid-template-columns: minmax(0, 1fr); }
.victory-banner { padding: 14px 18px; border: 2px solid #b19546; border-left: 7px solid var(--winner-color); border-radius: 12px; background: #faf2d7; text-align: center; }
.victory-label { text-transform: uppercase; letter-spacing: .1em; font-size: 11px; font-weight: 700; color: #79632d; }
.victory-banner h2 { margin: 4px 0; font-size: clamp(25px, 3vw, 38px); text-transform: none; letter-spacing: normal; color: var(--ink); }
.victory-banner p { margin: 0; font-size: 13px; }
.player-panel .players li.winner { border-color: #b19546; background: #faf2d7; }
.point-breakdown { width: 100%; margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--line); font-size: 11px; }
.point-breakdown > div { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
.point-breakdown dd { display: grid; grid-template-columns: 2ch 6ch; gap: 4px; flex-shrink: 0; margin: 0; white-space: nowrap; font-weight: 600; text-align: left; }
.point-value { text-align: right; font-variant-numeric: tabular-nums; }
.point-total { border-top: 1px solid var(--line); padding-top: 4px; font-weight: 700; }

/* Pre-game screens (create/join/lobby) are a single narrow column, centered. */
#app:not(.game-open) { max-width: 480px; padding-top: 10vh; }
#app:not(.game-open) > header { justify-content: center; }
#app:not(.game-open) .lede { text-align: center; }
