/* Baby Animal Kingdom: the full-screen game (bak.js). Everything a child touches is big and round;
   words are few, because Kiki says them all aloud. Uses the site's colour tokens from site.css. */
body.in-game { overflow: hidden; }
.bak { position: fixed; inset: 0; z-index: 150; background: #BFE6FF; color: var(--ink); font-family: var(--body); overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.bak-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Top bar */
.bak-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; pointer-events: none; z-index: 3; }
.bak-top > * { pointer-events: auto; }
.bak-btn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: #fff; font-size: 1.6rem; cursor: pointer; box-shadow: 0 5px 0 rgba(0, 0, 0, .14); flex: none; display: grid; place-items: center; }
.bak-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .14); }
.bak-btn[aria-pressed="false"] { opacity: .6; }
.bak-btn[data-b="exit"] { margin-right: 4px; }
.bak-chip { display: flex; align-items: center; gap: 6px; height: 50px; padding: 0 16px 0 4px; border-radius: 999px; border: 0; background: #fff; font: 800 1.05rem var(--display); color: var(--ink); box-shadow: 0 5px 0 rgba(0, 0, 0, .14); cursor: pointer; max-width: 200px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bak-chip img { width: 42px; height: 42px; border-radius: 50%; background: var(--sun-soft); }
.bak-stars { margin-left: auto; display: flex; align-items: center; gap: 6px; height: 50px; padding: 0 18px; border-radius: 999px; background: #fff; font: 800 1.35rem var(--display); box-shadow: 0 5px 0 rgba(0, 0, 0, .14); }
.bak-stars b { min-width: 1.2em; }

/* Kiki's speech bubble */
.bak-bubble { position: absolute; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 72px); transform: translateX(-50%); width: min(620px, calc(100% - 20px)); display: flex; align-items: center; gap: 12px; padding: 10px 20px 10px 10px; background: #fff; border-radius: 26px; box-shadow: 0 6px 0 rgba(0, 0, 0, .12); z-index: 2; animation: bak-pop .3s ease; }
.bak-bubble img { width: 58px; height: 58px; border-radius: 50%; flex: none; border: 3px solid var(--sun); object-fit: cover; }
.bak-bubble p { margin: 0; font: 700 clamp(1.05rem, 2.6vw, 1.35rem)/1.25 var(--display); }

/* Choices: food and homes, big picture buttons along the bottom */
.bak-tray { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: clamp(12px, 3vw, 26px); z-index: 2; }
.bak-pick { width: clamp(104px, 24vw, 150px); aspect-ratio: 1; border-radius: 30px; border: 0; background: #fff; box-shadow: 0 7px 0 rgba(0, 0, 0, .15); cursor: pointer; padding: 6px; animation: bak-pop .35s ease backwards; }
.bak-pick:nth-child(2) { animation-delay: .08s; } .bak-pick:nth-child(3) { animation-delay: .16s; }
.bak-pick img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bak-pick:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }

/* The pointing hand that shows a child where to tap when they wait */
.bak-hand { position: absolute; left: 0; top: 0; font-size: 64px; z-index: 4; pointer-events: none; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .25)); }
.bak-hand::after { content: ""; }
.bak-hand:not([hidden]) { animation: bak-tap 1s ease-in-out infinite; }
@keyframes bak-tap { 0%, 100% { margin-top: 0; } 50% { margin-top: -18px; } }

/* Menus: profiles, level map, rewards, sticker book */
.bak-screen { position: absolute; inset: 0; display: grid; place-items: center; padding: 84px 14px 20px; overflow-y: auto; z-index: 1; }
.bak-card { width: min(720px, 100%); background: rgba(255, 255, 255, .94); border-radius: 34px; padding: 26px clamp(16px, 4vw, 34px) 30px; box-shadow: 0 10px 0 rgba(0, 0, 0, .1); display: grid; gap: 18px; justify-items: center; text-align: center; animation: bak-pop .35s ease; }
.bak-card h2, .bak-map h2 { margin: 0; font: 800 clamp(1.6rem, 5vw, 2.4rem)/1.05 var(--display); color: var(--purple-deep); }
.bak-small { margin: -6px 0 0; color: var(--ink-soft); font-size: .95rem; }
.bak-card.loading img { width: 110px; height: 110px; border-radius: 50%; border: 5px solid var(--sun); animation: bak-bob 1.2s ease-in-out infinite; }
.bak-bar { width: 220px; height: 16px; border-radius: 9px; background: var(--line); overflow: hidden; }
.bak-bar i { display: block; height: 100%; width: 4%; background: var(--teal); border-radius: 9px; transition: width .3s; }

