.fca-ball-battles {
  --bb-bg: #10151d;
  --bb-panel: #18212c;
  --bb-panel-2: #202c38;
  --bb-border: rgba(218, 230, 240, .16);
  --bb-text: #edf3f7;
  --bb-muted: #9eb0bd;
  --bb-blue: #4d8ed8;
  --bb-green: #4ca978;
  --bb-red: #d65a52;
  --bb-gold: #d7a13b;
  width: 100%;
  min-height: 100vh;
  padding: 14px;
  box-sizing: border-box;
  color: var(--bb-text);
  background: var(--bb-bg);
}

.fca-ball-battles *,
.fca-ball-battles *::before,
.fca-ball-battles *::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

.fca-ball-battles [hidden] {
  display: none !important;
}

.fca-bb-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  max-width: 1680px;
  margin: 0 auto 12px;
}

.fca-bb-view-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 160px));
  gap: 5px;
  max-width: 1680px;
  margin: 0 auto 12px;
}

.fca-bb-view-tabs button {
  min-height: 38px;
  border: 1px solid var(--bb-border);
  border-radius: 5px;
  color: var(--bb-muted);
  background: var(--bb-panel);
  cursor: pointer;
  font-weight: 700;
}

.fca-bb-view-tabs button.is-active {
  border-color: var(--bb-blue);
  color: var(--bb-text);
  background: var(--bb-blue);
}

.fca-bb-topbar h1,
.fca-bb-panel h2 {
  margin: 0;
  color: var(--bb-text);
}

.fca-bb-topbar h1 {
  font-size: 1.45rem;
  line-height: 1.15;
}

.fca-bb-kicker {
  margin: 0 0 2px;
  color: var(--bb-gold);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.fca-bb-topbar__actions,
.fca-bb-roster__tools,
.fca-bb-inline,
.fca-bb-save-lineup {
  display: flex;
  gap: 7px;
  align-items: center;
}

.fca-bb-workspace {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(400px, 1fr) minmax(240px, 320px);
  gap: 12px;
  align-items: start;
  max-width: 1680px;
  margin: 0 auto;
}

.fca-bb-setup,
.fca-bb-feed,
.fca-bb-arena-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.fca-ball-battles.is-view-setup .fca-bb-workspace,
.fca-ball-battles.is-view-codex .fca-bb-workspace {
  grid-template-columns: 1fr;
}

.fca-ball-battles.is-view-setup .fca-bb-setup {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fca-ball-battles.is-view-setup .fca-bb-arena-column,
.fca-ball-battles.is-view-setup .fca-bb-feed,
.fca-ball-battles.is-view-arena .fca-bb-setup,
.fca-ball-battles.is-view-arena .fca-bb-codex,
.fca-ball-battles.is-view-codex .fca-bb-setup,
.fca-ball-battles.is-view-codex .fca-bb-arena-column,
.fca-ball-battles.is-view-codex .fca-bb-results,
.fca-ball-battles.is-view-codex .fca-bb-commentary {
  display: none;
}

.fca-ball-battles.is-view-arena .fca-bb-workspace {
  grid-template-columns: minmax(460px, 1fr) minmax(250px, 340px);
}

.fca-ball-battles.is-view-codex .fca-bb-feed {
  display: block;
}

.fca-ball-battles.is-view-codex .fca-bb-codex {
  max-width: 1100px;
}

.fca-bb-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--bb-border);
  border-radius: 7px;
  background: var(--bb-panel);
}

.fca-bb-panel h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.fca-bb-panel label {
  display: grid;
  gap: 4px;
  margin: 9px 0;
  color: var(--bb-muted);
  font-size: .78rem;
  font-weight: 700;
}

.fca-ball-battles select,
.fca-ball-battles input,
.fca-ball-battles textarea {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--bb-border);
  border-radius: 5px;
  outline: none;
  color: var(--bb-text);
  background: var(--bb-panel-2);
}

.fca-ball-battles textarea {
  height: auto;
  min-height: 72px;
  padding: 8px 9px;
  resize: vertical;
}

.fca-ball-battles input[type="color"] {
  padding: 3px;
}

.fca-ball-battles select:focus,
.fca-ball-battles input:focus,
.fca-ball-battles button:focus-visible {
  border-color: var(--bb-blue);
  outline: 2px solid rgba(77, 142, 216, .32);
  outline-offset: 1px;
}

