/* Crispybulb UI: every overlay. Loaded by createUI() (src/ui/ui.js); index.html does not link it.
   The look: a moonlit storybook. Text and marks are lit by the hero's lamp (warm) or by the moon (cool);
   the Gloom is the only violet. No panels: type, hairlines and light sit straight on the night.
   Surface kinds (three, nothing else gets a fill or an edge):
     1. night  - the veil over the scene behind a menu (no edge, no radius)
     2. card   - an upgrade card, the only framed object (radius --r-card; evolution cards are arched)
     3. meter  - a glass tube that holds light: health, boss, sliders (radius --r-tube)
   Every colour is a token in the first :root. Sizes scale with --u (14 px at 720p, about 23 px at 1440p). */

@font-face { font-family: 'CB Fell'; src: url('fonts/IMFellEnglish-Regular.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'CB Fell'; src: url('fonts/IMFellEnglish-Italic.woff2') format('woff2'); font-style: italic; font-display: block; }
@font-face { font-family: 'CB Alegreya'; src: url('fonts/Alegreya-VF.woff2') format('woff2'); font-weight: 400 900; font-display: block; }
@font-face { font-family: 'CB Alegreya'; src: url('fonts/Alegreya-Italic-VF.woff2') format('woff2'); font-weight: 400 900; font-style: italic; font-display: block; }
@font-face { font-family: 'CB Sans'; src: url('fonts/AlegreyaSans-Medium.woff2') format('woff2'); font-weight: 500; font-display: block; }
@font-face { font-family: 'CB Sans'; src: url('fonts/AlegreyaSans-ExtraBold.woff2') format('woff2'); font-weight: 800; font-display: block; }

:root {
  /* the night (cold) */
  --night-0: #06090d;
  --night-1: #0b121a;
  --night-2: #101a24;
  --paper: #131c27;
  --paper-lit: #1b2532;
  --ink: #04070a;
  --hair: #2b3846;
  --hair-strong: #3d4d5e;
  --glass: #0d151e;

  /* text */
  --text: #f2e6cd;          /* lamp-lit ink, the most read text */
  --text-2: #aebbc8;        /* moonlit, secondary */
  --text-3: #8293a3;        /* quiet: hints, labels */

  /* the hero's light (warm) */
  --honey: #f3c97a;
  --lamp: #ffb143;
  --lamp-deep: #e0812a;
  --white-hot: #fff3d6;
  --brass: #b0844a;
  --brass-dim: #5e4a33;
  --ember-cold: #6b3a22;    /* a filament before it heats */

  /* the Gloom (cold violet), danger */
  --gloom: #c35ae9;
  --gloom-pale: #e6b9f7;
  --gloom-deep: #43195a;
  --matriarch: #ee6fd8;            /* the boss's edge marker: magenta-violet, warmer than the gloom */
  --plum: #1c0f24;

  /* chest tiers: tin (cool pewter), brass (the honey family), gilt (dawn gold) */
  --tin: #c9d2d9;
  --tin-deep: #6f7b85;
  --tin-pool: rgba(201, 210, 217, 0.13);
  --tin-pool-clear: rgba(201, 210, 217, 0);
  --gilt-pool: rgba(255, 217, 142, 0.26);
  --gilt-pool-clear: rgba(255, 217, 142, 0);
  /* card faces: the paper each tier is printed on */
  --tin-face: #151b21;
  --brass-face: #18191b;
  --gilt-face: #2b2110;
  /* evolution: the gilt family's crown, a deeper burnished gold lit from the keystone */
  --evo-face: #36260d;
  --evo-face-hi: #5a4016;
  --evo-ray: rgba(255, 217, 142, 0.22);
  --evo-ray-clear: rgba(255, 217, 142, 0);
  --mask: #000;

  /* the minimap's night paper */
  --map-paper: #121a29;
  --map-paper-2: #24324c;
  --map-ink: #9fb0cc;
  --map-water: #23405e;

  /* dawn */
  --dawn: #ffd98e;
  --dawn-rose: #f2a383;
  --dawn-sky: #2a3550;

  /* veils (rgba of the night) */
  --veil: rgba(6, 9, 13, 0.74);
  --veil-soft: rgba(6, 9, 13, 0.38);
  --veil-deep: rgba(6, 9, 13, 0.84);
  --veil-mid: rgba(6, 9, 13, 0.56);
  --veil-clear: rgba(6, 9, 13, 0);
  --dawn-veil: rgba(255, 178, 128, 0.30);
  --dawn-veil-clear: rgba(255, 178, 128, 0);
  --lamp-pool: rgba(255, 177, 67, 0.20);
  --lamp-pool-clear: rgba(255, 177, 67, 0);
  --gloom-pool: rgba(195, 90, 233, 0.16);
  --gloom-pool-clear: rgba(195, 90, 233, 0);
  --shadow-ink: rgba(4, 7, 10, 0.92);
  --shadow-ink-soft: rgba(4, 7, 10, 0.55);
}

/* ------------------------------------------------------------------ root and layers */
.cb-ui {
  --u: min(calc(0.7vw + 5px), calc(1.25vh + 5px));
  --s-1: calc(var(--u) * 0.86);   /* 12 px at 720p: the floor */
  --s0: var(--u);
  --s1: calc(var(--u) * 1.15);
  --s2: calc(var(--u) * 1.45);
  --s3: calc(var(--u) * 1.9);
  --s4: calc(var(--u) * 2.6);
  --s5: calc(var(--u) * 3.6);
  --s6: calc(var(--u) * 5.6);
  --g1: calc(var(--u) * 0.25);
  --g2: calc(var(--u) * 0.5);
  --g3: calc(var(--u) * 0.85);
  --g4: calc(var(--u) * 1.4);
  --g5: calc(var(--u) * 2.4);
  --g6: calc(var(--u) * 4);
  --r-card: calc(var(--u) * 0.35);
  --r-tube: 999px;
  --edge: max(16px, calc(var(--u) * 1.5));

  position: fixed; inset: 0; z-index: 10;
  pointer-events: none; user-select: none;
  color: var(--text);
  font-family: 'CB Alegreya', Georgia, serif;
  font-size: var(--s0);
  line-height: 1.35;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}
.cb-ui *, .cb-ui *::before, .cb-ui *::after { box-sizing: border-box; }
.cb-ui [hidden] { display: none !important; }
.cb-fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.cb-hud, .cb-hudtop, .cb-toasts, .cb-boss, .cb-cross { position: absolute; }
.cb-layer { position: absolute; inset: 0; display: none; pointer-events: auto; }
.cb-layer.is-open { display: block; }
:where(.cb-ui) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
.cb-ui :focus { outline: none; }
.cb-ui :focus-visible { outline: 2px solid var(--lamp); outline-offset: 4px; border-radius: 2px; }

.cb-num { font-family: 'CB Sans', sans-serif; font-weight: 800; font-variant-numeric: tabular-nums lining-nums; }
.cb-display { font-family: 'CB Fell', Georgia, serif; font-weight: 400; letter-spacing: 0.005em; }
.cb-shadow { text-shadow: 0 1px 2px var(--shadow-ink), 0 0 calc(var(--u) * 0.6) var(--shadow-ink-soft); }

/* ------------------------------------------------------------------ icons */
.cb-icon { display: block; width: 100%; height: 100%; overflow: visible; }
.cb-icon use { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cb-icon__under { --ic-line: var(--ink); --ic-glow: var(--ink); --ic-soft: var(--ink); --ic-k: var(--ink); --ic-fw: 5.2; --ic-kw: 0; --ic-go: 0;
  stroke-width: 5.2; opacity: 0.85; }
.cb-icon__ink { stroke-width: 2.1; --ic-fw: 0.6; --ic-kw: 1.5; --ic-go: 0.42; }
/* each kind has its own default colours; a wrapper can override them by setting --c-line / --c-glow */
.cb-icon--weapon, .cb-icon--glyph { --k-line: var(--honey); --k-glow: var(--lamp); }
.cb-icon--passive { --k-line: var(--text); --k-glow: var(--honey); }
.cb-icon--special { --k-line: var(--text); --k-glow: var(--honey); }
.cb-icon--evolution { --k-line: var(--dawn); --k-glow: var(--white-hot); }
.cb-icon__ink { --ic-line: var(--c-line, var(--k-line)); --ic-glow: var(--c-glow, var(--k-glow)); --ic-soft: var(--c-glow, var(--k-glow)); --ic-k: var(--ink); }
.cb-slot .cb-icon__ink, .cb-mini .cb-icon__ink, .cb-toggle__bulb .cb-icon__ink { stroke-width: 2.6; }
.cb-slot .cb-icon__under, .cb-mini .cb-icon__under { stroke-width: 6; --ic-fw: 6; }
.cb-dawn__marker.is-out { --c-line: var(--text-3); --c-glow: var(--glass); }
.cb-ui.has-menu .cb-cross, .cb-ui.has-menu .cb-boss, .cb-ui.has-menu .cb-toasts, .cb-ui.has-menu .cb-dawn { visibility: hidden; }
.cb-ui.has-menu .cb-sum .cb-dawn { visibility: visible; }

/* ------------------------------------------------------------------ HUD */
.cb-hud { inset: 0; }
.cb-hud.is-hidden { visibility: hidden; }

/* top-centre: a soft shade under the night arc and the boss bar, so they read over a bright scene (no edge) */
.cb-topband { position: absolute; left: 50%; top: 0; width: calc(var(--u) * 44); height: calc(var(--u) * 11); transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 100% at 50% 0%, var(--veil) 0%, var(--veil-soft) 55%, var(--veil-clear) 100%); }

/* top-left: level and the build */
.cb-build { position: absolute; left: var(--edge); top: var(--edge); display: grid; gap: var(--g2); }
.cb-slots { display: flex; gap: var(--g3); list-style: none; margin: 0; padding: 0; }
.cb-slot { position: relative; width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8); }
.cb-slots--passive .cb-slot { width: calc(var(--u) * 2.2); height: calc(var(--u) * 2.2); }
.cb-slot__lv { position: absolute; right: calc(var(--u) * -0.35); bottom: calc(var(--u) * -0.3); font-size: var(--s-1);
  line-height: 1; color: var(--text); text-shadow: 0 0 2px var(--ink), 0 0 3px var(--ink), 0 1px 1px var(--ink); }
.cb-slot__lv.is-max { color: var(--lamp); }
.cb-slot--empty::before { content: ''; position: absolute; inset: 32%; border-radius: 50%; border: 1.5px dashed var(--hair-strong); }

/* top-centre: the night arc, moon to sun */
.cb-dawn { position: absolute; left: 50%; top: calc(var(--u) * 0.7); transform: translateX(-50%);
  width: calc(var(--u) * 19); text-align: center; }
.cb-dawn svg { display: block; width: 100%; height: auto; overflow: visible; }
.cb-dawn__track { fill: none; stroke: var(--hair-strong); stroke-width: 2.4; stroke-linecap: round; }
.cb-dawn__under { fill: none; stroke: var(--ink); stroke-opacity: 0.6; stroke-width: 7; stroke-linecap: round; }
.cb-dawn__done { fill: none; stroke: var(--honey); stroke-width: 3; stroke-linecap: round; }
.cb-dawn__tick { stroke: var(--text-3); stroke-width: 1.6; stroke-linecap: round; }
.cb-dawn__tick.is-major { stroke: var(--text-2); stroke-width: 2; }
.cb-dawn__tick.is-done { stroke: var(--honey); }
.cb-dawn__boss { --c-line: var(--gloom-pale); --c-glow: var(--gloom); }
.cb-dawn__moon { --c-line: var(--text-2); --c-glow: var(--text-2); }
.cb-dawn__sun { --c-line: var(--brass); --c-glow: var(--brass); }
.cb-dawn.is-warming .cb-dawn__sun { --c-line: var(--dawn); --c-glow: var(--dawn); }
.cb-dawn__time { margin-top: calc(var(--u) * -1.25); font-size: calc(var(--u) * 1.7); line-height: 1; color: var(--text); }
.cb-dawn__left { font-family: 'CB Fell'; font-style: italic; font-size: var(--s0); color: var(--text-2); margin-top: 0; }

/* top-right: kills and fps */
.cb-kills { position: absolute; right: var(--edge); top: calc(var(--edge) + var(--u) * 0.2); display: flex; align-items: center; gap: var(--g2); }
.cb-kills__ic { width: calc(var(--u) * 2.1); height: calc(var(--u) * 2.1); --c-line: var(--text-2); --c-glow: var(--gloom); }
.cb-kills__n { font-size: var(--s3); line-height: 1; }
/* minimap: a round vignette of night paper, bottom right (clear of the build, the arc, the kills and the vitals) */
.cb-map { position: absolute; right: var(--edge); bottom: var(--edge); width: calc(var(--u) * 14.5); aspect-ratio: 1; display: none;
  filter: drop-shadow(0 0 calc(var(--u) * 0.8) var(--shadow-ink-soft)); }
.cb-map.is-on { display: block; }
.cb-map.is-large { width: calc(var(--u) * 19); }
.cb-map__c { display: block; width: 100%; height: 100%; }
.cb-ui.has-menu .cb-map { visibility: hidden; }
.cb-fps { position: absolute; right: var(--edge); top: calc(var(--edge) + var(--u) * 2.8); font-size: var(--s-1); color: var(--text-3); }

/* bottom-centre: the hero's light (health) and the dash */
.cb-vital { position: absolute; left: 50%; bottom: calc(var(--edge) + var(--u) * 0.4); transform: translateX(-50%);
  display: grid; grid-template-columns: calc(var(--u) * 3) calc(var(--u) * 20) minmax(calc(var(--u) * 5.2), auto) auto; align-items: center;
  column-gap: var(--g3); row-gap: calc(var(--u) * 0.4); }
.cb-vital__bulb { grid-area: 1 / 1; justify-self: center; }
.cb-hp { grid-area: 1 / 2; }
.cb-dash { grid-area: 1 / 4 / 3 / 5; align-self: start; }
/* experience: a warm thread under the health tube, the level printed beside it */
.cb-lv { grid-area: 2 / 3; justify-self: start; transform-origin: 0 60%; display: flex; align-items: baseline; gap: calc(var(--u) * 0.2); line-height: 1; }
.cb-lv__k { font-family: 'CB Fell'; font-style: italic; font-size: var(--s-1); color: var(--text-2); }
.cb-lv__n { font-size: var(--s2); color: var(--honey); }
.cb-lv.is-queued .cb-lv__n { text-shadow: 0 0 calc(var(--u) * 0.7) var(--lamp-pool); }
/* queued picks (playtest M3 #8): a small fanned hand of night-paper cards left of the health bulb, the count on the
   front card, "picks waiting" beside it and under the words a thread that runs down until the cards open */
.cb-queue { position: absolute; right: calc(100% + var(--g3)); bottom: calc(var(--u) * 0.1); display: flex; align-items: center; gap: var(--g2);
  white-space: nowrap; transform-origin: 100% 60%; }
.cb-queue[hidden] { display: none; }
.cb-queue__deck { position: relative; width: calc(var(--u) * 3.1); height: calc(var(--u) * 2.6); flex: none; }
.cb-queue__deck i { position: absolute; left: 50%; bottom: 0; width: calc(var(--u) * 1.55); height: calc(var(--u) * 2.15); margin-left: calc(var(--u) * -0.775);
  border-radius: 2px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--brass-dim), 0 0 0 1.5px var(--ink); transform-origin: 50% 100%; }
