* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #17171a;
  --surface: #212126;
  --surface-2: #2b2b32;
  --line: #383840;
  --text: #ececf1;
  --muted: #9a9aa6;
  --accent: #d9a441;
  --danger: #e2574c;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding: 24px 20px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
}

/* ---------- 大厅 ---------- */

#lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}

.logo { margin-bottom: 4px; }

h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 1px;
}

.sub, .hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}

.hint { margin-top: 18px; font-size: 12px; opacity: .75; }

#lobby { max-width: 360px; margin: 0 auto; width: 100%; }

button {
  font-family: inherit;
  font-size: 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 13px 20px;
  cursor: pointer;
  transition: transform .06s ease, opacity .15s ease;
}
button:active { transform: scale(.97); opacity: .85; }

button.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #241a05;
  font-weight: 600;
  font-size: 16px;
}

button.ghost { background: transparent; }

.divider {
  width: 100%;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  gap: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.join-row { display: flex; gap: 10px; width: 100%; }

input {
  flex: 1;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 4px;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }

.tip {
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
  margin: 0;
}

/* ---------- 对局 ---------- */

#game { flex: 1; display: flex; flex-direction: column; gap: 12px; }

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.bar-left { display: flex; align-items: center; gap: 8px; }

.badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  letter-spacing: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 8px;
}

.stone-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 1px solid #555;
  display: inline-block;
}
.stone-dot.white { background: #f6f6f6; border-color: #bdbdbd; }

.status {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.status.turn { color: var(--accent); font-weight: 600; }

#btnLeave { padding: 7px 12px; font-size: 13px; }

.board-wrap { position: relative; width: 100%; }

#board {
  width: 100%;
  display: block;
  border-radius: 14px;
  touch-action: manipulation;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, .78);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }

.overlay-card {
  text-align: center;
  padding: 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  min-width: 200px;
}

.overlay-title { font-size: 22px; font-weight: 600; }
.overlay-text { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.actions { display: flex; gap: 10px; }
.actions button { flex: 1; }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  min-height: 10px;
}
.chat-log .msg {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 6px 11px;
  border-radius: 12px;
}
.chat-log .msg.self { align-self: flex-end; background: #3a3221; border-color: #5b4b23; }

/* ---------- toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .88);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 99;
}
.toast[hidden] { display: none; }
