/* css/puzzle.css — 拼图小游戏（独立页，入口：梦想小屋客厅鱼缸热点） */

.puzzle-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  flex-direction: column;
  background: linear-gradient(160deg, #1f2a44 0%, #2b3a5e 60%, #34487a 100%);
  color: #fff;
  -webkit-overflow-scrolling: touch;
  touch-action: none;             /* 阻止触摸滚动/缩放手势接管拼图拖拽 */
  overscroll-behavior: none;
}

/* 顶栏 */
.puzzle-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  flex-shrink: 0;
}
.puzzle-back {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.puzzle-back:hover { background: rgba(255,255,255,0.22); }
.puzzle-title {
  margin: 0; font-size: 18px; font-weight: 600; flex: 0 0 auto;
}
.puzzle-header-spacer { flex: 1; }
.puzzle-timer {
  font-variant-numeric: tabular-nums;
  font-size: 16px; font-weight: 600;
  background: rgba(0,0,0,0.25); padding: 4px 10px; border-radius: 12px;
}

/* 列表 */
.puzzle-list {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  padding: 16px;
  align-content: start;
}
.puzzle-card {
  background: rgba(255,255,255,0.08);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.puzzle-card:hover { transform: translateY(-3px); background: rgba(255,255,255,0.14); }
.puzzle-card-thumb {
  width: 100%; aspect-ratio: 1 / 1; overflow: hidden; background: rgba(0,0,0,0.2);
}
.puzzle-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.puzzle-card-meta { padding: 10px 12px; }
.puzzle-card-name { font-size: 15px; font-weight: 600; }
.puzzle-card-diff { margin-top: 6px; display: flex; gap: 4px; }
.puzzle-card-best {
  display: block; margin-top: 6px;
  font-size: 12px; opacity: 0.75; font-variant-numeric: tabular-nums;
}
.puzzle-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
}
.puzzle-dot.on { background: #ffd166; }

/* 棋盘 */
.puzzle-board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.puzzle-board {
  display: grid;
  gap: 0;                         /* 全局分隔线取消：正确归位的块需要无缝融合 */
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  touch-action: none;             /* 棋盘内拖动不触发页面手势 */
}
.puzzle-tile {
  display: block;
  cursor: pointer;
  background: #2b3a5e;
  /* 未拼块用 inset 白边作为分隔线；相邻两块合起来约 1px，和原来 gap 视觉接近 */
  box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.85);
  touch-action: none;             /* 块级拖动不触发页面手势 */
}
.puzzle-tile.selected {
  outline: 3px solid #ffd166;
  outline-offset: -3px;
  z-index: 2;
  position: relative;
}
.puzzle-tile.dragging {
  position: relative;
  z-index: 30;
  opacity: 0.92;
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
  cursor: grabbing;
}
/* 已拼对归位的块：白边消失、与相邻拼对块自然融合，不可再选/再交换 */
.puzzle-tile.locked {
  box-shadow: none;
  cursor: default;
}

/* 加载 */
.puzzle-loading {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; opacity: 0.85;
}

/* 完成态 */
.puzzle-complete {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 22, 40, 0.82);
  backdrop-filter: blur(4px);
  z-index: 5;
}
.puzzle-complete-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 20px;
}
.puzzle-complete-img {
  width: min(70vw, 320px);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.puzzle-complete-time { font-size: 18px; font-weight: 600; }
.puzzle-complete-record { font-size: 15px; color: #ffd166; font-weight: 600; }
.puzzle-complete-actions { display: flex; gap: 12px; margin-top: 6px; }

/* 按钮 */
.puzzle-btn {
  border: none; border-radius: 22px;
  padding: 10px 22px;
  font-size: 14px; font-weight: 600;
  background: #ffd166; color: #1f2a44;
  cursor: pointer;
}
.puzzle-btn:hover { filter: brightness(1.05); }
.puzzle-btn.ghost { background: rgba(255,255,255,0.15); color: #fff; }

/* 鱼缸热点（沿用小屋热点透明层，仅定位用） */
.dh-fishtank-hotspot { cursor: pointer; }
