/* Melody Jigsaw. */
/* Set here rather than inherited: a topic page centres everything its embedded game leaves unset. */
.mlj { position: relative; width: 100%; text-align: center; }
.mlj-bar { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; min-height: 34px; }
.mlj-left { color: var(--c-text-soft); font-weight: 600; font-size: .9rem; }
.mlj-song { display: inline-flex; align-items: center; gap: 6px; color: var(--c-text-soft); font-size: .9rem; font-style: italic; }
.mlj-song .mlj-icon { width: 1em; height: 1em; }

.mlj-stage {
  position: relative; width: 100%; overflow: hidden; border-radius: 14px;
  background: radial-gradient(120% 100% at 50% 0%, #f3f1ec 0%, #e8e4dc 55%, #ddd8ce 100%);
  box-shadow: inset 0 1px 3px rgba(70, 60, 50, .1);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.mlj-defs { position: absolute; width: 0; height: 0; }
.mlj-board {
  position: absolute; border-radius: 2px;
  background-size: 100% 100%; background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(60, 50, 40, .18), inset 0 2px 10px rgba(60, 50, 40, .12);
  opacity: 0; overflow: hidden;
}
.mlj-board.mlj-hint { opacity: .17; }
/* Full strength once done: it is also the backing that keeps antialiased seams between
   neighbouring clip-paths from reading as cracks. */
.mlj-board.mlj-done { opacity: 1; transition: opacity .4s ease; }
/* The finished picture is swept once by a band of light. It sits on the board, which is above
   the placed pieces only once they have gone (see .mlj-layer.mlj-gone). */
.mlj-board.mlj-sweep::after {
  content: ''; position: absolute; inset: -10% -60%;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 38%, rgba(255, 248, 225, .55) 50%, rgba(255, 255, 255, 0) 62%);
  transform: translateX(-70%); animation: mlj-sweep 2.4s ease-in-out .2s forwards;
}
@keyframes mlj-sweep { to { transform: translateX(70%); } }
.mlj-layer { position: absolute; inset: 0; }
/* The placed pieces make way for the board once the picture is whole, so the light sweep is
   drawn on one picture rather than across dozens of clips. */
.mlj-layer.mlj-gone { opacity: 0; transition: opacity .5s ease .1s; }

/* The filter lives on the outer element and the clip-path on the inner one: CSS applies filter
   before clip-path, so a drop-shadow on the clipped element is cut away by its own clip. */
.mlj-piece {
  position: absolute; left: 0; top: 0; padding: 0; border: 0;
  pointer-events: none;
  filter:
    drop-shadow(1px 1px 0 rgba(70, 56, 40, .55))
    drop-shadow(1px 1px 0 rgba(70, 56, 40, .38))
    drop-shadow(2px 4px 6px rgba(40, 34, 28, .42));
  will-change: transform;
}
.mlj-piece-face {
  position: absolute; inset: 0;
  background-repeat: no-repeat;
  pointer-events: auto; cursor: grab;
}
.mlj-piece-face::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(158deg,
    rgba(255, 255, 255, .38) 0%, rgba(255, 255, 255, .08) 20%,
    rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, .18) 100%);
}
.mlj-piece.lifting {
  filter:
    drop-shadow(1px 1px 0 rgba(70, 56, 40, .55))
    drop-shadow(1px 1px 0 rgba(70, 56, 40, .38))
    drop-shadow(5px 11px 12px rgba(40, 34, 28, .45));
}
.mlj-piece.lifting .mlj-piece-face { cursor: grabbing; }
.mlj-piece.placed { filter: none; }
.mlj-piece.placed .mlj-piece-face { cursor: default; pointer-events: none; }
.mlj-piece.placed .mlj-piece-face::after { display: none; }
.mlj-piece.snap { animation: mlj-snap .45s ease-out; }
@keyframes mlj-snap { 0% { filter: brightness(1.55) drop-shadow(0 0 6px rgba(255, 236, 170, .9)); } 100% { filter: brightness(1); } }

.mlj-fx { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }

/* Process hint: a strip across the top of the stage, never a mask, and inert so a piece
   under it can still be picked up. */
.mlj-coach {
  position: absolute; left: 12px; right: 12px; top: 10px; z-index: 2; width: fit-content; max-width: calc(100% - 24px);
  margin: 0 auto; padding: 8px 14px; border-radius: 12px; pointer-events: none;
  background: rgba(255, 255, 255, .88); color: var(--c-text); font-size: .9rem; line-height: 1.35; text-align: center;
  box-shadow: 0 6px 18px rgba(28, 32, 50, .16);
  transition: opacity .4s ease;
}
.mlj-coach.mlj-coach-out { opacity: 0; }

.mlj-foot { display: flex; flex-direction: column; align-items: center; }
.mlj-controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0 6px; }
.mlj-ctl {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text);
  font: inherit; font-size: .88rem; font-weight: 600; padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.mlj-ctl:hover { background: var(--c-bg); }
.mlj-icon { width: 1.1em; height: 1.1em; flex: none; }

