:root {
  --bg: #f4f1ea;
  --ink: #1f2a30;
  --dim: #5b666c;
  --line: #d6d0c4;
  --card: #fffdf8;
  --accent: #1d5f8a;
  --accent-ink: #ffffff;
  --sea: #2c6f93;
  --warn: #9b2c1f;
  --brick: #b65a3c;
  --wood: #3f7a3a;
  --sheep: #9cc56b;
  --wheat: #e2bd45;
  --ore: #8d939b;
  --desert: #e3d4a6;
  --p-red: #c8372d;
  --p-blue: #2b64c6;
  --p-green: #23874a;
  --p-purple: #7b45b8;
  --gap: 12px;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.4;
  font-size: 16px;
}
h1,
h2,
h3 {
  margin: 0 0 8px;
  line-height: 1.2;
}
h2 {
  font-size: 20px;
}
h3 {
  font-size: 16px;
}
button {
  font: inherit;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.on,
button[aria-checked="true"],
button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  font-weight: 600;
}
/* Refused moves stay tappable; tapping says why. */
button.muted,
button[aria-disabled="true"] {
  color: #8a9196;
  background: #eeebe4;
}
button.primary.muted {
  background: #9fb5c4;
  border-color: #9fb5c4;
  color: #f4f7f9;
}
input {
  font: inherit;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  width: 100%;
  max-width: 320px;
}
.note {
  color: var(--dim);
  font-size: 14px;
  margin: 6px 0;
}
.dim {
  color: var(--dim);
}
.warn {
  color: var(--warn);
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 8px 12px;
  background: #123247;
  color: #fff;
}
.brand {
  font-size: 18px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  width: 18px;
  height: 20px;
  background: var(--wheat);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.brand-tag {
  font-weight: 400;
  font-size: 14px;
  opacity: 0.85;
}
.tools {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tools button {
  background: transparent;
  color: #fff;
  border-color: #3d6178;
  padding: 6px 10px;
}
.tools button.muted {
  color: #9ab0bf;
  background: transparent;
}
.tools button[aria-pressed="true"] {
  background: #fff;
  color: #123247;
  box-shadow: none;
}
.save-warn {
  margin: 0;
  padding: 8px 12px;
  background: #fbe9e5;
}
main {
  padding: var(--gap);
  max-width: 1280px;
  margin: 0 auto;
}
.foot {
  text-align: center;
  padding: 12px;
}

.setup .field {
  display: block;
  margin: 14px 0;
}
.label {
  display: block;
  font-weight: 600;
  margin: 8px 0 6px;
  font-size: 14px;
}
.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.actions,
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 8px 0;
}
.lede {
  max-width: 60ch;
}
.sub-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Game */
.game {
  display: grid;
  gap: var(--gap);
}
.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.pl {
  border: 1px solid var(--line);
  border-left: 6px solid var(--pc);
  background: var(--card);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 0;
}
.pl.now {
  box-shadow: 0 0 0 2px var(--pc);
}
.pl-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pl-top b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pl-pts {
  margin-left: auto;
  font-weight: 700;
  white-space: nowrap;
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pc);
  flex: none;
}
.pl-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  color: var(--dim);
}
.pl-hand {
  font-size: 12px;
  margin-top: 2px;
}
.pl-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e8eef2;
  color: #123247;
}
.p-red {
  --pc: var(--p-red);
}
.p-blue {
  --pc: var(--p-blue);
}
.p-green {
  --pc: var(--p-green);
}
.p-purple {
  --pc: var(--p-purple);
}

