:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f7f5f0;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --line: #ddd8cc;
  --accent: #1a7f4b;
  --accent-2: #d7263d;
  --board: #cfe3cf;
  --cell: #e7f2e4;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151715; --surface: #1f221f; --surface-2: #262a26; --text: #ebe9e3; --muted: #a2a59e; --line: #353a35;
    --accent: #3bbf7a; --accent-2: #ff5a6b; --board: #243126; --cell: #2b3a2d; --danger: #ff6b61;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #151715; --surface: #1f221f; --surface-2: #262a26; --text: #ebe9e3; --muted: #a2a59e; --line: #353a35;
  --accent: #3bbf7a; --accent-2: #ff5a6b; --board: #243126; --cell: #2b3a2d; --danger: #ff6b61;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding: 0 16px 32px; }
h1 { font-size: 20px; margin: 0; }
h1 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent) url('/favicon.svg') center/cover; display: inline-block; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.tab { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 7px; cursor: pointer; font: inherit; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.panel { display: none; }
.panel.active { display: block; }
main { max-width: 1400px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.form label, .row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; align-items: flex-end; }
.row > label { min-width: 140px; flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); min-width: 0; }
label.check.small { font-size: 12px; }
input[type=text], input[type=number], input[type=password], input[type=url], select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%;
}
textarea { resize: vertical; }
input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.btn { font: inherit; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.file { display: inline-block; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.keys { display: grid; gap: 8px; }
.key-row { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: center; }
.key-row .name { font-size: 13px; }
.key-row .name a { font-size: 11px; margin-left: 4px; }
.key-row .status { font-size: 12px; color: var(--muted); grid-column: 2 / span 2; }
@media (max-width: 700px) { .key-row { grid-template-columns: 1fr; } .key-row .status { grid-column: 1; } }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.player { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface-2); border-top: 4px solid var(--pc, var(--accent)); }
.player .head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.player .head input[type=text] { flex: 1; }
.player .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.player label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.player .note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.player textarea { margin-top: 6px; }

.playbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.playbar-right { display: flex; gap: 10px; align-items: center; }
.play-grid { display: grid; grid-template-columns: minmax(320px, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .play-grid { grid-template-columns: 1fr; } }
.board-wrap { background: var(--board); border-radius: 12px; padding: 8px; border: 1px solid var(--line); }
.board { display: grid; gap: 2px; aspect-ratio: 1; width: 100%; max-width: 820px; margin: 0 auto; }
.cell { background: var(--cell); border-radius: 3px; position: relative; overflow: hidden; font-size: 9px; line-height: 1.1; padding: 2px 3px; display: flex; flex-direction: column; justify-content: flex-end; border: 2px solid transparent; }
.cell .band { height: 18%; margin: -2px -3px 2px; background: var(--gc, transparent); }
.cell .name { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cell .price { color: var(--muted); font-size: 8px; }
.cell .bld { font-size: 8px; color: var(--accent-2); font-weight: 700; }
.cell.corner { font-weight: 700; justify-content: center; align-items: center; text-align: center; font-size: 10px; }
.cell.corner .name { -webkit-line-clamp: 3; white-space: normal; }
.cell.mort { background: repeating-linear-gradient(45deg, var(--cell), var(--cell) 4px, rgba(0,0,0,.08) 4px, rgba(0,0,0,.08) 8px); }
.cell .tokens { position: absolute; top: 20%; right: 2px; display: flex; flex-wrap: wrap; gap: 1px; max-width: 60%; justify-content: flex-end; }
.tok { width: 12px; height: 12px; border-radius: 50%; color: #fff; font-size: 8px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.7); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.centre { grid-column: 2 / -2; grid-row: 2 / -2; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 10px; }
.centre .title { font-size: 22px; font-weight: 800; letter-spacing: .08em; color: var(--accent-2); }
.centre .dice { font-size: 26px; }
.centre .last { font-size: 12px; color: var(--muted); max-width: 90%; }
@media (max-width: 600px) { .cell { font-size: 7px; padding: 1px 2px; } .cell .price, .cell .bld { display: none; } .centre .title { font-size: 14px; } }

.player-cards { display: grid; gap: 8px; margin-bottom: 12px; }
.pcard { border: 1px solid var(--line); border-left: 5px solid var(--pc); border-radius: 8px; padding: 8px 10px; background: var(--surface); font-size: 13px; }
.pcard.current { outline: 2px solid var(--accent); }
.pcard.bankrupt { opacity: .5; }
.pcard .n { font-weight: 700; display: flex; justify-content: space-between; }
.pcard .m { color: var(--muted); font-size: 11px; }
.pcard .props { font-size: 11px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 2px; }
.pcard .props span { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--gc); }
.pcard .reason { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 4px; }
.feed-head { display: flex; justify-content: space-between; align-items: center; }
.feed { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; height: 260px; overflow: auto; font-size: 12px; padding: 6px 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.feed div { padding: 1px 0; border-bottom: 1px dotted var(--line); white-space: pre-wrap; word-break: break-word; }
.feed .ev-bankrupt, .feed .ev-game_end { color: var(--accent-2); font-weight: 700; }
.feed .ev-purchase, .feed .ev-auction_won, .feed .ev-build { color: var(--accent); }
.feed.llm { height: 220px; }
.feed.chat { height: 200px; font-family: inherit; font-size: 13px; }
.feed.chat .who { font-weight: 700; color: var(--c); }
.feed.chat .priv { color: var(--muted); font-style: italic; }
.feed.llm .err { color: var(--danger); }
details summary { cursor: pointer; margin: 10px 0 6px; font-weight: 600; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; }
.chart { width: 100%; max-width: 900px; height: auto; margin: 8px 0 16px; display: block; }
.chart text { font: 11px system-ui, sans-serif; fill: var(--muted); }
.chart .axis { stroke: var(--line); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; margin-bottom: 6px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 5px; vertical-align: middle; }
pre.json { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; max-height: 400px; font-size: 12px; }
footer { text-align: center; margin-top: 24px; }

.page-404 main { display: flex; justify-content: center; padding-top: 40px; }
.notfound { max-width: 420px; text-align: center; border-top: 8px solid var(--accent-2); }
.notfound .chance { color: var(--accent-2); font-weight: 800; letter-spacing: .2em; margin: 0 0 8px; }
