:root {
  --bg: #1f2125;
  --panel: #2a2d33;
  --ink: #e8e8ea;
  --muted: #9aa0a6;
  --accent: #77c7ff;
  --board-bg: #e8dcc0;     /* paper/parchment tone */
  --board-edge: #7a6a4a;
  --cell-hover: #c8b98d;
  --black-piece: #161616;
  --white-piece: #fafaf4;
  --claimed-black: rgba(20, 20, 20, 0.22);
  --claimed-white: rgba(255, 255, 255, 0.35);
  --selection: #d94b1a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #3a3d44;
}

.brand {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.15rem;
}

.who { color: var(--muted); margin-left: auto; }

main { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--panel);
  padding: 1.25rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 780px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

button {
  background: var(--accent);
  color: #0c1218;
  border: 0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
.inline { display: inline; }

input[type="text"], input:not([type]) {
  background: #14161a;
  color: var(--ink);
  border: 1px solid #3a3d44;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  width: 100%;
  margin-top: 0.25rem;
}

label { display: block; margin-bottom: 0.75rem; }

.error { color: #ff8a8a; }
.muted { color: var(--muted); }

.players { list-style: none; padding: 0; }
.players li { padding: 0.4rem 0; border-bottom: 1px solid #3a3d44; display: flex; justify-content: space-between; align-items: center; }

.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th, .leaderboard td {
  text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid #3a3d44;
}

.game-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.board-card { text-align: center; }
.status { margin: 0.75rem 0; font-weight: 600; }

.gameover {
  margin: 0.5rem 0 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  border: 2px solid var(--accent);
  background: #14161a;
  color: var(--ink);
}
.gameover.black {
  background: #111;
  color: #f4f4f6;
  border-color: #444;
}
.gameover.white {
  background: #efe9d3;
  color: #1a1a1a;
  border-color: #b8ac84;
}
.gameover.draw {
  background: #2a2d33;
  color: var(--ink);
  border-color: #4a4e56;
}

svg#board {
  width: min(100%, 640px);
  height: auto;
  background: var(--board-bg);
  border-radius: 8px;
  padding: 0.5rem;
}

.edge {
  stroke: var(--board-edge);
  stroke-width: 0.05;
  stroke-linecap: round;
  pointer-events: none;
}

/* Transparent base so every hover highlights uniformly. */
.cell { fill: transparent; cursor: pointer; pointer-events: all; }
.cell:hover { fill: var(--cell-hover); }
/* Faint fill on every currently-legal move so the player can see at a
   glance where placements are allowed without hovering each cell. */
.cell:not(.illegal):not(.occupied) { fill: rgba(118, 88, 34, 0.22); }
.cell:not(.illegal):not(.occupied):hover { fill: var(--cell-hover); }
.cell.illegal { cursor: default; pointer-events: none; }
.cell.occupied { cursor: default; fill: transparent; pointer-events: none; }
.cell.claimed-black { fill: var(--claimed-black); }
.cell.claimed-white { fill: var(--claimed-white); }

.piece.black { fill: var(--black-piece); stroke: #000; stroke-width: 0.05; }
.piece.white { fill: var(--white-piece); stroke: #333; stroke-width: 0.06; }
.piece.ghost { opacity: 0.45; }

.selection { fill: none; stroke: var(--selection); stroke-width: 0.12; }

.controls { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.75rem; }
.hint { color: var(--muted); font-size: 0.9rem; }

.scrubber {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.scrubber input[type="range"] { flex: 1; }
.scrubber button { padding: 0.35rem 0.8rem; }
