/* Go Arena - theme-aware, responsive. The board is a 9x9 CSS grid whose cells are
   the clickable intersections; grid lines are drawn per-cell so edges half-line to
   the outer stones. Stones are filled circles differentiated for both sides. */
:root {
  --bg: #14161b; --panel: #1d2027; --ink: #e7e3d8; --muted: #9aa3af;
  --board: #d9ad5f; --line: #5b421e; --edge: #2a2e37;
  --black: #171717; --black-edge: #000; --white: #f4f0e6; --white-edge: #b7ad90;
  --accent: #d7a94e; --last: #d1495b; --good: #57c07d; --bad: #ef6a7c;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#faf7f0; --panel:#ffffff; --ink:#20242c; --muted:#6b7280; --edge:#e6ddc9;
          --board:#e2b866; --accent:#b5852f; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.boot, .arena { padding: 16px; }
.boot { color: var(--muted); }

.topbar h1 { font-size: 1.35rem; margin: 0 0 12px; font-weight: 650; }
.topbar .sub { color: var(--muted); font-weight: 400; font-size: .95rem; }

.layout { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.board-wrap { position: relative; }

/* ---- board ---- */
.board {
  width: min(76vw, 520px); aspect-ratio: 1; display: grid;
  grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  background: var(--board); border-radius: 6px; padding: 3%;
  box-shadow: 0 8px 30px #0006; user-select: none; touch-action: manipulation;
}
.board.over { filter: saturate(.7) brightness(.92); }

.pt { position: relative; cursor: pointer; }
.hline { position: absolute; top: 50%; height: 1.5px; background: var(--line); transform: translateY(-50%); }
.vline { position: absolute; left: 50%; width: 1.5px; background: var(--line); transform: translateX(-50%); }
.star { position: absolute; top: 50%; left: 50%; width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); transform: translate(-50%, -50%); z-index: 1; }

.stone { position: absolute; top: 50%; left: 50%; width: 88%; height: 88%; border-radius: 50%;
  transform: translate(-50%, -50%); z-index: 2; display: flex; align-items: center; justify-content: center; }
.stone.b { background: radial-gradient(circle at 34% 30%, #555 0%, var(--black) 62%);
  box-shadow: 0 1px 2px #0008, inset 0 0 1px var(--black-edge); }
.stone.w { background: radial-gradient(circle at 34% 30%, #ffffff 0%, var(--white) 68%);
  box-shadow: 0 1px 2px #0007, inset 0 0 0 1px var(--white-edge); }

.lastmark { width: 34%; height: 34%; border-radius: 50%; }
.lastmark.onb { box-shadow: inset 0 0 0 2px var(--white); }
.lastmark.onw { box-shadow: inset 0 0 0 2px var(--last); }

.pt.illegal::after { content: ""; position: absolute; top: 50%; left: 50%; width: 60%; height: 60%;
  transform: translate(-50%, -50%); border-radius: 50%; box-shadow: inset 0 0 0 2px var(--bad); z-index: 3;
  animation: flash .5s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---- side panel ---- */
.panel { flex: 1 1 260px; min-width: 240px; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.status { background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  padding: 10px 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: 42px; }
.status.final { color: var(--accent); }
.spinner { width: 13px; height: 13px; border: 2px solid var(--muted); border-top-color: transparent;
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.scorewrap { display: flex; flex-direction: column; gap: 6px; }
.scorebar { height: 14px; border-radius: 99px; overflow: hidden; display: flex; border: 1px solid var(--edge); }
.sb.b { background: var(--black); } .sb.w { background: var(--white); }
.scorenums { display: flex; justify-content: space-between; align-items: center; font-size: .8rem;
  font-variant-numeric: tabular-nums; color: var(--muted); }
.scorenums .lead { font-weight: 700; color: var(--ink); }
.scorenums .tag { font-weight: 600; }

.caps { display: flex; flex-direction: column; gap: 4px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
.cap { display: flex; align-items: center; gap: 8px; }
.cap b { margin-left: auto; font-variant-numeric: tabular-nums; }
.cdot { width: 12px; height: 12px; border-radius: 50%; }
.cdot.b { background: var(--black); } .cdot.w { background: var(--white); border: 1px solid var(--white-edge); }

.controls { display: flex; flex-direction: column; gap: 8px; }
.ctl-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.controls button { background: var(--panel); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 7px; padding: 7px 11px; cursor: pointer; font-size: .9rem; flex: 1 1 auto; }
.controls button:hover:not(:disabled) { border-color: var(--accent); }
.controls button:disabled { opacity: .45; cursor: default; }
.controls label { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 6px; width: 100%; }
.controls select { background: var(--panel); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 6px; padding: 5px; flex: 1; }

.scoresheet { background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; overflow: hidden; }
.scoresheet-head { padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--edge);
  font-size: .85rem; color: var(--muted); }
.moves { max-height: 200px; overflow-y: auto; padding: 4px 0; }
.mrow { display: grid; grid-template-columns: 42px 1fr 1fr; padding: 3px 12px; font-variant-numeric: tabular-nums; font-size: .9rem; }
.mrow:nth-child(odd) { background: #ffffff06; }
.mrow.empty { display: block; color: var(--muted); font-size: .85rem; }
.mno { color: var(--muted); }

.engine-note { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.engine-note code { background: #ffffff10; padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: #b33; color: #fff; padding: 8px 12px; z-index: 100; }
#blazor-error-ui .reload, #blazor-error-ui .dismiss { color: #fff; margin-left: 8px; cursor: pointer; }

@media (max-width: 620px) {
  .layout { gap: 14px; } .board { width: 92vw; } .panel { max-width: none; }
}
