/* =========================================
   JIGSAW PUZZLE – FINAL STABLE CSS
   ========================================= */

/* ===== Wrapper tổng ===== */
.jfpuzzle-wrap{
  position: relative;
  width: 100%;
  background: #fff1e7;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* ===== Stage (khung chơi chính) ===== */
.jfpuzzle-stage{
  position: relative;
  height: min(85vh, 900px);   /* chỉnh độ cao khung chơi ở đây */
  min-height: 650px;          /* không cho co nhỏ */
  flex: 0 0 auto;
}

/* Puzzle container */
.jfpuzzle-wrap #forPuzzle{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--jfp-bg, #fff1e7);
  overflow: hidden;
}

/* ===== Menu trong game ===== */
.jfpuzzle-wrap #menu{
  position: absolute;
  top: 10px;
  left: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
  z-index: 1000;
}
.jfpuzzle-wrap #menu li{
  margin: 2px 0;
  padding: 4px 10px;
  border-radius: 6px;
  background: #ff750b;
  color: #fff;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}
.jfpuzzle-wrap #menu li:hover{
  background: #ffecdb;
  color: #000;
}

/* ===== Puzzle pieces ===== */
.jfpuzzle-wrap .polypiece{
  position: absolute;
  display: block;
  overflow: hidden;
}
.jfpuzzle-wrap .moving{
  transition: top 1s linear, left 1s linear;
}
.jfpuzzle-wrap .gameCanvas{
  display: none;
  position: absolute;
}

/* ===== Thanh điều khiển dưới ===== */
.jfpuzzle-bar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.08);
}

.jfpuzzle-btn{
  appearance: none;
  border: 1px solid rgba(0,0,0,.15);
  background: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.jfpuzzle-btn:hover{
  filter: brightness(.97);
}

.jfpuzzle-status{
  flex: 1 1 auto;
  text-align: center;
  font-size: 14px;
}

/* ===== Fullscreen ===== */
#jfpuzzle-stage:fullscreen,
#jfpuzzle-stage:-webkit-full-screen{
  background: #fff;
}

/* ===== Pause overlay ===== */
#jfpuzzle-stage.jfp-paused::after{
  content: "Paused";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(2px);
  z-index: 9990;
  pointer-events: none;
}

/* ===== Preview overlay (ảnh mờ bên dưới) ===== */
#forPuzzle{
  isolation: isolate;
}
#forPuzzle::before{
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--jfp-preview-url);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  z-index: 0;
}
.jfpuzzle-stage.jfp-preview-on #forPuzzle::before,
.jfpuzzle-stage.jfp-preview-temp #forPuzzle::before{
  opacity: 0.35;
}

#forPuzzle > *{
  z-index: 1;
}

/* ===== Leaderboard ===== */
.jfpuzzle-leaderboard{
  margin-top: 16px;
  padding: 12px;
  background: rgba(255,255,255,.65);
  border-radius: 14px;
}
.jfpuzzle-leaderboard h3{
  margin: 0 0 8px;
  font-size: 16px;
}
#jfpuzzle-top10{
  margin: 0;
  padding-left: 18px;
}
#jfpuzzle-top10 li{
  margin: 4px 0;
  font-size: 14px;
}

/* ===== Login hint ===== */
.jfpuzzle-login-hint{
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.06);
  font-size: 14px;
}
.jfpuzzle-login-buttons{
  margin-top: 8px;
}

/* ===== Modal hướng dẫn ===== */
.jfpuzzle-modal{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.45);
  z-index: 9999;
}
.jfpuzzle-modal__dialog{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.jfpuzzle-modal__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.jfpuzzle-modal__title{
  font-weight: 600;
}
.jfpuzzle-modal__body{
  padding: 12px 14px 16px;
  font-size: 14px;
  line-height: 1.45;
}
