/* ============================================================
   Crucible XP Calculator (wiki tool). Takes its look from the main
   calculator rather than inventing one: blue-framed class cards,
   flat list rows with thin dividers and gold switches, tier bands
   with a gold rule, small square number buttons, and the Health
   view's in-game bar frame for the XP bar. No boxed cards.
   All text #fff and >= 1rem.
   ============================================================ */

.wiki-main { max-width: 1340px; }

.cxp-intro { font-size: 1.05rem; color: #fff; line-height: 1.55; margin: 0 0 20px; }
.cxp-tool { margin-bottom: 40px; }

/* info icon + tooltip (same as the Tech-Priest tool) */
.cxp-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--gold); color: var(--gold);
  font-size: 0.72rem; font-weight: 700; font-style: italic;
  font-family: Georgia, "Times New Roman", serif; line-height: 1;
  cursor: help; margin-left: 6px; vertical-align: middle; user-select: none;
}
.cxp-info:focus { background: var(--gold-glow); outline: none; }
/* phone-only pieces, hidden on desktop: the title's info icon and the short control labels */
.cxp-title-info, .cxp-lbl-short { display: none; }
.rw-tip {
  white-space: pre-line;
  background: #34344c !important;
  border: 2px solid var(--gold) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7) !important;
  font-size: 0.95rem !important;
  max-width: 340px;
}

