/*
 * Bro Battles UI system
 *
 * This is the canonical visual contract for every browser-rendered UI. Keep
 * component styles focused on layout and content; colors, type, frames,
 * shadows, radii, focus, and interaction motion belong here.
 */

@font-face {
  font-family: "Press Start 2P";
  src: url("/assets/PressStart2P.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bb-font-display: "Press Start 2P", ui-monospace, monospace;
  --bb-font-body: "Lato", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --bb-bg-deep: #050914;
  --bb-bg: #080f1e;
  --bb-surface-1: #0b1629;
  --bb-surface-2: #111f37;
  --bb-surface-3: #182942;
  --bb-surface-raised: #20314a;
  --bb-border: #385478;
  --bb-border-soft: #263b59;
  --bb-border-highlight: #7aa9e5;
  --bb-ink: #03060b;

  --bb-text: #f7f9ff;
  --bb-text-soft: #c9d6e8;
  --bb-text-muted: #91a5c2;
  --bb-blue: #3d91eb;
  --bb-blue-deep: #2867c4;
  --bb-purple: #6a43bd;
  --bb-gold: #efc86e;
  --bb-green: #14b981;
  --bb-green-deep: #07885f;
  --bb-red: #d64a4a;
  --bb-red-deep: #a92833;
  --bb-orange: #e6923b;

  /* Fixed-size mosaic cells stay square on wide and compact popup headers. */
  --bb-chroma-mosaic: url("/assets/chromas/chroma-mosaic.svg") top left / 576px 96px repeat;
  --bb-chroma-header-veil: linear-gradient(90deg, transparent, #2856be 34%, #3045b9 66%, transparent);
  --bb-header-gradient: var(--bb-chroma-header-veil), var(--bb-chroma-mosaic), linear-gradient(100deg, #159dc9 0%, #2865c5 30%, #304bc4 62%, #3926a4 100%);
  --bb-chroma-button-corners:
    url("/assets/chromas/chroma-corner-light.svg") left top / var(--bb-chroma-corner-size, 18px) var(--bb-chroma-corner-size, 18px) no-repeat,
    url("/assets/chromas/chroma-corner-shade.svg") right bottom / var(--bb-chroma-corner-size, 18px) var(--bb-chroma-corner-size, 18px) no-repeat;
  --bb-chroma-button-trail:
    linear-gradient(rgba(255,255,255,.20), rgba(255,255,255,.20)) left 12% top 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(255,255,255,.15), rgba(255,255,255,.15)) left 20% top var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(255,255,255,.10), rgba(255,255,255,.10)) left 28% top 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(255,255,255,.06), rgba(255,255,255,.06)) left 35% top var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.20), rgba(8,16,32,.20)) right 12% bottom 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.15), rgba(8,16,32,.15)) right 20% bottom var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.10), rgba(8,16,32,.10)) right 28% bottom 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.06), rgba(8,16,32,.06)) right 35% bottom var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat;
  --bb-surface-gradient: linear-gradient(180deg, var(--bb-surface-2), var(--bb-surface-1));
  --bb-card-gradient: linear-gradient(180deg, #14243c, #0b172a);
  --bb-success-gradient: linear-gradient(180deg, #19c890, #079063);
  --bb-danger-gradient: linear-gradient(180deg, var(--bb-red), var(--bb-red-deep));
  --bb-primary-gradient: linear-gradient(180deg, #438feb, #285fc0);

  /* Every frame is square: windows, cards, media, controls, and tags. */
  --bb-radius-window: 0px;
  --bb-radius-media: 0px;
  --bb-radius-card: 0px;
  --bb-radius-control: 0px;
  --bb-radius-tag: 0px;
  --bb-radius-pill: 0px;

  --bb-border-width: 3px;
  --bb-frame-shadow:
    0 0 0 5px var(--bb-ink),
    0 8px 0 var(--bb-ink),
    0 24px 56px rgba(0, 0, 0, 0.58),
    inset 0 3px rgba(255, 255, 255, 0.09);
  --bb-card-shadow:
    0 0 0 4px var(--bb-ink),
    0 6px 0 var(--bb-ink),
    inset 0 2px rgba(255, 255, 255, 0.07);
  --bb-control-shadow:
    0 5px var(--bb-ink),
    0 -5px var(--bb-ink),
    5px 0 var(--bb-ink),
    -5px 0 var(--bb-ink),
    0 10px rgba(0, 0, 0, 0.3),
    inset 0 4px rgba(255, 255, 255, 0.16);
  --bb-control-shadow-pressed:
    0 5px var(--bb-ink),
    0 -5px var(--bb-ink),
    5px 0 var(--bb-ink),
    -5px 0 var(--bb-ink),
    inset 0 4px rgba(0, 0, 0, 0.24);
  --bb-inset-shadow:
    inset 0 2px rgba(255, 255, 255, 0.06),
    inset 0 -3px rgba(0, 0, 0, 0.3);

  --bb-field-focus: #6799d4;
  --bb-field-focus-shadow:
    0 0 0 2px rgba(73, 126, 191, 0.2),
    inset 0 2px rgba(255, 255, 255, 0.06),
    inset 0 -3px rgba(0, 0, 0, 0.34);
  --bb-title-shadow: 3px 4px 0 rgba(2, 5, 12, 0.72);
  --bb-overlay: rgba(3, 8, 16, 0.72);
  --bb-overlay-blur: 5px;
  --bb-popup-backdrop:
    radial-gradient(circle at 14% 16%, rgba(255, 201, 85, 0.18), transparent 44%),
    radial-gradient(circle at 85% 18%, rgba(81, 170, 255, 0.18), transparent 48%),
    rgba(5, 10, 22, 0.74);

  --bb-text-xs: 9px;
  --bb-text-sm: 11px;
  --bb-text-md: 13px;
  --bb-text-lg: 16px;
  --bb-title-sm: clamp(14px, 1.6vw, 19px);
  --bb-title-lg: clamp(20px, 2.5vw, 34px);

  --bb-space-1: 4px;
  --bb-space-2: 8px;
  --bb-space-3: 12px;
  --bb-space-4: 16px;
  --bb-space-5: 20px;
  --bb-space-6: 24px;
  --bb-space-8: 32px;

  --bb-motion-fast: 130ms;
  --bb-motion-standard: 180ms;
  --bb-ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --bb-popup-motion: 150ms;
  --bb-popup-shift: 12px;

  /* ---- Semantic component tokens. Components consume these, never raw hex. ---- */

  /* Popups and modals: one window surface for every dialog in lobby and battle. */
  /* Flat on purpose: a gradient reads as a different color on every window height. */
  --bb-popup-surface: #0c182c;
  --bb-popup-bg: var(--bb-popup-surface);
  --bb-popup-border-color: var(--bb-border);
  --bb-popup-border-width: var(--bb-border-width);
  --bb-popup-shadow: var(--bb-frame-shadow);
  --bb-popup-pad: var(--bb-space-5);
  --bb-popup-divider: 2px solid rgba(255, 255, 255, 0.14);

  /* Inset panels inside a popup (settings rows, profile sections). */
  --bb-panel-bg: rgba(8, 18, 36, 0.76);
  --bb-panel-border: 2px solid var(--bb-border-soft);
  --bb-panel-shadow: var(--bb-inset-shadow);

  /* Cards: benchmarked on the profile icon picker tile. */
  --bb-card-bg: var(--bb-card-gradient);
  --bb-card-bg-hover: linear-gradient(180deg, #1a2e4b, #0f1d33);
  --bb-card-border-width: 2px;
  --bb-card-border-color: var(--bb-border);
  --bb-card-border-hover: var(--bb-border-highlight);
  --bb-card-border-selected: var(--bb-green);
  --bb-card-border-current: var(--bb-gold);
  --bb-card-shadow-pressed:
    0 0 0 4px var(--bb-ink),
    0 2px 0 var(--bb-ink),
    inset 0 2px rgba(0, 0, 0, 0.24);
  --bb-card-locked-bg: linear-gradient(180deg, #161d2a, #0c111b);
  --bb-card-locked-border: #2c374a;
  --bb-card-pad: var(--bb-space-3);
  --bb-card-gap: var(--bb-space-2);
  --bb-card-grid-gap: var(--bb-space-5);
  --bb-card-title-size: 10px;

  /* In-battle HUD chrome, benchmarked on the match clock. */
  --bb-hud-frame:
    0 4px var(--bb-ink),
    0 -4px var(--bb-ink),
    4px 0 var(--bb-ink),
    -4px 0 var(--bb-ink),
    0 8px rgba(0, 0, 0, 0.33),
    4px 4px rgba(0, 0, 0, 0.33),
    -4px 4px rgba(0, 0, 0, 0.33),
    inset 0 3px rgba(255, 255, 255, 0.19);
  --bb-hud-fill: #102744;
  --bb-hud-fill-danger: #4a1a26;
  --bb-hud-mosaic: url("/assets/chromas/lobby-chroma-mosaic.svg") 0 0 / 288px 48px;
  --bb-hud-bg: linear-gradient(90deg, #10274430, #102744dd 45%, #10274460), var(--bb-hud-mosaic), var(--bb-hud-fill);
  --bb-hud-bg-danger: linear-gradient(90deg, #4a1a2630, #4a1a26e6 45%, #4a1a2660), var(--bb-hud-mosaic), var(--bb-hud-fill-danger);
  --bb-hud-label: var(--bb-border-highlight);

  /* Currency: one chip and one palette everywhere coins, gems, or trophies show. */
  --bb-coin: #ffd36a;
  --bb-gem: #8fe6ff;
  --bb-trophy: #ffd36a;
  --bb-currency-chip-bg: linear-gradient(180deg, #0d1a2e, #081221);
  --bb-currency-chip-border: 2px solid var(--bb-border-soft);
  --bb-currency-chip-shadow: 0 3px 0 var(--bb-ink), inset 0 2px rgba(255, 255, 255, 0.07);
  --bb-currency-icon: 20px;

  /* Rhythm for button rows and stacked actions. */
  --bb-stack-gap: var(--bb-space-3);
  --bb-action-gap: var(--bb-space-4);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

:is(
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  textarea,
  select
) {
  border: 2px solid var(--bb-border);
  border-radius: var(--bb-radius-control);
  color: var(--bb-text);
  background: rgba(5, 12, 25, 0.9);
  box-shadow: var(--bb-inset-shadow);
  transition:
    border-color var(--bb-motion-fast) ease,
    background-color var(--bb-motion-fast) ease,
    box-shadow var(--bb-motion-fast) ease;
}

:is(
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  textarea
)::placeholder {
  color: var(--bb-text-muted);
  opacity: 0.78;
}

button,
[role="button"],
a {
  -webkit-tap-highlight-color: transparent;
}

:where(button, a[href], [role="button"]):focus-visible {
  outline: 2px solid rgba(154, 203, 255, 0.92);
  outline-offset: 3px;
}

:is(
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  textarea,
  select
):focus,
:is(
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  textarea,
  select
):focus-visible {
  outline: none;
  border-color: var(--bb-field-focus);
  background: rgba(4, 10, 22, 0.98);
  box-shadow: var(--bb-field-focus-shadow);
}

input:-webkit-autofill,
input:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--bb-text);
  caret-color: var(--bb-text);
  box-shadow: 0 0 0 1000px #050c19 inset;
}

input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--bb-text);
  caret-color: var(--bb-text);
  box-shadow:
    0 0 0 1000px #040a16 inset,
    0 0 0 2px rgba(73, 126, 191, 0.2);
}

::selection {
  color: #fff;
  background: rgba(80, 115, 218, 0.78);
}

/* Canonical pixel control. Color is intentionally supplied by each variant. */
:is(
  .pixel-menu-button:not(.map-select-card),
  .bb-button,
  .profile-btn,
  .shop-close,
  .shop-buy-button,
  .shop-checkout-close,
  .shop-reveal-panel > button,
  .shop-load-error button,
  .bb-chat-send,
  .sonner__btn,
  .cs-btn,
  .game-notice-btn,
  body.admin-page button,
  .status-action
) {
  appearance: none;
  border: 0;
  border-radius: var(--bb-radius-control);
  box-shadow: var(--bb-control-shadow);
  color: var(--bb-text);
  cursor: pointer;
  font-family: var(--bb-font-display);
  font-size: var(--bb-text-sm);
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
  transition:
    transform var(--bb-motion-fast) var(--bb-ease),
    filter var(--bb-motion-fast) ease,
    background-color var(--bb-motion-fast) ease,
    color var(--bb-motion-fast) ease,
    opacity var(--bb-motion-fast) ease;
}

:is(
  .pixel-menu-button:not(.map-select-card),
  .bb-button,
  .profile-btn,
  .shop-close,
  .shop-buy-button,
  .shop-checkout-close,
  .shop-reveal-panel > button,
  .shop-load-error button,
  .bb-chat-send,
  .sonner__btn,
  .cs-btn,
  .game-notice-btn,
  body.admin-page button,
  .status-action
):hover:not(:disabled) {
  filter: brightness(1.12) saturate(1.06);
  /* Moving the control itself changes its hit-test bounds. */
  transform: none;
}

:is(
  .pixel-menu-button:not(.map-select-card),
  .bb-button,
  .profile-btn,
  .shop-close,
  .shop-buy-button,
  .shop-checkout-close,
  .shop-reveal-panel > button,
  .shop-load-error button,
  .bb-chat-send,
  .sonner__btn,
  .cs-btn,
  .game-notice-btn,
  body.admin-page button,
  .status-action
):active:not(:disabled) {
  filter: brightness(0.97);
  transform: none;
  box-shadow: var(--bb-control-shadow-pressed);
}

/* Depress the visible contents by 2px without moving the clickable element. */
:is(
  .pixel-menu-button:not(.map-select-card),
  .bb-button,
  .profile-btn,
  .shop-close,
  .shop-buy-button,
  .shop-checkout-close,
  .shop-reveal-panel > button,
  .shop-load-error button,
  .bb-chat-send,
  .sonner__btn,
  .cs-btn,
  .game-notice-btn,
  body.admin-page button,
  .status-action
):active:not(:disabled) > * {
  translate: 0 2px;
}

:is(button, .bb-button):disabled,
:is(button, .bb-button)[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.58;
}

/* Lobby players keep the scenery visible inside the shared pixel frame. */
#lobby-area .character-slot {
  --lobby-frame-color: var(--bb-border);
  border: var(--bb-border-width) solid var(--lobby-frame-color);
  border-radius: var(--bb-radius-card);
  background: transparent;
  box-shadow:
    0 2px 0 rgba(3, 6, 11, 0.25),
    inset 0 1px rgba(255, 255, 255, 0.3);
  transition:
    background-color var(--bb-motion-fast) ease,
    box-shadow var(--bb-motion-fast) ease;
}

@media (hover: hover) {
  #lobby-area .character-slot:is(.player-display, .op-display):hover {
    background-color: rgba(247, 249, 255, 0.1);
    box-shadow:
      0 0 0 2px rgba(247, 249, 255, 0.35),
      0 3px 0 rgba(3, 6, 11, 0.2),
      inset 0 0 0 1px rgba(247, 249, 255, 0.3);
  }
}

#lobby-area .character-slot.player-display {
  --lobby-frame-color: var(--bb-blue);
}

#lobby-area .character-slot.op-display {
  --lobby-frame-color: var(--bb-red);
}

