:root {
  --bg: #1a1d24;
  --bg-elev: #232732;
  --board: #f4e8d0;
  --board-line: #c9b88e;
  --red-tint: #fbe5e3;
  --black-tint: #dcdcdc;
  --red: #c8302c;
  --red-dark: #8b1f1d;
  --black: #1a1a1a;
  --black-light: #3a3a3a;
  --text: #e8e6e1;
  --text-dim: #9aa0ad;
  --accent: #d4a657;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Inter", -apple-system, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.status {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elev);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 1.05rem;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(200,48,44,0.18);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.dot.black {
  background: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.35);
}

.dot.winner {
  box-shadow: 0 0 0 6px rgba(212,166,87,0.4);
}

.hint {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

#board {
  width: min(720px, 92vw);
  height: auto;
  background: var(--board);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(0,0,0,0.05);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#board.rearrange { cursor: crosshair; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  width: 100%;
}

button {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  transition: background 120ms, border-color 120ms, transform 80ms;
}

button:hover { background: #2c3140; border-color: rgba(255,255,255,0.18); }
button:active { transform: translateY(1px); }

button.primary {
  background: var(--accent);
  color: #1a1d24;
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover { background: #e0b876; border-color: #e0b876; }

button.active {
  background: var(--accent);
  color: #1a1d24;
  border-color: var(--accent);
}

button.hidden { display: none; }

.footer-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.legend {
  display: flex;
  gap: 1rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.swatch.red { background: var(--red); }
.swatch.black { background: var(--black); }

/* SVG board styling */
.hole {
  fill: rgba(0,0,0,0.18);
  stroke: rgba(0,0,0,0.06);
  stroke-width: 0.5;
}

.hole.legal:hover { fill: rgba(0,0,0,0.32); cursor: pointer; }
.hole.illegal:hover { cursor: not-allowed; }

.border-red { fill: var(--red-tint); }
.border-black { fill: var(--black-tint); }

.peg-red { fill: var(--red); stroke: #6b1614; stroke-width: 1.2; }
.peg-black { fill: var(--black); stroke: #000; stroke-width: 1.2; }

.peg.last-placed { filter: drop-shadow(0 0 6px var(--accent)); }

.link-red { stroke: var(--red); stroke-width: 4; stroke-linecap: round; }
.link-black { stroke: var(--black); stroke-width: 4; stroke-linecap: round; }

.link.removable:hover { stroke: var(--accent); cursor: pointer; }

.ghost {
  pointer-events: none;
  opacity: 0.35;
}

.ghost-red { fill: var(--red); }
.ghost-black { fill: var(--black); }

.win-banner {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 700;
}

/* --- landing page --- */

.landing main {
  max-width: 960px;
}

.landing .lead {
  text-align: center;
  color: var(--text-dim);
  margin: 1.5rem 0 2rem;
  font-size: 1.05rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  width: 100%;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.25rem 1.1rem;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms, background 120ms;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  background: #272b37;
}

.card.primary {
  border-color: var(--accent);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
}

.card-desc {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.4;
}

.join-card { cursor: default; }
.join-card:hover { transform: none; background: var(--bg-elev); border-color: rgba(255,255,255,0.06); }

.join-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.join-form input {
  flex: 1;
  background: #14171f;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.join-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.landing-foot {
  margin-top: 2rem;
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 0.85rem;
  width: 100%;
}

.landing-foot a {
  color: var(--text-dim);
  text-decoration: underline dotted;
}
.landing-foot a:hover { color: var(--accent); }

/* --- online room header bits --- */

.brand-link {
  color: var(--accent);
  text-decoration: none;
}
.brand-link:hover { text-decoration: underline; }

.room-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elev);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 0.9rem;
}

.room-label { color: var(--text-dim); }

.room-id {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", monospace;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 600;
}

.link-button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline dotted;
}
.link-button:hover { color: var(--accent); }

.role-strip {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.role-tag.role-red {
  color: var(--red);
  border-color: rgba(200,48,44,0.4);
}
.role-tag.role-black {
  color: #d8d8d8;
  border-color: rgba(255,255,255,0.25);
}

.peer-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.peer-tag.connected {
  color: #6dd47e;
  border-color: rgba(109,212,126,0.35);
}
.peer-tag.waiting { color: var(--text-dim); }