.cb-queue__deck i:nth-child(1) { transform: translateX(calc(var(--u) * -0.75)) rotate(-24deg); }
.cb-queue__deck i:nth-child(2) { transform: translateX(calc(var(--u) * -0.3)) rotate(-10deg); }
.cb-queue[data-n="1"] .cb-queue__deck i:nth-child(-n+2), .cb-queue[data-n="2"] .cb-queue__deck i:nth-child(1) { visibility: hidden; }
.cb-queue__deck .cb-queue__front { transform: translateX(calc(var(--u) * 0.3)) rotate(5deg); display: grid; place-items: center; background: var(--paper-lit);
  box-shadow: inset 0 0 0 1.5px var(--honey), 0 0 0 1.5px var(--ink), 0 0 calc(var(--u) * 0.9) var(--lamp-pool); }
.cb-queue__front b { font-size: var(--s2); font-weight: 800; line-height: 1; color: var(--honey); transform: rotate(-5deg); }
.cb-queue__w { display: grid; gap: calc(var(--u) * 0.3); justify-items: start; }
.cb-queue__words { font-family: 'CB Fell'; font-style: italic; font-size: var(--s1); line-height: 1; color: var(--honey); }
.cb-queue__t { position: relative; width: 100%; height: 2px; border-radius: 1px; background: var(--hair); overflow: hidden; }
.cb-queue__t i { position: absolute; inset: 0; background: var(--honey); transform-origin: 0 50%; transform: scaleX(1); }
@media (prefers-reduced-motion: no-preference) {
  .cb-queue.is-arrive { animation: cb-q-arrive 620ms cubic-bezier(.2,.8,.3,1); }
  .cb-queue.is-first { animation: cb-q-arrive 620ms cubic-bezier(.2,.8,.3,1), cb-q-glow 1.1s 560ms ease-in-out 2; }
  .cb-queue.is-more .cb-queue__front { animation: cb-pop 380ms ease-out; }
}
@keyframes cb-q-arrive { from { opacity: 0; transform: translateY(calc(var(--u) * 0.8)) scale(0.85); } 55% { opacity: 1; transform: scale(1.12); } }
@keyframes cb-q-glow { 50% { filter: drop-shadow(0 0 calc(var(--u) * 0.7) var(--lamp)); transform: scale(1.06); } }
.cb-xp { grid-area: 2 / 2; position: relative; height: calc(var(--u) * 0.56); border-radius: var(--r-tube); background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--hair-strong), 0 0 0 2px var(--shadow-ink-soft); overflow: hidden; }
.cb-xp__fill { position: absolute; inset: 1.5px; border-radius: var(--r-tube); transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--brass), var(--honey) 80%, var(--white-hot)); transition: transform 160ms linear; }
.cb-xp__fill.is-wrap { transition: none; }
.cb-xp__flash { position: absolute; inset: 0; border-radius: var(--r-tube); background: var(--white-hot); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .cb-xp.is-flash .cb-xp__flash { animation: cb-flash-strong 700ms ease-out; }
  .cb-lv.is-flash { animation: cb-pop 420ms ease-out; }
}
@keyframes cb-flash-strong { 0% { opacity: 0; } 15% { opacity: 0.95; } 100% { opacity: 0; } }
.cb-vital__bulb { width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); --c-line: var(--honey); --c-glow: var(--lamp); }
.cb-vital.is-low .cb-vital__bulb { --c-line: var(--text-2); --c-glow: var(--lamp-deep); }
.cb-hp { position: relative; height: calc(var(--u) * 0.95); border-radius: var(--r-tube); background: var(--glass);
  box-shadow: inset 0 0 0 1.5px var(--hair-strong), 0 0 0 2px var(--shadow-ink-soft); overflow: hidden; }
