/* tính năng mở rộng — Xếp hình (js/game-puzzle.js). Mọi vị trí và kích thước do JS tính (layout); ở đây chỉ có hình thức. */
body[data-scene="xep-hinh"] { --sky1: #4FC08D; --sky2: #E3F8D0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

/* hình trên thẻ ở trang chủ */
.card .art > .gz-art { width: 2.6em; height: 2.05em; flex: none; overflow: visible; filter: drop-shadow(0 4px 0 rgba(30, 42, 94, .22)); }

/* khu chơi: được phép rộng hơn khung 1000px của trang; không cuộn, không phóng to khi bé kéo */
.gz-play { position: relative; isolation: isolate; /* thứ tự xếp lớp của các mảnh chỉ tính trong khu chơi: mảnh đang kéo không nổi lên trên màn "nghỉ mắt" hay hình dán mới */
  align-self: center; width: min(1500px, calc(100vw - 24px)); max-width: none; min-height: 200px; flex: none;
  overflow: hidden; overflow: clip; /* mảnh đang kéo sát mép không làm trang dài thêm (trang mà cuộn được thì bé kéo sẽ trượt) */
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.gz-play[hidden] { display: none; }
.gz-play > * { position: absolute; }

/* bảng: viền trắng, bên trong là bức ảnh mờ và các đường cắt */
.gz-board { z-index: 1; overflow: hidden; border-radius: 16px; background: #FFF9EA;
  box-shadow: 0 0 0 5px #fff, 0 7px 0 5px rgba(30, 42, 94, .18), 0 14px 22px rgba(30, 42, 94, .2); }
.gz-ghost, .gz-ghost svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.gz-gimg { opacity: .3; }
.gz-ghost[data-lv="2"] .gz-gimg { opacity: .22; }
.gz-ghost[data-lv="3"] .gz-gimg { opacity: .16; }
.gz-cut, .gz-cut2 { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gz-cut2 { stroke: rgba(30, 42, 94, .22); stroke-width: 5; }
.gz-cut { stroke: #fff; stroke-width: 2.5; }
.gz-full { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; transition: opacity .35s; }
.gz-shine { position: absolute; top: -20%; bottom: -20%; left: -60%; width: 45%; opacity: 0; pointer-events: none; transform: skewX(-18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent); }
.gz-name { position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%) scale(0); white-space: nowrap; pointer-events: none;
  padding: 0 .5em; border-radius: 999px; background: rgba(30, 42, 94, .28); font: 800 clamp(1.5rem, 6vmin, 3.2rem)/1.35 var(--font-ui); }
.gz-name.gz-long { font-size: clamp(1.2rem, 4.6vmin, 2.6rem); }

/* các ô đích (nằm trên các mảnh đã ghép để viền gợi ý không bị che) */
.gz-slots { z-index: 3; pointer-events: none; }
.gz-slot { position: absolute; border-radius: 18px; }
.gz-slot.gz-near { background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 4px #fff; }
.gz-slot.hinted { background: rgba(255, 210, 63, .32); outline-offset: -4px; }
.gz-pick .gz-slot:not(.gz-full)::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; aspect-ratio: 1; min-width: 34px; max-width: 64px; margin: 0; border-radius: 50%;
  transform: translate(-50%, -50%); background: rgba(255, 255, 255, .75); box-shadow: 0 0 0 4px rgba(255, 210, 63, .95); animation: gz-pulse 1.1s ease-in-out infinite; }

/* khay mảnh ghép */
.gz-tray { z-index: 0; border-radius: 24px; background: rgba(255, 255, 255, .55); border: 3px dashed rgba(255, 255, 255, .95); }
.gz-done .gz-tray, .gz-fail .gz-tray { border-style: solid; background: rgba(255, 255, 255, .3); }

/* mảnh ghép: lớp ngoài mang vị trí (translate), lớp trong mang cỡ + độ nghiêng (scale, rotate) và nhận cú chạm */
.gz-piece { left: 0; top: 0; z-index: 5; pointer-events: none; will-change: transform; transition: transform .34s cubic-bezier(.3, 1.25, .5, 1); }
.gz-in { width: 100%; height: 100%; pointer-events: auto; cursor: grab; touch-action: none; transition: transform .2s ease-out;
  filter: drop-shadow(0 3px 0 rgba(30, 42, 94, .38)) drop-shadow(0 5px 5px rgba(30, 42, 94, .22)); }
.gz-in svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.gz-seam { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; transition: opacity .35s; }
.gz-piece.gz-drag { transition: none; }
.gz-drag .gz-in { cursor: grabbing; filter: drop-shadow(0 12px 10px rgba(30, 42, 94, .4)); }
.gz-piece.gz-placed { z-index: 2; }
.gz-placed .gz-in { pointer-events: none; filter: none; }
.gz-piece.gz-sel { z-index: 6; }
.gz-sel .gz-in, .gz-piece.hinted .gz-in { filter: drop-shadow(0 0 5px var(--yellow)) drop-shadow(0 0 9px var(--yellow)) drop-shadow(0 4px 0 rgba(30, 42, 94, .35)); }
.gz-sel:not(.gz-drag) .gz-in svg, .gz-piece.hinted:not(.gz-drag) .gz-in svg { animation: gz-bob .9s ease-in-out infinite; }
.gz-piece.hinted { outline: none !important; box-shadow: none !important; }
.gz-in.gz-snap { animation: gz-snap .32s ease-out; }
.gz-play .gz-piece .gz-in.gz-wig svg { animation: gz-wig .5s ease-in-out; }
.gz-still .gz-piece, .gz-still .gz-in { transition: none !important; }
[data-phase="intro"] .gz-in, [data-phase="load"] .gz-in, [data-phase="done"] .gz-in { pointer-events: none; }

/* nút: Gấu Con, chọn ảnh, xem mẫu, ít mảnh hơn, nhiều mảnh hơn */
.gz-ctl { z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-evenly; gap: 8px 4px; --gz-b: 64px; }
.gz-ctl > .buddy { width: var(--gz-b); height: var(--gz-b); flex: none; }
.gz-ctl > .buddy .mascot { width: 100%; height: 100%; object-fit: contain; }
.gz-ctl > .gz-b { position: relative; width: var(--gz-b); height: var(--gz-b); border-width: 4px; }
.gz-ctl > .gz-b svg { width: 56%; height: 56%; fill: var(--navy); }
.gz-ctl > .gz-b:disabled { opacity: .38; box-shadow: none; cursor: default; }
.gz-less::after, .gz-more::after { content: "−"; position: absolute; right: -6px; top: -6px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; color: var(--navy); font: 800 20px/1 var(--font-ui); box-shadow: 0 2px 0 rgba(30, 42, 94, .25); pointer-events: none; }
.gz-more::after { content: "+"; }

/* nút "i": tác giả và giấy phép của ảnh */
.gz-info { z-index: 46; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .78); color: var(--navy); font: italic 800 16px/1 Georgia, serif; box-shadow: 0 2px 0 rgba(30, 42, 94, .2); opacity: .8; }
.gz-info2 { position: absolute; right: 2px; bottom: 2px; }
.gz-credits { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 14px; background: rgba(30, 42, 94, .5); }
.gz-credits-in { box-sizing: border-box; max-width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 14px 18px; border-radius: 20px; background: #fff; color: var(--navy);
  font: 600 14px/1.45 var(--font-ui); box-shadow: var(--lift); }
.gz-credits-in h3 { margin: 0 0 6px; font-size: 16px; }
.gz-credits-in ul { margin: 0; padding: 0; list-style: none; columns: 2 220px; column-gap: 18px; }
.gz-credits-in li { break-inside: avoid; }
.gz-credits-in p { margin: 8px 0 0; opacity: .7; font-size: 12px; }

/* xem ảnh mẫu một chút */
.gz-peek .gz-board { z-index: 40; }
.gz-peek .gz-full { opacity: 1; }

/* ghép xong: ảnh nguyên vẹn phủ lên các mảnh, đường cắt biến mất, ảnh sáng lên, tên con vật hiện ra */
.gz-done .gz-board { z-index: 40; animation: gz-win .9s ease-out; }
.gz-done .gz-full { opacity: 1; }
.gz-done .gz-seam { opacity: 0; }
.gz-done .gz-piece { opacity: 0; transition: opacity .2s .4s; }
.gz-done .gz-shine { animation: gz-shine 1.1s ease-out .25s; }
.gz-done .gz-name { transform: translateX(-50%) scale(1); transition: transform .4s cubic-bezier(.3, 1.6, .5, 1) .35s; }
.gz-done .gz-slots { display: none; }

/* nút "ảnh tiếp theo": ảnh con vật kế tiếp trong khung tròn, có mũi tên */
.gz-next { z-index: 45; display: grid; place-items: center; pointer-events: none; }
.gz-go { position: relative; width: clamp(96px, 62%, 210px); max-height: 92%; aspect-ratio: 1; padding: 0; border-radius: 50%; pointer-events: auto;
  background: var(--green); border: 6px solid #fff; box-shadow: 0 8px 0 rgba(30, 42, 94, .22), 0 14px 18px rgba(30, 42, 94, .22); animation: gz-pop .45s cubic-bezier(.3, 1.5, .5, 1) both, gz-beat 1.3s ease-in-out .6s infinite; }
@supports not (aspect-ratio: 1) { .gz-go { height: 120px; width: 120px; } }
.gz-go img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.gz-arrow { position: absolute; right: -4%; bottom: -4%; display: grid; place-items: center; width: 46%; height: 46%; min-width: 48px; min-height: 48px; border-radius: 50%;
  background: var(--green); border: 5px solid #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--green) 60%, #000); }
.gz-arrow svg { width: 58%; height: 58%; fill: #fff; }
.gz-go:active { transform: translateY(4px); }
.gz-oops { display: grid; gap: 12px; justify-items: center; pointer-events: auto; text-align: center; font-weight: 800; }

/* chọn ảnh */
.gz-chooser { position: relative; display: grid; place-items: center; align-self: center; width: min(1300px, calc(100vw - 24px)); max-width: none; flex: none; }
.gz-grid { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: var(--gz-g, 10px); max-width: 100%; }
.gz-thumb { position: relative; width: var(--gz-tw, 90px); height: var(--gz-th, 90px); flex: none; padding: 0; overflow: hidden; border-radius: 18px; background: #fff; border: 4px solid #fff;
  box-shadow: 0 5px 0 rgba(30, 42, 94, .2), 0 8px 12px rgba(30, 42, 94, .16); animation: gz-pop .35s cubic-bezier(.3, 1.4, .5, 1) backwards; transition: transform .08s; }
.gz-thumb:active { transform: translateY(3px) scale(.97); }
.gz-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 13px; pointer-events: none; }
.gz-thumb.gz-cur { border-color: var(--yellow); box-shadow: 0 0 0 4px var(--orange), 0 5px 0 4px rgba(30, 42, 94, .2); }
.gz-star { position: absolute; right: 2px; top: 2px; width: 30%; max-width: 34px; min-width: 20px; pointer-events: none; filter: drop-shadow(0 2px 0 rgba(30, 42, 94, .3)); }
.gz-star svg { display: block; width: 100%; height: auto; }

@keyframes gz-pulse { 0%, 100% { transform: translate(-50%, -50%) scale(.8); opacity: .65; } 50% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } }
@keyframes gz-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7%); } }
@keyframes gz-snap { 0% { transform: scale(1.1); } 60% { transform: scale(.97); } 100% { transform: scale(1); } }
@keyframes gz-wig { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 60% { transform: rotate(8deg); } 85% { transform: rotate(-3deg); } }
@keyframes gz-win { 0% { transform: scale(1); } 40% { transform: scale(1.035) rotate(-.6deg); } 70% { transform: scale(1.02) rotate(.4deg); } 100% { transform: scale(1); } }
@keyframes gz-shine { 0% { left: -60%; opacity: 1; } 100% { left: 130%; opacity: 1; } }
@keyframes gz-pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes gz-beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

@media (prefers-reduced-motion: reduce) {
  .gz-piece, .gz-in, .gz-full, .gz-seam, .gz-name { transition: none !important; }
  .gz-in.gz-snap, .gz-in.gz-wig svg, .gz-sel .gz-in svg, .gz-piece.hinted .gz-in svg, .gz-done .gz-board, .gz-done .gz-shine, .gz-go, .gz-thumb, .gz-pick .gz-slot::after { animation: none !important; }
}

/* ---------- wave 7: hình khối (3D) ---------- */
/* bảng ghép là một cái khay gỗ: vành khay nổi quanh bảng, lòng khay lõm xuống, mép dưới là bề dày của khay, bóng đổ xuống bàn */
.gz-board { background: #FBF1DA;
  box-shadow: 0 0 0 1px rgba(110, 70, 20, .5), 0 0 0 5px #E6BD82, 0 0 0 6px #B5874A, 0 5px 0 5px #A07238, 0 6px 0 6px #7C5524, 0 15px 18px 2px rgba(30, 42, 94, .3); }
.gz-board::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 2; border-radius: 16px; pointer-events: none;
  box-shadow: inset 0 5px 8px rgba(60, 35, 5, .42), inset 0 -2px 4px rgba(60, 35, 5, .16), inset 3px 0 5px rgba(60, 35, 5, .16), inset -3px 0 5px rgba(60, 35, 5, .16); }
/* khay đựng mảnh: một cái máng lõm */
.gz-tray { border: 0; background: linear-gradient(rgba(255, 255, 255, .62), rgba(255, 255, 255, .4)); box-shadow: inset 0 4px 9px rgba(30, 42, 94, .22), inset 0 -2px 0 rgba(255, 255, 255, .75), 0 2px 0 rgba(255, 255, 255, .55); }

/* mảnh ghép bằng bìa cứng: cạnh bìa màu nâu ở dưới (bề dày), mép trên–trái sáng, mép dưới–phải tối, bóng đổ xuống khay; nhấc lên thì bóng xa hơn */
.gz-in { filter: drop-shadow(0 2px 0 #D9B57C) drop-shadow(0 4px 0 #A8824A) drop-shadow(0 9px 6px rgba(30, 42, 94, .34)); }
.gz-drag .gz-in { filter: drop-shadow(0 2px 0 #D9B57C) drop-shadow(0 4px 0 #A8824A) drop-shadow(0 20px 14px rgba(30, 42, 94, .4)); }
.gz-sel .gz-in, .gz-piece.hinted .gz-in { filter: drop-shadow(0 3px 0 #A8824A) drop-shadow(0 0 5px var(--yellow)) drop-shadow(0 0 9px var(--yellow)); }
.gz-bev { fill: none; stroke-linejoin: round; stroke-width: 5.5; transition: opacity .35s; }
.gz-bev-d { stroke: rgba(40, 24, 4, .42); }
.gz-bev-l { stroke: rgba(255, 255, 255, .62); }
.gz-seam { stroke: rgba(255, 255, 255, .9); stroke-width: 1.4; }
.gz-done .gz-bev { opacity: 0; }

/* nút tròn: mặt nút vồng bóng, cạnh dày, bên trong là hình 3D (🖼️ chọn ảnh, 👁️ xem mẫu, lưới mảnh ghép 🧩 kèm dấu − / + 3D) */
.gz-ctl > .gz-b { background: radial-gradient(circle at 34% 24%, rgba(255, 255, 255, .8) 0, rgba(255, 255, 255, 0) 42%), linear-gradient(rgba(255, 255, 255, .2), rgba(0, 0, 0, .12)), var(--c);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .14), 0 5px 0 rgba(0, 0, 0, .36), 0 5px 0 var(--c), 0 10px 12px rgba(30, 42, 94, .26); }
.gz-ctl > .gz-b:active { box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14), 0 1px 0 rgba(0, 0, 0, .36), 0 1px 0 var(--c); }
.gz-ctl > .gz-b > img.emo { width: 68%; height: 68%; pointer-events: none; filter: drop-shadow(0 2px 1px rgba(30, 42, 94, .35)); }
.gz-pcs { display: grid; grid-template-columns: repeat(var(--k, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--r, 2), minmax(0, 1fr)); width: 64%; height: 60%; pointer-events: none; }
.gz-pcs img.emo { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; transform: scale(1.12); filter: drop-shadow(0 2px 1px rgba(30, 42, 94, .4)); }
.gz-less::after, .gz-more::after { content: ""; background: #fff url(../img/g3-dau-tru.png) center / 72% no-repeat; box-shadow: 0 2px 0 rgba(30, 42, 94, .3), 0 4px 5px rgba(30, 42, 94, .22); }
.gz-more::after { background-image: url(../img/g3-dau-cong.png); }
.gz-info { background: linear-gradient(#fff, #E4EAFA); box-shadow: inset 0 -2px 0 rgba(30, 42, 94, .12), 0 2px 0 rgba(30, 42, 94, .3), 0 4px 6px rgba(30, 42, 94, .2); }

/* nút "ảnh tiếp theo": tấm ảnh tròn có vành dày, mũi tên là phím 3D */
.gz-go { box-shadow: 0 8px 0 #C6CFE8, 0 10px 0 #A9B5D6, 0 14px 4px rgba(30, 42, 94, .22), 0 24px 20px rgba(30, 42, 94, .3); }
.gz-go::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: 50%; pointer-events: none; background: linear-gradient(118deg, rgba(255, 255, 255, .36) 0, rgba(255, 255, 255, 0) 40%); box-shadow: inset 0 8px 12px rgba(0, 0, 0, .2); }
.gz-arrow { z-index: 1; border: 0; background: none; box-shadow: none; }
.gz-arrow img.emo { display: block; width: 100%; height: 100%; filter: drop-shadow(0 4px 0 rgba(20, 60, 150, .6)) drop-shadow(0 8px 6px rgba(30, 42, 94, .3)); }

/* màn chọn ảnh: mỗi ảnh là một tấm thẻ dày, ảnh lõm vào khung, có vệt sáng chéo */
.gz-thumb { box-shadow: 0 5px 0 #C6CFE8, 0 6px 0 #A9B5D6, 0 12px 12px rgba(30, 42, 94, .28); }
.gz-thumb::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: 13px; pointer-events: none;
  background: linear-gradient(118deg, rgba(255, 255, 255, .32) 0, rgba(255, 255, 255, .05) 24%, rgba(255, 255, 255, 0) 40%); box-shadow: inset 0 6px 9px rgba(0, 0, 0, .22), inset 0 -3px 6px rgba(0, 0, 0, .12); }
.gz-thumb.gz-cur { box-shadow: 0 0 0 4px var(--orange), 0 6px 0 4px #B66A00, 0 14px 12px rgba(30, 42, 94, .3); }
.gz-star { z-index: 1; }
@media (prefers-reduced-motion: reduce) { .gz-bev { transition: none; } }

/* ---------- wave 6: compat (trình duyệt cũ) ---------- */
/* Bản dự phòng cho máy cũ của các luật phía trên (giải thích ở cuối css/style.css); sửa luật gốc thì sửa luôn dòng tương ứng ở đây. */
/* chưa có color-mix(): mũi tên "ảnh tiếp theo" (.gz-arrow) nay là hình 3D, không còn bóng dùng color-mix nên không cần dòng dự phòng */