.fca-bb-button,
.fca-bb-icon-button,
.fca-bb-segmented button,
.fca-bb-ability {
  min-height: 36px;
  border: 1px solid var(--bb-border);
  border-radius: 5px;
  color: var(--bb-text);
  background: var(--bb-panel-2);
  cursor: pointer;
  font-weight: 700;
}

.fca-bb-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  padding: 7px 11px;
  text-decoration: none;
}

.fca-bb-button--primary {
  width: 100%;
  border-color: transparent;
  background: var(--bb-blue);
}

.fca-bb-button--ghost {
  color: var(--bb-muted);
  background: transparent;
}

.fca-bb-icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 1rem;
}

.fca-bb-button:hover,
.fca-bb-icon-button:hover,
.fca-bb-segmented button:hover,
.fca-bb-ability:hover {
  border-color: var(--bb-blue);
  background: #27384a;
}

.fca-bb-segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 10px;
}

.fca-bb-check {
  display: flex !important;
  align-items: center;
  gap: 7px !important;
}

.fca-bb-check input {
  width: 18px;
  height: 18px;
}

.fca-bb-segmented button {
  min-width: 0;
  padding: 5px 3px;
  font-size: .75rem;
}

.fca-bb-segmented button.is-active {
  border-color: var(--bb-blue);
  background: var(--bb-blue);
}

.fca-bb-panel summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--bb-text);
  cursor: pointer;
  font-weight: 700;
}

.fca-bb-panel[open] summary {
  margin-bottom: 10px;
}

.fca-bb-roster__tools select {
  flex: 1;
}

.fca-bb-fighter-picker,
.fca-bb-saved-lineups {
  display: grid;
  gap: 6px;
  max-height: 330px;
  margin-top: 9px;
  overflow: auto;
  scrollbar-width: thin;
}

.fca-bb-fighter-option,
.fca-bb-lineup-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--bb-border);
  border-radius: 5px;
  color: var(--bb-text);
  background: var(--bb-panel-2);
  cursor: pointer;
}

.fca-bb-fighter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.fca-bb-fighter-option {
  width: 100%;
  text-align: left;
}

.fca-bb-fighter-remove {
  width: 32px;
  min-width: 32px;
  border: 1px solid var(--bb-border);
  border-radius: 5px;
  color: var(--bb-red);
  background: var(--bb-panel-2);
  cursor: pointer;
}

.fca-bb-fighter-option.is-selected {
  border-color: var(--bb-green);
  box-shadow: inset 3px 0 var(--bb-green);
}

.fca-bb-fighter-option__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.fca-bb-fighter-option strong,
.fca-bb-fighter-option small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fca-bb-fighter-option small,
.fca-bb-note {
  color: var(--bb-muted);
  font-size: .72rem;
}

.fca-bb-tier {
  min-width: 26px;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--bb-bg);
  background: var(--bb-gold);
  font-size: .68rem;
  font-weight: 800;
  text-align: center;
}

.fca-bb-custom-form {
  display: grid;
  gap: 8px;
}

.fca-bb-creator-preview,
.fca-bb-vs-status {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-left: 3px solid var(--bb-gold);
  border-radius: 4px;
  color: var(--bb-muted);
  background: var(--bb-panel-2);
  font-size: .72rem;
}

.fca-bb-creator-preview strong {
  color: var(--bb-text);
}

.fca-bb-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.fca-bb-save-lineup {
  margin-top: 12px;
}

.fca-bb-save-lineup input {
  flex: 1;
}

.fca-bb-lineup-option .js-bb-delete-lineup {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--bb-border);
  border-radius: 4px;
  color: var(--bb-muted);
  background: transparent;
  cursor: pointer;
}

.fca-bb-lineup-option .js-bb-load-lineup {
  display: grid;
  gap: 2px;
  min-width: 0;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  color: var(--bb-text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.fca-bb-lineup-option .js-bb-load-lineup strong,
.fca-bb-lineup-option .js-bb-load-lineup small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fca-bb-lineup-option .js-bb-load-lineup small {
  color: var(--bb-muted);
}

.fca-bb-arena-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--bb-border);
  border-radius: 7px;
  background: #0b1118;
}

.fca-bb-arena-shell canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.fca-bb-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 20px;
  color: var(--bb-text);
  background: rgba(11, 17, 24, .78);
  text-align: center;
  pointer-events: none;
}

.fca-bb-overlay[hidden] {
  display: none;
}

.fca-bb-overlay strong {
  font-size: 1.35rem;
}

