/* ============================================================
   合成大DK —— 样式表（手机端优先，桌面端媒体查询增强）
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: radial-gradient(circle at 30% 15%, #31406e 0%, #1b2340 55%, #141a33 100%);
  color: #ffffff;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 整体布局 ---------- */
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
}
#leftCol { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* ---------- 手机顶部栏：分数 / 最高 / 奖杯 / 音效 / 重开 ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: min(100vw, calc((100vh - 64px) * 9 / 16));
  width: min(100vw, calc((100dvh - 64px) * 9 / 16));
  height: 46px;
  padding: 0 4px;
}
.tb-stat {
  flex: 1;
  min-width: 56px;
  max-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 5px 6px;
}
.tb-label { font-size: 11px; color: #aeb9d8; }
.tb-value { font-size: 17px; font-weight: 700; color: #ffd166; }
.tb-btn {
  width: 36px;
  height: 36px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
  font-size: 17px;
  line-height: 1;
  transition: transform 0.1s ease, background 0.15s ease;
}
.tb-btn:active { transform: scale(0.88); background: rgba(255, 255, 255, 0.22); }
.tb-btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- 游戏操作区（9:16） ---------- */
#gameArea {
  position: relative;
  width: min(100vw, calc((100vh - 64px) * 9 / 16));
  width: min(100vw, calc((100dvh - 64px) * 9 / 16));
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  overflow: hidden;
  background: #fff8ec;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.14);
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

/* ---------- 游戏结束面板 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: rgba(24, 18, 48, 0.86);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.go-title {
  font-size: 34px;
  font-weight: 900;
  color: #ffd166;
  letter-spacing: 2px;
  text-shadow: 0 3px 12px rgba(255, 180, 60, 0.35);
}
.go-row { font-size: 18px; color: #e6e9f5; }
.go-num { font-size: 22px; font-weight: 800; color: #ff8fab; }
.go-btns { display: flex; gap: 14px; }
.go-author { margin-top: 6px; font-size: 13px; color: #8f97b5; }

/* ---------- 暂停覆盖提示 ---------- */
.pause-overlay {
  z-index: 4; /* 低于游戏结束面板(z-index:5)，且两者状态互斥 */
  background: rgba(24, 18, 48, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.pause-title {
  font-size: 40px;
  font-weight: 900;
  color: #ffd166;
  letter-spacing: 4px;
  text-shadow: 0 3px 14px rgba(255, 180, 60, 0.4);
}
.pause-sub { font-size: 14px; color: #d6dbee; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: none;
  border-radius: 26px;
  padding: 11px 24px;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.94); filter: brightness(1.12); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-orange { background: linear-gradient(135deg, #ffb347, #ff6f3c); }
.btn-teal   { background: linear-gradient(135deg, #2ec4b6, #1f9d8d); }
.btn-purple { background: linear-gradient(135deg, #7c6cff, #5a49d6); }
.btn-gray   { background: linear-gradient(135deg, #55608a, #3d4668); }
.btn-blue   { background: linear-gradient(135deg, #4ea8f5, #2b7fd4); }

/* ---------- 电脑端信息栏（桌面 ≥900px 显示） ---------- */
#sidebar { display: none; }
@media (min-width: 900px) {
  #topbar { display: none; }
  #app {
    flex-direction: row;
    gap: 40px;
    padding: 16px;
  }
  #gameArea {
    width: min(calc((100vh - 32px) * 9 / 16), 46vw);
    width: min(calc((100dvh - 32px) * 9 / 16), 46vw);
  }
  #sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 300px;
  }
}
.side-title {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(120deg, #ffd166, #ff8fab);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.side-rule { font-size: 14px; color: #aeb9d8; margin-top: -10px; }
.side-stats { display: flex; gap: 12px; }
.side-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
}
.side-stat-label { font-size: 13px; color: #aeb9d8; }
.side-stat-value { font-size: 26px; font-weight: 800; color: #ffd166; }
.side-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
}
.side-label { font-size: 14px; font-weight: 700; color: #cdd5ef; }
.next-img { width: 76px; height: 76px; }
#mergeTable { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
#mergeTable img { width: 38px; height: 38px; }
.side-note { font-size: 12px; color: #ffb3c1; }
.side-btns { display: flex; gap: 8px; }
.side-btns .btn { flex: 1; padding: 10px 4px; font-size: 13px; }
.side-tips { font-size: 12px; color: #8f97b5; line-height: 1.7; }

/* ---------- 排行榜弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(8, 7, 22, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-box {
  width: min(94vw, 430px);
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #252b4d;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 22px; font-weight: 800; color: #ffd166; }
.modal-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 15px;
}
.modal-close:active { background: rgba(255, 255, 255, 0.28); }
.lb-line {
  font-size: 15px;
  color: #dfe4f5;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#lbUsername {
  font-weight: 700;
  color: #ffd166;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score-me { font-weight: 800; color: #ff8fab; }
.btn-mini {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #cdd5ef;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
}
.btn-mini:active { background: rgba(255, 255, 255, 0.2); }
.lb-upload-row { display: flex; align-items: center; gap: 10px; }
.lb-msg { font-size: 12px; color: #9aa3c7; flex: 1; }
.lb-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.lb-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
}
.lb-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 700;
}
.lb-top1 .lb-rank { background: #ffd166; color: #4a3800; }
.lb-top2 .lb-rank { background: #d7dce8; color: #3a4258; }
.lb-top3 .lb-rank { background: #e8a06a; color: #4a2600; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: #ffd166; }
.lb-empty, .lb-loading { font-size: 13px; color: #9aa3c7; padding: 6px 2px; }