/* ---------- class cards (the calculator's .class-card) ---------- */
.cxp-classes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.cxp-class-btn {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 0; overflow: hidden; cursor: pointer;
  font: inherit; color: #fff;
  background: var(--surface);
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.cxp-class-btn img {
  display: block; width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover;
  pointer-events: none; -webkit-user-drag: none; user-select: none;
}
.cxp-class-btn span {
  padding: 8px 4px; text-align: center;
  font-size: 1rem; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
}
/* the class's saved Crucible tier (the game's rank badge) beside its name */
.cxp-class-name { display: flex; align-items: center; justify-content: center; gap: 6px; }
/* native 28px; the game's badge art is a muted grey made for its dark screen, so it is lifted here
   to read on the card label (and on the picked card's gold label, with a soft dark edge) */
.cxp-class-btn .cxp-class-rank { width: 28px; height: 28px; aspect-ratio: auto; object-fit: contain; flex-shrink: 0; filter: brightness(2.1) drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9)); }
.cxp-class-btn.active { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.cxp-class-btn.active span { background: var(--gold-dim); font-weight: 700; }
/* fold caret: open = pointing down, folded = pointing right. Folded hides the intro paragraph and
   the card pictures (leaving name + tier badge); the choice is saved. The caret keeps one spot, the
   start of the first row under the title (owner): beside the intro when open, with the cards full
   width below; beside the class names when folded. 9px down = centred on the 48px folded names. */
.cxp-head { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 12px; margin-bottom: 18px; }
.cxp-head .cxp-fold { grid-column: 1; grid-row: 1; align-self: start; margin-top: 9px; }
.cxp-head .cxp-intro { grid-column: 2; grid-row: 1; }
.cxp-head .cxp-classes { grid-column: 1 / -1; grid-row: 2; margin-bottom: 0; }
.cxp-folded .cxp-head .cxp-classes { grid-column: 2; grid-row: 1; }
.cxp-fold {
  flex-shrink: 0; width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.cxp-fold-caret {
  width: 9px; height: 9px; border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: translateY(-2px) rotate(45deg);
}
.cxp-folded .cxp-fold-caret { transform: translateX(-2px) rotate(-45deg); }
/* the title-line fold button is for phones only */
.cxp-fold-title { display: none; }
.cxp-folded .cxp-intro { display: none; }
.cxp-folded .cxp-class-btn > img { display: none; }

/* ---------- settings line ---------- */
.cxp-set { display: inline-flex; align-items: center; gap: 10px; font-size: 1rem; color: #fff; }
.cxp-set-label { font-weight: 600; white-space: nowrap; }


/* Crucible Tier: the current tier's game badge, large, with arrows either side */
.cxp-tier-step { display: inline-flex; align-items: center; gap: 8px; }
.cxp-tier-arrow {
  width: 30px; height: 30px; padding: 0;
  font: inherit; font-size: 1.15rem; font-weight: 700; line-height: 1; color: #fff;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.cxp-tier-arrow:disabled { opacity: 0.35; cursor: default; }
.cxp-tier-badge { width: 44px; height: 44px; filter: brightness(2.4); }

.cxp-set input {
  width: 92px; font: inherit; font-size: 1rem; font-weight: 700; color: #fff;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 8px;
}
.cxp-set input:focus { outline: none; border-color: var(--gold); }

/* the calculator's toggle switch */
.cxp-switch {
  position: relative; flex-shrink: 0;
  width: 36px; height: 20px;
  background: var(--surface3); border: 1px solid var(--border); border-radius: 10px;
  transition: background .2s, border-color .2s;
}
.cxp-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #4a4a68;
  transition: transform .2s, background .2s;
}
.on > .cxp-switch, .cxp-switch.on { background: var(--gold-dim); border-color: var(--gold); }
.on > .cxp-switch::after, .cxp-switch.on::after { transform: translateX(16px); background: var(--gold); }
.cxp-qm-btn { display: inline-flex; align-items: center; gap: 10px; padding: 0; background: none; border: 0; cursor: pointer; font: inherit; color: #fff; }

/* ---------- penances + detail + result ---------- */
/* three columns like the game's screen: card grid (4 wide), the hovered penance, then Mission XP */
.cxp-main { display: grid; grid-template-columns: auto minmax(0, 1fr) 300px; gap: 22px; align-items: start; }

.cxp-picker-head { display: flex; align-items: baseline; gap: 12px; }
.cxp-col-head {
  margin: 0; padding: 10px 0 6px;
  font-size: 1.05rem; font-weight: 700; color: #fff;
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: baseline; gap: 12px;
}
/* underline only the heading words, not the count or buttons beside them */
.cxp-col-title { text-decoration: underline; text-underline-offset: 3px; }
.cxp-col-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.cxp-act {
  font: inherit; font-size: 1rem; color: #fff; padding: 3px 10px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.cxp-act:disabled { opacity: 0.4; cursor: default; }

/* the card grid: 120px cards, 4 to a row, built like the game's ui_crucible_penance_button.sso
   (textures in /assets/crucible-ui/, exported from the 15.2 client). Padding leaves room for the
   frame, which overhangs each card by 10px, and the flag, which overhangs 4-5px. */
.cxp-grid { display: grid; grid-template-columns: repeat(4, 120px); gap: 10px; padding: 10px 10px 0; margin-left: -10px; }
.cxp-card {
  position: relative; width: 120px; height: 120px; padding: 0;
  background: none; border: 0; cursor: pointer; font: inherit; color: #fff;
}
.cxp-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; }
/* body: every layer clipped to the game's path, a square with 6px notches in each corner */
.cxp-card-body {
  position: absolute; inset: 0; overflow: hidden;
  background: rgba(0, 0, 0, 0.133); /* "darken": black at alpha 34 */
  clip-path: polygon(6px 0, 114px 0, 114px 6px, 120px 6px, 120px 114px, 114px 114px, 114px 120px, 6px 120px, 6px 114px, 0 114px, 0 6px, 6px 6px);
}
.cxp-card-body > * { position: absolute; }
/* "bg": the game's dotbg texture tiled across the card, half strength at rest, full on hover */
.cxp-card-dots {
  inset: 0; opacity: 0.5; transition: opacity .12s;
  background: url(/assets/crucible-ui/dotbg.png) repeat; background-size: 6px 6px; background-position: 3px 3px;
}
.cxp-card-team { left: 4px; top: 4px; width: 112px; height: 112px; }
/* "highlight" (ui_codex_button_highlight.sso) is a white-to-blue gradient added on top, pulsing
   25-35%. Over the game's lit scene that reads as a muted slate blue, lighter at the top (owner's
   screenshot), so it is drawn here as that colour directly; our page behind is flat dark. */
.cxp-card-glow {
  inset: 0; opacity: 0;
  background: linear-gradient(180deg, rgba(128, 152, 178, 0.34) 0%, rgba(78, 104, 128, 0.24) 100%);
}
@keyframes cxp-glow-pulse { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
.cxp-card-icon { left: 60px; top: 56px; width: 72px; height: 72px; transform: translate(-50%, -50%); object-fit: contain; }
.cxp-card:has(.cxp-card-holders) .cxp-card-icon { top: 50px; width: 64px; height: 64px; }
/* unpicked cards: the icon dimmed (owner's call), lifted part way while hovered or shown in the panel */
.cxp-card .cxp-card-icon { transition: opacity .12s; }
.cxp-card:not(.on) .cxp-card-icon { opacity: 0.4; }
.cxp-card:not(.on).is-focus .cxp-card-icon { opacity: 0.75; }
.cxp-card-rank { left: 54px; top: 2px; width: 64px; height: 34px; background: url(/assets/crucible-ui/counter_top_bg.png) no-repeat; }
.cxp-card-rank img { position: absolute; left: 34px; top: 2px; width: 28px; height: 28px; }
.cxp-card-bottom { left: 2px; top: 78px; width: 64px; height: 40px; background: url(/assets/crucible-ui/counter_bottom_bg.png) no-repeat; }
.cxp-card-bottom img { position: absolute; left: 0; top: 9px; width: 31px; height: 31px; }
/* team penances: the squad count (0-3, you included) as four buttons along the card's bottom, in the
   game's beige counter text; the active one is gold. Buttons 1-3 only (owner): not picked is 0. */
.cxp-card-holders {
  position: absolute; left: 6px; right: 6px; bottom: 5px; z-index: 4;
  display: flex; gap: 3px;
}
.cxp-hold {
  flex: 1 1 0; height: 22px; padding: 0;
  font: inherit; font-size: 1rem; font-weight: 700; line-height: 1;
  color: rgb(182, 166, 142); text-shadow: 0 0 2px rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.6); border: 1px solid #55555f; border-radius: 2px;
  cursor: pointer;
}
.cxp-hold.active { background: var(--gold-dim); border-color: var(--gold); color: #fff; }
/* frames: 9-slice, drawn 10px outside the card (codex_item_frame at half strength; on hover the gold
   codex_item_frame_select plus codex_item_frame_thin inside it) */
.cxp-card-frame, .cxp-card-sel, .cxp-card-thin { position: absolute; box-sizing: border-box; pointer-events: none; transition: opacity .12s; }
.cxp-card-frame, .cxp-card-sel { left: -10px; top: -10px; width: 140px; height: 140px; border: 59px solid transparent; }
.cxp-card-frame { border-image: url(/assets/crucible-ui/codex_item_frame.png) 59 fill / 59px stretch; opacity: 0.5; }
.cxp-card-sel { border-image: url(/assets/crucible-ui/codex_item_frame_select.png) 59 fill / 59px stretch; opacity: 0; }
.cxp-card-thin { left: 1px; top: 1px; width: 118px; height: 118px; border: 40px solid transparent; border-image: url(/assets/crucible-ui/codex_item_frame_thin.png) 40 fill / 40px stretch; opacity: 0; }
/* picked: the game's corner flag, overhanging the top left */
.cxp-card-flag { position: absolute; left: -4px; top: -5px; width: 29px; height: 29px; pointer-events: none; }
/* picked cards keep the gold select frame and full-strength dots (the game's selected_* states look
   the same as hover on these layers); hover and the card in the detail panel also get the glow */
.cxp-card.on .cxp-card-dots { opacity: 1; }
.cxp-card.on .cxp-card-frame { opacity: 0; }
.cxp-card.on .cxp-card-sel, .cxp-card.on .cxp-card-thin { opacity: 1; }
.cxp-card.is-focus .cxp-card-dots { opacity: 1; }
.cxp-card.is-focus .cxp-card-glow { opacity: 0.85; animation: cxp-glow-pulse 2.7s linear infinite; }
.cxp-card.is-focus .cxp-card-frame { opacity: 0; }
.cxp-card.is-focus .cxp-card-sel, .cxp-card.is-focus .cxp-card-thin { opacity: 1; }
/* touch: the card being held for its tooltip lights up like a hovered card */
.cxp-card.is-held .cxp-card-dots, .cxp-card.is-held .cxp-card-sel, .cxp-card.is-held .cxp-card-thin { opacity: 1; }
/* steady, not pulsing: on iPhone the pulse made the other cards' frames stop drawing (owner bug) */
.cxp-card.is-held .cxp-card-glow { opacity: 0.85; animation: none; }
.cxp-card.is-held .cxp-card-frame { opacity: 0; }
.cxp-card:not(.on).is-held .cxp-card-icon { opacity: 0.75; }
/* no native press-and-hold menu (Share / Save to Photos / Copy) or text selection on the cards */
.cxp-card, .cxp-card img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* the hold tooltip: the page's tooltip look, with the calculator's gold note */
.cxp-tip { z-index: 9999; }
.cxp-tip .cxp-tip-desc, .cxp-tip .cxp-tip-mech, .cxp-tip .cxp-tip-xp { display: block; margin-top: 6px; }
.cxp-tip .cxp-tip-mech { color: #f5c518; font-style: italic; }
.cxp-tip .cxp-tip-xp { color: var(--gold); font-weight: 700; }

/* "13 selected of 7 Penances", under the grid as the game shows it under the model */
.cxp-selected-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 14px; }
.cxp-selected-rank { width: 28px; height: 28px; }
.cxp-selected { margin: 0; text-align: center; font-size: 1.05rem; font-weight: 700; color: #fff; }
.cxp-selected.is-short { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* the hovered penance, like the game's right-hand panel */
/* pinned below the sticky XP block like the Mission XP column, so scrolling down to the Tier 5 and 6
   cards never carries it out of view */
.cxp-detail {
  position: sticky; top: calc(var(--sticky-top, 0px) + var(--cxp-stick-h, 0px) + 12px);
  margin-top: 44px; min-height: 300px; padding: 22px 20px 18px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border: 1px solid #3b3b47; background: linear-gradient(180deg, #14141c 0%, #0e0e13 100%);
}
.cxp-detail-name { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.12em; }
.cxp-detail-cls { margin: 10px 0 0; display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.06em; }
.cxp-detail-cls img { width: 31px; height: 31px; }
/* effect text + the calculator's gold mechNote under it, kept together in the middle of the panel */
.cxp-detail-body { margin: auto 0; padding: 20px 0; }
.cxp-detail-desc { margin: 0; font-size: 1.05rem; font-style: italic; line-height: 1.5; color: #fff; }
/* same look as the calculator's gold note (.tooltip-mech-note: #f5c518, italic) */
.cxp-detail-mech { margin: 14px 0 0; font-size: 1rem; font-style: italic; line-height: 1.5; color: #f5c518; }
.cxp-red { color: #e0453a; font-style: italic; }
.cxp-detail-xp { margin: 0; padding-top: 12px; width: 100%; border-top: 1px solid #3b3b47; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1.1rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; }
.cxp-detail-xp img { width: 30px; height: 30px; }

/* ---------- result column ---------- */
/* sticks below the stuck XP bar (--cxp-stick-h = its height, measured in crucible-xp.js) */
.cxp-results { position: sticky; top: calc(var(--sticky-top, 0px) + var(--cxp-stick-h, 0px) + 12px); }
.cxp-results .cxp-col-head { border-bottom: 0; }

.cxp-ledger { margin: 0; }
.cxp-ledger > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 1rem; color: #fff;
}
.cxp-ledger dt { font-weight: 500; }
.cxp-ledger dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
/* Quick Match Bonus while the bonus is off: the amount stays, grey and struck through (owner's call) */
.cxp-ledger > div.is-off dd { color: #8a8aa3; text-decoration: line-through; }

.cxp-outcome { border-top: 1px solid var(--gold-dim); margin-top: 2px; }
.cxp-outcome > div {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.cxp-outcome dt { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 600; color: #fff; }
.cxp-outcome dd { margin: 0; font-size: 1.7rem; font-weight: 800; color: #fff; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cxp-mark { width: 16px; height: 10px; flex-shrink: 0; }
.cxp-mark.is-win { background: var(--green); }
/* the loss key matches the XP bar: red diagonal stripes over gold */
.cxp-mark.is-loss { background: repeating-linear-gradient(-45deg, var(--red) 0 3px, var(--gold) 3px 6px); }

.cxp-warn { margin: 10px 0 0; font-size: 1rem; color: #fff; padding: 6px 0 6px 10px; border-bottom: 2px solid var(--red); }

/* XP bar under the class cards, in the Health view's in-game frame (assets/health-bar-frame.png,
   416x72). The frame is drawn as a border-image: the diamond (left 70px) and arrow tip (right 12px)
   stay at native size and only the straight outline between them stretches, so the bar can be wide
   and stay sharp. The channel itself (rows 29-43) is left out and drawn by .cxp-xpbar-chan.
   Channel geometry is the Health view's at native scale: 63px in from the left, 8px from the right,
   41%..59% down, with the same arrow tip. The diamond holds the tier number. */
/* the bar block sticks under the wiki's sticky header (--sticky-top, set by wiki-search.js) while
   you scroll; its own background hides what scrolls underneath, and a rule appears once it is stuck */
.cxp-track {
  position: sticky; top: var(--sticky-top, 0px); z-index: 30;
  display: flex; flex-direction: column; align-items: center;
  margin: 12px 0 8px; padding: 30px 0 14px;
  background: var(--bg);
}
.cxp-track.is-stuck { border-bottom: 1px solid var(--border); }
.cxp-xpbar { position: relative; width: 100%; max-width: 820px; height: 72px; }
.cxp-xpbar > * { position: absolute; }
.cxp-xpbar-chan {
  left: 63px; right: 8px; top: 29.5px; height: 13px;
  background: #0a0a0a; z-index: 1;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
}
.cxp-xpbar-chan > span { position: absolute; top: 0; bottom: 0; left: 0; width: 0; }
.cxp-bar-now { background: var(--gold); }
.cxp-bar-win { background: var(--green); }
/* previewing a tier above yours: the win it would add is a plan, not your XP, so it shows grey */
.cxp-bar-win.is-plan { background: #8a8aa3; }
/* what a loss would take: red diagonal stripes laid over the gold, so the earned gold still shows */
.cxp-bar-loss { background: repeating-linear-gradient(-45deg, var(--red) 0 4px, transparent 4px 8px); }
.cxp-xpbar-bulb {
  z-index: 2; height: 62px; width: 62px; left: 35px; top: 50%;
  transform: translate(-50%, -50%);
  background: #0a0a0a;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.cxp-xpbar-frame {
  inset: 0; z-index: 3; pointer-events: none;
  border-style: solid; border-width: 29px 12px 29px 70px;
  /* no "fill": the channel's own dark texture stays out, so the gold / red / green read at full strength */
  border-image: url(/assets/health-bar-frame.png) 29 12 29 70 stretch;
}
.cxp-xpbar-tier {
  z-index: 4; left: 35px; top: 50%; transform: translate(-50%, -50%);
  font-size: 1.3rem; font-weight: 800; color: #fff; line-height: 1;
}
/* reward points: same span as the channel, so left % = share of the tier's XP */
.cxp-xpbar-marks { left: 63px; right: 8px; top: 0; bottom: 0; z-index: 5; }
/* a reward point: a gold tick on the bar at the exact point, and the reward box hanging just below
   the bar on that point (so the bar itself stays visible), with the XP and the wins beside it */
.cxp-rw { position: absolute; top: 0; width: 0; height: 72px; cursor: help; }
.cxp-rw::before { /* the tick, from just above the channel down to the box */
  content: ""; position: absolute; left: -1px; top: 24px; height: 28px; width: 2px; background: var(--gold);
}
.cxp-rw::after { /* diamond head on the bar, echoing the frame */
  content: ""; position: absolute; left: -5px; top: 19px; width: 10px; height: 10px;
  background: var(--gold); transform: rotate(45deg);
}
.cxp-rw-box {
  position: absolute; left: -26px; top: 52px; width: 52px; height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #0e0e14; border: 1px solid #6c6c7c;
}
.cxp-rw-box > img { width: 40px; height: 40px; object-fit: contain; filter: grayscale(1) brightness(0.8); }
.cxp-rw-box.is-coin > img { width: 28px; height: 28px; }
.cxp-rw-amt { font-size: 1rem; font-weight: 700; line-height: 1; color: #fff; }
/* reached: the icon in colour and the game's inner glow on a gold frame */
.cxp-rw.is-reached .cxp-rw-box { border-color: var(--gold); }
.cxp-rw.is-reached .cxp-rw-box::after { /* reward_frame_inner_glow, 9-slice 20, scaled to the 52px box */
  content: ""; position: absolute; inset: 0; box-sizing: border-box; pointer-events: none;
  border: 12px solid transparent; border-image: url(/assets/crucible-ui/rewards/reward_frame_inner_glow.png) 20 fill / 12px stretch;
}
.cxp-rw.is-reached .cxp-rw-box > img { filter: none; }
.cxp-rw-lbl, .cxp-rw-runs {
  position: absolute; left: 34px;
  font-size: 1rem; color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.cxp-rw-lbl { top: 56px; font-weight: 700; }
/* wins it takes to reach this reward from your current XP with the penances picked now */
.cxp-rw-runs { top: 78px; font-weight: 500; }

/* where you are now: a white caret above the bar (the Health view's marker, pointing down) */
.cxp-caret {
  position: absolute; top: 14px; z-index: 2; width: 0; height: 0;
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-top: 12px solid #fff;
  filter: drop-shadow(0 -1px 1px #000);
  transform: translateX(-50%); pointer-events: none;
}

/* "Current XP: n" sits above the caret */
.cxp-now-lbl {
  position: absolute; top: -24px; transform: translateX(-50%); line-height: 1.2;
  font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Win / Loss: record a mission and move your saved XP (the calculator's button look) */
/* the control row below the bar inside the sticky block (the top margin clears the reward boxes
   hanging under the bar): tier, XP and Quick Match, a divider, then Win / Loss */
.cxp-record {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 18px;
  width: 100%; margin: 50px 0 0; padding-top: 14px; border-top: 1px solid var(--border);
}
.cxp-record-div { width: 1px; align-self: stretch; min-height: 32px; background: var(--border); }
.cxp-record-actions { display: flex; gap: 12px; }
.cxp-rec-btn {
  display: inline-flex; align-items: center; gap: 10px;
  font: inherit; font-size: 1.05rem; font-weight: 700; color: #fff;
  padding: 7px 16px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: background .15s, border-color .15s;
}
.cxp-rec-btn span:last-child { font-variant-numeric: tabular-nums; }
.cxp-rec-btn:disabled { cursor: not-allowed; border-style: dashed; }
/* on a future tier Win and Loss stay in place but greyed out, so the row never shifts; Win's swatch
   turns the planned-win grey of the bar (owner) */
.cxp-rec-btn.is-off { opacity: 0.4; }
.cxp-rec-btn.is-off .cxp-mark.is-win { background: #8a8aa3; }
/* the amounts and the "of N" total keep one width (widest: +88,888 and "of 104,400"), so the
   centred row, and the tier arrows in it, never move when the numbers change (owner) */
#cxp-add-win-amt, #cxp-add-loss-amt { display: inline-block; min-width: 4.3em; text-align: left; }
#cxp-xp-of { display: inline-block; min-width: 5.2em; text-align: left; font-variant-numeric: tabular-nums; }
/* "Previewing Tier 6, your tier is 4." with Back / Make buttons, under the control row */
.cxp-preview { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0 0; font-size: 1rem; color: #fff; }
.cxp-preview[hidden] { display: none; }
.cxp-preview strong { color: var(--gold); }
.cxp-act.is-gold { border-color: var(--gold); }
/* Clear unsaved changes: drops the tiers you mapped out, so it reads as a warning */
.cxp-act.is-red { border-color: var(--red); }
.cxp-set input:disabled { cursor: not-allowed; }
/* what the last Win / Loss did, under the row (empty until you press one) */
.cxp-status { margin: 6px 0 0; min-height: 1.3em; text-align: center; font-size: 1rem; font-weight: 600; color: #fff; }

/* ---------- How Crucible XP Works ---------- */
.cxp-tables { display: grid; grid-template-columns: 1fr 1.4fr; gap: 28px; align-items: start; }
.cxp-tables h3 { margin: 8px 0 4px; }
.cxp-formula th { white-space: nowrap; width: 1%; }

/* hover looks only where there is a mouse (the calculator's rule): on a touch screen they would stay
   on after a tap, so a tap that only closes a tooltip would look like it pressed something */
@media (hover: hover) {
  .cxp-info:hover { background: var(--gold-glow); outline: none; }
  .cxp-class-btn:hover { border-color: var(--gold); }
  .cxp-fold:hover { background: var(--surface3); border-color: var(--gold-dim); }
  .cxp-tier-arrow:hover:not(:disabled) { background: var(--surface3); border-color: var(--gold-dim); }
  .cxp-act:hover:not(:disabled) { background: var(--surface3); }
  .cxp-card:not(.on):hover .cxp-card-icon { opacity: 0.75; }
  .cxp-hold:hover { border-color: #9a9aac; color: #fff; }
  .cxp-card:hover .cxp-card-dots { opacity: 1; }
  .cxp-card:hover .cxp-card-glow { opacity: 0.85; animation: cxp-glow-pulse 2.7s linear infinite; }
  .cxp-card:hover .cxp-card-frame { opacity: 0; }
  .cxp-card:hover .cxp-card-sel, .cxp-card:hover .cxp-card-thin { opacity: 1; }
  .cxp-rec-btn.is-win:hover:not(:disabled) { border-color: var(--green); background: var(--surface3); }
  .cxp-rec-btn.is-loss:hover:not(:disabled) { border-color: var(--red); background: var(--surface3); }
  .cxp-act.is-gold:hover { background: var(--gold-dim); }
  .cxp-act.is-red:hover { background: rgba(192, 57, 43, 0.25); }
}

/* touch tooltips: the held element lights up while its tooltip is open; no native press-and-hold
   menu (Share / Save to Photos / Copy) or text selection on the tool's pictures and controls */
.cxp-rw.is-held .cxp-rw-box { border-color: var(--gold); }
.cxp-card-holders.is-held { outline: 1px solid var(--gold); outline-offset: 2px; }
.cxp-title-info.is-held { background: var(--gold-glow); }
.cxp-head img, .cxp-tool img, .cxp-class-btn, .cxp-rw, .cxp-card-holders { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* the Mission XP drawer's tab, close button and dimmed backdrop are for phones only */
.cxp-drawer-tab, .cxp-drawer-x { display: none; }
.cxp-drawer-scrim { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, 0.6); }
.cxp-drawer-scrim[hidden] { display: none; }

/* ---------- phones (owner, 2026-11-25) ----------
   The desktop layout stays as approved; at phone width:
   - the intro opens from an info icon beside the title (no fold caret; the class pictures always show)
   - class cards in two rows, 4 then 3, the tier badge on the picture and the name below it
     ("TECHMARINE" in capitals needs ~105px, a card here has ~75px, so the names are not capitalised)
   - reward labels sit to the left of each box and the last box hangs inside the bar's end
   - the Crucible Tier arrows sit under the tier diamond, its label dropped
   - "XP" and "Quick Match" share one row, Win / Loss below, with tighter spacing */
@media (max-width: 700px) {
  .cxp-title-info { display: inline-flex; width: 28px; height: 28px; margin-left: -4px; font-size: 1rem; padding: 0; background: none; }
  .cxp-head { grid-template-columns: minmax(0, 1fr); margin-bottom: 8px; }
  .cxp-head .cxp-fold, .cxp-head .cxp-intro { display: none; }
  .cxp-head .cxp-classes, .cxp-folded .cxp-head .cxp-classes { grid-column: 1; grid-row: 1; }
  /* fold button on the title line, pushed to the right end (owner); folds the class pictures */
  .cxp-fold-title { display: flex; margin-left: auto; }

  /* every card the same size, 4 to a row. The bottom row's 3 are spaced evenly: the same gap
     between them and to the page edges, so they sit offset under the top row (owner). Cards are
     one fixed height; the name strip is only as tall as its text (owner: no margin above and
     below the names) and the picture fills the rest, so "Tech-marine" on two lines simply
     takes a little more of its card. */
  .cxp-classes { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 0; }
  .cxp-class-btn { position: relative; width: calc((100% - 24px) / 4); height: 124px; }
  .cxp-class-btn:nth-child(n+5) { margin-left: auto; }
  .cxp-class-btn:nth-child(7) { margin-right: auto; }
  .cxp-class-btn > img { flex: 1 1 auto; min-height: 0; height: auto; aspect-ratio: auto; object-position: center 22%; }
  .cxp-class-btn span { padding: 3px 2px; letter-spacing: 0; text-transform: none; line-height: 1.2; }
  .cxp-class-btn .cxp-class-name { flex: 0 0 auto; hyphens: manual; position: relative; }
  /* the badge sits in the picture's bottom left corner (owner), just above the name, on a dark disc
     so it reads over the art */
  .cxp-class-btn .cxp-class-rank { position: absolute; left: 4px; bottom: calc(100% + 4px); width: 32px; height: 32px; padding: 2px; box-sizing: border-box; border-radius: 50%; background: rgba(0, 0, 0, 0.65); }
  /* folded = fully collapsed (owner): one slim row of chips, each the name with its tier badge
     beside it. Badge + name at full size does not fit 4 to a row, so the row scrolls sideways. */
  /* the row runs on to the screen's right edge so the next chip peeks in, showing there are more */
  .cxp-folded .cxp-classes { flex-wrap: nowrap; justify-content: flex-start; gap: 0 8px; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
  .cxp-folded .cxp-classes::-webkit-scrollbar { display: none; }
  .cxp-folded .cxp-class-btn { flex: 0 0 auto; width: auto; height: auto; margin: 0; }
  .cxp-folded .cxp-class-btn .cxp-class-name { flex-direction: row; gap: 6px; padding: 5px 10px 5px 6px; white-space: nowrap; }
  .cxp-folded .cxp-class-btn .cxp-class-rank { position: static; width: 26px; height: 26px; padding: 0; background: none; }

  /* Penances header: the buttons sit right after the title and drop under it when they do not fit
     on the screen's line (owner: they ran off the page) */
  .cxp-picker-head { flex-wrap: wrap; row-gap: 8px; max-width: calc(100vw - 32px); }
  .cxp-col-actions { margin-left: 0; }

  .cxp-track { margin: 4px 0 6px; padding: 28px 0 8px; }
  /* once pinned, drop the band above the bar (owner): "Current XP" goes (the XP field just below
     shows the same number) and the 20px given back moves to the bottom margin, so nothing jumps */
  .cxp-track.is-stuck { padding-top: 8px; margin-bottom: 26px; }
  .cxp-track.is-stuck .cxp-now-lbl { display: none; }
  .cxp-track .cxp-rw-lbl, .cxp-track .cxp-rw-runs { left: auto; right: 32px; text-align: right; }
  .cxp-track .cxp-rw.is-end .cxp-rw-box { left: -52px; }
  .cxp-track .cxp-rw.is-end .cxp-rw-lbl, .cxp-track .cxp-rw.is-end .cxp-rw-runs { right: 58px; }

  /* tier arrows under the diamond (centre 35px from the bar's left), in the space the rewards leave */
  .cxp-record > .cxp-set:first-child { display: contents; }
  .cxp-record > .cxp-set:first-child > .cxp-set-label { display: none; }
  .cxp-tier-step { position: absolute; left: 0; top: 104px; gap: 4px; }
  .cxp-track.is-stuck .cxp-tier-step { top: 84px; }
  .cxp-tier-step .cxp-tier-badge { width: 28px; height: 28px; }

  .cxp-record { justify-content: space-between; gap: 10px 14px; margin-top: 42px; padding-top: 10px; }
  .cxp-record-div { display: none; }
  .cxp-lbl-long { display: none; }
  .cxp-lbl-short { display: inline; }
  .cxp-set { gap: 8px; }
  .cxp-set input { width: 80px; }
  .cxp-record-actions { flex: 1 1 100%; display: flex; gap: 10px; }
  .cxp-record-actions .cxp-rec-btn { flex: 1 1 0; justify-content: center; padding: 7px 10px; }
  .cxp-status:empty { display: none; }
  /* preview line: the sentence on its own line, the two buttons side by side under it */
  .cxp-preview { flex-wrap: wrap; justify-content: flex-start; gap: 8px; width: 100%; margin-top: 10px; }
  .cxp-preview > span { flex: 1 1 100%; }
  .cxp-preview .cxp-act { flex: 1 1 0; min-height: 40px; white-space: nowrap; }

  /* penances: one column, the grid 3 cards to a row scaled to fit the screen; the detail panel's job
     is done by the press-and-hold tooltip, so it is not shown, and the last tapped card is not lit */
  .cxp-main { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .cxp-detail { display: none; }
  /* four to a row like the desktop and the game (owner); fitGrid() in crucible-xp.js scales the grid
     to the screen (about 0.69 on an iPhone). Team count buttons taller and bigger inside the card so
     they stay tappable at that scale. */
  .cxp-grid { grid-template-columns: repeat(4, 120px); gap: 10px; justify-content: center; margin: 0 auto; padding: 10px; zoom: 0.69; }
  .cxp-hold { height: 30px; font-size: 1.35rem; }
  .cxp-card.is-focus:not(.is-held) .cxp-card-glow { opacity: 0; animation: none; }
  .cxp-card.is-focus:not(.on):not(.is-held) .cxp-card-dots { opacity: 0.5; }
  .cxp-card.is-focus:not(.on):not(.is-held) .cxp-card-frame { opacity: 0.5; }
  .cxp-card.is-focus:not(.on):not(.is-held) .cxp-card-sel, .cxp-card.is-focus:not(.on):not(.is-held) .cxp-card-thin { opacity: 0; }
  .cxp-card.is-focus:not(.on):not(.is-held) .cxp-card-icon { opacity: 0.4; }
  .cxp-tables { display: block; }
  /* the wiki turns tables into sideways-scrolling blocks on phones; the formula table wraps instead */
  #section-how .cxp-formula { display: table; width: 100%; }
  #section-how .cxp-formula tbody { display: table-row-group; width: auto; }

  /* Mission XP: a drawer from the right edge (owner's idea), the tab on the edge opens it */
  .cxp-results {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1001;
    width: min(340px, 88vw); overflow-y: auto; padding: 14px 16px 28px;
    background: #101017; border-left: 1px solid var(--gold-dim);
    transform: translateX(100%); visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  .cxp-drawer-open .cxp-results { transform: none; visibility: visible; transition: transform 0.22s ease, visibility 0s; }
  .cxp-results .cxp-col-head { justify-content: space-between; align-items: center; }
  .cxp-drawer-x {
    display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
    font: inherit; font-size: 1.5rem; line-height: 1; color: #fff;
    background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  }
  .cxp-drawer-tab {
    display: block; position: fixed; right: 0; top: 74%; z-index: 40;
    writing-mode: vertical-rl; transform: rotate(180deg); padding: 12px 4px;
    font: inherit; font-size: 1rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #fff;
    background: var(--surface2); border: 1px solid var(--gold-dim); border-right: 0;
    border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer;
  }
  .cxp-drawer-tab.is-away { display: none; }
}
