/* Bubble Brawl — character select overlay.
   Self-contained: every colour, radius and font lives here so the overlay never
   depends on the game's inline custom properties. */

#bb-select {
  --bbs-ink: #04121e;
  --bbs-ink-soft: #0a2233;
  --bbs-foam: #eaf9ff;
  --bbs-mute: #8fb6c9;
  --bbs-sun: #ffd23f;
  --bbs-panel: #0d3049;
  --bbs-panel-2: #143f5c;
  --bbs-radius: 18px;
  --bbs-display: "Luckiest Guy", "Arial Black", Impact, "Trebuchet MS", system-ui, sans-serif;
  --bbs-body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --el: #35d6e8;
  --el-dark: #062a38;
  --el-glow: #48e8ff;
  --el-soft: rgba(72, 232, 255, 0.38);
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: max(14px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px))
    max(18px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  color: var(--bbs-foam);
  font-family: var(--bbs-body);
  background:
    radial-gradient(1100px 700px at 82% -12%, rgba(53, 214, 232, 0.2), transparent 62%),
    radial-gradient(900px 620px at -8% 108%, rgba(255, 122, 47, 0.16), transparent 62%),
    radial-gradient(700px 520px at 50% 40%, rgba(176, 108, 255, 0.08), transparent 70%),
    linear-gradient(158deg, #041824 0%, #072b42 54%, #03121c 100%);
}

#bb-select *,
#bb-select *::before,
#bb-select *::after {
  box-sizing: border-box;
}

#bb-select[hidden] {
  display: none !important;
}

body.bbs-open {
  overflow: hidden;
}

/* ── shell ─────────────────────────────────────────────────────────────── */

#bb-select .bbs-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

#bb-select .bbs-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 4px 2px 0;
}

#bb-select .bbs-back {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid var(--bbs-ink);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #d9f2ff 62%, #b9e2f4);
  color: var(--bbs-ink);
  font-family: var(--bbs-display);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--bbs-ink);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

#bb-select .bbs-back:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--bbs-ink);
}

#bb-select .bbs-back:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--bbs-ink);
}

#bb-select .bbs-heading {
  min-width: 0;
}

#bb-select .bbs-kicker {
  display: block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--bbs-mute);
}

#bb-select .bbs-heading h2 {
  margin: 0;
  font-family: var(--bbs-display);
  font-weight: 400;
  font-size: clamp(28px, 3.6vw, 44px);
  line-height: 0.98;
  letter-spacing: 0.02em;
  color: var(--bbs-sun);
  -webkit-text-stroke: 2px var(--bbs-ink);
  text-shadow: 4px 4px 0 var(--bbs-ink);
  transform: rotate(-1.2deg);
  transform-origin: left center;
}

#bb-select .bbs-best {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 128px;
  padding: 8px 14px 7px;
  border: 3px solid var(--bbs-ink);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--bbs-panel-2), var(--bbs-panel));
  box-shadow: 0 5px 0 var(--bbs-ink);
  text-align: right;
}

#bb-select .bbs-best > span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bbs-mute);
}

#bb-select .bbs-best strong {
  font-family: var(--bbs-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1;
  color: var(--bbs-sun);
  -webkit-text-stroke: 1px var(--bbs-ink);
}

#bb-select .bbs-best small {
  font-size: 11px;
  font-weight: 800;
  color: #b9d7e5;
  font-variant-numeric: tabular-nums;
}

/* ── body layout ───────────────────────────────────────────────────────── */

#bb-select .bbs-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 408px);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

#bb-select .bbs-roster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

/* ── champion cards ────────────────────────────────────────────────────── */

#bb-select .bbs-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 13px 13px 11px;
  text-align: left;
  color: var(--bbs-foam);
  font-family: var(--bbs-body);
  border: 3px solid var(--bbs-ink);
  border-radius: var(--bbs-radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 34%),
    linear-gradient(180deg, var(--bbs-panel-2), var(--bbs-panel));
  box-shadow: 0 6px 0 var(--bbs-ink), 0 14px 24px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease, outline-color 0.12s ease;
}

#bb-select .bbs-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--el);
  box-shadow: 0 2px 0 rgba(4, 18, 30, 0.55);
}