.cb-hp__lag, .cb-hp__fill { position: absolute; inset: 2px; border-radius: var(--r-tube); transform-origin: 0 50%; }
.cb-hp__lag { background: var(--white-hot); transition: transform 500ms ease-in 380ms; }
.cb-hp__fill { background: linear-gradient(180deg, var(--white-hot), var(--honey) 35%, var(--lamp) 70%, var(--lamp-deep)); transition: transform 90ms linear; }
.cb-vital.is-low .cb-hp__fill { background: linear-gradient(180deg, var(--lamp), var(--lamp-deep) 55%, var(--ember-cold)); }
.cb-hp__n { grid-area: 1 / 3; font-size: var(--s0); color: var(--text-2); white-space: nowrap; }
.cb-hp__n b { color: var(--text); font-weight: 800; }
.cb-vital.is-low .cb-hp__n b { color: var(--lamp); }
.cb-dash { position: relative; width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); }
.cb-dash svg { width: 100%; height: 100%; overflow: visible; transform: rotate(-90deg); }
.cb-dash__track { fill: none; stroke: var(--glass); stroke-width: 6; }
.cb-dash__edge { fill: none; stroke: var(--hair-strong); stroke-width: 1.2; }
.cb-dash__fill { fill: none; stroke: var(--brass); stroke-width: 3.6; stroke-linecap: round; }
.cb-dash__core { fill: var(--glass); }
.cb-dash.is-ready .cb-dash__fill { stroke: var(--lamp); }
.cb-dash.is-ready .cb-dash__core { fill: var(--lamp-deep); }
.cb-dash__key { position: absolute; left: 50%; top: calc(100% + var(--g1)); transform: translateX(-50%); font-size: var(--s-1); color: var(--text-3); white-space: nowrap; }
.cb-dash.is-ready .cb-dash__key { color: var(--honey); }
@media (prefers-reduced-motion: no-preference) {
  .cb-vital.is-low .cb-vital__bulb, .cb-vital.is-low .cb-hp__fill { animation: cb-flicker 1.9s steps(1, end) infinite; }
  .cb-dash.is-flash { animation: cb-pop 260ms ease-out; }
}
@keyframes cb-flicker { 0%, 100% { opacity: 1; } 47% { opacity: 0.45; } 50% { opacity: 1; } 53% { opacity: 0.6; } 56% { opacity: 1; } }
@keyframes cb-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* boss: under the night arc */
.cb-boss { left: 50%; top: calc(var(--u) * 7.3); transform: translateX(-50%); width: calc(var(--u) * 28); text-align: center; display: none; }
.cb-boss.is-on { display: block; }
.cb-boss__name { font-family: 'CB Fell'; font-style: italic; font-size: var(--s1); color: var(--gloom-pale); line-height: 1.1; margin-bottom: var(--g1); }
.cb-boss__bar { position: relative; height: calc(var(--u) * 0.6); margin: 0 calc(var(--u) * 1.2); border-radius: var(--r-tube);
  background: var(--plum); box-shadow: inset 0 0 0 1.5px var(--gloom-deep), 0 0 0 2px var(--shadow-ink-soft); overflow: hidden; }
.cb-boss__fill { position: absolute; inset: 2px; border-radius: var(--r-tube); transform-origin: 0 50%;
  background: linear-gradient(180deg, var(--gloom-pale), var(--gloom) 45%, var(--gloom-deep)); transition: transform 120ms linear; }
.cb-boss__wing { position: absolute; top: 50%; width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); margin-top: calc(var(--u) * -0.8); --c-line: var(--gloom-pale); --c-glow: var(--gloom); }
.cb-boss__wing--l { left: calc(var(--u) * -0.6); }
.cb-boss__wing--r { right: calc(var(--u) * -0.6); }

/* toasts */
.cb-toasts { left: 50%; top: calc(var(--u) * 10.4); transform: translateX(-50%); width: min(90vw, calc(var(--u) * 40));
  display: flex; flex-direction: column; align-items: center; gap: var(--g2); }
.cb-toast { font-family: 'CB Fell'; font-style: italic; font-size: var(--s1); line-height: 1.2; text-align: center; color: var(--honey);
  text-wrap: balance; text-shadow: 0 1px 2px var(--shadow-ink), 0 0 calc(var(--u) * 0.8) var(--shadow-ink), 0 0 calc(var(--u) * 1.6) var(--shadow-ink-soft);
  transition: opacity 400ms ease, transform 400ms ease; display: flex; align-items: center; gap: var(--g2); }
.cb-toast--warning { color: var(--gloom-pale); }
.cb-toast--elite { color: var(--gloom-pale); }
/* info: a practical instruction (mouse not captured). Upright text on a soft ink shade so it reads over any scene */
.cb-toast--info { font-family: 'CB Alegreya'; font-style: normal; font-size: var(--s0); color: var(--text); max-width: calc(var(--u) * 34);
  padding: var(--g2) var(--g4); background: radial-gradient(ellipse 60% 70% at 50% 50%, var(--veil) 0%, var(--veil-soft) 60%, var(--veil-clear) 100%); }
.cb-toast__ic { flex: none; width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); --c-line: var(--gloom-pale); --c-glow: var(--gloom); }
.cb-toast--elite .cb-toast__ic, .cb-toast--chest .cb-toast__ic { --c-line: var(--honey); --c-glow: var(--lamp); }
/* chest: warm, a reward (violet is danger) */
.cb-toast--chest { color: var(--honey); }
/* while the boss bar is up the centre column is hers: toasts move to the right, under the kill count (playtest M3 #6) */
.cb-ui.has-boss .cb-toasts { left: auto; right: var(--edge); top: calc(var(--edge) + var(--u) * 4.6); transform: none; width: min(34vw, calc(var(--u) * 24)); align-items: flex-end; }
.cb-ui.has-boss .cb-toast { text-align: right; font-size: var(--s0); }
.cb-toast.is-in { opacity: 0; transform: translateY(calc(var(--u) * -0.6)); }
.cb-toast.is-out { opacity: 0; }

