/* ============ 围棋对弈系统样式 ============ */
:root {
  --bg: #f5f1e8;
  --panel: #ffffff;
  --border: #e3dccb;
  --text: #3a342c;
  --text-dim: #8a8072;
  --accent: #8b5e34;
  --accent-light: #c8a24a;
  --danger: #c0392b;
  --board-wood: #dcb35c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- 菜单屏 ---------- */
.screen { min-height: 100vh; }

.menu-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.menu-header { text-align: center; margin-bottom: 28px; }
.menu-header h1 { font-size: 44px; letter-spacing: 12px; color: var(--accent); }
.menu-header .subtitle { color: var(--text-dim); margin-top: 8px; font-size: 14px; }

.nickname-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.nickname-row label { font-weight: 600; }
.nickname-row input {
  width: 180px; padding: 8px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel);
}
.nickname-row input#password { width: 120px; }
.nickname-row input:focus { outline: 2px solid var(--accent-light); border-color: transparent; }
.nickname-hint {
  text-align: center; color: var(--text-dim); font-size: 12px; margin-bottom: 28px;
}

.mode-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  margin-bottom: 36px;
}
.mode-cards.two-cards {
  grid-template-columns: repeat(2, 1fr);
  max-width: 760px; margin: 0 auto 36px;
}
.mode-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 22px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.mode-card .mode-icon { font-size: 30px; }
.mode-card h3 { font-size: 18px; }
.mode-card p { color: var(--text-dim); font-size: 13px; min-height: 38px; }
.mode-card .btn { margin-top: auto; }

.ai-options {
  background: var(--bg); border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; font-size: 13px;
}
.option-row { display: flex; align-items: center; gap: 10px; }
.option-row > span:first-child { font-weight: 600; color: var(--text-dim); }
.option-row label { cursor: pointer; }
#ai-level { flex: 1; accent-color: var(--accent); }
.level-label { min-width: 52px; text-align: right; color: var(--accent); font-weight: 600; }

.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1; padding: 8px 10px; font-size: 15px; text-transform: uppercase; letter-spacing: 2px;
  border: 1px solid var(--border); border-radius: 6px;
}

