/* Chomper Boss Battles — same chunky Soft Emoji UI as Number Dash */

.bb {
  --ink: #263238;
  --white: #ffffff;
  --yellow: #ffd54f;
  --red: #e53935;
  --blue: #1e88e5;
  --green: #43a047;
  --orange: #ff9800;
  --purple: #7e57c2;
  --outline: 5px;
  --ease-pop: cubic-bezier(0.34, 1.4, 0.64, 1);
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  color: var(--white);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.bb[hidden],
.bb [hidden] {
  display: none !important;
}

.bb button {
  font-family: inherit;
  cursor: pointer;
}

.bb-canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.bb-flash {
  position: absolute;
  inset: 0;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
}

.bb-flash.is-on {
  animation: bb-flash 0.5s ease-out both;
}

/* ── HUD: boss health + Chomper shields ── */
.bb-hud {
  position: absolute;
  top: max(0.7rem, env(safe-area-inset-top));
  left: 50%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(34rem, calc(100% - 1.4rem));
  transform: translate(-50%, -140%);
  transition: transform 0.5s var(--ease-pop);
  pointer-events: none;
}

.bb-hud.is-in {
  transform: translate(-50%, 0);
}

.bb-bosscard {
  padding: 0.45rem 0.7rem 0.55rem;
  border-radius: 1.2rem;
  background: rgba(38, 50, 56, 0.82);
  border: 4px solid var(--white);
  box-shadow: 0 6px 0 rgba(38, 50, 56, 0.2);
}

.bb-bosscard__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-weight: 800;
}

.bb-bosscard__name {
  font-size: clamp(1rem, 4vw, 1.3rem);
}

.bb-bosscard__hp {
  font-size: 0.95rem;
  opacity: 0.9;
}

.bb-bar {
  position: relative;
  height: 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  border: 3px solid var(--white);
  overflow: hidden;
}

.bb-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
}

.bb-bar__lag {
  background: #fff59d;
  transition: width 0.6s ease;
}

