/* =========================================
   JIGSAW PUZZLE – STABLE CSS (CLEAN)
   Goal:
   - Stage has fixed height (from inline --jfp-h or fallback)
   - forPuzzle fills stage (absolute)
   - Bar + leaderboard stay below (normal flow)
   - Modal overlays only inside wrap
   ========================================= */

/* ===== Main wrapper ===== */
.jfpuzzle-wrap{
  position: relative;
  width: 100%;
  background: var(--jfp-bg, #fff1e7);
  overflow: visible; /* allow leaderboard below */
}

/* ===== Stage (main game area) ===== */
/* Height prioritizes the inline --jfp-h value set by the shortcode, with min(85vh, 900px) as the fallback. */
.jfpuzzle-wrap .jfpuzzle-stage{
  position: relative;
  width: 100%;
  height: var(--jfp-h, min(85vh, 900px));
  min-height: 650px;
  overflow: hidden; /* keep pieces inside */
}

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

/* ===== 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;
}

/* ===== Bottom control bar (positioned below the stage in normal flow) ===== */
.jfpuzzle-wrap .jfpuzzle-bar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.08);
  position: relative;
  z-index: 5;
}

.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;
}

/* ===== Options next to Preview ===== */
.jfpuzzle-bar__opts{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px;
}
.jfpuzzle-opt{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,.10);
  background:#fff;
}
.jfpuzzle-opt__label{
  font-size:12px;
  font-weight:600;
  color: rgba(0,0,0,.70);
  white-space:nowrap;
}
.jfpuzzle-opt__select{
  appearance:none;
  border:0;
  background:transparent;
  font-size:13px;
  font-weight:600;
  padding:2px 4px;
  cursor:pointer;
  color:#111;
  outline:none;
}
.jfpuzzle-opt__select:focus{
  outline:2px solid rgba(74,144,226,.35);
  outline-offset:2px;
  border-radius:8px;
}


