/* ability-card.css — self-contained. Only knob you must set is --ac-accent.
   Font: <link href="https://fonts.googleapis.com/css2?family=Alegreya+Sans:ital,wght@0,400;0,500;0,700;0,800;1,400;1,500&display=swap" rel="stylesheet"> */

.ac-card {
  --ac-accent: #5b8fae;
  --ac-bar: color-mix(in srgb, var(--ac-accent) 58%, #0d1218);
  --ac-body: color-mix(in srgb, var(--ac-accent) 18%, #2b3239);
  --ac-unit: color-mix(in srgb, var(--ac-accent) 58%, #ffffff);
  --ac-up: #5ddc7a;

  width: 560px;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  color: #e7edf2;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
}

/* Header ------------------------------------------------------------------ */
.ac-top {
  position: relative;
  background: var(--ac-accent);
}
.ac-head {
  position: relative;
  padding: 26px 24px 24px;
}
.ac-art {
  position: absolute;
  inset: 0 0 0 46%;
  background-size: cover;
  background-position: center;
  opacity: .55;
  mix-blend-mode: screen;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 42%);
  mask-image: linear-gradient(to right, transparent 0%, #000 42%);
}
.ac-head-text { position: relative; }

/* Tier corner — mirrors the .ai-tier corner on the item icon */
.ac-corner {
  position: absolute;
  top: 0;
  right: 0;
  width: 62px;
  height: 62px;
  background: color-mix(in srgb, var(--ac-accent) 52%, #0d1218);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  pointer-events: none;
}
.ac-corner > span {
  position: absolute;
  top: 5px;
  right: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
  color: #fff;
}
.ac-head:has(.ac-corner) .ac-head-text { padding-right: 54px; }.ac-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: .2px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
}
.ac-level {
  margin: 5px 0 0;
  font-size: 19px;
  font-weight: 500;
  color: rgba(255, 255, 255, .78);
}

/* Type bar — sits over the header background ------------------------------- */
.ac-bar {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  min-height: 48px;
  background: color-mix(in srgb, var(--ac-bar) 78%, transparent);
}
.ac-type {
  display: flex;
  align-items: center;
  padding-left: 24px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
  color: #fff;
}
.ac-cd {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 6px;
  padding: 0 14px;
  border-radius: 5px;
  background: #0e141b;
  font-size: 20px;
  font-weight: 700;
  color: #eef4f8;
}
.ac-cd svg { flex: none; }
.ac-caret { font-size: 13px; color: rgba(255, 255, 255, .45); transform: translateY(1px); }

/* Body -------------------------------------------------------------------- */
.ac-body { padding: 22px 24px 24px; background: var(--ac-body); }
.ac-desc {
  margin: 0;
  font-size: 19px;
  line-height: 1.45;
  color: #d7e0e8;
  text-wrap: pretty;
}
.ac-desc strong { color: #fff; font-weight: 700; }
.ac-note {
  margin: 14px 0 0;
  font-size: 17px;
  line-height: 1.4;
  font-style: italic;
  color: #95a3af;
  text-wrap: pretty;
}

/* Stat panel — both sections are optional --------------------------------- */
.ac-panel {
  margin-top: 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .24);
  overflow: hidden;
}
.ac-body > .ac-panel:first-child { margin-top: 0; }

.ac-stats { display: flex; }
.ac-stat {
  flex: 1;
  min-width: 0;
  padding: 18px 12px;
  text-align: center;
}
.ac-stat + .ac-stat { box-shadow: inset 1px 0 rgba(255, 255, 255, .13); }
.ac-stat-val {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}
.ac-stat-val svg { flex: none; }
.ac-stat-label {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 500;
  color: #adbac5;
}

.ac-details {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 12px 24px;
  padding: 14px 20px 16px;
}
.ac-stats + .ac-details { border-top: 1px solid rgba(255, 255, 255, .1); }
.ac-detail {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
.ac-detail-val { font-size: 21px; font-weight: 700; color: #fff; }
.ac-detail-label { font-size: 18px; font-weight: 500; color: #adbac5; }

.ac-unit { font-size: 16px; font-weight: 700; color: var(--ac-unit); }
.ac-stat-val .ac-unit { font-size: 20px; }
.ac-up { font-size: 11px; line-height: 1; color: var(--ac-up); }
.ac-stat-val .ac-up { font-size: 12px; align-self: flex-start; margin-top: 2px; }

/* Narrow screens ---------------------------------------------------------- */
@media (max-width: 600px) {
  .ac-card { width: 100%; }
  .ac-details { grid-template-columns: 1fr; }
  .ac-stats { flex-wrap: wrap; }
  .ac-stat { flex-basis: 50%; }
}

/* Shell — card + buy panel side by side ------------------------------------ */
.ac-shell {
  display: flex;
  align-items: stretch;
  gap: 8px;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
}

.ac-side {
  width: 208px;
  flex: none;
  padding: 16px 18px 18px;
  border-radius: 10px;
  background: #43474d;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .07);
  color: #e7edf2;
}
.ac-side-title {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
  color: #fff;
  text-wrap: balance;
}
.ac-cost {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}
.ac-cost svg { flex: none; }
.ac-cost-label {
  margin-left: auto;
  font-size: 16px;
  font-weight: 500;
  color: #b0bac3;
}
.ac-deltas {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.ac-delta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 18px;
  line-height: 1.2;
}
.ac-delta-val {
  flex: none;
  min-width: 46px;
  font-weight: 700;
  color: #5ddc7a;
}
.ac-delta.ac-delta--down .ac-delta-val { color: #e2705f; }
.ac-delta-label { font-weight: 500; color: #c3ccd4; text-wrap: pretty; }
.ac-side-note {
  margin: 14px 0 0;
  font-size: 16px;
  font-style: italic;
  line-height: 1.35;
  color: #97a2ac;
}

/* Tier / upgrade rows ------------------------------------------------------ */
.ac-tiers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}
.ac-tier {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}
.ac-tier--owned {
  background: color-mix(in srgb, var(--ac-accent) 30%, rgba(0, 0, 0, .2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ac-accent) 55%, transparent);
}
.ac-tier--next { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .26); }
.ac-tier--locked { opacity: .5; }

.ac-tier-cost {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 34px;
  margin-top: 2px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .42);
  font-size: 16px;
  font-weight: 700;
  color: #e9eff4;
}
.ac-tier--owned .ac-tier-cost { background: rgba(0, 0, 0, .34); }
.ac-pip {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ac-accent) 45%, #ffffff);
  transform: rotate(45deg);
}
.ac-tier-bonus {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1 1 0;
  font-size: 18px;
  line-height: 1.3;
  color: #d7e0e8;
  text-wrap: pretty;
}
.ac-tier-line {
  flex: 1 1 150px;
  min-width: 0;
  padding: 5px 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .26);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.ac-tier--owned .ac-tier-line { background: rgba(0, 0, 0, .22); }
.ac-tier-bonus strong { color: #fff; font-weight: 700; }
.ac-tier-state {
  margin-left: auto;
  flex: none;
  align-self: flex-start;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
}

/* Stat progression table --------------------------------------------------- */
.ac-prog {
  --ac-prog-n: 4;
  margin-top: 16px;
  padding: 12px 18px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .24);
}
.ac-prog-row {
  display: grid;
  grid-template-columns: 96px repeat(var(--ac-prog-n), 1fr);
  align-items: center;
  gap: 0 6px;
  padding: 5px 0;
}
.ac-prog-row + .ac-prog-row { border-top: 1px solid rgba(255, 255, 255, .07); }
.ac-prog-row--head { padding-bottom: 8px; }
.ac-prog-col {
  padding: 0 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  text-align: center;
  color: #8996a2;
}
.ac-prog-col.is-current { color: color-mix(in srgb, var(--ac-accent) 45%, #ffffff); }
.ac-prog-label { font-size: 17px; font-weight: 500; color: #adbac5; }
.ac-prog-step {
  min-width: 0;
  padding: 2px 4px;
  border-radius: 4px;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: rgba(255, 255, 255, .38);
}
.ac-prog-step.is-current {
  background: color-mix(in srgb, var(--ac-accent) 55%, transparent);
  color: #fff;
}
.ac-prog-step.is-future { color: color-mix(in srgb, var(--ac-accent) 50%, #ffffff); }

/* Hover popup -------------------------------------------------------------- */
.ac-pop {
  position: fixed;
  z-index: 90;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .09s ease, transform .09s ease;
  pointer-events: none;
}
.ac-pop.is-open { opacity: 1; transform: none; }

/* =========================================================================
   ITEM ICONS — .ai-*  (companion to .ac-card)
   Everything scales from --ai-w, so one class handles 44px scoreboard chips
   and 110px build-browser tiles alike. Category colour is --ai-accent.
   ========================================================================= */

.ai-item {
  --ai-w: 110px;
  --ai-accent: #a45fd6;
  --ai-plate: color-mix(in srgb, var(--ai-accent) 42%, #ffffff);
  --ai-plate-text: #221d2a;
  --ai-art-bg: #efe9dd;

  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--ai-w);
  flex: none;
  border-radius: calc(var(--ai-w) * .036);
  overflow: hidden;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .28), inset 0 0 0 1px rgba(255, 255, 255, .07);
  -webkit-user-select: none;
  user-select: none;
}

/* Dark / "activated" treatment — dark art well, tinted label text */
.ai-item.ai--dark {
  --ai-plate: #23262c;
  --ai-plate-text: color-mix(in srgb, var(--ai-accent) 62%, #ffffff);
  --ai-art-bg: #12151a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13);
}

/* Category presets ------------------------------------------------------- */
.ai-item.ai--gun      { --ai-accent: #d4842c; --ai-art-bg: #efe6d3; }
.ai-item.ai--spirit   { --ai-accent: #a45fd6; }
.ai-item.ai--vitality { --ai-accent: #5fbb52; }

/* Art well --------------------------------------------------------------- */
.ai-art {
  position: relative;
  aspect-ratio: 1;
  background: var(--ai-art-bg) center / cover no-repeat;
}
.ai-art > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Tier corner ------------------------------------------------------------ */
.ai-tier {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(var(--ai-w) * .31);
  aspect-ratio: 1;
  background: var(--ai-accent);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  pointer-events: none;
}
.ai-tier > span {
  position: absolute;
  top: max(1px, calc(var(--ai-w) * .012));
  right: max(2px, calc(var(--ai-w) * .042));
  font-size: max(8px, calc(var(--ai-w) * .105));
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.25;
  color: #fff;
}

/* Badge strips (bottom of the art well, stacked) ------------------------- */
.ai-badges {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
}
.ai-badge {
  padding: calc(var(--ai-w) * .022) 0;
  background: rgba(11, 12, 15, .88);
  font-size: max(7px, calc(var(--ai-w) * .085));
  font-weight: 700;
  letter-spacing: .16em;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  color: #fff;
}
.ai-badge.ai-badge--imbue { background: #342449; }

/* Below ~64px there is no room for badge text — collapse to colour bars. */
.ai-item.ai--chip .ai-badge {
  height: 3px;
  padding: 0;
  font-size: 0;
  letter-spacing: 0;
  background: rgba(232, 238, 243, .82);
}
.ai-item.ai--chip .ai-badge.ai-badge--imbue { background: #9a6fd0; }
.ai-item.ai--chip .ai-badges { gap: 1px; padding-bottom: 1px; }

/* Label plate ------------------------------------------------------------ */
.ai-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--ai-w) * .33);
  padding: calc(var(--ai-w) * .055) calc(var(--ai-w) * .05);
  background: var(--ai-plate);
  font-size: calc(var(--ai-w) * .118);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  color: var(--ai-plate-text);
}

/* Layout helpers --------------------------------------------------------- */
.ai-grid { display: flex; flex-wrap: wrap; gap: calc(var(--ai-gap, 6px)); align-items: flex-start; }
.ai-row  { display: flex; flex-wrap: nowrap; gap: 2px; align-items: flex-start; }


/* =========================================================================
   ITEM PROGRESSION BOARD — .ib-*
   Tier columns left-to-right, item icons stacked inside, arrows drawn as an
   SVG overlay between nodes (mountItemBoardArrows). Scroll/touch friendly:
   the board is the scroll container in both axes.
   ========================================================================= */

.ib-board {
  --ib-col: 132px;
  --ib-gap-x: 84px;
  --ib-gap-y: 20px;
  --ib-line: rgba(226, 236, 244, .30);
  --ib-accent: #a45fd6;

  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: rgba(226, 236, 244, .26) rgba(255, 255, 255, .05);
  scrollbar-width: thin;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  border-radius: 14px;
  background:
    radial-gradient(1200px 420px at 12% -10%, rgba(164, 95, 214, .13), transparent 70%),
    linear-gradient(#12161c, #0d1014);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  color: #e7edf2;
}
.ib-board.is-grabbing { cursor: grabbing; }
.ib-board::-webkit-scrollbar { width: 12px; height: 12px; }
.ib-board::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }
.ib-board::-webkit-scrollbar-thumb {
  background: rgba(226, 236, 244, .20);
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}
.ib-board::-webkit-scrollbar-thumb:hover { background: rgba(226, 236, 244, .34); background-clip: padding-box; }

.ib-inner {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--ib-cols, 4), var(--ib-col));
  column-gap: var(--ib-gap-x);
  row-gap: var(--ib-gap-y);
  align-content: start;
  justify-content: start;
  width: max-content;
  min-width: 100%;
  padding: 18px 26px 30px;
}

/* Tier column header ------------------------------------------------------ */
.ib-col-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
  padding: 9px 10px 10px;
  border-radius: 8px;
  background: rgba(15, 19, 24, .94);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09);
  text-align: center;
}
.ib-col-label {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fff;
}
.ib-col-sub {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  color: rgba(231, 237, 242, .58);
}
.ib-col-head[data-tier-state="locked"] { opacity: .62; }

/* Node -------------------------------------------------------------------- */
.ib-node {
  position: relative;
  border-radius: 8px;
  transition: transform .13s ease, box-shadow .13s ease;
}
.ib-node > .ai-item { --ai-w: var(--ib-col); width: 100%; }
.ib-board--paned { overflow-y: auto; }
.ib-node:hover { transform: translateY(-2px); z-index: 2; }
.ib-node--owned {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ib-accent) 70%, #ffffff),
              0 8px 22px rgba(0, 0, 0, .5);
}
.ib-node--next { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55); }
.ib-node--locked { opacity: .48; filter: saturate(.55); }

/* Divider between the build-path zone and the unconnected items below */
.ib-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(231, 237, 242, .42);
}
.ib-rule > span { flex: none; white-space: nowrap; }
.ib-rule > em {
  order: 3;
  flex: none;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .06em;
  color: rgba(231, 237, 242, .34);
}
.ib-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, .12);
}

/* Unconnected pool — nested mini-grid inside one tier column ------------- */
.ib-loose {
  position: relative;
  min-width: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--ib-loose-cols, 2), 1fr);
  gap: 6px;
  align-content: start;
  grid-auto-rows: min-content;
}
/* Names survive in the pool at chip size with tighter type. */
.ib-loose .ai-item.ai--chip .ai-label {
  align-items: flex-start;
  min-height: 30px;
  overflow: hidden;
  padding: 4px 3px 5px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
}
.ib-loose .ib-node:hover { transform: none; box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.ib-loose .ai-item { --ai-w: calc((var(--ib-col) - 6px * (var(--ib-loose-cols, 2) - 1)) / var(--ib-loose-cols, 2)); width: 100%; }

/* Arrow overlay ----------------------------------------------------------- */
.ib-links {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
.ib-links path {
  fill: none;
  stroke: var(--ib-line);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.ib-links path.is-owned { stroke: color-mix(in srgb, var(--ib-accent) 72%, #ffffff); stroke-width: 3; }
.ib-links path.is-locked { stroke: rgba(226, 236, 244, .16); stroke-dasharray: 5 6; }
.ib-links polygon { fill: var(--ib-line); }
.ib-links polygon.is-owned { fill: color-mix(in srgb, var(--ib-accent) 72%, #ffffff); }
.ib-links polygon.is-locked { fill: rgba(226, 236, 244, .16); }

/* Board chrome ------------------------------------------------------------ */
.ib-wrap { display: flex; flex-direction: column; gap: 12px; }
.ib-legend {
  --ib-line: rgba(226, 236, 244, .30);
  --ib-accent: #a45fd6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 14px;
  color: rgba(231, 237, 242, .62);
}
.ib-legend b { color: #fff; font-weight: 700; }
.ib-key { display: flex; align-items: center; gap: 7px; }
.ib-key i {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  background: var(--ib-line);
}
.ib-key.is-owned i { background: rgba(255, 255, 255, .92); }
.ib-key.is-locked i { background: rgba(226, 236, 244, .22); }

@media (max-width: 640px) {
  .ib-board { --ib-col: 108px; --ib-gap-x: 62px; --ib-gap-y: 16px; }
  .ib-inner { padding: 14px 16px 24px; }
}