#bb-select .bbs-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 var(--bbs-ink), 0 18px 28px rgba(0, 0, 0, 0.32);
}

#bb-select .bbs-card:focus-visible {
  outline: 4px solid var(--bbs-sun);
  outline-offset: 3px;
}

#bb-select .bbs-card[aria-selected="true"] {
  outline: 4px solid var(--el);
  outline-offset: 2px;
  background:
    linear-gradient(180deg, var(--el-soft), transparent 55%),
    linear-gradient(180deg, var(--bbs-panel-2), var(--bbs-panel));
}

#bb-select .bbs-card[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: calc(var(--bbs-radius) - 3px);
  box-shadow: inset 0 0 26px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

#bb-select .bbs-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

#bb-select .bbs-card-num {
  font-family: var(--bbs-display);
  font-size: 15px;
  line-height: 1;
  color: var(--bbs-mute);
  letter-spacing: 0.08em;
}

#bb-select .bbs-el {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 2px;
  border: 2px solid var(--bbs-ink);
  border-radius: 999px;
  background: var(--el);
  color: var(--el-dark);
  font-family: var(--bbs-display);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

#bb-select .bbs-el::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--el-dark);
  opacity: 0.65;
}

#bb-select .bbs-card-name {
  display: block;
  font-family: var(--bbs-display);
  font-size: clamp(23px, 2vw, 28px);
  line-height: 0.94;
  letter-spacing: 0.02em;
  color: #ffffff;
  -webkit-text-stroke: 1.5px var(--bbs-ink);
  text-shadow: 3px 3px 0 var(--bbs-ink);
  overflow-wrap: break-word;
}

#bb-select .bbs-card-title {
  display: block;
  margin-top: -2px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--el);
}

#bb-select .bbs-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 0 1px;
}

#bb-select .bbs-bar {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

#bb-select .bbs-bar-k {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--bbs-mute);
}

#bb-select .bbs-bar-t {
  position: relative;
  display: block;
  height: 8px;
  border: 2px solid var(--bbs-ink);
  border-radius: 6px;
  background: rgba(2, 14, 22, 0.6);
  overflow: hidden;
}

#bb-select .bbs-bar-t > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 55%), var(--el);
  box-shadow: 1px 0 0 rgba(4, 18, 30, 0.5);
}

#bb-select .bbs-bar-v {
  font-size: 10px;
  font-weight: 900;
  text-align: right;
  color: #cfe8f4;
  font-variant-numeric: tabular-nums;
}

#bb-select .bbs-ability {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 5px 8px 6px;
  border: 2px solid rgba(4, 18, 30, 0.9);
  border-radius: 12px;
  background: rgba(2, 14, 22, 0.42);
}

#bb-select .bbs-ability b {
  font-family: var(--bbs-display);
  font-weight: 400;
  font-size: 14.5px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--el);
}

#bb-select .bbs-ability small {
  display: block;
  font-size: 10.5px;
  line-height: 1.32;
  font-weight: 700;
  color: #b9d7e5;
}

/* ── stage / live preview ──────────────────────────────────────────────── */

#bb-select .bbs-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  position: sticky;
  top: 6px;
  align-self: start;
}

#bb-select .bbs-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.04;
  min-height: 240px;
  border: 3px solid var(--bbs-ink);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 7px 0 var(--bbs-ink), 0 18px 30px rgba(0, 0, 0, 0.34);
  background:
    radial-gradient(90% 64% at 50% 8%, var(--el-soft), transparent 68%),
    radial-gradient(120% 100% at 50% 100%, #062434 0%, #04121c 74%);
}

#bb-select .bbs-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 19px;
  box-shadow: inset 0 0 60px rgba(2, 10, 16, 0.55);
}

#bb-select #bbs-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#bb-select .bbs-preview-tag {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  padding: 5px 11px 3px;
  border: 2.5px solid var(--bbs-ink);
  border-radius: 999px;
  background: var(--bbs-foam);
  color: var(--bbs-ink);
  font-family: var(--bbs-display);
  font-size: 13px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 3px 0 var(--bbs-ink);
}