/* crosshair: four warm arcs; on an enemy they close in and heat */
.cb-cross { left: 0; top: 0; width: calc(var(--u) * 2.5); height: calc(var(--u) * 2.5); margin: calc(var(--u) * -1.25) 0 0 calc(var(--u) * -1.25); display: none; will-change: transform; }
.cb-cross.is-on { display: block; }
.cb-cross svg { width: 100%; height: 100%; overflow: visible; transition: transform 90ms ease-out; }
.cb-cross__under { fill: none; stroke: var(--ink); stroke-width: 5.6; stroke-linecap: round; opacity: 0.7; }
.cb-cross__arc { fill: none; stroke: var(--honey); stroke-width: 2.6; stroke-linecap: round; transition: stroke 90ms; }
.cb-cross__dot { fill: var(--honey); stroke: var(--ink); stroke-width: 1; }
.cb-cross.is-enemy svg { transform: scale(0.78) rotate(45deg); }
.cb-cross.is-enemy .cb-cross__arc { stroke: var(--white-hot); stroke-width: 3.2; }
.cb-cross.is-enemy .cb-cross__dot { fill: var(--lamp); }

/* ------------------------------------------------------------------ screens (menus) */
.cb-screen { position: absolute; inset: 0; display: flex; color: var(--text); }
.cb-veil { position: absolute; inset: 0; background: var(--veil); }
.cb-levelup .cb-veil, .cb-chest .cb-veil { background: radial-gradient(ellipse 62% 58% at 50% 54%, var(--veil) 0%, var(--veil-mid) 70%, var(--veil-soft) 100%); }
.cb-veil--left { background: linear-gradient(90deg, var(--veil) 0%, var(--veil) 32%, var(--veil-soft) 62%, var(--veil-clear) 100%); }
.cb-veil--pause { background: linear-gradient(90deg, var(--veil-soft) 0%, var(--veil) 14%, var(--veil-mid) 50%, var(--veil) 86%, var(--veil-soft) 100%); }
/* victory: shade only behind the text column and let the sunrise and the hero (screen centre) stay clear */
.cb-veil--dawn { background: linear-gradient(90deg, var(--veil) 0%, var(--veil) 30%, var(--veil-mid) 40%, var(--veil-soft) 46%, var(--veil-clear) 56%); }
.cb-veil--defeat { background: linear-gradient(0deg, var(--gloom-pool), var(--gloom-pool-clear) 45%), linear-gradient(90deg, var(--veil-deep) 0%, var(--veil) 45%, var(--veil-soft) 75%, var(--veil-clear)); }
.cb-screen__body { position: relative; }

/* menu items: lit words, a small bulb marks the one under the lamp */
.cb-menu { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--g1); justify-items: start; }
.cb-item { position: relative; display: inline-flex; align-items: baseline; gap: var(--g3); min-height: calc(var(--u) * 2.9);
  padding: var(--g1) var(--g2) var(--g1) calc(var(--u) * 2.2); margin-left: calc(var(--u) * -2.2);
  font-family: 'CB Fell'; font-size: var(--s4); line-height: 1.1; color: var(--text-2); text-shadow: 0 1px 2px var(--shadow-ink); }
.cb-item__mark { position: absolute; left: calc(var(--u) * 0.2); top: 50%; width: calc(var(--u) * 1.5); height: calc(var(--u) * 1.5);
  margin-top: calc(var(--u) * -0.82); opacity: 0; transform: translateX(calc(var(--u) * -0.4)); transition: opacity 120ms, transform 120ms;
  --c-line: var(--honey); --c-glow: var(--lamp); }
.cb-item__hint { font-family: 'CB Sans'; font-weight: 500; font-size: var(--s0); color: var(--text-3); letter-spacing: 0.02em; }
/* on the title the Enter hint follows the focused item, so the hint and what Enter does always agree */
.cb-title__menu .cb-item:not(:focus) .cb-item__hint { visibility: hidden; }
.cb-item:hover, .cb-item:focus-visible, .cb-item.is-sel { color: var(--text); outline: none; }
.cb-item:hover .cb-item__mark, .cb-item:focus-visible .cb-item__mark, .cb-item.is-sel .cb-item__mark { opacity: 1; transform: none; }
.cb-item::after { content: ''; position: absolute; left: calc(var(--u) * 2.2); right: var(--g2); bottom: calc(var(--u) * 0.15); height: 2px;
  background: linear-gradient(90deg, var(--lamp), var(--lamp-pool-clear)); transform: scaleX(0); transform-origin: 0 50%; transition: transform 160ms ease-out; }
.cb-item:hover::after, .cb-item:focus-visible::after, .cb-item.is-sel::after { transform: scaleX(1); }
.cb-item--small { font-size: var(--s3); min-height: calc(var(--u) * 2.4); }
.cb-item--armed { color: var(--gloom-pale) !important; white-space: nowrap; }
.cb-item--armed::after { background: linear-gradient(90deg, var(--gloom), var(--gloom-pool-clear)); }
.cb-item--armed .cb-item__mark { --c-line: var(--gloom-pale); --c-glow: var(--gloom); }
.cb-armed-note { font-style: italic; font-size: var(--s0); color: var(--gloom-pale); margin: calc(var(--g1) * -1) 0 0 0; }

/* batched level-ups: one filament bead per queued pick, the current one lit */
.cb-batch { display: flex; justify-content: center; gap: calc(var(--u) * 0.7); margin: calc(var(--u) * 0.6) 0 0; }
/* the batch's progress: a row of tiny upright cards (a hand being played), distinct from the cards' round rank pips */
.cb-batch { align-items: end; }
.cb-batch i { width: calc(var(--u) * 0.7); height: calc(var(--u) * 1); border-radius: 1.5px; box-shadow: inset 0 0 0 1.5px var(--text-3); transform: rotate(-6deg); }
.cb-batch i:nth-child(even) { transform: rotate(5deg); }
.cb-batch i.is-done { background: var(--brass-dim); box-shadow: inset 0 0 0 1.5px var(--brass); }
.cb-batch i.is-now { width: calc(var(--u) * 0.86); height: calc(var(--u) * 1.22); background: var(--paper-lit); box-shadow: inset 0 0 0 1.5px var(--white-hot), 0 0 calc(var(--u) * 0.8) var(--lamp); transform: none; }
.cb-lede { font-family: 'CB Fell'; font-style: italic; font-size: var(--s2); color: var(--text-2); line-height: 1.25; margin: 0; text-wrap: balance; }
.cb-h { font-family: 'CB Fell'; font-weight: 400; font-size: var(--s5); line-height: 1; margin: 0; color: var(--text); text-wrap: balance;
  text-shadow: 0 2px 4px var(--shadow-ink); }