.fca-bb-overlay span {
  color: var(--bb-muted);
}

.fca-bb-fanfare {
  position: absolute;
  z-index: 5;
  inset: 50% auto auto 50%;
  display: grid;
  min-width: min(430px, calc(100% - 32px));
  padding: 18px 22px;
  border: 2px solid var(--bb-gold);
  border-radius: 7px;
  color: #fff;
  background: rgba(11, 17, 24, .88);
  box-shadow: 0 0 0 5px rgba(215, 161, 59, .14);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: fca-bb-fanfare-in .32s ease-out both;
}

.fca-bb-fanfare[hidden] {
  display: none;
}

.fca-bb-fanfare strong {
  font-size: clamp(1.5rem, 5vw, 3rem);
  line-height: 1;
  text-transform: uppercase;
}

.fca-bb-fanfare span {
  margin-top: 7px;
  color: var(--bb-muted);
  font-weight: 700;
}

.fca-bb-fanfare.is-ko,
.fca-bb-fanfare.is-lose {
  border-color: var(--bb-red);
  box-shadow: 0 0 0 5px rgba(214, 90, 82, .14);
}

.fca-bb-fanfare.is-win,
.fca-bb-fanfare.is-champion {
  border-color: var(--bb-green);
  box-shadow: 0 0 0 5px rgba(76, 169, 120, .16);
}

.fca-bb-fanfare.is-power {
  border-color: var(--bb-gold);
  box-shadow: 0 0 0 5px rgba(215, 161, 59, .16);
}

.fca-bb-cinematic {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 9, 14, .68);
}

.fca-bb-cinematic[hidden],
.fca-bb-ability-scene[hidden] {
  display: none;
}

.fca-bb-cinematic__card {
  display: grid;
  gap: 8px;
  width: min(620px, 100%);
  padding: 24px;
  border: 1px solid var(--bb-gold);
  border-left-width: 6px;
  border-radius: 7px;
  color: var(--bb-text);
  background: rgba(11, 17, 24, .98);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .38);
  animation: fca-bb-cinematic-in .34s ease-out both;
}

.fca-bb-cinematic__card small,
.fca-bb-cinematic__card code {
  color: var(--bb-gold);
  font-weight: 700;
  text-transform: uppercase;
}

.fca-bb-cinematic__card strong {
  font-size: clamp(1.55rem, 5vw, 2.8rem);
  line-height: 1;
}

.fca-bb-cinematic__card span {
  color: var(--bb-muted);
}

.fca-bb-cinematic__card .fca-bb-button {
  justify-self: start;
  margin-top: 5px;
}

.fca-bb-ability-scene {
  position: absolute;
  z-index: 6;
  inset: auto 12px 12%;
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-left: 5px solid var(--bb-gold);
  border-radius: 5px;
  color: var(--bb-text);
  background: rgba(11, 17, 24, .9);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  pointer-events: none;
  animation: fca-bb-ability-in .22s ease-out both;
}

.fca-bb-ability-scene small,
.fca-bb-ability-scene span {
  color: var(--bb-muted);
  font-size: .72rem;
  font-weight: 700;
}

.fca-bb-ability-scene strong {
  font-size: clamp(1rem, 3vw, 1.65rem);
}

.fca-bb-ability-scene .js-bb-ability-effect {
  color: var(--bb-text);
  font-weight: 400;
}

.fca-bb-ability-scene .js-bb-ability-rank {
  color: var(--bb-gold);
  text-transform: uppercase;
}

