* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* 作者 display 规则会压过浏览器默认的 hidden 隐藏，必须显式兜底 */
body {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #2c2c2c; color: #eee;
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: 16px;
}
h1 { font-size: 20px; letter-spacing: 8px; text-indent: 8px; text-align: center; color: #f0c060;
     padding-bottom: 10px; border-bottom: 1px solid #4a4a4a;
     display: flex; align-items: center; justify-content: center; gap: 9px; }
/* zl66 艺术字：回导航首页入口 */
a.zl-home {
  font-style: italic; font-weight: 900; font-size: 18px; line-height: 1;
  letter-spacing: normal; white-space: nowrap; text-decoration: none; padding: 0 1px;
  background: linear-gradient(135deg, #f0c060, #ffe3a3);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transition: filter .15s;
}
a.zl-home:hover { filter: brightness(1.25) drop-shadow(0 0 6px rgba(240, 192, 96, .5)); }
/* 各项按自然高度排列：面板因记录变长时不再把同行的棋盘拉伸出空白 */
.container { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; max-width: 100%; align-items: flex-start; }
.board-wrap {
  position: relative;
  background: #b58a4a; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
  padding: 12px;
  max-width: calc(100vw - 32px);
}
.board-frame { position: relative; display: inline-block; max-width: 100%; vertical-align: bottom; }
canvas { display: block; cursor: pointer; border-radius: 2px; max-width: 100%; height: auto;
  touch-action: manipulation; -webkit-touch-callout: none; }
/* 触屏二次确认按钮条：棋盘下方边框内的 确认/取消（绝对定位，不影响布局） */
.cfm-bar { position: absolute; left: 50%; top: calc(100% - 15px); transform: translate(-50%, -50%);
  display: flex; gap: 10px; z-index: 20;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cfm-bar[hidden] { display: none; }
.cfm-bar button { min-width: 64px; padding: 3px 14px; border-radius: 13px; font-size: 13px;
  font-weight: 600; border: 1px solid rgba(0,0,0,.35); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.cfm-bar #cfmOk { background: #6fae7f; color: #10331c; }
.cfm-bar #cfmOk:hover { background: #82c292; }
.cfm-bar #cfmNo { background: #5a5a5a; color: #eee; }
.cfm-bar #cfmNo:hover { background: #6d6d6d; }

/* 联机断线遮罩：盖住棋盘阻断误下，红边脉动卡片醒目提示重连进度；
   hint 变体=对方掉线横幅（只占顶部一条、不挡操作） */
.net-drop { position: absolute; inset: 0; z-index: 30; display: flex;
  align-items: center; justify-content: center; background: rgba(24, 14, 6, .62); }
.net-drop-card { text-align: center; max-width: 86%; padding: 16px 24px; border-radius: 10px;
  background: rgba(22, 13, 6, .92); border: 1px solid #d9534f;
  animation: net-drop-pulse 1.6s ease-in-out infinite; }
.net-drop-t { font-size: 18px; font-weight: 700; color: #ffb066; letter-spacing: 2px; }
.net-drop-s { margin-top: 8px; font-size: 13px; color: #ddd; line-height: 1.5; text-wrap: balance; }
@keyframes net-drop-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(217, 83, 79, .35); }
  50% { box-shadow: 0 0 26px rgba(217, 83, 79, .8); }
}
.net-drop.hint { top: 0; bottom: auto; align-items: flex-start; background: none; pointer-events: none; }
.net-drop.hint .net-drop-card { margin-top: 6px; padding: 7px 16px; animation: none;
  border-color: #c98a3d; box-shadow: 0 3px 10px rgba(0,0,0,.4); }
.net-drop.hint .net-drop-t { font-size: 13px; letter-spacing: 0; }
.net-drop.hint .net-drop-s { margin-top: 2px; font-size: 12px; }
.panel {
  background: #3a3a3a; border-radius: 8px; padding: 16px;
  width: 250px; max-width: 100%; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.panel h2 { font-size: 14px; color: #f0c060; }
.info { font-size: 14px; line-height: 1.8; }
.turn-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  vertical-align: -2px; margin-right: 6px; border: 1px solid #888;
}
.turn-dot.red { background: #b0341f; }
.turn-dot.black { background: #111; }
button {
  background: #f0c060; color: #222; border: none; border-radius: 6px;
  padding: 8px 12px; font-size: 14px; cursor: pointer; font-weight: 600;
}
button:hover { background: #ffd479; }
button.danger { background: #c96a5a; color: #fff; }
button.danger:hover { background: #e08476; }
button.secondary { background: #5a5a5a; color: #eee; }
button.secondary:hover { background: #6d6d6d; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.record-actions { margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.record-actions .secondary { padding: 7px 4px; font-size: 12px; width: 100%; }
.popover-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 300; }
.popover-mask[hidden] { display: none; }
.popover { background: #3a3a3a; border: 1px solid #555; border-radius: 10px;
  padding: 16px 18px; max-width: 320px; width: calc(100vw - 48px);
  box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.popover p { font-size: 14px; line-height: 1.6; margin-bottom: 14px; color: #eee; }
.popover-btns { justify-content: flex-end; }
/* 设置项：统一卡片（文字左、控件右），两列等宽 */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  font-size: 13px; color: #ccc; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: #2e2e2e; border: 1px solid #555; border-radius: 8px;
  padding: 5px 10px; min-height: 36px; cursor: pointer; user-select: none; }
.settings label:hover { border-color: #888; }
.settings select { padding: 3px 4px; font-size: 12px; max-width: 60%; }
.settings input[type="checkbox"] { accent-color: #f0c060; width: 15px; height: 15px;
  margin: 0; cursor: pointer; flex: none; }
select {
  background: #4a4a4a; color: #eee; border: 1px solid #666;
  border-radius: 6px; padding: 4px; font-size: 13px;
}
.msg { min-height: 20px; font-size: 13px; color: #ffd479; line-height: 1.5; text-wrap: balance; }
.captured { font-size: 13px; color: #aaa; text-wrap: balance; }

/* 联机对战面板 */
.net { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.net-status { color: #aaa; line-height: 1.5; min-height: 20px; text-wrap: balance; }
.net-status.ok { color: #8fd3a8; }
.net-status.warn { color: #ffb066; }
.net-room { display: flex; flex-direction: column; gap: 10px;
  background: #2e2e2e; border-radius: 6px; padding: 10px; }
.net-code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.net-code-label { font-size: 12px; color: #aaa; }
.net-code-actions { display: flex; gap: 6px; }
.net-code-actions .secondary { padding: 4px 10px; font-size: 12px; }
#netCodeShow { display: block; font-family: Consolas, monospace; font-size: 20px; font-weight: 700;
  color: #ffd479; letter-spacing: 4px; line-height: 1.3; word-break: break-all; }
.net-role { font-size: 12px; line-height: 1.5; color: #8fd3a8; min-height: 16px; text-wrap: balance; }
.net-room .btn-row button { flex: 1; padding: 7px; font-size: 13px; }
.net-wide { width: 100%; padding: 7px; font-size: 13px; }

/* 对局模式切换（本地 / 联机 button group）+ 联机入口 */
.mode-switch { display: flex; gap: 4px; background: #2e2e2e; border-radius: 8px; padding: 4px; }
.mode-btn { flex: 1; background: transparent; border: none; color: #bbb;
  border-radius: 6px; padding: 8px 4px; font-size: 13px; font-weight: 600; }
.mode-btn:hover { background: #3a3a3a; color: #eee; }
.mode-btn.active { background: #f0c060; color: #222; }
.mode-btn.active:hover { background: #ffd479; }
.net-entry { display: flex; flex-direction: column; gap: 8px; }
#homeEnter { width: 100%; padding: 9px; font-size: 14px; }
#homeEnter:disabled { opacity: .65; cursor: default; }   /* 连接中：文字已换、按钮压暗 */
#homeCode { width: 100%; background: #2e2e2e; color: #ffd479; border: 1px solid #555; border-radius: 8px;
  padding: 10px; font-size: 20px; font-family: Consolas, monospace; letter-spacing: 6px;
  text-indent: 6px; text-transform: uppercase; text-align: center; }
#homeCode::placeholder { letter-spacing: 2px; text-indent: 2px; font-size: 14px; color: #777; }
.home-addr { width: 100%; background: #2e2e2e; color: #eee; border: 1px solid #555; border-radius: 8px;
  padding: 8px 10px; font-size: 13px; color: #bbb; }
.home-hint { font-size: 12px; color: #888; line-height: 1.7; text-align: center; text-wrap: balance; }
.home-msg { min-height: 18px; font-size: 13px; color: #ffd479; text-align: center; text-wrap: balance; }
.home-msg.warn { color: #ffb066; }
.history {
  font-size: 12px; color: #aaa; max-height: 180px; overflow-y: auto;
  background: #2e2e2e; border-radius: 6px; padding: 8px; line-height: 1.8;
}
.hitem { cursor: pointer; padding: 0 4px; border-radius: 4px; }
.hitem:hover { background: #444; color: #fff; }
.hitem.cur { color: #ffd479; font-weight: 600; }
.hitem.live { margin-top: 4px; border-top: 1px dashed #555; padding-top: 4px; color: #8fd3a8; }
.hitem.cp { color: #9fd0ff; }
.review-bar { margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.rv-nav { display: flex; align-items: center; justify-content: center; gap: 6px; }
.rv-nav button { padding: 4px 10px; }
#rvPos { font-size: 13px; color: #ffd479; min-width: 72px; text-align: center; font-weight: 600; }
.review-bar .secondary { padding: 6px; font-size: 12px; width: 100%; }
.hitem.dim { cursor: default; color: #777; }
.hitem.dim:hover { background: none; color: #777; }
@media (max-width: 640px) {
  body { padding: 8px; }
  h1 { font-size: 17px; letter-spacing: 6px; }
  a.zl-home { font-size: 15px; }
  .panel { width: 100%; padding: 12px; }
}

/* 昵称行（房间卡片内）：昵称 + 改名按钮 */
.nick-row { display: flex; align-items: center; gap: 8px; }
.nick-label { font-size: 12px; color: #aaa; flex: none; }
.nick-val { font-size: 14px; font-weight: 600; color: #ffd479; word-break: break-all; flex: 1; }
.nick-btn { padding: 4px 10px; font-size: 12px; flex: none; }
.popover-input { width: 100%; background: #2e2e2e; color: #ffd479; border: 1px solid #555;
  border-radius: 8px; padding: 8px 10px; font-size: 14px; margin-bottom: 14px; }
.popover-input:focus { outline: none; border-color: #f0c060; }
