:root {
  color-scheme: light;
  --bg: #f2f5f4;
  --panel: #ffffff;
  --text: #202124;
  --muted: #667085;
  --line: #d0d5dd;
  --board: #ffffff;
  --board-border: #e4e7ec;
  --accent: #116d6e;
  --danger: #b42318;
  --shadow: 0 10px 26px rgba(31, 41, 55, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
}

p {
  margin: 0;
}

#statusText,
.notice,
.meta span {
  color: var(--muted);
}

.connection {
  min-width: 92px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 700;
}

.connection.online {
  color: #067647;
}

.connection.offline {
  color: var(--danger);
}

.room-form,
.starter-form,
.ai-form,
.meta,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.room-form label,
.starter-form label,
.ai-form label {
  font-weight: 700;
}

.room-form input,
.starter-form select,
.ai-form select {
  width: min(360px, 100%);
  height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.starter-form select {
  width: 140px;
}

.ai-form select {
  width: 140px;
}

button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.meta div {
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.meta span,
.meta strong {
  display: block;
}

.meta strong {
  margin-top: 6px;
  font-size: 20px;
}

.board-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 14px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(280px, 1fr);
  align-items: start;
  gap: 18px;
}

.play-area {
  min-width: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  width: min(68vw, 380px);
  aspect-ratio: 1;
  padding: 8px;
  border: 3px solid var(--board-border);
  border-radius: 8px;
  background: var(--board);
  box-shadow: 0 10px 22px rgba(31, 41, 55, 0.1);
}

.cell {
  position: relative;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.cell:hover:not(:disabled) {
  background: rgba(17, 109, 110, 0.08);
}

.stone::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  box-shadow: inset -4px -5px 8px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(0, 0, 0, 0.25);
}

.stone.black::after {
  background: #111827;
}

.stone.white::after {
  background: #cfd4dc;
  border: 1px solid rgba(17, 24, 39, 0.28);
}

.last-move::before {
  content: "";
  position: absolute;
  inset: 28%;
  z-index: 1;
  border: 2px solid #f04438;
  border-radius: 50%;
  pointer-events: none;
}

.actions {
  justify-content: center;
}

.actions button:last-child {
  background: #344054;
}

.notice {
  min-height: 24px;
  text-align: center;
}

.notice.error {
  color: var(--danger);
}

.docs-panel {
  min-height: 500px;
  padding: 18px;
  border: 1px solid #d9e2e0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 249, 0.96)),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(17, 109, 110, 0.07) 32px);
  box-shadow: var(--shadow);
}

.docs-kicker {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.docs-panel h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

.docs-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.docs-panel dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.docs-panel dl div {
  min-height: 72px;
  padding: 10px;
  border: 1px solid #dbe5e3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.docs-panel dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.docs-panel dd {
  margin: 6px 0 0;
  font-weight: 800;
}

.docs-panel pre {
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #1f2933;
  color: #d7f8ed;
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 820px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .board {
    width: min(78vw, 380px);
  }

  .docs-panel {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100vw - 18px, 960px);
    padding-top: 12px;
  }

  .topbar,
  .room-form,
  .starter-form,
  .ai-form,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .connection {
    width: 100%;
  }

  .room-form input,
  .room-form button,
  .starter-form select,
  .ai-form select,
  .actions button {
    width: 100%;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .board {
    width: min(82vw, 330px);
    padding: 6px;
  }

  .docs-panel dl {
    grid-template-columns: 1fr;
  }
}