/* ---------- loading ---------- */
.cb-loading { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse 60% 60% at 50% 46%, var(--night-2), var(--night-0) 75%); pointer-events: auto; transition: opacity 500ms ease; }
.cb-loading.is-gone { opacity: 0; pointer-events: none; }
.cb-loading__inner { display: grid; justify-items: center; gap: var(--g3); }
.cb-loading__bulb { width: calc(var(--u) * 9); height: calc(var(--u) * 10.8); overflow: visible; }
.cb-loading__glass { fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-loading__cap { fill: none; stroke: var(--brass); stroke-width: 2.2; stroke-linecap: round; }
.cb-loading__fil-base { fill: none; stroke: var(--ember-cold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
.cb-loading__fil { fill: none; stroke: var(--fil, var(--lamp)); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cb-loading__pool { fill: var(--lamp); }
.cb-loading__word { font-family: 'CB Fell'; font-size: var(--s4); color: var(--honey); line-height: 1; }
.cb-loading__label { font-family: 'CB Fell'; font-style: italic; font-size: var(--s1); color: var(--text-2); min-height: 1.4em; }
.cb-loading__pct { font-size: var(--s-1); color: var(--text-3); }

/* ---------- logotype ---------- */
.cb-logo { margin: 0; position: relative; display: inline-block; font-family: 'CB Fell'; font-weight: 400; font-size: calc(var(--u) * 7.4); line-height: 0.9;
  color: var(--honey); letter-spacing: -0.01em; text-shadow: 0 3px 6px var(--shadow-ink); }
.cb-logo__i { position: relative; display: inline-block; }
.cb-logo__dot { position: absolute; left: 50%; top: -0.08em; width: 0.44em; height: 0.44em; transform: translateX(-50%) rotate(8deg);
  --c-line: var(--honey); --c-glow: var(--lamp); }
.cb-logo__dot::before { content: ''; position: absolute; inset: -60%; border-radius: 50%;
  background: radial-gradient(circle, var(--lamp-pool) 0%, var(--lamp-pool-clear) 65%); }
.cb-logo__flourish { display: block; width: 100%; height: auto; margin-top: -0.02em; overflow: visible; }
.cb-logo__flourish path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cb-logo__flourish .u { stroke: var(--ink); stroke-width: 6; opacity: 0.6; }
.cb-logo__flourish .w { stroke: var(--lamp); stroke-width: 2.6; }
.cb-logo__flourish .s { fill: var(--white-hot); stroke: var(--lamp); stroke-width: 1; }

/* ---------- title ---------- */
.cb-title { padding: calc(var(--u) * 5) 0 var(--g5) calc(var(--u) * 6); flex-direction: column; }
.cb-title__head { position: relative; }
.cb-title.is-settings .cb-title__tag, .cb-title.is-settings .cb-title__foot { display: none; }
.cb-title.is-settings .cb-logo { font-size: calc(var(--u) * 4.4); }
.cb-title.is-settings .cb-title__main { margin: var(--g4) 0 0; }
.cb-title__tag { margin-top: var(--g3); max-width: 24em; }
.cb-title__main { margin: auto 0; padding-bottom: var(--g4); }
.cb-title__menu { margin-top: 0; }
.cb-title__best { margin-top: var(--g5); display: grid; gap: var(--g1); }
.cb-title__best-label { font-family: 'CB Fell'; font-style: italic; color: var(--text-2); font-size: var(--s1); }
.cb-title__best-line { display: flex; gap: var(--g4); align-items: baseline; }
.cb-stat { display: grid; gap: 0; }
.cb-stat__v { font-size: var(--s3); line-height: 1; color: var(--text); }
.cb-stat__k { font-size: var(--s-1); color: var(--text-3); }
.cb-title__first { font-family: 'CB Fell'; font-style: italic; color: var(--text-2); font-size: var(--s1); }
.cb-title__foot { margin-top: 0; }
.cb-keys { display: flex; flex-wrap: wrap; gap: var(--g2) var(--g4); align-items: baseline; color: var(--text-2); font-size: var(--s0); margin: 0; padding: 0; list-style: none; }
.cb-keys li { display: inline-flex; gap: var(--g2); align-items: baseline; }
.cb-kbd { font-family: 'CB Sans'; font-weight: 800; font-size: var(--s0); color: var(--honey); letter-spacing: 0.04em; }

/* ---------- settings (used by title and pause) ---------- */
.cb-settings { display: grid; gap: var(--g4); width: calc(var(--u) * 30); }
.cb-settings__group { border: 0; margin: 0; padding: 0; min-width: 0; }
.cb-settings__group legend { padding: 0; font-family: 'CB Fell'; font-style: italic; font-size: var(--s2); color: var(--honey); margin-bottom: var(--g2); }
.cb-row { display: grid; grid-template-columns: 1fr calc(var(--u) * 13) calc(var(--u) * 3.6); align-items: center; column-gap: var(--g3);
  min-height: calc(var(--u) * 2.6); border-top: 1px solid var(--hair); }
.cb-row:last-child { border-bottom: 1px solid var(--hair); }
.cb-row__label { color: var(--text); font-size: var(--s1); }
.cb-row__val { font-size: var(--s0); color: var(--text-2); text-align: right; font-family: 'CB Sans'; font-weight: 500; font-variant-numeric: tabular-nums; }
.cb-row--wide .cb-row__ctl { grid-column: 2 / 4; }

.cb-range { -webkit-appearance: none; appearance: none; width: 100%; height: calc(var(--u) * 1.6); background: transparent; margin: 0; cursor: pointer; --v: 50%; }
.cb-range::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-tube);
  background: linear-gradient(90deg, var(--honey) 0, var(--honey) var(--v), var(--hair-strong) var(--v)); }
.cb-range::-webkit-slider-thumb { -webkit-appearance: none; width: calc(var(--u) * 1.05); height: calc(var(--u) * 1.05); margin-top: calc(var(--u) * -0.525 + 2px);
  border-radius: 50%; background: radial-gradient(circle at 38% 34%, var(--white-hot), var(--honey) 40%, var(--brass) 100%); box-shadow: 0 0 0 2px var(--ink); }
.cb-range::-moz-range-track { height: 4px; border-radius: var(--r-tube); background: var(--hair-strong); }
.cb-range::-moz-range-progress { height: 4px; border-radius: var(--r-tube); background: var(--honey); }
.cb-range::-moz-range-thumb { width: calc(var(--u) * 1.05); height: calc(var(--u) * 1.05); border: 0; border-radius: 50%; background: var(--honey); box-shadow: 0 0 0 2px var(--ink); }
.cb-range:focus-visible { outline: none; }
.cb-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4.5px var(--lamp); }
.cb-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4.5px var(--lamp); }

.cb-choice { display: flex; gap: var(--g4); border: 0; margin: 0; padding: 0; }
.cb-choice label { position: relative; cursor: pointer; color: var(--text-3); font-size: var(--s1); padding: var(--g1) 0; }
.cb-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cb-choice label:hover { color: var(--text-2); }
.cb-choice input:checked + span { color: var(--text); }
.cb-choice input:checked + span::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--lamp); border-radius: 1px; }
.cb-choice input:focus-visible + span { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 2px; }

.cb-toggle { display: inline-flex; align-items: center; gap: var(--g2); cursor: pointer; color: var(--text-3); font-size: var(--s1); }
.cb-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cb-toggle__bulb { width: calc(var(--u) * 1.5); height: calc(var(--u) * 1.5); --c-line: var(--text-3); --c-glow: var(--glass); }
.cb-toggle input:checked ~ .cb-toggle__bulb { --c-line: var(--honey); --c-glow: var(--lamp); }
.cb-toggle input:checked ~ .cb-toggle__word { color: var(--text); }
.cb-toggle input:focus-visible ~ .cb-toggle__word { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 2px; }

.cb-settings__back { margin-top: var(--g2); }
/* on the title the form sits beside the logo's column: two columns (sound and controls | picture), so it fits 720p */
.cb-title .cb-title__settings { width: calc(var(--u) * 64); grid-template-columns: 1fr 1fr; column-gap: var(--g6); align-items: start; }
.cb-title .cb-title__settings .cb-settings__group:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }

/* ---------- pause ---------- */
.cb-pause { align-items: center; justify-content: center; gap: calc(var(--u) * 6); }
.cb-pause__left { display: grid; gap: var(--g3); align-content: start; width: calc(var(--u) * 25); align-self: center; }
.cb-pause__menu { margin-top: var(--g2); }
.cb-pause__build { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--g4); border-top: 1px solid var(--hair); padding-top: var(--g3); margin-top: var(--g2); }
.cb-pause__build .cb-sum__item { grid-template-columns: calc(var(--u) * 1.6) 1fr auto; min-height: calc(var(--u) * 1.8); }
.cb-pause__build .cb-mini { width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); }
.cb-pause__build .cb-sum__name { font-size: var(--s0); }
.cb-pause__build h3 { margin: 0 0 var(--g1); font-family: 'CB Fell'; font-style: italic; font-weight: 400; font-size: var(--s1); color: var(--text-2); }
/* pause lists the build itself (and at 720p, with the map legend, its heading reaches the HUD's build icons) */
.cb-ui:has(.cb-pause) .cb-build { visibility: hidden; }
.cb-legend { border-top: 1px solid var(--hair); padding-top: var(--g3); }
.cb-legend h3 { margin: 0 0 var(--g1); font-family: 'CB Fell'; font-style: italic; font-weight: 400; font-size: var(--s1); color: var(--text-2); }
.cb-legend__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--g4); row-gap: calc(var(--u) * 0.2); }
.cb-legend__row { display: flex; align-items: center; gap: var(--g2); font-size: var(--s-1); color: var(--text-3); line-height: 1.2; min-height: calc(var(--u) * 1.7); }
.cb-legend__row b { font-weight: 500; color: var(--text-2); }
.cb-legend__ic { width: calc(var(--u) * 1.5); height: calc(var(--u) * 1.5); flex: none; }
.cb-legend__ic .cb-icon__ink { stroke-width: 2.6; }
.cb-legend__ic .cb-icon__under { stroke-width: 6; --ic-fw: 6; }
/* the colours each icon has on the minimap (minimap.js buildIcons) */
.cb-legend--glowjar .cb-icon { --k-line: var(--text); --k-glow: var(--honey); }
.cb-legend--mothtrap .cb-icon { --k-line: var(--gloom-pale); --k-glow: var(--honey); }
.cb-legend--eyes .cb-icon { --k-line: var(--gloom-pale); --k-glow: var(--gloom); }
.cb-pause__right { align-self: center; padding-left: calc(var(--u) * 5); border-left: 1px solid var(--hair); }

