:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --line: #2a3050;
  --text: #eef0fa;
  --dim: #a3a9c7;
  --accent: #7c9cff;
  --accent-ink: #0b1030;
  --good: #58d68d;
  --warn: #f5b041;
  --bad: #ff6b6b;
  --black: #111;
  --white: #f4f4f4;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

.city-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.city-bar .biz-name { font-weight: 600; flex: 1; min-width: 0; }
.city-link { text-decoration: none; }
#nvc-passport-mount { min-width: 0; max-width: calc(100vw - 16px); }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { margin: 8px 0 4px; font-size: 1.6rem; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.sub, .note { color: var(--dim); }
.note { font-size: 0.9rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; }
fieldset label { display: block; padding: 4px 0; }
.stake { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.stake input { width: 140px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 1rem; }

.btn {
  display: inline-block;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: default; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.list li span { min-width: 0; overflow-wrap: anywhere; }
.list li.empty { color: var(--dim); justify-content: flex-start; }

.match-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.85rem; }
.badge.vibes { border-color: var(--warn); color: var(--warn); }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.player { display: flex; flex-direction: column; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.player strong { overflow-wrap: anywhere; }
.player span { color: var(--dim); font-variant-numeric: tabular-nums; }
.player.to-move { border-color: var(--accent); }
.player.me strong { color: var(--accent); }

.status { font-weight: 600; min-height: 1.5em; }
.error { color: var(--bad); min-height: 1.2em; }

.contract { border: 1px dashed var(--warn); border-radius: 10px; padding: 12px; margin: 8px 0; }
.contract dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 12px; }
.contract dt { color: var(--dim); }
.contract dd { margin: 0; overflow-wrap: anywhere; }

.board-area { margin: 12px 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 2px;
  width: min(100%, 520px);
  margin: 0 auto;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.grid-3 { width: min(100%, 320px); }
.cell {
  aspect-ratio: 1;
  border: 0;
  background: var(--panel);
  color: var(--text);
  font-size: clamp(0.6rem, 6vw, 2.4rem);
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  position: relative;
}
.cell:disabled { cursor: default; }
.cell.win { background: #23402f; }
.cell.disc, .cell.stone { background: #1d5e3a; }
.grid-15 .cell.stone { background: #c9a063; }
.cell.piece-b::after, .cell.piece-w::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: var(--black);
}
.cell.piece-w::after { background: var(--white); }
.cell.hint::after { content: ""; position: absolute; inset: 40%; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }

.dice { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.die {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--white);
  color: var(--black);
  font-size: 1.4rem;
  font-weight: 700;
}
.die.held { opacity: 0.45; }
.die.selected { border-color: var(--accent); outline: 3px solid var(--accent); }
.dice-seat p { margin: 4px 0; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.footer { padding: 24px 16px; color: var(--dim); font-size: 0.85rem; text-align: center; }

@media (max-width: 420px) {
  .players { grid-template-columns: 1fr; }
  .grid-15 .cell { font-size: 0.5rem; }
}
