* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #1d2733 0%, #2b3a4d 55%, #1a2330 100%);
  min-height: 100vh;
  min-height: 100dvh;
  color: #e8edf4;
}

.btn, canvas, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

.view { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; }

/* ---------- 按钮 ---------- */
.btn {
  background: #3d4f63;
  color: #e8edf4;
  border: 1px solid #556b82;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #4a6076; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: #b23a2e; border-color: #c9503f; }
.btn.primary:hover { background: #c9503f; }
.btn.danger { background: #5a3230; border-color: #7a4540; }
.btn.danger:hover { background: #6f3d3a; }
.btn.big { width: 100%; padding: 12px; font-size: 16px; margin-top: 10px; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* ---------- 大厅 ---------- */
.lobby-card {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 16px;
  padding: 40px 44px;
  width: min(360px, calc(100vw - 32px));
  text-align: center;
  backdrop-filter: blur(10px);
}
.logo {
  width: 72px; height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fdf3d8, #edd39b);
  border: 3px solid #7a4a1f;
  color: #b03024;
  font-size: 26px; font-weight: 700;
  line-height: 66px;
  font-family: "KaiTi", "STKaiti", serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.lobby-card h1 { font-size: 22px; margin-bottom: 6px; }
.lobby-card .sub { font-size: 13px; color: #9fb0c3; margin-bottom: 24px; }
.divider {
  display: flex; align-items: center;
  margin: 22px 0 6px;
  color: #7f92a6; font-size: 12px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, .12);
}
.divider span { padding: 0 10px; }
#joinInput {
  width: 100%;
  padding: 11px 12px;
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid #556b82;
  background: rgba(0, 0, 0, .25);
  color: #fff;
  font-size: 18px;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  outline: none;
}
#joinInput:focus { border-color: #8aa2bd; }
.error { color: #ff8a80; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 对局 ---------- */
#game {
  flex-direction: column;
  justify-content: flex-start;
  padding: 16px;
}
header {
  width: 100%;
  max-width: 940px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.room-tag {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.room-tag b { font-size: 18px; letter-spacing: 3px; color: #ffd54a; }
.status { font-size: 15px; color: #cfd9e4; }

.main {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 940px;
  flex-wrap: wrap;
}
.board-wrap { flex: 0 1 auto; }
/*
 * 棋盘自适应：同时受三个宽度上限约束——
 * 设计原始尺寸 532px、视口宽度、视口高度折算（532/596 ≈ 0.8926 宽高比），
 * 保证 PC 缩小窗口或手机横屏时棋盘完整可见、不出滚动条。
 */
canvas {
  width: min(532px, calc(100vw - 32px), calc((100dvh - 150px) * 0.8926));
  height: auto;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  cursor: pointer;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

.panel {
  flex: 1 1 240px;
  max-width: 300px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  padding: 18px;
}
.side-info { font-size: 15px; margin-bottom: 8px; }
.turn-info { font-size: 14px; color: #ffd54a; margin-bottom: 16px; min-height: 20px; }
.actions { display: flex; gap: 8px; margin-bottom: 18px; }
.actions .btn { flex: 1; padding: 8px 4px; font-size: 13px; }
.moves-title {
  font-size: 13px; color: #9fb0c3;
  border-top: 1px solid rgba(255, 255, 255, .12);
  padding-top: 12px; margin-bottom: 8px;
}
#moveList {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.9;
  color: #cfd9e4;
}
#moveList li { padding: 0 4px; border-radius: 4px; }
#moveList li:nth-child(odd) { background: rgba(255, 255, 255, .04); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-card {
  background: #2b3a4d;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 14px;
  padding: 30px 36px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
}
.modal-card p { font-size: 16px; margin-bottom: 22px; line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .btn { min-width: 90px; }

/* ---------- Electron 桌面壳 ---------- */
body.xq-desktop { background: transparent; }
body.xq-desktop .view { background: transparent; padding-top: 36px; }

/* 通栏标题栏：贴窗口顶边，构成窗口的可见上边界 */
#desktopBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 12px;
  background: rgba(13, 19, 27, .92);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  font-size: 12px;
  -webkit-app-region: drag;   /* 整条默认可拖动移动窗口 */
  user-select: none;
}
#desktopBar .dbar-title {
  cursor: move;
  font-weight: 600;
  letter-spacing: 1px;
  color: #e8edf4;
}
#desktopBar .dbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  -webkit-app-region: no-drag;
}
#desktopBar input[type="range"] {
  width: 120px;
  accent-color: #b23a2e;
  cursor: pointer;
  margin: 0 4px;
}
#desktopBar #opacityVal {
  display: inline-block;
  min-width: 34px;
  text-align: right;
  color: #9fb0c3;
  font-variant-numeric: tabular-nums;
}
.dbar-btn {
  background: transparent;
  border: none;
  color: #cfd9e4;
  cursor: pointer;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 6px;
}
.dbar-btn:hover { background: rgba(255, 255, 255, .14); }
.dbar-btn.active { color: #ffd54a; }
.dbar-btn.close:hover { background: #b23a2e; color: #fff; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%; top: 24px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .8);
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 99;
  pointer-events: none;
}

/* 中屏（PC 小窗口 / 平板竖屏）：上下布局 */
@media (max-width: 760px) {
  #game { padding: 10px; }
  header { margin-bottom: 10px; }
  .status { font-size: 13px; }
  .main { flex-direction: column; align-items: center; }
  .panel { width: 100%; max-width: min(532px, calc(100vw - 32px)); }
}

/* 手机竖屏：进一步压缩非棋盘区域 */
@media (max-width: 480px) {
  .lobby-card { padding: 30px 22px; }
  .room-tag { font-size: 12px; padding: 6px 10px; gap: 6px; }
  .room-tag b { font-size: 15px; }
  .panel { padding: 12px; }
  .actions .btn { font-size: 12px; padding: 8px 2px; }
  #moveList { max-height: 160px; }
  .modal-card { min-width: 0; width: calc(100vw - 48px); max-width: 320px; padding: 24px 20px; }
}
