/* Unit pieces: bitmap digits, element marks, stars, role tags, unit tile, item tile, cost plate, gauges, pedestal. */

/* ---------------------------------------------------------------- bitmap digits (num64_font: cells 50x62, advance 48) */
.bfc-num { display: inline-flex; align-items: center; height: 1em; line-height: 1; white-space: nowrap; vertical-align: -.12em; }
.bfc-num > i { display: inline-block; width: .806em; height: 1em; margin-right: -.04em; background: url(../assets/ui/num64.png) 0 0 / 9.677em 1em no-repeat; }
.bfc-num > i.is-one { margin-right: -.1em; }
.bfc-num > i.is-gap { width: .18em; background: none; }
.bfc-num--gold > i { background-image: url(../assets/ui/num64-gold.png); }
.bfc-num--s { font-size: var(--bfc-num-s); } .bfc-num--m { font-size: var(--bfc-num-m); } .bfc-num--l { font-size: var(--bfc-num-l); } .bfc-num--xl { font-size: var(--bfc-num-xl); }

/* ---------------------------------------------------------------- element mark (attribute_mark_M, 6 cells) */
.bfc-el { display: inline-block; flex: none; width: 22px; height: 22px; vertical-align: middle; background: url(../assets/ui/elements.png) 0 0 / 600% 100% no-repeat; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .7)); }
.bfc-el--l { width: 34px; height: 34px; background-image: url(../assets/ui/elements-l.png); }
.bfc-el[data-el="fire"] { background-position-x: 0; }
.bfc-el[data-el="water"] { background-position-x: 20%; }
.bfc-el[data-el="earth"] { background-position-x: 40%; }
.bfc-el[data-el="thunder"] { background-position-x: 60%; }
.bfc-el[data-el="light"] { background-position-x: 80%; }
.bfc-el[data-el="dark"] { background-position-x: 100%; }

