/* slidepuzzle.app — playable sliding-puzzle widget styles.
   Self-contained, light "clean/Apple" aesthetic to match solver.css. */
.sg-root {
  --sg-accent: #007aff;
  --sg-ink: #1d1d1f;
  --sg-mute: rgba(60, 60, 67, 0.6);
  --sg-hair: rgba(60, 60, 67, 0.12);
  display: block;
  margin: 28px 0 34px;
}
.sg-mini { margin: 0; }

.sg-stage {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}
.sg-mini .sg-stage { max-width: 320px; }

.sg-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  touch-action: manipulation;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.sg-canvas:focus-visible { box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.45); }

/* HUD ------------------------------------------------------------------- */
.sg-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  max-width: 460px;
  margin: 14px auto 0;
}
.sg-mini .sg-hud { max-width: 320px; margin-top: 10px; }

.sg-stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--sg-ink);
  font-variant-numeric: tabular-nums;
}
.sg-sep { color: var(--sg-mute); }
.sg-moves { color: var(--sg-mute); }

.sg-controls { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.sg-btn {
  font-family: "Hanken Grotesk", -apple-system, "SF Pro Text", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--sg-accent);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.sg-btn:active { transform: scale(0.96); }
.sg-btn-ghost {
  color: var(--sg-ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--sg-hair);
}
.sg-btn-ghost[aria-pressed="true"] {
  background: #e9f2ff;
  border-color: var(--sg-accent);
  color: var(--sg-accent);
}

.sg-select {
  font-family: "Hanken Grotesk", -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--sg-ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--sg-hair);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

.sg-expand {
  font-family: "Hanken Grotesk", -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--sg-accent);
  text-decoration: none;
  white-space: nowrap;
}
.sg-expand:hover { text-decoration: underline; }

/* image picker ---------------------------------------------------------- */
.sg-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 460px;
  margin: 14px auto 0;
}
.sg-pick-item {
  width: 52px; height: 52px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.sg-pick-item:active { transform: scale(0.94); }
.sg-pick-item.is-active { border-color: var(--sg-accent); }

/* win overlay ----------------------------------------------------------- */
.sg-win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: rgba(242, 242, 247, 0.62);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sg-win.is-on { opacity: 1; pointer-events: auto; }
.sg-win-card {
  text-align: center;
  padding: 22px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
          backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 16px 40px rgba(60, 60, 67, 0.18);
  max-width: 88%;
}
.sg-win-emoji { font-size: 34px; line-height: 1; }
.sg-win-title {
  font-family: "Instrument Serif", "SF Pro Display", serif;
  font-size: 26px;
  font-weight: 600;
  margin: 8px 0 4px;
  color: var(--sg-ink);
}
.sg-win-sub {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  color: var(--sg-mute);
  font-variant-numeric: tabular-nums;
}
.sg-win-app {
  font-family: "Hanken Grotesk", -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--sg-ink);
  margin: 16px 0 10px;
}
.sg-stores { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.sg-store {
  font-family: "Hanken Grotesk", -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #1d1d1f;
  border-radius: 999px;
  padding: 8px 16px;
  text-decoration: none;
}
.sg-store:hover { opacity: 0.9; }
.sg-win-again { margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  .sg-btn:active { transform: none; }
  .sg-win { transition: none; }
}
