/*! © 2026 JuJu Games — https://juju.games */
/* Slide Merge. The tray's whole geometry is one number, `--c` (a cell's width in CSS pixels),
   set by slide-merge.js on .smg-stage along with the tray's size in cells (--w, --h) and its
   rim (--rim). Nothing here states one of those numbers of its own.

   Nothing here states a panel size either: mode 2 belongs to game-layout.css and the game
   only declares 'fill'. */

.game-root[data-game="boop-zoo"] {
  padding: clamp(12px, 2.4vw, 24px);
  background: linear-gradient(180deg, #cdeaf3 0%, #eaf6ee 58%, #f5ebd4 100%);
}

/* width:100% is load-bearing: the filling panel is a flex container, so without it .smg is a
   flex item that shrinks to its contents — and its contents are sized from it. */
.smg { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
/* Only the tray's box may take the slack, or clearing a level shrinks the tray it was won on. */
.smg > :not(.g-fit) { flex: none; }

/* The line every animal climbs, as the top of the game shows it. Twelve across where there is
   room, two rows of six on a phone; the arrow belongs to the animal before it, so a row that
   ends still points on to the next. */
.smg-chain {
  display: grid; grid-template-columns: repeat(12, auto); justify-content: center; gap: 4px 13px;
  margin: 0; padding: 6px 12px; list-style: none;
  border-radius: 14px; background: rgba(255, 250, 238, .7); box-shadow: 0 2px 8px rgba(92, 60, 26, .1);
}
.smg-link { position: relative; display: grid; place-items: center; }
.smg-link img { display: block; width: 34px; height: 34px; object-fit: contain; }
.smg-link:not(:last-child)::after {
  content: ''; position: absolute; right: -10px; top: 50%;
  width: 6px; height: 6px; margin-top: -3px;
  border-top: 2px solid #c38b4d; border-right: 2px solid #c38b4d; transform: rotate(45deg);
}
.smg-link.is-goal::before {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: rgba(255, 207, 90, .45); box-shadow: 0 0 0 2px #f2b53a;
}
.smg-link.is-goal img { position: relative; }

.smg-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; width: 100%; }
.smg-select {
  max-width: 100%; font-size: .9rem; padding: 7px 10px; border-radius: 10px;
  border: 1px solid rgba(90, 64, 38, .25); background: #fffaf0; color: #3e2f20;
}
.smg-goal { display: inline-flex; align-items: center; gap: 6px; color: #4a3a28; font-weight: 700; font-size: .92rem; }
.smg-goal-img { width: 32px; height: 32px; object-fit: contain; }
.smg-status { min-height: 1.45em; color: #3d4c45; font-size: .93rem; text-align: center; line-height: 1.45; }
.smg-status.smg-new { color: #b35d14; font-weight: 700; animation: smg-say .45s ease-out; }
@keyframes smg-say { 0% { transform: scale(.85); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }

/* --- the tray --------------------------------------------------------------------------- */
.smg-stage {
  --c: 60px;
  --r: calc(var(--c) * .14);
  --wood: linear-gradient(160deg, #d7a86e 0%, #c28e55 55%, #a8743f 100%);
  position: relative; flex: none;
  border-radius: calc(var(--c) * .24);
  background: var(--wood);
  box-shadow: 0 10px 26px rgba(92, 60, 26, .28), inset 0 2px 0 rgba(255, 236, 200, .55),
              inset 0 -3px 0 rgba(90, 56, 22, .35);
  touch-action: manipulation;
}
.smg-layer {
  position: absolute;
  left: calc(var(--rim) * var(--c)); top: calc(var(--rim) * var(--c));
  width: calc(var(--w) * var(--c)); height: calc(var(--h) * var(--c));
  border-radius: var(--r);
  background-color: #efd3a6;
  background-image:
    linear-gradient(to right, rgba(120, 80, 40, .16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(120, 80, 40, .16) 1px, transparent 1px);
  background-size: var(--c) var(--c);
  box-shadow: inset 0 3px 8px rgba(110, 70, 30, .28);
}
/* Walls and fillets are drawn with the rim's own gradient, sized to the whole stage and shifted
   back by their offset from its corner, so a wall is continuous with the rim it grows out of.
   The box clips them to the play area's rounded corners; the shape inside it casts one shadow
   for the whole outline, where a shadow per cell would darken every seam between two walls. */
.smg-walls {
  position: absolute; z-index: 1; overflow: hidden; pointer-events: none;
  left: calc(var(--rim) * var(--c)); top: calc(var(--rim) * var(--c));
  width: calc(var(--w) * var(--c)); height: calc(var(--h) * var(--c));
  border-radius: var(--r);
}
.smg-walls-shape { position: absolute; inset: 0; filter: drop-shadow(0 3px 4px rgba(110, 70, 30, .34)); }
.smg-wall, .smg-fillet {
  position: absolute; left: var(--fx); top: var(--fy);
  background: var(--wood);
  background-size: calc((var(--w) + 2 * var(--rim)) * var(--c)) calc((var(--h) + 2 * var(--rim)) * var(--c));
  background-position: calc(-1 * (var(--rim) * var(--c) + var(--fx))) calc(-1 * (var(--rim) * var(--c) + var(--fy)));
}
.smg-wall {
  --fx: calc(var(--x) * var(--c)); --fy: calc(var(--y) * var(--c));
  width: var(--c); height: var(--c);
}
.smg-wall.is-tl { border-top-left-radius: var(--r); }
.smg-wall.is-tr { border-top-right-radius: var(--r); }
.smg-wall.is-bl { border-bottom-left-radius: var(--r); }
.smg-wall.is-br { border-bottom-right-radius: var(--r); }
.smg-wall.has-art { background: var(--art) center / contain no-repeat; }
.smg-fillet { width: var(--r); height: var(--r); }
.smg-fillet.is-tl {
  --fx: calc(var(--x) * var(--c)); --fy: calc(var(--y) * var(--c));
  -webkit-mask-image: radial-gradient(circle at 100% 100%, transparent var(--r), #000 calc(var(--r) + .5px));
  mask-image: radial-gradient(circle at 100% 100%, transparent var(--r), #000 calc(var(--r) + .5px));
}
.smg-fillet.is-tr {
  --fx: calc((var(--x) + 1) * var(--c) - var(--r)); --fy: calc(var(--y) * var(--c));
  -webkit-mask-image: radial-gradient(circle at 0 100%, transparent var(--r), #000 calc(var(--r) + .5px));
  mask-image: radial-gradient(circle at 0 100%, transparent var(--r), #000 calc(var(--r) + .5px));
}
.smg-fillet.is-bl {
  --fx: calc(var(--x) * var(--c)); --fy: calc((var(--y) + 1) * var(--c) - var(--r));
  -webkit-mask-image: radial-gradient(circle at 100% 0, transparent var(--r), #000 calc(var(--r) + .5px));
  mask-image: radial-gradient(circle at 100% 0, transparent var(--r), #000 calc(var(--r) + .5px));
}
.smg-fillet.is-br {
  --fx: calc((var(--x) + 1) * var(--c) - var(--r)); --fy: calc((var(--y) + 1) * var(--c) - var(--r));
  -webkit-mask-image: radial-gradient(circle at 0 0, transparent var(--r), #000 calc(var(--r) + .5px));
  mask-image: radial-gradient(circle at 0 0, transparent var(--r), #000 calc(var(--r) + .5px));
}

/* A piece is positioned by its transform alone, so everything that animates it — the pop, the
   fade, the lift — runs on the child, never on the piece: two animations on one transform
   cancel each other. */
.smg-piece {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: calc(var(--pw) * var(--c)); height: calc(var(--ph) * var(--c));
  transform: translate(calc(var(--x) * var(--c)), calc(var(--y) * var(--c)));
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.smg-stage.is-live .smg-piece { transition: transform .15s cubic-bezier(.3, 1.35, .6, 1); }
.smg-stage.is-resizing .smg-piece { transition: none; }
/* Two layers: the jelly (--sx/--sy, driven by springs in slide-merge.js) on .smg-art, and the
   picture, its shadow, its breathing and its fade on .smg-img. One element carrying both would
   have the keyframes overwrite the springs' transform. The pivot sits near the feet, so a
   squash lands on the floor instead of shrinking towards the middle. */
.smg-art {
  position: absolute; inset: calc(var(--c) * .02);
  transform: scale(var(--sx, 1), var(--sy, 1)); transform-origin: 50% 92%;
}
.smg-img {
  position: absolute; inset: 0;
  background: center / contain no-repeat;
  filter: drop-shadow(0 calc(var(--c) * .05) calc(var(--c) * .05) rgba(84, 52, 20, .32));
  transform-origin: 50% 95%;
  animation: smg-idle 2.6s ease-in-out infinite;
}
@keyframes smg-idle { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.018, .978); } }
.smg-piece.is-held { z-index: 5; cursor: grabbing; }
.smg-piece.is-held .smg-img { filter: drop-shadow(0 calc(var(--c) * .12) calc(var(--c) * .1) rgba(84, 52, 20, .34)); }
.smg-piece.is-gone { z-index: 4; pointer-events: none; }
.smg-piece.is-gone .smg-img { animation: smg-gone .26s ease-in forwards; }
@keyframes smg-gone { to { transform: scale(.55); opacity: 0; } }
.smg-piece.is-born { z-index: 6; }

/* The ring is the piece's own child, so it never meets the animations on the art. */
.smg-halo {
  position: absolute; inset: calc(var(--c) * -.04); border-radius: calc(var(--c) * .28);
  border: max(2px, calc(var(--c) * .06)) solid #ffcf5a; opacity: 0; pointer-events: none;
}
.smg-piece.is-coach .smg-halo { animation: smg-breathe 1.6s ease-in-out infinite; }
@keyframes smg-breathe {
  0%, 100% { transform: scale(1); opacity: .35; }
  50% { transform: scale(1.18); opacity: .95; }
}
.smg-piece.is-born .smg-halo { animation: smg-ring .62s ease-out; }
@keyframes smg-ring { 0% { transform: scale(.6); opacity: .95; } 100% { transform: scale(1.45); opacity: 0; } }

.smg-stage.smg-won { animation: smg-won .5s ease-out; }
@keyframes smg-won {
  0% { box-shadow: 0 10px 26px rgba(92, 60, 26, .28), 0 0 0 0 rgba(255, 207, 90, .9); }
  100% { box-shadow: 0 10px 26px rgba(92, 60, 26, .28), 0 0 0 calc(var(--c) * .5) rgba(255, 207, 90, 0); }
}

/* --- controls ------------------------------------------------------------------------------ */
.smg-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.smg-btn { background: #fffaf0; color: #3e2f20; border: 1px solid rgba(90, 64, 38, .25); }
.smg-btn:disabled { opacity: .45; }
.smg-fs { display: inline-flex; align-items: center; gap: 7px; }
/* Two nested corners read as "expand" at any size; U+26F6 tofus on Windows and Android. */
.smg-fsicon {
  position: relative; display: inline-block; width: .85em; height: .72em;
  border: 2px solid currentColor; border-radius: 2px;
}
.smg-fsicon::before {
  content: ''; position: absolute; inset: 2px;
  border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; opacity: .45;
}

/* --- the result card ----------------------------------------------------------------------- */
/* Over the whole game, not only the tray: an early tray is a strip one cell tall, and a card
   inside it would be cut away. */
.smg-end {
  position: absolute; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(62, 44, 26, .22); border-radius: 12px;
}
.smg-end:empty { display: none; }
.smg-card {
  max-width: min(92%, 360px); max-height: calc(100% - 24px); overflow-y: auto;
  padding: 18px 22px 20px; border-radius: 18px; text-align: center;
  background: #fffaf0; color: #3e2f20; box-shadow: 0 18px 44px rgba(62, 44, 26, .35);
}
.smg-card .result-done { color: #b35d14; font-size: .95rem; }
.smg-card-name { margin: 6px 0 4px; font-size: 1.3rem; line-height: 1.25; }
.smg-card-line { margin: 0; color: #5b4a38; font-size: .95rem; line-height: 1.5; }
.smg-card-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
/* Green is "press this" sitewide; this is the leaf green of the tray's own world, and the
   neutral buttons under the tray stay cream. */
.smg-card .btn-primary { background: #55a446; border-color: #46893a; color: #fff5e8; }
.smg-card .btn-primary:hover { background: #4b9a3d; border-color: #3d7a33; }
.smg-replay {
  display: block; margin: 12px auto 0; padding: 4px 6px;
  background: none; border: 0; cursor: pointer;
  color: #9d968c; font-size: .88rem; text-decoration: underline; text-underline-offset: 3px;
}
.smg-replay:hover { color: #6b645b; }

/* --- the daily board ---------------------------------------------------------------------- */
.smg-card-after { margin: 12px 0 0; color: #5b4a38; font-size: .92rem; }
.smg-daily-next { display: grid; gap: 2px; margin: 14px 0 0; }
.smg-daily-count { font-weight: 700; color: #3e2f20; font-variant-numeric: tabular-nums; }
.smg-daily-rule { color: #9d968c; font-size: .8rem; }
.smg-daily-head { margin: 14px 0 6px; color: #9d968c; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.smg-daily-total {
  display: inline-block; margin: 12px 0 0; padding: 3px 12px; border-radius: 999px;
  background: #fdecc8; color: #8a5a17; font-size: .85rem; font-weight: 700;
}
.smg-week { display: flex; justify-content: center; gap: 6px; }
.smg-week-day {
  position: relative; display: grid; justify-items: center; gap: 1px; width: 40px; padding: 4px 0 2px;
  border: 1px solid #ead9bd; border-radius: 10px; background: #fff5e3; cursor: pointer; font: inherit;
}
.smg-week-day:hover { border-color: #d7b98a; }
.smg-week-day.is-next { border-color: #55a446; box-shadow: 0 0 0 2px rgba(85, 164, 70, .22); }
.smg-week-mark {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 2px dashed #dcc7a3; color: #fff; font-size: 13px; font-weight: 700;
}
.smg-week-day.is-done .smg-week-mark { border: 0; background: #55a446; }
/* The one beat on the card: today's tick lands as the card comes up. */
.smg-week-day.is-current.is-done .smg-week-mark { animation: smg-tick-pop .55s .2s cubic-bezier(.3, 1.8, .5, 1) both; }
@keyframes smg-tick-pop { from { transform: scale(0); } to { transform: scale(1); } }
.smg-week-when { min-height: .8rem; color: #9d968c; font-size: .62rem; line-height: .8rem; }

/* --- Mode 1: page-embedded ------------------------------------------------------------------- */
/* The tray takes what the window leaves, capped at an absolute 640px: a viewport share here
   would be no cap at all. */
.smg .g-fit {
  position: relative; display: grid; place-items: center; width: 100%;
  height: clamp(240px, calc(100svh - 300px), 760px);
}

/* --- Mode 3: phone ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Full bleed: on a phone the width is what binds the tray, so the page’s own gutter
     is what the cells would otherwise pay for. */
  .game-root[data-game="boop-zoo"] { border: 0; padding: 10px 0 12px; margin-inline: -16px; }
  .smg .g-fit { height: min(60svh, calc(100svh - 360px)); min-height: 220px; }
  .smg-fslabel { display: none; }
  .smg-chain { grid-template-columns: repeat(6, auto); gap: 4px 14px; }
  .smg-link img { width: 30px; height: 30px; }
}

/* --- Mode 2: page-filling ------------------------------------------------------------------ */
/* Only what goes INSIDE the panel. :not(.smg-full) on every page-mode rule: full screen is a
   separate mode with its own sizing and these selectors outrank its own. */
html.fills-window .smg:not(.smg-full) { height: 100%; justify-content: center; }
html.fills-window .smg:not(.smg-full) .g-fit { flex: 1 1 0; min-height: 0; height: auto; }

/* --- Mode 4: full screen ------------------------------------------------------------------- */
/* Written outside every media query: mode 2's copy lives inside a window-height query and
   full screen on a tall monitor falls outside it. */
body.smg-locked { overflow: hidden; }
.smg.smg-full {
  position: fixed; inset: 0; z-index: 200; margin: 0; padding: 12px;
  background: linear-gradient(180deg, #cdeaf3 0%, #eaf6ee 58%, #f5ebd4 100%);
  justify-content: center;
}
.smg.smg-full .g-fit { flex: 1 1 0; min-height: 0; height: auto; }
.smg.smg-full .smg-end { border-radius: 0; }
