:root {
  --bg: #0f1226;
  --bg2: #1a1f3c;
  --card: #ffffff;
  --ink: #1f2433;
  --muted: #8a90a6;
  --accent: #4f7cff;
  --accent2: #6c5ce7;
  --board: #e9c08a;
  --board-line: #9c6b35;
  --win: #ff5d73;
  --ok: #2ecc71;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 20% -10%, #2a3170 0%, transparent 60%),
              radial-gradient(1000px 700px at 110% 10%, #4b2a6b 0%, transparent 55%),
              var(--bg);
  min-height: 100vh;
}

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 18px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.topbar h1 {
  font-size: 22px;
  color: #fff;
  margin: 0;
  letter-spacing: .5px;
}
.badge {
  font-size: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.conn {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.15);
}
.conn.off { color: #ffb4b4; }
.conn.on { color: #b6ffce; }

.board-wrap {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  flex: 0 0 auto;
}
#board {
  display: block;
  width: 600px;
  height: 600px;
  max-width: 86vw;
  max-height: 86vw;
  border-radius: 10px;
  background: var(--board);
  cursor: pointer;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 14px;
  border-radius: 10px;
  background: rgba(15,18,38,.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay.hidden { display: none; }
.overlay-box {
  text-align: center;
  color: #fff;
  padding: 18px;
}
#overlayTitle { font-size: 24px; font-weight: 700; }
.overlay-box .sub { margin-top: 8px; color: #c9cee6; font-size: 14px; }

.side {
  flex: 1 1 260px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 14px 16px;
  color: #eef0fb;
}
.status-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.status {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.roles {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: #d7dbf0;
}
.role { display: flex; align-items: center; gap: 8px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-block;
}
.dot.black { background: #1f2433; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.dot.white { background: #f4f6ff; }

.log {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: 13px;
  color: #cfd4ee;
}
.log li { padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,.08); }

.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,.12);
  color: #fff;
  transition: transform .05s ease, background .2s ease;
}
.btn:hover { background: rgba(255,255,255,.2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,.25); }
.btn.hidden { display: none; }

.tip {
  margin-top: 22px;
  text-align: center;
  color: #9aa0c0;
  font-size: 13px;
}

@media (max-width: 720px) {
  .board-wrap { justify-content: center; }
  .side { width: 100%; }
}
