:root {
  --bg: #f4efe6;
  --panel: #fffaf2;
  --ink: #31261c;
  --muted: #756453;
  --line: #7d6a57;
  --accent: #b36a2e;
  --whiteStone: #f7f7f3;
  --blackStone: #202020;
  --legal: rgba(58, 140, 92, 0.28);
  --selected: rgba(53, 100, 185, 0.28);
  --centre: rgba(230, 194, 120, 0.35);
  --corner: rgba(193, 111, 44, 0.18);
  --lastmove: rgba(201, 62, 62, 0.22);
  --danger: #a33b31;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}
.sidebar {
  padding: 20px;
  border-right: 1px solid #d8cab7;
  background: linear-gradient(180deg, #fffaf2 0%, #f7efdf 100%);
  overflow: auto;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 10px; font-size: 1rem; }
p, li { line-height: 1.42; }
.muted { color: var(--muted); }
.card {
  background: var(--panel);
  border: 1px solid #ddcfbe;
  border-radius: 16px;
  padding: 12px 14px;
  margin-top: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.04);
}
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.stat-row:last-child { border-bottom: 0; }
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
button {
  appearance: none;
  border: 1px solid #ccb79a;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { background: #faf4ea; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.board-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
  min-height: 78vh;
}
svg {
  width: min(92vw, 1100px);
  height: auto;
  max-height: 92vh;
  display: block;
}
.log-panel { padding: 0 18px 18px; }
.log {
  background: var(--panel);
  border: 1px solid #ddcfbe;
  border-radius: 16px;
  padding: 10px 12px;
  max-height: 250px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.warning {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 600;
}
.small { font-size: 0.92rem; }
.legend-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #746858;
  display: inline-block;
}
.dot.centre { background: var(--centre); }
.dot.corner { background: var(--corner); }
.dot.white { background: var(--whiteStone); }
.dot.black { background: var(--blackStone); }
.dot.legal { background: var(--legal); }
.dot.selected { background: var(--selected); }
.dot.lastmove { background: var(--lastmove); }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid #d8cab7; }
  .controls, .legend-list { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {

  #sidebar {
    font-size: 0.85rem;
  }

  #logContainer {
    max-height: 120px;
    overflow-y: auto;
  }

}


.stat-row-diagnostics strong {
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: normal;
  text-align: right;
  max-width: 14rem;
}


.status-guide {
  display: grid;
  gap: 8px;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-chip {
  width: 20px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid #8f7a64;
}
.guide-chip.token {
  background: linear-gradient(90deg, transparent 0%, transparent 25%, rgba(196, 110, 40, 0.24) 25%, rgba(196, 110, 40, 0.24) 75%, transparent 75%, transparent 100%);
  box-shadow: inset 0 0 0 2px rgba(176, 96, 26, 0.88);
}
.guide-chip.placement { background: rgba(126, 167, 131, 0.2); }
.guide-chip.centre {
  background: radial-gradient(circle, rgba(230, 194, 120, 0.42) 0%, rgba(230, 194, 120, 0.18) 70%, transparent 71%);
}
.dot.corner-token {
  background: transparent;
  box-shadow: inset 0 0 0 3px rgba(176, 96, 26, 0.88);
}
.dot.setup { background: rgba(126, 167, 131, 0.2); }

.log {
  line-height: 1.55;
}

.log .log-entry {
  display: block;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.log .log-entry:last-child {
  border-bottom: 0;
}
.log .log-entry.event {
  font-weight: 600;
}
.log .log-entry.metrics {
  color: #5f503f;
}
.log .metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px 12px;
}
.log .metric {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.03);
}
.log .metric-label {
  font-size: 0.75rem;
  color: var(--muted);
}
.log .metric-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}
