:root {
  --board: min(76vmin, 680px);
  --bg: #1f2328;
  --panel: #30363d;
  --border: #6e7681;
  --text: #f6f8fa;
  --muted: #8c959f;
  --soft: #c9d1d9;
  --green: #1f6f43;
  --green-border: #3fb950;
  --red: #da3633;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  display: grid;
  justify-items: center;
  align-items: start;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

main {
  display: grid;
  gap: 20px;
  justify-items: center;
  width: 100%;
  padding: 24px;
}

h1 { margin: 0 0 8px; font-size: 24px; font-weight: 600; }
#board { width: var(--board); height: var(--board); }
#setup, fieldset, .players, .player-row { display: flex; align-items: center; }
#setup { gap: 12px; }
fieldset { gap: 10px; margin: 0; padding: 0; border: 0; }
label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

select,
button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 7px 13px;
  font: inherit;
}

button { cursor: pointer; }
select:focus, button:focus { outline: 2px solid #58a6ff; outline-offset: 2px; }

#setup button,
.players div[id$="-player"].active {
  border-color: var(--green-border);
  background: var(--green);
  font-weight: 700;
}

.game {
  display: grid;
  grid-template-columns: 285px var(--board) 250px;
  gap: 18px;
}

.logs {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  height: var(--board);
  min-height: 0;
}

#log,
#kingsman-log,
.players div[id$="-player"] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--soft);
}

#log,
#kingsman-log {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.players {
  height: var(--board);
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 15px;
}

.player-row { gap: 8px; }
.players div[id$="-player"] { min-width: 140px; padding: 16px 12px; text-align: center; }
.players div[id$="-player"].active { color: #f0fff4; }

.players .abandon {
  width: 51px;
  height: 51px;
  padding: 0;
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  font-weight: 700;
}

.player-row.is-kingsman .abandon { display: none; }
.player-row.pending .abandon { background: var(--panel); color: var(--muted); }

footer {
  position: fixed;
  right: 12px;
  bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

footer a { color: inherit; }

@media (max-width: 760px) {
  :root { --board: min(92vmin, 680px); }
  .game { grid-template-columns: 1fr; }
  .players { width: 100%; height: auto; flex-direction: row; padding: 0; }
  .player-row { width: 48%; }
  .players div[id$="-player"] { min-width: 0; flex: 1; }
  .logs { width: 100%; height: 220px; }
}
