/* Adventurer Bible Books Game */

body.bb {
  --lv: #D2242A;
  --lv-ink: #A21E24;
  --lv-soft: #FFF0F0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-size: clamp(16px, 0.5vw + 13px, 20px);
  background:
    radial-gradient(120% 60% at 50% 0%, var(--lv-soft) 0%, rgba(252, 246, 232, 0) 70%),
    url(../../assets/img/paper.webp) repeat,
    var(--cream);
  background-attachment: scroll, fixed, scroll;
  -webkit-tap-highlight-color: transparent;
}
.bb button { touch-action: manipulation; }
.bb [hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.bb-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(252, 246, 232, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.bb-top__title {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35em;
  color: var(--green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bb-top__tools { display: flex; gap: 8px; align-items: center; }
.bb-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--green);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95em;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(6, 60, 42, 0.12);
}
.bb-iconbtn svg { width: 24px; height: 24px; flex: none; }
/* On: the level's dark ink color (white icons on the light pink/yellow/orange level colors
   would be too faint). Off: white with a slashed icon. */
.bb-iconbtn[aria-pressed="true"] { background: var(--lv-ink); color: #fff; }
.bb-btnlabel { display: none; white-space: nowrap; }
@media (min-width: 1024px) { .bb-btnlabel { display: inline; } }
/* Hover tips for the icon-only buttons (mouse and trackpad only). */
@media (hover: hover) {
  .bb-iconbtn[data-tip] { position: relative; }
  .bb-iconbtn[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
  }
}
@media (hover: hover) and (min-width: 1024px) { .bb-labelbtn[data-tip]:hover::after { display: none; } }
/* Phones: back + title + Music, Sounds, Home share ~360–430 px, every button a full 48 px
   touch target. The title may wrap onto a second line rather than be cut short. */
@media (max-width: 480px) {
  .bb-top { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .bb-top__tools { gap: 9px; }
  .bb-top__title {
    font-size: 1.05em;
    line-height: 1.1;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow-wrap: break-word;
  }
  .bb-iconbtn { min-width: 48px; height: 48px; padding: 0 10px; }
  .bb-iconbtn svg { width: 22px; height: 22px; }
}
/* The narrowest phones (360 px): a little more room for a two-line title. */
@media (max-width: 374px) {
  .bb-top { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .bb-top__tools { gap: 8px; }
  .bb-top__title { font-size: 0.92em; }
}

/* ---------- Main + screens ---------- */
.bb-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 8px 16px 120px;
  outline: none;
}
.bb-screen { animation: bb-in 0.3s ease; }
/* The first moment of a new screen ignores taps (the second tap of a double tap; see screen()). */
.bb-main.bb-entering { pointer-events: none; }
.bb-h1 {
  font-size: clamp(1.8em, 1.3em + 1.6vw, 2.6em);
  margin: 6px 0 4px;
}
.bb-sub { margin: 0 0 12px; color: var(--muted); font-size: 1.05em; }
.bb-label { display: block; margin: 18px 0 8px; font-family: var(--font-display); font-weight: 600; font-size: 1.2em; color: var(--green); }
.bb-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.bb-row--center { justify-content: center; }
.bb-name { width: min(420px, 100%); font-size: 1.4em; padding: 0.55em 0.9em; }
/* The main button of a screen, in the class's dark shade: cream text on the light class colors
   (Little Lamb pink, Busy Bee yellow, Sunbeam orange) was too faint to read. */
.bb-go { --btn-bg: var(--lv-ink); --btn-edge: color-mix(in srgb, var(--lv-ink) 62%, #000); }
/* An emoji on a button (in color everywhere, not the text glyph some fonts have). */
.bb-btnemoji { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; font-size: 1.1em; line-height: 1; }
.bb-go:disabled { opacity: 0.4; }
.bb-pic { display: inline-grid; place-items: center; }
.bb-pic svg { width: 100%; height: 100%; display: block; }
.bb-pic img { width: 100%; height: 100%; display: block; object-fit: contain; border-radius: 14px; user-select: none; }
.bb-pic img.bb-logo { border-radius: 0; }
.bb-pic img.bb-photo { aspect-ratio: 1 / 1; height: auto; object-fit: cover; object-position: center 30%; border-radius: 18px; border: 3px solid #1E2B45; }
.bb-pic img.bb-photo--char { border-radius: 50%; object-position: center; }
.bb-pic img.bb-photo--section, .bb-pic img.bb-photo--testament, .bb-pic img.bb-photo--activity { object-position: center; border-radius: 22%; }
.bb-pic img.bb-photo--activity { border: 0; box-shadow: 0 4px 12px rgba(6, 60, 42, 0.15); }

/* ---------- Pico, the club mascot: mascotHtml() in bb-app.js ----------
   His main picture (img/pico/pico.webp, a see-through cut-out with a soft ground shadow)
   moves a little for each pose until the club supplies that pose's own picture
   (img/pico/<pose>.webp, a clean cut-out), which then shows as it is, without motion. The
   motions turn around his feet, so he stays on his spot; reduced motion turns them off.
   Every slot shows the whole picture (object-fit: contain): head feathers, wing tips and feet.
   Light surfaces only (cream, white, the pale green answer box): the main picture's soft
   ground shadow shows as a pale patch on mid or dark colours. For such a place, ask the club
   for a cut-out without the shadow; never edit his pixels. */
.bb-mascot {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 50% 94%;
}
.bb-mascot--sway { animation: bb-pico-sway 3.2s ease-in-out infinite; }      /* wave */
.bb-mascot--hop { animation: bb-pico-hop 0.7s ease-in-out 3; }               /* cheer, thumbsup, medal */
.bb-mascot--tilt { animation: bb-pico-tilt 4.4s ease-in-out infinite; }      /* think, peek */
.bb-mascot--wiggle { animation: bb-pico-wiggle 0.6s ease; }                   /* oops */
.bb-mascot--lean { animation: bb-pico-lean 0.45s ease-out forwards; }         /* listen */
.bb-mascot--bob { animation: bb-pico-bob 3.4s ease-in-out infinite; }        /* every other pose */
@keyframes bb-pico-sway { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
/* (Up and down only: his picture is never squashed or stretched.) */
@keyframes bb-pico-hop {
  0%, 70%, 100% { transform: translateY(0); }
  45% { transform: translateY(-5%); }
  85% { transform: translateY(-1.5%); }
}
@keyframes bb-pico-tilt { 0%, 80%, 100% { transform: rotate(0deg); } 20%, 60% { transform: rotate(-6deg); } }
@keyframes bb-pico-wiggle {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(7deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(2deg); }
}
@keyframes bb-pico-lean { to { transform: translateX(3%) rotate(5deg); } }
@keyframes bb-pico-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3%); } }
@media (prefers-reduced-motion: reduce) {
  .bb-mascot { animation: none !important; }
}

/* ---------- Golden medals (class badges, stickers): medalHtml() in bb-app.js ----------
   The SVG (.bb-medal__art) draws the ribbon, rim, laurel and disc; the class logo, picture
   or emoji sits in .bb-medal__face on top; .bb-medal__shine sweeps light across an earned
   medal. The box sets the size (or medalHtml's `size`). */
.bb-medal {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
}
.bb-medal__art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.bb-medal:not(.bb-medal--mini) .bb-medal__art { filter: drop-shadow(0 3px 5px rgba(90, 60, 0, 0.22)); }
.bb-medal:not(.bb-medal--mini):not(.is-earned) .bb-medal__art { filter: drop-shadow(0 2px 4px rgba(60, 55, 45, 0.14)); }
.bb-medal__face {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
}
.bb-medal__face img { width: 90%; height: 90%; object-fit: contain; pointer-events: none; }
.bb-medal--mini .bb-medal__face img { width: 96%; height: 96%; }
/* An emoji in the middle grows with the medal (its box sets the medal's size). */
.bb-medal__emoji { font-size: 1.9em; line-height: 1; }
.bb-medal--emoji { container-type: inline-size; }
.bb-medal--emoji .bb-medal__emoji { font-size: 30cqw; }
.bb-medal--emoji.bb-medal--mini .bb-medal__emoji { font-size: 44cqw; }
.bb-medal:not(.is-earned) .bb-medal__face img,
.bb-medal:not(.is-earned) .bb-medal__emoji { filter: grayscale(1) contrast(0.85); opacity: 0.5; }
/* The lock on a medal not earned yet: small, round and friendly. */
.bb-medal__lock {
  position: absolute;
  display: grid;
  place-items: center;
  width: 15%;
  height: 15%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #FFFFFF;
  color: #8E897F;
  box-shadow: 0 0 0 2px #D9D5CC, 0 2px 5px rgba(60, 55, 45, 0.2);
}
.bb-medal__lock svg { width: 62%; height: 62%; }
/* The shine: a soft band of light that sweeps across now and then. */
.bb-medal__shine { position: absolute; border-radius: 50%; overflow: hidden; pointer-events: none; }
.bb-medal__shine::before {
  content: '';
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: -60%;
  width: 45%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.75) 50%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-120%) skewX(-16deg);
  animation: bb-medal-shine 5.5s ease-in-out 0.6s infinite;
}
.bb-medal--mini .bb-medal__shine::before { animation-duration: 7s; animation-delay: 1.2s; }
.bb-medal__twinkle { transform-box: fill-box; transform-origin: center; animation: bb-medal-twinkle 2.8s ease-in-out infinite; }
.bb-medal__twinkle--2 { animation-delay: 1.3s; }
@keyframes bb-medal-shine {
  0% { transform: translateX(-120%) skewX(-16deg); }
  22%, 100% { transform: translateX(420%) skewX(-16deg); }
}
@keyframes bb-medal-twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.55); }
  50% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .bb-medal__shine { display: none; }
  .bb-medal__twinkle { animation: none; opacity: 0.85; }
}
/* A medal written without the SVG (older markup): a gold disc in CSS. */
.bb-medal:not(.has-art)::before {
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background:
    radial-gradient(circle, #FFFBEA 0 56%, rgba(0, 0, 0, 0) 57%),
    radial-gradient(circle, #9C6A00 0 61%, rgba(0, 0, 0, 0) 62%),
    conic-gradient(from 200deg, #FFF7CC, #F6C928 15%, #D39A0C 32%, #FFE58A 50%, #D39A0C 68%, #9C6A00 84%, #FFF7CC);
  box-shadow: inset 0 0 0 2px #7A5200, 0 3px 8px rgba(90, 60, 0, 0.28);
}
.bb-medal:not(.has-art):not(.is-earned)::before {
  background:
    radial-gradient(circle, #FCFBF8 0 56%, rgba(0, 0, 0, 0) 57%),
    radial-gradient(circle, #A39E94 0 61%, rgba(0, 0, 0, 0) 62%),
    conic-gradient(from 200deg, #FAF9F6, #DEDAD2 20%, #C3BEB4 45%, #EEEBE4 60%, #A39E94 85%, #FAF9F6);
  box-shadow: inset 0 0 0 2px #8E897F;
}
.bb-medal:not(.has-art) > * { position: relative; }
.bb-medal:not(.has-art) img { width: 70%; height: 70%; object-fit: contain; }
.bb-medal:not(.has-art):not(.is-earned) img { filter: grayscale(1); opacity: 0.5; }

/* ---------- Players ---------- */
.bb-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.bb-player {
  position: relative;
  display: flex;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(6, 60, 42, 0.1);
  overflow: hidden;
}
.bb-player__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px 16px;
  border: 0;
  background: linear-gradient(to bottom, var(--lv-soft), transparent 70%);
  color: inherit;
}
.bb-player__emblem { width: 96px; height: 96px; }
.bb-player__name { font-family: var(--font-display); font-weight: 700; font-size: 1.5em; color: var(--green); }
.bb-player__class { color: var(--lv-ink); font-weight: 800; }
.bb-player--add {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  border: 3px dashed rgba(6, 60, 42, 0.25);
  background: transparent;
  box-shadow: none;
  color: var(--green);
}
.bb-player__plus { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--yellow); }
.bb-player__plus svg { width: 40px; height: 40px; }
.bb-confirm { margin-top: 18px; padding: 16px 18px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); text-align: center; }

/* ---------- Class picker ---------- */
.bb-classes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.bb-class {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  border: 4px solid transparent;
  border-radius: 22px;
  background: var(--lv-soft);
  color: var(--lv-ink);
  transition: transform 0.15s ease, border-color 0.15s;
}
.bb-class:hover { transform: translateY(-2px); }
.bb-class[aria-checked="true"] { border-color: var(--lv); background: #fff; box-shadow: 0 6px 20px rgba(6, 60, 42, 0.15); transform: scale(1.03); }
.bb-class__emblem { width: 112px; height: 112px; }
.bb-class__name { font-family: var(--font-display); font-weight: 700; font-size: 1.2em; }
.bb-class__age { font-weight: 700; font-size: 0.9em; opacity: 0.8; }

/* ---------- Map ---------- */
.bb-hello { display: flex; align-items: center; gap: 14px; }
.bb-hello__emblem { width: 84px; height: 84px; flex: none; }
.bb-levels { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; margin: 8px -2px 4px; scrollbar-width: thin; }
.bb-level {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 6px;
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--lv-soft);
  color: var(--lv-ink);
  font-family: var(--font-display);
  font-weight: 600;
  white-space: nowrap;
}
.bb-level__emblem { width: 44px; height: 44px; }
.bb-level[aria-checked="true"] { border-color: var(--lv); background: #fff; box-shadow: 0 4px 12px rgba(6, 60, 42, 0.14); }
.bb-level.is-mine::after { content: '★'; margin-left: 2px; color: var(--yellow); text-shadow: 0 0 1px var(--lv-ink); }
.bb-level__check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(150deg, #FFF0A8, #F4C127 45%, #C98A08);
  color: #5E3E00;
  box-shadow: inset 0 0 0 1.5px #8A5C00, 0 1px 3px rgba(122, 82, 0, 0.35);
}
.bb-level__check svg { width: 14px; height: 14px; }

.bb-acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 8px; }
.bb-act {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px 14px;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--green);
  box-shadow: 0 4px 16px rgba(6, 60, 42, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bb-act:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(6, 60, 42, 0.16); }
.bb-act:active { transform: scale(0.98); }
.bb-act__num {
  position: absolute;
  top: 10px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--lv-soft);
  color: var(--lv-ink);
  font-family: var(--font-display);
  font-weight: 700;
}
.bb-act.is-done .bb-act__num { background: var(--lv); color: #fff; }
.bb-act__pic { width: min(120px, 70%); aspect-ratio: 1; }
.bb-act__name { font-family: var(--font-display); font-weight: 700; font-size: 1.15em; line-height: 1.1; text-align: center; }
.bb-act__stars, .bb-result__stars { display: flex; gap: 2px; }
.bb-act__stars svg { width: 26px; height: 26px; }
.bb-act__stars svg.on, .bb-result__stars svg.on { fill: var(--yellow); stroke: #B48E0C; stroke-width: 1.2; }
.bb-act__stars svg.off, .bb-result__stars svg.off { fill: #E8E2D2; stroke: none; }
.bb-map-tools .pw-btn { font-size: 1.05em; }
.bb-mini-medal { position: relative; display: inline-block; flex: none; width: 34px; height: 34px; margin-right: 8px; vertical-align: middle; }
.bb-mini-medal__count {
  position: absolute;
  top: -7px;
  right: -9px;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--lv-ink);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}

/* ---------- Questions ---------- */
.bb-dots { display: flex; justify-content: center; gap: 8px; margin: 4px 0 10px; }
.bb-dots i { width: 14px; height: 14px; border-radius: 50%; background: #E8E2D2; }
.bb-dots i.done { background: var(--lv); }
.bb-dots i.now { background: var(--yellow); box-shadow: 0 0 0 3px rgba(246, 201, 40, 0.35); }

.bb-q__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(6, 60, 42, 0.08);
}
.bb-q__pic { width: clamp(110px, 18vw, 170px); aspect-ratio: 1; flex: none; }
.bb-q__text { flex: 1; min-width: 0; }
.bb-q__prompt { font-size: clamp(1.4em, 1.1em + 1vw, 2em); line-height: 1.15; }
.bb-q__sub { margin: 4px 0 0; color: var(--lv-ink); font-weight: 800; font-size: 1.05em; }
.bb-speak {
  flex: none;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--lv);
  color: #fff;
  box-shadow: 0 4px 0 var(--lv-ink);
}
.bb-speak svg { width: 30px; height: 30px; }
.bb-speak:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--lv-ink); }
.bb-clues { margin: 8px 0 0; padding-left: 1.4em; font-size: 1.15em; font-weight: 700; color: var(--green); }
.bb-clues li { margin: 4px 0; }
.bb-clues li.is-new { animation: bb-in 0.35s ease; }
.bb-more { margin-top: 4px; }

.bb-options { display: grid; gap: 14px; margin-top: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bb-options--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bb-options--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bb-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 84px;
  padding: 14px 12px;
  border: 4px solid transparent;
  border-radius: 24px;
  background: var(--paper);
  color: var(--green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35em;
  line-height: 1.1;
  box-shadow: 0 5px 0 rgba(6, 60, 42, 0.14), 0 6px 18px rgba(6, 60, 42, 0.08);
  transition: transform 0.12s ease, opacity 0.2s, border-color 0.15s;
}
.bb-opt:hover { transform: translateY(-2px); border-color: var(--lv-soft); }
.bb-opt:active { transform: translateY(3px); }
.bb-opt__pic { width: clamp(96px, 20vw, 170px); aspect-ratio: 1; }
.bb-options--small .bb-opt__pic { width: 72px; }
.bb-options--big .bb-opt { min-height: 200px; }
.bb-options--big .bb-opt__pic { width: clamp(130px, 28vw, 220px); }
.bb-options--testament .bb-opt__pic { width: clamp(90px, 16vw, 140px); }
.bb-opt.is-right { border-color: #0C8A4A; background: #E6F6EC; animation: bb-bounce 0.5s var(--ease-out-back); }
.bb-opt.is-right::after {
  content: '';
  position: absolute;
  top: -12px;
  right: -12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0C8A4A url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 70% no-repeat;
  box-shadow: 0 0 0 4px #fff;
}
.bb-opt.is-wrong { opacity: 0.45; animation: bb-wiggle 0.45s ease; }
.bb-opt.is-faded { opacity: 0.4; }
.bb-opt.is-hint { border-color: var(--yellow); animation: bb-glow 1.2s ease-in-out infinite; }
.bb-opt:disabled { cursor: default; }

/* Shelf (Find the Missing Book) */
.bb-shelf { margin-top: 16px; padding: 12px; border-radius: 22px; background: #E9D3B2; box-shadow: inset 0 -10px 0 #C9A57A; }
.bb-shelf__row { display: flex; align-items: flex-end; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 6px 0 12px; }
.bb-shelf__row + .bb-shelf__row { border-top: 8px solid #C9A57A; padding-top: 12px; }
.bb-shelf__label { flex-basis: 100%; text-align: center; font-weight: 800; color: #6B4423; font-size: 0.95em; }
.bb-book {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: clamp(76px, 15vw, 128px);
  min-height: 110px;
  padding: 8px 6px 10px;
  border-radius: 12px 12px 6px 6px;
  border: 3px solid #1E2B45;
  background: #FFFBF0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--green);
  text-align: center;
  line-height: 1.05;
}
.bb-book--ot { background: #FFF1D6; }
.bb-book--nt { background: #E3F0FB; }
.bb-book__pic { width: 80%; aspect-ratio: 1; }
.bb-book__name { font-size: 0.95em; overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.bb-book--gap { border-style: dashed; background: rgba(255, 255, 255, 0.5); justify-content: center; font-size: 2.6em; color: var(--lv); animation: bb-glow 1.4s ease-in-out infinite; }
.bb-book--filled { animation: bb-bounce 0.5s var(--ease-out-back); border-color: #0C8A4A; }

/* Order */
.bb-slots { display: grid; gap: 10px; margin-top: 16px; }
.bb-slots__row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.bb-slots__label { flex-basis: 100%; text-align: center; font-weight: 800; color: var(--lv-ink); }
.bb-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(120px, 21vw, 200px);
  min-height: 92px;
  border: 3px dashed rgba(6, 60, 42, 0.3);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
}
.bb-slots--vertical .bb-slots__row { flex-direction: column; align-items: stretch; }
.bb-slots--vertical .bb-slot { width: 100%; min-height: 60px; }
.bb-slots--rows .bb-slot { width: clamp(110px, 20vw, 180px); min-height: 70px; }
.bb-slot__n {
  position: absolute;
  top: -12px;
  left: -10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--lv);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
}
.bb-slot.is-filled { border-style: solid; border-color: #0C8A4A; background: #E6F6EC; }
.bb-slot__item { font-family: var(--font-display); font-weight: 700; font-size: 1.1em; color: var(--green); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; animation: bb-bounce 0.45s var(--ease-out-back); }
.bb-tray { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }
.bb-tray--vertical { flex-direction: column; align-items: stretch; }
.bb-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 120px;
  min-height: 64px;
  padding: 10px 16px;
  border: 4px solid transparent;
  border-radius: 20px;
  background: var(--paper);
  color: var(--green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2em;
  box-shadow: 0 5px 0 rgba(6, 60, 42, 0.14), 0 6px 18px rgba(6, 60, 42, 0.08);
  transition: opacity 0.2s, transform 0.15s;
}
.bb-tile:hover { transform: translateY(-2px); }
.bb-tile.has-pic { padding: 8px; }
.bb-tile__pic { width: clamp(90px, 16vw, 140px); aspect-ratio: 1; }
.bb-slot .bb-tile__pic { width: clamp(70px, 12vw, 110px); }
.bb-tile__label { line-height: 1.15; text-align: center; }
.bb-tile.is-placed { visibility: hidden; }
.bb-tile.is-wrong { animation: bb-wiggle 0.45s ease; }
.bb-tile.is-hint { border-color: var(--yellow); animation: bb-glow 1.2s ease-in-out infinite; }

/* Order: pick on the left, shelf on the right */
.bb-order { display: grid; gap: 16px; margin-top: 16px; }
.bb-order__col { min-width: 0; padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, 0.55); }
.bb-order__shelf { background: var(--lv-soft); }
.bb-order__label { margin: 0 0 8px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 1.1em; color: var(--lv-ink); }
.bb-order .bb-slots, .bb-order .bb-tray { margin-top: 0; }
@media (min-width: 761px) {
  .bb-order { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .bb-order .bb-tray { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 10px; }
  .bb-order .bb-tile { width: 100%; }
  .bb-order .bb-tile.has-pic { flex-direction: row; justify-content: flex-start; gap: 14px; text-align: left; }
  .bb-order .bb-tile.has-pic .bb-tile__pic { width: 84px; flex: none; }
  .bb-order .bb-slots__row { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 10px; }
  .bb-order .bb-slot { width: 100%; min-height: 64px; place-items: center start; padding-left: 34px; }
  .bb-order .bb-slot__n { top: 50%; left: -12px; transform: translateY(-50%); }
  .bb-order .bb-slot__item { flex-direction: row; gap: 14px; padding: 6px; }
  .bb-order .bb-slot .bb-tile__pic { width: 84px; }
  .bb-order .bb-tile.is-placed { display: none; }
  .bb-order .bb-tray--many { display: grid; grid-template-columns: 1fr 1fr; }
  .bb-order .bb-slots--rows { grid-template-columns: 1fr 1fr; gap: 12px; }
  .bb-order .bb-slots--rows .bb-slot { width: 100%; }
}
/* Story sequence steps with pictures (Builder, Helping Hand): picture beside the words. */
.bb-order--steps .bb-tile.has-pic { flex-direction: row; justify-content: flex-start; gap: 12px; text-align: left; }
.bb-order--steps .bb-tile__pic { width: 72px; flex: none; }
.bb-order--steps .bb-tile__label { text-align: left; }
.bb-order--steps .bb-slot { place-items: center start; padding-left: 24px; }
.bb-order--steps .bb-slot__item { flex-direction: row; gap: 12px; text-align: left; padding: 6px; }
.bb-order--steps .bb-slot .bb-tile__pic { width: 60px; }
.bb-order--steps .bb-tile.is-placed { display: none; }
@media (min-width: 761px) {
  .bb-order--steps .bb-tile__pic { width: 84px; }
  .bb-order--steps .bb-slot .bb-tile__pic { width: 72px; }
}

/* Match */
/* Both columns are the same height and their cards share it equally, so each
   left card sits level with a right card and nothing is left hanging. */
.bb-match { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; gap: 14px 22px; margin-top: 16px; }
.bb-match__col { display: grid; grid-auto-rows: 1fr; gap: 12px; }
.bb-mcard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 76px;
  padding: 10px 14px;
  border: 4px solid transparent;
  border-radius: 20px;
  background: var(--paper);
  color: var(--green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15em;
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 5px 0 rgba(6, 60, 42, 0.14), 0 6px 18px rgba(6, 60, 42, 0.08);
}
.bb-mcard.has-pic { flex-direction: column; }
.bb-mcard__pic { width: clamp(84px, 16vw, 140px); aspect-ratio: 1; }
.bb-match--mixed .bb-mcard.has-pic { flex-direction: row; justify-content: flex-start; gap: 14px; text-align: left; padding: 8px 14px 8px 8px; }
.bb-match--mixed .bb-mcard__pic { width: clamp(64px, 9vw, 96px); flex: none; }
.bb-mcard.is-selected { border-color: var(--lv); transform: scale(1.03); box-shadow: 0 0 0 4px var(--lv-soft), 0 8px 22px rgba(6, 60, 42, 0.16); }
.bb-mcard.is-matched { border-color: var(--m, #0C8A4A); background: color-mix(in srgb, var(--m, #0C8A4A) 12%, white); animation: bb-bounce 0.45s var(--ease-out-back); }
.bb-mcard.is-wrong { animation: bb-wiggle 0.45s ease; }

/* Flashcards */
.bb-flip__row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.bb-flip__stage { perspective: 1400px; }
.bb-card {
  display: block;
  width: clamp(240px, 46vw, 420px);
  height: clamp(320px, 52vh, 460px);
  padding: 0;
  border: 0;
  background: none;
}
.bb-card__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.6s var(--ease-out-back);
  transform-style: preserve-3d;
}
.bb-card.is-flipped .bb-card__inner { transform: rotateY(180deg); }
.bb-card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 18px;
  border: 5px solid var(--lv);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(6, 60, 42, 0.16);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  color: var(--green);
  text-align: center;
}
.bb-card__back { transform: rotateY(180deg); background: var(--lv-soft); }
.bb-card--ot .bb-card__front { background: linear-gradient(#FFF7E6, #FFFBF0); }
.bb-card--nt .bb-card__front { background: linear-gradient(#EAF4FB, #FFFFFF); }
.bb-card__pic { width: min(64%, 220px); aspect-ratio: 1; }
.bb-card__pic--small { width: min(40%, 130px); }
.bb-card__name { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.8em, 1.4em + 1.2vw, 2.6em); line-height: 1.05; }
.bb-card__text { margin: 0; font-size: 1.2em; font-weight: 700; line-height: 1.3; }
.bb-card__ref { margin: 0; color: var(--lv-ink); font-weight: 800; }
.bb-card__hint { color: var(--muted); font-weight: 700; font-size: 1em; }
.bb-card__tag { padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 0.9em; }
.bb-card__tag--ot { background: #FFE2B8; color: #7E3C00; }
.bb-card__tag--nt { background: #D2E8F6; color: #065490; }
.bb-flip__count { text-align: center; color: var(--muted); font-weight: 700; margin: 12px 0 0; }
.bb-navbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: var(--lv);
  color: #fff;
  box-shadow: 0 5px 0 var(--lv-ink);
}
.bb-navbtn svg { width: 32px; height: 32px; }
.bb-navbtn:disabled { opacity: 0.3; }

/* Feedback after a right answer */
.bb-feedback {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 24px;
  background: #E6F6EC;
  border: 3px solid #0C8A4A;
  animation: bb-in 0.35s ease;
}
.bb-feedback__pico { width: 84px; height: 84px; flex: none; }
.bb-feedback__text { flex: 1; min-width: 0; }
.bb-feedback__text strong { font-family: var(--font-display); font-size: 1.6em; color: #075C31; }
.bb-feedback__text p { margin: 4px 0 0; font-size: 1.1em; font-weight: 600; color: var(--green); }
.bb-feedback__note { color: var(--lv-ink) !important; font-size: 1em !important; }
.bb-next { --btn-bg: #0C8A4A; --btn-edge: #075C31; flex: none; }

/* Results + badges */
.bb-result { text-align: center; padding-top: 10px; }
.bb-result__pico { display: block; width: 160px; height: 160px; margin: 0 auto; }
.bb-result__stars { justify-content: center; margin: 10px 0; }
.bb-result__stars svg { width: 72px; height: 72px; animation: bb-star 0.6s var(--ease-out-back) both; }
.bb-badges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 10px; }
.bb-badge {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px 14px;
  border: 3px solid transparent;
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(6, 60, 42, 0.08);
  color: var(--green);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bb-badge:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(6, 60, 42, 0.14); }
.bb-badge.is-earned {
  border-color: #F3DC9C;
  background: radial-gradient(90% 70% at 50% 28%, #FFF5D1 0%, rgba(255, 245, 209, 0) 70%), var(--card);
  box-shadow: 0 6px 20px rgba(156, 106, 0, 0.16);
}
.bb-badge__medal { width: clamp(118px, 30vw, 156px); aspect-ratio: 1; }
.bb-badge.is-earned .bb-badge__medal { animation: bb-bob 3s ease-in-out infinite; }
.bb-badge__name { font-family: var(--font-display); font-weight: 700; font-size: 1.2em; text-align: center; line-height: 1.1; }
.bb-badge__info { color: var(--lv-ink); font-weight: 800; }
.bb-badge.is-earned .bb-badge__info {
  padding: 2px 12px;
  border-radius: 999px;
  background: linear-gradient(#FFE58A, #F6C928);
  color: #6B4700;
  box-shadow: inset 0 -2px 0 rgba(156, 106, 0, 0.35);
}
.bb-badge__progress { display: flex; gap: 5px; margin: 2px 0; }
.bb-badge__progress i { width: 10px; height: 10px; border-radius: 50%; background: #E8E2D2; }
.bb-badge__progress i.on { background: var(--lv); }
.bb-badge__stars { color: #9C6A00; font-weight: 800; }
/* A row of earned mini medals on a player card. */
.bb-player__medals { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 4px; }
.bb-player__medals .bb-medal { flex: none; }
/* (above the confetti layer, .pw-confetti z-index 140: no stars over "New badge!" or its button) */
.bb-award {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 40, 28, 0.45);
  animation: bb-in 0.3s ease;
}
.bb-award__card {
  width: min(440px, 100%);
  padding: 22px 24px 24px;
  border-radius: 28px;
  border: 3px solid #F3DC9C;
  background: radial-gradient(80% 55% at 50% 22%, #FFF2C2 0%, rgba(255, 242, 194, 0) 75%), var(--card);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.bb-award__badge { position: relative; display: block; width: 220px; height: 220px; margin: 0 auto; animation: bb-bounce 0.8s var(--ease-out-back); }
.bb-award__badge > .bb-medal { position: relative; z-index: 1; }
/* Pico stands at the badge's side (in front of its rays), as big as a celebration allows. */
.bb-award__stage { display: flex; align-items: flex-end; justify-content: center; margin: 0 auto; }
.bb-award__stage .bb-award__badge { margin: 0; }
.bb-award__pico { position: relative; z-index: 2; flex: none; width: 116px; height: 116px; margin: 0 -10px 0 -18px; }
/* … and he is the only Pico at the badge: the results screen's Pico behind the card hides
   while it is open (body.bb-awarding, showBadgeAward() in bb-app.js); the guide bar's stays. */
.bb-awarding .bb-result__pico { visibility: hidden; }
@media (max-width: 760px) {
  .bb-award__badge { width: 180px; height: 180px; }
  .bb-award__pico { width: 96px; height: 96px; margin-left: -10px; }
}
/* Soft golden rays behind the new badge. */
.bb-award__rays {
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(246, 201, 40, 0.34) 0deg 9deg, rgba(246, 201, 40, 0) 9deg 22.5deg);
  -webkit-mask: radial-gradient(circle, #000 28%, rgba(0, 0, 0, 0) 70%);
  mask: radial-gradient(circle, #000 28%, rgba(0, 0, 0, 0) 70%);
  animation: bb-rays 24s linear infinite;
}
@keyframes bb-rays { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bb-award__rays { animation: none; } }

/* ---------- Pico's guide bar: Pico and his speech bubble ---------- */
.bb-guide {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 92px;
  padding: 0 16px max(0px, env(safe-area-inset-bottom));
  background: rgba(252, 246, 232, 0.86);
  box-shadow: 0 -4px 16px rgba(6, 60, 42, 0.08);
}
.bb-guide__pico {
  flex: none;
  width: 96px;
  height: 96px;
  margin-top: -18px;
  padding: 0;
  border: 0;
  background: none;
}
.bb-guide__bubble {
  position: relative;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 20px 20px 20px 4px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(6, 60, 42, 0.16);
}
.bb-guide__text { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.1em; color: var(--green); }
.bb-guide.is-pop .bb-guide__bubble { animation: bb-pop 0.4s var(--ease-out-back); }

@keyframes bb-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bb-pop { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: none; } }
@keyframes bb-bounce { 0% { transform: scale(0.85); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes bb-wiggle { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes bb-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(246, 201, 40, 0.7); } 50% { box-shadow: 0 0 0 10px rgba(246, 201, 40, 0); } }
@keyframes bb-star { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
@keyframes bb-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .bb-acts, .bb-badges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bb-classes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bb-options--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bb-options--3 .bb-opt:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .bb-q__head { flex-wrap: wrap; }
  .bb-q__pic { width: 120px; }
  .bb-speak { width: 52px; height: 52px; }
  .bb-feedback { flex-wrap: wrap; }
  .bb-feedback__pico { width: 72px; height: 72px; }
  .bb-feedback .bb-next { width: 100%; }
  .bb-main { padding-bottom: 96px; }
  .bb-guide { height: 76px; padding-left: 8px; padding-right: 8px; }
  .bb-guide__pico { width: 72px; height: 72px; margin-top: -12px; }
  .bb-guide__bubble { padding: 8px 12px; }
  .bb-guide__text { font-size: 0.95em; }
  .bb-shelf { padding: 10px 6px; }
  .bb-shelf__row { gap: 6px; }
  .bb-book { width: calc((100% - 18px) / 4); min-height: 80px; padding: 6px 2px 8px; }
  .bb-book__name { font-size: 0.72em; }
  .bb-slots__row { gap: 8px; }
  .bb-slots--rows .bb-slot, .bb-slot { width: calc((100% - 24px) / 4); min-height: 56px; }
  .bb-slots--vertical .bb-slot { width: 100%; }
  .bb-slot .bb-tile__label { font-size: 0.8em; }
  .bb-slots:not(.bb-slots--rows):not(.bb-slots--vertical) .bb-slots__row { flex-wrap: wrap; }
  .bb-slots:not(.bb-slots--rows):not(.bb-slots--vertical) .bb-slot { width: calc((100% - 16px) / 3); }
  .bb-navbtn { width: 52px; height: 52px; }
  .bb-card { width: calc(100vw - 160px); height: 360px; }
  .bb-match { gap: 10px; }
  .bb-mcard { font-size: 1em; padding: 8px; }
}

/* ==================================================================== */
/* UI: Grown-ups settings, celebration, touch and focus                 */
/* ==================================================================== */

/* Keyboard focus: a dark ring that shows on cream, white and colored buttons alike
   (the site's yellow ring is too faint on the cream paper). */
.bb :focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

/* Every button a child or a grown-up taps is at least 48 px tall. */
.bb .pw-btn { min-height: 48px; }

/* Player cards: the big "play" button, then the Grown-ups button apart from it. */
.bb-player { flex-direction: column; }
.bb-player__foot { display: flex; justify-content: center; padding: 0 12px 12px; }

/* Grown-ups button: press and hold (the bar along the bottom fills), a quick tap shows a hint. */
.bb-grownups {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px 0 14px;
  border: 2px solid rgba(6, 60, 42, 0.16);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.bb-grownups svg { width: 22px; height: 22px; flex: none; }
.bb-grownups:hover { color: var(--green); border-color: rgba(6, 60, 42, 0.3); }
.bb-grownups::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 5px;
  height: 4px;
  border-radius: 2px;
  background: var(--lv);
  transform: scaleX(0);
  transform-origin: left center;
}
.bb-grownups.is-holding { color: var(--green); border-color: var(--lv); }
.bb-grownups.is-holding::after { transform: scaleX(1); transition: transform 1.5s linear; }
.bb-grownups.is-holding svg { animation: bb-spin 1.5s linear; }
.bb-grownups__hint { display: none; }
.bb-grownups.is-hint { color: var(--green); border-color: var(--yellow); background: var(--yellow-soft); }
.bb-grownups.is-hint .bb-grownups__label { display: none; }
.bb-grownups.is-hint .bb-grownups__hint { display: inline; }
.bb-map-tools .bb-grownups { font-size: 1em; }
@keyframes bb-spin { to { transform: rotate(90deg); } }

/* The settings panel */
body.bb-modal-open { overflow: hidden; }
.bb-settings {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(6, 40, 28, 0.5);
  animation: bb-in 0.25s ease;
}
.bb-settings__card {
  width: min(600px, 100%);
  margin: auto 0;
  padding: 16px 20px 20px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}
.bb-settings__head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid rgba(6, 60, 42, 0.08); }
.bb-settings__gear { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 50%; background: var(--yellow-soft); color: var(--green); }
.bb-settings__gear svg { width: 30px; height: 30px; }
.bb-settings__titles { flex: 1; min-width: 0; }
.bb-settings__title { margin: 0; font-size: 1.6em; line-height: 1.1; }
.bb-settings__sub { margin: 2px 0 0; color: var(--muted); font-weight: 700; overflow-wrap: anywhere; }
.bb-settings__x { flex: none; border: 2px solid rgba(6, 60, 42, 0.12); box-shadow: none; }
.bb-set { padding: 14px 0; border-bottom: 2px solid rgba(6, 60, 42, 0.08); }
.bb-set--row { display: flex; align-items: center; gap: 14px; }
.bb-set__text { flex: 1; min-width: 0; }
.bb-set__name { margin: 0 0 8px; font-size: 1.15em; line-height: 1.2; }
.bb-set--row .bb-set__name { margin: 0; }
.bb-set__help { margin: 6px 0 0; color: var(--muted); font-size: 0.95em; line-height: 1.35; }
.bb-set__note { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 600; }
.bb-set__note svg { width: 22px; height: 22px; flex: none; }
/* Read aloud: three big choices side by side */
.bb-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 999px; background: rgba(6, 60, 42, 0.08); }
.bb-seg__opt {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05em;
}
.bb-seg__opt[aria-checked="true"] { background: var(--green); color: #fff; box-shadow: 0 2px 6px rgba(6, 60, 42, 0.25); }
/* On/off switches */
.bb-switch {
  position: relative;
  flex: none;
  width: 96px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #D8D3C8;
  color: var(--green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1em;
  transition: background 0.2s ease;
}
.bb-switch__knob { position: absolute; top: 5px; left: 5px; width: 38px; height: 38px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.2s ease; }
.bb-switch__text { position: absolute; top: 50%; right: 14px; transform: translateY(-50%); }
.bb-switch[aria-checked="true"] { background: var(--green); color: #fff; }
.bb-switch[aria-checked="true"] .bb-switch__knob { transform: translateX(48px); }
.bb-switch[aria-checked="true"] .bb-switch__text { right: auto; left: 16px; }
/* Change class */
.bb-set__classes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bb-set__class {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 8px 4px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: var(--lv-soft);
  color: var(--lv-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92em;
  line-height: 1.1;
}
.bb-set__class[aria-checked="true"] { border-color: var(--lv); background: #fff; box-shadow: 0 4px 12px rgba(6, 60, 42, 0.14); }
.bb-set__emblem { width: 60px; height: 60px; }
/* Remove player */
.bb-set--remove { display: flex; flex-direction: column; align-items: center; border-bottom: 0; }
.bb-set__remove { --btn-fg: #A21E24; }
.bb-settings .bb-confirm { margin-top: 0; width: 100%; box-shadow: none; border: 2px solid #F3C4C6; background: #FFF4F4; }
.bb-settings .bb-confirm p { margin: 0 0 4px; font-weight: 700; color: #7E1418; }
.bb-settings .bb-confirm .bb-row { margin-top: 10px; }
.bb-settings__done { margin-top: 4px; }
@media (min-width: 700px) {
  .bb-set__classes { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .bb-set__class { padding: 8px 2px; font-size: 0.8em; }
  .bb-set__emblem { width: 54px; height: 54px; }
}
/* Short laptop screens: the whole panel, Done included, fits without scrolling. */
@media (max-height: 820px) and (min-width: 481px) {
  .bb-set { padding: 9px 0; }
  .bb-settings__head { padding-bottom: 8px; }
  .bb-set__help { margin-top: 4px; }
}
/* Phones: a full-screen sheet that grows with its content (the backdrop scrolls), so the class
   grid, Remove and Done never spill past the card onto the dimmed screen behind. */
@media (max-width: 480px) {
  .bb-settings { padding: 0; align-items: flex-start; }
  .bb-settings__card { min-height: 100%; height: auto; margin: 0; padding: max(12px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); border-radius: 0; }
  .bb-set__emblem { width: 52px; height: 52px; }
  .bb-set__class { font-size: 0.85em; }
}

/* Celebration: a big thumbs-up pops over the right answer and floats away. */
.bb-thumbs {
  position: fixed;
  z-index: 95;
  font-size: clamp(84px, 16vw, 140px);
  line-height: 1;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  pointer-events: none;
  user-select: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 10px rgba(6, 60, 42, 0.3));
  animation: bb-thumbs 1.35s ease-out both;
}
@keyframes bb-thumbs {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(-30deg); }
  22% { opacity: 1; transform: translate(-50%, -58%) scale(1.22) rotate(10deg); }
  40% { transform: translate(-50%, -60%) scale(1) rotate(-4deg); }
  72% { opacity: 1; transform: translate(-50%, -68%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -105%) scale(0.85); }
}
@keyframes bb-fade { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .bb-thumbs { animation: bb-fade 1.35s linear both; }
  .bb-grownups.is-holding svg { animation: none; }
}

/* Phones: Put in Order with pictures keeps its tiles in one row, so the numbered shelf
   below stays on screen while the child taps. */
@media (max-width: 760px) {
  .bb-order:not(.bb-order--vertical) .bb-tray:not(.bb-tray--many):has(.bb-tile.has-pic) {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .bb-order .bb-tray .bb-tile.has-pic { min-width: 0; padding: 6px 4px 8px; font-size: 1em; }
  .bb-order .bb-tray .bb-tile.has-pic .bb-tile__pic { width: 100%; max-width: 120px; }
  .bb-order .bb-tray .bb-tile.has-pic .bb-tile__label { font-size: 0.85em; }
  .bb-map-tools { gap: 10px; }
}
/* Side by side (tablets and up): picture tiles read left to right, every label lined up. */
@media (min-width: 761px) {
  .bb-order .bb-tile.has-pic .bb-tile__label { text-align: left; }
}


/* ==================================================================== */
/* Flip & Learn suite (bb-flip.js): picker, ways to play, My Bible Shelf */
/* ==================================================================== */
.bb-flipsuite .bb-fhead { flex-wrap: wrap; }
.bb-shelfchip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #F3E2C7;
  color: #6B4423;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05em;
  box-shadow: inset 0 -3px 0 rgba(107, 68, 35, 0.18);
}
.bb-shelfchip.is-bump { animation: bb-bounce 0.5s var(--ease-out-back); }
.bb-flipsuite .is-wiggle { animation: bb-wiggle 0.45s ease; }

/* --- the picker --- */
.bb-modes { --per: 2; display: flex; flex-wrap: wrap; justify-content: center; gap: 18px 14px; margin-top: 20px; }
@media (min-width: 700px) { .bb-modes { --per: 4; } }
.bb-mode {
  position: relative;
  flex: 0 0 calc((100% - (var(--per) - 1) * 14px) / var(--per));
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 170px;
  padding: 18px 10px 12px;
  border: 4px solid transparent;
  border-radius: 26px;
  background: linear-gradient(to bottom, var(--mode, #fff) 0%, var(--paper) 78%);
  color: var(--green);
  box-shadow: 0 5px 0 rgba(6, 60, 42, 0.12), 0 6px 18px rgba(6, 60, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bb-mode:hover { transform: translateY(-3px); box-shadow: 0 8px 0 rgba(6, 60, 42, 0.12), 0 12px 26px rgba(6, 60, 42, 0.14); }
.bb-mode:active { transform: translateY(2px); }
.bb-mode.is-rec { border-color: #F6C928; }
.bb-mode__rec {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: #F6C928;
  color: #5A3E00;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78em;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(126, 90, 0, 0.3);
}
.bb-mode__pic { display: grid; place-items: center; width: clamp(84px, 13vw, 116px); aspect-ratio: 1; border-radius: 26%; overflow: hidden; }
.bb-mode__pic--emoji { background: var(--mode, #FFF5CC); font-size: clamp(2.6em, 2em + 2vw, 3.6em); line-height: 1; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.7); }
.bb-mode__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bb-mode__name { font-family: var(--font-display); font-weight: 700; font-size: 1.2em; line-height: 1.1; text-align: center; }
.bb-mode__sub { font-size: 0.85em; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.2; }
.bb-mode__stars { display: flex; gap: 2px; margin-top: auto; }
.bb-mode__stars svg { width: 20px; height: 20px; }
.bb-mode__stars svg.on { fill: var(--yellow); stroke: #B48E0C; stroke-width: 1.2; }
.bb-mode__stars svg.off { fill: #E8E2D2; }

/* --- the My Bible Shelf panel (picker) --- */
.bb-shelfpanel {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 18px;
  padding: 14px 16px 22px;
  border: 0;
  border-radius: 26px;
  background: linear-gradient(#F7EBD6, #EFDDBF);
  color: #5A3A1C;
  text-align: left;
  box-shadow: inset 0 -10px 0 #C9A06E, 0 6px 18px rgba(107, 68, 35, 0.15);
}
.bb-shelfpanel:hover { filter: brightness(1.03); }
.bb-shelfpanel__pic { flex: none; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 22%; overflow: hidden; background: #FFF6E4; font-size: 2.6em; }
.bb-shelfpanel__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bb-shelfpanel__name { font-family: var(--font-display); font-weight: 700; font-size: 1.35em; }
.bb-shelfpanel__count { font-weight: 800; }
.bb-shelfpanel__stickers { flex: none; display: flex; gap: 6px; }
.bb-shelfpanel__stickers > span { width: 64px; height: 64px; }
.bb-minishelf { display: flex; flex-wrap: wrap; gap: 2px; max-width: 360px; padding: 4px 6px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.55); box-shadow: inset 0 -3px 0 #C9A06E; }
.bb-minishelf i { width: 3px; height: 16px; border-radius: 1px; background: transparent; box-shadow: inset 0 0 0 1px rgba(107, 68, 35, 0.35); }
.bb-minishelf i.on { background: var(--sec); box-shadow: none; }
@media (max-width: 520px) {
  .bb-shelfpanel { flex-wrap: wrap; }
  .bb-shelfpanel__pic { width: 60px; height: 60px; font-size: 2em; }
  .bb-shelfpanel__stickers { width: 100%; justify-content: center; }
}

/* --- stickers: a painting, or a golden sticker seal (medalHtml, variant 'sticker') with an
   emoji that grows with its box. Older markup without the SVG keeps a CSS disc. --- */
.bb-medal--sticker:not(.has-art) .bb-medal__emoji { position: relative; font-size: 1.9em; line-height: 1; }
.bb-badge__medal .bb-medal--sticker:not(.has-art) .bb-medal__emoji, .bb-stickercard__medal .bb-medal--sticker:not(.has-art) .bb-medal__emoji { font-size: 3.3em; }
.bb-sticker-toast__medal .bb-medal--sticker:not(.has-art) .bb-medal__emoji { font-size: 2.3em; }
.bb-medal--sticker:not(.has-art):not(.is-earned) .bb-medal__emoji { filter: grayscale(1); opacity: 0.4; }
.bb-medal--sticker.has-art .bb-medal__emoji { font-size: 34cqw; }
.bb-sticker { display: grid; place-items: center; width: 100%; height: 100%; }
.bb-sticker__img { width: 100%; height: 100%; object-fit: contain; }
.bb-sticker:not(.is-earned) .bb-sticker__img { filter: grayscale(1); opacity: 0.45; }
.bb-sticker-toast {
  position: fixed;
  top: max(76px, calc(env(safe-area-inset-top) + 70px));
  left: 50%;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 10px;
  border: 3px solid #F6C928;
  border-radius: 999px;
  background: #FFFBEA;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: bb-toast 0.45s var(--ease-out-back);
  transition: opacity 0.5s, transform 0.5s;
  pointer-events: none;
}
.bb-sticker-toast.is-out { opacity: 0; transform: translateX(-50%) translateY(-20px); }
.bb-sticker-toast__medal { width: 72px; height: 72px; flex: none; }
.bb-sticker-toast__text { display: flex; flex-direction: column; color: var(--green); font-weight: 800; white-space: nowrap; }
.bb-sticker-toast__text strong { font-family: var(--font-display); font-size: 1.3em; color: #7E5A00; }
@keyframes bb-toast { from { opacity: 0; transform: translateX(-50%) scale(0.7); } to { opacity: 1; transform: translateX(-50%); } }
.bb-stickers { margin-top: 22px; }
.bb-stickers__title { margin: 0 0 4px; font-size: 1.5em; }
.bb-stickers__row { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 14px; }

/* --- Flip Cards and Watch --- */
.bb-flipcards .bb-card { --card-h: clamp(300px, 47vh, 440px); touch-action: pan-y; user-select: none; -webkit-user-select: none; height: var(--card-h); }
/* Everything stays inside the card, clear of the dots row: the picture (square, as big as before
   when there is room) takes only the room the words leave, and the card grows past its usual
   height only when its words need more (a long back on a small phone). */
@supports (width: 1cqw) {
  .bb-flipcards .bb-card { height: auto; min-height: var(--card-h); }
  .bb-flipcards .bb-card__inner { display: grid; height: auto; min-height: inherit; }
  .bb-flipcards .bb-card__face { position: relative; grid-area: 1 / 1; container-type: inline-size; }
  .bb-flipcards .bb-card__pic { flex: 1 1 0; min-height: 0; width: auto; max-height: min(64cqw, 220px); }
  .bb-flipcards .bb-card__pic--small { max-height: min(40cqw, 130px); }
}
.bb-flipcards .bb-flip__row { margin-top: 12px; }
.bb-flip__meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; margin-top: 10px; }
.bb-flip__meta .bb-fdots { margin-top: 0; }
.bb-flip__meta .bb-flip__count { margin: 0; font-size: 0.95em; }
.bb-card__text { display: block; }
.bb-fdots { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.bb-fdots i { width: 16px; height: 22px; border-radius: 4px; background: #E8E2D2; transition: background 0.2s, transform 0.2s; }
.bb-fdots i.on { background: var(--lv); }
.bb-fdots i.now { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--lv-soft), 0 0 0 5px var(--lv); }
.bb-flip__tools { margin-top: 8px; }
.bb-watchbtn { display: inline-flex; align-items: center; gap: 8px; font-size: 1.15em; }
/* The drawn Play and Pause marks (Watch, Book Chant): as big as the word next to them. */
.bb-glyph { width: 1em; height: 1em; flex: none; }
/* Short screens (small phones, landscape tablets): the card is smaller, so the card, its arrows
   and "I learned them!" fit above Pico's bar. */
@media (max-height: 720px) {
  .bb-flipcards .bb-card { --card-h: clamp(236px, 41vh, 300px); }
  .bb-flipcards .bb-flip__row { margin-top: 6px; }
  .bb-flip__meta { margin-top: 6px; }
  .bb-flip__tools { margin-top: 4px; }
}
.bb-watchbtn[aria-pressed="true"] { background: var(--lv-ink); color: #fff; }

/* --- Find it! --- */
.bb-find { --per: 4; display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-top: 18px; }
.bb-find--2 { --per: 2; }
.bb-find--3 { --per: 3; }
@media (max-width: 760px) { .bb-find--3, .bb-find--4 { --per: 2; } }
.bb-fcard { flex: 0 0 auto; width: min(calc((100% - (var(--per) - 1) * 16px) / var(--per)), 240px); aspect-ratio: 4 / 5; padding: 0; border: 0; background: none; perspective: 1000px; color: var(--green); }
.bb-find--2 .bb-fcard { width: min(calc((100% - 16px) / 2), 280px); }
@media (max-height: 760px) and (min-width: 761px) { .bb-fcard { width: min(calc((100% - (var(--per) - 1) * 16px) / var(--per)), 210px); } }
.bb-fcard__inner { position: relative; display: block; width: 100%; height: 100%; transition: transform 0.55s var(--ease-out-back); transform-style: preserve-3d; }
.bb-fcard.is-flipped .bb-fcard__inner { transform: rotateY(180deg); }
.bb-fcard__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 4px solid transparent;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 5px 0 rgba(6, 60, 42, 0.14), 0 6px 18px rgba(6, 60, 42, 0.08);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.bb-fcard__back { transform: rotateY(180deg); background: #E6F6EC; border-color: #0C8A4A; }
.bb-fcard__pic { width: 82%; aspect-ratio: 1; }
.bb-fcard__name { font-family: var(--font-display); font-weight: 700; font-size: 1.25em; line-height: 1.05; text-align: center; }
.bb-fcard__back .bb-fcard__name { font-size: 1.6em; color: #075C31; }
.bb-fcard__check { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #0C8A4A; color: #fff; }
.bb-fcard__check svg { width: 40px; height: 40px; }
.bb-fcard:hover .bb-fcard__front { border-color: var(--lv-soft); }
.bb-fcard.is-wrong { opacity: 0.45; }
.bb-fcard.is-faded { opacity: 0.4; }
.bb-fcard.is-hint .bb-fcard__front { border-color: var(--yellow); animation: bb-glow 1.2s ease-in-out infinite; }
.bb-fcard:disabled { cursor: default; }

/* --- Memory Match --- */
.bb-mem { --cols: 3; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; margin: 16px auto 0; max-width: calc(var(--cols) * 170px + (var(--cols) - 1) * 12px); }
.bb-mem--8 { --cols: 4; }
.bb-mem--10 { --cols: 5; }
.bb-mem--12 { --cols: 6; }
@media (max-width: 760px) { .bb-mem--10, .bb-mem--12 { --cols: 4; } }
.bb-memcard { width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; background: none; perspective: 900px; color: var(--green); }
.bb-memcard__inner { position: relative; display: block; width: 100%; height: 100%; transition: transform 0.45s ease; transform-style: preserve-3d; }
.bb-memcard.is-up .bb-memcard__inner { transform: rotateY(180deg); }
.bb-memcard__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 0 rgba(6, 60, 42, 0.14), 0 5px 14px rgba(6, 60, 42, 0.08);
}
/* The card back until card-back.webp is painted: cream, a soft gold border and a small book. */
.bb-memcard__back {
  border: 4px solid #E3B341;
  background:
    radial-gradient(circle at 50% 50%, #FFF8E4 0 34%, rgba(255, 248, 228, 0) 35%),
    repeating-linear-gradient(45deg, #FBEBC4 0 9px, #F7E0AA 9px 18px);
  color: #B07F12;
}
.bb-memcard__emblem { display: grid; place-items: center; width: 46%; aspect-ratio: 1; }
.bb-memcard__emblem svg { width: 100%; height: 100%; }
.has-backimg .bb-memcard__back { padding: 0; border: 0; background: #FFF8E4; overflow: hidden; }
.bb-memcard__backimg { width: 100%; height: 100%; object-fit: cover; border-radius: 18px; }
.bb-memcard__front { transform: rotateY(180deg); background: var(--paper); border: 4px solid var(--lv-soft); }
.bb-memcard__front--name { background: linear-gradient(var(--lv-soft), #fff); }
.bb-memcard__pic { width: 92%; aspect-ratio: 1; }
.bb-memcard__label { font-family: var(--font-display); font-weight: 700; font-size: 0.9em; line-height: 1; text-align: center; }
.bb-memcard__name { font-family: var(--font-display); font-weight: 700; font-size: clamp(0.95em, 0.7em + 1vw, 1.35em); line-height: 1.05; text-align: center; overflow-wrap: anywhere; }
/* (the bounce is on the card, not the face: the face's own transform keeps it turned over) */
.bb-memcard.is-matched { animation: bb-bounce 0.45s var(--ease-out-back); }
.bb-memcard.is-matched .bb-memcard__front { border-color: #0C8A4A; background: #E6F6EC; }
.bb-memcard:not(.is-up):hover .bb-memcard__back { filter: brightness(1.04); }

/* --- Peek & Guess --- */
.bb-peek { display: grid; gap: 16px; margin-top: 16px; justify-items: center; }
.bb-peek__stage { perspective: 1200px; }
.bb-peek__card { width: clamp(220px, 34vw, 320px); height: clamp(270px, 44vh, 400px); }
.bb-peek__card .bb-card__pic { width: min(78%, 240px); }
.bb-peek__card .bb-card__back { gap: 8px; }
.bb-peek__card .bb-card__back .bb-card__pic--small { width: min(46%, 150px); }
.bb-peek__card .bb-card__text { font-size: 1.1em; }
.bb-card__text.is-long { font-size: 1.02em; line-height: 1.25; }
@media (max-width: 480px) { .bb-card__text.is-long { font-size: 0.92em; } }
.bb-peek__q {
  position: absolute;
  top: 12px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--yellow);
  color: #5A3E00;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6em;
}
.bb-peek__opts { width: 100%; margin-top: 0; }
@media (max-width: 480px) { .bb-peek__card { width: 210px; height: 310px; } }
.bb-opt.is-reading { border-color: var(--lv); transform: scale(1.04); box-shadow: 0 0 0 5px var(--lv-soft), 0 6px 18px rgba(6, 60, 42, 0.12); }
/* Little Lamb, Eager Beaver: a name tapped once is read and lights up; a finger says "tap again". */
.bb-opt.is-armed { border-color: var(--lv); background: var(--lv-soft); transform: scale(1.04); box-shadow: 0 0 0 5px #fff, 0 6px 18px rgba(6, 60, 42, 0.16); }
.bb-opt__again { display: none; position: absolute; right: -6px; bottom: -10px; font-size: 1.5em; line-height: 1; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.bb-opt.is-armed .bb-opt__again { display: block; animation: bb-tapagain 0.9s ease-in-out infinite; }
@keyframes bb-tapagain { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@media (prefers-reduced-motion: reduce) { .bb-opt.is-armed .bb-opt__again { animation: none; } }
@media (min-width: 761px) {
  .bb-peek { grid-template-columns: auto minmax(0, 460px); justify-content: center; align-items: center; gap: 28px; }
  .bb-peek__opts, .bb-peek__opts.bb-options--3 { grid-template-columns: 1fr; }
  .bb-peek__opts.bb-options--4 { grid-template-columns: 1fr 1fr; }
}

/* --- Sort it! --- */
.bb-sort { display: grid; gap: 14px; margin-top: 16px; grid-template-areas: "card card" "ot nt"; grid-template-columns: 1fr 1fr; align-items: end; }
.bb-sort__zone { grid-area: card; display: grid; place-items: center; min-height: 230px; }
.bb-sort__baskets { display: contents; }
.bb-basket--ot { grid-area: ot; }
.bb-basket--nt { grid-area: nt; }
@media (min-width: 761px) {
  .bb-sort { grid-template-areas: "ot card nt"; grid-template-columns: 1fr auto 1fr; align-items: center; }
  .bb-sort__zone { min-height: 300px; padding: 0 10px; }
}
/* Short phones (iPhone SE, older Android): the baskets stand beside the card, so both are above
   Pico's bar, and the drag is short. */
@media (max-width: 760px) and (max-height: 720px) {
  .bb-sort { grid-template-areas: "ot card nt"; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 10px; }
  .bb-sort .bb-sort__zone { min-height: 0; }
  .bb-sort .bb-sortcard { width: clamp(104px, 30vw, 150px); padding: 8px 6px; border-width: 4px; border-radius: 20px; }
  .bb-sort .bb-sortcard__name { font-size: 1.1em; }
  .bb-sort .bb-sortcard__hint { top: -12px; right: -8px; font-size: 1.3em; }
  .bb-sort .bb-basket { gap: 4px; padding: 8px 4px 10px; border-radius: 20px; }
  .bb-sort .bb-basket__art { width: 100%; }
  .bb-sort .bb-basket__label { font-size: 0.9em; }
  .bb-sort .bb-basket__count { top: 2px; right: 2px; min-width: 26px; height: 26px; font-size: 0.9em; }
}
.bb-sortcard {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: clamp(160px, 28vw, 230px);
  padding: 14px 12px 12px;
  border: 5px solid var(--lv);
  border-radius: 26px;
  background: var(--paper);
  color: var(--green);
  box-shadow: 0 10px 26px rgba(6, 60, 42, 0.18);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  animation: bb-pop 0.35s var(--ease-out-back);
}
.bb-sortcard.bb-card--ot { background: linear-gradient(#FFF7E6, #FFFBF0); }
.bb-sortcard.bb-card--nt { background: linear-gradient(#EAF4FB, #FFFFFF); }
.bb-sortcard.is-dragging { cursor: grabbing; z-index: 50; box-shadow: 0 18px 40px rgba(6, 60, 42, 0.28); }
.bb-sortcard__pic { width: 86%; aspect-ratio: 1; pointer-events: none; }
.bb-sortcard__name { font-family: var(--font-display); font-weight: 700; font-size: 1.5em; line-height: 1.05; text-align: center; }
.bb-sortcard__hint { position: absolute; top: -14px; right: -10px; font-size: 1.6em; }
.bb-basket {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 12px 10px 14px;
  border: 4px solid transparent;
  border-radius: 28px;
  background: var(--card);
  color: var(--green);
  box-shadow: 0 5px 0 rgba(6, 60, 42, 0.12), 0 6px 18px rgba(6, 60, 42, 0.08);
  transition: transform 0.15s ease, border-color 0.15s;
}
.bb-basket:hover, .bb-basket.is-over { border-color: var(--lv); transform: scale(1.03); }
.bb-basket.is-hint { border-color: var(--yellow); animation: bb-glow 1.2s ease-in-out infinite; }
.bb-basket.is-catch { animation: bb-bounce 0.5s var(--ease-out-back); }
.bb-basket__art { position: relative; display: block; width: clamp(120px, 24vw, 190px); aspect-ratio: 1.1; }
.bb-basket__art.has-img { aspect-ratio: 1; }
.bb-basket__img { width: 100%; height: 100%; object-fit: contain; }
.bb-basket__pic { position: absolute; left: 16%; right: 16%; top: 0; aspect-ratio: 1; }
/* A woven basket in front of the Testament picture (until basket-ot / basket-nt are painted). */
.bb-basket__weave {
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: 0;
  height: 50%;
  border: 3px solid #7A4A1E;
  border-radius: 10px 10px 46% 46% / 10px 10px 60% 60%;
  background:
    repeating-linear-gradient(0deg, rgba(90, 50, 18, 0.28) 0 3px, rgba(0, 0, 0, 0) 3px 13px),
    repeating-linear-gradient(90deg, #D39A5C 0 11px, #BC8043 11px 22px);
  box-shadow: inset 0 7px 0 #E7B67C, 0 4px 8px rgba(90, 50, 18, 0.25);
}
.bb-basket__label { display: flex; flex-direction: column; align-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.15em; line-height: 1.1; text-align: center; }
.bb-basket__label small { font-size: 0.75em; color: var(--muted); }
.bb-basket__count {
  position: absolute;
  top: 8px;
  right: 10px;
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--lv);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
}
.bb-basket__pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; min-height: 22px; max-width: 90%; }
.bb-basket__pile i { width: 8px; height: 22px; border-radius: 2px; background: var(--sec); box-shadow: inset -2px 0 0 rgba(0, 0, 0, 0.15); animation: bb-pop 0.35s var(--ease-out-back); }

/* --- Book Chant and the shelves --- */
.bb-chant__sets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.bb-chip {
  padding: 8px 16px;
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--lv-soft);
  color: var(--lv-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05em;
}
.bb-chip[aria-checked="true"] { border-color: var(--lv); background: #fff; box-shadow: 0 4px 12px rgba(6, 60, 42, 0.14); }
.bb-chant__tools { position: sticky; top: 72px; z-index: 6; margin-top: 14px; padding: 6px 8px; border-radius: 999px; background: rgba(252, 246, 232, 0.88); }
@media (max-width: 480px) { .bb-chant__tools { top: 66px; gap: 8px; } }
.bb-chant__play { --btn-bg: var(--lv-ink); --btn-edge: color-mix(in srgb, var(--lv-ink) 65%, #000); min-width: 190px; font-size: 1.35em; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.bb-chant__echo, .bb-chant__restart { display: inline-flex; align-items: center; gap: 8px; }
.bb-chant__echo[aria-pressed="true"] { background: var(--lv-ink); color: #fff; }
.bb-chant__restart svg { width: 22px; height: 22px; }
.bb-spines { display: grid; gap: 12px; margin-top: 14px; }
.bb-spines__board, .bb-myshelf__board {
  padding: 10px 10px 0;
  border-radius: 18px;
  background: linear-gradient(#F7EBD6, #EDD9B8);
  box-shadow: inset 0 0 0 2px rgba(107, 68, 35, 0.12);
}
.bb-spines__label { display: block; margin: 0 0 6px; text-align: center; font-family: var(--font-display); font-weight: 700; color: #6B4423; }
.bb-spines__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 18px 4px;
  padding: 14px 4px 0;
  border-bottom: 12px solid #B9834D;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(to top, rgba(107, 68, 35, 0.12), rgba(107, 68, 35, 0) 30px);
}
.bb-spine {
  --sec: #888;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  width: 30px;
  height: 120px;
  padding: 6px 0;
  border: 0;
  border-radius: 5px 5px 3px 3px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.18) 28%, rgba(0, 0, 0, 0.04) 70%, rgba(0, 0, 0, 0.22)),
    var(--sec);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
}
.bb-spine__name { writing-mode: vertical-rl; font-size: 12px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 100%; }
.bb-spine.is-lit { z-index: 2; transform: translateY(-12px) scale(1.12); box-shadow: 0 0 0 3px #fff, 0 0 16px 6px rgba(246, 201, 40, 0.95); }
.bb-spine.is-said::after { content: '★'; position: absolute; top: -16px; color: #E0A800; font-size: 13px; text-shadow: none; }
.bb-spines--big .bb-spines__row--groups { gap: 22px 28px; }
.bb-spines--big .bb-myshelf__spines { gap: 8px; padding: 12px 8px 0; }
.bb-spine--big { width: clamp(64px, 9.5vw, 98px); height: clamp(176px, 26vh, 236px); padding: 8px 4px 10px; border-radius: 10px 10px 4px 4px; }
.bb-spine--big .bb-spine__name { font-size: clamp(15px, 1vw + 9px, 21px); }
.bb-spine--big.is-said::after { top: -20px; font-size: 18px; }
.bb-spine__pic { width: 88%; aspect-ratio: 1; flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85); }
.bb-spine__pic img, .bb-spine__thumb img { border-radius: 50% !important; border: 0 !important; }
@media (max-width: 760px) {
  .bb-spine--big { width: 72px; height: 170px; }
}

/* My Bible Shelf */
.bb-myshelf { display: grid; gap: 14px; margin-top: 14px; }
.bb-myshelf__board { padding-bottom: 12px; }
.bb-spines__row--groups { gap: 14px 12px; padding: 4px 0 0; border-bottom: 0; background: none; }
.bb-spines__board:has(.bb-spines__row--groups) { padding-bottom: 12px; }
.bb-myshelf__group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bb-myshelf__sec { font-size: 0.75em; font-weight: 800; color: #6B4423; white-space: nowrap; }
/* Each group of books stands on its own plank, so a wrapped row still has a shelf under it. */
.bb-myshelf__spines { display: flex; align-items: flex-end; gap: 3px; padding: 8px 6px 0; border-bottom: 10px solid #B9834D; border-radius: 0 0 4px 4px; background: linear-gradient(to top, rgba(107, 68, 35, 0.12), rgba(107, 68, 35, 0) 26px); }
/* My Bible Shelf: every spine is a finger-sized button (at least 40 px wide). A long group wraps
   onto more rows, and the background draws a plank under each row (rows are --spine-h tall,
   22 px apart; the 8 px top padding puts the first plank right under the first row). */
.bb-myshelf .bb-myshelf__spines {
  --spine-h: 124px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px 4px;
  max-width: 100%;
  padding: 8px 6px 10px;
  border-bottom: 0;
  background: repeating-linear-gradient(to bottom,
    rgba(107, 68, 35, 0) 0, rgba(107, 68, 35, 0) calc(var(--spine-h) - 18px), rgba(107, 68, 35, 0.12) calc(var(--spine-h) + 8px),
    #B9834D calc(var(--spine-h) + 8px), #B9834D calc(var(--spine-h) + 18px),
    rgba(107, 68, 35, 0) calc(var(--spine-h) + 18px), rgba(107, 68, 35, 0) calc(var(--spine-h) + 22px));
}
.bb-myshelf .bb-spine { width: 42px; height: var(--spine-h); }
.bb-spine.is-got { cursor: pointer; }
.bb-spine.is-got:hover { transform: translateY(-6px); }
.bb-spine.is-empty {
  border: 2px dashed color-mix(in srgb, var(--sec) 60%, transparent);
  background: rgba(255, 255, 255, 0.6);
  color: color-mix(in srgb, var(--sec) 75%, #333);
  text-shadow: none;
  box-shadow: none;
}
.bb-spine__thumb { width: 24px; height: 24px; flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #fff; }
.bb-spine__initial { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, 0.9); color: var(--sec); text-shadow: none; font-size: 12px; }
.bb-myshelf__stickers { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); justify-content: center; gap: 12px; margin-top: 14px; }
.bb-stickercard { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 10px; padding: 8px 14px 8px 8px; border-radius: 22px; background: var(--card); box-shadow: 0 4px 16px rgba(6, 60, 42, 0.08); text-align: left; }
.bb-stickercard__medal { grid-row: span 2; width: 72px; height: 72px; }
.bb-stickercard__medal .bb-medal--sticker:not(.has-art) .bb-medal__emoji { font-size: 2.4em !important; }
.bb-stickercard.is-earned .bb-stickercard__medal { animation: bb-bob 3s ease-in-out infinite; }
.bb-stickercard__name { font-family: var(--font-display); font-weight: 700; font-size: 1.15em; color: var(--green); }
.bb-stickercard__info { font-weight: 800; color: var(--lv-ink); font-size: 0.9em; }
@media (max-width: 760px) {
  .bb-myshelf .bb-myshelf__spines { --spine-h: 112px; }
  .bb-myshelf .bb-spine { width: 40px; }
  .bb-spines__row--groups { gap: 10px 10px; }
}
/* Phones: the longest group (History, 12 books) still fits on one plank. */
@media (max-width: 480px) {
  .bb-spines__board, .bb-myshelf__board { padding-left: 6px; padding-right: 6px; }
  .bb-myshelf__spines { gap: 2px; padding: 8px 3px 0; }
  .bb-spines__row--groups .bb-spine:not(.bb-spine--big) { width: 23px; height: 108px; }
  .bb-myshelf .bb-myshelf__spines { --spine-h: 104px; gap: 22px 3px; padding: 8px 3px 10px; }
  .bb-myshelf .bb-spines__row--groups .bb-spine { width: 40px; height: var(--spine-h); }
  .bb-spine__name { font-size: 11px; }
  .bb-spine__thumb, .bb-spine__initial { width: 19px; height: 19px; font-size: 10px; }
}

/* A book's card over the shelf */
.bb-cardmodal { position: fixed; inset: 0; z-index: 115; display: grid; place-items: center; padding: 20px; background: rgba(6, 40, 28, 0.45); animation: bb-in 0.25s ease; }
.bb-cardmodal__box { position: relative; perspective: 1400px; }
.bb-cardmodal__close { position: absolute; top: -18px; right: -14px; z-index: 3; }