/* ===== Share dropdown next to Background ===== */
.jfpuzzle-share{
  position: relative;
  display: inline-flex;
  align-items: center;
}
.jfpuzzle-share__toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-weight:600;
}
.jfpuzzle-share__menu{
  position:absolute;
  right:0;
  bottom:calc(100% + 10px);
  min-width:210px;
  padding:8px;
  border-radius:14px;
  background:#fff;
  border:1px solid rgba(0,0,0,.12);
  box-shadow:0 14px 34px rgba(0,0,0,.18);
  z-index:10020;
}
.jfpuzzle-share__menu::after{
  content:"";
  position:absolute;
  right:18px;
  bottom:-7px;
  width:12px;
  height:12px;
  transform:rotate(45deg);
  background:#fff;
  border-right:1px solid rgba(0,0,0,.10);
  border-bottom:1px solid rgba(0,0,0,.10);
}
.jfpuzzle-share__item{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  border:0;
  background:transparent;
  color:#111;
  cursor:pointer;
  padding:9px 10px;
  border-radius:10px;
  font-size:14px;
  font-weight:600;
  text-align:left;
}
.jfpuzzle-share__item:hover,
.jfpuzzle-share__item:focus{
  background:rgba(0,0,0,.06);
  outline:none;
}
.jfpuzzle-share__ico{
  width:28px;
  height:28px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-size:15px;
  font-weight:800;
  line-height:1;
  flex:0 0 28px;
}
.jfpuzzle-share__item.is-facebook .jfpuzzle-share__ico{ background:#1877f2; }
.jfpuzzle-share__item.is-twitter .jfpuzzle-share__ico{ background:#111; }
.jfpuzzle-share__item.is-pinterest .jfpuzzle-share__ico{ background:#e60023; }
.jfpuzzle-share__item.is-email .jfpuzzle-share__ico{ background:#64748b; }
.jfpuzzle-share__item.is-embed .jfpuzzle-share__ico{ background:#555; font-size:12px; border-radius:7px; }
.jfpuzzle-share__item.is-copy .jfpuzzle-share__ico{ background:#16a34a; }

.jfpuzzle-share__embed{
  margin:8px 4px 2px;
  padding:10px;
  border-top:1px solid rgba(0,0,0,.10);
  background:#f8fafc;
  border-radius:12px;
}
.jfpuzzle-share__embed[hidden]{ display:none !important; }
.jfpuzzle-share__embed-title{
  font-size:13px;
  font-weight:700;
  color:#111;
  margin-bottom:7px;
}
.jfpuzzle-share__embed-code{
  width:100%;
  min-height:86px;
  resize:vertical;
  box-sizing:border-box;
  border:1px solid rgba(0,0,0,.16);
  border-radius:10px;
  background:#fff;
  color:#111;
  padding:8px;
  font:12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.jfpuzzle-share__embed-copy{
  width:100%;
  margin-top:8px;
  border:0;
  border-radius:10px;
  background:#111827;
  color:#fff;
  cursor:pointer;
  padding:9px 10px;
  font-size:13px;
  font-weight:700;
}
.jfpuzzle-share__embed-copy:hover,
.jfpuzzle-share__embed-copy:focus{
  background:#000;
  outline:none;
}

.jfpuzzle-share.is-copied .jfpuzzle-share__toggle{
  border-color:rgba(22,163,74,.55);
  box-shadow:0 0 0 3px rgba(22,163,74,.15);
}
@media (max-width:640px){
  .jfpuzzle-share{ position:static; }
  .jfpuzzle-share__menu{
    left:10px;
    right:10px;
    bottom:calc(100% + 8px);
    min-width:0;
  }
  .jfpuzzle-share__menu::after{ display:none; }
}

/* Mobile: stack controls nicely */
@media (max-width: 640px){
  .jfpuzzle-bar{
    justify-content:center;
  }
  .jfpuzzle-status{
    flex: 1 1 100%;
    order: 3;
    margin-top: 6px;
  }
}

/* ===== 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;
}

/* ===== Leaderboard (positioned below the control bar in normal flow) ===== */
.jfpuzzle-wrap .jfpuzzle-leaderboard{
  margin-top: 16px;
  padding: 12px;
  background: rgba(255,255,255,.65);
  border-radius: 14px;
  position: relative;
  z-index: 5;
}
.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;
}

/* ===== Instructions modal (covers only the wrapper) ===== */
.jfpuzzle-wrap .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;
}

/* ===== Preview box (clear image overlay, bottom-left) ===== */
.jfpuzzle-previewthumb{
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 9000;
  pointer-events: none; /* allow dragging pieces under it */
  padding: 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 10px 26px rgba(0,0,0,.14);
}
.jfpuzzle-previewthumb img{
  display:block;
  width: 440px;
  height: auto;
  max-width: 56vw;
  border-radius: 14px;
  object-fit: cover;
}
@media (max-width: 768px){
  .jfpuzzle-previewthumb{ left: 10px; bottom: 10px; padding: 6px; }
  .jfpuzzle-previewthumb img{ width: 340px; max-width: 90vw; border-radius: 12px; }
}

/* ===== Preview button ON/OFF icon ===== */
.jfpuzzle-btn--preview .ico-on{ display:none; }
.jfpuzzle-btn--preview .ico-off{ display:block; }
.jfpuzzle-btn--preview.is-on .ico-on{ display:block; }
.jfpuzzle-btn--preview.is-on .ico-off{ display:none; }

/* =======================================================
   LOGIN ICONS (Facebook / Google / User) – CLEAN & ALIGNED
   ======================================================= */

.jfpuzzle-login-buttons{
  display:flex;
  align-items:center;
  gap:12px;
  margin-top:10px;
}

.jfp-login-icon{
  width:44px;
  height:44px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(0,0,0,.15);
  background:#fff;
  transition: transform .15s ease, box-shadow .15s ease;
}

.jfp-login-icon svg{
  width:20px;
  height:20px;
  display:block;
  fill: currentColor; /* Use currentColor so brand colors can be applied easily. */
}

/* Facebook */
.jfp-login-icon.fb{
  background:#1877f2;
  color:#fff;
}

/* Google */
.jfp-login-icon.google{
  background:#fff;
  color:#ea4335;
}

/* User */
.jfp-login-icon.user{
  background:#111;
  color:#fff;
}

/* Hover */
.jfp-login-icon:hover{
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0,0,0,.18);
}
/* ===========================
   Leaderboard 2 columns
   Left: Top 10 list
   Right: CTA box
   =========================== */

.jfpuzzle-leaderboard-grid{
  display:flex;
  gap:18px;
  align-items:stretch;
}

/* Left column */
.jfpuzzle-leaderboard-left{
  flex: 1 1 60%;
  min-width: 260px;
}

/* Right column */
.jfpuzzle-leaderboard-right{
  flex: 0 0 520px;   /* Fixed desktop width. */
  max-width: 520px;
  display:flex;
}

/* CTA card */
.jfpuzzle-cta{
  width:100%;
  background:#fff;
  border-radius:16px;
  padding:22px 18px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  box-shadow: 0 10px 26px rgba(0,0,0,.06);
  border: 1px solid rgba(0,0,0,.06);
}

.jfpuzzle-cta__title{
  font-size:34px;
  font-weight:800;
  line-height:1.1;
  color:#111827;
  margin: 6px 0 16px;
}

.jfpuzzle-cta__btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 16px 26px;
  border-radius: 999px;
  text-decoration:none;
  font-weight:700;
  font-size:20px;
  background:#5b5bef; /* Matches the visual style of the reference image. */
  color:#fff;
  min-width: 320px;
  max-width: 100%;
  box-shadow: 0 10px 24px rgba(91,91,239,.25);
}

.jfpuzzle-cta__btn:hover{
  filter: brightness(.98);
  transform: translateY(-1px);
}
/* ===============================
   JIGSAW GAME – FULL WIDTH
   =============================== */

.jigsaw-fullwidth{
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);

  background: #ffffff;
  padding: 24px 0;
}

/* Main game area. */
.jigsaw-fullwidth #forPuzzle,
.jigsaw-fullwidth .game-area,
.jigsaw-fullwidth .puzzle-wrapper{
  width: 100%;
  max-width: none !important;
}

/* canvas / puzzle */
.jigsaw-fullwidth canvas{
  max-width: none !important;
}

/* Puzzle pieces spread toward both sides, matching the reference image. */
.jigsaw-fullwidth .polypiece{
  will-change: transform;
}

/* mobile */
@media (max-width: 768px){
  .jigsaw-fullwidth{
    padding: 12px 0;
  }
}

/* Responsive: stack */
@media (max-width: 900px){
  .jfpuzzle-leaderboard-grid{
    flex-direction:column;
  }
  .jfpuzzle-cta__title{
    font-size:28px;
  }
  .jfpuzzle-cta__btn{
    min-width: 0;
    width: 100%;
    font-size:18px;
  }
}


/* Next button hidden when no next puzzle */
#jfpuzzle-next[style*="display:none"]{ display:none !important; }

/* ===== FIX Share dropdown above puzzle pieces ===== */
.jfpuzzle-wrap .jfpuzzle-bar{
  z-index: 2147483000 !important;
  overflow: visible !important;
  isolation: isolate;
}
.jfpuzzle-share{
  z-index: 2147483001 !important;
}
.jfpuzzle-share__menu{
  z-index: 2147483002 !important;
  background: #ffffff !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  overflow: visible !important;
}
.jfpuzzle-share__menu[hidden]{
  display: none !important;
}
.jfpuzzle-share__item,
.jfpuzzle-share__item span,
.jfpuzzle-share__embed,
.jfpuzzle-share__embed *{
  position: relative;
  z-index: 1;
}

/* ===== Advanced embed generator ===== */
.jfpuzzle-share.is-embed-open .jfpuzzle-share__menu{
  width:min(520px, calc(100vw - 30px));
  min-width:min(520px, calc(100vw - 30px));
}
.jfpuzzle-share__embed{
  margin:8px 0 0;
  padding:12px;
}
.jfpuzzle-share__embed-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.jfpuzzle-share__embed-head .jfpuzzle-share__embed-title{ margin:0; }
.jfpuzzle-share__embed-close{
  border:0;
  background:transparent;
  font-size:24px;
  line-height:1;
  cursor:pointer;
  padding:0 4px;
  color:#475569;
}
.jfpuzzle-embed-tabs{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:6px;
  margin-bottom:10px;
}
.jfpuzzle-embed-tab{
  border:1px solid rgba(0,0,0,.13);
  background:#fff;
  border-radius:9px;
  padding:8px 7px;
  font-size:12px;
  font-weight:700;
  cursor:pointer;
}
.jfpuzzle-embed-tab.is-active{
  color:#fff;
  background:#111827;
  border-color:#111827;
}
.jfpuzzle-embed-settings{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:9px;
}
.jfpuzzle-embed-settings[hidden]{ display:none !important; }
.jfpuzzle-embed-settings label{
  display:flex;
  align-items:center;
  gap:7px;
  font-size:12px;
  font-weight:700;
  color:#334155;
}
.jfpuzzle-embed-settings input{
  width:100%;
  min-width:0;
  border:1px solid rgba(0,0,0,.16);
  border-radius:8px;
  padding:7px 8px;
  background:#fff;
  box-sizing:border-box;
}
.jfpuzzle-share__embed-help{
  margin:0 0 8px;
  font-size:12px;
  line-height:1.45;
  color:#64748b;
}
.jfpuzzle-share__embed-code{ min-height:112px; }
@media (max-width:640px){
  .jfpuzzle-share.is-embed-open .jfpuzzle-share__menu{
    width:auto;
    min-width:0;
  }
  .jfpuzzle-embed-settings{ grid-template-columns:1fr; }
}
