/* Jigsaw modal - all selectors are prefixed with jgz- to avoid clashing with the host site. */

html.jgz-lock, html.jgz-lock body { overflow: hidden; }

.jgz-overlay {
  position: fixed; inset: 0; z-index: 99999;
  box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 18, 24, 0.78);
  font: 14px/1.4 -apple-system, "Segoe UI", system-ui, sans-serif;
  color: #1f2328;
}
.jgz-overlay[hidden] { display: none; }

.jgz-modal {
  display: flex; flex-direction: column;
  /* Percentages of the fixed overlay = the visible area. Avoid vh: on mobile it ignores the URL bar. */
  width: min(1200px, 96%); height: min(820px, 94%);
  background: #f4f1ea; border-radius: 10px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.jgz-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 8px 12px; background: #2b3039; color: #fff;
}
.jgz-title { font-weight: 600; margin-right: auto; }
.jgz-field { display: flex; align-items: center; gap: 6px; }
.jgz-count {
  font: inherit; padding: 3px 6px; border-radius: 4px; border: 0; background: #fff; color: #1f2328;
}
.jgz-btn {
  font: inherit; cursor: pointer; padding: 5px 12px; border-radius: 4px;
  border: 1px solid #5a6270; background: #3a404b; color: #fff;
}
.jgz-btn:hover { background: #4a5260; }
.jgz-stat { color: #c9ced6; white-space: nowrap; }
.jgz-stat b { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.jgz-close {
  font: 24px/1 inherit; width: 32px; height: 32px; cursor: pointer;
  border: 0; border-radius: 4px; background: transparent; color: #fff;
}
.jgz-close:hover { background: #c0392b; }
.jgz-overlay button:focus-visible, .jgz-overlay select:focus-visible { outline: 2px solid #3b82d4; outline-offset: 2px; }

.jgz-stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background: #d9d3c5; touch-action: none; user-select: none; -webkit-user-select: none;
}
.jgz-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.jgz-board {
  position: absolute; box-sizing: border-box;
  background: #efeadd; border: 2px dashed rgba(0, 0, 0, 0.3);
}
.jgz-ghost {
  position: absolute; inset: 0; background-size: 100% 100%; opacity: 0.12;
}

.jgz-piece {
  position: absolute; left: 0; top: 0; cursor: grab; touch-action: none;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.45));
}
.jgz-piece.jgz-drag { cursor: grabbing; filter: drop-shadow(4px 8px 8px rgba(0, 0, 0, 0.5)); }
.jgz-piece.jgz-locked { cursor: default; pointer-events: none; filter: none; }

.jgz-thumb {
  position: absolute; right: 12px; bottom: 12px; z-index: 2000000;
  max-width: 28%; max-height: 40%; border: 3px solid #fff; border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); pointer-events: none;
}
.jgz-thumb[hidden] { display: none; }

.jgz-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #555; pointer-events: none;
}
.jgz-msg[hidden] { display: none; }

.jgz-win {
  position: absolute; inset: 0; z-index: 3000000;
  display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.35);
}
.jgz-win[hidden] { display: none; }
.jgz-win-card {
  background: #fff; padding: 22px 32px; border-radius: 10px; text-align: center;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4); max-width: 90%;
}
.jgz-win-card h2 { margin: 0 0 8px; font-size: 22px; }
.jgz-win-card p { margin: 0 0 14px; color: #57606a; }
.jgz-score-slot:empty { display: none; } /* reserved for a future scoreboard */
.jgz-score-slot { margin-bottom: 14px; }
.jgz-win-btns { display: flex; gap: 10px; justify-content: center; }
.jgz-win-card .jgz-btn { background: #3b82d4; border-color: #3b82d4; }
.jgz-win-card .jgz-btn:hover { background: #2f6db5; }

@media (max-width: 600px) {
  .jgz-modal { width: 100%; height: 100%; border-radius: 0; }
  .jgz-title { display: none; }
}