#lobby-area .character-slot.empty {
  --lobby-frame-color: rgba(247, 249, 255, 0.45);
  border-width: 2px;
  border-style: dashed;
  background: rgba(247, 249, 255, 0.06);
  box-shadow:
    0 2px 0 rgba(3, 6, 11, 0.48),
    0 4px 9px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

#lobby-area .character-slot.empty > .character-sprite.random {
  filter: drop-shadow(0 3px 3px rgba(3, 6, 11, 0.32));
}

#lobby-area .status {
  --lobby-status-color: var(--bb-blue);
  border: 2px solid var(--lobby-status-color);
  border-radius: var(--bb-radius-tag);
  background: var(--bb-surface-gradient);
  box-shadow: 0 0 0 2px var(--bb-ink), 0 4px 0 var(--bb-ink);
  color: var(--bb-text);
  font-family: var(--bb-font-display);
  font-size: clamp(7px, 0.65vw, 8px);
  font-weight: 400;
  line-height: 1.6;
  text-transform: uppercase;
  text-shadow: 1px 2px 0 var(--bb-ink);
}

#lobby-area .status:is(.ready, .selecting-character) {
  --lobby-status-color: var(--bb-green);
}

#lobby-area .status.not-ready {
  --lobby-status-color: var(--bb-red);
}

#lobby-area .status.offline {
  --lobby-status-color: var(--bb-text-muted);
  color: var(--bb-text-muted);
}

#lobby-area .status.in-battle {
  --lobby-status-color: var(--bb-purple);
}

#lobby-area .status.end-screen {
  --lobby-status-color: var(--bb-gold);
}

#lobby-area :is(.switch-character, .status.invite) {
  border: 0;
  border-radius: var(--bb-radius-control);
  box-shadow: var(--bb-control-shadow);
  color: var(--bb-text);
  cursor: pointer;
  transition:
    transform var(--bb-motion-fast) var(--bb-ease),
    filter var(--bb-motion-fast) ease;
}

#lobby-area .switch-character {
  background: var(--bb-primary-gradient);
}

#lobby-area .status.invite {
  background: linear-gradient(180deg, var(--bb-gold), var(--bb-orange));
  color: var(--bb-ink);
  text-shadow: none;
}

#lobby-area :is(.switch-character, .status.invite):hover,
#lobby-area .character-slot:has(> .character-sprite:hover) > .switch-character {
  filter: brightness(1.12) saturate(1.06);
}

#lobby-area .switch-character:hover,
#lobby-area .character-slot:has(> .character-sprite:hover) > .switch-character {
  transform: translateY(-2px);
}

#lobby-area .status.invite:hover {
  transform: translate(-50%, -2px);
}

#lobby-area :is(.switch-character, .status.invite):active {
  filter: brightness(0.97);
  box-shadow: var(--bb-control-shadow-pressed);
}

#lobby-area .switch-character:active {
  transform: translateY(5px);
}

#lobby-area .status.invite:active {
  transform: translate(-50%, 5px);
}

/* Reusable presets for new UI. Existing components below are mapped to the same contract. */
.bb-popup {
  overflow: hidden;
  color: var(--bb-text);
}

.bb-popup-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bb-space-4);
  padding: var(--bb-space-3) var(--bb-space-5);
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
  background: var(--bb-header-gradient);
}

.bb-popup-title {
  margin: 0;
  color: #fff;
  font-family: var(--bb-font-display);
  font-size: var(--bb-title-lg);
  line-height: 1.2;
  text-transform: uppercase;
  text-shadow: var(--bb-title-shadow);
}

/* Canonical popup motion: a quick fade and small upward settle. */
:where(
  .character-select-overlay,
  .character-details-overlay,
  .trophy-overlay,
  #profile-overlay,
  .profile-loadout-overlay,
  .mm-overlay,
  body.profile-page-body .cards-modal,
  .game-notice-overlay,
  .bb-chat-viewers-popup
) {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear;
}

:where(
  .character-select-overlay,
  .character-details-overlay
).is-hidden,
:where(
  .trophy-overlay,
  #profile-overlay,
  .profile-loadout-overlay,
  .mm-overlay,
  .game-notice-overlay
).hidden {
  display: flex !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear var(--bb-popup-motion);
}

.bb-chat-viewers-popup.hidden {
  display: block !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear var(--bb-popup-motion);
}

body.profile-page-body .cards-modal.hidden {
  display: block !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear var(--bb-popup-motion);
}

.shop-overlay {
  display: grid !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear var(--bb-popup-motion);
}

.shop-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear;
}

.shop-checkout {
  display: grid !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear var(--bb-popup-motion);
}

.shop-checkout.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity var(--bb-popup-motion) ease,
    visibility 0s linear;
}

:is(
  .character-select-popup,
  .character-details-popup,
  .trophy-overlay-panel,
  .profile-popup,
  .profile-loadout-modal,
  .mm-card,
  .shop-window,
  .game-notice-card,
  .cs-confirm,
  .shop-checkout-panel
) {
  opacity: 1;
  transition:
    transform var(--bb-popup-motion) var(--bb-ease),
    opacity var(--bb-popup-motion) ease;
}

.character-select-overlay.is-hidden .character-select-popup,
.character-details-overlay.is-hidden .character-details-popup,
.trophy-overlay.hidden .trophy-overlay-panel,
#profile-overlay.hidden .profile-popup,
.profile-loadout-overlay.hidden .profile-loadout-modal,
.mm-overlay.hidden .mm-card,
.shop-overlay:not(.is-open) .shop-window,
.game-notice-overlay.hidden .game-notice-card {
  opacity: 0;
  transform: translateY(var(--bb-popup-shift));
}

.shop-checkout:not(.is-open) .shop-checkout-panel {
  opacity: 0;
  transform: translateY(var(--bb-popup-shift));
}

body.profile-page-body .cards-modal-panel {
  opacity: 1;
  transition:
    transform var(--bb-popup-motion) var(--bb-ease),
    opacity var(--bb-popup-motion) ease;
}

