/* 三人中国象棋 —— 界面样式
   配色取自棋盘底图的米黄纸面（#fdf6e3）与木纹，保持实物棋盘的质感。 */

:root {
  --paper: #fdf6e3;
  --ink: #1f1b16;
  --ink-soft: #6b6152;
  --line: #d9cdb4;
  --panel: #fffdf7;
  --bg: #2a2622;
  --bg-2: #211e1b;
  --wei: #b3261e;
  --shu: #1b5e20;
  --wu: #0d47a1;
  --accent: #f59e0b;
  --good: #2a9d8f;
  --bad: #c1121f;
  --radius: 12px;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: linear-gradient(160deg, var(--bg), var(--bg-2));
  color: #efe9dd;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; flex-direction: column; min-height: 100%; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--wei); color: #fff; font-weight: 800; font-size: 19px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .5px; }
.brand-text small { color: #b9ae9b; font-size: 11.5px; letter-spacing: 2px; }

.room { display: flex; align-items: center; gap: 9px; }
.room-label { color: #b9ae9b; font-size: 12.5px; }
.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 19px; font-weight: 700; letter-spacing: 3px;
  color: var(--accent);
  background: rgba(245, 158, 11, .12);
  padding: 3px 11px; border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, .3);
}

.views { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.views-label { color: #b9ae9b; font-size: 12.5px; margin-right: 3px; }
.view-btn {
  width: 32px; height: 30px; border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, .07); color: #e6ddcd;
  border: 1px solid rgba(255, 255, 255, .13);
  font-size: 14px; font-family: inherit; transition: .15s;
}
.view-btn:hover { background: rgba(255, 255, 255, .14); }
.view-btn.active {
  background: var(--accent); color: #2a2000; border-color: var(--accent); font-weight: 700;
}

.conn { font-size: 12.5px; padding: 4px 10px; border-radius: 20px; }
.conn.ok { color: #8fd6a8; background: rgba(60, 180, 110, .13); }
.conn.bad { color: #ffb3b3; background: rgba(200, 60, 60, .16); }

/* ---------------- 主体 ---------------- */
.main {
  flex: 1; display: flex; gap: 18px; padding: 16px 18px; align-items: flex-start;
}
.board-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.banner {
  padding: 9px 14px; border-radius: 10px; font-size: 14.5px; font-weight: 600;
  background: rgba(255, 255, 255, .08); color: #ded4c2;
  border-left: 4px solid #7c7364; transition: .2s;
}
.banner.kind-turn { background: rgba(42, 157, 143, .16); color: #9fe6da; border-left-color: var(--good); }
.banner.kind-check { background: rgba(193, 18, 31, .18); color: #ffb0b0; border-left-color: var(--bad); }
.banner.kind-win { background: rgba(245, 158, 11, .18); color: #ffd98a; border-left-color: var(--accent); }
.banner.kind-lose, .banner.kind-over { background: rgba(120, 120, 130, .16); color: #cfc7ba; border-left-color: #8d8579; }

.board {
  width: 100%; max-width: min(74vh, 900px); margin: 0 auto;
  aspect-ratio: 1; border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow); overflow: hidden;
}
.board-svg { display: block; width: 100%; height: 100%; }

.piece { transition: opacity .15s; }
.piece:not([data-owner]) { }
/* 可交互提示：轮到自己时自己的子可点 */
.board.can-move .piece { cursor: default; }

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  padding: 8px 15px; border-radius: 9px; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 600;
  background: #3a352e; color: #f0e9dc; border: 1px solid rgba(255, 255, 255, .14);
  transition: .15s;
}
.btn:hover:not(:disabled) { background: #4a443b; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.ghost { background: transparent; color: #ded4c2; }
.btn.danger { background: rgba(193, 18, 31, .2); color: #ffc0c0; border-color: rgba(193, 18, 31, .45); }
.btn.danger:hover:not(:disabled) { background: rgba(193, 18, 31, .34); }
.seat-hint { color: #a99e8c; font-size: 12.5px; }

/* ---------------- 侧栏 ---------------- */
.side {
  width: 320px; flex: 0 0 320px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 130px);
}
.card {
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius); padding: 11px 12px;
  display: flex; flex-direction: column; min-height: 0;
}
.card.grow { flex: 1 1 auto; }
.card h3 {
  margin: 0 0 9px; font-size: 12.5px; font-weight: 700;
  letter-spacing: 1.5px; color: #a99e8c; text-transform: uppercase;
}

/* 名牌 */
.roster { display: flex; flex-direction: column; gap: 7px; }
.roster-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 9px;
  background: rgba(0, 0, 0, .2);
  border-left: 3px solid transparent;
}
.roster-row.is-turn { border-left-color: var(--accent); background: rgba(245, 158, 11, .11); }
.roster-row.is-out { opacity: .5; }
.roster-row.is-me { outline: 1px solid rgba(255, 255, 255, .16); }
.roster-chip {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px;
  display: grid; place-items: center;
  background: var(--paper); color: var(--ink);
  font-weight: 800; font-size: 14px;
}
.roster-info { flex: 1; min-width: 0; }
.roster-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-sub { font-size: 11.5px; color: #a99e8c; }
.roster-note { font-size: 11px; color: #8c8474; }
.roster-note.offline { color: #ffb3b3; }

/* 损失 */
.captured { display: flex; flex-direction: column; gap: 5px; }
.captured-line { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 22px; }
.captured-label { font-size: 11.5px; color: #a99e8c; width: 42px; flex: 0 0 42px; }
.captured-none { color: #6f685c; font-size: 12px; }
.captured-piece {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: rgba(253, 246, 227, .9);
}
.captured-piece.p-wei { color: var(--wei); }
.captured-piece.p-shu { color: var(--shu); }
.captured-piece.p-wu { color: var(--wu); }

/* 滚动区 */
.scroll { overflow-y: auto; min-height: 60px; flex: 1 1 auto; scrollbar-width: thin; }
.scroll::-webkit-scrollbar { width: 7px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 4px; }

/* 行棋记录 */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.history-empty { color: #6f685c; font-size: 12.5px; }
.history-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; padding: 3px 6px; border-radius: 6px;
  background: rgba(0, 0, 0, .16);
}
.history-no { color: #7d7566; font-family: ui-monospace, monospace; font-size: 11px; min-width: 18px; }
.history-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item.h-wei .history-text { color: #ffb3ac; }
.history-item.h-shu .history-text { color: #a7e0a9; }
.history-item.h-wu .history-text { color: #a8c6ff; }
.history-badge {
  font-size: 10.5px; padding: 1px 6px; border-radius: 20px;
  background: rgba(245, 158, 11, .25); color: #ffd98a;
}
.history-badge.out { background: rgba(193, 18, 31, .3); color: #ffb3b3; }

/* 聊天 */
.chat { display: flex; flex-direction: column; gap: 4px; padding-right: 3px; }
.chat-line { font-size: 13px; line-height: 1.45; }
.chat-who { font-weight: 700; margin-right: 6px; color: #cfc7ba; }
.chat-who.s-0 { color: #ff9b93; }
.chat-who.s-1 { color: #93d996; }
.chat-who.s-2 { color: #96b8ff; }
.chat-text { color: #e2dad0; word-break: break-word; }
.chat-form { display: flex; gap: 6px; margin-top: 9px; }
.chat-form input {
  flex: 1; min-width: 0; padding: 7px 10px; border-radius: 8px;
  background: rgba(0, 0, 0, .3); color: #f0e9dc;
  border: 1px solid rgba(255, 255, 255, .13); font-family: inherit; font-size: 13px;
}
.chat-form input::placeholder { color: #7d7566; }

/* 页脚 */
.foot {
  padding: 8px 18px 14px; color: #8c8474; font-size: 12px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.foot-sep { opacity: .5; }

/* 浮动提示 */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 18px);
  background: rgba(20, 18, 16, .94); color: #f5efe4;
  padding: 11px 20px; border-radius: 11px; font-size: 14px; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .13);
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .main { flex-direction: column; }
  .side { width: 100%; flex: 1 1 auto; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .side .card { flex: 1 1 260px; }
  .board { max-width: min(88vw, 720px); }
}
@media (max-width: 620px) {
  .topbar { gap: 12px; padding: 9px 12px; }
  .main { padding: 12px; gap: 12px; }
  .views { margin-left: 0; }
  .room-code { font-size: 17px; letter-spacing: 2px; }
  .side { flex-direction: column; }
  .foot { display: none; }
}