#bb-select .bbs-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  font-family: var(--bbs-display);
  font-size: 20px;
  color: var(--bbs-foam);
  -webkit-text-stroke: 1px var(--bbs-ink);
  text-shadow: 2px 2px 0 var(--bbs-ink);
  animation: bbs-pulse 1.4s ease-in-out infinite;
}

#bb-select .bbs-loading[hidden] {
  display: none !important;
}

@keyframes bbs-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ── variant strip ─────────────────────────────────────────────────────── */

#bb-select .bbs-variant {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 11px 13px 12px;
  border: 3px solid var(--bbs-ink);
  border-radius: var(--bbs-radius);
  background: linear-gradient(180deg, var(--bbs-panel-2), var(--bbs-panel));
  box-shadow: 0 5px 0 var(--bbs-ink);
}

#bb-select .bbs-variant-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

#bb-select .bbs-variant-head > span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bbs-mute);
}

#bb-select .bbs-variant-head strong {
  font-family: var(--bbs-display);
  font-weight: 400;
  font-size: 20px;
  line-height: 1;
  color: var(--bbs-foam);
  -webkit-text-stroke: 1px var(--bbs-ink);
}

#bb-select .bbs-variant-head em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  color: var(--bbs-sun);
  font-variant-numeric: tabular-nums;
}

#bb-select .bbs-swatches {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
}

#bb-select .bbs-swatch {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 3px solid var(--bbs-ink);
  border-radius: 12px;
  background: var(--sw, #35d6e8);
  box-shadow: inset 0 -5px 0 rgba(4, 18, 30, 0.28), 0 3px 0 var(--bbs-ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, outline-color 0.1s ease;
}

#bb-select .bbs-swatch:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 -5px 0 rgba(4, 18, 30, 0.28), 0 5px 0 var(--bbs-ink);
}

#bb-select .bbs-swatch:active {
  transform: translateY(1px);
  box-shadow: inset 0 -3px 0 rgba(4, 18, 30, 0.28), 0 1px 0 var(--bbs-ink);
}

#bb-select .bbs-swatch:focus-visible {
  outline: 3px solid var(--bbs-sun);
  outline-offset: 2px;
}

#bb-select .bbs-swatch[aria-pressed="true"] {
  outline: 3px solid var(--bbs-sun);
  outline-offset: 2px;
  transform: translateY(-2px);
}

#bb-select .bbs-swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--bbs-ink);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}

/* ── start button ──────────────────────────────────────────────────────── */

#bb-select .bbs-start {
  position: relative;
  width: 100%;
  padding: 15px 20px 11px;
  border: 3px solid var(--bbs-ink);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 46%),
    linear-gradient(180deg, var(--el), var(--el-dark));
  color: var(--bbs-ink);
  font-family: var(--bbs-display);
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--bbs-ink), 0 16px 24px rgba(0, 0, 0, 0.34);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

#bb-select .bbs-start:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 9px 0 var(--bbs-ink), 0 20px 28px rgba(0, 0, 0, 0.36);
}

#bb-select .bbs-start:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--bbs-ink), 0 8px 14px rgba(0, 0, 0, 0.3);
}

#bb-select .bbs-start:focus-visible {
  outline: 4px solid var(--bbs-sun);
  outline-offset: 3px;
}

#bb-select .bbs-hint {
  margin: -2px 0 0;
  text-align: center;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--bbs-mute);
}

/* ── menu entry button (created by select.js when index has none) ──────── */