body.profile-page-body .cards-modal.hidden .cards-modal-panel {
  opacity: 0;
  transform: translate(-50%, calc(-50% + var(--bb-popup-shift)));
}

.game-notice-card,
.game-notice-overlay.show .game-notice-card {
  transform: translateY(0);
  transition-duration: var(--bb-popup-motion);
}

.cs-confirm-backdrop,
.bb-game-over-backdrop {
  animation: bb-popup-backdrop-in var(--bb-popup-motion) ease both;
}

.cs-confirm-backdrop .cs-confirm,
.bb-game-over-backdrop .bb-game-over-card {
  animation: bb-popup-panel-in var(--bb-popup-motion) var(--bb-ease) both;
}

.bb-popup-closing {
  animation: bb-popup-backdrop-out var(--bb-popup-motion) ease both !important;
  pointer-events: none !important;
}

.bb-popup-closing .cs-confirm {
  animation: bb-popup-panel-out var(--bb-popup-motion) var(--bb-ease) both !important;
}

@keyframes bb-popup-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bb-popup-backdrop-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes bb-popup-panel-in {
  from {
    opacity: 0;
    transform: translateY(var(--bb-popup-shift));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bb-popup-panel-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(var(--bb-popup-shift));
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(
    .character-select-overlay,
    .character-details-overlay,
    .trophy-overlay,
    #profile-overlay,
    .profile-loadout-overlay,
    .mm-overlay,
    body.profile-page-body .cards-modal,
    .shop-overlay,
    .shop-checkout,
    .game-notice-overlay,
    .bb-chat-viewers-popup,
    .cs-confirm-backdrop,
    .bb-game-over-backdrop
  ),
  :is(
    .character-select-popup,
    .character-details-popup,
    .trophy-overlay-panel,
    .profile-popup,
    .profile-loadout-modal,
    .mm-card,
    .shop-window,
    .shop-checkout-panel,
    .cards-modal-panel,
    .game-notice-card,
    .cs-confirm,
    .bb-game-over-card
  ) {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

.bb-card {
  border: 2px solid var(--bb-border);
  border-radius: var(--bb-radius-card);
  color: var(--bb-text);
  background: var(--bb-card-gradient);
  box-shadow: var(--bb-card-shadow);
}

.bb-field {
  min-height: 42px;
  width: 100%;
  border: 2px solid var(--bb-border);
  border-radius: var(--bb-radius-control);
  padding: 10px 12px;
  color: var(--bb-text);
  background: rgba(5, 12, 25, 0.88);
  box-shadow: var(--bb-inset-shadow);
}

.bb-field::placeholder {
  color: var(--bb-text-muted);
}

.bb-field:focus {
  border-color: var(--bb-border-highlight);
}

.bb-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 9px;
  border: 2px solid var(--bb-ink);
  border-radius: var(--bb-radius-tag);
  color: var(--bb-text);
  background: var(--bb-surface-raised);
  box-shadow: 0 3px 0 var(--bb-ink);
  font-family: var(--bb-font-display);
  font-size: var(--bb-text-xs);
  line-height: 1.15;
  text-transform: uppercase;
}

button.bb-chat-close.bb-chat-close {
  --bb-close-size: 28px;
  --bb-close-font-size: 10px;
  --bb-chroma-corner-size: 12px;
  flex: 0 0 var(--bb-close-size);
}

button.bb-close.bb-close,
button.bb-chat-close.bb-chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--bb-close-size, 38px) !important;
  min-width: var(--bb-close-size, 38px) !important;
  height: var(--bb-close-size, 38px) !important;
  min-height: var(--bb-close-size, 38px) !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: #fff !important;
  background: var(--bb-danger-gradient) !important;
  box-shadow: var(--bb-control-shadow) !important;
  font-family: var(--bb-font-display) !important;
  font-size: var(--bb-close-font-size, 15px) !important;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-transform: none;
  transition:
    transform var(--bb-motion-fast) var(--bb-ease),
    filter var(--bb-motion-fast) ease;
}

button.bb-close.bb-close:hover:not(:disabled),
button.bb-chat-close.bb-chat-close:hover:not(:disabled) {
  filter: brightness(1.12) saturate(1.06);
  transform: none !important;
}

button.bb-close.bb-close:active:not(:disabled),
button.bb-chat-close.bb-chat-close:active:not(:disabled) {
  filter: brightness(0.96);
  transform: none !important;
  box-shadow: var(--bb-control-shadow-pressed) !important;
}

.profile-loadout-head #profile-loadout-shop,
.cards-modal-head .browse-shop-link {
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 16px !important;
  font-size: 11px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

.profile-guest-card[hidden],
[data-account-member][hidden],
.profile-form[hidden],
body.profile-page-body .profile-form[hidden] {
  display: none;
}

.profile-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bb-space-4);
  margin: var(--bb-space-2) 0 var(--bb-space-5);
}

.profile-account-actions button {
  min-height: 40px;
}

.profile-account-actions button[aria-expanded="true"] {
  outline: 2px solid var(--bb-border-highlight);
  outline-offset: 4px;
}

.profile-account-actions ~ .profile-form {
  padding-top: var(--bb-space-4);
  border-top: 2px solid var(--bb-border-soft);
}

.profile-form button[data-account-cancel] {
  color: var(--bb-text-soft);
  background: var(--bb-surface-raised);
}

.profile-guest-card {
  display: flex;
  align-items: flex-start;
  gap: var(--bb-space-5);
  padding: var(--bb-space-5);
  border: 2px solid var(--bb-border);
  border-top-color: var(--bb-gold);
  border-radius: var(--bb-radius-card);
  background: radial-gradient(ellipse at top left, rgba(61, 145, 235, 0.16), transparent 65%), var(--bb-card-gradient);
  box-shadow: var(--bb-inset-shadow);
}

.profile-guest-art {
  flex: 0 0 64px;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid var(--bb-border);
  background: var(--bb-surface-1);
  box-shadow: var(--bb-card-shadow);
}

.profile-guest-art img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
}

.profile-guest-copy {
  min-width: 0;
}

.profile-guest-tag {
  display: inline-block;
  margin-bottom: var(--bb-space-3);
  color: var(--bb-gold);
  font-family: var(--bb-font-display);
  font-size: 8px;
  line-height: 1.6;
  text-transform: uppercase;
}

.profile-guest-card .profile-guest-copy h3 {
  margin: 0 0 var(--bb-space-3);
  color: var(--bb-text);
  font-family: var(--bb-font-display);
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

.profile-guest-copy p {
  max-width: 52ch;
  margin: 0;
  color: var(--bb-text-soft);
  font-family: var(--bb-font-body);
  font-size: var(--bb-text-md);
  line-height: 1.6;
}

.profile-guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bb-space-5);
  margin: var(--bb-space-5) 5px var(--bb-space-6);
}

.profile-guest-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: var(--bb-space-3) var(--bb-space-4);
  text-decoration: none;
}

.profile-guest-signup {
  background: var(--bb-success-gradient);
}

.profile-guest-login {
  background: var(--bb-primary-gradient);
}

.profile-guest-copy .profile-guest-note {
  color: var(--bb-text-muted);
  font-size: 12px;
}

@media (max-width: 560px) {
  .profile-guest-card {
    flex-direction: column;
    padding: var(--bb-space-4);
  }
}

/* Matching edit controls for the profile portrait and player card. */
.profile-card-showcase .profile-edit-badge {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--bb-radius-control);
  color: var(--bb-text);
  background: var(--bb-primary-gradient);
  box-shadow: var(--bb-control-shadow), 0 0 12px rgba(61, 145, 235, 0.35);
  pointer-events: none;
  transition:
    filter var(--bb-motion-fast) ease,
    box-shadow var(--bb-motion-fast) ease;
}

.profile-card-showcase .profile-edit-badge > img {
  display: block;
  width: 14px;
  height: 14px;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  filter: none;
}

.profile-card-showcase button:is(:hover, :focus-visible):not(:disabled) .profile-edit-badge {
  filter: brightness(1.12) saturate(1.06);
  box-shadow: var(--bb-control-shadow), 0 0 20px rgba(61, 145, 235, 0.6);
}

.profile-card-showcase button:active:not(:disabled) .profile-edit-badge {
  box-shadow: var(--bb-control-shadow-pressed);
}

.profile-card-showcase .profile-edit-badge[hidden],
.profile-card-showcase .profile-card-edit-trigger[hidden] {
  display: none;
}

.profile-card-showcase .profile-hero-avatar-trigger:disabled {
  opacity: 1;
  filter: none;
}

/* Profile loadout: use the same square frames and pixel tags as the shop. */
.profile-loadout-modal .profile-icon-group + .profile-icon-group {
  border-top: 2px solid var(--bb-border-soft);
}

