:root {
  color-scheme: light;
  --page: #f1ede2;
  --paper: #fffaf0;
  --ink: #193530;
  --muted: #59645c;
  --border: #d6cebb;
  --dark: #173631;
  --gold: #f1c66b;
  --all: #284c50;
  --open: #a74831;
  --locked: #573176;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, .viewport:focus-visible {
  outline: 2px solid #997228;
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.viewport.is-movable { cursor: grab; touch-action: none; }
.viewport.is-dragging, .viewport.is-dragging * { cursor: grabbing !important; }
.viewport.route-hover { cursor: pointer; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; }
.terrain, .fiber, #markers { position: absolute; inset: 0; width: 100%; height: 100%; }
.terrain, .fiber { pointer-events: none; }
.terrain { filter: saturate(.53) contrast(.79) brightness(1.18); }
#markers { pointer-events: none; }
.map-node {
  position: absolute; width: 24px; height: 24px; margin: 0; padding: 0; border: 0; border-radius: 50%;
  background: transparent; transform: translate(-50%, -50%); overflow: visible; pointer-events: none;
  color: var(--ink); font: 800 20px/1.1 "Avenir Next", "Helvetica Neue", sans-serif;
}
.marker-head, .marker-label { position: absolute; display: block; pointer-events: auto; }
.marker-head {
  left: 0; top: 0; width: 24px; height: 24px; padding: 0; border-radius: 50%;
  background: #fff2d1; border: 3px solid #1d3b36; outline: 2px solid #fff2d1;
}
.marker-head::after {
  content: ""; position: absolute; inset: 5px; border-radius: inherit; background: #1d3b36;
}
.market-node .marker-head, .external-node .marker-head {
  border-radius: 3px; width: 21px; height: 21px; top: 1.5px; left: 1.5px;
  transform: rotate(45deg); outline: none; border: 2px solid #f6ead0;
}
.market-node .marker-head { background: #a94832; }
.market-node .marker-head::after { inset: 5px; background: #fff1d6; }
.external-node .marker-head { background: #145450; }
.external-node .marker-head::after { display: none; }
.marker-label {
  display: grid; justify-items: center; gap: 3px; width: max-content; white-space: nowrap;
  left: calc(50% + var(--label-x)); top: calc(50% + var(--label-y));
}
.marker-caption {
  display: block; width: max-content; padding: 2px 3px; background: transparent; border: 0;
  color: inherit; font: inherit; text-align: center; white-space: nowrap;
  text-shadow: 0 0 3px #fff7e2, -1px 0 #fff7e2, 1px 0 #fff7e2, 0 -1px #fff7e2, 0 1px #fff7e2;
}
.marker-caption:hover { text-decoration: underline; text-underline-offset: 3px; }
.marker-caption:focus-visible, .slot-control:focus-visible { outline-offset: 1px; }
.slot-strip {
  display: flex; justify-content: center; gap: 4px; padding: 4px 5px;
  border: 1.5px solid #8c7756; background: #faf0d9; border-radius: 5px;
  box-shadow: 0 2px 3px #2d2c2340;
}
.slot-icon {
  display: inline-grid; place-items: center; flex: 0 0 auto; padding: 0;
  color: var(--industry-color); border: 1px solid var(--industry-color); border-radius: 3px;
  background: #fff6df; font-style: normal; font-weight: 800; line-height: 1;
}
.slot-icon svg {
  display: block; width: 20px; height: 20px; fill: currentColor;
}
.slot-control { width: 26px; height: 25px; }
.slot-control:hover, .slot-control[aria-pressed="true"] { background: var(--industry-color); color: white; }
.slot-control.is-occupied { background: var(--slot-owner); border-color: var(--slot-owner); color: white; }
.slot-control.is-occupied[aria-pressed="true"] { outline: 2px solid #664a1f; outline-offset: 1px; }
.map-node[data-label="left"] .marker-label { transform: translate(calc(-100% - 17px), -50%); }
.map-node[data-label="right"] .marker-label { transform: translate(17px, -50%); }
.map-node[data-label="above"] .marker-label { transform: translate(-50%, calc(-100% - 15px)); }
.map-node[data-label="below"] .marker-label { transform: translate(-50%, 15px); }
.external-node .marker-label, .market-node .marker-label { font-size: 17px; }
.market-node .marker-caption, .external-node .marker-caption {
  padding: 2px 6px; border-radius: 3px; background: #faedcf; text-shadow: none;
}
.market-node .marker-caption { color: #733324; }
.map-node:hover, .map-node:focus-within, .map-node.is-selected { z-index: 4; }
.map-node:hover .slot-strip, .map-node:focus-within .slot-strip, .map-node.is-selected .slot-strip {
  border-color: #604821; outline: 2px solid #f3cb73;
}
.map-node.is-selected .marker-caption { color: #543718; }
.map-node.is-selected .marker-head, .map-node.is-related .marker-head { outline: 4px solid #f2c368; }
.map-node.is-selected .marker-head { outline-width: 5px; }
.map-node .marker-head:focus-visible { outline: 4px solid #f2c368; outline-offset: 2px; }

.route-tip {
  position: absolute; z-index: 5; padding: 6px 9px; border-radius: 5px; font-size: .77rem;
  color: var(--paper); background: #12332e; pointer-events: none; white-space: nowrap;
}
.board-error { position: absolute; inset: 18px auto auto 18px; max-width: calc(100% - 36px); padding: 12px; background: var(--paper); border-radius: 7px; }
.legend-line { display: inline-block; width: 28px; height: 0; border-top: 3px solid var(--all); border-radius: 2px; }
.legend-line.open { border-color: var(--open); border-top-style: dashed; }
.legend-line.locked { border-top: 4px dotted var(--locked); }
.legend-node { display: inline-block; width: 9px; height: 9px; margin-inline: 2px; border-radius: 1px; transform: rotate(45deg); }
.legend-node.market { background: var(--open); }
.legend-node.external { background: #19605a; }
select {
  min-width: 0; border: 1px solid #d8ceb6; border-radius: 6px; background: #fbf6e9;
  color: var(--ink); padding: 6px 27px 6px 8px; font-size: .83rem; text-overflow: ellipsis; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #52665b 50%), linear-gradient(135deg, #52665b 50%, transparent 50%);
  background-position: calc(100% - 12px) 51%, calc(100% - 8px) 51%;
  background-size: 4px 4px; background-repeat: no-repeat;
}
.slot-picker { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.slot-option {
  padding: 5px 7px; border: 1px solid #d8ceb6; border-radius: 5px; background: #f9f3e4;
  color: var(--ink); font-size: .76rem; font-weight: 700;
}
.slot-option[aria-pressed="true"], .slot-option:hover {
  color: var(--industry-color); border-color: var(--industry-color);
}
.connection-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.connection-button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 36px; padding: 6px 7px; border: 1px solid transparent; border-radius: 6px;
  background: #f6f0e1; color: var(--ink); text-align: left; font-size: .8rem; font-weight: 700;
}
.connection-button:hover { background: #eee4cc; border-color: #ded1b5; }
.route-label { font-size: .73rem; color: #52665b; font-weight: 600; white-space: nowrap; }
.route-label.is-inactive { color: #735b7c; }
.route-label.is-built { border-bottom: 2px solid var(--seat); color: var(--ink); }
.trial-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: stretch; }
.trial-row select { flex: 1 1 130px; width: 118px; }
.primary-action, .secondary-action {
  min-height: 34px; padding: 6px 10px; border: 1px solid var(--dark); border-radius: 6px;
  background: var(--dark); color: var(--paper); white-space: nowrap; font-size: .81rem; font-weight: 700;
}
.primary-action:hover:not(:disabled) { background: #2d564c; }
.primary-action:disabled { color: #49534b; border-color: #d7cdb8; background: #eae3d4; }
.secondary-action { color: var(--ink); background: transparent; border-color: #cfc3aa; }
.secondary-action:hover { background: #f1e8d5; }
.owner-inline { display: inline-flex; align-items: center; gap: 6px; }
.owner-inline::before { content: ""; width: 10px; height: 10px; border-radius: 2px; flex: 0 0 10px; background: var(--seat); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

:root {
  --paper: #fbf7eb; --page: #eee8d8; --line: #beb49c; --faint: #ded5be;
  --serif: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
}
body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--serif); }
h2 { font-size: 1.12rem; letter-spacing: .045em; }
button { color: inherit; }
.masthead { background: #193a35; color: #fff8e3; border-bottom: 3px double #a99c78; }
.masthead-content { display: flex; align-items: center; gap: clamp(12px, 2.3vw, 36px); padding: 9px 20px; min-height: 55px; }
.brand { display: flex; align-items: center; gap: 10px; font: bold clamp(1.4rem,2.1vw,2rem)/1 var(--serif); letter-spacing: -.045em; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #dcc38c; border-radius: 6px; transform: rotate(-5deg); background: #314b3e; }
.brand-mark i { width: 17px; height: 17px; display: block; border: 3px double #e9cb87; box-shadow: 4px 0 0 -3px #e9cb87,-4px 0 0 -3px #e9cb87,0 4px 0 -3px #e9cb87,0 -4px 0 -3px #e9cb87; }
.turn-strip { display: flex; align-items: baseline; gap: 13px; padding-left: 20px; border-left: 1px solid #6a8173; font-size: .86rem; }
#round-label { color: #ebcb87; font-weight: 700; }
#actions-left { color: #c3d3c5; }
.rules-button { margin-left: auto; padding: 6px 11px; border: 1px solid #6e8777; border-radius: 4px; color: #fcf2d9; background: transparent; font-size: .82rem; }
.rules-button:hover { background: #35574c; }
.table { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(124px,10.6vw,175px) minmax(0,1fr) clamp(330px,30vw,530px); grid-template-rows: minmax(0,1fr) clamp(210px,26vh,248px); grid-template-areas: "rail board ledger" "dock dock ledger"; }
.rail,.ledger,.dock { background: var(--paper); scrollbar-color: #b8ae92 transparent; scrollbar-width: thin; }
.rail { grid-area: rail; overflow: auto; border-right: 1px solid var(--line); }
.rail section,.ledger > section { padding: 15px clamp(10px,1.1vw,20px); border-bottom: 1px solid var(--line); }
.rail h2 { margin-bottom: 12px; font-size: .97rem; }
.deck-face { aspect-ratio: 1.55; max-width: 116px; width: 87%; margin: 3px auto 13px; display: grid; place-items: center; border-radius: 6px; border: 3px solid #43564a; outline: 1px solid #aa9875; color: #e9d8a5;
  background: repeating-linear-gradient(45deg,transparent 0 4px,#a4b19640 4px 5px),repeating-linear-gradient(-45deg,transparent 0 4px,#a4b19640 4px 5px),#36594f;
  box-shadow: inset 0 0 0 1px #e0cd98,0 2px #f5f0dd,0 3px #8f8467,0 5px #f5f0dd,0 6px #8f8467; }
.deck-symbol { display: grid; place-items: center; width: 32px; height: 32px; border: 3px double #c6ba8e; border-radius: 50%; background: #345148; font: italic bold 1.2rem var(--serif); }
.pile-data { display: flex; align-items: baseline; justify-content: space-between; padding: 3px 0; font-size: .85rem; }
.pile-data strong { font: bold 1.28rem var(--serif); }
.deck-section small { display: block; margin-top: 7px; color: var(--muted); font-size: .76rem; }
.legend > span,.industry-legend > span { display: flex; gap: 9px; align-items: center; margin-top: 8px; color: #42554a; font-size: .82rem; }
.legend-node { margin-inline: 8px; }
.industry-legend .slot-icon { width: 24px; height: 24px; background: color-mix(in srgb,var(--industry-color) 9%,var(--paper)); border-radius: 50%; }
.industry-legend svg { width: 16px; height: 16px; }
.board-card { grid-area: board; min-height: 0; min-width: 0; display: flex; flex-direction: column; background: #eae5d4; }
.map-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 15px; padding: 5px 9px; background: var(--paper); }
.resource-market { border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.resource-market th,.resource-market td { padding: 2px 5px; white-space: nowrap; text-align: center; }
.resource-market th:first-child { padding-left: 0; text-align: left; }
.resource-market thead th { border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.resource-market thead th:first-child { color: var(--ink); font: bold .92rem var(--serif); }
.resource-market tbody th { color: var(--resource-color); }
.resource-market th svg { width: 16px; height: 16px; margin-right: 3px; vertical-align: -.21em; fill: currentColor; }
.resource-market small { margin-left: 4px; color: var(--muted); font-size: .74rem; font-weight: 500; }
.stock-cube { display: inline-block; vertical-align: middle; width: 10px; height: 10px; border: 1px dashed #a9a38f; border-radius: 2px; }
.stock-cube + .stock-cube { margin-left: 2px; }
.stock-cube.full { background: var(--resource-color); border: 1px solid color-mix(in srgb,var(--resource-color) 80%,black); box-shadow: inset 0 1px #ffffff55; }
.resource-market [data-resource="gpu"] .stock-cube { border-radius: 50%; }
.resource-quote { border-left: 1px solid var(--faint); color: var(--resource-color); font-weight: 750; }
.map-topbar .board-header { flex: 1 1 155px; flex-wrap: wrap; gap: 4px 8px; padding: 0; }
.map-topbar select { max-width: 100%; }
.board-header,.map-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 13px; }
.board-header > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.board-header h1 { font-size: 1.1rem; }
.board-header span,.map-footer,.panel-head > span { color: var(--muted); font-size: .77rem; }
.board-header select { max-width: 40%; }
.map-frame { flex: 1; min-height: 0; margin: 0 6px; padding: 5px; background: repeating-linear-gradient(90deg,#b2a680 0 1px,transparent 1px 9px),#dcd3b6; border: 1px solid #918972; box-shadow: inset 0 0 0 2px #e7dec6; }
.viewport { position: relative; isolation: isolate; overflow: hidden; width: 100%; height: 100%; border: 1px solid #405c51; background: repeating-linear-gradient(135deg,#2d4b47 0 1px,#304e49 1px 6px); touch-action: pan-y; }
.zoom-controls { position: absolute; left: 7px; top: 7px; display: grid; gap: 3px; z-index: 6; }
.zoom-controls button { width: 32px; height: 32px; border: 1px solid #b5ac92; border-radius: 4px; background: #fbf7ebf5; box-shadow: 0 1px 3px #152c2840; font-size: 1.04rem; font-weight: bold; }
.zoom-controls #zoom-fit { padding: 0; white-space: nowrap; font-size: .7rem; }
.zoom-controls button:disabled { color: #92978a; }
.map-footer { padding-block: 5px; }
.phase-switch { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.phase-switch button { background: transparent; border: 0; font-size: .75rem; padding: 3px 9px; }
.phase-switch button[aria-pressed=true] { background: #39564b; color: #fff8e1; }
.map-node .can-play { outline: 2px solid #daa946; background: #ffdda0; }
.ledger { grid-area: ledger; min-height: 0; min-width: 0; overflow-y: auto; border-left: 2px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.scores { width: 100%; border-collapse: collapse; text-align: right; font-variant-numeric: tabular-nums; }
.scores th { color: var(--muted); font-size: .75rem; font-weight: 500; padding: 0 5px 6px; border-bottom: 1px solid var(--faint); }
.scores th:first-child,.scores td:first-child { text-align: left; }
.scores td { padding: 6px 5px; border-bottom: 1px dashed var(--faint); font-size: .87rem; }
.scores tr:last-child td { border-bottom: 0; }
.score-value { background: transparent; color: inherit; font: inherit; font-weight: 700; border: 0; border-bottom: 1px dotted var(--muted); padding: 1px 3px; }
.scores .active { background: linear-gradient(90deg,color-mix(in srgb,var(--seat) 14%,var(--paper)),transparent); box-shadow: inset 3px 0 var(--seat); }
.seat-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.monogram { display: inline-grid; place-items: center; flex: none; width: 23px; height: 24px; border-radius: 4px 4px 7px 7px; background: var(--seat); color: #fffaf1; font: bold .65rem Georgia,serif; border: 1px solid #0003; box-shadow: inset 0 0 0 2px #ffffff30; }
.company-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px; margin-bottom: 10px; }
.company-button { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 34px; padding: 3px 0; font-size: .77rem; border: 0; border-bottom: 2px solid var(--faint); background: transparent; }
.company-button[aria-pressed=true] { border-color: var(--seat); background: color-mix(in srgb,var(--seat) 9%,var(--paper)); font-weight: bold; }
.mat-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.mat-tile { display: flex; flex-direction: column; min-width: 0; text-align: left; border: 1px solid color-mix(in srgb,var(--suit) 55%,var(--faint)); border-radius: 6px; padding: 0; overflow: hidden; background: color-mix(in srgb,var(--suit) 6%,var(--paper)); box-shadow: 0 2px 0 #3d332322; }
.tile-head,.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 2px; padding: 4px 6px; }
.tile-head { background: var(--suit); color: white; font-size: .78rem; font-weight: 700; }
.tile-head b { font: bold .72rem Georgia, serif; padding: 1px 4px; border-radius: 3px; background: #0002; }
.tile-face { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 6px; }
.tile-symbol { display: grid; place-items: center; flex: none; width: 27px; height: 27px; border: 3px double color-mix(in srgb,var(--suit) 45%,var(--paper)); border-radius: 50%; color: var(--suit); background: var(--paper); }
.tile-symbol svg { width: 17px; height: 17px; fill: currentColor; }
.tile-name { flex: 1 1 57px; font: bold .92rem/1.16 var(--serif); overflow-wrap: anywhere; }
.tile-foot { border-top: 1px solid color-mix(in srgb,var(--suit) 20%,var(--paper)); font-size: .73rem; color: #4b554b; }
/* Printed stacks and the shared demand track sit together in the ledger. */
.mat-tile[aria-expanded=true] { outline: 2px solid var(--suit); outline-offset: -1px; }
.tile-face { min-height: 46px; }
.tile-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-head b { white-space: nowrap; }
.tile-stats,.tile-status { padding: 4px 7px; font-size: .76rem; }
.tile-stats { padding-top: 0; color: #4c5145; }
.tile-status { display: block; border-top: 1px solid #6c715933; font-weight: 650; }
.tile-status.ready { color: #315d48; background: #e6eddd; }
.tile-status.locked { color: #715332; background: #f3e7d4; }
.tile-status.neutral,.tile-status.muted { color: #56594d; background: #eeeade; }
.expand-mark { display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid #0002; border-radius: 50%; color: var(--suit); background: var(--paper); font-size: 1rem; line-height: 1; }
#mat-stack { margin-top: 12px; padding: 11px; border: 1px solid var(--line); border-top: 3px solid var(--suit); background: color-mix(in srgb,var(--suit) 6%,var(--paper)); border-radius: 5px; }
#mat-stack h3 { font: bold 1.02rem var(--serif); }
.level-reference { margin: 0 0 9px; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.level-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.level-tile { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--paper); }
.level-tile.next { outline: 2px solid var(--suit); outline-offset: -1px; }
.level-cost { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 7px; padding: 7px 8px 5px; }
.level-cost strong { color: var(--ink); font: bold 1.45rem/1.1 var(--serif); }
.level-cost span,.level-output { color: #585441; font-size: .79rem; }
.power-cost { display: inline-flex; align-items: center; gap: .15em; white-space: nowrap; }
.power-cost svg { width: 1.15em; height: 1.15em; fill: #9a4b37; }
.level-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 0 8px; padding: 7px 0 5px; border-top: 1px dashed var(--line); text-align: center; }
.level-metrics div { display: flex; flex-direction: column-reverse; }
.level-metrics dt { color: var(--muted); font-size: .76rem; }
.level-metrics dd { margin: 0; color: var(--suit); font: bold 1.2rem/1.1 var(--serif); }
.level-output { padding: 3px 8px; font-weight: 650; }
.level-name { flex: 1; padding: 5px 8px 8px; font: bold .87rem/1.25 var(--serif); overflow-wrap: anywhere; }
.level-variant { display: flex; align-items: baseline; justify-content: space-between; gap: 3px; }
.level-variant small { flex: none; font: .73rem/1.4 system-ui, sans-serif; color: var(--muted); }
.level-tile footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; padding: 5px 7px; background: color-mix(in srgb,var(--suit) 6%,var(--paper)); border-top: 1px solid var(--faint); font-size: .76rem; }
#market-summary { border: 1px solid #8baf97; color: #315e4a; background: #e5eddf; border-radius: 99px; padding: 2px 8px; font-weight: 700; }
#market-summary.closed { border-color: #c49584; color: #834531; background: #f1e1da; }
.market-subhead,.market-risk { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: .79rem; color: var(--muted); }
.market-subhead strong { color: #63573c; }
.demand-track { list-style: none; display: grid; grid-template-columns: repeat(9,minmax(0,1fr)); padding: 0; margin: 5px 0; border: 1px solid #b5a27f; border-radius: 6px; background: linear-gradient(90deg,#f0db9e,#faf5e4); }
.demand-track li { display: grid; place-items: center; padding: 7px 0 3px; border-right: 1px solid #bfac807c; font: bold clamp(.92rem,1.3vw,1.35rem) var(--serif); color: #715b32; }
.demand-track li::after { content: "•"; font: .65rem/1 sans-serif; opacity: .55; }
.demand-track li.failure { color: #a04f39; background: #eed9cf; border: 0; border-radius: 0 5px 5px 0; }
.demand-track [aria-current=step] { background: #325d50; color: #fff2c7; border-radius: 4px; outline: 2px solid #8d793f; outline-offset: -1px; }
.demand-track [aria-current=step]::after { content: "◆"; opacity: 1; color: #f1cd73; }
.demand-track .failure[aria-current=step] { background:#954f3d; color:white; }
.market-note,.market-risk { color: var(--muted); font-size: .77rem; line-height: 1.4; }
.market-note { margin: 5px 0 12px; }
.demand-tiles { display: flex; gap: 3px; flex-wrap: wrap; margin: 5px 0 8px; }
.demand-tiles span { flex: 1; min-width: 18px; max-width: 38px; padding: 3px 0; text-align: center; border: 1px solid #bbaa81; border-radius: 4px; background: linear-gradient(var(--paper),#eee2be); box-shadow: 0 2px 0 #b3a58b55; color: #695433; font: bold .82rem var(--serif); }
.market-risk { justify-content: flex-start; align-items: center; }
.market-risk b { padding: 1px 6px; border: 1px solid #b1bc9d; background: #e9eddf; border-radius: 10px; color: #3d5a48; }
#sale-controls:not(:empty) { border-top: 1px solid var(--faint); margin-top: 9px; padding-top: 8px; }
#sale-controls select { width: 100%; margin-top: 4px; }
#sale-controls .market-note { margin: 0; }
.sale-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top: 6px; }
.mobile-nav { display: none; }
@media (max-width: 850px) {
  body { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); position: fixed; z-index: 8; inset: auto 0 0; padding: 4px 5px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
  .mobile-nav a { display: grid; place-items: center; min-height: 44px; border-radius: 5px; color: var(--muted); text-decoration: none; font-size: .86rem; font-weight: 650; }
  .mobile-nav a[aria-current=location] { color: var(--dark); background: #dce8df; }
}
.level-name details summary { cursor: pointer; }
.level-name details span { display: block; margin-top: 5px; font: .78rem/1.35 system-ui, sans-serif; }
.slot-control.is-flipped { position: relative; opacity: .83; }
.slot-control.is-flipped::after { content: "✓"; position: absolute; top:-5px; right:-5px; background:#285e42; border:1px solid #fff; border-radius:50%; color:white; font:bold 12px/14px sans-serif; width:14px; height:14px; }
@media (max-width: 580px) {
  #player-mat .mat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tile-face { min-height: 42px; }
}
.log-panel ol { list-style: none; margin: 0; padding: 0; }
.log-panel li { padding: 7px 1px; border-top: 1px dashed var(--faint); font-size: .84rem; line-height: 1.45; overflow-wrap: anywhere; }
.log-panel strong { color: var(--seat,var(--ink)); margin-right: 6px; }
.dock { grid-area: dock; display: grid; grid-template-columns: minmax(0,2.4fr) minmax(215px,1fr); min-width: 0; min-height: 0; border-top: 2px solid var(--line); }
.hand-panel,.action-panel { min-width: 0; padding: 8px 12px 11px; }
.hand-panel { display: flex; flex-direction: column; }
.dock .panel-head { margin-bottom: 6px; }
.hand-panel .panel-head > span { margin-right: auto; }
.text-control { padding: 3px 7px; border: 1px solid #c8bea4; border-radius: 4px; background: #f5efde; font-size: .75rem; }
.text-control[aria-pressed=true] { color: white; background: var(--dark); }
button:disabled { opacity: .56; }
.hand { flex: 1; min-height: 0; display: flex; align-items: stretch; gap: 5px; overflow-x: auto; padding: 4px 1px 3px; }
.play-card { display: flex; flex: 1 0 0; min-width: 56px; max-width: 105px; flex-direction: column; align-items: stretch; padding: 3px; border: 2px solid var(--suit); border-radius: 7px; color: #26382e; background: color-mix(in srgb,var(--suit) 13%,#faf3db); box-shadow: inset 0 0 0 1px #fff9,0 2px 0 #403d2e38; }
.play-card[aria-pressed=true] { box-shadow: 0 0 0 2px var(--dark); transform: translateY(-2px); }
.play-card:hover { background: color-mix(in srgb,var(--suit) 24%,#fff9e9); }
.card-type { padding: 3px 0; color: var(--suit); font-size: .72rem; font-weight: 750; }
.card-art { flex: 1; min-height: 30px; display: grid; place-items: center; position: relative; border-block: 1px solid color-mix(in srgb,var(--suit) 37%,transparent); background: repeating-linear-gradient(135deg,transparent 0 4px,#fff5 4px 5px); }
.card-art.city { background-image: linear-gradient(#fff0,#fff4),url("./assets/terrain.webp"); background-position: var(--map-pos); background-size: 460%; }
.card-art.city::before { content: ""; position: absolute; inset: 0; background: color-mix(in srgb,var(--suit) 15%,transparent); }
.card-art i { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; border: 3px double var(--suit); background: #faf2db; color: var(--suit); z-index: 1; font: bold 1rem var(--serif); }
.card-art svg { width: 20px; height: 20px; fill: currentColor; }
.card-name { display: grid; place-items: center; min-height: 31px; padding: 2px 0; font: bold .85rem/1.03 var(--serif); overflow-wrap: anywhere; }
.action-panel { border-left: 1px solid var(--line); overflow: auto; }
.detail-title { font: bold 1.02rem var(--serif); }
.detail-note { font-size: .78rem; line-height: 1.35; color: var(--muted); margin: 4px 0; }
.action-heading { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin-bottom: 5px; }
.trial-row { margin: 4px 0; }
.trial-row select { flex: 1 1 90px; }
.slot-picker { margin-bottom: 3px; }
.slot-option { padding: 3px 5px; }
.slot-option[aria-pressed=true] { background: #e5e6d7; }
.hand-cover { display: grid; place-content: center; justify-items: center; gap: 6px; width: 100%; border: 1px dashed var(--line); border-radius: 5px; font-size: .88rem; }
dialog { width: min(440px,calc(100% - 24px)); max-height: min(80dvh,710px); padding: 20px; border: 1px solid #8e856d; border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 10px 70px #14251c50; }
dialog::backdrop { background: #11251e66; }
dialog p,dialog ul { font-size: .93rem; line-height: 1.55; margin: 10px 0; }
dialog .connection-list { padding: 0; }
dialog details { margin-top: 10px; }
dialog summary { cursor: pointer; font-weight: 650; }
dialog a { display: inline-block; margin-top: 12px; color: #38634e; }
@media (max-width: 1160px) and (min-width: 851px) {
  .table { grid-template-columns: 111px minmax(0,1fr) 320px; }
  .dock { grid-template-columns: minmax(0,1fr) 205px; }
  .hand-panel,.action-panel { padding-inline: 8px; }
  .company-button .monogram { display: none; }
}
@media (max-width: 850px) {
  body { height: auto; min-height: 100dvh; }
  .table { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto; grid-template-areas: "board" "dock" "ledger" "rail"; }
  .map-frame { flex: auto; aspect-ratio: 1.5; }
  .ledger { border-left: 0; border-top: 2px solid var(--line); overflow: visible; }
  .dock { min-height: 168px; }
  .rail { display: flex; flex-wrap: wrap; border: 0; }
  .rail section { flex: 1 1 100px; }
  .deck-face { max-width: 80px; }
  .mat-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .ledger > section { padding: 14px; }
  .turn-strip { gap: 7px; padding-left: 10px; }
}
@media (max-width: 580px) {
  .masthead-content { flex-wrap: wrap; padding: 9px 12px 7px; gap: 7px; }
  .turn-strip { order: 3; flex: 0 0 100%; gap: 12px; padding: 0; border: 0; font-size: .79rem; }
  .board-header { padding: 6px 8px; }
  .board-header > div { gap: 2px; flex-direction: column; }
  .zoom-controls { display: flex; left: 3px; top: 3px; gap: 2px; }
  .zoom-controls button { width: 26px; height: 26px; }
  .dock { display: block; }
  .hand-panel { height: 155px; }
  .hand { gap: 5px; }
  .play-card { min-width: 63px; }
  .action-panel { border-left: 0; border-top: 1px solid var(--faint); }
  .action-heading { justify-content: flex-start; gap: 12px; }
  .trial-row { max-width: 450px; }
}

.table-tools { display: flex; gap: 6px; margin-left: auto; }
.table-tools .rules-button { margin: 0; }
#open-room { color: #ffe3a5; border-color: #a49368; }
#room-dialog { width: min(380px,calc(100% - 24px)); }
#room-entry label { display: block; margin: 16px 0 5px; font-size: .9rem; font-weight: 700; }
#room-entry input { min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fffaf0; font: inherit; }
#guest-name { width: 100%; margin-bottom: 8px; }
#join-code { text-transform: uppercase; flex: 1; }
.join-line,.room-invite,#room-seats li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#room-code { color: #335c4d; font: bold 1.35rem/1.3 monospace; letter-spacing: .12em; }
#room-seats { list-style: none; padding: 0; }
#room-seats li { padding: 8px 0; border-bottom: 1px dashed var(--faint); }
#room-seats li span { overflow-wrap: anywhere; }
#room-hint,#room-status { font-size: .85rem; }
#room-status:empty { margin: 0; }
#room-status,#room-feedback { overflow-wrap: anywhere; }
#room-feedback { background: #fff2ca; padding: 5px 14px; color: #65471b; font-size: .86rem; }
.seat-player { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); max-width: 110px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

#cash-available { margin-right: auto; font: 700 1rem var(--serif); }
.action-modes,.build-options { display: flex; gap: 5px; flex-wrap: wrap; margin: 0 0 6px; }
.action-modes { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); }
.action-modes button { min-height: 29px; padding: 3px 2px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font-size: .8rem; }
.action-modes #pass { grid-column: span 2; }
.route-choice { display: grid; gap: 3px; margin-block: 5px; font-size: .8rem; }
.route-choice select { max-width: 100%; min-width: 0; }
.action-modes button[aria-pressed=true] { color: var(--paper); background: var(--ink); }
.action-modes button:disabled { opacity: .5; }
.build-option { display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px; min-height: 36px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
.build-option[aria-pressed=true] { box-shadow: inset 0 0 0 1px var(--suit); border-color: var(--suit); background: color-mix(in srgb,var(--suit) 8%,var(--paper)); }
.build-option svg { width: 21px; height: 21px; fill: var(--suit); }
.build-option-state { display: grid; justify-items: center; line-height: 1; }
.build-option-state small { font: 600 .7rem system-ui,sans-serif; }
.build-option-state .ready { color: #287047; }
.build-option-state .blocked,.build-reason { color: #963f35; }
.build-option strong { border-left: 1px solid var(--line); padding-left: 4px; font: bold .9rem var(--serif); }
.build-details { font-size: .82rem; }
.build-needs,.build-gives { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; }
.build-needs b,.build-gives b { color: var(--muted); font-size: .76rem; }
.build-reason { margin: 3px 0; }
.build-details .primary-action { min-height: 28px; padding: 3px 8px; }
.develop-choices { display: flex; flex-wrap: wrap; gap: 10px; }
.develop-choices label { display: grid; gap: 4px; }
@media (max-width: 580px) {
  .build-option { min-height: 44px; padding-inline: 8px; }
  .action-modes button { min-height: 34px; }
}
