:root {
  --board-bg: #d9b26a;
  --board-line: #1a1a1a;
  --bg: #f0e8d8;
  --text: #222;
  --accent: #2a5b8a;
  --accent-hover: #1e4466;
}
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
}
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
h1 { margin: 0; font-size: 1.5rem; }
#status { color: #555; font-style: italic; }

.screen { display: block; }
.screen.hidden { display: none; }

/* Lobby / waiting */
.lobby-box {
  max-width: 480px;
  margin: 40px auto;
  padding: 28px 32px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.lobby-box h2 { margin-top: 0; }
.lobby-box h3 { margin: 0 0 8px 0; font-size: 0.95rem; color: #555; text-transform: uppercase; letter-spacing: 0.5px; }
.lobby-box .sub { color: #666; margin: 0 0 16px 0; }
.lobby-box label { display: block; margin-bottom: 16px; font-weight: 600; color: #444; }
.lobby-box input[type="text"],
.lobby-box input:not([type]) {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid #bbb;
  border-radius: 4px;
}
.lobby-box .section {
  margin: 18px 0;
  padding: 14px 0;
  border-top: 1px solid #eee;
}
.lobby-box .row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.lobby-box .row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: "Consolas", "Menlo", monospace;
}
.lobby-box .row button {
  flex-shrink: 0;
}
#lobby-msg {
  margin-top: 12px;
  color: #c33;
  min-height: 20px;
}
#room-code-display {
  margin: 20px 0;
  text-align: center;
}
#room-code {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin: 8px 0;
}

button {
  padding: 10px 18px;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: white;
  color: var(--accent);
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:not(:disabled):hover { background: var(--accent); color: white; }

/* Game */
#game main {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
#board-wrap {
  width: 540px;
  height: 540px;
  flex-shrink: 0;
}
#board {
  width: 100%;
  height: 100%;
  background: var(--board-bg);
  border: 2px solid var(--board-line);
}
#sidebar {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#color-label { font-size: 1.25rem; font-weight: 600; padding: 6px 10px; border-radius: 4px; background: #ddd; text-align: center; }
#opponent-label { color: #555; font-style: italic; text-align: center; }
#info { line-height: 1.6; }
#controls { display: flex; gap: 8px; flex-wrap: wrap; }
#timer {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 1.1rem;
  padding: 6px 10px;
  background: #fff3cd;
  border-left: 4px solid #d4a017;
  border-radius: 2px;
}
#timer.urgent { background: #f8d7da; border-color: #c33; color: #c33; }
#message {
  padding: 10px 12px;
  background: #fff3cd;
  border-left: 4px solid #d4a017;
  min-height: 20px;
  white-space: pre-wrap;
  font-size: 0.95rem;
}
#message.error { background: #f8d7da; border-color: #c33; }
#message.ok { background: #d4edda; border-color: #2e7d32; }
#rules { margin-top: 16px; color: #555; }
#rules ul { padding-left: 20px; line-height: 1.6; }

.line { stroke: var(--board-line); stroke-width: 1.2; }
.star { fill: var(--board-line); }
.hit { fill: transparent; cursor: default; }
.hit.live { cursor: pointer; }
.hit.live:hover { fill: rgba(0, 0, 0, 0.08); }
.stone { pointer-events: none; }
.stone.black { fill: #111; stroke: #000; stroke-width: 1; }
.stone.white { fill: #f8f8f8; stroke: #111; stroke-width: 1; }
.coord {
  fill: var(--board-line);
  font: 12px system-ui, sans-serif;
  text-anchor: middle;
  pointer-events: none;
}