.profile-loadout-modal .profile-icon-group-heading h3 {
  color: var(--bb-text);
  font-family: var(--bb-font-display);
  font-size: var(--bb-text-sm);
  font-weight: 700;
  line-height: 1.5;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

.profile-loadout-modal .profile-icon-group-heading h3 span {
  border: 1px solid var(--bb-border);
  border-radius: var(--bb-radius-tag);
  color: var(--bb-text-soft);
  background: var(--bb-surface-raised);
  box-shadow: 0 3px 0 var(--bb-ink);
  font-size: var(--bb-text-xs);
  text-shadow: none;
}

.profile-loadout-modal .profile-icon-group-heading p,
.profile-loadout-modal .profile-loadout-empty,
.profile-loadout-modal .profile-icon-status {
  color: var(--bb-text-muted);
  font-family: var(--bb-font-body);
}

.profile-loadout-modal .profile-icon-choice-tile,
.profile-loadout-modal .profile-card-tile {
  color: var(--bb-text);
  font-family: var(--bb-font-body);
  transition:
    transform var(--bb-motion-fast) var(--bb-ease),
    border-color var(--bb-motion-fast) ease,
    box-shadow var(--bb-motion-fast) ease;
}

.profile-loadout-modal .profile-icon-art {
  border-radius: var(--bb-radius-media);
  background: var(--bb-bg-deep);
}



.profile-loadout-modal .profile-icon-choice-tile:focus-visible {
  outline: 2px solid var(--bb-border-highlight);
  outline-offset: 5px;
}


/* The portrait supplies its own inner frame; the complete choice stays raised. */
.profile-loadout-modal .profile-icon-art {
  background: transparent;
}

.profile-loadout-modal .profile-icon-selected-badge {
  border: 2px solid var(--bb-ink);
  border-radius: var(--bb-radius-tag);
  color: var(--bb-text);
  background: var(--bb-success-gradient);
  box-shadow: 0 3px 0 var(--bb-ink);
  font-family: var(--bb-font-display);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.4;
  text-transform: uppercase;
}

.profile-loadout-modal .is-selected .profile-icon-status {
  color: var(--bb-text-soft);
}

.profile-loadout-modal .profile-icon-requirement {
  color: var(--bb-gold);
}


/* Join-request dialogs follow the shared window-and-inset visual hierarchy. */
:is(
  .party-request-banner,
  .party-request-card,
  .party-request-empty,
  .party-request-summary-card,
  .party-request-pill
) {
  border-radius: var(--bb-radius-card);
}

:is(.party-join-request-panel, .party-join-request-owner-panel) {
  font-family: var(--bb-font-body);
}

:is(.party-join-request-panel, .party-join-request-owner-panel)
  .trophy-overlay-head h2 {
  line-height: 1.5;
}

.party-request-banner,
.party-request-summary-card,
.party-request-empty {
  border-color: var(--bb-border-soft);
  background: rgba(26, 49, 84, 0.58);
  box-shadow: var(--bb-inset-shadow);
}

.party-request-banner,
.party-request-summary-card {
  border-width: 2px;
}

.party-request-banner[data-status="pending"] {
  border-color: var(--bb-blue);
  background: rgba(26, 49, 84, 0.72);
}

.party-request-banner[data-status="accepted"] {
  border-color: var(--bb-green);
  background: rgba(7, 136, 95, 0.2);
}

.party-request-banner[data-status="rejected"] {
  border-color: var(--bb-red);
  background: rgba(169, 40, 51, 0.2);
}


.party-request-pill {
  border-color: var(--bb-border-soft);
  color: var(--bb-text-soft);
  background: var(--bb-surface-raised);
}

.party-request-submit {
  background: var(--bb-primary-gradient);
}

.party-request-return,
.party-request-button:not(.party-request-accept):not(.party-request-reject) {
  background: linear-gradient(180deg, #29405f, #1d2e47);
}

.party-request-accept {
  background: var(--bb-success-gradient);
}

.party-request-reject {
  background: var(--bb-danger-gradient);
}

.party-request-summary-card span,
.party-request-card-copy span,
.party-request-empty {
  color: var(--bb-text-soft);
}

.party-request-summary-card strong,
.party-request-card-copy strong {
  color: var(--bb-text);
}

:is(
  .character-select-popup .popup-header,
  .shop-header,
  .profile-loadout-head
) {
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
  background: var(--bb-header-gradient);
}

:is(
  .party-join-request-panel,
  .party-join-request-owner-panel,
  .party-discovery-panel,
  .party-settings-panel
) .trophy-overlay-head {
  margin: -16px -16px 16px;
  padding: 12px 16px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
  background: var(--bb-header-gradient);
}

:is(
  .popup-title,
  .trophy-overlay-title,
  .shop-brand h1
) {
  color: #fff;
  font-family: var(--bb-font-display);
  text-shadow: var(--bb-title-shadow);
}

.leaderboard-head .leaderboard-title-line h2,
.trophy-rewards-head .trophy-rewards-title-line h2,
.trophy-overlay-head h2,
.profile-popup-head h2,
.cards-modal-head h2,
.auth-card h1,
.status-title,
.mm-heading,
.bb-game-over-title,
.game-notice-title {
  text-shadow: var(--bb-title-shadow);
}

:is(
  .leaderboard-row,
  .party-discovery-card,
  .party-request-summary-card,
  .profile-panel,
  .profile-metric-card,
  .profile-character-level-card,
  .card-tile,
  .shop-product-card,
  .shop-cycle-card,
  .stat-card,
  .panel
) {
  border-radius: var(--bb-radius-card);
}

:is(
  .character-card-status-text,
  .mode-select-badge,
  .game-mode-status,
  .profile-card-rarity,
  .profile-card-state,
  .profile-icon-name-badge,
  .profile-icon-gem-badge,
  .profile-icon-limited-tag,
  .shop-offer-badge,
  .shop-rarity-badge,
  .shop-action-state,
  .shop-payment-status,
  .trophy-claim-badge
) {
  border-radius: var(--bb-radius-tag);
}

:is(
  .party-discovery-input,
  .party-public-name-input,
  .profile-form input,
  .form-input,
  body.admin-page input,
  body.admin-page select,
  body.admin-page textarea
) {
  border-radius: var(--bb-radius-control);
}

/* Party discovery and settings use the shared palette and control treatments. */
.party-discovery-input,
.party-public-name-input {
  font-size: var(--bb-text-sm);
  letter-spacing: 0;
  font-family: var(--bb-font-display);
}

.party-discovery-refresh {
  background: var(--bb-primary-gradient);
  color: var(--bb-text);
}

.party-discovery-status,
.party-settings-status {
  color: var(--bb-text-soft);
  font-size: var(--bb-text-md);
}

.party-discovery-status.has-count {
  color: #d8e9ff;
}


.party-discovery-title {
  font-size: var(--bb-text-lg);
  color: var(--bb-text);
  font-weight: 700;
}


.party-discovery-meta {
  color: var(--bb-text-soft);
  font-size: var(--bb-text-sm);
}

.party-discovery-meta-label {
  color: var(--bb-text-muted);
  font-size: var(--bb-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.party-discovery-member img {
  border-radius: var(--bb-radius-media);
  background: var(--bb-bg-deep);
}

.party-discovery-member-name {
  color: var(--bb-text-soft);
  font-size: var(--bb-text-sm);
  font-weight: 600;
}

.party-discovery-join {
  color: var(--bb-text);
  background: var(--bb-success-gradient);
}

.party-visibility-toggle {
  color: var(--bb-text);
  font-weight: 700;
  font-size: var(--bb-text-md);
}

.party-public-name-label,
.party-visibility-toggle-label {
  font-weight: 600;
  color: var(--bb-text);
  font-size: var(--bb-text-md);
}

.party-settings-hint {
  color: var(--bb-text-muted);
  font-size: var(--bb-text-sm);
}

.party-settings-save {
  color: var(--bb-text);
  background: var(--bb-success-gradient);
}

.party-visibility-toggle input[type="checkbox"] {
  appearance: none;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--bb-border);
  border-radius: var(--bb-radius-control);
  background: var(--bb-surface-1);
  box-shadow: var(--bb-inset-shadow);
  color: var(--bb-text);
  cursor: pointer;
  transition:
    border-color var(--bb-motion-fast) ease,
    background-color var(--bb-motion-fast) ease;
}

.party-visibility-toggle input[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--bb-border-highlight);
}

.party-visibility-toggle input[type="checkbox"]:checked {
  background: var(--bb-success-gradient);
  border-color: var(--bb-green);
}

.party-visibility-toggle input[type="checkbox"]:checked::after {
  content: "✓";
  font: 900 var(--bb-text-lg)/1 var(--bb-font-body);
}

.party-visibility-toggle input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--bb-field-focus);
  outline-offset: 3px;
}

.party-visibility-toggle input[type="checkbox"]:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

:is(.party-discovery-status, .party-settings-status).is-error {
  color: var(--bb-red);
}

:is(.party-discovery-panel, .party-settings-panel) {
  font-family: var(--bb-font-body);
}

:is(.party-discovery-panel, .party-settings-panel) .trophy-overlay-head p {
  color: var(--bb-text-soft);
}


:is(.party-discovery-panel, .party-settings-panel) .trophy-overlay-head h2 {
  line-height: 1.5;
}

/* Match completion is a compact reward reveal, not a dense scoreboard. */
.bb-game-over-backdrop {
  position: fixed;
  inset: 0;
  z-index: 14000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
  color: var(--bb-text);
  background: var(--bb-popup-backdrop);
  font-family: var(--bb-font-body);
}

.bb-game-over-card {
  position: relative;
  width: min(680px, 94vw);
  max-height: min(800px, 92dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 26px 24px;
  text-align: center;
  isolation: isolate;
}

.bb-game-over-card::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.48;
  background:
    linear-gradient(115deg, transparent 20%, rgba(255, 255, 255, 0.055) 45%, transparent 68%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 5px);
}



.bb-game-over-hero {
  position: relative;
  flex: 0 0 auto;
  margin: 0 -26px;
  padding: 20px 26px 18px;
  overflow: hidden;
  border-bottom: 2px solid rgba(255, 255, 255, 0.13);
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.24), transparent 35%),
    var(--bb-header-gradient);
  box-shadow: inset 0 -12px 24px rgba(3, 7, 18, 0.16);
}

.bb-game-over-card.is-victory .bb-game-over-hero {
  background:
    radial-gradient(circle at 50% 12%, rgba(218, 255, 237, 0.28), transparent 36%),
    linear-gradient(100deg, #16775c, #228e70 48%, #3569a9);
}

.bb-game-over-card.is-defeat .bb-game-over-hero {
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 214, 222, 0.19), transparent 36%),
    linear-gradient(100deg, #6d2940, #88434c 48%, #45457f);
}

.bb-game-over-kicker {
  display: block;
  margin-bottom: 9px;
  color: rgba(236, 245, 255, 0.78);
  font-family: var(--bb-font-display);
  font-size: 7px;
  line-height: 1.2;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  animation: bb-game-over-rise 420ms 90ms var(--bb-ease) both;
}

.bb-game-over-title {
  margin: 0;
  color: #fff;
  font-family: var(--bb-font-display);
  font-size: clamp(30px, 5.2vw, 50px);
  line-height: 1.12;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow:
    0 4px 0 rgba(2, 5, 12, 0.48),
    0 0 24px rgba(255, 255, 255, 0.18);
  animation: bb-game-over-title-in 620ms 80ms cubic-bezier(0.12, 0.78, 0.25, 1.2) both;
}

.bb-game-over-title.is-victory {
  color: #baffd4;
  text-shadow:
    0 4px 0 #07533b,
    0 0 30px rgba(119, 255, 183, 0.38);
}

.bb-game-over-title.is-defeat {
  color: #ffb3bd;
  text-shadow:
    0 4px 0 #641e32,
    0 0 25px rgba(255, 117, 139, 0.25);
  animation: bb-game-over-defeat-in 820ms 80ms cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.bb-game-over-title.is-draw {
  color: #ffe6a6;
}

.bb-game-over-hero p {
  margin: 9px 0 0;
  color: rgba(242, 247, 255, 0.88);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
  animation: bb-game-over-rise 430ms 230ms var(--bb-ease) both;
}

.bb-game-over-content {
  min-height: 0;
  overflow: auto;
  padding: 3px 3px 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--bb-border) transparent;
}

.bb-game-over-summary,
.bb-game-over-results {
  margin-top: 17px;
  text-align: left;
}

.bb-game-over-summary {
  animation: bb-game-over-rise 500ms 260ms var(--bb-ease) both;
}

