:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1b1f24;
  --muted: #5d6670;
  --line: #e2ded5;
  --accent: #2f5d8a;
  --accent-ink: #ffffff;
  --accent-soft: #e4edf6;
  --board: #e9d9b4;
  --board-line: #a8895a;
  --dark-stone: #1f2328;
  --light-stone: #fbfaf6;
  --win: #2e7d4f;
  --lose: #a33a2b;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519;
    --surface: #1a1f25;
    --ink: #e7eaee;
    --muted: #9aa4ae;
    --line: #2b323a;
    --accent: #79a9d8;
    --accent-ink: #0c1117;
    --accent-soft: #1d2a38;
    --board: #7d6a48;
    --board-line: #4a3c25;
    --win: #6cc28f;
    --lose: #e07b6a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121519; --surface: #1a1f25; --ink: #e7eaee; --muted: #9aa4ae; --line: #2b323a;
  --accent: #79a9d8; --accent-ink: #0c1117; --accent-soft: #1d2a38; --board: #7d6a48; --board-line: #4a3c25;
  --win: #6cc28f; --lose: #e07b6a; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--line); background: var(--surface); }
header.top .wrap { display: flex; align-items: center; gap: 18px; height: 56px; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
nav.main { display: flex; gap: 14px; margin-left: auto; font-size: 15px; }
nav.main a { color: var(--muted); text-decoration: none; }
nav.main a:hover, nav.main a.on { color: var(--ink); }
#me { font-size: 14px; color: var(--muted); }
main { padding: 24px 0 48px; }
h1 { font-size: 30px; line-height: 1.2; margin: 8px 0 10px; }
h2 { font-size: 21px; margin: 28px 0 10px; }
.lead { font-size: 18px; color: var(--muted); max-width: 640px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
.btn-small { padding: 6px 12px; font-size: 14px; }
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin-top: 0; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input[type=text] { font: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 200px; }
table { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 14px; color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tabs button { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.play { display: grid; grid-template-columns: minmax(0, 560px) minmax(220px, 1fr); gap: 20px; align-items: start; }
.board svg { width: 100%; height: auto; display: block; border-radius: var(--radius); touch-action: manipulation; }
.board .cell { cursor: pointer; }
.board .cell:hover { fill: rgba(0, 0, 0, .06); }
.side .player { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.side .player.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.side .who { display: flex; align-items: center; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid #0003; }
.dot.dark { background: var(--dark-stone); }
.dot.light { background: var(--light-stone); }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; }
.clock.low { color: var(--lose); }
#status { margin: 10px 0; min-height: 1.5em; }
.win { color: var(--win); font-weight: 700; }
.lose { color: var(--lose); font-weight: 700; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.prose { max-width: 720px; }
.prose li { margin: 4px 0; }
footer { border-top: 1px solid var(--line); padding: 18px 0 30px; font-size: 14px; color: var(--muted); }
footer a { color: var(--muted); }
.hidden { display: none !important; }
@media (max-width: 760px) {
  .play { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
  nav.main { gap: 10px; font-size: 14px; }
  #me { display: none; }
}