.board-wrap {
  background: var(--sea);
  border-radius: 14px;
  padding: 4px;
}
.board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 10.7 / 9.6;
}
.hex polygon {
  stroke: #f4ead0;
  stroke-width: 0.05;
}
.h-brick polygon {
  fill: var(--brick);
}
.h-wood polygon {
  fill: var(--wood);
}
.h-sheep polygon {
  fill: var(--sheep);
}
.h-wheat polygon {
  fill: var(--wheat);
}
.h-ore polygon {
  fill: var(--ore);
}
.h-desert polygon {
  fill: var(--desert);
}
.hex-res {
  font-size: 0.22px;
  text-anchor: middle;
  fill: #fff;
  font-weight: 600;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.45);
  stroke-width: 0.04px;
}
.h-desert .hex-res,
.h-wheat .hex-res,
.h-sheep .hex-res {
  fill: #1f2a30;
  stroke: rgba(255, 255, 255, 0.5);
}
.token {
  fill: #fbf5e6;
  stroke: #6b5e44;
  stroke-width: 0.02;
}
.num {
  font-size: 0.3px;
  font-weight: 700;
  text-anchor: middle;
  fill: #1f2a30;
}
.num.red {
  fill: #b3261e;
}
.pip {
  fill: #1f2a30;
}
.hex.legal polygon {
  stroke: #fff;
  stroke-width: 0.1;
  cursor: pointer;
}
.hex.hinted polygon,
.hex.legal.hinted polygon {
  stroke: #ffde4a;
  stroke-width: 0.14;
}
.port line {
  stroke: #f4ead0;
  stroke-width: 0.05;
}
.port rect {
  fill: #fbf5e6;
  stroke: #123247;
  stroke-width: 0.02;
}
.port text {
  font-size: 0.19px;
  text-anchor: middle;
  fill: #123247;
  font-weight: 600;
}
.road {
  stroke: var(--pc);
  stroke-width: 0.16;
  stroke-linecap: round;
}
.bld {
  fill: var(--pc);
  stroke: #fff;
  stroke-width: 0.035;
}
.robber circle,
.robber path {
  fill: #222;
  stroke: #fff;
  stroke-width: 0.02;
}
.edge-tap {
  stroke: transparent;
  stroke-width: 0.32;
  stroke-linecap: round;
  cursor: pointer;
}
.edge-tap.legal {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-dasharray: 0.12 0.08;
}
.edge-tap.hinted {
  stroke: #ffde4a;
  stroke-dasharray: none;
}
.hint-mark {
  fill: none;
  stroke: #ffde4a;
  stroke-width: 0.1;
  stroke-dasharray: 0.12 0.08;
  pointer-events: none;
}
.vert-tap {
  fill: transparent;
  cursor: pointer;
}
.vert-tap.legal {
  fill: rgba(255, 255, 255, 0.75);
  stroke: #123247;
  stroke-width: 0.03;
}
.vert-tap.hinted {
  fill: #ffde4a;
  stroke: #123247;
  stroke-width: 0.05;
}
[role="button"]:focus-visible {
  outline: none;
  stroke: #ffde4a;
}

.status {
  padding: 10px 12px;
  border-radius: 10px;
  background: #e8eef2;
  min-height: 44px;
}
.status.error {
  background: #fbe9e5;
  color: var(--warn);
}
.box {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}
.box p {
  margin: 4px 0;
}
.build-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.res-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.res-grid button {
  padding: 6px 2px;
  font-size: 13px;
}
.b2 {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.b2 small {
  font-size: 12px;
  color: inherit;
  opacity: 0.8;
}
.steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.step {
  display: grid;
  grid-template-rows: auto auto auto auto;
  justify-items: center;
  gap: 2px;
  font-size: 13px;
}
.pm {
  width: 44px;
  padding: 0;
  position: relative;
}
.minus,
.plus {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}
.plus::after {
  content: "";
  position: absolute;
  left: 6px;
  top: -6px;
  width: 2px;
  height: 14px;
  background: currentColor;
}
.replies,
.cards {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}
.replies li,
.cards li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.cards li .dim {
  flex: 1 1 100%;
  font-size: 14px;
}
.rate {
  margin: 6px 0;
}
.coach-tag {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #123247;
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  margin-right: 4px;
}

.hand {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
}
.hand-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.rc {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 8px;
  padding: 6px 2px;
  border: 2px solid var(--rcol);
  background: color-mix(in srgb, var(--rcol) 18%, white);
  font-size: 12px;
}
.rc b {
  font-size: 18px;
}
.r-brick {
  --rcol: var(--brick);
}
.r-wood {
  --rcol: var(--wood);
}
.r-sheep {
  --rcol: var(--sheep);
}
.r-wheat {
  --rcol: var(--wheat);
}
.r-ore {
  --rcol: var(--ore);
}
.dev-line,
.pieces {
  font-size: 13px;
  margin: 6px 0 0;
}

.coach {
  border: 2px solid #123247;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}
.coach-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.coach-why {
  margin: 6px 0;
}
.numbers summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.nums {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  display: grid;
  gap: 4px;
}
.nums .numbtn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.math {
  background: #f3f6f8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.log-wrap h3 {
  font-size: 14px;
  color: var(--dim);
}
.log {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
}
.log li {
  margin: 2px 0;
}
.log li.flag {
  background: #fff4d6;
}
.log small {
  display: block;
  color: var(--warn);
}

.history-list,
.mistakes,
.rev-hands {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: grid;
  gap: 6px;
}
.hist-row,
.mistake {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hist-row small,
.mistake small {
  color: var(--dim);
}
.m-cost {
  font-weight: 700;
  color: var(--warn);
}
.stepper {
  justify-content: space-between;
}
.rev-grid {
  display: grid;
  gap: var(--gap);
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 28, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.sheet[hidden] {
  display: none;
}
.sheet-body {
  background: var(--card);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 12px 16px 24px;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: -12px;
  background: var(--card);
  padding-top: 4px;
}
.rules li {
  margin: 4px 0;
}

@media (min-width: 900px) {
  .game {
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 1fr);
    align-items: start;
  }
  .players {
    grid-template-columns: repeat(4, 1fr);
  }
  .board-wrap {
    max-width: 640px;
  }
  .rev-grid {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
    align-items: start;
  }
  .sheet {
    align-items: center;
  }
  .sheet-body {
    border-radius: 16px;
  }
}