.bb-game-over-results {
  animation: bb-game-over-rise 500ms 390ms var(--bb-ease) both;
}

.bb-game-over-summary h2,
.bb-game-over-results h2 {
  margin: 0 0 10px;
  color: var(--bb-text-muted);
  font-family: var(--bb-font-display);
  font-size: 8px;
  line-height: 1.35;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(2, 5, 12, 0.7);
}

.bb-game-over-rewards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bb-game-over-reward {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  border: 2px solid #4e5562;
  background: linear-gradient(180deg, #1d2a3c, #101a29);
  box-shadow:
    0 4px 0 var(--bb-ink),
    inset 0 2px rgba(255, 255, 255, 0.08);
}

.bb-game-over-reward::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.18;
  background: linear-gradient(110deg, transparent 38%, #fff 50%, transparent 62%);
  transform: translateX(-100%);
  animation: bb-game-over-sheen 850ms 650ms ease-out both;
}

.bb-game-over-reward.is-coins {
  border-color: #7b6532;
}

.bb-game-over-reward.is-gems {
  border-color: #376879;
}

.bb-game-over-reward.is-trophies {
  border-color: #796a3d;
}

.bb-game-over-reward.is-negative {
  border-color: #7c3d4d;
  background: linear-gradient(180deg, #3b2230, #1d1521);
}

.bb-game-over-reward.is-zero {
  opacity: 0.58;
}

.bb-game-over-reward-icon {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
}

.bb-game-over-reward-icon i {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  opacity: 0.34;
  background: #f5c94d;
  filter: blur(9px);
}

.bb-game-over-reward.is-gems .bb-game-over-reward-icon i {
  background: #56d8ff;
}

.bb-game-over-reward.is-negative .bb-game-over-reward-icon i {
  background: #ff6f8b;
}

.bb-game-over-reward-icon img {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.45));
  transition: opacity 180ms ease, transform 180ms ease;
}

.bb-game-over-reward.is-collecting .bb-game-over-reward-icon img {
  opacity: 0.58;
  transform: scale(0.86);
}

.bb-game-over-reward > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bb-game-over-reward small {
  color: var(--bb-text-muted);
  font-family: var(--bb-font-display);
  font-size: 6px;
  line-height: 1;
  text-transform: uppercase;
}

.bb-game-over-reward strong {
  overflow: hidden;
  color: #ffd45d;
  font-family: var(--bb-font-display);
  font-size: clamp(12px, 2vw, 17px);
  line-height: 1.2;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.bb-game-over-reward.is-gems strong {
  color: #71e3ff;
}

.bb-game-over-reward.is-trophies strong {
  color: #ffe08b;
}

.bb-game-over-reward.is-negative strong {
  color: #ff91a6;
}

.bb-game-over-results-table {
  overflow: hidden;
  border: 2px solid var(--bb-border-soft);
  background: rgba(8, 18, 36, 0.76);
  box-shadow: var(--bb-inset-shadow);
}

.bb-game-over-result-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(76px, 1fr) minmax(58px, 0.7fr);
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(176, 219, 255, 0.13);
  color: var(--bb-text-soft);
  font-family: var(--bb-font-display);
  font-size: 9px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.bb-game-over-result-row:last-child {
  border-bottom: 0;
}

.bb-game-over-result-row > :first-child {
  overflow: hidden;
  color: var(--bb-text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bb-game-over-result-row.is-header {
  min-height: 30px;
  color: var(--bb-text-muted);
  background: rgba(32, 55, 86, 0.55);
  font-size: 7px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.bb-game-over-result-row.is-header > :first-child {
  color: var(--bb-text-muted);
}

.bb-game-over-result-row.is-you {
  background: linear-gradient(90deg, rgba(61, 145, 235, 0.2), rgba(61, 145, 235, 0.07));
  box-shadow: inset 3px 0 #4b9cf0;
}

.bb-game-over-you {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 5px;
  color: #b9dcff;
  background: rgba(66, 145, 226, 0.26);
  font-family: var(--bb-font-display);
  font-size: 6px;
  line-height: 1;
  text-transform: uppercase;
  vertical-align: 2px;
}

.bb-game-over-action {
  min-width: min(300px, 82vw);
  min-height: 50px;
  flex: 0 0 auto;
  align-self: center;
  margin-top: 22px;
  padding: 12px 20px;
  color: #fff;
  background: var(--bb-primary-gradient);
  animation: bb-game-over-rise 500ms 510ms var(--bb-ease) both;
}

.bb-game-over-wallet {
  position: fixed;
  z-index: 15000;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-14px) scale(0.96);
}

.bb-game-over-wallet.is-active {
  animation: bb-game-over-wallet-in 340ms var(--bb-ease) forwards;
}

.bb-game-over-wallet.is-complete > span {
  border-color: #6989ac;
}

.bb-game-over-wallet.is-leaving {
  animation: bb-game-over-wallet-out 360ms ease-in forwards;
}

.bb-game-over-wallet > span {
  min-width: 108px;
  min-height: 44px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 2px solid #324c6d;
  background: rgba(7, 15, 28, 0.96);
  box-shadow:
    0 5px 0 var(--bb-ink),
    0 9px 20px rgba(0, 0, 0, 0.38),
    inset 0 2px rgba(255, 255, 255, 0.08);
  transform-origin: center;
  transition: border-color 180ms ease;
}

.bb-game-over-wallet img {
  width: 25px;
  height: 25px;
  object-fit: contain;
  image-rendering: pixelated;
}

.bb-game-over-wallet > span > span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bb-game-over-wallet small {
  color: #8da2bf;
  font-family: var(--bb-font-display);
  font-size: 5px;
  line-height: 1;
  text-transform: uppercase;
}

.bb-game-over-wallet strong {
  overflow: hidden;
  color: #fff;
  font-family: var(--bb-font-display);
  font-size: 8px;
  line-height: 1;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.bb-game-over-celebration {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bb-game-over-celebration i {
  --spark-angle: calc(var(--spark-index) * 25.72deg);
  position: absolute;
  left: 50%;
  top: 88px;
  width: 4px;
  height: 13px;
  background: #c8e8ff;
  box-shadow: 0 0 8px currentColor;
  opacity: 0;
  animation: bb-game-over-burst 760ms calc(110ms + var(--spark-index) * 13ms) cubic-bezier(0.1, 0.65, 0.22, 1) both;
}

.bb-game-over-card.is-victory .bb-game-over-celebration i:nth-child(3n + 1) {
  color: #74ffc0;
  background: #74ffc0;
}

.bb-game-over-card.is-victory .bb-game-over-celebration i:nth-child(3n + 2),
.bb-game-over-card.is-draw .bb-game-over-celebration i:nth-child(odd) {
  color: #ffe580;
  background: #ffe580;
}

.bb-game-over-card.is-defeat .bb-game-over-celebration i {
  left: calc(12% + var(--spark-index) * 5.8%);
  top: 42px;
  color: #e990a1;
  background: #e990a1;
  animation: bb-game-over-defeat-fall 1100ms calc(160ms + var(--spark-index) * 36ms) ease-in both;
}

.bb-game-over-flying-reward {
  position: fixed;
  z-index: 15010;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  opacity: 0;
  will-change: transform;
  filter:
    drop-shadow(0 5px 6px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 7px rgba(255, 220, 112, 0.42));
}

.bb-game-over-flying-reward.is-gems {
  filter:
    drop-shadow(0 5px 6px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 8px rgba(86, 216, 255, 0.55));
}

.bb-game-over-wallet-spark {
  position: fixed;
  z-index: 15011;
  width: 6px;
  height: 6px;
  border: 1px solid #fff4c7;
  background: #ffbf35;
  box-shadow: 0 0 8px rgba(255, 193, 53, 0.8);
  pointer-events: none;
}

.bb-game-over-wallet-spark.is-gems {
  border-color: #e3fbff;
  background: #56d8ff;
  box-shadow: 0 0 9px rgba(86, 216, 255, 0.9);
}

.bb-game-over-wallet-spark.is-trophies {
  border-color: #fff6ce;
  background: #f7d567;
  box-shadow: 0 0 9px rgba(247, 213, 103, 0.9);
}

@keyframes bb-game-over-title-in {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.72);
    letter-spacing: -3px;
  }
  72% {
    opacity: 1;
    transform: translateY(-2px) scale(1.045);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bb-game-over-defeat-in {
  0% {
    opacity: 0;
    transform: translateY(-14px) rotate(-1deg);
    letter-spacing: 4px;
  }
  62% {
    opacity: 1;
    transform: translateY(5px) rotate(0.5deg);
  }
  100% {
    opacity: 1;
    transform: translateY(3px) rotate(0);
    letter-spacing: 2px;
  }
}

@keyframes bb-game-over-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bb-game-over-sheen {
  from { transform: translateX(-110%); }
  to { transform: translateX(110%); }
}

@keyframes bb-game-over-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(0) scale(0.3);
  }
  24% { opacity: 0.95; }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-155px) scale(0.55);
  }
}

@keyframes bb-game-over-defeat-fall {
  0% {
    opacity: 0;
    transform: translate(-50%, -12px) rotate(-8deg) scaleY(0.7);
  }
  18% { opacity: 0.58; }
  100% {
    opacity: 0;
    transform: translate(-50%, 150px) rotate(16deg) scaleY(1.15);
  }
}

@keyframes bb-game-over-wallet-in {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bb-game-over-wallet-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
}

@media (max-width: 680px) {
  .bb-game-over-backdrop {
    align-items: center;
    padding: max(66px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .bb-game-over-card,
  .bb-game-over-card.is-mobile {
    width: min(520px, 96vw);
    max-height: calc(100dvh - max(84px, env(safe-area-inset-top)));
    padding: 0 14px 16px;
  }

  .bb-game-over-hero {
    margin: 0 -14px;
    padding: 16px 14px 14px;
  }

  .bb-game-over-kicker {
    margin-bottom: 7px;
    font-size: 6px;
  }

  .bb-game-over-title {
    font-size: clamp(24px, 9vw, 36px);
  }

  .bb-game-over-hero p {
    margin-top: 7px;
    font-size: 11px;
  }

  .bb-game-over-summary,
  .bb-game-over-results {
    margin-top: 13px;
  }

  .bb-game-over-rewards {
    gap: 6px;
  }

  .bb-game-over-reward {
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px;
    text-align: center;
  }

  .bb-game-over-reward-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .bb-game-over-reward-icon img {
    width: 29px;
    height: 29px;
  }

  .bb-game-over-reward > span:last-child {
    align-items: center;
    gap: 4px;
  }

  .bb-game-over-reward small {
    font-size: 5px;
  }

  .bb-game-over-reward strong {
    font-size: clamp(10px, 3.4vw, 14px);
  }

  .bb-game-over-result-row {
    grid-template-columns: minmax(0, 1.65fr) minmax(66px, 0.85fr) minmax(45px, 0.5fr);
    gap: 6px;
    min-height: 36px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .bb-game-over-result-row.is-header {
    min-height: 27px;
    font-size: 5px;
  }

  .bb-game-over-action {
    min-height: 46px;
    margin-top: 16px;
    font-size: 9px;
  }

  .bb-game-over-wallet {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    justify-content: flex-end;
    gap: 5px;
  }

  .bb-game-over-wallet > span {
    min-width: 0;
    width: min(31%, 96px);
    min-height: 38px;
    grid-template-columns: 21px minmax(0, 1fr);
    gap: 5px;
    padding: 5px 6px;
  }

  .bb-game-over-wallet img {
    width: 21px;
    height: 21px;
  }

  .bb-game-over-wallet small {
    font-size: 4px;
  }

  .bb-game-over-wallet strong {
    font-size: 6px;
  }
}


#battle-keybind-hud .bs-help-title {
  color: var(--bb-text);
  text-shadow: 0 2px 0 rgba(2, 5, 12, 0.7);
}

#battle-keybind-hud .controls-section {
  border: 2px solid var(--bb-border-soft);
  border-radius: var(--bb-radius-card);
  background: rgba(8, 18, 36, 0.76);
  box-shadow: var(--bb-inset-shadow);
}

#battle-keybind-hud kbd,
#battle-keybind-hud .bs-help-mouse {
  border: 2px solid var(--bb-ink);
  border-radius: var(--bb-radius-control);
  color: var(--bb-text);
  background: var(--bb-chroma-button-corners), var(--bb-primary-gradient);
  box-shadow:
    0 3px 0 var(--bb-ink),
    inset 0 2px rgba(255, 255, 255, 0.16);
}

#battle-keybind-hud kbd {
  font-family: var(--bb-font-display);
  text-shadow: 1px 2px 0 rgba(2, 5, 12, 0.7);
}