.bak-kids { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.bak-kid { width: 140px; display: grid; gap: 6px; justify-items: center; padding: 12px 8px 14px; border-radius: 28px; border: 0; background: #fff; box-shadow: 0 6px 0 var(--line); cursor: pointer; font: 800 1.15rem var(--display); color: var(--ink); }
.bak-kid img { width: 100px; height: 100px; border-radius: 50%; background: var(--sun-soft); }
.bak-kid.new span { width: 100px; height: 100px; border-radius: 50%; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-text); font-size: 3rem; }
.bak-kid b { max-width: 124px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bak-link { border: 0; background: none; font: 700 1rem var(--body); color: var(--purple); text-decoration: underline; cursor: pointer; padding: 10px; }
.bak-name { width: min(340px, 100%); font: 800 1.5rem var(--display); text-align: center; padding: 12px 18px; border-radius: 20px; border: 3px solid var(--line); background: #fff; color: var(--ink); }
.bak-name:focus { outline: none; border-color: var(--purple); }
.bak-avatars { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.bak-av { width: 88px; height: 88px; border-radius: 50%; border: 5px solid transparent; background: var(--sun-soft); padding: 0; cursor: pointer; }
.bak-av img { width: 100%; height: 100%; border-radius: 50%; }
.bak-av[aria-pressed="true"] { border-color: var(--teal); transform: scale(1.06); }
.bak-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.bak-go { min-height: 68px; padding: 0 30px; border-radius: 999px; border: 0; background: var(--teal-text); color: #fff; font: 800 1.4rem var(--display); box-shadow: 0 6px 0 var(--teal-deep); cursor: pointer; }
.bak-go.light { background: #fff; color: var(--purple); box-shadow: 0 6px 0 var(--line); }
.bak-go:active, .bak-kid:active, .bak-level:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }

.bak-map { width: min(980px, 100%); display: grid; gap: 18px; justify-items: center; }
.bak-map h2 { color: #fff; text-shadow: 0 3px 0 rgba(40, 36, 59, .35), 0 0 22px rgba(40, 36, 59, .25); }
.bak-levels { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 2vw, 20px); }
.bak-level { position: relative; display: grid; justify-items: center; gap: 2px; padding: 12px 8px 14px; border-radius: 30px; border: 0; background: rgba(255, 255, 255, .95); box-shadow: 0 7px 0 rgba(0, 0, 0, .14); cursor: pointer; color: var(--ink); animation: bak-pop .35s ease backwards; }
.bak-level:nth-child(2) { animation-delay: .05s; } .bak-level:nth-child(3) { animation-delay: .1s; } .bak-level:nth-child(4) { animation-delay: .15s; } .bak-level:nth-child(5) { animation-delay: .2s; } .bak-level:nth-child(6) { animation-delay: .25s; }
.bak-level img { width: clamp(76px, 13vw, 120px); aspect-ratio: 1; }
.bak-level .num { position: absolute; left: 12px; top: 10px; width: 38px; height: 38px; border-radius: 50%; background: var(--purple); color: #fff; font: 800 1.3rem/38px var(--display); }
.bak-level .t { font: 800 clamp(1rem, 2.4vw, 1.3rem)/1.1 var(--display); }
.bak-level .st { font-size: 1.3rem; letter-spacing: 2px; color: var(--sun-deep); }
.bak-level.locked { filter: grayscale(1); opacity: .7; }
.bak-level.next { outline: 5px solid var(--sun); animation: bak-pop .35s ease backwards, bak-glow 1.6s ease-in-out .6s infinite; }
@keyframes bak-glow { 50% { outline-color: #fff; transform: scale(1.03); } }

.bak-bigstars { display: flex; gap: 10px; font-size: clamp(3rem, 12vw, 4.6rem); }
.bak-bigstars span { animation: bak-star .6s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.bak-bigstars span:nth-child(2) { animation-delay: .25s; } .bak-bigstars span:nth-child(3) { animation-delay: .5s; }
@keyframes bak-star { from { transform: scale(0) rotate(-90deg); } }
.bak-stickers { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.bak-stickers img { width: 84px; height: 84px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 var(--line); }
.bak-stickers img.new { outline: 4px solid var(--sun); animation: bak-star .6s cubic-bezier(.3, 1.6, .5, 1) .7s backwards; }

.bak-card.book { width: min(960px, 100%); align-self: start; }
.bak-book { width: 100%; display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.bak-sticker { aspect-ratio: 1; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 5px 0 var(--line); padding: 4px; cursor: pointer; }
.bak-sticker img { width: 100%; height: 100%; }
.bak-sticker.empty { background: var(--line); cursor: default; }
.bak-sticker.empty img { filter: brightness(0) opacity(.18); }
.bak-sticker.pop { animation: bak-star .5s cubic-bezier(.3, 1.6, .5, 1); }

@keyframes bak-pop { from { transform: scale(.7); opacity: 0; } }
@keyframes bak-bob { 50% { transform: translateY(-10px); } }
.bak-bubble[hidden], .bak-tray[hidden], .bak-screen[hidden], .bak-hand[hidden], .bak-top [hidden] { display: none; }

@media (max-width: 640px) {
  .bak-btn { width: 50px; height: 50px; font-size: 1.35rem; }
  .bak-top { gap: 7px; left: 8px; right: 8px; }
  .bak-chip { height: 44px; width: 44px; padding: 0 0 0 4px; font-size: 0; flex: none; } /* just the picture */
  .bak-chip img { width: 36px; height: 36px; }
  .bak-stars { height: 44px; padding: 0 12px; font-size: 1.15rem; }
  .bak-bubble { top: calc(max(8px, env(safe-area-inset-top)) + 60px); }
  .bak-bubble img { width: 48px; height: 48px; }
  .bak-screen { padding-top: 70px; }
  .bak-levels { grid-template-columns: repeat(2, 1fr); }
  .bak-book { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .bak-kid { width: 124px; } .bak-kid img, .bak-kid.new span { width: 88px; height: 88px; }
  .bak-av { width: 72px; height: 72px; }
}
@media (max-width: 430px) {
  .bak-top { gap: 5px; left: 6px; right: 6px; }
  .bak-btn { width: 44px; height: 44px; font-size: 1.2rem; }
  .bak-chip { height: 44px; width: 44px; }
  .bak-stars { padding: 0 10px; gap: 4px; }
}
/* Phones on their side: smaller buttons and cards, six levels in one row, two rows of stickers. */
@media (max-height: 500px) and (orientation: landscape) {
  .bak-top { top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); gap: 8px; }
  .bak-btn { width: 46px; height: 46px; font-size: 1.2rem; }
  .bak-chip, .bak-stars { height: 42px; }
  .bak-chip img { width: 34px; height: 34px; }
  .bak-stars { font-size: 1.1rem; padding: 0 12px; }
  .bak-bubble { top: calc(max(8px, env(safe-area-inset-top)) + 54px); width: min(560px, calc(100% - 20px)); padding: 6px 16px 6px 6px; }
  .bak-bubble img { width: 40px; height: 40px; }
  .bak-bubble p { font-size: 1.05rem; }
  .bak-pick { width: min(118px, 28vh); border-radius: 24px; }
  .bak-hand { font-size: 48px; }
  .bak-screen { padding: 116px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
  .bak-card { padding: 12px 18px 14px; gap: 10px; border-radius: 26px; }
  .bak-card h2 { font-size: 1.45rem; }
  .bak-map h2 { display: none; } /* Kiki says it; the levels need the room */
  .bak-levels { grid-template-columns: repeat(6, 1fr); gap: 8px; }
  .bak-level { padding: 8px 4px 10px; border-radius: 22px; }
  .bak-level img { width: 58px; }
  .bak-level .num { width: 28px; height: 28px; left: 6px; top: 6px; font-size: 1rem; line-height: 28px; }
  .bak-level .t { font-size: .85rem; }
  .bak-level .st { font-size: 1rem; }
  .bak-kid { width: 112px; padding: 8px 6px 10px; } .bak-kid img, .bak-kid.new span { width: 64px; height: 64px; }
  .bak-kid.new span { font-size: 2.2rem; }
  .bak-av { width: 56px; height: 56px; }
  .bak-name { font-size: 1.2rem; padding: 8px 14px; }
  .bak-go { min-height: 52px; font-size: 1.15rem; padding: 0 24px; }
  .bak-bigstars { font-size: 2.6rem; }
  .bak-stickers img { width: 56px; height: 56px; }
  .bak-card.book { align-self: center; }
  .bak-book { grid-template-columns: repeat(12, 1fr); gap: 6px; }
}
@media (max-width: 360px) { .bak-top [data-b="again"] { display: none; } }
@media (prefers-reduced-motion: reduce) { .bak *, .bak *::before { animation: none !important; transition: none !important; } }

/* On the Play & Learn page */
.bak-feature { display: grid; grid-template-columns: 1.15fr 1fr; background: #fff; border-radius: var(--r-lg); border: 2px solid var(--line); box-shadow: 0 6px 0 var(--line); overflow: hidden; margin-bottom: 26px; }
.bak-feature .pic { position: relative; background: #BFE6FF; min-height: 260px; }
.bak-feature .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bak-feature .new { position: absolute; left: 16px; top: 16px; padding: 6px 14px; border-radius: 999px; background: var(--coral-text); color: #fff; font: 800 .95rem var(--display); }
.bak-feature .txt { display: grid; gap: 12px; padding: 28px 30px 30px; align-content: center; }
.bak-feature h3 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.bak-feature .goal { font-size: var(--t-sm); color: var(--ink-soft); }
.bak-feature .goal b { color: var(--teal-text); }
.bak-feature .btn { justify-self: start; }
@media (max-width: 900px) { .bak-feature { grid-template-columns: 1fr; } .bak-feature .pic { aspect-ratio: 3 / 2; min-height: 0; } .bak-feature .txt { padding: 20px 20px 24px; } }

/* For grown-ups: each child's progress */
.kid-progress { display: grid; gap: 14px; }
.kp { background: #fff; border: 2px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; display: grid; gap: 10px; }
.kp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.kp-head b { font: 800 1.25rem var(--display); }
.kp-head small { color: var(--ink-soft); }
.kp-head .btn { margin-left: auto; }
.kp-levels { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.kp-levels li { padding: 4px 12px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); font-size: var(--t-sm); color: var(--ink-soft); }
.kp-levels li.done { background: var(--teal-soft); color: var(--teal-deep); border-color: transparent; font-weight: 700; }
.kp-acts { margin: 0; font-size: var(--t-sm); }