.room-list-section h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.room-list { display: flex; flex-direction: column; gap: 8px; }
.room-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; display: flex; align-items: center; gap: 14px; font-size: 14px;
}
.room-item .room-code { font-weight: 700; letter-spacing: 2px; color: var(--accent); }
.room-item .room-state { color: var(--text-dim); flex: 1; }
.empty-hint { color: var(--text-dim); text-align: center; padding: 12px; font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 18px; font-size: 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  transition: all .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent-light); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #6f4a26; }
.btn-danger { color: var(--danger); border-color: #e5b8b2; }
.btn-danger:hover:not(:disabled) { background: #fbeeec; }
.btn-small { padding: 4px 10px; font-size: 12px; }

/* ---------- 大厅屏 ---------- */
.lobby-container {
  max-width: 1080px; margin: 0 auto; padding: 40px 20px 60px;
}
.lobby-info {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 22px; font-size: 14px;
}
.lobby-actions { display: flex; gap: 8px; }

.bot-status {
  text-align: center; font-size: 13px; color: var(--text-dim);
  margin: 0 auto 14px; padding: 8px 16px; max-width: 640px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.bot-status.training { color: #1a7f37; border-color: #b7dfc2; background: #eef8f0; font-weight: 600; }

.tables-box {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
@media (max-width: 900px) {
  .tables-box { grid-template-columns: repeat(2, 1fr); }
}

.table-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.table-card .table-head {
  display: flex; align-items: center; justify-content: space-between;
}
.table-card .table-name { font-size: 16px; font-weight: 700; color: var(--accent); }
.table-state-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 9px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text-dim);
}
.table-state-badge.playing { color: #1a7f37; border-color: #b7dfc2; background: #eef8f0; }
.table-state-badge.finished { color: var(--danger); border-color: #e5b8b2; background: #fbeeec; }

.seat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 8px; background: var(--bg); font-size: 13px;
}
.seat-row .seat-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.seat-row .seat-occupant { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.seat-row .seat-occupant.taken { color: var(--text); font-weight: 600; }
.seat-btn { padding: 3px 12px; font-size: 12px; }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-dim);
}
.spectate-btn { padding: 3px 12px; font-size: 12px; }

.lobby-chat {
  max-width: 760px; margin: 26px auto 0;
}
.lobby-chat .chat-list { height: 130px; }

/* ---------- 对局屏 ---------- */
.game-container {
  max-width: 1280px; margin: 0 auto; padding: 18px;
  display: flex; gap: 18px; align-items: flex-start; justify-content: center;
}
.board-column { flex: 0 1 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.board-status {
  font-size: 15px; font-weight: 600; min-height: 22px; text-align: center; color: var(--accent);
}

#board-wrap {
  width: min(92vw, calc(100vh - 120px), 760px);
  aspect-ratio: 1;
}
#board-canvas { width: 100%; height: 100%; display: block; cursor: pointer; border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); }

.sidebar {
  width: 320px; flex: 0 0 320px; display: flex; flex-direction: column; gap: 12px;
}
@media (max-width: 1000px) {
  .game-container { flex-direction: column; align-items: center; }
  .sidebar { width: min(92vw, 560px); flex-basis: auto; }
  #board-wrap { width: 92vw; }
}

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.panel h4 { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

.info-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.badge {
  font-size: 12px; padding: 2px 10px; border-radius: 10px; background: var(--bg);
  border: 1px solid var(--border); color: var(--accent); font-weight: 600;
}
.room-id { font-weight: 700; letter-spacing: 2px; color: var(--accent); }

.turn-indicator {
  text-align: center; padding: 8px; border-radius: 8px; background: var(--bg);
  font-size: 15px; font-weight: 600; margin-bottom: 10px;
}
.turn-indicator .stone-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  vertical-align: middle; margin: 0 4px 2px 0;
}
.stone-dot.black { background: #1a1a1a; box-shadow: inset 0 2px 3px rgba(255,255,255,.35); }
.stone-dot.white { background: #fafafa; border: 1px solid #999; }
.stone-dot.unknown { background: #b8b2a6; }

.players { display: flex; flex-direction: column; gap: 4px; font-size: 14px; margin-bottom: 8px; }
.players .player-row { display: flex; align-items: center; gap: 8px; }
.players .captured { margin-left: auto; color: var(--text-dim); font-size: 12px; }
.player-row.current { font-weight: 700; }
.meta-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-dim); }
.ai-thinking { color: var(--accent); font-weight: 600; }

.actions-panel { display: flex; flex-wrap: wrap; gap: 8px; }
.actions-panel .btn { flex: 1; white-space: nowrap; }

.history-list {
  max-height: 180px; overflow-y: auto; display: grid;
  grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.history-item {
  padding: 4px 2px; text-align: center; font-size: 12px; border-radius: 4px;
  cursor: pointer; background: var(--bg); border: 1px solid transparent; user-select: none;
}
.history-item:hover { border-color: var(--accent-light); }
.history-item.reviewed { border-color: var(--accent); font-weight: 700; }
.history-item.black { color: #1a1a1a; }
.history-item.white { color: #666; }
.history-item .pass-mark { color: var(--text-dim); }

.chat-list {
  height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; margin-bottom: 8px; background: var(--bg); border-radius: 6px; padding: 8px;
}
.chat-msg .from { font-weight: 600; margin-right: 4px; }
.chat-msg.system { color: var(--text-dim); text-align: center; font-size: 12px; }
.chat-ts {
  color: var(--text-dim); text-align: center; font-size: 11px;
  opacity: .75; margin-top: 2px; user-select: none;
}
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input {
  flex: 1; padding: 7px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
}

/* ---------- 模态框 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content {
  background: var(--panel); border-radius: 14px; padding: 28px 32px;
  min-width: 320px; max-width: 92vw; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal-content.small { min-width: 280px; }
.modal-content h2 { font-size: 24px; margin-bottom: 10px; }
.modal-content h3 { font-size: 18px; margin-bottom: 10px; }
.gameover-reason { color: var(--text-dim); margin-bottom: 16px; font-size: 14px; }

.score-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 14px; }
.score-table th, .score-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.score-table th { color: var(--text-dim); font-weight: 600; }
.score-table .komi-row { color: var(--text-dim); font-size: 12px; }
.territory-toggle { display: block; margin-bottom: 16px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
  background: #3a342c; color: #fff; padding: 10px 22px; border-radius: 8px;
  font-size: 14px; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,.3);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; background: #c0392b; color: #fff;
  text-align: center; padding: 6px; font-size: 13px; z-index: 300;
}