.bb-bar__fill {
  background: linear-gradient(180deg, #81c784, #43a047);
  transition: width 0.25s ease;
}

.bb-bar__fill[data-level="mid"] {
  background: linear-gradient(180deg, #ffe082, #ffb300);
}

.bb-bar__fill[data-level="low"] {
  background: linear-gradient(180deg, #ff8a80, #e53935);
}

.bb-me {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  align-self: flex-start;
  padding: 0.2rem 0.7rem 0.2rem 0.8rem;
  border-radius: 999px;
  background: rgba(38, 50, 56, 0.6);
  border: 3px solid var(--white);
  font-weight: 800;
  font-size: 0.95rem;
}

.bb-shields {
  display: inline-flex;
  gap: 0.1rem;
  font-size: 1.05rem;
}

.bb-shields i {
  font-style: normal;
  filter: grayscale(1) opacity(0.3);
}

.bb-shields i.on {
  filter: none;
}

.bb-shields i.lost {
  animation: bb-shield-pop 0.5s ease both;
}

.bb-combo {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--orange);
  color: var(--white);
  font-size: 0.85rem;
}

.bb-combo.is-pop {
  animation: bb-pop 0.4s var(--ease-pop) both;
}

/* ── Banner ── */
.bb-banner {
  position: absolute;
  top: 26%;
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1.6rem 0.6rem;
  border-radius: 1.4rem;
  background: var(--blue);
  border: var(--outline) solid var(--white);
  box-shadow: 0 8px 0 rgba(38, 50, 56, 0.25);
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

.bb-banner b {
  font-size: clamp(2rem, 9vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-shadow: 0 4px 0 rgba(38, 50, 56, 0.25);
}

.bb-banner span {
  font-weight: 700;
  font-size: 1.05rem;
}

.bb-banner.is-pop {
  animation: bb-banner-in 0.55s var(--ease-pop) both;
}

.bb-banner--warn {
  background: repeating-linear-gradient(-45deg, #e53935 0 18px, #c62828 18px 36px);
}

.bb-banner--warn.is-pop {
  animation:
    bb-banner-in 0.55s var(--ease-pop) both,
    bb-throb 0.45s ease-in-out 0.55s infinite;
}

.bb-banner--win {
  background: linear-gradient(120deg, #ef5350, #ffa726, #fdd835, #66bb6a, #42a5f5, #ab47bc);
}

.bb-banner--lose {
  background: #78909c;
}

/* ── Problem card ── */
.bb-problem {
  position: absolute;
  top: calc(max(0.7rem, env(safe-area-inset-top)) + 7.4rem);
  left: 50%;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 1.3rem;
  border-radius: 1.3rem;
  background: var(--white);
  border: var(--outline) solid var(--ink);
  box-shadow: 0 7px 0 rgba(38, 50, 56, 0.28);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  line-height: 1.1;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}

.bb-problem b {
  display: inline-grid;
  place-items: center;
  min-width: 1.3em;
  padding: 0 0.15em;
  border-radius: 0.6rem;
  background: #fff3c4;
  color: #f57f17;
}

.bb-problem b.is-right {
  background: #c8f7c5;
  color: var(--green);
}

.bb-problem.is-pop {
  animation: bb-problem-in 0.45s var(--ease-pop) both;
}

/* ── Answers ── */
.bb-answers {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(0.9rem + env(safe-area-inset-bottom));
  z-index: 12;
  display: flex;
  justify-content: center;
  gap: clamp(0.45rem, 2vw, 0.9rem);
  padding: 0 0.8rem;
}

.bb-answer {
  flex: 0 1 8rem;
  min-width: 0;
  min-height: clamp(4rem, 11vh, 5.4rem);
  border-radius: 1.3rem;
  border: var(--outline) solid var(--white);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(1.9rem, 7vw, 2.8rem);
  box-shadow: 0 7px 0 rgba(38, 50, 56, 0.25);
  transition: transform 0.12s ease;
}

.bb-answer:nth-child(1) { background: #ffd54f; }
.bb-answer:nth-child(2) { background: #f48fb1; }
.bb-answer:nth-child(3) { background: #80deea; }
.bb-answer:nth-child(4) { background: #aed581; }

.bb-answers.is-in .bb-answer {
  animation: bb-answer-in 0.4s var(--ease-pop) both;
}

.bb-answers.is-in .bb-answer:nth-child(2) { animation-delay: 0.05s; }
.bb-answers.is-in .bb-answer:nth-child(3) { animation-delay: 0.1s; }
.bb-answers.is-in .bb-answer:nth-child(4) { animation-delay: 0.15s; }

.bb-answer:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(38, 50, 56, 0.25);
}

.bb-answer.is-right {
  background: var(--green) !important;
  color: var(--white);
  transform: scale(1.1);
}

.bb-answer.is-wrong {
  background: #b0bec5 !important;
  animation: bb-wrong 0.4s ease both !important;
}

/* ── Panels (rewards / gym) ── */
.bb-panel {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: max(0.8rem, env(safe-area-inset-top)) 0.8rem max(0.8rem, env(safe-area-inset-bottom));
  background: rgba(38, 50, 56, 0.45);
}

/* JG-043: a panel with a button under the card (the gym): card scrolls, button stays put */
.bb-panel.has-go {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}
.bb-panel.has-go .bb-card {
  max-height: calc(100% - 5rem);
  flex: 0 1 auto;
}
.bb-panel__go[hidden] {
  display: none;
}
.bb-panel__go .bb-btn {
  min-width: min(18rem, 80vw);
  min-height: 3.6rem;
  font-size: 1.3rem;
  box-shadow: 0 6px 0 rgba(38, 50, 56, 0.35);
}

.bb-card {
  width: min(26rem, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 1.1rem 1.1rem 1.2rem;
  border-radius: 1.6rem;
  background: #fff8e7;
  border: var(--outline) solid var(--white);
  box-shadow: 0 12px 0 rgba(38, 50, 56, 0.25);
  color: var(--ink);
  text-align: center;
  touch-action: pan-y;
}

.bb-card.is-pop {
  animation: bb-card-in 0.5s var(--ease-pop) both;
}

.bb-card--gym {
  width: min(30rem, 100%);
}

.bb-card__title {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  font-weight: 800;
}

.bb-card__title.is-win {
  color: #f57f17;
  text-shadow: 0 3px 0 #ffe082;
}

.bb-card__title.is-lose {
  color: #546e7a;
}

.bb-card__sub {
  margin: 0.2rem 0 0.8rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.bb-rewards {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
}

.bb-reward {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 6rem;
  padding: 0.45rem 0.8rem;
  border-radius: 1.1rem;
  background: var(--white);
  border: 3px solid #eadfc8;
}

.bb-reward__icon {
  font-size: 1.8rem;
  line-height: 1.1;
}

.bb-reward b {
  font-size: 1.6rem;
  font-weight: 800;
}

.bb-reward span:last-child {
  font-size: 0.8rem;
  font-weight: 700;
  color: #78909c;
}

.bb-xp {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 0 0.2rem;
  font-weight: 800;
}

.bb-xp__lvl {
  white-space: nowrap;
}

.bb-xp__bar {
  flex: 1;
  height: 1rem;
  border-radius: 999px;
  background: #e0d7c3;
  border: 3px solid var(--white);
  overflow: hidden;
}

.bb-xp__bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #80deea, #1e88e5);
  transition: width 0.6s ease;
}

.bb-xp__up {
  position: absolute;
  right: 0;
  top: -1.2rem;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--blue);
  color: var(--white);
  font-size: 0.85rem;
  animation: bb-pop 0.5s var(--ease-pop) both, bb-throb 0.8s ease-in-out 0.5s infinite;
}

.bb-hatdrop {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.8rem;
  padding: 0.5rem 0.8rem;
  border-radius: 1.1rem;
  background: linear-gradient(135deg, #fff59d, #ffe082);
  border: 3px solid #f9a825;
  text-align: left;
  animation: bb-card-in 0.5s var(--ease-pop) both;
}

.bb-hatdrop img {
  width: 4.6rem;
  height: 4.6rem;
  animation: bb-throb 1s ease-in-out infinite;
}

.bb-hatdrop div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.bb-hatdrop__new {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-weight: 800;
  font-size: 0.8rem;
}

.bb-hatdrop b {
  font-size: 1.2rem;
}

.bb-next {
  margin: 0.7rem 0 0;
  font-weight: 700;
  color: #546e7a;
}

.bb-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1rem;
}

.bb-btn {
  min-height: 3.2rem;
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  border: var(--outline) solid var(--white);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 6px 0 rgba(38, 50, 56, 0.22);
}

.bb-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(38, 50, 56, 0.22);
}

.bb-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.bb-btn--go {
  background: var(--yellow);
}

.bb-btn--gym {
  background: var(--purple);
  color: var(--white);
}

.bb-btn--small {
  min-height: 2.3rem;
  padding: 0.15rem 0.9rem;
  font-size: 0.95rem;
  --outline: 3px;
  background: var(--green);
  color: var(--white);
}

.bb-btn--buy {
  min-height: 2.6rem;
  min-width: 5.2rem;
  padding: 0.2rem 0.7rem;
  font-size: 1rem;
  --outline: 3px;
  background: #4fc3f7;
  color: var(--ink);
  flex: none;
}

/* Gym */
.bb-gym__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bb-gems {
  padding: 0.15rem 0.8rem;
  border-radius: 999px;
  background: #e1f5fe;
  border: 3px solid #4fc3f7;
  font-weight: 800;
  font-size: 1.15rem;
}

.bb-gym__me {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0;
  padding: 0.3rem 0.7rem;
  border-radius: 1.1rem;
  background: var(--white);
  border: 3px solid #eadfc8;
  text-align: left;
}

.bb-gym__me img {
  width: 4.2rem;
  height: 4.2rem;
}

.bb-gym__me div {
  display: flex;
  flex-direction: column;
}

.bb-gym__me b {
  font-size: 1.2rem;
}

.bb-gym__me span {
  font-size: 0.85rem;
  font-weight: 700;
  color: #78909c;
}

.bb-ups {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.bb-up {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.55rem;
  border-radius: 1rem;
  background: var(--white);
  border: 3px solid #eadfc8;
  text-align: left;
}

.bb-up.is-bought {
  animation: bb-pop 0.5s var(--ease-pop) both;
  border-color: var(--green);
}

.bb-up__icon {
  font-size: 1.8rem;
  flex: none;
}

.bb-up__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.bb-up__info b {
  font-size: 1.05rem;
}

.bb-up__info span {
  font-size: 0.8rem;
  font-weight: 700;
  color: #78909c;
}

.bb-up__pips {
  display: flex;
  gap: 0.2rem;
  margin-top: 0.15rem;
}

.bb-up__pips i {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: #e0d7c3;
  border: 2px solid #cfc3a8;
}

.bb-up__pips i.on {
  background: var(--yellow);
  border-color: #f9a825;
}

.bb-gym__sub {
  margin: 0.9rem 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: left;
}

.bb-hats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
  gap: 0.4rem;
}

.bb-hat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.2rem;
  border-radius: 0.9rem;
  background: var(--white);
  border: 3px solid #eadfc8;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.7rem;
  line-height: 1.15;
}

.bb-hat img {
  width: 3.4rem;
  height: 3.4rem;
}

.bb-hat.is-on {
  border-color: var(--green);
  background: #e8f5e9;
}

.bb-hat.is-locked {
  color: #90a4ae;
  cursor: default;
}

.bb-hat.is-locked img {
  filter: brightness(0) opacity(0.2);
}

/* Short landscape phones */
@media (max-height: 520px) {
  .bb-hud {
    width: min(26rem, 55vw);
    left: auto;
    right: 0.6rem;
    transform: translate(0, -140%);
  }
  .bb-hud.is-in {
    transform: none;
  }
  .bb-bosscard {
    padding: 0.25rem 0.55rem 0.35rem;
  }
  .bb-problem {
    top: max(0.6rem, env(safe-area-inset-top));
    left: 0.7rem;
    transform: none;
    font-size: 2rem;
  }
  .bb-problem.is-pop {
    animation: none;
  }
  .bb-answer {
    min-height: 3.4rem;
    font-size: 1.8rem;
  }
  .bb-banner {
    top: 40%;
  }
  .bb-card {
    padding: 0.6rem 0.8rem 0.8rem;
    width: min(34rem, 100%);
  }
  .bb-card__title {
    font-size: 1.6rem;
  }
  .bb-card__sub {
    margin-bottom: 0.4rem;
  }
  .bb-reward {
    flex-direction: row;
    gap: 0.35rem;
    padding: 0.2rem 0.7rem;
  }
  .bb-reward__icon {
    font-size: 1.3rem;
  }
  .bb-reward b {
    font-size: 1.2rem;
  }
  .bb-xp {
    margin-top: 0.5rem;
  }
  .bb-hatdrop {
    margin-top: 0.4rem;
    padding: 0.25rem 0.6rem;
  }
  .bb-hatdrop img {
    width: 3.2rem;
    height: 3.2rem;
  }
  .bb-card__actions {
    flex-direction: row;
    margin-top: 0.6rem;
  }
  .bb-card__actions .bb-btn {
    flex: 1;
  }
  .bb-gym__me {
    margin: 0.3rem 0;
  }
  .bb-ups {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  .bb-up {
    flex-direction: column;
    text-align: center;
  }
  .bb-up__info {
    align-items: center;
  }
  .bb-up__info span:not(.bb-up__pips) {
    display: none;
  }
  .bb-hats {
    grid-template-columns: repeat(9, 1fr);
  }
  .bb-hat span {
    display: none;
  }
}

@keyframes bb-flash {
  0% { opacity: var(--flash, 0.8); }
  100% { opacity: 0; }
}

@keyframes bb-pop {
  0% { transform: scale(0.4); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes bb-shield-pop {
  0% { transform: scale(1); filter: none; }
  40% { transform: scale(1.6) rotate(-20deg); filter: none; }
  100% { transform: scale(1); }
}

@keyframes bb-banner-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes bb-throb {
  0%, 100% { scale: 1; }
  50% { scale: 1.06; }
}

@keyframes bb-problem-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.7); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes bb-answer-in {
  from { opacity: 0; transform: translateY(40px) scale(0.8); }
  to { opacity: 1; transform: none; }
}

@keyframes bb-wrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-3deg); }
  50% { transform: translateX(8px) rotate(3deg); }
  75% { transform: translateX(-5px); }
}

@keyframes bb-card-in {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bb-banner--warn.is-pop,
  .bb-xp__up,
  .bb-hatdrop img {
    animation: none;
  }
}