#bb-play {
  background: linear-gradient(180deg, #a9f7ff, #35d6e8 58%, #1b8fa8);
  color: var(--bbs-ink, #04121e);
  font-size: 26px;
  padding: 12px 30px 7px;
  box-shadow: 5px 6px 0 var(--bbs-ink, #04121e);
  transform: rotate(1.2deg);
}

#bb-play:hover {
  transform: rotate(1.2deg) translateY(-2px);
}

#bb-play:active {
  transform: rotate(1.2deg) translateY(2px);
  box-shadow: 2px 3px 0 var(--bbs-ink, #04121e);
}

/* ── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 980px) {
  #bb-select .bbs-body {
    grid-template-columns: minmax(0, 1fr);
  }

  #bb-select .bbs-stage {
    position: static;
    order: -1;
  }

  #bb-select .bbs-preview {
    aspect-ratio: 16 / 10;
    min-height: 0;
    max-height: 340px;
  }

  #bb-select .bbs-swatches {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    max-width: 520px;
  }
}

@media (max-width: 700px) {
  #bb-select {
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }

  #bb-select .bbs-head {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 10px;
  }

  #bb-select .bbs-best {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    gap: 9px;
    min-width: 0;
    text-align: left;
    padding: 6px 12px 5px;
  }

  #bb-select .bbs-best > span {
    margin-right: auto;
  }

  #bb-select .bbs-roster {
    grid-template-columns: minmax(0, 1fr);
  }

  #bb-select .bbs-preview {
    aspect-ratio: 4 / 3;
    max-height: 320px;
  }

  #bb-select .bbs-card-name {
    font-size: 27px;
  }
}

@media (max-width: 420px) {
  #bb-select .bbs-shell {
    gap: 12px;
  }

  #bb-select .bbs-heading h2 {
    font-size: 27px;
  }

  #bb-select .bbs-back {
    width: 46px;
    height: 46px;
    font-size: 23px;
    border-radius: 14px;
  }

  #bb-select .bbs-card {
    padding: 13px 12px 11px;
  }

  #bb-select .bbs-swatches {
    gap: 5px;
  }

  #bb-select .bbs-swatch {
    border-width: 2.5px;
    border-radius: 10px;
  }

  #bb-select .bbs-variant {
    padding: 10px 11px 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #bb-select *,
  #bb-select *::before,
  #bb-select *::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
  }
}

/* ════════════════════════════════════════════════════════════════════════
   Brawl HUD (src/brawl-hud.js)
   Injected into #hud, so every selector is namespaced with .bbh- or a
   #bb-hud/#bb-result id. Nothing here can reach the duel widgets except
   .bbh-duel-hidden, which is only applied while a brawl is live.
   ════════════════════════════════════════════════════════════════════════ */

#hud .bbh-duel-hidden {
  display: none !important;
}

#bb-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--body);
  color: var(--foam);
  z-index: 2;
}

#bb-hud,
#bb-hud * {
  box-sizing: border-box;
}

#bb-hud[hidden] {
  display: none !important;
}

/* ── wave pill ─────────────────────────────────────────────────────────── */