@keyframes fca-bb-fanfare-in {
  from { opacity: 0; transform: translate(-50%, -42%) scale(.88); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes fca-bb-cinematic-in {
  from { transform: translateY(20px) scale(.97); }
  to { transform: translateY(0) scale(1); }
}

@keyframes fca-bb-ability-in {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

.fca-bb-hud {
  position: absolute;
  inset: 8px 8px auto;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.fca-bb-hud span {
  padding: 4px 7px;
  border: 1px solid var(--bb-border);
  border-radius: 4px;
  color: var(--bb-muted);
  background: rgba(11, 17, 24, .84);
  font-size: .72rem;
  font-weight: 700;
}

.fca-bb-touch-controls {
  display: grid;
  grid-template-columns: minmax(180px, 280px);
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.fca-bb-touch-controls[hidden] {
  display: none;
}

.fca-bb-ability {
  display: grid;
  place-content: center;
  min-height: 74px;
  padding: 8px 14px;
  border-color: var(--bb-gold);
  touch-action: manipulation;
}

.fca-bb-ability small {
  color: var(--bb-muted);
}

.fca-bb-bracket {
  display: flex;
  gap: 10px;
  min-height: 120px;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--bb-border);
  border-radius: 7px;
  background: var(--bb-panel);
}

.fca-bb-bracket[hidden] {
  display: none;
}

.fca-bb-bracket__round {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 180px;
}

.fca-bb-bracket__round h3 {
  margin: 0;
  color: var(--bb-muted);
  font-size: .75rem;
}

.fca-bb-bracket__match {
  padding: 6px 7px;
  border-left: 3px solid var(--bb-border);
  border-radius: 4px;
  background: var(--bb-panel-2);
  font-size: .72rem;
}

.fca-bb-bracket__match.is-active {
  border-left-color: var(--bb-gold);
}

.fca-bb-results {
  min-height: 130px;
}

.fca-bb-stat-list {
  display: grid;
  gap: 6px;
}

.fca-bb-stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--bb-border);
  color: var(--bb-muted);
  font-size: .76rem;
}

.fca-bb-stat-row strong {
  overflow: hidden;
  color: var(--bb-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fca-bb-result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.fca-bb-result-actions .fca-bb-button {
  width: 100%;
}

.fca-bb-commentary ol {
  display: grid;
  gap: 6px;
  max-height: 510px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.fca-bb-commentary li {
  padding: 6px 7px;
  border-left: 2px solid var(--bb-blue);
  color: var(--bb-muted);
  background: var(--bb-panel-2);
  font-size: .74rem;
}

.fca-bb-commentary li.is-ko {
  border-left-color: var(--bb-red);
  color: var(--bb-text);
}

.fca-bb-reference-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 9px;
}

.fca-bb-reference-tabs button {
  min-height: 34px;
  border: 1px solid var(--bb-border);
  border-radius: 4px;
  color: var(--bb-muted);
  background: var(--bb-panel-2);
  cursor: pointer;
}

.fca-bb-reference-tabs button.is-active {
  border-color: var(--bb-blue);
  color: var(--bb-text);
}

.js-bb-reference {
  display: grid;
  gap: 7px;
  max-height: 430px;
  overflow-y: auto;
}

.fca-bb-reference-card {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-left: 3px solid var(--bb-blue);
  border-radius: 4px;
  background: var(--bb-panel-2);
}

.fca-bb-reference-card strong,
.fca-bb-reference-card small,
.fca-bb-reference-card p {
  margin: 0;
}

.fca-bb-reference-card strong {
  display: flex;
  gap: 6px;
  align-items: center;
}

.fca-bb-reference-card strong i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.fca-bb-reference-card strong span {
  margin-left: auto;
  color: var(--bb-gold);
  font-size: .7rem;
}

.fca-bb-reference-card small,
.fca-bb-reference-card p,
.fca-bb-reference-card code {
  color: var(--bb-muted);
  font-size: .7rem;
}

.fca-bb-toast {
  position: fixed;
  z-index: 1000;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 1px solid var(--bb-border);
  border-radius: 5px;
  color: var(--bb-text);
  background: var(--bb-panel-2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.fca-bb-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .fca-ball-battles.is-view-arena .fca-bb-workspace {
    grid-template-columns: 1fr;
  }

  .fca-ball-battles.is-view-arena .fca-bb-feed {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .fca-ball-battles {
    padding: 8px;
    overflow-x: hidden;
  }

  .fca-bb-topbar {
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .fca-bb-topbar > * {
    min-width: 0;
  }

  .fca-bb-topbar__actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .fca-bb-workspace {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .fca-bb-view-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fca-ball-battles.is-view-setup .fca-bb-setup {
    grid-template-columns: 1fr;
  }

  .fca-ball-battles.is-view-arena .fca-bb-workspace {
    grid-template-columns: 1fr;
  }

  .fca-bb-arena-column {
    grid-row: 1;
    width: 100%;
  }

  .fca-bb-setup {
    grid-row: 2;
  }

  .fca-bb-feed {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .fca-bb-fighter-picker,
  .fca-bb-saved-lineups,
  .fca-bb-commentary ol {
    max-height: 260px;
  }

  .fca-bb-segmented button {
    overflow: hidden;
    font-size: .7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fca-bb-toast,
  .fca-bb-fanfare,
  .fca-bb-cinematic__card,
  .fca-bb-ability-scene {
    transition: none;
    animation: none;
  }
}
