/* 华容道 · DaoBox 家族（v0.1.0） */
:root {
  --bg: #f3ede1;
  --board: #a97b4f;
  --tile: #fdf6e9;
  --tile-num: #7c4a1e;
  --text: #4a3319;
  --muted: #9a8465;
  --accent: #b45309;
  --green: #16a34a;
  --red: #b91c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 顶栏 ---------- */
.topbar { background: #fff; border-bottom: 1px solid rgba(0,0,0,.06); }
.topbar-inner {
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { font-size: 17px; font-weight: 700; }
.topbar-tools { display: inline-flex; align-items: center; gap: 6px; }
.version-badge { font-size: 11px; color: #6b7280; background: #f3f4f6; border-radius: 999px; padding: 3px 7px; }
.refresh-btn { width: 26px; height: 26px; padding: 0; border: 1px solid #e5e7eb; border-radius: 999px; background: #fff; color: #6b7280; font-size: 15px; line-height: 1; cursor: pointer; }
.refresh-btn:hover { color: var(--accent); border-color: #fcd34d; }

/* ---------- 主体 ---------- */
.page { max-width: 560px; width: 100%; margin: 0 auto; padding: 14px 16px 32px; flex: 1; }

.mode-switch { display: flex; gap: 8px; margin-bottom: 10px; }
.mode-btn {
  flex: 1; border: 2px solid transparent; border-radius: 10px;
  padding: 10px 0; font-size: 15px; font-weight: 700;
  background: #e7ddc9; color: #8a7350; cursor: pointer;
}
.mode-btn.active { background: var(--accent); color: #fff; }

.hud { display: flex; gap: 10px; margin-bottom: 10px; }
.score-box { flex: 1; background: #ece3cf; border-radius: 10px; padding: 8px 12px; text-align: center; }
.score-label { font-size: 12px; color: var(--muted); }
.score-value { font-size: 22px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }

.sub-switch { display: flex; gap: 6px; margin-bottom: 12px; }
.sub-btn {
  flex: 1; border: 1px solid #d8c9a8; border-radius: 8px;
  padding: 7px 0; font-size: 13px; font-weight: 700;
  background: #fff; color: #8a7350; cursor: pointer;
}
.sub-btn.active { background: var(--tile-num); border-color: var(--tile-num); color: #fff; }
.hidden { display: none; }

/* ---------- 棋盘 ---------- */
.board {
  width: 100%; position: relative;
  background: var(--board); border-radius: 14px;
  border: 4px solid #7c4a1e;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  overflow: hidden;
}
.board.numeric { aspect-ratio: 1; }
.board.classic { aspect-ratio: 4 / 5; }

/* 数字块 */
.tile {
  position: absolute;
  background: var(--tile);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(22px, 7vw, 40px);
  font-weight: 800; color: var(--tile-num);
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
  cursor: pointer;
  transition: left .12s ease, top .12s ease;
  font-variant-numeric: tabular-nums;
}
.tile.moving { transition: none; }

/* 经典棋子 */
.piece {
  position: absolute;
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  transition: left .15s ease, top .15s ease;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.25);
  font-weight: 800;
}
.piece .p-name { font-size: clamp(16px, 4.6vw, 26px); letter-spacing: 2px; }
.piece .p-role { font-size: clamp(9px, 2.2vw, 12px); font-weight: 600; opacity: .75; }
.piece-caocao { background: #b91c1c; color: #fff; }
.piece-guanyu { background: #16a34a; color: #fff; }
.piece-general { background: #fdf6e9; color: #7c4a1e; }
.piece-soldier { background: #e7ddc9; color: #6b5637; font-size: 90%; }
.piece-caocao .p-role, .piece-guanyu .p-role { opacity: .85; }

/* 方向选择浮层 */
.dir-pad {
  position: absolute; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 30px); grid-auto-rows: 30px; gap: 2px;
  background: rgba(255,255,255,.95); border-radius: 10px; padding: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.dir-btn {
  border: none; border-radius: 6px; background: #e7ddc9; color: #4a3319;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.dir-btn[data-dir="up"] { grid-column: 2; grid-row: 1; }
.dir-btn[data-dir="left"] { grid-column: 1; grid-row: 2; }
.dir-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }
.dir-btn[data-dir="down"] { grid-column: 2; grid-row: 3; }

/* 胜利横幅 */
.win-banner {
  margin-top: 14px; background: #f0fdf4; border: 2px solid #86efac;
  border-radius: 12px; padding: 14px; text-align: center;
}
.win-banner.hidden { display: none; }
.win-emoji { font-size: 34px; }
.win-text { font-size: 18px; font-weight: 800; color: var(--green); margin-top: 2px; }
.win-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.btn-row { display: flex; justify-content: center; margin-top: 14px; }
.btn {
  border: none; border-radius: 8px;
  padding: 10px 26px; font-size: 14px; font-weight: 700;
  background: #e7ddc9; color: #6b5637; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }

/* ---------- 说明 ---------- */
.tips { margin-top: 20px; background: #fff; border-radius: 12px; padding: 14px 16px; }
.tips h2 { font-size: 15px; margin: 0 0 8px; }
.tips ul { margin: 0; padding-left: 18px; }
.tips li { font-size: 13px; line-height: 1.8; color: #6b5637; }
.tips b { color: var(--red); }

/* ---------- 时长锁 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-mask.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: 16px; padding: 24px 28px;
  max-width: 300px; width: calc(100% - 48px); text-align: center;
}
.win-emoji { font-size: 40px; }
.modal-card h3 { margin: 10px 0 6px; font-size: 17px; }
.modal-card p { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.modal-btns { display: flex; flex-direction: column; gap: 8px; }
.primary-btn {
  display: block; background: var(--accent); color: #fff; text-decoration: none;
  border-radius: 10px; padding: 10px 0; font-weight: 700; font-size: 15px;
}
.secondary-btn {
  background: #f3f4f6; color: #4b5563; border: none;
  border-radius: 10px; padding: 10px 0; font-weight: 700; font-size: 15px; cursor: pointer;
}

/* ---------- 页脚 ---------- */
.footer {
  max-width: 560px; width: 100%; margin: 0 auto;
  padding: 14px 16px 24px; text-align: center;
  font-size: 13px; color: var(--muted);
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }
.footer .dot { margin: 0 6px; }
#contact-email a { color: var(--muted); }