.bbh-wave {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) rotate(-1.2deg);
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 16px 5px;
  background: var(--foam, #f5fbff);
  color: var(--ink, #122433);
  border: 3px solid var(--ink, #122433);
  border-radius: 16px;
  box-shadow: 3px 4px 0 var(--ink, #122433);
  white-space: nowrap;
  max-width: calc(100% - 28px);
}

.bbh-wave-label {
  font-family: var(--toon);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--sea, #1b7aa6);
  padding-top: 2px;
}

.bbh-wave-num {
  font-family: var(--toon);
  font-weight: 400;
  font-size: 27px;
  line-height: 1;
  color: var(--ink, #122433);
  font-variant-numeric: tabular-nums;
}

.bbh-wave-total {
  font-family: var(--toon);
  font-size: 15px;
  color: var(--mute, #5b7a8c);
  padding-top: 2px;
}

.bbh-faction {
  margin-left: 4px;
  padding: 2px 9px 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sun, #ffd23f);
  background: var(--ink, #122433);
  border-radius: 8px;
  align-self: center;
}

.bbh-faction:empty {
  display: none;
}

/* ── score / kills / enemies ───────────────────────────────────────────── */

.bbh-stats {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  display: flex;
  gap: 8px;
}

.bbh-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 74px;
  padding: 5px 12px 3px;
  background: var(--ink, #122433);
  border: 3px solid var(--ink, #122433);
  border-radius: 13px;
  box-shadow: 3px 4px 0 rgba(18, 36, 51, 0.55);
}

.bbh-stat span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #9fc0d2;
}

.bbh-stat b {
  font-family: var(--toon);
  font-weight: 400;
  font-size: 20px;
  line-height: 1.05;
  color: var(--sun, #ffd23f);
  font-variant-numeric: tabular-nums;
}

.bbh-stat.kills b {
  color: #8dffc8;
}

.bbh-enemies {
  position: absolute;
  top: calc(76px + env(safe-area-inset-top, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 12px 2px;
  background: rgba(245, 251, 255, 0.92);
  border: 3px solid var(--ink, #122433);
  border-radius: 11px;
  box-shadow: 2px 3px 0 var(--ink, #122433);
  color: var(--ink, #122433);
}

.bbh-enemies b {
  font-family: var(--toon);
  font-weight: 400;
  font-size: 20px;
  line-height: 1;
  color: #d6455a;
  font-variant-numeric: tabular-nums;
}

.bbh-enemies span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--mute, #5b7a8c);
}

/* ── boss bar ──────────────────────────────────────────────────────────── */

.bbh-boss {
  position: absolute;
  top: calc(62px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 12px 9px;
  background: rgba(18, 36, 51, 0.92);
  border: 3px solid var(--ink, #122433);
  border-radius: 14px;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 107, 107, 0.35);
  animation: bbh-boss-in 0.32s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.bbh-boss[hidden] {
  display: none !important;
}

.bbh-boss-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.bbh-boss-name {
  font-family: var(--toon);
  font-size: 17px;
  line-height: 1;
  letter-spacing: 0.06em;
  color: #ff9aa9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bbh-boss-hp {
  font-size: 11px;
  font-weight: 900;
  color: var(--foam, #f5fbff);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bbh-boss-bar {
  height: 12px;
  border: 2.5px solid var(--ink, #122433);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.bbh-boss-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff6b6b, #ff9f43);
  transition: width 0.15s linear;
}

@keyframes bbh-boss-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

/* ── champion HP (separate from the duel #health block) ────────────────── */

.bbh-hp {
  position: absolute;
  left: calc(22px + env(safe-area-inset-left, 0px));
  bottom: calc(132px + env(safe-area-inset-bottom, 0px));
  width: min(270px, calc(100% - 44px));
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bbh-hp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.bbh-hp-name {
  font-family: var(--toon);
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--foam, #f5fbff);
  -webkit-text-stroke: 1px var(--ink, #122433);
  text-shadow: 2px 2px 0 var(--ink, #122433);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bbh-hp-num {
  font-family: var(--toon);
  font-size: 16px;
  color: var(--sun, #ffd23f);
  -webkit-text-stroke: 1px var(--ink, #122433);
  text-shadow: 2px 2px 0 var(--ink, #122433);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bbh-hp-bar {
  height: 14px;
  border: 3px solid var(--ink, #122433);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 2px 3px 0 var(--ink, #122433);
  overflow: hidden;
}

.bbh-hp-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--kelp, #3ecf8e);
  transition: width 0.12s linear;
}

.bbh-hp.low .bbh-hp-bar i {
  background: var(--coral, #ff6b6b);
}

.bbh-hp.low .bbh-hp-num {
  color: #ff9aa9;
}

/* ── ability pill ──────────────────────────────────────────────────────── */

.bbh-ability {
  position: absolute;
  right: calc(22px + env(safe-area-inset-right, 0px));
  bottom: calc(132px + env(safe-area-inset-bottom, 0px));
  width: min(210px, calc(100% - 44px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding: 7px 13px 6px;
  overflow: hidden;
  background: rgba(18, 36, 51, 0.88);
  border: 3px solid var(--ink, #122433);
  border-radius: 14px;
  box-shadow: 3px 4px 0 var(--ink, #122433);
}

.bbh-ability::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 18, 30, 0.72), rgba(4, 18, 30, 0.42));
  transform: scaleY(var(--bbh-cd, 0));
  transform-origin: bottom center;
  transition: transform 0.1s linear;
  pointer-events: none;
}

.bbh-ab-name,
.bbh-ab-state {
  position: relative;
  z-index: 1;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bbh-ab-name {
  font-family: var(--toon);
  font-size: 15px;
  letter-spacing: 0.05em;
  color: var(--foam, #f5fbff);
}

.bbh-ab-state {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--mute, #9fc0d2);
  font-variant-numeric: tabular-nums;
}

.bbh-ability.ready {
  border-color: var(--sun, #ffd23f);
  box-shadow: 3px 4px 0 var(--ink, #122433), 0 0 16px rgba(255, 210, 63, 0.55);
}

.bbh-ability.ready .bbh-ab-state {
  color: var(--sun, #ffd23f);
}

.bbh-ability.ready .bbh-ab-name {
  color: var(--sun, #ffd23f);
}

/* ── banners ───────────────────────────────────────────────────────────── */

.bbh-banner {
  position: absolute;
  left: 50%;
  top: 27%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.bbh-banner[hidden] {
  display: none !important;
}

.bbh-banner.on {
  animation: bbh-banner 1.8s cubic-bezier(0.2, 1.3, 0.4, 1) forwards;
}

.bbh-banner-title {
  font-family: var(--toon);
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  color: var(--sun, #ffd23f);
  -webkit-text-stroke: 3px var(--ink, #122433);
  text-shadow: 4px 5px 0 var(--ink, #122433);
  white-space: nowrap;
}

.bbh-banner-sub {
  font-family: var(--toon);
  font-size: clamp(13px, 1.8vw, 19px);
  letter-spacing: 0.14em;
  color: var(--foam, #f5fbff);
  -webkit-text-stroke: 1.5px var(--ink, #122433);
  text-shadow: 2px 3px 0 var(--ink, #122433);
  white-space: nowrap;
}

.bbh-banner.boss .bbh-banner-title {
  color: #ff8fa3;
}

.bbh-banner.boss .bbh-banner-sub {
  color: var(--sun, #ffd23f);
}

@keyframes bbh-banner {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(1.5) rotate(-5deg);
  }
  14% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1) rotate(-2deg);
  }
  78% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1) rotate(-2deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -18px) scale(1) rotate(-2deg);
  }
}

/* ── result panel ──────────────────────────────────────────────────────── */

#bb-result {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(6, 30, 48, 0.72);
  pointer-events: auto;
}

#bb-result[hidden] {
  display: none !important;
}

.bbh-result-card {
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 20px 22px 22px;
  background: var(--foam, #f5fbff);
  color: var(--ink, #122433);
  border: 4px solid var(--ink, #122433);
  border-radius: 22px;
  box-shadow: 7px 8px 0 var(--ink, #122433);
  transform: rotate(-0.8deg);
  animation: bbh-result-in 0.4s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.bbh-result-kicker {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--mute, #5b7a8c);
  text-align: center;
}

.bbh-result-title {
  margin: -4px 0 0;
  font-family: var(--toon);
  font-weight: 400;
  font-size: clamp(38px, 8vw, 60px);
  line-height: 1;
  text-align: center;
  color: var(--kelp, #3ecf8e);
  -webkit-text-stroke: 2.5px var(--ink, #122433);
  text-shadow: 4px 5px 0 var(--ink, #122433);
}

#bb-result.defeat .bbh-result-title {
  color: var(--coral, #ff6b6b);
}

.bbh-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.bbh-result-grid > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  padding: 7px 6px 5px;
  background: #dff1fb;
  border: 3px solid var(--ink, #122433);
  border-radius: 12px;
}

.bbh-result-grid span {
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--mute, #5b7a8c);
}

.bbh-result-grid b {
  font-family: var(--toon);
  font-weight: 400;
  font-size: 20px;
  line-height: 1.05;
  color: var(--ink, #122433);
  font-variant-numeric: tabular-nums;
}

.bbh-result-grid > div:last-child b {
  color: var(--sea, #1b7aa6);
}

.bbh-result-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2px;
}

.bbh-btn {
  font-family: var(--toon);
  font-size: 19px;
  letter-spacing: 0.04em;
  padding: 9px 22px 5px;
  border-radius: 14px;
  border: 3px solid var(--ink, #122433);
  box-shadow: 3px 4px 0 var(--ink, #122433);
  background: var(--foam, #f5fbff);
  color: var(--ink, #122433);
  cursor: pointer;
}

.bbh-btn:hover {
  transform: translateY(-2px);
}

.bbh-btn:active {
  transform: translateY(2px);
  box-shadow: 1px 2px 0 var(--ink, #122433);
}

.bbh-btn.primary {
  background: var(--sun, #ffd23f);
  font-size: 22px;
  padding: 9px 30px 5px;
  transform: rotate(-1.2deg);
}

.bbh-btn.primary:hover {
  transform: rotate(-1.2deg) translateY(-2px);
}

.bbh-btn.primary:active {
  transform: rotate(-1.2deg) translateY(2px);
}

@keyframes bbh-result-in {
  from {
    opacity: 0;
    transform: rotate(-0.8deg) scale(0.82);
  }
  to {
    opacity: 1;
    transform: rotate(-0.8deg) scale(1);
  }
}

/* ── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
  .bbh-wave {
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    transform: rotate(-1.2deg);
    width: fit-content;
    margin: 0 auto;
    padding: 5px 11px 4px;
    gap: 5px;
  }

  .bbh-wave-num {
    font-size: 23px;
  }

  .bbh-wave-label,
  .bbh-wave-total {
    font-size: 13px;
  }

  .bbh-faction {
    font-size: 9px;
    letter-spacing: 0.1em;
    padding: 2px 7px 0;
  }

  .bbh-stats {
    top: calc(60px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    gap: 6px;
  }

  .bbh-stat {
    min-width: 62px;
    padding: 4px 9px 2px;
    border-width: 2.5px;
  }

  .bbh-stat span {
    font-size: 8px;
  }

  .bbh-stat b {
    font-size: 17px;
  }

  .bbh-enemies {
    top: calc(60px + env(safe-area-inset-top, 0px));
    right: auto;
    left: calc(10px + env(safe-area-inset-left, 0px));
    padding: 2px 9px 1px;
    border-width: 2.5px;
  }

  .bbh-enemies b {
    font-size: 17px;
  }

  .bbh-boss {
    top: calc(104px + env(safe-area-inset-top, 0px));
    width: calc(100% - 20px);
    padding: 6px 10px 8px;
  }

  .bbh-boss-name {
    font-size: 14px;
  }

  .bbh-boss-hp {
    font-size: 10px;
  }

  .bbh-hp {
    left: calc(12px + env(safe-area-inset-left, 0px));
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
    width: min(200px, calc(100% - 150px));
  }

  .bbh-hp-name,
  .bbh-hp-num {
    font-size: 13px;
  }

  .bbh-hp-bar {
    height: 12px;
  }

  .bbh-ability {
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
    width: min(132px, calc(100% - 220px));
    min-width: 96px;
    padding: 6px 10px 5px;
    border-width: 2.5px;
  }

  .bbh-ab-name {
    font-size: 13px;
  }

  .bbh-ab-state {
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .bbh-banner {
    top: 32%;
    width: calc(100% - 24px);
  }

  #bb-result {
    padding-left: max(22px, env(safe-area-inset-left, 0px));
    padding-right: max(22px, env(safe-area-inset-right, 0px));
    overflow-y: auto;
  }

  .bbh-result-card {
    padding: 16px 14px 18px;
    gap: 10px;
    border-radius: 18px;
    box-shadow: 5px 6px 0 var(--ink, #122433);
  }

  .bbh-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bbh-result-grid b {
    font-size: 18px;
  }

  .bbh-btn {
    font-size: 16px;
    padding: 8px 16px 4px;
  }

  .bbh-btn.primary {
    font-size: 19px;
    padding: 8px 22px 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #bb-hud *,
  #bb-hud *::before,
  #bb-hud *::after,
  #bb-result *,
  #bb-result *::before,
  #bb-result *::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
  }
}

/* ── collection link ─────────────────────────────────────────────────── */
#bb-select .bbs-collection {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px 5px;
  border: 3px solid var(--bbs-ink);
  border-radius: 999px;
  background: var(--bbs-panel-2);
  color: var(--bbs-foam);
  font-family: var(--bbs-display);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--bbs-ink);
  transition: transform 0.08s, box-shadow 0.08s;
}

#bb-select .bbs-collection:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--bbs-ink);
}

#bb-select .bbs-collection:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--bbs-ink);
}

@media (max-width: 700px) {
  #bb-select .bbs-collection {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
