/* jigsaw: spillregler flyttet ut av styles.css 11. oktober 2026, i samme rekkefølge.
   Lastes rett etter styles.min.css på universet.html. */
.jigsaw-game::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.38;
  background-image:
    radial-gradient(circle, rgba(17, 106, 141, 0.25) 0 3px, transparent 4px),
    radial-gradient(circle, rgba(246, 196, 83, 0.3) 0 4px, transparent 5px);
  background-position: 18px 20px, 76px 71px;
  background-size: 104px 104px, 138px 138px;
}
.jigsaw-game__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
}
.jigsaw-game__head h3 {
  margin: 9px 0 6px;
  font-size: clamp(2rem, 4.6vw, 3.45rem);
}
.jigsaw-game__head p {
  max-width: 760px;
  margin: 0;
}
.jigsaw-game__score strong,
.jigsaw-game__score span {
  padding: 9px 15px;
  font-family: var(--font-title);
}
.jigsaw-game__score strong {
  color: #ffe27a;
  font-size: 1.08rem;
}
.jigsaw-game__score span {
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 800;
}
.jigsaw-gallery {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}
.jigsaw-gallery__choice {
  min-width: 0;
  padding: 6px;
  overflow: hidden;
  color: var(--fjord-deep);
  cursor: pointer;
  border: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 7px 17px rgba(18, 59, 83, 0.13);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.jigsaw-gallery__choice img {
  width: 100%;
  height: clamp(72px, 8vw, 112px);
  object-fit: cover;
  object-position: center 30%;
  border-radius: 11px;
  filter: saturate(1.1) contrast(1.03);
}
.jigsaw-gallery__choice span {
  display: block;
  padding: 7px 3px 3px;
  overflow: hidden;
  font-family: var(--font-title);
  font-size: clamp(0.74rem, 1.15vw, 0.92rem);
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jigsaw-gallery__choice:hover {
  transform: translateY(-3px);
}
.jigsaw-gallery__choice[aria-pressed="true"] {
  border-color: var(--sun);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(246, 196, 83, 0.28), 0 10px 22px rgba(18, 59, 83, 0.18);
}
.jigsaw-game__toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0;
  padding: 12px;
  border: 3px solid rgba(17, 106, 141, 0.15);
  border-radius: 23px;
  background: rgba(255, 255, 255, 0.78);
}
.jigsaw-game__sizes,
.jigsaw-game__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.jigsaw-game__sizes > span {
  margin-right: 3px;
  font-family: var(--font-title);
  font-weight: 900;
}
.jigsaw-game__sizes button {
  min-width: 48px;
  min-height: var(--tap);
  padding: 8px 13px;
  color: var(--fjord-deep);
  cursor: pointer;
  border: 2px solid rgba(17, 106, 141, 0.24);
  border-radius: 999px;
  background: var(--white);
  font-family: var(--font-title);
  font-weight: 900;
}
.jigsaw-game__sizes button[aria-pressed="true"] {
  color: var(--white);
  border-color: var(--plum);
  background: var(--plum);
  box-shadow: 0 5px 0 rgba(64, 43, 80, 0.22);
}
.jigsaw-game__actions .button {
  min-height: var(--tap);
  margin: 0;
  padding: 9px 14px;
  white-space: nowrap;
}
.jigsaw-game__play {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: clamp(18px, 3vw, 30px);
  align-items: start;
}
.jigsaw-game__play[aria-busy="true"] {
  opacity: 0.62;
}
.jigsaw-game__picture-label,
.jigsaw-tray__title {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-bottom: 8px;
  color: var(--fjord-deep);
  font-family: var(--font-title);
}
.jigsaw-game__picture-label span,
.jigsaw-tray__title span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}
.jigsaw-board__guide,
.jigsaw-board__slots {
  position: absolute;
  inset: 0;
}
.jigsaw-board__guide {
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0;
  filter: saturate(0.82) contrast(0.9);
  transition: opacity 320ms ease, filter 320ms ease;
}
.jigsaw-board__slots {
  display: grid;
  grid-template-columns: repeat(var(--puzzle-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--puzzle-rows), minmax(0, 1fr));
}
.jigsaw-slot {
  position: relative;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
  border: 1px dashed rgba(255, 255, 255, 0.72);
  transition: background 140ms ease, box-shadow 140ms ease;
}
.jigsaw-slot::after {
  position: absolute;
  inset: 5px;
  pointer-events: none;
  content: "";
  border: 2px solid transparent;
  border-radius: 8px;
}
.jigsaw-slot.is-helped::after,
.jigsaw-slot.is-dragover::after {
  border-color: #ffe06a;
  background: rgba(255, 224, 106, 0.18);
  box-shadow: 0 0 0 3px rgba(18, 59, 83, 0.32), 0 0 20px rgba(255, 224, 106, 0.76);
}
.jigsaw-slot.is-soft-hint::after {
  border-color: rgba(255, 224, 106, 0.78);
  background: rgba(255, 224, 106, 0.1);
  box-shadow: 0 0 0 2px rgba(255, 224, 106, 0.2);
  animation: jigsaw-soft-hint 1050ms ease-in-out infinite alternate;
}
.jigsaw-slot.is-wrong {
  background: rgba(224, 74, 74, 0.32);
  animation: jigsaw-shake 380ms ease;
}
.jigsaw-slot.is-filled {
  cursor: default;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.34);
}
.jigsaw-tray-wrap {
  min-width: 0;
  padding: 12px;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 26px;
  background:
    linear-gradient(145deg, rgba(16, 105, 136, 0.9), rgba(18, 59, 83, 0.94)),
    url("../images/canonical/stuen-sm.jpg") center / cover;
  box-shadow: 0 14px 30px rgba(18, 59, 83, 0.22);
}
.jigsaw-tray-wrap .jigsaw-tray__title {
  padding-inline: 4px;
  color: var(--white);
}
.jigsaw-tray-wrap .jigsaw-tray__title span {
  color: rgba(255, 255, 255, 0.8);
}
.jigsaw-tray {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 180px;
  align-content: start;
}
.jigsaw-tray[data-jigsaw-count="6"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.jigsaw-piece {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  border: 3px solid rgba(255, 255, 255, 0.98);
  border-radius: 10px 4px 10px 4px;
  background: var(--sky);
  box-shadow: 0 5px 0 rgba(4, 37, 53, 0.26), 0 8px 15px rgba(4, 37, 53, 0.24);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.jigsaw-piece svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: saturate(1.12) contrast(1.035);
}
.jigsaw-piece:hover {
  z-index: 2;
  transform: translateY(-3px) rotate(-1deg) scale(1.03);
}
.jigsaw-piece.is-selected {
  z-index: 3;
  border-color: #ffe06a;
  box-shadow: 0 0 0 4px var(--plum), 0 0 0 8px #ffe06a, 0 11px 22px rgba(4, 37, 53, 0.34);
  transform: translateY(-4px) scale(1.035);
}
.jigsaw-piece.is-grabbed {
  opacity: 0.28;
}
.jigsaw-piece.is-wrong {
  animation: jigsaw-shake 380ms ease;
}
.jigsaw-piece.is-placed {
  height: 100%;
  cursor: default;
  pointer-events: none;
  border-width: 1px;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}
.jigsaw-piece--floating {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.96;
  transform: translate(-50%, -58%) rotate(2deg) scale(1.08);
  box-shadow: 0 17px 30px rgba(4, 37, 53, 0.42);
}
.jigsaw-game__celebration {
  position: absolute;
  z-index: 12;
  inset: 0;
  pointer-events: none;
  color: var(--fjord-deep);
  text-align: left;
  animation: jigsaw-reveal 460ms ease-out;
}
.jigsaw-game__celebration[hidden] {
  display: none;
}
.jigsaw-game__celebration-copy {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: flex;
  gap: 11px;
  align-items: center;
  width: min(calc(100% - 28px), 410px);
  padding: 10px 14px;
  border: 4px solid rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  background: rgba(255, 239, 172, 0.94);
  box-shadow: 0 12px 30px rgba(4, 37, 53, 0.34);
  backdrop-filter: blur(7px);
}
.jigsaw-game__celebration-copy > span:last-child {
  display: grid;
}
.jigsaw-game__celebration-badge {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--sun);
  font-size: 2rem;
}
.jigsaw-game__celebration strong {
  font-family: var(--font-title);
  font-size: clamp(1.15rem, 2.6vw, 1.7rem);
}
.jigsaw-game__celebration small {
  color: var(--fjord-deep);
  font-weight: 900;
}
.jigsaw-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.jigsaw-stars i {
  position: absolute;
  top: -14%;
  color: #ffe06a;
  font-style: normal;
  font-size: clamp(1rem, 3vw, 2rem);
  text-shadow: 0 3px 6px rgba(18, 59, 83, 0.42);
  animation: jigsaw-star-shower 1700ms ease-in forwards;
}
.jigsaw-stars i:nth-child(1) { left: 8%; animation-delay: 40ms; }
.jigsaw-stars i:nth-child(2) { left: 23%; animation-delay: 280ms; }
.jigsaw-stars i:nth-child(3) { left: 41%; animation-delay: 120ms; }
.jigsaw-stars i:nth-child(4) { left: 59%; animation-delay: 360ms; }
.jigsaw-stars i:nth-child(5) { left: 76%; animation-delay: 180ms; }
.jigsaw-stars i:nth-child(6) { left: 91%; animation-delay: 460ms; }
.jigsaw-game__feedback {
  min-height: 28px;
  margin: 18px 0 0;
  padding: 11px 16px;
  color: var(--fjord-deep);
  text-align: center;
  border: 2px solid rgba(17, 106, 141, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
  font-weight: 850;
}
.jigsaw-complete-panel[hidden] {
  display: none;
}
.jigsaw-complete-panel__copy {
  display: flex;
  gap: 14px;
  align-items: center;
}
.jigsaw-complete-panel__copy small,
.jigsaw-complete-panel__copy strong {
  display: block;
}
.jigsaw-complete-panel__copy small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.jigsaw-complete-panel__copy strong {
  margin: 2px 0 4px;
  font-family: var(--font-title);
  font-size: clamp(1.35rem, 3vw, 2rem);
}
.jigsaw-complete-panel__copy p,
.jigsaw-complete-panel__episode {
  margin: 0;
}
.jigsaw-complete-panel__episode {
  padding: 10px 13px;
  border-radius: 14px;
  background: rgba(215, 242, 241, 0.86);
}
.jigsaw-complete-panel__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.jigsaw-complete-panel__actions .button {
  min-height: var(--tap);
  margin: 0;
}
.jigsaw-story-player {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 20px;
  background: var(--fjord-deep);
}
.jigsaw-story-player[hidden] {
  display: none;
}
.jigsaw-story-player__frame {
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  background: #081f2b;
}
.jigsaw-story-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.jigsaw-story-player > a {
  justify-self: center;
  color: var(--white);
  font-weight: 900;
}
.jigsaw-game.is-complete .jigsaw-board {
  box-shadow: 0 0 0 7px var(--sun), 0 18px 42px rgba(18, 59, 83, 0.32);
}
.jigsaw-game.is-complete .jigsaw-board__guide {
  opacity: 1;
  filter: saturate(1.14) contrast(1.03);
}
.jigsaw-game.is-complete .jigsaw-board__slots {
  opacity: 0;
  pointer-events: none;
}
.jigsaw-game.is-complete .jigsaw-game__play {
  grid-template-columns: minmax(0, 860px);
  justify-content: center;
}
.jigsaw-game.is-complete .jigsaw-tray-wrap {
  display: none;
}
.jigsaw-gallery__choice:focus-visible,
.jigsaw-game__sizes button:focus-visible,
.jigsaw-game__actions button:focus-visible,
.jigsaw-complete-panel button:focus-visible,
.jigsaw-piece:focus-visible,
.jigsaw-slot:focus-visible {
  z-index: 4;
  outline: 4px solid var(--fjord-deep);
  outline-offset: 4px;
}
@keyframes jigsaw-shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}
@keyframes jigsaw-soft-hint {
  from { opacity: 0.48; box-shadow: 0 0 0 1px rgba(255, 224, 106, 0.2); }
  to { opacity: 1; box-shadow: 0 0 0 5px rgba(255, 224, 106, 0.42), 0 0 22px rgba(255, 224, 106, 0.52); }
}
@keyframes jigsaw-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes jigsaw-star-shower {
  0% { opacity: 0; transform: translateY(-12px) rotate(0deg) scale(0.55); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateY(390px) rotate(250deg) scale(1.1); }
}
[data-calm="true"] .jigsaw-piece,
[data-calm="true"] .jigsaw-board__guide,
[data-calm="true"] .jigsaw-slot {
  transition: none !important;
}
[data-calm="true"] .jigsaw-piece,
[data-calm="true"] .jigsaw-slot,
[data-calm="true"] .jigsaw-game__celebration {
  animation: none !important;
}
[data-calm="true"] .jigsaw-stars {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .jigsaw-piece,
  .jigsaw-board__guide,
  .jigsaw-slot {
    transition: none !important;
  }
  .jigsaw-piece,
  .jigsaw-slot,
  .jigsaw-game__celebration {
    animation: none !important;
  }
  .jigsaw-stars {
    display: none;
  }
}
@media (max-width: 980px) {
  .jigsaw-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .jigsaw-game__toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .jigsaw-game__play {
    grid-template-columns: 1fr;
  }
  .jigsaw-tray {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .jigsaw-tray[data-jigsaw-count="6"],
  .jigsaw-tray[data-jigsaw-count="12"] {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
@media (max-width: 680px) {
  .jigsaw-game__head {
    grid-template-columns: 1fr;
  }
  .jigsaw-game__score {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .jigsaw-game__score span {
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.22);
  }
  .jigsaw-gallery {
    display: flex;
    margin-inline: -2px;
    padding: 3px 2px 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }
  .jigsaw-gallery__choice {
    min-width: 118px;
    scroll-snap-align: start;
  }
  .jigsaw-gallery__choice img {
    height: 82px;
  }
  .jigsaw-game__sizes {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .jigsaw-game__sizes > span {
    grid-column: 1 / -1;
  }
  .jigsaw-game__sizes button {
    min-width: 0;
    padding-inline: 6px;
  }
  .jigsaw-game__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .jigsaw-game__actions .button {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
    font-size: 0.82rem;
    white-space: normal;
  }
  .jigsaw-game__actions [data-jigsaw-reset] {
    grid-column: 1 / -1;
  }
  .jigsaw-board {
    border-width: 4px;
    border-radius: 20px;
  }
  .jigsaw-tray {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .jigsaw-tray[data-jigsaw-count="6"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .jigsaw-tray[data-jigsaw-count="12"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .jigsaw-piece {
    border-width: 2px;
    border-radius: 8px 3px 8px 3px;
  }
  .jigsaw-complete-panel__actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .jigsaw-complete-panel__actions .button {
    width: 100%;
  }
}
.jigsaw-complete-panel.game-finish-card { display: block; border-width: 3px; }
.jigsaw-complete-panel.game-finish-card[hidden] { display: none; }
.jigsaw-complete-panel.game-finish-card .jigsaw-complete-panel__copy,
.jigsaw-complete-panel.game-finish-card .jigsaw-complete-panel__episode,
.jigsaw-complete-panel.game-finish-card .jigsaw-complete-panel__actions,
.jigsaw-complete-panel.game-finish-card .jigsaw-story-player { position: relative; z-index: 2; }
