:root {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --ink: #14201c;
  --muted: #607069;
  --line: #d9e3de;
  --brand: #006b57;
  --brand-dark: #06483e;
  --accent: #b24b32;
  --gold: #d69a16;
  --shadow: 0 18px 42px rgba(24, 48, 40, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px clamp(18px, 4vw, 56px);
  background: #fbfcfb;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.home-link,
button {
  min-height: 42px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.game-shell {
  width: min(1280px, calc(100% - 28px));
  margin: 24px auto 40px;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
}

.control-panel,
.board-panel,
.score-panel,
.players-panel,
.ledger-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-self: start;
}

.control-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.control-panel input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

.button-row {
  display: grid;
  gap: 10px;
}

.button-row button:nth-child(2),
.button-row button:nth-child(3),
.button-row button:nth-child(4) {
  background: #fff;
  color: var(--brand-dark);
}

.board-panel {
  min-height: 430px;
  padding: 12px;
  overflow: hidden;
}

#network-board {
  width: 100%;
  min-height: 420px;
  display: block;
}

.score-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 1px;
  overflow: hidden;
}

.score-panel article {
  padding: 18px;
  background: #fff;
}

.score-panel span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.score-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.players-panel,
.ledger-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.player-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.player-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.player-card.best-move {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(214, 154, 22, 0.16);
}

.player-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.player-badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.player-cost {
  color: var(--brand-dark);
  font-weight: 900;
}

.route-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.route-toggle button {
  min-height: 36px;
  padding: 0 10px;
  background: #fff;
  color: var(--brand-dark);
}

.route-toggle button.active {
  background: var(--brand);
  color: #fff;
}

.saving {
  min-height: 22px;
  margin: 9px 0 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.ledger-panel {
  min-width: 0;
}

.ledger-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--brand-dark);
  font-size: 13px;
}

.game-footer {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto 36px;
  color: var(--muted);
  font-size: 14px;
}

.game-footer a {
  color: var(--brand-dark);
  font-weight: 800;
}

.edge {
  fill: none;
  stroke: #a9b9b2;
  stroke-width: 3;
  stroke-linecap: round;
}

.edge.used {
  stroke: var(--brand);
}

.edge-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.node {
  fill: #fff;
  stroke: var(--brand-dark);
  stroke-width: 3;
}

.hub-node {
  fill: #e8f4ef;
}

.terminal-node {
  stroke-width: 2;
}

.node-label {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
}

.player-dot {
  stroke: #fff;
  stroke-width: 2;
}

@media (max-width: 900px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .score-panel {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

@media (max-width: 560px) {
  .game-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .score-panel {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