/* The result lands on the stage, anchored to the bottom, so it does not cover the picture. */
.mlj-win { position: absolute; inset: 0; z-index: 3; display: flex; align-items: flex-end; justify-content: center; padding: 10px; pointer-events: none; }
.mlj-win:empty { display: none; }
.mlj-win-card {
  position: relative;
  pointer-events: auto; width: min(440px, 94%);
  max-height: 100%; overflow-y: auto;
  padding: 14px 20px 16px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  box-shadow: 0 12px 34px rgba(28, 32, 50, .3);
  text-align: center;
  animation: mlj-win-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes mlj-win-in { from { opacity: 0; transform: translateY(12px); } }
.mlj-win-card .result-card { margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
.mlj-win-card .result-done { font-size: 1.35rem; margin: 0 0 2px; }
.mlj-win-card .result-value { font-size: .9rem; color: var(--c-text-soft); margin: 0 0 4px; }
.mlj-feel { margin: 12px 0 0; font-size: .92rem; font-weight: 700; }
.mlj-moods { display: flex; justify-content: center; gap: 10px; margin: 6px 0 0; }
.mlj-mood {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px; min-width: 76px;
  border: 1px solid var(--c-border); background: rgba(255, 255, 255, .7); color: var(--c-text-soft);
  font: inherit; font-size: .8rem; font-weight: 600; padding: 6px 8px; border-radius: 12px; cursor: pointer;
}
.mlj-mood .mlj-icon { width: 30px; height: 30px; }
.mlj-mood:hover { color: var(--c-text); background: #fff; }
.mlj-mood.on { color: var(--c-primary-dark, var(--c-primary)); border-color: var(--c-primary); background: #fff; }
.mlj-note { display: block; min-height: 1.3em; margin: 6px 0 0; font-size: .85rem; color: var(--c-text-soft); }
/* Favorite, Share and Play again carry the same weight, so they wear the same style. */
.mlj-acts { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.mlj-act {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--c-border); background: #fff; color: var(--c-text);
  font: inherit; font-size: .88rem; font-weight: 700; padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.mlj-act:hover { border-color: var(--c-primary); }
.mlj-act.on { color: #d6456b; border-color: #efb3c3; }
.mlj-win-close {
  position: absolute; top: 4px; right: 8px;
  border: 0; background: none; color: var(--c-text-soft);
  font: inherit; line-height: 1; padding: 6px; cursor: pointer; border-radius: 8px;
}
.mlj-win-close .mlj-icon { width: 1.1rem; height: 1.1rem; }
.mlj-win-close:hover { background: var(--c-bg); color: var(--c-text); }
.mlj-win-reopen {
  pointer-events: auto;
  border: 1px solid var(--c-border); background: rgba(255, 255, 255, .94); color: var(--c-text);
  font: inherit; font-size: .85rem; font-weight: 700; padding: 8px 16px; border-radius: 999px;
  cursor: pointer; box-shadow: 0 4px 14px rgba(28, 32, 50, .18);
}

/* Inside the page-filling panel: the rows keep their height and the stage takes the rest;
   melody-jigsaw.js reads the stage's height back off it. */
html.fills-window .game-root:not(.mlj-fs) .mlj { display: flex; flex-direction: column; height: 100%; }
html.fills-window .game-root:not(.mlj-fs) .mlj > :not(.mlj-stage) { flex: none; }
html.fills-window .game-root:not(.mlj-fs) .mlj-stage { flex: 1 1 0; min-height: 0; }

/* #game-root is itself the element that goes full screen; these same rules are the
   fixed-position fallback for a browser without the Fullscreen API. game-layout.css gives a
   [data-fill] panel an explicit width and height, which would beat the fallback's inset. */
#game-root.mlj-fs {
  position: fixed; inset: 0; z-index: 200; margin: 0; padding: 10px 12px 12px;
  width: auto; height: auto;
  border: 0; border-radius: 0; box-shadow: none; min-height: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(120% 100% at 50% 0%, #2c2a2b 0%, #201f20 55%, #171617 100%);
}
.mlj-fs .mlj { width: 100%; }
.mlj-fs .mlj-stage { background: none; box-shadow: none; border-radius: 0; }
.mlj-fs .mlj-board { box-shadow: 0 0 0 1px rgba(255, 255, 255, .10), 0 18px 50px rgba(0, 0, 0, .6); }
.mlj-fs .mlj-left, .mlj-fs .mlj-song { color: rgba(255, 255, 255, .72); }
.mlj-fs .mlj-ctl { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .3); color: #fff; padding: 6px 12px; font-size: .85rem; }
.mlj-fs .mlj-ctl:hover { background: rgba(255, 255, 255, .24); }
/* FS_CHROME in melody-jigsaw.js is sized against these two rows. */
.mlj-fs .mlj-bar { margin-bottom: 6px; min-height: 0; }
.mlj-fs .mlj-controls { margin: 8px 0 4px; }
body.mlj-locked { overflow: hidden; }