#battle-keybind-hud .controls-input-or {
  color: var(--bb-text-muted);
  font-family: var(--bb-font-body);
  font-size: 10px;
}

#battle-keybind-hud kbd.is-pressed,
#battle-keybind-hud .bs-help-action-row.is-pressed .bs-help-mouse {
  transform: translateY(2px);
  border-color: var(--bb-ink);
  color: var(--bb-text);
  background: var(--bb-chroma-button-corners), var(--bb-success-gradient);
  box-shadow:
    0 1px 0 var(--bb-ink),
    inset 0 2px rgba(0, 0, 0, 0.24);
}

@media (max-width: 600px) {
  :root {
    --bb-text-sm: 10px;
    --bb-title-lg: clamp(17px, 5vw, 24px);
  }

  .bb-popup-header {
    min-height: 56px;
    padding: 10px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Chroma surfaces: the texture is a background, so titles remain crisp above it. */
:is(.leaderboard-head, .trophy-rewards-head, .cards-modal-head,
    .shop-checkout-panel > header, .shop-reveal-heading,
    .bb-chat-header, .bb-chat-viewers-head) {
  background: var(--bb-header-gradient);
}

.bb-game-over-card.is-victory .bb-game-over-hero {
  background: var(--bb-chroma-mosaic), linear-gradient(100deg, #16775c, #228e70 48%, #3569a9);
}

.bb-game-over-card.is-defeat .bb-game-over-hero {
  background: var(--bb-chroma-mosaic), linear-gradient(100deg, #6d2940, #88434c 48%, #45457f);
}

/* Compact dialogs have a title instead of a separate header element. */
.cs-confirm {
  --bb-confirm-padding: var(--bb-popup-pad);
  padding: var(--bb-confirm-padding);
  overflow: hidden;
}

.cs-confirm .cs-confirm-title {
  margin: calc(-1 * var(--bb-confirm-padding)) calc(-1 * var(--bb-confirm-padding)) 16px;
  padding: 18px var(--bb-confirm-padding);
  background: var(--bb-header-gradient);
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.game-notice-card .game-notice-title {
  background: var(--bb-header-gradient);
}

/* Four stepped cells at each opposing corner. Translucent light and shade
   blend with the actual control fill, including hover and disabled variants.
   Use a low-specificity positioning default to retain absolute close controls. */
:where(.pixel-menu-button:not(.map-select-card), .bb-button, .profile-btn,
  .bb-close, .bb-chat-close, .shop-close, .shop-buy-button, .shop-checkout-close,
  .shop-reveal-panel > button, .shop-load-error button, .bb-chat-send,
  .sonner__btn, .status-action, .cs-btn, .switch-character, .status.invite,
  .character-card-status-text, .character-details-action,
  .profile-action-btn, .shop-tabs button) {
  position: relative;
}

:is(.pixel-menu-button:not(.map-select-card), .bb-button, .profile-btn,
  .bb-close, .bb-chat-close, .shop-close, .shop-checkout-close,
  .shop-reveal-panel > button, .shop-load-error button, .bb-chat-send,
  .sonner__btn, .status-action, .cs-btn, .switch-character, .status.invite,
  .character-card-status-text, .character-details-action,
  .profile-action-btn, .shop-tabs button)::before,
.shop-buy-button::after {
  content: "";
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    url("/assets/chromas/chroma-corner-light.svg") left top / var(--bb-chroma-corner-size, 18px) var(--bb-chroma-corner-size, 18px) no-repeat,
    url("/assets/chromas/chroma-corner-shade.svg") right bottom / var(--bb-chroma-corner-size, 18px) var(--bb-chroma-corner-size, 18px) no-repeat;
  opacity: 1;
  transform: none;
  filter: none;
  box-shadow: none;
}

.character-card-status-text {
  --bb-chroma-corner-size: 12px;
}

@media (max-width: 480px) {
  .cs-confirm { --bb-confirm-padding: 18px; }
}

.character-details-popup.is-character-locked .character-details-header {
  background: var(--bb-chroma-mosaic), linear-gradient(90deg, #515865, #343a45);
}

/* Left-aligned headings need a quiet, darker field beneath their copy. */
:is(.shop-header, .profile-popup-head, .profile-loadout-head,
    .cards-modal-head, .character-details-header, .cs-confirm-title,
    .shop-checkout-panel > header, .bb-chat-header, .bb-chat-viewers-head,
    .party-join-request-panel, .party-join-request-owner-panel,
    .party-discovery-panel, .party-settings-panel) {
  --bb-chroma-header-veil: linear-gradient(90deg, rgba(30, 133, 185, .82) 0%, rgba(42, 103, 193, .94) 42%, rgba(48, 77, 188, .65) 65%, transparent 90%);
  --bb-header-gradient: var(--bb-chroma-header-veil), var(--bb-chroma-mosaic), linear-gradient(100deg, #159dc9, #304bc4 62%, #3926a4);
}

/* Longer actions carry a few extra, progressively quieter cells along the edge. */
:is(.character-details-action, .bb-game-over-action, .profile-action-btn,
    .cs-btn, .party-request-submit, .party-request-return,
    .party-button:not(.party-search-button):not(.party-settings-button),
    .shop-tabs button, .shop-reveal-panel > button)::before,
.shop-buy-button::after {
  background: var(--bb-chroma-button-trail), var(--bb-chroma-button-corners);
}

/* Ready is an input: browsers do not paint pseudo-elements on input controls.
   Paint the same accents into its background and retain all state colors. */
#ready {
  --bb-ready-fill: linear-gradient(135deg, #b49e20, #bda322);
  background: var(--bb-chroma-button-trail), var(--bb-chroma-button-corners), var(--bb-ready-fill) !important;
}
#ready:hover { --bb-ready-fill: linear-gradient(135deg, #d4ba3a, #c6991b); }
#ready.cancel { --bb-ready-fill: linear-gradient(135deg, #ff4757, #dc3545); }
#ready.cancel:hover { --bb-ready-fill: linear-gradient(135deg, #dc3545, #c82333); }
#ready.battle-in-progress { --bb-ready-fill: linear-gradient(135deg, #2879df, #1856b8); }
#ready.battle-in-progress:hover { --bb-ready-fill: linear-gradient(135deg, #398bf0, #2468ce); }

/* Varied mineral-toned pixels over the lobby’s separate midnight palette. */
#navbar,
.site-header {
  background:
    linear-gradient(90deg, rgba(16, 29, 47, .76), rgba(23, 26, 42, .94) 38%, rgba(34, 24, 40, .88) 72%, rgba(43, 27, 39, .76)),
    linear-gradient(100deg, #243d50, #262b40 48%, #493042);
  border-bottom: 2px solid #424052;
  box-shadow: 0 4px 16px rgba(5, 13, 35, .35), inset 0 2px rgba(182, 186, 208, .09);
}

#navbar > .flex:first-child h2 {
  text-shadow: 0 2px 0 #090e19;
}

/* Sparse color at the edges, with a quiet center and clear foreground text. */
#navbar::before,
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: url("/assets/chromas/lobby-chroma-mosaic.svg") top left / 576px 96px repeat;
  mask-image: linear-gradient(90deg, #000 0%, rgba(0, 0, 0, .65) 9%, transparent 25%, transparent 93%, rgba(0, 0, 0, .45) 100%);
  -webkit-mask-image: linear-gradient(90deg, #000 0%, rgba(0, 0, 0, .65) 9%, transparent 25%, transparent 93%, rgba(0, 0, 0, .45) 100%);
}
#navbar > *,
.site-header > * {
  position: relative;
}
#navbar .lobby-wordmark,
.site-header .lobby-wordmark {
  width: 176px;
  margin: 0 0 0 4px;
}
#navbar .lobby-wordmark img,
.site-header .lobby-wordmark img {
  display: block;
  width: 100%;
  height: auto;
}
@media(max-width:1099px){#navbar .lobby-wordmark,.site-header .lobby-wordmark{width:132px}}
@media(max-width:650px){#navbar .lobby-wordmark,.site-header .lobby-wordmark{width:120px}}

/* Shop actions use larger square cells and wider corner clusters. */
.shop-buy-button,
.shop-reveal-panel > button,
.party-button.shop-button {
  --bb-chroma-corner-size: 27px;
  --bb-chroma-trail-cell: 9px;
  --bb-chroma-button-corners:
    url("/assets/chromas/chroma-corner-light.svg") left top / 27px 27px no-repeat,
    url("/assets/chromas/chroma-corner-shade.svg") right bottom / 27px 27px no-repeat;
}
.shop-buy-button, .shop-reveal-panel > button, .party-button.shop-button {
  --bb-chroma-button-trail:
    linear-gradient(rgba(255,255,255,.20), rgba(255,255,255,.20)) left 12% top 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(255,255,255,.15), rgba(255,255,255,.15)) left 20% top var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(255,255,255,.10), rgba(255,255,255,.10)) left 28% top 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(255,255,255,.06), rgba(255,255,255,.06)) left 35% top var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.20), rgba(8,16,32,.20)) right 12% bottom 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.15), rgba(8,16,32,.15)) right 20% bottom var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.10), rgba(8,16,32,.10)) right 28% bottom 0 / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat,
    linear-gradient(rgba(8,16,32,.06), rgba(8,16,32,.06)) right 35% bottom var(--bb-chroma-trail-cell, 6px) / var(--bb-chroma-trail-cell, 6px) var(--bb-chroma-trail-cell, 6px) no-repeat;
}
/* Shared compact chrome. The lobby stays in document flow so overlays can cover it. */
#navbar,.site-header{top:0;left:0;right:0;width:100%;height:60px;min-height:60px;box-sizing:border-box;padding:8px 24px;z-index:1000}
#navbar{position:relative!important}.site-header{position:fixed!important}
@media(max-width:650px){#navbar,.site-header{padding:8px 16px}}

/* Keep currency glows static. Animating chained drop-shadows on every image
   creates continuously changing filter surfaces, especially on Trophy Road. */
img:is([src*="/coin.webp"], [src*="/gem.webp"], [src*="/currency/coins-"], [src*="/currency/gems-"]) {
  --currency-light: 255, 211, 80;
  filter: drop-shadow(0 0 var(--currency-bloom-size, 3px) rgba(var(--currency-light), .25));
}
img:is([src*="/gem.webp"], [src*="/currency/gems-"]) { --currency-light: 86, 219, 255; }

/* Chat views uses the compact tooltip surface, not a full dialog header. */
.bb-chat-viewers-popup .bb-chat-viewers-card {
  box-sizing: border-box;
  width: min(228px, calc(100vw - 16px));
  max-height: min(200px, calc(100vh - 16px));
  transform: translateY(var(--chat-popover-offset, -3px));
  transition: opacity 120ms ease, transform 120ms ease;
}
.bb-chat-viewers-popup .bb-chat-viewers-card.is-visible {
  transform: translateY(0);
}
.bb-chat-viewers-popup .bb-chat-viewers-backdrop { background: transparent; }
.bb-chat-viewers-popup .bb-chat-viewers-head {
  min-height: 0;
  padding: 5px 8px;
  background: none;
  border-bottom: 1px solid #ffffff12;
}
.bb-chat-viewers-popup .bb-chat-viewers-title { font-size: 8px; }
.bb-chat-viewers-popup .bb-chat-viewers-list { padding: 5px 8px; gap: 4px; }
.bb-chat-viewers-popup .bb-chat-viewer-row {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 6px;
  padding: 3px 0;
  border: 0;
  background: none;
}
.bb-chat-viewers-popup .bb-chat-viewer-avatar { width: 20px; height: 20px; border-radius: 0; }
.bb-chat-viewers-popup .bb-chat-viewer-name { font-size: 10px; overflow-wrap: anywhere; }
.bb-chat-viewers-popup .bb-chat-viewer-time { font-size: 9px; white-space: nowrap; }
.bb-chat-viewers-popup .bb-chat-viewers-empty { padding: 5px 0; }
.bb-chat-viewers-popup .bb-chat-viewers-head button[data-chat-viewers-close] {
  --bb-close-size: 20px;
  --bb-close-font-size: 8px;
  --bb-chroma-corner-size: 9px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  height: 20px !important;
  min-height: 20px !important;
  max-height: 20px !important;
  flex: 0 0 20px;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
}
.bb-chat-viewers-popup .bb-chat-viewers-head button[data-chat-viewers-close]::after { content: none; }

/* ==========================================================================
   Design system contract
   --------------------------------------------------------------------------
   The single source for popup shells, cards, and currency chips in the lobby
   and battle UI. Component stylesheets own layout and content only; they do
   not restate these frames. `body` lifts these rules above component rules
   that load later (lazy chunks such as the shop) without needing !important.
   ========================================================================== */

/* ---- Popups & modals: identical surface, border, corners, and shadow. ---- */
body :is(
  .character-select-popup,
  .character-details-popup,
  .trophy-overlay-panel,
  .profile-popup,
  .profile-loadout-modal,
  .party-popup,
  .party-join-request-panel,
  .party-join-request-owner-panel,
  .party-discovery-panel,
  .party-settings-panel,
  .shop-window,
  .cs-confirm,
  .bb-game-over-card,
  .game-notice-card,
  .profile-slot-menu,
  .bb-chat-viewers-card,
  .email-dialog,
  .site-dialog
),
body #battle-keybind-hud .controls-popover,
body .site-dialog.site-settings-side[open] {
  border: var(--bb-popup-border-width) solid var(--bb-popup-border-color);
  border-radius: 0;
  color: var(--bb-text);
  background: var(--bb-popup-bg);
  box-shadow: var(--bb-popup-shadow);
}

/* Checkout hosts the payment provider's light form, so it keeps its fill. */
body .shop-checkout-panel {
  border: var(--bb-popup-border-width) solid var(--bb-popup-border-color);
  border-radius: 0;
  box-shadow: var(--bb-popup-shadow);
}

/* Inner decorative frames were drawn for rounded windows. */
body .shop-window::after {
  display: none;
}

/* The chroma header strip under the window title. */
body .character-select-popup::before {
  border-bottom: var(--bb-popup-divider);
}

body :is(.shop-header, .trophy-overlay-head, .profile-popup-head, .profile-loadout-head,
  .character-details-header, .bb-chat-header, .site-dialog > header) {
  border-bottom: var(--bb-popup-divider);
}

body .shop-header {
  background: var(--bb-header-gradient);
}

/* ---- Cards: the profile icon tile is the benchmark. ---------------------
   Variants never restate the frame. They set:
     --bb-card-accent / --bb-card-accent-hover   border color
     --bb-card-fill   / --bb-card-fill-hover     background
     --bb-card-halo                              extra glow or inset lip    */
body :is(
  .character-card,
  .map-select-card,
  .trophy-lane-card,
  .profile-icon-choice-tile,
  .profile-card-tile,
  .profile-metric-card,
  .profile-character-level-card,
  .party-discovery-card,
  .party-request-card,
  .party-request-summary-card,
  .battle-card,
  .shop-offer
) {
  border: var(--bb-card-border-width) solid var(--bb-card-accent, var(--bb-card-border-color));
  border-radius: 0;
  box-shadow: var(--bb-card-shadow), var(--bb-card-halo, 0 0 transparent);
  transition:
    translate var(--bb-motion-fast) var(--bb-ease),
    border-color var(--bb-motion-fast) ease,
    background-color var(--bb-motion-fast) ease,
    box-shadow var(--bb-motion-fast) ease;
}

/* Shop offers paint rarity light into their own fill; every other card uses the token. */
body :is(
  .character-card,
  .map-select-card,
  .trophy-lane-card,
  .profile-icon-choice-tile,
  .profile-card-tile,
  .profile-metric-card,
  .profile-character-level-card,
  .party-discovery-card,
  .party-request-card,
  .party-request-summary-card,
  .battle-card
) {
  background: var(--bb-card-fill, var(--bb-card-bg));
}

/* Interactive cards lift 2px. `translate` composes with layout transforms
   (Trophy Road positions its cards with translateX(-50%)). */
body :is(
  .character-card,
  .map-select-card,
  .profile-icon-choice-tile,
  .profile-card-tile,
  .battle-card
):is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]) {
  border-color: var(--bb-card-accent-hover, var(--bb-card-border-hover));
  background: var(--bb-card-fill-hover, var(--bb-card-bg-hover));
  translate: 0 -2px;
}