/* ---------------------------------------------------------------- rarity stars */
.bfc-stars { display: inline-flex; align-items: center; vertical-align: middle; }
.bfc-stars > i { width: 16px; height: 16px; margin-right: -3px; background: url(../assets/ui/star.png) center / contain no-repeat; }
.bfc-stars--omni > i { background-image: url(../assets/ui/star-omni.png); width: 20px; height: 20px; }
.bfc-stars__omni { margin-left: 7px; font: 800 12px/1 var(--bfc-font-game); letter-spacing: .1em; color: #ecd4ff; text-shadow: 0 0 6px rgba(190, 120, 255, .9), var(--bfc-outline-thin); }

/* ---------------------------------------------------------------- role tag: word + sphere icon + tier pips
   (plates rebuilt from category_name_plate colour bands; the word is always written, never icon-only) */
.bfc-role {
  --c1: var(--bfc-role-buff-1); --c2: var(--bfc-role-buff-2); --cr: var(--bfc-role-buff-r);
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 4px; max-width: 100%;
  font: 800 12px/1 var(--bfc-font-game); color: #fff; text-shadow: var(--bfc-outline-thin); white-space: nowrap;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28) 0 2px, var(--c1) 2px 52%, var(--c2) 100%);
  border: 1px solid var(--cr); border-left-width: 3px; border-radius: 3px 7px 7px 3px;
  box-shadow: 0 1px 0 #000, inset 0 -1px 0 rgba(0, 0, 0, .5);
}
.bfc-role__ico { flex: none; width: 16px; height: 16px; background: url(../assets/ui/sphere-icons.png) 0 0 / 1000% 200% no-repeat; --x: 1; --y: 0; background-position: calc(var(--x) * 11.111%) calc(var(--y) * 100%); }
.bfc-role__word { overflow: hidden; text-overflow: ellipsis; }
.bfc-role__tier { display: inline-flex; gap: 2px; margin-left: 2px; }
.bfc-role__tier i { width: 5px; height: 5px; transform: rotate(45deg); background: rgba(0, 0, 0, .55); box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.bfc-role__tier i.is-on { background: #fff6d0; box-shadow: 0 0 0 1px #000, 0 0 4px rgba(255, 240, 180, .8); }
.bfc-role--s { height: 20px; font-size: 10.5px; padding: 0 6px 0 3px; gap: 3px; }
.bfc-role--s .bfc-role__ico { width: 13px; height: 13px; }
.bfc-role--s .bfc-role__tier i { width: 4px; height: 4px; }
.bfc-role--l { height: 30px; font-size: 14px; padding: 0 10px 0 5px; }
.bfc-role--l .bfc-role__ico { width: 20px; height: 20px; }
.bfc-role[data-family="offence"] { --c1: var(--bfc-role-offence-1); --c2: var(--bfc-role-offence-2); --cr: var(--bfc-role-offence-r); }
.bfc-role[data-family="offence"] .bfc-role__ico { --x: 9; --y: 0; }
.bfc-role[data-family="buff"] .bfc-role__ico { --x: 1; --y: 0; }
.bfc-role[data-family="gauge"] { --c1: var(--bfc-role-gauge-1); --c2: var(--bfc-role-gauge-2); --cr: var(--bfc-role-gauge-r); }
.bfc-role[data-family="gauge"] .bfc-role__ico { --x: 6; --y: 0; }
.bfc-role[data-family="sustain"] { --c1: var(--bfc-role-sustain-1); --c2: var(--bfc-role-sustain-2); --cr: var(--bfc-role-sustain-r); }
.bfc-role[data-family="sustain"] .bfc-role__ico { --x: 7; --y: 0; }
.bfc-role[data-family="defence"] { --c1: var(--bfc-role-defence-1); --c2: var(--bfc-role-defence-2); --cr: var(--bfc-role-defence-r); }
.bfc-role[data-family="defence"] .bfc-role__ico { --x: 0; --y: 1; }
.bfc-role[data-family="cure"] { --c1: var(--bfc-role-cure-1); --c2: var(--bfc-role-cure-2); --cr: var(--bfc-role-cure-r); }
.bfc-role[data-family="cure"] .bfc-role__ico { --x: 5; --y: 0; }
.bfc-role[data-family="debuff"] { --c1: var(--bfc-role-debuff-1); --c2: var(--bfc-role-debuff-2); --cr: var(--bfc-role-debuff-r); }
.bfc-role[data-family="debuff"] .bfc-role__ico { --x: 4; --y: 1; }
.bfc-role[data-family="drops"] { --c1: var(--bfc-role-drops-1); --c2: var(--bfc-role-drops-2); --cr: var(--bfc-role-drops-r); }
.bfc-role[data-family="drops"] .bfc-role__ico { --x: 3; --y: 0; }
.bfc-role[data-family="crit"] { --c1: var(--bfc-role-crit-1); --c2: var(--bfc-role-crit-2); --cr: var(--bfc-role-crit-r); }
.bfc-role[data-family="crit"] .bfc-role__ico { --x: 2; --y: 0; }
.bfc-role[data-family="spark"] { --c1: var(--bfc-role-spark-1); --c2: var(--bfc-role-spark-2); --cr: var(--bfc-role-spark-r); }
.bfc-role[data-family="spark"] .bfc-role__ico { --x: 1; --y: 1; }
.bfc-role[data-family="leader"] { --c1: var(--bfc-role-leader-1); --c2: var(--bfc-role-leader-2); --cr: var(--bfc-role-leader-r); }
.bfc-role[data-family="leader"] .bfc-role__ico { --x: 2; --y: 1; }
.bfc-role.is-missing { --c1: #3a1010; --c2: #140404; --cr: #ff6a5a; border-style: dashed; color: #ffd2cb; }
.bfc-role.is-missing .bfc-role__ico { filter: grayscale(1) brightness(.8); }
@media (prefers-reduced-motion: no-preference) { .bfc-role.is-missing { animation: bfc-missing 1.4s ease-in-out infinite alternate; } }
@keyframes bfc-missing { to { box-shadow: 0 0 12px rgba(255, 90, 70, .7); } }
/* UBB-only job: a small parchment "UBB" stub after the word (the job comes about once a battle, not every burst) */
.bfc-role__src { flex: none; margin-left: 2px; padding: 1px 3px 0; border-radius: 3px; font-size: .78em; line-height: 1.25; letter-spacing: .02em; color: var(--bfc-ink-dark); text-shadow: none; background: linear-gradient(#fff3c4, #e2b450); box-shadow: 0 0 0 1px #000; }
.bfc-role--s.is-ubb .bfc-role__tier { display: none; }
.bfc-roles { display: flex; flex-wrap: wrap; gap: 4px; }
.bfc-roles--center { justify-content: center; }

/* ---------------------------------------------------------------- unit tile (box thumbnail, frame baked into the art) */
.bfc-utile {
  position: relative; display: block; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; text-decoration: none; color: inherit;
  border-radius: 12px; transition: transform var(--bfc-dur-fast) var(--bfc-ease-out), filter .15s;
}
.bfc-utile__art { position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 12%; background: radial-gradient(circle at 50% 40%, #1d3a86, #0b1634 70%); }
.bfc-utile__art img { width: 100%; height: 100%; border-radius: inherit; filter: drop-shadow(0 2px 0 #000); }
.bfc-utile__art img.is-missing { opacity: 0; }
.bfc-utile__lv { display: block; height: 17px; margin-top: -2px; font-size: 14px; }
.bfc-utile__lv img { height: 15px; width: auto; aspect-ratio: 87 / 27; margin: 1px auto 0; }
.bfc-utile__lv { display: flex; align-items: center; justify-content: center; gap: 2px; }
.bfc-utile__lvl { font: 800 10px/1 var(--bfc-font-game); color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-utile__name { display: block; max-width: 100%; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; line-height: 1.2; color: var(--bfc-ink-soft); text-align: center; }
.bfc-utile__tag { position: absolute; z-index: 2; left: 50%; top: -7px; transform: translateX(-50%); width: 50px; height: 15px; background: center / contain no-repeat; filter: drop-shadow(0 1px 1px #000); }
.bfc-utile__tag--party { background-image: url(../assets/ui/party-tag.png); }
.bfc-utile__tag--fav { background-image: url(../assets/ui/fav-tag.png); }
.bfc-utile__new { position: absolute; z-index: 2; right: -4px; top: -6px; width: 38px; height: 17px; background: url(../assets/ui/new.png) center / contain no-repeat; }
.bfc-utile:hover { filter: brightness(1.12); }
.bfc-utile:active { filter: brightness(.88); }
.bfc-utile.is-selected .bfc-utile__art::after, .bfc-utile[aria-current="true"] .bfc-utile__art::after {
  content: ""; position: absolute; inset: -14%; background: url(../assets/ui/slot-glow.png) center / 100% 100%; pointer-events: none; animation: bfc-glow 1.4s ease-in-out infinite alternate;
}
@keyframes bfc-glow { from { opacity: .55; } to { opacity: 1; } }

/* ---------------------------------------------------------------- item tile (item_frame_bg + gold frame) */
.bfc-itile { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; justify-items: center; gap: 2px; text-align: center; text-decoration: none; color: inherit; border: 0; padding: 0; background: none; cursor: pointer; }
.bfc-itile__art { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; background: url(../assets/ui/slot-bg.png) center / 100% 100%; border-radius: 12px; }
.bfc-itile__art img { width: 80%; height: 80%; object-fit: contain; }
.bfc-itile__art::after { content: ""; position: absolute; inset: 0; background: url(../assets/ui/item-frame.png) center / 100% 100%; pointer-events: none; }
.bfc-itile__n { position: absolute; right: 3px; bottom: 2px; z-index: 1; font-size: 15px; }
.bfc-itile__name { font-size: 11.5px; line-height: 1.2; color: var(--bfc-ink-soft); text-shadow: 0 1px 0 #000; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bfc-itile:hover .bfc-itile__art { filter: brightness(1.15); }

/* ---------------------------------------------------------------- cost plate (party_edit plate_total_cost)
   A 9-slice of the game's plate: the "COST" end keeps its art, the blue field stretches to hold the digits, so the
   numbers sit inside the plate at any value ("1234/1234"). --h sets the plate height; everything scales from it. */
.bfc-cost {
  --h: 32px; position: relative; display: inline-flex; align-items: center; gap: .1em; box-sizing: border-box; max-width: 100%;
  height: var(--h); padding: 0 calc(var(--h) * .12) 0 calc(var(--h) * .06); border-radius: calc(var(--h) * .14);
  border-style: solid; border-color: transparent; border-width: 0 calc(var(--h) * 10 / 47) 0 calc(var(--h) * 78 / 47);
  border-image: url(../assets/ui/plate-cost.png) 0 10 0 78 fill / 0 calc(var(--h) * 10 / 47) 0 calc(var(--h) * 78 / 47) stretch;
  font-size: calc(var(--h) * .56); white-space: nowrap;
}
.bfc-cost__inner { display: inline-flex; align-items: center; gap: .08em; }
.bfc-cost .bfc-num { font-size: 1em; vertical-align: 0; }
.bfc-cost__of { font: 800 .8em/1 var(--bfc-font-game); color: var(--bfc-ink-dim); text-shadow: 0 1px 0 #000; }
.bfc-cost.is-over { box-shadow: 0 0 0 2px #e0503c; }

/* ---------------------------------------------------------------- gauge bars (header_ui fills) */
.bfc-gauge { display: grid; gap: 4px; }
.bfc-gauge__label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; font: 800 var(--bfc-fs-label)/1 var(--bfc-font-game); color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-gauge__label .bfc-num { flex: none; font-size: 14px; }
.bfc-gauge__bar { position: relative; height: 12px; border-radius: 8px; overflow: hidden; background: #0a0f1a; box-shadow: inset 0 1px 2px #000, 0 0 0 1px #000, 0 0 0 2px rgba(214, 164, 62, .45); }
.bfc-gauge__bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(var(--bfc-exp-a), var(--bfc-exp-b) 30%, var(--bfc-exp-a) 62%, #d54a0c); transition: width var(--bfc-dur-slow) var(--bfc-ease-out); }
.bfc-gauge--energy .bfc-gauge__bar > i { background: linear-gradient(var(--bfc-nrg-a), var(--bfc-nrg-b) 30%, var(--bfc-nrg-a) 62%, #1bd407); }
.bfc-gauge--blue .bfc-gauge__bar > i { background: linear-gradient(var(--bfc-hp-a), var(--bfc-hp-b) 30%, var(--bfc-hp-a) 62%, #0a7fd4); }
.bfc-gauge--gold .bfc-gauge__bar > i { background: linear-gradient(#ffd85a, #fff7cf 30%, #f0b51f 62%, #a46a0a); }

/* ---------------------------------------------------------------- unit on a pedestal (idle sprite or battle art) */
.bfc-figure { position: relative; display: grid; justify-items: center; align-content: end; width: 112px; height: 118px; }
.bfc-figure__base { position: absolute; left: 50%; bottom: 0; width: 100px; height: 54px; transform: translateX(-50%); background: url(../assets/ui/pedestal.png) center / contain no-repeat; }
.bfc-figure__who { position: absolute; left: 50%; bottom: 30px; width: 0; height: 0; }
.bfc-sprite { position: absolute; left: 0; top: 0; background-repeat: no-repeat; image-rendering: auto; pointer-events: none; }
.bfc-sprite--still { position: absolute; left: 0; bottom: 0; width: 96px; height: 96px; transform: translateX(-50%); object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .5)); }