/* ---------- level-up and chest: the cards ---------- */
.cb-pick { flex-direction: column; align-items: center; justify-content: center; gap: var(--g5); padding: var(--g5) var(--g4); }
.cb-pick__head { text-align: center; display: grid; gap: var(--g2); justify-items: center; }
.cb-pick__orn { width: calc(var(--u) * 16); height: calc(var(--u) * 1.4); overflow: visible; }
.cb-pick__orn path { fill: none; stroke: var(--brass); stroke-width: 1.4; stroke-linecap: round; }
.cb-pick__orn .f { fill: var(--lamp); stroke: none; }
.cb-cards { list-style: none; margin: 0; padding: calc(var(--u) * 3.3) 0 0; display: flex; gap: var(--g4); align-items: stretch; justify-content: center; }
.cb-cards > li { display: flex; }
/* A card is a torn leaf of night paper with one inked rule inside its edge, and its icon in a coin that sits on
   the top edge and breaks the rule. The paper is the ::before (filter #cb-deckle in icons.js tears its edge, wobbles
   the rule and lays the grain); the card itself has no fill, so its text stays sharp.
   Per-card material: --face (paper), --edge (the torn edge), --rule (the inked line), --ring (the coin), --sheen. */
.cb-card { --lit: 0; --pool: 0;
  --face: var(--paper); --edge: var(--hair); --rule: var(--brass-dim); --ring: var(--brass); --sheen: var(--lamp-pool-clear);
  position: relative; isolation: isolate; display: flex; flex-direction: column; align-items: center; text-align: center;
  width: calc(var(--u) * 15.5); min-height: calc(var(--u) * 18.5); padding: calc(var(--u) * 4.5) var(--g4) var(--g4);
  border-radius: var(--r-card); background: none; color: var(--text);
  transition: transform 160ms ease-out; }
.cb-card::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(ellipse 90% 100% at 50% 0%, var(--lamp-pool), var(--lamp-pool-clear) 100%) no-repeat,
    linear-gradient(165deg, var(--sheen), var(--lamp-pool-clear) 55%),
    var(--face);
  background-size: 100% calc(var(--u) * (var(--pool) * 9 + var(--lit) * 6)), 100% 100%, 100% 100%;
  box-shadow: inset 0 0 0 1px var(--edge);
  outline: 2px solid var(--rule); outline-offset: calc(var(--u) * -0.62);
  filter: url(#cb-deckle);
  transition: background-size 200ms, outline-color 160ms; }
.cb-deckle__shadow { flood-color: var(--shadow-ink); flood-opacity: 0.85; }
.cb-card__key { position: absolute; left: 50%; bottom: calc(var(--u) * -0.95); transform: translateX(-50%); width: calc(var(--u) * 1.9); height: calc(var(--u) * 1.9);
  display: grid; place-items: center; border-radius: 50%; background: var(--night-1); box-shadow: inset 0 0 0 1px var(--rule);
  font-size: var(--s0); color: var(--text-2); line-height: 1; }
/* the coin: centred on the top edge, a ring of the tier's metal, a gap of night, then the rule's colour */
.cb-card__icon { position: absolute; left: 50%; top: 0; transform: translate(-50%, -52%);
  width: calc(var(--u) * 6.4); height: calc(var(--u) * 6.4); padding: calc(var(--u) * 0.9); box-sizing: border-box; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--paper-lit), var(--night-1) 72%);
  box-shadow: inset 0 0 0 1.5px var(--ring), 0 0 0 calc(var(--u) * 0.32) var(--night-1), 0 0 0 calc(var(--u) * 0.32 + 1px) var(--rule),
    0 calc(var(--u) * 0.4) calc(var(--u) * 1.1) var(--shadow-ink);
  transition: box-shadow 160ms; }
.cb-card__kind { font-family: 'CB Fell'; font-style: italic; font-size: var(--s0); color: var(--text-2); }
.cb-card__name { font-family: 'CB Fell'; font-size: var(--s3); line-height: 1.02; margin: var(--g1) 0 var(--g3); text-wrap: balance; color: var(--text); }
.cb-card__pips { display: flex; gap: calc(var(--u) * 0.32); margin-bottom: var(--g3); }
.cb-pip { width: calc(var(--u) * 0.55); height: calc(var(--u) * 0.55); border-radius: 50%; box-shadow: inset 0 0 0 1.3px var(--hair-strong); }
.cb-pip.is-on { background: var(--honey); box-shadow: none; }
.cb-pip.is-new { background: var(--white-hot); box-shadow: 0 0 0 2px var(--lamp); }
.cb-card__text { font-size: var(--s1); line-height: 1.38; color: var(--text-2); text-wrap: pretty; max-width: 100%; }
.cb-card__recipe { margin-top: auto; padding-top: var(--g3); display: grid; justify-items: start; gap: var(--g1); font-size: var(--s0); color: var(--text-2); border-top: 1px solid var(--brass-dim); width: 100%; }
.cb-card__recipe-row { display: flex; align-items: center; gap: var(--g2); }
.cb-card__recipe .cb-mini { width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); flex: none; }

/* new: no pips yet, a sprig of light over the name */
.cb-card.is-new { --pool: 1; }
.cb-card.is-new .cb-card__kind { color: var(--honey); }
/* special: a moonlit card */
.cb-card--special { --face: var(--night-2); --edge: var(--hair-strong); --rule: var(--hair-strong); --ring: var(--text-3); }
/* evolution: an arched window lit from inside, the coin set in the arch like a keystone */
.cb-card--evolution { border-radius: 50% 50% var(--r-card) var(--r-card) / calc(var(--u) * 5.4) calc(var(--u) * 5.4) var(--r-card) var(--r-card);
  --face: linear-gradient(180deg, var(--evo-face-hi), var(--evo-face) 46%); --edge: var(--dawn); --rule: var(--honey); --ring: var(--white-hot);
  --sheen: var(--gilt-pool); --pool: 1.8;
  padding-top: calc(var(--u) * 5); }
/* gilt in every chest and on the level-up screen alike: an evolution always outranks the cards beside it */
.cb-card--evolution::before { outline-width: 2.5px; box-shadow: inset 0 0 0 1.5px var(--edge), 0 0 calc(var(--u) * 2.2) var(--lamp-pool); }
.cb-card--evolution .cb-card__kind { color: var(--honey); letter-spacing: 0.04em; }
.cb-card--evolution .cb-card__name { color: var(--dawn); font-size: calc(var(--u) * 1.75); text-shadow: 0 0 calc(var(--u) * 1.1) var(--lamp-pool), 0 1px 2px var(--shadow-ink); }
.cb-card--evolution .cb-card__text { color: var(--text); }
.cb-card--evolution .cb-card__recipe { border-top-color: var(--brass); color: var(--honey); }
.cb-card--evolution .cb-card__icon { width: calc(var(--u) * 7.2); height: calc(var(--u) * 7.2);
  background: radial-gradient(circle at 50% 38%, var(--evo-face-hi), var(--night-1) 74%);
  box-shadow: inset 0 0 0 2px var(--ring), 0 0 0 calc(var(--u) * 0.32) var(--night-1), 0 0 0 calc(var(--u) * 0.32 + 1.5px) var(--dawn),
    0 0 calc(var(--u) * 2) var(--lamp-pool), 0 calc(var(--u) * 0.4) calc(var(--u) * 1.1) var(--shadow-ink); }