body :is(
  .character-card,
  .map-select-card,
  .profile-icon-choice-tile,
  .profile-card-tile
):active:not(:disabled):not([aria-disabled="true"]) {
  translate: 0 1px;
  box-shadow: var(--bb-card-shadow-pressed);
}

body :is(.character-card, .map-select-card, .profile-icon-choice-tile, .profile-card-tile):focus-visible {
  outline: 2px solid var(--bb-border-highlight);
  outline-offset: 5px;
}

/* Selected / current choice. */
body :is(
  .character-card.selected,
  .map-select-card.active,
  .profile-icon-choice-tile.is-selected,
  .profile-card-tile.is-selected
) {
  --bb-card-accent: var(--bb-card-border-selected);
  --bb-card-accent-hover: var(--bb-card-border-selected);
  --bb-card-halo: inset 0 -3px 0 var(--bb-green-deep);
}

/* Locked or unavailable. */
body :is(.character-card.locked, .mode-select-card.is-trophy-locked) {
  --bb-card-fill: var(--bb-card-locked-bg);
  --bb-card-fill-hover: linear-gradient(180deg, #1b2333, #0f1520);
  --bb-card-accent: var(--bb-card-locked-border);
  --bb-card-accent-hover: #44526a;
}

/* Vibrant progression accents: same frame, accent color only. */
body .character-card.is-maxed {
  --bb-card-fill: radial-gradient(circle at 18% 34%, rgba(255, 207, 82, 0.1), transparent 44%), var(--bb-card-bg);
  --bb-card-fill-hover: radial-gradient(circle at 18% 34%, rgba(255, 207, 82, 0.14), transparent 44%), var(--bb-card-bg-hover);
  --bb-card-halo: inset 0 3px rgba(255, 230, 143, 0.24);
}

body .character-card.is-upgrade-ready {
  --bb-card-halo: inset 0 3px rgba(255, 215, 125, 0.24);
}

body .trophy-lane-card.claimable {
  --bb-card-accent: #38d66c;
  --bb-card-halo: 0 0 22px rgba(56, 214, 108, 0.3);
}

body .trophy-lane-card.major {
  --bb-card-accent: #e5a93b;
  --bb-card-halo: 0 0 22px rgba(229, 169, 59, 0.3);
}

/* Shop offers share the standard card border; only real rarities tint it. */
body .shop-offer.has-rarity:not(.shop-rarity-common) {
  --bb-card-accent: rgba(var(--rarity-rgb), 0.7);
}

body .shop-offer.has-rarity {
  --bb-card-halo: 0 0 24px rgba(var(--rarity-rgb), 0.14);
}

body .shop-offer.has-rarity:is(.shop-rarity-epic, .shop-rarity-legendary) {
  --bb-card-halo: 0 0 34px rgba(var(--rarity-rgb), 0.22), inset 0 0 22px rgba(var(--rarity-rgb), 0.06);
}

/* Battle log keeps its result stripe on the left edge. */
body .battle-card:is(.victory, .defeat, .draw, .unknown) {
  border-left-width: 4px;
}

/* Profile metrics: accent stripe only, on the shared card fill. */
body .profile-metric-card::after {
  height: 3px;
  background: var(--profile-metric-accent);
  opacity: 1;
}

body .profile-metric-card[data-profile-metric="coins"] {
  --profile-metric-accent: var(--bb-coin);
}

body .profile-metric-card[data-profile-metric="gems"] {
  --profile-metric-accent: var(--bb-gem);
  --profile-metric-glow: rgba(86, 219, 255, 0.2);
}

/* Card inner media frames are square too. */
body :is(.map-select-card img, .trophy-lane-item-wrap, .profile-icon-art) {
  border-radius: 0;
}

/* ---- Card typography: titles and labels use the pixel face. ---- */
body :is(
  .profile-icon-details strong,
  .map-select-name,
  .character-card-name,
  .profile-character-level-name,
  .party-discovery-title
) {
  font-family: var(--bb-font-display);
  font-size: var(--bb-card-title-size);
  font-weight: 400;
  line-height: 1.5;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

body .profile-metric-card > span:not(.profile-metric-icon) {
  color: var(--bb-text-muted);
  font-family: var(--bb-font-display);
  font-size: 8px;
  letter-spacing: 0;
}

body .profile-metric-card strong {
  font-family: var(--bb-font-display);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

body .profile-icon-status,
body .profile-icon-requirement {
  font-size: 12px;
}

/* ---- Card grid rhythm: room for the 4px ink ring plus a clear gutter. ---- */
body :is(
  .characters-grid,
  .map-select-grid,
  .mode-select-grid,
  .shop-offer-grid,
  .profile-icon-group-grid,
  .profile-cards-grid,
  .profile-character-levels-grid,
  .party-bot-picker-grid,
  .party-request-summary-grid
) {
  gap: var(--bb-card-grid-gap);
}

/* ---- Currency: one chip for the lobby header, shop wallet, and reveals. ---- */
body :is(.currency-resource, .shop-header-wallet > span, .shop-reveal-wallet > span) {
  display: inline-flex;
  align-items: center;
  gap: var(--bb-space-2);
  min-width: 0;
  min-height: 34px;
  height: auto;
  padding: 4px 12px 4px 8px;
  border: var(--bb-currency-chip-border);
  border-radius: 0;
  background: var(--bb-currency-chip-bg);
  box-shadow: var(--bb-currency-chip-shadow);
}

body :is(.currency-resource, .shop-header-wallet > span, .shop-reveal-wallet > span) img {
  width: var(--bb-currency-icon);
  height: var(--bb-currency-icon);
  object-fit: contain;
  image-rendering: pixelated;
}

body :is(.currency-resource p, .shop-header-wallet strong, .shop-reveal-wallet strong) {
  margin: 0;
  color: var(--bb-text);
  font: 400 10px/1 var(--bb-font-display);
  font-variant-numeric: tabular-nums;
  text-shadow: 1px 2px 0 var(--bb-ink);
}

/* Labels repeat what the icon already says; the chip stays compact. */
body :is(.shop-header-wallet small, .shop-reveal-wallet small) {
  display: none;
}

body .currency-resource:is(:hover, :focus-visible) {
  border-color: var(--bb-border-highlight);
  background: var(--bb-currency-chip-bg);
  filter: brightness(1.12);
}

body .shop-header-wallet,
body .shop-reveal-wallet,
#navbar-right .resources {
  gap: var(--bb-space-3);
}

/* ---- Tags and small badges stay square. ---- */
body :is(.trophy-claim-badge, .bb-chat-tab-count, .shop-rarity-badge, .profile-card-rarity) {
  border-radius: 0;
}

/* ---- Spacing rhythm: pixel controls draw a 5px ink ring on every side, so
   rows and stacks of them need the action gap to read as separate buttons. ---- */
body :is(
  .cs-confirm-actions,
  .game-notice-actions,
  .party-settings-actions,
  .party-request-actions-row,
  .profile-account-actions,
  .profile-guest-actions,
  .profile-loadout-head-actions,
  .mm-actions,
  .mm-fill-actions,
  .lobby-quick-actions,
  .bb-friends-actions
) {
  gap: var(--bb-action-gap);
}

body .game-notice-card {
  padding: var(--bb-popup-pad);
}

body .game-notice-card .game-notice-title {
  margin: calc(-1 * var(--bb-popup-pad)) calc(-1 * var(--bb-popup-pad)) var(--bb-space-4);
  padding: 18px var(--bb-popup-pad);
  border-bottom: var(--bb-popup-divider);
}

/* ---- Typography rule: headings, labels, names, values, and table text use the
   pixel face. Sentences and paragraphs stay in the readable body face. ---- */
body :is(
  .profile-panel h3,
  .profile-form label,
  .party-public-name-label,
  .party-request-summary-card span,
  .party-request-summary-card strong,
  .party-request-card-copy strong,
  .party-request-pill,
  .bb-mobile-jump-label
) {
  font-family: var(--bb-font-display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
}

/* Section headings inside popups. */
body .profile-panel h3 {
  color: var(--bb-text);
  font-size: 11px;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

/* Small caps-style labels above a value or field. */
body :is(.profile-form label, .party-public-name-label, .party-request-summary-card span) {
  color: var(--bb-text-muted);
  font-size: 8px;
  text-transform: uppercase;
}

body .party-request-summary-card {
  display: grid;
  gap: var(--bb-space-2);
}

body .party-request-summary-card strong {
  color: var(--bb-text);
  font-size: 12px;
  text-shadow: 2px 2px 0 var(--bb-ink);
  overflow-wrap: anywhere;
}

body .party-request-card-copy strong {
  font-size: 10px;
}

body .party-request-pill {
  font-size: 7px;
  text-transform: uppercase;
}

body :is(
  .trophy-pack-contents,
  .leaderboard-name,
  .leaderboard-row small,
  .party-discovery-meta > span,
  .party-discovery-detail,
  .party-discovery-meta-label,
  .party-discovery-member-name,
  .profile-hero-class,
  .profile-bros-unlocked-count,
  .profile-bros-unlocked-count strong
) {
  font-family: var(--bb-font-display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
}

body :is(.trophy-pack-contents, .leaderboard-row small, .party-discovery-meta-label,
  .party-discovery-meta > span, .profile-bros-unlocked-count) {
  color: var(--bb-text-muted);
  font-size: 7px;
  text-transform: uppercase;
}

body :is(.leaderboard-name, .party-discovery-member-name) {
  font-size: 10px;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

body .party-discovery-member-name {
  font-size: 8px;
}

body .party-discovery-detail {
  font-size: 8px;
  text-transform: uppercase;
}

body .party-discovery-detail .party-discovery-meta-label {
  color: var(--bb-text-muted);
}

body .party-discovery-title {
  font-size: 12px;
}

body .profile-hero-class {
  color: var(--bb-gold);
  font-size: 10px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 var(--bb-ink);
}

body .profile-bros-unlocked-count strong {
  color: var(--bb-text);
  font-size: 8px;
}

/* Card preview uses the same popup frame, chroma header and close control. */
.player-card-preview.bb-popup {
  border: var(--bb-popup-border-width) solid var(--bb-popup-border-color);
  border-radius: var(--bb-radius-window);
  background: var(--bb-popup-bg);
  box-shadow: var(--bb-popup-shadow);
  font-family: var(--bb-font-body);
}
.player-card-preview[open] {
  animation: bb-popup-panel-in var(--bb-popup-motion) var(--bb-ease) both;
}
.player-card-preview::backdrop {
  background: var(--bb-popup-backdrop);
  backdrop-filter: blur(var(--bb-overlay-blur));
}
.player-card-preview figcaption {
  color: var(--bb-text-soft);
  font-family: var(--bb-font-display);
  font-size: var(--bb-text-sm);
  line-height: 1.6;
  text-transform: uppercase;
}
.shop-card-info.bb-button { background: var(--bb-primary-gradient); }

/* Shared loading emblem: opposing pixel blades clash on a gold impact spark.
 * The legacy status selector also supports server-rendered status pages. */
.bb-battle-loader,
.status-spinner {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: var(--bb-loader-size, 64px);
  height: var(--bb-loader-size, 64px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  vertical-align: middle;
  background:
    linear-gradient(var(--bb-gold), var(--bb-gold)) 50% 41% / 6% 32% no-repeat,
    linear-gradient(var(--bb-gold), var(--bb-gold)) 50% 41% / 32% 6% no-repeat,
    linear-gradient(#fff2c7, #fff2c7) 30% 30% / 6% 6% no-repeat,
    linear-gradient(#fff2c7, #fff2c7) 70% 30% / 6% 6% no-repeat;
  animation: bb-blade-impact 1.2s steps(1, end) infinite;
}
.bb-battle-loader::before,
.bb-battle-loader::after,
.status-spinner::before,
.status-spinner::after {
  content: "";
  position: absolute;
  top: 3%;
  left: 7%;
  width: 40%;
  height: 88%;
  /* Two transparent sprite cells share the same dimensions and grip pivot. */
  background: url("/assets/ui/loading-swords.webp") left top / 200% 100% no-repeat;
  image-rendering: pixelated;
  transform-origin: 50% 84%;
  transform: rotate(33deg);
  animation: bb-blue-blade-clash 1.2s steps(6, end) infinite;
}
.bb-battle-loader::after,
.status-spinner::after {
  left: 53%;
  background-position: right top;
  transform: rotate(-33deg);
  animation-name: bb-red-blade-clash;
}
.bb-battle-loader[hidden], .status-spinner[hidden] { display: none; }
/* Each hilt stays planted. Separated blades swing inward, strike, then recoil. */
@keyframes bb-blue-blade-clash {
  0%, 18%, 88%, 100% { transform: rotate(-16deg); }
  38%, 44% { transform: rotate(33deg); }
  55% { transform: rotate(27deg); }
  66% { transform: rotate(30deg); }
}
@keyframes bb-red-blade-clash {
  0%, 18%, 88%, 100% { transform: rotate(16deg); }
  38%, 44% { transform: rotate(-33deg); }
  55% { transform: rotate(-27deg); }
  66% { transform: rotate(-30deg); }
}
@keyframes bb-blade-impact {
  0%, 52%, 100% { background-size: 0 0; }
  38% { background-size: 6% 32%, 32% 6%, 6% 6%, 6% 6%; }
  46% { background-size: 4% 12%, 12% 4%, 4% 4%, 4% 4%; }
}
@media (prefers-reduced-motion: reduce) {
  .bb-battle-loader, .bb-battle-loader::before, .bb-battle-loader::after,
  .status-spinner, .status-spinner::before, .status-spinner::after {
    animation: none;
  }
}
