/* 태블릿 놀이: 그림 퍼즐 (play/puzzle/), 같은 그림 찾기 (play/match/), 수 세기 (play/count/). site/play_games.js,
 * pages by pipeline/site_play_games.py. The look follows the colouring game (site/color.css): cut paper, warm colours, Jua. */
.pg-head .date { max-width: 46em; }
@media (max-width: 760px) { .pg-head .date { padding-bottom: 40px; } }   /* phone: the last line of the lead sat on the green hill */
.pg-tip { margin: 0 0 14px; font-size: 15px; color: #6b5a44; }
.pg h2 { margin: 22px 0 10px; }
.pg-how { margin-top: 10px; }
.pg-more b { font-family: var(--display); font-weight: 400; margin-right: 8px; }
.pg-more a { margin-right: 14px; white-space: nowrap; }

/* the shelf: stars and stickers */
.pg-shelf { background: #fff; border: 3px solid #f1e3c8; border-radius: 18px; padding: 10px 14px; }
.pg-shelf-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.pg-shelf-stars { font-family: var(--display); font-weight: 400; font-size: 24px; color: #f29b00; }
.pg-shelf-next { display: inline-flex; gap: 5px; }
.pg-shelf-next i { width: 16px; height: 16px; border-radius: 50%; background: #f3ead8; }
.pg-shelf-next i.on { background: #ffc52e; }
.pg-shelf-head small { color: #8a7458; font-size: 14px; }
.pg-stickers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pg-stickers img { width: 64px; height: 48px; object-fit: contain; filter: drop-shadow(0 0 0 #fff) drop-shadow(0 2px 2px rgba(74, 38, 16, .25)); }

/* modes and levels: big picture buttons */
.pg-modes, .pg-levels { display: flex; flex-wrap: wrap; gap: 10px; }
.pg-mode, .pg-lv { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 3px solid #f1e3c8; border-radius: 18px; background: #fff;
  padding: 10px 14px; font: inherit; color: #4a3a28; cursor: pointer; min-width: 104px; min-height: 96px; justify-content: center; }
.pg-mode { min-width: 150px; }
.pg-mode b, .pg-lv b { font-family: var(--display); font-weight: 400; font-size: 18px; line-height: 1.15; }
.pg-mode small, .pg-lv small { font-size: 13px; color: #a08c70; }
.pg-mode[aria-checked="true"], .pg-lv[aria-checked="true"] { border-color: #ff7a1a; background: #fff3e6; box-shadow: 0 0 0 2px #ff7a1a; }
.pg-grid { display: grid; gap: 3px; width: 58px; }
.pg-grid s { height: 12px; border-radius: 3px; background: #ffc98f; }
.pg-lv[aria-checked="true"] .pg-grid s { background: #ff9b4a; }
.pg-range { font-family: var(--display); font-style: normal; font-size: 28px; line-height: 1.3; color: #e2650c; }
.pg-mi { display: flex; align-items: center; justify-content: center; gap: 6px; height: 62px; font-style: normal; }
.pg-mi img { height: 40px; width: auto; }
.pg-mi .c { display: grid; place-items: center; width: 68px; height: 54px; border-radius: 10px; border: 2px solid #f1e3c8; background: #fff; }
.pg-mi .c img { max-width: 88%; max-height: 86%; height: auto; }
.pg-mi .c.bk { border-color: #f08a34; background: #ff9b4a radial-gradient(circle, #ffd8b0 3px, transparent 4px) 0 0 / 14px 14px; }
.pg-mi em { font-family: var(--display); font-style: normal; font-size: 38px; line-height: 1; color: #e2650c; }
.pg-mi .g { display: flex; align-items: center; gap: 1px; padding: 5px; border-radius: 10px; border: 2px solid #f1e3c8; background: #fff; }
.pg-mi .g img { height: 24px; }
.pg-mi .g.win { border-color: #ff7a1a; background: #fff3e6; }
.pg-mi-many img { height: 32px; margin: 0 -3px; }
.pg-mi .bsk { font-size: 40px; line-height: 1; }
.pg-sh { filter: brightness(0); opacity: .7; }

/* picture cards */
.pg-chips { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; margin: 0 0 6px; background: var(--paper, #fffaf0); }
.pg-chip { border: 2px solid #f1e3c8; border-radius: 99px; padding: 7px 14px; font: inherit; font-size: 15px; font-weight: 700; background: #fff; color: #4a3a28; cursor: pointer; }
.pg-chip[aria-pressed="true"] { background: #ff7a1a; border-color: #ff7a1a; color: #fff; }
.pg-group h3 { margin: 18px 0 10px; font-size: 20px; }
.pg-group h3 small { font-size: 14px; color: #a08c70; font-weight: 400; }
.pg-group[hidden], .pg-card[hidden], .pg-mine[hidden] { display: none; }
.pg-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 0 0 28px; }
.pg-card { position: relative; display: block; background: #fff; border: 3px solid #f1e3c8; border-radius: 18px; padding: 8px 8px 10px;
  text-decoration: none; color: #4a3a28; text-align: center; transition: transform .15s, border-color .15s; }
.pg-card:hover, .pg-card:focus-visible { transform: translateY(-3px); border-color: #ff9b4a; }
.pg-card b { display: block; margin-top: 6px; font-size: 16px; }
.pg-card small { display: block; font-size: 13px; color: #a08c70; }
.pg-card[data-done]::after { content: attr(data-done); position: absolute; top: 4px; right: 8px; color: #ffb300; font-size: 15px; letter-spacing: -1px;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.pg-th { display: block; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 10px; background: #fff; }
.pg-th img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pg-th-sheet { aspect-ratio: 846 / 478; }   /* the picture frame of a colouring sheet's preview (900 x 636), without the title */
.pg-th-sheet img { width: 106.4%; max-width: none; height: auto; margin: -13% 0 0 -3.2%; }
.pg-th-mine { border: 3px solid #cfe8c0; }
.pg-th-mine img { object-fit: cover; }
.pg-mine { margin: 4px 0 0; }

/* the board: full screen over the page */
html.pg-lock, html.pg-lock body { overflow: hidden; }
.pg-ed { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; background: #fff7e6; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; font-family: var(--display); }
.pg-ed[hidden], .pg-end[hidden] { display: none; }
.pg-ed button { font-family: inherit; }
.pg-top { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #fff; border-bottom: 2px solid #f1e3c8; }
.pg-top b { flex: 1; min-width: 0; font-weight: 400; font-size: clamp(16px, 2.4vw, 22px); color: #4a3a28; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-btn { border: 0; border-radius: 99px; min-height: 48px; padding: 9px 16px; font: inherit; font-size: 16px; background: #f3ead8; color: #4a3a28; cursor: pointer; white-space: nowrap; }
.pg-btn:active { transform: scale(.96); }
.pg-btn.main { background: #ff7a1a; color: #fff; }
.pg-mute { width: 48px; padding: 0; font-size: 22px; }
.pg-dots { display: inline-flex; gap: 5px; }
.pg-dots i { width: 14px; height: 14px; border-radius: 50%; background: #f1e3c8; }
.pg-dots i.on { background: #8fcf5a; }
.pg-starpill { font-size: 18px; color: #f29b00; background: #fff6d8; border-radius: 99px; padding: 8px 12px; white-space: nowrap; }
.pg-main { position: relative; flex: 1; min-height: 0; }
.pg-area { position: absolute; inset: 0; touch-action: none; }
.pg-busy { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; font-size: 18px; color: #8a7458; }
.pg-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }
.pg-wob { animation: pg-wob .42s ease-in-out; }
@keyframes pg-wob { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-6px) rotate(-3deg); } 60% { transform: translateX(6px) rotate(3deg); } 85% { transform: translateX(-2px); } }
.pg-pop { animation: pg-pop .32s ease-out; }
@keyframes pg-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* a number: the digit and as many dots, in rows of five */
.pg-n { display: inline-flex; flex-direction: column; align-items: center; gap: .08em; font-size: 46px; line-height: 1; color: #4a3a28; }
.pg-n b { font-weight: 400; font-size: 1em; line-height: 1; }
.pg-pips { display: flex; flex-wrap: wrap; justify-content: center; gap: .07em; width: 1.34em; min-height: .19em; }
.pg-pips s { width: .19em; height: .19em; border-radius: 50%; background: #ff7a1a; text-decoration: none; }
.pg-n.big { font-size: clamp(50px, 9vmin, 76px); }
.pg-n.ghost { opacity: .3; }
.pg-n.corner { position: absolute; left: 10px; top: 10px; z-index: 2; font-size: clamp(34px, 6vmin, 54px); background: #fff; border-radius: 16px; padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(120, 80, 30, .25); animation: pg-pop .32s ease-out; }

/* the end of a round */
.pg-end { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; justify-content: center; padding: 12px; pointer-events: none; }
.pg-end-box { pointer-events: auto; max-width: 680px; background: #fff; border-radius: 28px; padding: 14px 18px 12px; text-align: center;
  box-shadow: 0 6px 24px rgba(120, 80, 30, .3); animation: pg-up .4s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pg-up { from { transform: translateY(120%); } to { transform: translateY(0); } }
.pg-end-h { display: block; font-weight: 400; font-size: clamp(24px, 4vw, 34px); color: #e2650c; }
.pg-end-stars { font-size: clamp(40px, 7vw, 58px); line-height: 1.1; color: #ffc52e; }
.pg-end-stars i { display: inline-block; font-style: normal; animation: pg-pop .4s ease-out backwards; text-shadow: 0 2px 0 #e9a400; }
.pg-end-sticker { display: inline-flex; align-items: center; gap: 10px; margin: 2px 0 8px; padding: 6px 14px; border-radius: 99px; background: #fff6d8; font-size: 18px; color: #4a3a28; }
.pg-end-sticker img { width: 84px; height: 60px; object-fit: contain; animation: pg-pop .5s .5s ease-out backwards; }
.pg-end-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.pg-end-btns .pg-btn { min-height: 64px; padding: 12px 22px; font-size: clamp(17px, 2.4vw, 21px); box-shadow: 0 2px 8px rgba(120, 80, 30, .15); }
.pg-end-print { display: inline-block; margin-top: 10px; font-family: var(--body); font-size: 14px; color: #8a7458; }

/* 1. the jigsaw */
.pz-tray { position: absolute; border-radius: 22px; border: 3px dashed #ecd9b4; background: rgba(255, 255, 255, .55); }
.pz-board { position: absolute; border-radius: 8px; overflow: hidden; background: #fffdf8; box-shadow: 0 0 0 5px #fff, 0 4px 16px 4px rgba(120, 80, 30, .2); }
.pz-ghost, .pz-full { position: absolute; inset: 0; width: 100%; height: 100%; }
.pz-full { animation: pz-in .5s ease-out; }
@keyframes pz-in { from { opacity: 0; } to { opacity: 1; } }
.pz-board.shine { box-shadow: 0 0 0 6px #fff, 0 0 0 11px #ffc52e, 0 6px 26px 8px rgba(255, 170, 30, .45); transition: box-shadow .5s; }
.pz-board.shine::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, .9) 50%, transparent 68%);
  transform: translateX(-110%); animation: pz-shine 1.2s .25s ease-out; }
@keyframes pz-shine { to { transform: translateX(110%); } }
.pz-piece { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; pointer-events: none; will-change: transform;
  transition: transform .28s cubic-bezier(.3, 1.3, .5, 1); filter: drop-shadow(0 2px 2px rgba(74, 38, 16, .4)); }
.pz-piece.drag { transition: none; filter: drop-shadow(0 9px 8px rgba(74, 38, 16, .35)); }
.pz-piece.placed { transition: transform .12s ease-out; filter: none; }
.pz-piece.pg-wob { animation: pz-no .45s ease-in-out; }   /* a piece keeps its own transform: it blinks instead of wobbling */
@keyframes pz-no { 30% { opacity: .45; } 60% { opacity: 1; } 80% { opacity: .7; } }

/* 2. matching */
.mt-find { position: absolute; inset: 0; display: flex; gap: 14px; padding: 12px; }
.mt-target { flex: 0 0 38%; display: grid; place-items: center; min-width: 0; min-height: 0; border-radius: 28px; background: #fff3d6; border: 5px dashed #ffc98f; padding: 12px; }
.mt-target img { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; transition: filter .45s, opacity .45s; }
.mt-target.hit { border-style: solid; border-color: #8fcf5a; background: #f3fbe9; }
.mt-choices { flex: 1; min-width: 0; min-height: 0; display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; }
.mt-choices[data-n="3"] { grid-template-columns: 1fr; }
.mt-choice { position: relative; min-width: 0; min-height: 0; border: 4px solid #f1e3c8; border-radius: 22px; background: #fff; padding: 8px; cursor: pointer;
  box-shadow: 0 3px 0 #ecd9b4; }
.mt-choice img, .mt-face img { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; pointer-events: none; }
.mt-choice:active { transform: translateY(2px); box-shadow: none; }
.mt-choice.hit { border-color: #8fcf5a; background: #f3fbe9; animation: pg-pop .35s ease-out; }
@media (orientation: portrait) {
  .mt-find { flex-direction: column; }
  .mt-target { flex-basis: 36%; }
  /* standing tablet / phone: wide rows (1 x 3, 2 x 3) keep the pictures big; three narrow columns made them tiny */
}
.mt-grid { position: absolute; inset: 0; display: grid; place-content: center; }
.mt-card { position: relative; border: 0; background: none; padding: 0; cursor: pointer; perspective: 900px; -webkit-perspective: 900px; }
.mt-in { position: absolute; inset: 0; display: block; transition: transform .38s; transform-style: preserve-3d; -webkit-transform-style: preserve-3d; }
.mt-back, .mt-face { position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.mt-back { border: 4px solid #f08a34; box-shadow: 0 3px 0 #d9741f;
  background: url("assets/churro_happy.webp") center / 62% auto no-repeat, #ffb468 radial-gradient(circle, #ffd8b0 4px, transparent 5px) 0 0 / 22px 22px; }
.mt-face { background: #fff; border: 4px solid #f1e3c8; transform: rotateY(180deg); }
.mt-card.up .mt-in { transform: rotateY(180deg); }
.mt-card.hit .mt-face { border-color: #8fcf5a; background: #f3fbe9; }
.mt-card.hit { animation: pg-pop .35s ease-out; }

/* 3. counting */
.ct-many, .ct-bk { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.ct-field { position: relative; flex: 1; min-height: 0; border-radius: 22px; background: rgba(255, 255, 255, .6); border: 3px solid #f6ead0; }
.ct-item { position: absolute; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 22%; }
.ct-it { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ct-item.on .ct-it { opacity: .5; }
.ct-item.on { animation: pg-pop .3s ease-out; }
.ct-badge { position: absolute; left: 50%; top: 50%; min-width: 1.7em; height: 1.7em; margin: -.85em 0 0 -.85em; display: grid; place-items: center; border-radius: 99px;
  background: #ff7a1a; color: #fff; font-style: normal; font-size: clamp(18px, 3.4vmin, 30px); line-height: 1; box-shadow: 0 0 0 3px #fff; }
.ct-bar { flex: none; display: flex; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 34px); height: clamp(118px, 21vh, 176px); }
.ct-run { flex: none; display: grid; place-items: center; width: clamp(100px, 18vmin, 150px); height: 100%; border-radius: 26px; background: #fff3d6; border: 4px dashed #ffc98f; }
.ct-answers { display: flex; gap: clamp(8px, 2vw, 22px); height: 100%; visibility: hidden; }
.ct-answers.show { visibility: visible; }
.ct-ans { min-width: clamp(76px, 15vmin, 132px); height: 100%; border: 4px solid #f1e3c8; border-radius: 24px; background: #fff; cursor: pointer; padding: 4px; box-shadow: 0 4px 0 #ecd9b4;
  animation: pg-pop .35s ease-out backwards; }
.ct-ans:nth-child(2) { animation-delay: .08s; }
.ct-ans:nth-child(3) { animation-delay: .16s; }
.ct-ans .pg-n { font-size: clamp(40px, 7.5vmin, 62px); }
.ct-ans.off { opacity: .45; }
.ct-ans.hit { border-color: #8fcf5a; background: #f3fbe9; }
.ct-more { position: absolute; inset: 0; display: flex; gap: 14px; padding: 12px; }
.ct-side { position: relative; flex: 1; min-width: 0; min-height: 0; border: 5px solid #f1e3c8; border-radius: 28px; background: #fff; cursor: pointer; padding: 0; box-shadow: 0 4px 0 #ecd9b4; }
.ct-side:nth-child(2) { background: #f4fbff; border-color: #cfe6fb; box-shadow: 0 4px 0 #b9d6ee; }
.ct-sidefield { position: absolute; inset: 12px; pointer-events: none; }
.ct-sidefield .ct-it { position: absolute; }
.ct-side.hit { border-color: #8fcf5a; background: #f3fbe9; box-shadow: 0 0 0 4px #c9eaa9; }
@media (orientation: portrait) { .ct-more { flex-direction: column; } }
.ct-strip { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; height: clamp(96px, 16vh, 132px); }
.ct-target { display: flex; align-items: center; gap: 10px; height: 100%; padding: 6px 16px; border-radius: 24px; background: #fff3d6; border: 4px dashed #ffc98f; }
.ct-target .pg-n.big { font-size: clamp(38px, 6.4vmin, 58px); }
.ct-target-pic { height: 72%; width: auto; max-width: 110px; object-fit: contain; }
.ct-ok { flex: none; width: clamp(84px, 14vmin, 112px); height: clamp(84px, 14vmin, 112px); border: 0; border-radius: 50%; background: #8fcf5a; color: #fff; font: inherit; font-size: clamp(44px, 8vmin, 62px);
  line-height: 1; cursor: pointer; box-shadow: 0 5px 0 #6fae3e; }
.ct-ok:active { transform: translateY(3px); box-shadow: 0 2px 0 #6fae3e; }
.ct-ok.ready { animation: ct-pulse 1s ease-in-out infinite; }
@keyframes ct-pulse { 50% { transform: scale(1.1); box-shadow: 0 5px 0 #6fae3e, 0 0 0 8px #d7f0c0; } }
.ct-basket { position: relative; flex: none; height: clamp(150px, 31%, 270px); border-radius: 18px 18px 46px 46px; border: 4px solid #b97a3c; border-top-width: 14px;
  background: repeating-linear-gradient(45deg, rgba(150, 90, 30, .14) 0 10px, transparent 10px 20px), repeating-linear-gradient(-45deg, rgba(150, 90, 30, .14) 0 10px, transparent 10px 20px), #ecc184; }
.ct-basket.over { box-shadow: 0 0 0 5px #ffd23f; }
.ct-basket.hit { box-shadow: 0 0 0 6px #8fcf5a; }
.ct-cnt { position: absolute; right: 8px; top: 0; bottom: 0; display: grid; place-items: center; }
.ct-cnt .pg-n { min-width: 1.5em; padding: 8px 10px; border-radius: 18px; background: #fff; box-shadow: 0 2px 6px rgba(74, 38, 16, .3); font-size: clamp(34px, 6.5vmin, 52px); }
.ct-cnt .pg-n.ghost { opacity: .75; }
.ct-cnt .pg-n.ghost b { opacity: .35; }
.ct-drag { position: absolute; left: 0; top: 0; z-index: 3; object-fit: contain; pointer-events: none; transition: transform .22s ease-out, width .22s, height .22s;
  filter: drop-shadow(0 2px 2px rgba(74, 38, 16, .3)); }
.ct-drag.drag { transition: none; z-index: 5; filter: drop-shadow(0 8px 7px rgba(74, 38, 16, .35)); }
/* standing tablet: the field has room to spare, so the basket gets taller and what is inside stays big enough to pull out */
@media (orientation: portrait) { .ct-basket { height: clamp(170px, 36%, 400px); } }

@media (max-width: 520px) {
  .pg-top { gap: 5px; padding: 6px; }
  .pg-btn { padding: 8px 12px; font-size: 15px; }
  .pg-starpill { font-size: 15px; padding: 7px 9px; }
  .pg-dots i { width: 10px; height: 10px; }
  .pg-mode { min-width: 132px; flex: 1; padding: 10px 8px; }
  .pg-mi .c { width: 58px; height: 48px; }
  .pg-mi .g img { height: 18px; }
  .pg-mi-many img { height: 26px; }
  .pg-pick { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .mt-find, .ct-more { padding: 8px; gap: 8px; }
}