/* the keystone throws fine rays of dawn into the arch, behind the coin, fading out before the name */
.cb-card--evolution .cb-card__icon::before { content: ''; position: absolute; inset: -62%; z-index: -1; pointer-events: none;
  background: repeating-conic-gradient(from 3deg, var(--evo-ray) 0deg 1.6deg, var(--evo-ray-clear) 1.6deg 12deg);
  -webkit-mask: radial-gradient(circle closest-side, transparent 47%, var(--mask) 52%, transparent 100%);
  mask: radial-gradient(circle closest-side, transparent 47%, var(--mask) 52%, transparent 100%); }

/* hover / keyboard selection: the card is lit, the rule and the coin take the lamp's colour */
.cb-card.is-sel, .cb-card:hover, .cb-card:focus-visible { --lit: 1; --rule: var(--lamp); --ring: var(--lamp); outline: none;
  transform: translateY(calc(var(--u) * -0.7)); }
.cb-card--evolution.is-sel, .cb-card--evolution:hover, .cb-card--evolution:focus-visible { --edge: var(--lamp); --rule: var(--honey); --ring: var(--white-hot); }
/* the chosen-to-be card throws warm light on the ground under it */
.cb-cards > li { position: relative; }
.cb-cards > li::after { content: ''; position: absolute; left: 8%; right: 8%; bottom: calc(var(--u) * -2.4); height: calc(var(--u) * 2.2); pointer-events: none;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--lamp-pool), var(--lamp-pool-clear)); opacity: 0; transition: opacity 160ms; }
.cb-cards > li:has(.cb-card.is-sel)::after, .cb-cards > li:has(.cb-card:hover)::after { opacity: 1; }
.cb-card.is-sel .cb-card__key, .cb-card:hover .cb-card__key, .cb-card:focus-visible .cb-card__key { background: var(--lamp); color: var(--ink); box-shadow: none; }
.cb-cards.has-sel .cb-card:not(.is-sel):not(:hover) { filter: brightness(0.72); }
.cb-card.is-picked { transform: translateY(calc(var(--u) * -0.6)) scale(1.04); }
.cb-card.is-picked::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--lamp); opacity: 0; pointer-events: none; }
.cb-cards.is-done .cb-card:not(.is-picked) { opacity: 0; transform: translateY(calc(var(--u) * 1.2)); transition: opacity 260ms, transform 260ms; }
@media (prefers-reduced-motion: no-preference) {
  .cb-card.is-picked::after { animation: cb-flash 380ms ease-out; }
  .cb-pick.is-enter .cb-cards > li { animation: cb-deal 300ms cubic-bezier(.2,.8,.3,1) backwards; }
  .cb-pick.is-enter .cb-cards > li:nth-child(2) { animation-delay: 50ms; }
  .cb-pick.is-enter .cb-cards > li:nth-child(3) { animation-delay: 100ms; }
  .cb-pick.is-enter .cb-cards > li:nth-child(4) { animation-delay: 150ms; }
}
@keyframes cb-flash { 0% { opacity: 0; } 25% { opacity: 0.55; } 100% { opacity: 0; } }
@keyframes cb-deal { from { opacity: 0; transform: translateY(calc(var(--u) * 1.5)); } }
/* the entry guard (screens.js PICK_GUARD_MS): until the deal ends the key badges and the hint are unlit; then they
   light with one soft pulse. A key pressed too early blinks its badge (.is-early). */
.cb-levelup .cb-card__key, .cb-levelup .cb-pick__foot { transition: opacity 180ms ease-out; }
.cb-levelup:not(.is-armed) .cb-card__key { opacity: 0.28; }
.cb-levelup:not(.is-armed) .cb-pick__foot { opacity: 0.3; }
@media (prefers-reduced-motion: no-preference) {
  .cb-levelup.is-armed .cb-card__key { animation: cb-arm 520ms ease-out; }
  .cb-card__key.is-early { animation: cb-early 300ms ease-out; }
}
@keyframes cb-arm { 0% { box-shadow: inset 0 0 0 1px var(--rule), 0 0 0 0 var(--lamp-pool); } 40% { box-shadow: inset 0 0 0 1px var(--lamp), 0 0 0 calc(var(--u) * 0.5) var(--lamp-pool); } }
@keyframes cb-early { 0%, 100% { opacity: 0.28; } 35% { opacity: 1; background: var(--brass-dim); } }
.cb-pick__foot { display: flex; gap: var(--g5); align-items: baseline; color: var(--text-3); font-size: var(--s0); }
.cb-pick__foot .cb-kbd { margin-right: var(--g1); }
.cb-reroll { color: var(--text-2); font-size: var(--s0); }
.cb-reroll:hover, .cb-reroll:focus-visible { color: var(--text); }

/* chest: the cards are shown, not chosen */
.cb-chest .cb-cards > li.is-landed .cb-card { cursor: pointer; } /* a click on a gift takes them all */
.cb-chest .cb-card__key { display: none; }
.cb-chest__lid { width: calc(var(--u) * 4); height: calc(var(--u) * 4); --c-line: var(--honey); --c-glow: var(--lamp); }
/* the tier: the lid, the heading and a pool of its light behind the cards */
.cb-chest__pool { position: absolute; left: 50%; top: 50%; width: calc(var(--u) * 80); height: calc(var(--u) * 44); transform: translate(-50%, -52%); pointer-events: none;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--lamp-pool), var(--lamp-pool-clear)); }
.cb-chest--brass .cb-h { color: var(--honey); }
.cb-chest--tin .cb-chest__lid { --c-line: var(--tin); --c-glow: var(--tin-deep); }
.cb-chest--tin .cb-h { color: var(--tin); }
.cb-chest--tin .cb-chest__pool { background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--tin-pool), var(--tin-pool-clear)); }
/* the cards' materials: pewter, honey brass, gilt (evolutions keep their own dawn window) */
.cb-chest--tin .cb-card:not(.cb-card--evolution) { --face: var(--tin-face); --edge: var(--tin-deep); --rule: var(--tin-deep); --ring: var(--tin); --sheen: var(--tin-pool); }
.cb-chest--tin .cb-card:not(.cb-card--evolution) .cb-card__kind { color: var(--tin); }
.cb-chest--brass .cb-card:not(.cb-card--evolution) { --face: var(--brass-face); --edge: var(--brass-dim); --rule: var(--brass); --ring: var(--honey); --sheen: var(--lamp-pool); }
.cb-chest--gilt .cb-card:not(.cb-card--evolution) { --face: var(--gilt-face); --edge: var(--honey); --rule: var(--honey); --ring: var(--dawn); --sheen: var(--gilt-pool); --pool: 0.6; }
.cb-chest--gilt .cb-card:not(.cb-card--evolution)::before { outline-width: 2.5px; }
.cb-chest--gilt .cb-card:not(.cb-card--evolution) .cb-card__icon { box-shadow: inset 0 0 0 2px var(--ring), 0 0 0 calc(var(--u) * 0.32) var(--night-1),
  0 0 0 calc(var(--u) * 0.32 + 1.5px) var(--rule), 0 0 calc(var(--u) * 1.4) var(--lamp-pool), 0 calc(var(--u) * 0.4) calc(var(--u) * 1.1) var(--shadow-ink); }
.cb-chest--gilt .cb-chest__lid { --c-line: var(--dawn); --c-glow: var(--white-hot); width: calc(var(--u) * 4.8); height: calc(var(--u) * 4.8);
  filter: drop-shadow(0 0 calc(var(--u) * 0.9) var(--lamp)); }
.cb-chest--gilt .cb-h { color: var(--dawn); text-shadow: 0 0 calc(var(--u) * 1.4) var(--lamp-pool), 0 2px 4px var(--shadow-ink); }
.cb-chest--gilt .cb-chest__pool { width: calc(var(--u) * 96); height: calc(var(--u) * 56);
  background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--gilt-pool), var(--gilt-pool-clear)); }
