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

/* —— 主题（settings.js） —— */
#bgLayer { position: fixed; inset: 0; pointer-events: none; z-index: 0; background-size: cover; }
header, main { position: relative; z-index: 1; }
body.theme-lightblue  { background: radial-gradient(ellipse at 50% 30%, #c6dcf8 0%, #8fb4e6 60%, #7aa3da 100%); color: #1e2f4d; }
body.theme-lightgreen { background: radial-gradient(ellipse at 50% 30%, #cfe9cf 0%, #9ccba2 60%, #86bd8f 100%); color: #203a26; }
body.theme-darkblue   { background: radial-gradient(ellipse at 50% 30%, #24406e 0%, #15264a 60%, #0d1a35 100%); color: #eaf0ff; }
body.theme-darkgreen  { background: radial-gradient(ellipse at 50% 30%, #1e4a2e 0%, #143520 60%, #0c2416 100%); color: #e6f5e9; }
body.theme-brown      { background: radial-gradient(ellipse at 50% 30%, #7a5638 0%, #553a22 60%, #3e2a18 100%); color: #f5e8d8; }
body.theme-black      { background: radial-gradient(ellipse at 50% 30%, #2a2d34 0%, #171a1f 60%, #0b0c0f 100%); color: #dfe4ec; }
body.theme-white      { background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, #eef1f6 60%, #d8dfe9 100%); color: #22314f; }
body.theme-white button, body.theme-lightblue button, body.theme-lightgreen button { color: #fff; }

/* —— 桌面材质纹理尺寸 —— */
body.bg-grass #bgLayer   { background-size: 40px 40px; }
body.bg-stones #bgLayer  { background-size: 300px 300px; }
body.bg-blueclouds #bgLayer, body.bg-grayclouds #bgLayer { background-size: 140% 140%; }
body.bg-wood #bgLayer, body.bg-woodgrain #bgLayer { background-size: auto, auto; }
body.bg-bamboo #bgLayer { opacity: .5; }

/* —— 牌面开关 —— */
.tiles-contrast .tile { border: 2px solid #222; box-shadow: 2px 3px 0 #5f5233, 4px 6px 8px rgba(0,0,0,.55); }
.tiles-contrast .tile .face { text-shadow: 0 0 2px #fff; }
.tiles-dark .tile { background: linear-gradient(160deg, #34363c 0%, #232529 70%, #1b1d20 100%); border: 1px solid #7d838d; box-shadow: 2px 3px 0 #000, 4px 6px 8px rgba(0,0,0,.6); }
.tiles-dark .tile.up { background: linear-gradient(160deg, #3d4046 0%, #2b2d31 100%); }
.tiles-dark .tile .face { filter: brightness(1.9) saturate(1.5); }
.tiles-dark .tile.selected { background: linear-gradient(160deg, #5c5433 0%, #463f1f 100%); border-color: #ffd76a; }
.tiles-dark .tile.selected .face { filter: brightness(2.2) saturate(1.2); }

/* ============ 设置面板 ============ */
#settingsModal { position: fixed; inset: 0; background: rgba(5,10,25,.75); display: flex; align-items: center; justify-content: center; z-index: 100000; }
#setBox { background: #f8f1dd; color: #222; border-radius: 12px; padding: 18px 26px 22px; max-width: 700px; width: 92%; max-height: 88vh; overflow-y: auto; }
#setBox h2 { text-align: center; margin-bottom: 8px; font-size: 20px; }
#setBox h3 { margin: 14px 0 6px; font-size: 15px; border-bottom: 2px solid #222; padding-bottom: 3px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.set-grid label, .set-check { font-size: 14px; padding: 3px 0; cursor: pointer; }
.set-best { list-style: none; font-size: 14px; margin-bottom: 8px; }
.set-best li { padding: 2px 0; }
#setClose { display: block; margin: 16px auto 0; background: #3a5a96; }

/* ============ 顶栏 ============ */
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 { display: flex; flex-direction: column; align-items: center; overflow: hidden; padding: 8px; height: calc(100vh - 104px); min-height: 400px; flex: none; }
#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; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.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 .emj { font-size: 20px; font-weight: 400; }
.tile .face.blank { color: #9aa3ad !important; }
.tile .face svg.pip { display: block; }

/* —— 黑金皮肤（牌面矢量图沿用 classic，仅换底色与亮度）—— */
body.tileart-black .tile { background: linear-gradient(160deg, #2a2d33 0%, #191b1f 70%, #101214 100%); border-color: #565b63; box-shadow: 2px 3px 0 #000, 4px 6px 10px rgba(0,0,0,.6); }
body.tileart-black .tile.up { background: linear-gradient(160deg, #343841 0%, #202227 100%); }
body.tileart-black .tile .face { filter: brightness(1.75) saturate(1.3); }
body.tileart-black .tile.selected { background: linear-gradient(160deg, #4a4222 0%, #332d12 100%); border-color: #ffd76a; }

.tile.selected {
  background: linear-gradient(160deg, #fff8d8 0%, #f8e9a8 100%);
  border: 2px solid #333;
  transform: translateY(-9px) scale(1.07);
  box-shadow: 2px 3px 0 #9d8a55, 0 14px 22px rgba(0,0,0,.55);
  z-index: 99999 !important;
}
.tile.hinted {
  outline: 3px solid #ff3b3b; outline-offset: -1px;
  animation: pulse .55s ease-in-out infinite;
}
.tile.hinted.selected { outline: 3px solid #ff3b3b; }
@keyframes pulse {
  0%,100% { transform: translateY(0) scale(1); box-shadow: 2px 3px 0 #9d8a55, 4px 6px 8px rgba(0,0,0,.45); }
  50% { transform: translateY(-7px) scale(1.1); box-shadow: 2px 3px 0 #9d8a55, 0 14px 20px rgba(0,0,0,.55); }
}
.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; }

/* ============ SEO 内容区（页面下方，可滚动到） ============ */
.seo {
  max-width: 860px; margin: 0 auto; padding: 28px 22px 8px;
  color: #d7e2f7; line-height: 1.7; font-size: 15px;
}
.seo h2 { font-size: 19px; color: #fff; margin: 22px 0 10px; border-left: 4px solid #ffd76a; padding-left: 10px; }
.seo p, .seo li { color: #c6d3ee; }
.seo ol { padding-left: 22px; }
.seo li { margin: 6px 0; }
.seo b { color: #ffe39a; }
.seo details {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 10px 14px; margin: 8px 0; cursor: pointer;
}
.seo summary { font-weight: 600; color: #fff; outline: none; }
.seo details p { margin-top: 8px; }
.seo-foot { text-align: center; padding: 24px 16px 30px; font-size: 13px; color: #9fb0d0; }
.seo-foot a { color: #bcd0f5; }

/* —— 商品位 —— */
#shopBox:empty { display: none; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.shop-grid a {
  display: block; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; padding: 10px; text-decoration: none; color: #eaf0ff; font-size: 13px;
  transition: background .15s, transform .12s;
}
.shop-grid a:hover { background: rgba(255,255,255,.12); transform: translateY(-2px); }
.shop-grid img { width: 100%; border-radius: 6px; margin-bottom: 6px; aspect-ratio: 1/1; object-fit: cover; }
#adSlotBottom:empty { display: none; }

/* —— 棋盘模式下把 SEO 区收起，只在无操作/移动端自然滚动；桌面用折叠标题更清爽 —— */
@media (min-width: 900px) {
  .seo { padding-top: 10px; }
}

/* ============ 手机端小屏适配 ============ */
@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; }
}
