* { box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0; background: #f2f4f8; color: #222; }
header { background: #24344d; color: #fff; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
header h1 { font-size: 20px; margin: 0; }
nav#menu { display: flex; gap: 6px; flex-wrap: wrap; }
nav#menu a { color: #fff; text-decoration: none; padding: 6px 14px; border-radius: 6px; background: rgba(255,255,255,.12); }
nav#menu a:hover { background: rgba(255,255,255,.25); }
nav#menu a.nav-active {
  background: #ffb703 !important;
  color: #1b2430 !important;
  font-weight: bold;
  box-shadow: 0 0 0 2px rgba(255,255,255,.45) inset;
}
nav#menu a.nav-active::after { content: ' ●'; font-size: 11px; vertical-align: middle; }
main { max-width: 100%; margin: 10px auto; padding: 0 10px; }
.lobby { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.lobby-hero { display: flex; gap: 16px; align-items: center; }
.lobby-hero img { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; }
.lobby-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { padding: 8px 18px; border: 1px solid #24344d; background: #fff; color: #24344d; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn.primary { background: #24344d; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.hide { display: none; }
input { padding: 8px; border: 1px solid #ccc; border-radius: 6px; }
#room-status { margin-top: 10px; color: #2a7; }
.board { display: inline-block; background: #f6deac; border: 2px solid #b8860b; border-radius: 8px; touch-action: manipulation; }
.cell { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.chess-piece { width: 88%; height: 88%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; box-shadow: 0 2px 3px rgba(0,0,0,.3); font-size: 20px; }
.chess-piece.r { background: #fff; color: #c00; border: 2px solid #c00; }
.chess-piece.b { background: #efe6d5; color: #333; border: 2px solid #333; }
.cell.sel { background: #ffe9a0 !important; }
.cell.hint { background: #bfe3bf !important; border-radius: 8px; }
.cell.lastmv { box-shadow: inset 0 0 0 2px #f90; }
.toolbar { display: flex; flex-direction: column; gap: 10px; min-width: 120px; }
.toolbar .btn.wide { width: 100%; padding: 12px 0; font-size: 16px; }
.game-shell { min-height: 480px; }
.gomoku-board { background: #dea560; }
.gomoku-stone { width: 70%; height: 70%; border-radius: 50%; }
.gomoku-stone.b { background: radial-gradient(circle at 30% 30%, #666, #000); }
.gomoku-stone.w { background: radial-gradient(circle at 30% 30%, #fff, #ccc); }
.gok { margin: 10px 0; }
.gok span { margin-right: 10px; }
.badge { background: #eee; border-radius: 999px; padding: 2px 12px; font-size: 13px; }
.tag-r { background: #ffe4e4; color: #c00; }
.tag-b { background: #e0f0ff; color: #06c; }
.junqi-cell { cursor: pointer; }
.junqi-cell.facedown { color: #337; background: #6a89cc; color: #fff; }
.ludo-root { display: flex; gap: 20px; flex-wrap: wrap; }
.dice-btn { font-size: 40px; padding: 10px 24px; }
.statusline { margin: 10px 0; color: #555; }
.msg { color: #c00; margin: 8px 0; min-height: 20px; }
.logbox { background: #fff; padding: 12px; border-radius: 8px; max-height: 300px; overflow: auto; width: 260px; }

/* ===== 手机适配 ===== */
html, body { width: 100%; min-height: 100%; }
main { max-width: 100%; margin: 8px auto; padding: 0 8px; }
header { padding: 10px 12px; }
header h1 { font-size: 17px; }
.lobby { padding: 14px; border-radius: 10px; }
/* 游戏页：棋盘居上自适应，工具按钮横排在下方 */
.game-shell .lobby { padding: 10px; }
.game-shell > div { gap: 10px !important; }
#game-canvas { display: flex; justify-content: center; overflow-x: auto; }
#game-canvas > * { max-width: 100%; height: auto; }
/* 象棋 10x9 格用 vw 缩放 */
.chess-board .cell, #chess-b .cell { width: min(9vw, 44px); height: min(9vw, 44px); }
.chess-piece { font-size: min(4.4vw, 20px); }
/* 军棋 10x6 */
.junqi-cell { width: min(14vw, 56px) !important; height: min(14vw, 56px) !important; font-size: min(4.5vw, 16px) !important; }
/* 五子棋 SVG 自适应 */
#gok-board { width: 100% !important; height: auto !important; max-width: 92vw; display: block; }
/* 工具栏在手机上转为横排 */
.toolbar { flex-direction: row !important; min-width: 0 !important; width: 100%; }
.toolbar .btn.wide { width: auto; flex: 1; padding: 12px 8px; font-size: 15px; }
/* 状态栏可换行 */
.statusline { font-size: 14px; word-break: break-all; }
@media (hover: hover) and (pointer: fine) {
  /* 桌面还原固定尺寸 */
  .chess-board .cell, #chess-b .cell { width: 44px; height: 44px; }
  .junqi-cell { width: 56px !important; height: 56px !important; }
}

.chess-board .crow { display: flex; }
.chess-board .cell { margin: 0; }

.diff-box { display:flex; align-items:center; gap:8px; background:#fff; border:1px solid #ccc; border-radius:8px; padding:8px 12px; }
.diff-box label { font-size:14px; color:#24344d; font-weight:bold; }
.diff-box select { border:none; font-size:15px; outline:none; background:transparent; }

.ai-box { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 99; }
.ai-inner { background: #fff; padding: 18px; border-radius: 10px; display: flex; flex-direction: column; gap: 10px; width: min(90vw, 380px); }
.ai-inner input { padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.ai-hintbox { background: #fffbe6; border: 1px solid #f0d060; border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 15px; line-height: 1.6; }
.toolbar .btn.wide { white-space: nowrap; font-size: 14px; }

/* 浮动工具栏右侧 */
.float-toolbar { position: fixed; right: 10px; top: 50%; transform: translateY(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; background: rgba(255,255,255,.94); border: 1px solid #d0d0d0; border-radius: 12px; padding: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.14); width: 128px; }
.float-toolbar .diff-box { flex-direction: column; gap: 4px; padding: 6px 8px; }
.float-toolbar .diff-box select { font-size: 14px; }
.float-toolbar .btn.wide { padding: 8px 6px; font-size: 13px; }
.game-shell { width: 100%; max-width: 100% !important; }
@media (max-width: 560px) {
  .float-toolbar { width: 76px; padding: 6px; top: auto; bottom: 10px; transform: none; max-height: 76vh; overflow: auto; }
  .float-toolbar .btn.wide { font-size: 11px; padding: 6px 2px; }
  .float-toolbar .diff-box label { font-size: 11px; }
  .float-toolbar .diff-box select { font-size: 12px; }
  .game-shell { width: 100%; max-width: 100% !important; }
}

.game-head .btn { padding: 8px 14px; }
.game-head .diff-box { padding: 6px 10px; }
.game-shall { margin-bottom: 8px; }
.game-head { margin-bottom: 10px; }

.status-banner { background: linear-gradient(90deg, #24344d, #3b547a); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 16px; font-weight: bold; letter-spacing: 0.5px; box-shadow: 0 2px 6px rgba(36,52,77,.25); margin-bottom: 4px; text-align: center; }
.status-banner:empty::before { content: '…'; opacity: .4; }

.btn.start-big { display: block; width: min(92vw, 420px); margin: 18px auto 8px; padding: 14px 0; font-size: 19px; font-weight: bold; letter-spacing: 1px; border: none; border-radius: 12px; background: linear-gradient(90deg, #1e6ef0, #3b82f6); color: #fff; box-shadow: 0 4px 14px rgba(30,110,240,.35); cursor: pointer; }
.btn.start-big:hover { filter: brightness(1.08); }
.btn.start-big:active { transform: scale(.98); }

.btn.start-two { display: block; width: min(92vw, 420px); margin: 12px auto 8px; padding: 13px 0; font-size: 17px; font-weight: bold; letter-spacing: 1px; border: none; border-radius: 12px; background: linear-gradient(90deg, #0ea56a, #22c98a); color: #fff; box-shadow: 0 4px 12px rgba(14,165,106,.3); cursor: pointer; }
.btn.start-two:hover { filter: brightness(1.08); }


/* 军棋竖版棋盘：按屏幕自适应（不超出视口高度） */
#junqi-b {
  width: auto !important;
  height: auto !important;
  max-width: min(100%, 400px) !important;
  max-height: calc(100vh - 258px) !important;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
#game-canvas { align-items: flex-start; }
@media (max-width: 560px) {
  .game-shell:has(#junqi-b) { max-width: 100% !important; }
  #junqi-b { max-height: calc(100vh - 286px) !important; }
  /* 手机上头部按钮单行横向滑动，省出竖向空间 */
  .game-head {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    width: 100%;
  }
  .game-head > * { flex: 0 0 auto; }
  .game-head .btn { padding: 6px 9px !important; font-size: 12px !important; white-space: nowrap; }
  .game-head select { font-size: 12px !important; }
  .game-head .diff-box { padding: 3px 6px !important; }
}


/* 大厅卡片保持居中限宽；游戏页满屏 100% */
#view > .lobby:not(.game-shell) { max-width: 1100px; margin: 0 auto; }
.game-shell { width: 100% !important; max-width: 100% !important; box-sizing: border-box; }
.game-shell > * { max-width: 100%; }


/* 手机上禁用下拉刷新，避免对局中误刷新 */
html, body { overscroll-behavior-y: contain; }


/* ===== 全站页脚：版权 / 友情链接 / 开源地址 ===== */
.site-footer {
  margin: 22px 0 0;
  padding: 18px 14px 26px;
  border-top: 1px solid rgba(127,140,160,.25);
  background: rgba(255,255,255,.45);
  text-align: center;
  color: #5b6b80;
  font-size: 13px;
  line-height: 1.9;
}
.site-footer a { color: #1e6ef0; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .sf-line { margin: 2px 0; }
.site-footer .sf-links { margin-top: 6px; }
.site-footer .sf-links-title { display: block; color: #43536b; font-weight: 600; margin-bottom: 6px; }
.site-footer .sf-links a {
  display: inline-block; margin: 3px 5px; padding: 4px 12px; white-space: nowrap;
  background: #eef4ff; border: 1px solid #d5e3fb; border-radius: 15px;
  color: #1e5fd0; font-weight: 600; transition: all .15s;
}
.site-footer .sf-links a:hover { background: #1e6ef0; border-color: #1e6ef0; color: #fff; text-decoration: none; }
.site-footer .sf-copy { color: #8a97a8; font-size: 12.5px; }
.site-footer .sf-oss { color: #8a97a8; font-size: 12.5px; }
.site-footer .sf-lic {
  display: inline-block; margin-left: 8px; padding: 0 7px;
  border: 1px solid #cfd8e3; border-radius: 5px; font-size: 12px; color: #7b8797;
}
@media (max-width: 560px) {
  .site-footer { font-size: 12.5px; padding: 14px 10px 22px; }
  .site-footer .sf-links a { margin: 0 6px; }
}


/* 主推推广项：呼吸式微光（只在主推项上，避免整页闪烁） */
@keyframes sfTitleGlow {
  from { text-shadow: 0 0 0 rgba(255,140,0,0); }
  to   { text-shadow: 0 0 12px rgba(255,142,0,.75), 0 0 3px rgba(255,190,60,.95); }
}
@keyframes sfHotGlow {
  from { box-shadow: 0 0 0 rgba(255,140,0,0); }
  to   { box-shadow: 0 0 11px rgba(255,140,0,.6), 0 0 2px rgba(255,180,60,.8); }
}
@keyframes sfShine {
  0%   { transform: translateX(-120%) skewX(-18deg); }
  100% { transform: translateX(240%)  skewX(-18deg); }
}
.site-footer .sf-links-title {
  color: #b35c00;
  animation: sfTitleGlow 1.9s ease-in-out infinite alternate;
}
.site-footer .sf-links a.hot {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fff4dc, #ffe2b8);
  border-color: #ffc766;
  color: #a85500;
  animation: sfHotGlow 1.9s ease-in-out infinite alternate;
}
.site-footer .sf-links a.hot::after {   /* 掠过式光泽 */
  content: '';
  position: absolute; top: 0; left: 0;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.85), rgba(255,255,255,0));
  animation: sfShine 3.6s ease-in-out infinite;
  pointer-events: none;
}
.site-footer .sf-links a.hot:hover {
  background: linear-gradient(135deg, #ff9a1f, #ff6a00);
  border-color: #ff6a00; color: #fff;
  animation: none;
  box-shadow: 0 0 14px rgba(255,120,0,.75);
}
@media (prefers-reduced-motion: reduce) {
  .site-footer .sf-links-title,
  .site-footer .sf-links a.hot,
  .site-footer .sf-links a.hot::after { animation: none !important; }
}