/* cards land one by one (screens.js sets the classes) */
.cb-chest .cb-cards > li.is-waiting, .cb-chest .cb-pick__head.is-waiting { opacity: 0; }
/* Lucky Socket's stamp: an inked seal pressed on the corner of a card that exists only by luck */
.cb-stamp { position: absolute; z-index: 2; right: calc(var(--u) * -1.1); top: calc(var(--u) * -1.2); width: calc(var(--u) * 5.2); height: calc(var(--u) * 5.2);
  display: grid; place-content: center; justify-items: center; gap: calc(var(--u) * 0.1); border-radius: 50%; transform: rotate(-12deg);
  background: var(--night-1); color: var(--honey); text-align: center;
  box-shadow: 0 0 0 1.5px var(--honey), inset 0 0 0 3px var(--night-1), inset 0 0 0 4px var(--brass), 0 calc(var(--u) * 0.3) calc(var(--u) * 0.8) var(--shadow-ink); }
.cb-stamp__ic { width: calc(var(--u) * 1.9); height: calc(var(--u) * 1.9); }
.cb-stamp__t { font-family: 'CB Fell'; font-style: italic; font-size: var(--s-1); line-height: 0.95; }
@media (prefers-reduced-motion: no-preference) {
  .cb-chest .cb-cards > li.is-landed { animation: cb-land 460ms cubic-bezier(.2,.8,.3,1) both; }
  .cb-chest .cb-pick__head.is-landed { animation: cb-head-in 340ms ease-out both; }
  .cb-chest .cb-cards > li.is-landed .cb-stamp { animation: cb-stamp 380ms 240ms cubic-bezier(.3,1.6,.5,1) backwards; }
}
@keyframes cb-head-in { from { opacity: 0; transform: translateY(calc(var(--u) * 0.5)); } }
@keyframes cb-land { from { opacity: 0; transform: translateY(calc(var(--u) * -1.4)) scale(0.96); } }
@keyframes cb-stamp { from { opacity: 0; transform: rotate(-24deg) scale(1.9); } }

/* ---------- hero select: "Choose your light." The lit figure stands in the clear centre (gameplay draws it) ---------- */
.cb-heroes { flex-direction: column; justify-content: center; padding: calc(var(--u) * 4) 0 calc(var(--u) * 9) calc(var(--u) * 6); }
.cb-heroes__body { display: grid; gap: var(--g3); max-width: calc(var(--u) * 34); }
.cb-heroes__kick { margin: 0; font-family: 'CB Fell'; font-style: italic; font-size: var(--s2); color: var(--honey); }
.cb-heroes__card { display: grid; gap: var(--g3); }
.cb-heroes__card .cb-h { margin: 0; }
.cb-heroes__card .cb-lede { margin: 0; max-width: calc(var(--u) * 30); }
.cb-heroes__weapon { display: flex; align-items: center; gap: var(--g2); font-size: var(--s1); color: var(--text-2); }
.cb-heroes__weapon b { color: var(--text); font-weight: 600; }
.cb-heroes__weapon .cb-mini { width: calc(var(--u) * 2.2); height: calc(var(--u) * 2.2); flex: none; }
.cb-heroes__facts { display: flex; gap: var(--g5); }
.cb-heroes__fact { display: grid; gap: calc(var(--u) * 0.1); }
.cb-heroes__fact > span:first-child { font-family: 'CB Fell'; font-style: italic; font-size: var(--s0); color: var(--text-3); }
.cb-heroes__fact > span:last-child { font-size: var(--s2); color: var(--text); line-height: 1.05; }
.cb-heroes__best { margin: 0; font-family: 'CB Fell'; font-style: italic; font-size: var(--s0); color: var(--text-2); }
.cb-heroes__menu { margin-top: var(--g3); }
.cb-heroes__pick { position: absolute; left: 50%; bottom: calc(var(--u) * 5.5); transform: translateX(-50%); display: flex; align-items: center; gap: var(--g4); }
:where(.cb-ui) .cb-heroes__arrow { width: calc(var(--u) * 1.6); height: calc(var(--u) * 2.6); padding: 0; color: var(--text-3); cursor: pointer; }
.cb-heroes__arrow svg { width: 100%; height: 100%; overflow: visible; }
.cb-heroes__arrow path { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
/* a menu (level-up, chest, pause) needs the bottom of the screen at small sizes: the vitals step aside */
.cb-ui.has-menu .cb-vital { visibility: hidden; }
.cb-heroes__arrow:hover { color: var(--honey); }
:where(.cb-ui) .cb-heroes__name { position: relative; display: flex; align-items: center; gap: var(--g2); padding: var(--g2) var(--g3);
  font-family: 'CB Fell'; font-size: var(--s3); color: var(--text-3); text-shadow: 0 2px 6px var(--shadow-ink); transition: color 160ms; }
.cb-heroes__ic { width: calc(var(--u) * 2.4); height: calc(var(--u) * 2.4); opacity: 0.5; transition: opacity 160ms; }
.cb-heroes__name::after { content: ''; position: absolute; left: var(--g3); right: var(--g3); bottom: 0; height: 2px; background: var(--lamp);
  transform: scaleX(0); transform-origin: 0 50%; transition: transform 200ms ease-out; }
.cb-heroes__name.is-sel { color: var(--honey); }
.cb-heroes__name.is-sel .cb-heroes__ic { opacity: 1; }
.cb-heroes__name.is-sel::after { transform: scaleX(1); }
.cb-heroes__name:hover { color: var(--text); }
@media (prefers-reduced-motion: no-preference) {
  .cb-heroes__card.is-swap { animation: cb-swap 280ms ease-out; }
}
@keyframes cb-swap { from { opacity: 0; transform: translateX(calc(var(--u) * -0.8)); } }

/* ---------- game over / victory ---------- */
.cb-sum { padding: var(--g5) calc(var(--u) * 6); flex-direction: column; justify-content: center; }
.cb-sum__body { display: grid; gap: var(--g3); max-width: calc(var(--u) * 40); }
.cb-sum__arc { width: calc(var(--u) * 24); margin: var(--g2) 0 0 calc(var(--u) * 1.4); }
.cb-sum__arc svg { display: block; width: 100%; height: auto; overflow: visible; }
.cb-sum__stats { display: flex; gap: var(--g5); }
.cb-sum__stats .cb-stat__v { font-size: var(--s4); }
.cb-sum__stats .cb-stat__k { font-size: var(--s0); color: var(--text-2); font-family: 'CB Fell'; font-style: italic; }
.cb-sum__hero { display: flex; align-items: center; gap: var(--g2); font-family: 'CB Fell'; font-style: italic; font-size: var(--s1); color: var(--text-2); margin-bottom: calc(var(--u) * -0.6); }
.cb-sum__hero-ic { width: calc(var(--u) * 1.9); height: calc(var(--u) * 1.9); }
.cb-sum__best { font-family: 'CB Fell'; font-style: italic; font-size: var(--s1); color: var(--honey); }
.cb-sum__build { display: grid; grid-template-columns: repeat(2, calc(var(--u) * 15)); column-gap: var(--g5); border-top: 1px solid var(--hair); padding-top: var(--g3); }
.cb-sum__build h3 { grid-column: span 1; margin: 0 0 var(--g1); font-family: 'CB Fell'; font-style: italic; font-weight: 400; font-size: var(--s1); color: var(--text-2); }
.cb-sum__col { display: grid; gap: var(--g1); align-content: start; }
.cb-sum__item { display: grid; grid-template-columns: calc(var(--u) * 1.8) 1fr auto; align-items: center; column-gap: var(--g2); min-height: calc(var(--u) * 2); }
.cb-sum__item .cb-mini { width: calc(var(--u) * 1.8); height: calc(var(--u) * 1.8); }
.cb-sum__name { font-size: var(--s1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-sum__lv { font-size: var(--s0); color: var(--text-2); }
.cb-sum__lv.is-max { color: var(--lamp); }
.cb-sum__none { font-style: italic; color: var(--text-3); }
.cb-sum__menu { display: flex; gap: var(--g5); margin-top: var(--g2); padding-left: calc(var(--u) * 2.2); align-items: baseline; }
.cb-sum__menu .cb-item { white-space: nowrap; }
.cb-victory .cb-h { color: var(--dawn); font-size: calc(var(--u) * 5.6); }
.cb-defeat .cb-h { color: var(--text); }
