:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --grid: #d9d4c7;
  --legal: #b9b2a1;
  --p1: #e0584b;
  --p2: #2f8f9d;
  --win: #f2b705;
  --border: #e3dfd4;
  --danger: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --panel: #1d2027;
    --text: #e8e6e3;
    --muted: #9aa0a8;
    --grid: #2b2f38;
    --legal: #4a505c;
    --p1: #ff6f61;
    --p2: #45b8c8;
    --win: #ffd23f;
    --border: #2b2f38;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
header.site .brand { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: 0.02em; text-decoration: none; }
header.site .who { margin-left: auto; color: var(--muted); }

button, .button {
  font: inherit;
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .button.primary { background: var(--p1); border-color: var(--p1); color: #fff; padding: 10px 20px; font-weight: 600; }

.page { max-width: 44rem; margin: 0 auto; padding: 24px 16px 48px; }
.page h1 { font-size: 32px; margin: 8px 0; }
.page h2 { font-size: 20px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }

.dot {
  display: inline-block; width: 0.75em; height: 0.75em; margin-right: 0.35em;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* Lobby */
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.choices label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--bg);
}
.choices label:has(input:checked) { border-color: var(--p2); box-shadow: 0 0 0 1px var(--p2); }
.games { list-style: none; margin: 0; padding: 0; }
.games li { border-top: 1px solid var(--border); }
.games li:first-child { border-top: 0; }
.games a { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 4px; text-decoration: none; }
.games a:hover { background: var(--bg); }
.games .state { margin-left: auto; color: var(--muted); }
.games .state.turn { color: var(--text); font-weight: 600; }

/* Room */
body.room { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.room #status { flex: 1; min-width: 12em; }
body.room .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
body.room main { position: relative; flex: 1; min-height: 0; }
body.room canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
body.room canvas.dragging { cursor: grabbing; }
body.room .message {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center;
}
