/* ============ 全局 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: radial-gradient(ellipse at 50% 30%, #24406e 0%, #15264a 60%, #0d1a35 100%);
  color: #eaf0ff;
  display: flex; flex-direction: column;
}

/* ============ 顶栏 ============ */
header { padding: 10px 16px 6px; }
.hd-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
h1 { font-size: 22px; letter-spacing: 1px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  cursor: pointer; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 14px;
  background: #3a5a96; color: #fff; transition: background .15s, transform .1s;
}
button:hover { background: #4a6fb5; }
button:active { transform: scale(.96); }
#status { margin-top: 6px; font-size: 13px; color: #a8bcdf; }
#status b { color: #ffd76a; }

/* ============ 棋盘 ============ */
main { flex: 1; display: flex; flex-direction: column; align-items: center; overflow: hidden; padding: 8px; }
#stage {
  width: 100%; flex: 1; display: flex; align-items: flex-start; justify-content: center;
  overflow: hidden; touch-action: none;      /* 手机端：禁浏览器默认手势，交给缩放/平移 */
}
body { overscroll-behavior: none; }          /* 禁下拉刷新回弹 */
#board { position: relative; transform-origin: top center; }

.tile {
  position: absolute; width: 34px; height: 46px; border-radius: 5px;
  background: linear-gradient(160deg, #fffdf4 0%, #f5ecd6 70%, #e8dcbf 100%);
  border: 1px solid #b9a877;
  box-shadow: 2px 3px 0 #9d8a55, 4px 6px 8px rgba(0,0,0,.45);
  cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .25s, transform .12s;
}
.tile .face { text-align: center; line-height: 1.05; font-weight: 700; }
.tile .face .t { display: block; font-size: 15px; }
.tile .face .b { display: block; font-size: 15px; }
.tile .face .big { display: block; font-size: 22px; }
.tile .face.blank { color: #9aa3ad !important; }

.tile.selected {
  background: #f8eabb; border: 2px solid #333;
  transform: scale(1.06); z-index: 99999 !important;
}
.tile.hinted { outline: 3px solid #ff3b3b; outline-offset: -1px; animation: pulse .5s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.tile.blocked { animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.tile.gone { opacity: 0; pointer-events: none; transform: scale(.6); }
.tile.up { background: linear-gradient(160deg, #ffffff 0%, #f8f0dc 70%, #eee2c4 100%); }

/* ============ 提示横幅 ============ */
#banner {
  margin: 6px auto; padding: 10px 18px; border-radius: 10px;
  background: #8c2f2f; font-size: 15px; text-align: center;
}
#banner button { margin-left: 10px; background: #fff; color: #8c2f2f; }

/* ============ 画牌型弹窗 ============ */
#drawBox {
  background: #1b2c52; border-radius: 14px; padding: 18px 22px;
  max-width: 760px; width: 94%; max-height: 92vh; overflow-y: auto;
}
#drawBox h2 { text-align: center; margin-bottom: 12px; font-size: 20px; }
.draw-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dtool, .draw-tools button { padding: 6px 10px; font-size: 13px; }
.dtool.active { outline: 2px solid #ffd76a; background: #4a6fb5; }
.dsep { flex: 1; }
#densSel {
  background: #10203f; color: #eaf0ff; border: 1px solid #3a5a96;
  border-radius: 8px; padding: 6px 8px; font-size: 13px;
}
#drawWrap { display: flex; justify-content: center; }
#drawCv {
  max-width: 100%; height: auto;
  border: 2px solid #31477a; border-radius: 8px;
  cursor: crosshair; touch-action: none;
  background: #101c3a;
}
#drawStat { text-align: center; margin-top: 8px; font-size: 14px; color: #a8bcdf; }
#drawStat b.good { color: #7ee2a0; }
#drawStat b.warn { color: #ffcf6a; }

/* ============ 弹窗 ============ */
#modal, #winMask {
  position: fixed; inset: 0; background: rgba(5,10,25,.75);
  display: flex; align-items: center; justify-content: center; z-index: 100000;
}
#modalBox {
  background: #1b2c52; border-radius: 14px; padding: 18px 22px;
  max-width: 720px; width: 92%; max-height: 88vh; overflow-y: auto;
}
#modalBox h2 { text-align: center; margin-bottom: 12px; font-size: 20px; }
#boardList {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px;
}
.boardItem {
  border: 2px solid #31477a; border-radius: 10px; padding: 8px; cursor: pointer;
  text-align: center; transition: border-color .15s, background .15s;
}
.boardItem:hover { background: #24396a; }
.boardItem.picked { border-color: #ffd76a; background: #24396a; }
.boardItem canvas { width: 100px; height: 62px; background: #101c3a; border-radius: 6px; }
.boardItem .bn { font-size: 13px; margin-top: 4px; }
.boardItem .bc { font-size: 11px; color: #8fa4c9; }
.boardItem .dadd {
  height: 62px; display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #6d86b8;
}
.boardItem:hover .dadd { color: #ffd76a; }

.modal-opts { margin-top: 14px; font-size: 13px; color: #b8c8e8; }
.modal-opts label { display: flex; align-items: center; gap: 6px; justify-content: center; }
.modal-opts input { accent-color: #ffd76a; }
.modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
#btnStart { background: #1f9d55; }
#btnStart:hover { background: #27b565; }
#btnCancel { background: #55607a; }
#btnCancel:hover { background: #6a769a; }
.tip { margin-top: 8px; color: #7f93ba; font-size: 12px; text-align: center; }

.win-box {
  background: #1b2c52; border-radius: 14px; padding: 30px 40px; text-align: center;
}
.win-box h2 { font-size: 26px; margin-bottom: 10px; }
.win-box p { color: #b8c8e8; margin-bottom: 16px; }
#btnWinNew { background: #1f9d55; font-size: 16px; padding: 10px 26px; }

.hidden { display: none !important; }

/* ============ 手机端小屏适配 ============ */
@media (max-width: 640px) {
  h1 { font-size: 17px; }
  header { padding: 6px 8px 4px; }
  button { padding: 6px 9px; font-size: 12px; border-radius: 6px; }
  #status { font-size: 11px; }
  #modalBox, #drawBox { padding: 12px 12px; width: 97%; }
  #modalBox h2, #drawBox h2 { font-size: 16px; }
  #boardList { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
  .boardItem canvas { width: 82px; height: 51px; }
  .draw-tools { gap: 5px; }
  .modal-opts label { align-items: flex-start; text-align: left; line-height: 1.5; }
  .tip { line-height: 1.5; }
}
