@font-face { font-family: 'KenneyPixel'; src: url('../assets/fonts/KenneyPixel.ttf'); }
@font-face { font-family: 'KenneyMini'; src: url('../assets/fonts/KenneyMiniSquare.ttf'); }
@font-face { font-family: 'KenneyBlocks'; src: url('../assets/fonts/KenneyBlocks.ttf'); }

/*
 * Every size in this file is in FRAME pixels. #frame is a fixed 1280x720
 * box that main.js scales as a unit to fit the window, so 16px here is 16px
 * on a 720p window, 24px at 1080p and 48px at 4K. Nothing below needs a
 * media query for window size; the only queries are for touch input.
 */

:root {
  /* Pixel fonts are for display only. Anything you actually have to READ uses
     a real UI font: bitmap faces are drawn for exact pixel sizes and turn to
     mush at the 12-14px that descriptions and tooltips need. */
  --ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --display: 'KenneyBlocks', var(--ui);

  --ink:      #0c0912;
  --felt:     #15101e;
  --panel:    #1d1729;
  --panel-2:  #261e36;
  --panel-3:  #332948;
  --edge:     #4a3e63;
  --edge-hi:  #6d5d8f;
  --bone:     #f2ece2;
  --dim:      #b1a7c6;
  --faint:    #74698e;

  --red:      #d23a4f;  --red-lo:    #7d1430;
  --orange:   #e8832a;  --orange-lo: #8a4210;
  --green:    #36a56a;  --green-lo:  #17573a;
  --blue:     #3d7fd6;  --blue-lo:   #1a3f76;
  --gold:     #f5c65c;  --gold-lo:   #8a6418;

  --chips:    #4aa3f5;
  --mult:     #f5574a;
  --xmult:    #c77df5;
  --good:     #6fdc98;
  --bad:      #ff6b7d;

  /* survival slots */
  --guard:    #8fa5c4;
  --swift:    #5fe0c8;
  --blood:    #e0556f;
  --hex:      #9a7ae8;
  --econ:     #f5c65c;
  --util:     #b8b0c8;

  --r-common:    #5a9ae0;
  --r-uncommon:  #4fbf7a;
  --r-rare:      #e0405a;
  --r-legendary: #b36ae8;

  --paper:     #efe6d2;
  --paper-ink: #2a2233;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ink);
  overflow: hidden;
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--bone);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
  touch-action: none;
}

/* Display type: chunky and spaced. Reserved for labels and titles you
   recognise by shape. Anything numeric stays in the UI font, because "567"
   and "1111" are genuinely hard to tell apart in a blocky face. */
.disp, .btn, h1, h2, h3 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 1px;
}
.num { font-variant-numeric: tabular-nums; font-weight: 800; }

.hidden { display: none !important; }

#stage {
  position: fixed; inset: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #171122 0%, #06040a 100%);
}

/* Positioned and scaled by fit(). */
#frame {
  position: absolute;
  left: 0; top: 0;
  width: 1280px; height: 720px;
  transform-origin: 0 0;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 2px #2a2238, 0 30px 90px rgba(0,0,0,.8);
}

#game {
  position: absolute; inset: 0;
  width: 1280px; height: 720px;
  display: block;
  image-rendering: pixelated;
}

/* Colours that relic text uses on dark backgrounds. */
.c-chips { color: var(--chips); font-weight: 700; }
.c-mult  { color: var(--mult);  font-weight: 700; }
.c-xmult { color: var(--xmult); font-weight: 700; }
.c-gold  { color: var(--gold);  font-weight: 700; }
.c-bad   { color: var(--bad);   font-weight: 700; }
.c-good  { color: var(--good);  font-weight: 700; }
/* ...and darker ones on paper. */
.paper .c-chips { color: #4a5364; }
.paper .c-mult  { color: #a4520f; }
.paper .c-xmult { color: #8a2fc4; }
.paper .c-gold  { color: #a06a00; }
.paper .c-bad   { color: #c4203a; }
.paper .c-good  { color: #17803e; }

.slot-chips  { --slot: var(--chips); }
.slot-mult   { --slot: var(--mult); }
.slot-xmult  { --slot: var(--xmult); }
.slot-guard  { --slot: var(--guard); }
.slot-swift  { --slot: var(--swift); }
.slot-blood  { --slot: var(--blood); }
.slot-hex    { --slot: var(--hex); }
.slot-econ   { --slot: var(--econ); }
.slot-util   { --slot: var(--util); }

canvas.px { image-rendering: pixelated; display: block; }

/* ================================ BUTTONS ================================ */

.btn {
  --b: var(--red); --b-lo: var(--red-lo);
  position: relative;
  font-size: 18px;
  line-height: 1;
  color: #fff;
  background: var(--b);
  border: 0;
  border-radius: 10px;
  padding: 13px 22px 11px;
  box-shadow: 0 5px 0 var(--b-lo), 0 9px 16px rgba(0,0,0,.45);
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform .06s, box-shadow .06s, filter .12s;
  white-space: nowrap;
}
@media (hover: hover) { .btn:hover { filter: brightness(1.12); } }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--b-lo), 0 3px 6px rgba(0,0,0,.4); }
.btn.green  { --b: var(--green);  --b-lo: var(--green-lo); }
.btn.orange { --b: var(--orange); --b-lo: var(--orange-lo); }
.btn.blue   { --b: var(--blue);   --b-lo: var(--blue-lo); }
.btn.gold   { --b: var(--gold);   --b-lo: var(--gold-lo); color: #2a1a05; text-shadow: none; }
.btn.ghost  { --b: var(--panel-3); --b-lo: #140f1d; color: var(--bone); }
.btn.big    { font-size: 26px; padding: 18px 30px 15px; border-radius: 12px; }
.btn.small  { font-size: 14px; padding: 9px 14px 8px; border-radius: 8px; }
.btn .sub   { display: block; font-family: var(--ui); font-size: 13px; font-weight: 700; letter-spacing: 0; margin-top: 6px; opacity: .85; text-shadow: none; }
.btn.off, .btn:disabled {
  filter: grayscale(.85) brightness(.62);
  cursor: not-allowed;
}
.btn.off:active, .btn:disabled:active { transform: none; box-shadow: 0 5px 0 var(--b-lo), 0 9px 16px rgba(0,0,0,.45); }
.btn.danger { --b: #a0102a; --b-lo: #4a0712; animation: armed .5s ease-in-out infinite alternate; }
@keyframes armed { to { filter: brightness(1.25); } }

/* The pad / keyboard focus ring. */
.nav-focus { outline: 4px solid var(--gold) !important; outline-offset: 4px; }
.card.nav-focus, .mini.nav-focus, .lvcard.nav-focus, .bcard.nav-focus { transform: translateY(-10px); }

/* ================================== HUD ================================== */
/* v0.7: smaller and see-through (the user: "make the UI during the game much
 * better and smaller and more transparent so you can see more things").
 * Every panel is a thin smoked glass over the fight rather than a slab, the
 * text carries its own outline so it reads over anything, and the whole HUD
 * takes about half the room it did. Still no coloured side stripes. */

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud .hov { pointer-events: auto; }
#hud { --glass: rgba(14, 12, 20, .42); --glass-edge: rgba(122, 108, 156, .28); }

/* Experience: a thin line along the top edge, the level under its end. */
#xpBar {
  position: absolute; left: 0; right: 0; top: 0; height: 6px;
  background: rgba(7, 5, 11, .45);
}
#xpFill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(180deg, #ecd9a2 0%, #c9a45a 60%, #8a6a2c 100%);
  box-shadow: 0 0 8px #d4b36a44;
  transition: width .12s linear;
}
#xpBar.flash #xpFill { background: linear-gradient(180deg, #ffffff, #efe8d8 60%, #c9bfa8); }
#xpLevel {
  position: absolute; right: 8px; top: 8px;
  font: 800 11px/1 var(--ui);
  color: #efe6cf; text-shadow: 0 1px 0 #000, 0 0 3px #000;
  font-variant-numeric: tabular-nums;
}

/* Top-left: which blind, which ante, money and kills, on one small plate. */
#blindPlate {
  position: absolute; left: 10px; top: 14px;
  display: grid; grid-template-columns: 30px auto; grid-template-rows: auto auto; gap: 0 8px;
  align-items: center;
  padding: 5px 11px 5px 6px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 9px;
}
#bpToken { grid-row: 1 / 3; width: 30px; height: 30px; display: grid; place-items: center; }
#bpToken canvas { width: 28px; height: 28px; }
#bpName { font-family: var(--display); font-size: 13px; line-height: 1.15; color: #fff; text-shadow: 0 1px 0 #000; white-space: nowrap; }
#bpSub { font-size: 9.5px; font-weight: 700; color: var(--dim); letter-spacing: .5px; text-shadow: 0 1px 0 #000; white-space: nowrap; }
.bp-stats { grid-column: 2; display: flex; gap: 10px; align-items: center; margin-top: 2px; }
#bpMoney { font: 800 15px/1 var(--ui); color: var(--gold); text-shadow: 0 1px 0 #000, 0 0 3px #000; font-variant-numeric: tabular-nums; }
#bpKills { font: 800 11.5px/1 var(--ui); color: var(--dim); text-shadow: 0 1px 0 #000; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; }
#bpKills::before { content: ''; width: 11px; height: 10px; background: var(--dim); -webkit-mask: var(--skull) center / contain no-repeat; mask: var(--skull) center / contain no-repeat; }
:root { --skull: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h5v1h1v3h-1v1h-1v1h-3v-1h-1v-1h-1v-3h1zM2 2v1h1v-1zM4 2v1h1v-1z'/%3E%3C/svg%3E"); }

/* Top-centre: the clock is the objective, so it is still the biggest thing
   here, with no panel behind it at all. */
#clock {
  position: absolute; left: 50%; top: 10px; width: 200px; margin-left: -100px;
  text-align: center;
}
#clockTime {
  font: 900 30px/1 var(--ui);
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 2px #000, 2px 0 0 #000, -2px 0 0 #000, 0 -1px 0 #000;
  letter-spacing: 1px;
}
#clock.late #clockTime { color: #aef0c4; }
#clock.urgent #clockTime { color: var(--gold); animation: tick 1s steps(1) infinite; }
@keyframes tick { 50% { transform: scale(1.06); } }
#clockBar {
  margin: 4px auto 0; width: 140px; height: 4px;
  background: rgba(7, 5, 11, .5); border-radius: 2px; overflow: hidden;
}
#clockFill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--gold)); }
#clockNote {
  margin-top: 3px; min-height: 12px;
  font: 800 10.5px/12px var(--ui); letter-spacing: 1px;
  color: var(--gold); text-shadow: 0 1px 0 #000, 0 0 3px #000;
}

/* Top-right: relic slots, with each relic's live contribution under it, and
   the HUD buttons under those. The bar wraps before it reaches the clock. */
#hudRight {
  position: absolute; right: 10px; top: 14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#relicSlots {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px;
  max-width: 420px;
}
/* A v0.2 run reached fifty relics, a bar that ran across the whole top of
   the screen. Past seven slots the boxes shrink (ui.js, updateRelicSlots);
   past twenty they drop their badges too, and the TAB panel carries the
   numbers. */
#relicSlots.dense { gap: 3px; }
#relicSlots.dense .rslot { width: 34px; gap: 1px; }
#relicSlots.dense .rs-box { width: 34px; height: 34px; border-radius: 7px; }
#relicSlots.dense .rs-box canvas { width: 26px; height: 26px; }
#relicSlots.dense .rs-pos { left: -4px; top: -4px; min-width: 12px; height: 12px; padding: 0 2px; font-size: 8px; line-height: 12px; }
#relicSlots.dense .rs-val { min-width: 32px; height: 12px; padding: 0 2px; font-size: 8.5px; line-height: 12px; }
#relicSlots.packed .rslot { width: 28px; }
#relicSlots.packed .rs-box { width: 28px; height: 28px; border-radius: 6px; }
#relicSlots.packed .rs-box canvas { width: 22px; height: 22px; }
#relicSlots.packed .rs-pos, #relicSlots.packed .rs-val { display: none; }
#relicSlots .rslot { opacity: .8; transition: opacity .15s; }
#relicSlots .rslot.hov:hover, #relicSlots .rslot.pulse { opacity: 1; }

#hudBtns { display: flex; gap: 6px; }
#hudBtns .btn { pointer-events: auto; padding: 6px 9px 5px; opacity: .8; }
#hudBtns svg { width: 15px; height: 15px; }
.rslot {
  width: 60px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.rslot .rs-box {
  position: relative;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--slot, var(--edge)) 28%, #1d1729) 0%, #150f1f 80%);
  border: 2px solid var(--slot, var(--edge));
  border-radius: 10px;
  box-shadow: 0 3px 0 #000b;
  transition: transform .08s;
}
.rslot.empty .rs-box { background: #0c091299; border: 2px dashed #4a3e6399; box-shadow: none; }
.rslot .rs-pos {
  position: absolute; left: -5px; top: -6px;
  min-width: 18px; height: 18px; padding: 0 4px;
  font: 800 11px/18px var(--ui); text-align: center;
  color: #1a1024; background: var(--slot, var(--edge)); border-radius: 9px;
  box-shadow: 0 1px 0 #000;
}
.rslot .rs-val {
  min-width: 56px; height: 18px; padding: 0 5px;
  font: 800 12px/18px var(--ui); text-align: center; font-variant-numeric: tabular-nums;
  background: #07050bcc; border-radius: 9px;
  text-shadow: 0 1px 0 #000;
}
.rslot .rs-val.idle { color: var(--faint); }
.rslot.pulse .rs-box { transform: scale(1.14) rotate(-3deg); box-shadow: 0 0 16px var(--slot), 0 3px 0 #000b; }

/* The fight's relic bar: the same slots, smaller and see-through (v0.7). */
#relicSlots .rslot { width: 44px; gap: 2px; }
#relicSlots .rs-box {
  width: 44px; height: 44px; border-radius: 8px; border-width: 1.5px; box-shadow: none;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--slot, var(--edge)) 26%, transparent) 0%, rgba(21, 15, 31, .45) 80%);
}
#relicSlots .rslot.ed-negative .rs-box { background: rgba(7, 3, 13, .75); }
#relicSlots .rslot.empty .rs-box { background: rgba(12, 9, 18, .3); border: 1.5px dashed rgba(74, 62, 99, .5); }
#relicSlots .rs-pos { left: -4px; top: -5px; min-width: 14px; height: 14px; padding: 0 3px; font-size: 9px; line-height: 14px; box-shadow: none; }
#relicSlots .rs-val { min-width: 40px; height: 14px; padding: 0 4px; font-size: 10px; line-height: 14px; background: rgba(7, 5, 11, .55); }
#relicSlots .rslot.pulse .rs-box { transform: scale(1.12) rotate(-3deg); box-shadow: 0 0 12px var(--slot); }

/* Left: the hit readout. Might and Mult in two small wells, the hit under
   them, and how it was built in a short list (the longest are cut, TAB has
   the rest). */
#scorebox {
  position: absolute; left: 10px; top: 72px; width: 176px;
  padding: 6px 7px 7px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 9px;
  transition: opacity .3s;
}
#scorebox.idle { opacity: .3; }
.sb-head {
  font: 800 9.5px/1.2 var(--ui); letter-spacing: 1px; color: var(--dim);
  text-transform: uppercase; margin-bottom: 4px; text-shadow: 0 1px 0 #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-row { display: grid; grid-template-columns: 1fr 12px 1fr; align-items: center; }
.sb-well {
  padding: 3px 6px 4px;
  background: rgba(8, 9, 14, .45);
  border: 1px solid rgba(60, 66, 84, .55);
  border-radius: 6px;
  transition: border-color .15s;
}
.sb-well .label { display: block; font-size: 8.5px; }
.sb-chips, .sb-mult {
  margin-top: 2px;
  font: 900 15px/1 var(--ui); font-variant-numeric: tabular-nums; color: var(--bone);
  text-shadow: 0 1px 0 #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-mult { color: var(--mult); }
/* An XMult in the hit: the Mult well lights in its colour. */
.sb-mult.hot { color: var(--xmult); }
.sb-well:has(.hot) { border-color: color-mix(in srgb, var(--xmult) 55%, transparent); }
.sb-x { text-align: center; font: 900 12px/1 var(--ui); color: var(--faint); }
.sb-total {
  margin-top: 4px;
  font: 900 20px/1.05 var(--ui); font-variant-numeric: tabular-nums;
  text-align: center; color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 3px #000;
}
.sb-total.big { color: var(--gold); animation: pop .25s ease-out; }
@keyframes pop { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
.sb-breakdown { margin-top: 4px; font-size: 10.5px; line-height: 1.28; text-shadow: 0 1px 0 #000; }
.sb-breakdown > div { display: flex; justify-content: space-between; gap: 6px; }
.sb-breakdown > div > span { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-breakdown > .sb-cut { display: none; }
.sb-breakdown .sb-more { color: var(--faint); justify-content: flex-end; font-size: 9.5px; }
/* Holding TAB opens it to every line. */
#scorebox.full .sb-breakdown > .sb-cut { display: flex; }
#scorebox.full .sb-more { display: none; }
.sb-breakdown b { font-variant-numeric: tabular-nums; }
.sb-breakdown .sb-base { color: var(--dim); }
.sb-breakdown .sb-base span { color: var(--bone); font-weight: 800; }
.sb-breakdown .c-chips b { color: var(--chips); }
.sb-breakdown .c-mult b { color: var(--mult); }
.sb-breakdown .c-xmult b { color: var(--xmult); }
.sb-breakdown .sb-share b { color: var(--dim); }
.sb-breakdown .c-chips, .sb-breakdown .c-mult, .sb-breakdown .c-xmult { font-weight: 400; }

/* Bottom-left: hearts, then weapons, then tomes. */
#loadout {
  position: absolute; left: 10px; bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
#hearts { display: flex; gap: 2px; align-items: center; height: 20px; }
#hearts canvas { filter: drop-shadow(0 1px 0 #000); }
#hearts .hp-text { font: 900 14px/1 var(--ui); color: #ff8a9a; text-shadow: 0 1px 0 #000, 0 0 3px #000; margin-left: 5px; }
#hearts.hurt { animation: hurt .35s; }
@keyframes hurt { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.slot-row { display: flex; gap: 5px; }
.wslot, .tslot {
  position: relative;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: #1a1426e6;
  border: 2px solid var(--edge);
  border-radius: 9px;
  box-shadow: 0 3px 0 #000b;
}
.slot-row.small .tslot { width: 38px; height: 38px; border-radius: 8px; }
.wslot.empty, .tslot.empty { background: #0c091288; border: 2px dashed #4a3e6388; box-shadow: none; }
.wslot.evolved { border-color: var(--gold); background: radial-gradient(circle, #4a3410 0%, #1a1426 75%); }
.wslot.ready { border-color: var(--gold); animation: ready 1s ease-in-out infinite alternate; }
@keyframes ready { to { box-shadow: 0 0 14px var(--gold), 0 3px 0 #000b; } }
.wslot.sealed { opacity: .35; }
.wslot .pips {
  position: absolute; left: 4px; right: 4px; bottom: 3px;
  display: flex; gap: 1px; justify-content: center;
}
.wslot .pips i { width: 4px; height: 4px; background: #3a3050; border-radius: 1px; }
.wslot .pips i.on { background: var(--gold); box-shadow: 0 0 3px #f5c65c99; }
.wslot .star, .tslot .lv, .wslot .lv {
  position: absolute; right: -5px; top: -6px;
  min-width: 17px; height: 17px; padding: 0 3px;
  font: 900 11px/17px var(--ui); text-align: center;
  border-radius: 9px; box-shadow: 0 1px 0 #000;
}
.wslot .star { background: var(--gold); color: #2a1a05; }
.tslot .lv, .wslot .lv { background: #dcd2ee; color: #1a1024; }
/* At its top level a slot's badge says MAX, in gold (v0.7). */
.tslot .lv.max, .wslot .lv.max { background: var(--gold); color: #2a1a05; font-size: 8.5px; letter-spacing: .3px; }

/* The fight's own loadout: the same slots, smaller and see-through. */
#loadout .slot-row { gap: 4px; }
#loadout .wslot {
  width: 36px; height: 36px; border-radius: 7px; border-width: 1.5px;
  background: rgba(26, 20, 38, .5); box-shadow: none;
}
#loadout .wslot canvas { width: 30px; height: 30px; }
#loadout .wslot.evolved { background: radial-gradient(circle, rgba(74, 52, 16, .7) 0%, rgba(26, 20, 38, .5) 75%); }
#loadout .wslot .pips { left: 3px; right: 3px; bottom: 2px; }
#loadout .wslot .pips i { width: 3px; height: 3px; }
#loadout .wslot .star { right: -4px; top: -5px; min-width: 13px; height: 13px; font-size: 9px; line-height: 13px; }
#loadout .slot-row.small .tslot {
  width: 28px; height: 28px; border-radius: 6px; border-width: 1.5px;
  background: rgba(26, 20, 38, .5); box-shadow: none;
}
#loadout .tslot canvas { width: 22px; height: 22px; }
#loadout .tslot .lv { right: -4px; top: -5px; min-width: 13px; height: 13px; font-size: 9px; line-height: 13px; padding: 0 2px; }
#loadout .tslot .lv.max { font-size: 7px; }
#loadout .wslot.empty, #loadout .tslot.empty { background: rgba(12, 9, 18, .25); border: 1.5px dashed rgba(74, 62, 99, .45); }

#tabHint {
  position: absolute; right: 10px; bottom: 6px;
  font: 700 10px/1 var(--ui); letter-spacing: .5px;
  color: var(--dim); opacity: .55;
  text-shadow: 0 1px 0 #000;
}
#btnPauseTouch { display: none; }

/* The hero's two abilities (heroes.js), bottom right, over the inspect
   hint. A slot like the weapons', the knight inside it in the pose, and the
   cooldown a shade that sweeps off it (ui.js, updateAbilities). */
#abil {
  position: absolute; right: 10px; bottom: 26px;
  display: flex; flex-direction: row-reverse; gap: 8px; align-items: flex-end;
}
#abil .ab {
  pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent;
  position: relative; width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 38%, rgba(43, 33, 64, .6) 0%, rgba(21, 15, 31, .5) 78%);
  border: 1.5px solid rgba(122, 108, 156, .55); border-radius: 10px;
  cursor: pointer; color: var(--bone);
}
#abil .ab[data-ab="1"] { border-color: rgba(184, 154, 92, .7); }
/* A knight with no second move (the Red Knight) has one button. */
#abil .ab[hidden] { display: none; }
#abil .ab-ico canvas { display: block; image-rendering: pixelated; filter: drop-shadow(0 1px 0 #000c); width: 34px; height: 34px; }
#abil .ab-cd {
  position: absolute; inset: 0; border-radius: 9px; pointer-events: none;
  background: conic-gradient(#07050bc8 var(--cd, 0%), transparent 0);
}
#abil .ab-key {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  min-width: 16px; padding: 1px 4px 1px; border-radius: 4px;
  font: 800 8.5px/1.2 var(--ui); letter-spacing: .5px; white-space: nowrap;
  color: #1a1024; background: #dcd2eecc;
}
#abil .ab-key:empty { display: none; }
#abil .ab.cooling .ab-ico { opacity: .55; }
#abil .ab.on { border-color: var(--gold); transform: translateY(2px); box-shadow: 0 0 10px #f5c65c55; }
#abil .ab.ready { animation: abReady .35s ease-out; }
@keyframes abReady {
  0% { transform: scale(1.12); border-color: #fff6c4; box-shadow: 0 0 12px #f8df9b; }
  100% { transform: scale(1); }
}

/* The stairs out of the lava. Drawn on the canvas it sat under the HUD, so
   an exit up and to the right was a pointer behind the relic bar. */
#exitPtr {
  position: absolute; left: 0; top: 0; z-index: 7; pointer-events: none;
  width: 0; height: 0;
}
#exitPtr .ep-ring {
  position: absolute; left: -38px; top: -38px; width: 76px; height: 76px;
  display: grid; place-items: center; border-radius: 50%;
  background: #08060de6; border: 3px solid #f0bb4a;
  box-shadow: 0 0 0 3px #08060d, 0 0 22px #f0bb4acc;
  animation: epPulse .8s ease-in-out infinite alternate;
}
#exitPtr svg { width: 48px; height: 48px; fill: #f0bb4a; transform: rotate(var(--ep-a, 0rad)); }
#exitPtr .ep-dist {
  position: absolute; left: -70px; top: 44px; width: 140px; text-align: center;
  font: 900 17px/1 var(--ui); color: #f0bb4a; letter-spacing: .5px;
  text-shadow: 0 2px 0 #000, 0 0 4px #000, 0 0 8px #000;
}
@keyframes epPulse { to { box-shadow: 0 0 0 3px #08060d, 0 0 34px #f0bb4a; } }

/* ================================ BANNER ================================= */

#blindBanner {
  position: absolute; left: 50%; top: 200px; width: 560px; margin-left: -280px;
  z-index: 8; pointer-events: none;
  text-align: center;
  padding: 22px 26px 20px;
  background: linear-gradient(180deg, #1b2029f2, #11141bf2);
  border: 2px solid var(--edge);
  border-radius: 16px;
  box-shadow: 0 8px 0 #000c, 0 0 60px #000;
  animation: bannerIn .45s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes bannerIn { from { transform: translateY(-40px) scale(.9); opacity: 0; } }
.bb-kind { font: 800 13px/1 var(--ui); letter-spacing: 2px; color: var(--dim); }
.bb-name { font-family: var(--display); font-size: 44px; line-height: 1.1; margin: 10px 0 8px; color: #fff; text-shadow: 0 4px 0 #000; }
#blindBanner.boss .bb-name { color: var(--red); }
.bb-rule { font-size: 17px; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.bb-goal { font-size: 16px; color: var(--bone); }
.bb-goal b { color: #fff; font-weight: 900; }

/* =========================== RELIC INSPECTOR ============================ */

#relicPanel {
  position: absolute; right: 14px; top: 124px; width: 430px; max-height: 470px;
  z-index: 9; overflow: hidden;
  padding: 12px;
  background: #140f1df2;
  border: 2px solid var(--edge);
  border-radius: 14px;
  box-shadow: 0 6px 0 #000c;
}
.rp-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.rp-head h3 { font-size: 16px; }
.rp-head span { font-size: 12px; color: var(--dim); }
.rp-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  padding: 6px 8px; margin-bottom: 5px;
  background: #0b0d13cc; border: 1px solid #252b37; border-radius: 8px;
}
.rp-name { font-family: var(--display); font-size: 13px; }
.rp-desc { font-size: 12.5px; color: var(--dim); line-height: 1.35; }
.rp-val { font: 900 15px/1 var(--ui); font-variant-numeric: tabular-nums; }
.rp-val.idle { color: var(--faint); }
.rp-empty { font-size: 14px; color: var(--dim); padding: 8px 0; }

/* ============================== TOOLTIP ================================= */

#tooltip {
  position: absolute; z-index: 40;
  width: max-content; max-width: 300px;
  padding: 10px 12px;
  background: #120d1af7;
  border: 2px solid var(--edge-hi);
  border-radius: 10px;
  box-shadow: 0 6px 0 #000c;
  pointer-events: none;
}
#tooltip .tt-name { font-family: var(--display); font-size: 15px; margin-bottom: 4px; color: #fff; }
#tooltip .tt-desc { font-size: 13.5px; line-height: 1.4; color: var(--bone); }
#tooltip .tt-flavor { font-size: 12.5px; color: var(--faint); font-style: italic; margin-top: 6px; }
#tooltip .tt-tag { display: inline-block; margin: 0 0 6px; }

/* ============================== OVERLAY ================================= */

#overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(8, 6, 13, .74);
  animation: fadeIn .18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }
/* Dark enough that the arena's own floating text ("RITE PACK DROPPED")
   stops competing with the cards, light enough to still see the fight. */
#overlay.clear { background: radial-gradient(ellipse at 50% 45%, rgba(8, 6, 13, .62), rgba(8, 6, 13, .82)); }
#hud.under #clock { opacity: 0; }
/* The shop art is true 320x180 pixel art (4x into the 1280x720 frame), so it
   sits on its own layer with nearest-neighbour scaling. image-rendering is
   inherited, which is why it isn't set on #overlay itself. */
#overlay.den { background: #0a060e; }
#overlay.den::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10,6,14,.5), rgba(10,6,14,.7)),
    url('../assets/images/shop-bg.png') center / cover no-repeat;
  image-rendering: pixelated;
}

.panel {
  background: linear-gradient(180deg, #221a31f5, #17111ff5);
  border: 2px solid var(--edge);
  border-radius: 16px;
  box-shadow: 0 6px 0 #000c, 0 20px 50px #0009;
}
.inset {
  background: #0f0b16cc;
  border: 2px solid #2c2340;
  border-radius: 12px;
}
.label { font: 800 11px/1 var(--ui); letter-spacing: 1.5px; color: var(--dim); text-transform: uppercase; }
.paper {
  background: var(--paper); color: var(--paper-ink);
  border-radius: 8px;
  box-shadow: inset 0 -3px 0 #d3c6aa;
}

/* ------------------------------ run sidebar ----------------------------- */
/* Shared by blind select, cash-out, shop and packs, so money and the run's
   shape never leave the screen between fights. */

.side {
  position: absolute; left: 18px; top: 18px; bottom: 18px; width: 256px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
}
.side-blind {
  border-radius: 12px; overflow: hidden;
  background: #0b0d13cc;
  border: 2px solid #252b37;
}
.side-blind .sbl-top {
  padding: 10px 10px 0;
  font-family: var(--display); font-size: 17px; color: #fff; text-shadow: 0 2px 0 #000;
}
.side-blind .sbl-top small { display: block; margin-top: 4px; font: 800 11px/1.2 var(--ui); letter-spacing: 1.5px; color: var(--dim); text-shadow: none; }
.side-blind .sbl-body { display: flex; gap: 10px; align-items: center; padding: 8px 10px; }
.side-blind .sbl-body p { font-size: 13px; color: var(--dim); line-height: 1.35; }
.side-blind .sbl-body p b { color: var(--bone); }
.side-money {
  padding: 8px 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.side-money .num { font-size: 34px; color: var(--gold); text-shadow: 0 3px 0 #000; }
.side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-grid > div { padding: 7px 10px; }
.side-grid .num { display: block; font-size: 20px; margin-top: 3px; }
.side-grid .num small { font-size: 13px; color: var(--faint); font-weight: 700; }
.side-note { font-size: 12.5px; color: var(--dim); line-height: 1.35; padding: 0 2px; }
.side-note b { color: var(--gold); }
.side-load { padding: 8px 10px; }
/* Six slots across a 208px column: a grid shares the width out exactly,
   where fixed 36px squares wrapped the sixth onto a row of its own. */
.side-load .slot-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 6px; }
.side-load .wslot, .side-load .tslot { width: auto; height: auto; aspect-ratio: 1; border-radius: 7px; }
.side-load .wslot canvas, .side-load .tslot canvas { width: 22px; height: 22px; }
.side-load .wslot .pips { display: none; }
.side-load .wslot .lv, .side-load .tslot .lv { right: -4px; top: -5px; min-width: 15px; height: 15px; font-size: 10px; line-height: 15px; }
.side-spacer { flex: 1; }
/* Nothing in the column gives way on its own (the blind's text used to be
   what shrank and clipped). fitSide() in ui.js closes it up instead. */
.side > :not(.side-spacer) { flex-shrink: 0; }
.side.dense { gap: 7px; padding: 10px 12px; }
.side.dense .side-money { padding: 5px 12px; }
.side.dense .side-money .num { font-size: 28px; }
.side.dense .side-grid > div { padding: 5px 10px; }
.side.dense .side-grid .num { font-size: 17px; margin-top: 1px; }
.side.dense .side-load { padding: 6px 10px; }
.side.dense .side-blind .sbl-body { padding: 6px 10px; }
.side.denser .side-note { display: none; }
.side.denser .side-blind .sbl-body p { font-size: 12px; line-height: 1.3; }
.side.denser > .hint { display: none; }
.side.scrolls { overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; }

.main {
  position: absolute; left: 292px; right: 18px; top: 18px; bottom: 18px;
}

/* -------------------------------- cards --------------------------------- */

.card {
  --slot: var(--edge-hi);
  position: relative;
  width: 168px; height: 236px;
  flex: 0 0 auto;
  display: flex; flex-direction: column;
  padding: 8px;
  background: linear-gradient(180deg, #2c2240, #1d1629);
  border: 3px solid var(--slot);
  border-radius: 13px;
  box-shadow: 0 6px 0 #000b, 0 12px 20px #0007;
  cursor: pointer;
  transition: transform .12s ease-out, box-shadow .12s;
}
/* Hover only where there is a pointer that hovers. A phone keeps :hover on
   the last thing tapped, so a card stayed lifted after the finger had moved
   on and looked picked when it was not. */
@media (hover: hover) {
  .card:hover { transform: translateY(-8px) rotate(-1deg); box-shadow: 0 10px 0 #000b, 0 20px 26px #0008; }
}
.card.sel { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--gold), 0 14px 0 #000b, 0 24px 30px #0009; }
.card.sold { opacity: 0; pointer-events: none; transform: translateY(-40px) scale(.9); transition: all .25s; }
.card.cant .c-price { background: #4a3e63; color: #cfc5e0; }
.card.cant .c-art { filter: saturate(.5) brightness(.8); }
.c-art {
  height: 84px; border-radius: 9px;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--glow, transparent) 45%, transparent) 0%, transparent 56%),
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--slot) 35%, #1a1426) 0%, #110c18 78%);
  box-shadow: inset 0 0 0 2px #0006;
}
.c-name {
  font-family: var(--display); font-size: 14px; line-height: 1.12;
  text-align: center; color: #fff;
  margin: 7px 0 6px;
  min-height: 32px; display: grid; place-items: center;
}
.c-desc {
  flex: 1; overflow: hidden auto;
  padding: 6px 8px;
  font-size: 12.5px; line-height: 1.33;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.c-desc::-webkit-scrollbar { display: none; }
/* Text that still runs long after fitText() scrolls; the fade says so. */
.c-desc.scrolls:not(.at-end) {
  -webkit-mask: linear-gradient(#000 calc(100% - 22px), #0000);
  mask: linear-gradient(#000 calc(100% - 22px), #0000);
}
/* fitText() in ui.js steps a description down through these when it would
   otherwise clip: a relic's live "Currently +160 Chips" line is the part
   that matters most and it is always the last line. */
.c-desc.dense { font-size: 11.5px; line-height: 1.28; padding: 5px 7px; }
.c-desc.denser { font-size: 10.5px; line-height: 1.22; padding: 4px 6px; }
.c-foot {
  margin-top: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 4px;
  font: 800 10px/1 var(--ui); letter-spacing: 1px;
}
.pill {
  display: inline-block;
  padding: 3px 7px 3px;
  border-radius: 7px;
  font: 800 10px/1.1 var(--ui); letter-spacing: 1px;
  color: #fff; background: var(--pc, var(--edge));
  box-shadow: 0 2px 0 #0008;
  white-space: nowrap;
}
/* fitText() again: two long pills (LEGENDARY and HOLOGRAPHIC) are wider than
   a card, so the pair closes up rather than running off its edge. */
.p-tight > .pill { padding: 3px 5px; letter-spacing: .3px; }
.p-tighter > .pill { font-size: 8.5px; letter-spacing: 0; padding: 3px 4px; }
/* Still too wide (COMMON and HOLOGRAPHIC on a shop card): the edition takes
   a line of its own, on the right where it would have been. */
.p-wrap { flex-wrap: wrap; row-gap: 4px; }
.p-wrap > .pill:last-child { margin-left: auto; }
.pill.common { --pc: var(--r-common); }
.pill.uncommon { --pc: var(--r-uncommon); }
.pill.rare { --pc: var(--r-rare); }
.pill.legendary { --pc: var(--r-legendary); }
.pill.slot { --pc: color-mix(in srgb, var(--slot) 55%, #1a1426); }
.pill.gold { --pc: var(--gold); color: #2a1a05; }
.pill.green { --pc: var(--green); }
.pill.purple { --pc: #6a4aa8; }
.pill.blue { --pc: var(--blue); }
.pill.steel { --pc: #5d6678; }
.pill.leather { --pc: #7c6038; }
.pill.red { --pc: var(--red); }
.c-price {
  position: absolute; left: 50%; top: -30px; transform: translateX(-50%);
  min-width: 62px; padding: 5px 12px 9px;
  font: 900 18px/1 var(--ui); font-variant-numeric: tabular-nums; text-align: center;
  color: #2a1a05; background: var(--gold);
  border-radius: 9px 9px 0 0;
  box-shadow: 0 -2px 0 #0006;
  z-index: -1;
}
.c-price.free { background: var(--good); color: #0b2a16; }
.c-price s { opacity: .55; font-size: 13px; margin-right: 4px; }
.c-price.none { display: none; }
/* Selecting a card turns its price tab into the button that buys it, so the
   decision costs no extra space and the second click lands where the eye
   already is. Clicking the selected card anywhere does the same. */
.card.sel .c-price {
  display: block;
  background: var(--green); color: #fff; text-shadow: 0 2px 0 #0006;
  box-shadow: 0 -2px 0 #0006, 0 0 16px #36a56a88;
  font-family: var(--display); font-size: 15px; letter-spacing: 1px;
  padding-top: 7px;
}
.card.sel.cant .c-price { background: #6a2a3a; color: #f0c0c8; box-shadow: 0 -2px 0 #0006; }
.card.evolve { --slot: var(--gold); background: linear-gradient(180deg, #4a3614, #231a0e); }
.card.evolve .c-art { background: radial-gradient(circle, #8a6418 0%, #231a0e 78%); }

/* Cards on a shelf breathe a little, each on its own phase. */
.cw { animation: sway 3.4s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -1.1s); }
@keyframes sway { 0%, 100% { transform: rotate(-.9deg); } 50% { transform: rotate(.9deg) translateY(-3px); } }

/* Small owned-relic cards. */
.mini {
  --slot: var(--edge-hi);
  position: relative;
  width: 94px; height: 118px;
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 5px 5px;
  background: linear-gradient(180deg, #2c2240, #1d1629);
  border: 3px solid var(--slot);
  border-radius: 11px;
  box-shadow: 0 5px 0 #000b;
  cursor: pointer;
  transition: transform .12s ease-out;
}
@media (hover: hover) { .mini:hover { transform: translateY(-5px); } }
.mini.sel { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--gold), 0 8px 0 #000b; }
.mini .m-art { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 10px;
  background: radial-gradient(circle, color-mix(in srgb, var(--glow, transparent) 40%, transparent) 0%, transparent 66%); }
.mini .m-name { font-family: var(--display); font-size: 10.5px; line-height: 1.1; text-align: center; min-height: 24px; display: grid; place-items: center; margin-top: 3px; }
.mini .m-val { font: 900 12px/1 var(--ui); font-variant-numeric: tabular-nums; margin-top: auto; }
.mini .m-val.idle { color: var(--faint); font-weight: 700; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.mini .m-pos {
  position: absolute; left: -7px; top: -7px;
  width: 20px; height: 20px; border-radius: 10px;
  font: 900 11px/20px var(--ui); text-align: center;
  background: var(--slot); color: #1a1024; box-shadow: 0 2px 0 #000;
}
.mini.empty { background: #0c091266; border: 3px dashed #4a3e6388; box-shadow: none; cursor: default; }
.mini.empty:hover { transform: none; }
/* Selected, the value line becomes the sell button. */
.mini.sel .m-val {
  padding: 4px 7px 3px; border-radius: 6px;
  background: var(--red); color: #fff; font-size: 11px; letter-spacing: .5px;
  box-shadow: 0 2px 0 var(--red-lo);
}
.mini.position-locked::after {
  content: 'LOCKED'; position: absolute; top: 4px; right: 4px;
  font: 800 8px/1 var(--ui); letter-spacing: 1px; color: var(--gold);
}
.dragging { opacity: .4; }
.drop-target { outline: 3px dashed var(--gold); outline-offset: 3px; }
/* In a fanned row the target comes to the front, so you see where it lands. */
.fanned > .drop-target { z-index: 6; }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }
.is-dragging .dragging { pointer-events: none; }
/* A held relic must not call up the phone's own long-press menu. */
.reorder { -webkit-touch-callout: none; }
/* The relic a finger carries, drawn above the finger (ui.js pointerDrag). */
.drag-ghost {
  position: absolute; left: 0; top: 0; z-index: 60; margin: 0;
  pointer-events: none; transition: none;
  box-shadow: 0 0 0 3px var(--gold), 0 16px 28px #000c;
}

/* ------------------------------- pack card ------------------------------ */

.pack {
  --pk: #5a3a9a;
  width: 128px; height: 160px;
  background:
    repeating-linear-gradient(135deg, #ffffff10 0 6px, transparent 6px 14px),
    linear-gradient(160deg, color-mix(in srgb, var(--pk) 90%, #fff) 0%, var(--pk) 45%, color-mix(in srgb, var(--pk) 55%, #000) 100%);
  border-color: color-mix(in srgb, var(--pk) 50%, #fff);
}
.pack.rite { --pk: #5a3fa8; }
.pack.grand_rite { --pk: #a8781a; }
.pack.reagent { --pk: #2a6ab0; }
.pack.omen { --pk: #7a2a5a; }
.pack .c-art { height: 56px; background: #0006; }
.pack .c-name { min-height: 26px; font-size: 12.5px; margin: 5px 0 2px; }
.pack .p-desc { font-size: 11.5px; line-height: 1.3; text-align: center; color: #f5eefc; text-shadow: 0 1px 0 #0008; }
.pack .p-free {
  position: absolute; top: 6px; right: -8px; transform: rotate(8deg);
}

/* =============================== SCREENS ================================ */

.screen { position: absolute; inset: 0; }
.center-col {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.title-xl {
  font-family: var(--display);
  font-size: 54px; line-height: 1; color: var(--gold);
  text-shadow: 0 5px 0 #000, 0 0 30px #f5c65c55;
}
.title-l { font-family: var(--display); font-size: 34px; line-height: 1.05; color: #fff; text-shadow: 0 4px 0 #000; }
.subline { font-size: 16px; color: var(--dim); margin-top: 8px; }
.subline b { color: var(--bone); }
.hint { font: 700 13px/1 var(--ui); color: var(--faint); letter-spacing: .5px; }
.row { display: flex; gap: 14px; align-items: center; justify-content: center; }

/* ------------------------------ level up -------------------------------- */

.lv-head { text-align: center; margin-bottom: 26px; }
.lv-head .title-xl { animation: lvIn .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes lvIn { from { transform: scale(.4); opacity: 0; } }
.lv-cards { display: flex; gap: 20px; }
.lvcard {
  --slot: var(--edge-hi);
  position: relative;
  width: 232px; height: 330px;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 14px 12px;
  background: linear-gradient(180deg, #2c2240, #1a1426);
  border: 3px solid var(--slot);
  border-radius: 16px;
  box-shadow: 0 7px 0 #000b, 0 16px 30px #0008;
  cursor: pointer;
  transition: transform .12s ease-out;
  animation: dealIn .35s cubic-bezier(.2, 1.3, .4, 1) both;
  animation-delay: calc(var(--i) * .06s);
}
@keyframes dealIn { from { transform: translateY(60px) rotate(4deg); opacity: 0; } }
@media (hover: hover) { .lvcard:hover { transform: translateY(-10px); } }
.lvcard.t-weapon, .lvcard.t-wlevel { --slot: #8d97a8; }
.lvcard.t-tome, .lvcard.t-tlevel { --slot: #a4865a; }
.lvcard.t-evolve { --slot: var(--gold); }
.lvcard.t-gold, .lvcard.t-heal { --slot: var(--good); }
.lvcard .lv-art {
  width: 100%; height: 100px; border-radius: 12px;
  display: grid; place-items: center;
  background: radial-gradient(circle, color-mix(in srgb, var(--slot) 40%, #1a1426) 0%, #110c18 75%);
}
.lvcard .lv-kind { margin-top: 10px; }
.lvcard .lv-name { font-family: var(--display); font-size: 18px; line-height: 1.1; text-align: center; margin: 8px 0 8px; color: #fff; }
.lvcard .lv-step { font: 900 15px/1 var(--ui); color: var(--gold); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.lvcard .lv-step .new { color: var(--good); letter-spacing: 2px; }
.lvcard .c-desc { width: 100%; font-size: 13.5px; line-height: 1.38; }
/* The shared .dense steps lose to the rule above on specificity and source
   order, which is why a long level-up card used to clip at full size. */
.lvcard .c-desc.dense { font-size: 12.5px; line-height: 1.3; }
.lvcard .c-desc.denser { font-size: 11.5px; line-height: 1.26; }
/* Inside the text box, so it shrinks and scrolls with the description instead
   of squeezing it down to one line (v0.3's longer evolution text did). */
.lvcard .lv-evo { margin-top: 6px; padding-top: 5px; border-top: 1px dashed #0000002e; font-size: .92em; color: #5d5140; }
.lvcard .lv-evo b { color: #a06a00; }
.lvcard .lv-evo .have { color: #17803e; }
.lvcard .key {
  position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 6px;
  font: 900 14px/26px var(--ui); text-align: center;
  background: var(--panel-3); color: var(--dim); box-shadow: 0 3px 0 #000;
}
.lv-foot { margin-top: 56px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lv-load { display: flex; gap: 18px; align-items: center; padding: 8px 14px; }

/* -------------------------------- chest --------------------------------- */

.chest-art { position: relative; width: 150px; height: 150px; display: grid; place-items: center; }
.chest-art::before {
  content: ''; position: absolute; inset: -60px;
  background: conic-gradient(from 0deg, #f5c65c00, #f5c65c55, #f5c65c00 12%, #f5c65c44 25%, #f5c65c00 37%, #f5c65c55 50%, #f5c65c00 62%, #f5c65c44 75%, #f5c65c00 87%);
  border-radius: 50%;
  animation: spin 9s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 70%);
  mask: radial-gradient(circle, #000 20%, transparent 70%);
}
@keyframes spin { to { transform: rotate(360deg); } }
.chest-art canvas { position: relative; animation: chestShake .5s ease-in-out 2; }
@keyframes chestShake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.chest-items { display: flex; gap: 18px; margin-top: 18px; }
.chest-items .lvcard { height: 290px; cursor: default; animation-delay: calc(.9s + var(--i) * .25s); }
.chest-items .lvcard:hover { transform: none; }
/* A chest to choose from is dealt like a level-up, in the chest's gold. */
.chest-pick .lvcard { border-color: color-mix(in srgb, var(--slot) 55%, var(--gold)); }
.chest-pick .lv-foot { margin-top: 30px; }
.chest-took { margin-top: 22px; font-size: 14px; color: var(--dim); }

/* ----------------------------- blind select ----------------------------- */

.bs-head { position: absolute; left: 0; right: 0; top: 4px; text-align: center; }
.bs-cards { position: absolute; left: 0; right: 0; top: 76px; bottom: 0; display: flex; gap: 22px; justify-content: center; align-items: flex-start; }
.bcard {
  --bc: var(--edge-hi);
  position: relative;
  width: 280px; height: 560px;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px;
  background: linear-gradient(180deg, #221a31f5, #140f1df5);
  border: 2px solid var(--edge);
  border-radius: 18px;
  box-shadow: 0 7px 0 #000c;
  transition: transform .15s, filter .15s;
}
.bcard.current { transform: translateY(-10px); border-color: color-mix(in srgb, var(--gold) 70%, var(--edge)); box-shadow: 0 7px 0 #000c, 0 0 30px #d4b36a26; }
.bcard.upcoming { filter: brightness(.62) saturate(.7); }
.bcard.defeated, .bcard.skipped { filter: brightness(.45) saturate(.3); }
.bcard .bc-state { height: 58px; width: 100%; display: grid; place-items: center; }
.bcard .bc-state .btn { width: 100%; }
.bcard .bc-state .label { font-size: 13px; }
.bcard .bc-name {
  width: 100%; margin-top: 6px;
  padding: 6px 4px 0; text-align: center;
  font-family: var(--display); font-size: 22px; color: #fff; text-shadow: 0 2px 0 #000;
}
.bcard.boss .bc-name { color: var(--red); }
.bcard .bc-token {
  margin-top: 16px; width: 120px; height: 120px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle, color-mix(in srgb, var(--bc) 55%, #1a1426) 0%, #0f0b16 72%);
  box-shadow: 0 0 0 4px #0f0b16, 0 0 0 7px color-mix(in srgb, var(--bc) 60%, #000);
}
.bcard.current .bc-token { animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.bcard .bc-goal { margin-top: 16px; text-align: center; font-size: 15px; color: var(--dim); }
.bcard .bc-goal b { display: block; font: 900 30px/1.1 var(--ui); color: #fff; }
.bcard .bc-reward { margin-top: 8px; font: 900 18px/1 var(--ui); color: var(--gold); letter-spacing: 1px; }
.bcard .bc-rule { margin-top: 12px; width: 100%; padding: 8px 10px; font-size: 14px; line-height: 1.35; text-align: center; font-weight: 600; }
.bcard .bc-warden { margin-top: 8px; font-size: 13px; color: var(--dim); }
.bcard .bc-warden b { color: var(--bone); }
.bcard .bc-or { margin: 14px 0 8px; width: 100%; display: flex; align-items: center; gap: 10px; font: 800 12px/1 var(--ui); color: var(--faint); letter-spacing: 2px; }
.bcard .bc-or::before, .bcard .bc-or::after { content: ''; flex: 1; height: 2px; background: #2c2340; }
.bcard .bc-tag { width: 100%; display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; padding: 8px; }
.bcard .bc-tag .tg-name { font-family: var(--display); font-size: 12.5px; color: #fff; }
.bcard .bc-tag .tg-desc { font-size: 12px; line-height: 1.3; color: var(--dim); }
.bcard .bc-skip { margin-top: 10px; }
.bcard .bc-stamp {
  position: absolute; top: 240px; left: 50%; transform: translateX(-50%) rotate(-12deg);
  padding: 6px 16px; border: 4px solid; border-radius: 8px;
  font-family: var(--display); font-size: 26px;
  background: #0009;
}
.bcard.defeated .bc-stamp { color: var(--good); border-color: var(--good); }
.bcard.skipped .bc-stamp { color: var(--gold); border-color: var(--gold); }
.bs-toast {
  position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  white-space: nowrap;
  padding: 8px 16px; font-size: 14px; font-weight: 700;
  animation: dealIn .3s both;
}

/* -------------------------------- cash out ------------------------------ */

.co {
  position: absolute; left: 50%; top: 60px; width: 560px; margin-left: -280px;
  padding: 20px 24px 24px;
}
.co-head { display: flex; gap: 14px; align-items: center; padding-bottom: 14px; border-bottom: 2px dashed #3a2f52; }
.co-head .title-l { font-size: 28px; }
.co-rows { margin: 12px 0 8px; }
.co-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 4px; font-size: 16px;
  animation: rowIn .25s ease-out both;
  animation-delay: calc(.25s + var(--i) * .32s);
}
@keyframes rowIn { from { opacity: 0; transform: translateX(-16px); } }
.co-row .co-lead { flex: 1; border-bottom: 2px dotted #3a2f52; transform: translateY(-4px); }
.co-row .co-amt { font: 900 20px/1 var(--ui); color: var(--gold); font-variant-numeric: tabular-nums; }
.co-row .co-dollars { font: 900 14px/1 var(--ui); color: var(--gold); letter-spacing: 1px; opacity: .8; }
.co-stats { display: flex; gap: 18px; justify-content: center; padding: 10px 0 14px; font-size: 14px; color: var(--dim); }
.co-stats b { color: var(--bone); font-variant-numeric: tabular-nums; }
.co .btn { width: 100%; animation: rowIn .25s ease-out both; animation-delay: calc(.25s + var(--n) * .32s); }

/* --------------------------------- shop --------------------------------- */

.shop-relics {
  position: absolute; left: 0; right: 0; top: 0; height: 150px;
  display: flex; gap: 14px; align-items: stretch;
  padding: 14px 14px;
}
.sr-label { width: 110px; flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.sr-label .num { font-size: 26px; }
.sr-label .num small { font-size: 15px; color: var(--faint); }
.sr-label p { font-size: 11.5px; line-height: 1.3; color: var(--faint); }
.sr-row { display: flex; gap: 12px; align-items: center; padding-top: 4px; }

.shop-body {
  position: absolute; left: 0; right: 0; top: 162px; bottom: 0;
  padding: 12px 16px;
}
.shop-top { display: flex; gap: 22px; height: 290px; }
.shop-btns { width: 180px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 16px; padding-top: 44px; }
.shop-btns .btn { width: 100%; }
.shop-btns .btn.next { height: 110px; font-size: 24px; line-height: 1.2; white-space: normal; }
.shop-btns .btn.reroll { height: 80px; font-size: 20px; }
.shelf { flex: 1; display: flex; gap: 16px; align-items: flex-start; justify-content: center; padding-top: 42px; }
.shelf .card { width: 184px; height: 244px; }
.shelf .c-art { height: 70px; }
.shelf .c-name { min-height: 28px; margin: 6px 0 5px; }
/* Five or more on the shelf (Merchant relics, a couple of evolutions). */
.shelf.tight { gap: 10px; }
.shelf.tight .card { width: 138px; }
.shelf .empty-note, .packs .empty-note { align-self: center; font-size: 15px; color: var(--dim); }
.packs .empty-note { margin-top: -30px; }
.shop-bottom { display: flex; gap: 16px; margin-top: 6px; height: 200px; border-top: 2px dashed #2c2340; }
.shop-bottom .sb-title { width: 180px; flex: 0 0 auto; padding-top: 40px; }
.shop-bottom .sb-title h3 { font-size: 17px; color: #fff; margin-bottom: 6px; }
.shop-bottom .sb-title p { font-size: 12.5px; color: var(--dim); line-height: 1.35; }
.packs { flex: 1; display: flex; gap: 16px; align-items: flex-start; justify-content: center; padding-top: 34px; }
/* fanRow() overlaps a crowded row. These let a row be narrower than its cards
   so it can, and bring the card being looked at over its neighbours. */
.shelf, .packs, .sr-row { min-width: 0; }
.fanned > * { flex-shrink: 0; }
.fanned > .sel, .fanned > :has(.sel),
.fanned > .nav-focus, .fanned > :has(.nav-focus) { z-index: 5; }
@media (hover: hover) { .fanned > :hover { z-index: 5; } }

/* ------------------------------ pack opening ---------------------------- */

.pk-head { position: absolute; left: 0; right: 0; top: 8px; text-align: center; }
.pk-cards { position: absolute; left: 0; right: 0; top: 118px; height: 290px; display: flex; justify-content: center; gap: 14px; }
.pk-cards .card { animation: dealIn .35s cubic-bezier(.2, 1.3, .4, 1) both; animation-delay: calc(var(--i) * .07s); }
.pk-cards .card.taken { opacity: .25; pointer-events: none; }
.pk-cards.tight { gap: 10px; }
.pk-cards.tight .card { width: 128px; }
.pk-skip { position: absolute; left: 0; right: 0; top: 420px; display: flex; justify-content: center; gap: 12px; }
.pk-owned { position: absolute; left: 0; right: 0; bottom: 0; height: 190px; padding: 12px 14px; display: flex; gap: 14px; }
.pk-owned .sr-row { display: flex; gap: 12px; align-items: center; }
.pk-weapons { display: flex; gap: 10px; align-items: center; }

/* ---------------------------------- menu -------------------------------- */

.menu-left { position: absolute; left: 70px; top: 50px; width: 560px; }
.logo { font-family: var(--display); line-height: .9; transform: rotate(-3deg); transform-origin: left bottom; }
.logo .l1 { display: block; font-size: 96px; color: var(--red); text-shadow: 0 8px 0 #3a0612, 0 0 50px #d23a4f66; }
.logo .l2 { display: block; font-size: 96px; color: var(--gold); margin-left: 52px; text-shadow: 0 8px 0 #4a3008, 0 0 50px #f5c65c55; }
.logo { animation: logoBob 4s ease-in-out infinite; }
@keyframes logoBob { 50% { transform: rotate(-2deg) translateY(-6px); } }
.tagline { margin-top: 16px; font-size: 18px; color: var(--dim); max-width: 480px; }
.menu-btns { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; width: 340px; }
.menu-btns .btn { width: 100%; text-align: left; }
.menu-note { margin-top: 12px; font-size: 13px; color: var(--faint); }
.menu-right { position: absolute; right: 60px; top: 48px; width: 470px; display: flex; flex-direction: column; gap: 16px; }

/* Co-op (v0.7): the lobby, and the cover over a screen that is the other
   player's to use. The cover lets the screen show through; only its pill
   says whose turn it is. */
.co-status { margin-top: 18px; font-size: 17px; color: var(--dim); }
.co-status b { color: var(--gold); }
.co-note { color: var(--bad); }
.co-addr { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.co-addr code { font: 800 24px/1.2 var(--ui); color: var(--gold); letter-spacing: .5px; user-select: all; }
.co-addr.small code { font-size: 16px; color: var(--bone); }
.co-lan { margin-top: 14px; }
.co-how { margin-top: 14px; }
/* The CO-OP button's panel on the main menu. */
.modal-card.coop { width: 600px; }
.co-pane[hidden] { display: none; }
.how.co-steps { counter-reset: coStep; gap: 9px; }
.how.co-steps li { counter-increment: coStep; padding-left: 30px; }
.how.co-steps li::before { content: counter(coStep); left: 0; top: 0; width: 20px; height: 20px; background: none; transform: none; font: 800 14px/20px var(--ui); color: var(--gold); text-align: center; border: 1px solid #5a4a2a; border-radius: 50%; }
.co-join { display: flex; gap: 10px; margin: 2px 0 6px; }
.co-join input { flex: 1; min-width: 0; font: 800 22px/1.2 var(--ui); letter-spacing: .5px; color: var(--gold); background: #0a0c11; border: 2px solid #2a303c; border-radius: 10px; padding: 10px 14px; outline: none; }
.co-join input:focus { border-color: var(--gold); }
.co-join input::placeholder { color: #4a4452; }
.c-gold { color: var(--gold); }
.btn[disabled] { opacity: .45; filter: saturate(.4); cursor: default; }
#coopWait { position: absolute; inset: 0; z-index: 35; cursor: default; }
.coop-pill {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 999px; white-space: nowrap;
  background: rgba(8, 6, 13, .82); border: 1px solid var(--edge);
  font: 800 13px/1 var(--ui); letter-spacing: 1.5px; color: var(--gold);
  pointer-events: none; animation: coopPulse 1.6s ease-in-out infinite;
}
#coopNote { z-index: 36; top: 64px; }
@keyframes coopPulse { 50% { opacity: .6; } }
.menu-card { padding: 18px 20px; }
.menu-card h3 { font-size: 16px; color: #fff; margin-bottom: 12px; }
.formula { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.formula .f-box { flex: 1; height: 54px; border-radius: 10px; display: grid; place-items: center; text-align: center; font: 900 14px/1.1 var(--ui); letter-spacing: 1.5px; color: var(--bone); background: #0b0d13cc; border: 2px solid #252b37; }
.formula .f-chips { color: var(--chips); }
.formula .f-mult { color: var(--mult); }
.formula .f-dmg { color: var(--gold); }
.formula .f-op { font: 900 22px/1 var(--ui); color: var(--dim); }
.how { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.how li { font-size: 14px; line-height: 1.35; padding-left: 20px; position: relative; color: var(--bone); }
.how li::before { content: ''; position: absolute; left: 3px; top: 7px; width: 8px; height: 8px; background: var(--red); transform: rotate(45deg); }
.how li b { color: var(--gold); }
.keys { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: 13px; color: var(--dim); }
.keys kbd { display: inline-block; min-width: 22px; padding: 2px 6px; margin-right: 4px; border-radius: 5px; background: var(--panel-3); box-shadow: 0 2px 0 #000; font: 800 12px/1.3 var(--ui); color: var(--bone); text-align: center; }
.records { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.records > div { padding: 8px 10px; }
.records .num { display: block; font-size: 18px; margin-top: 4px; }
.records .best { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.records .best .num { font-size: 20px; color: var(--gold); margin: 0; }

.volume-settings { display: flex; gap: 18px; align-items: center; }
.volume-control { display: flex; align-items: center; gap: 8px; font: 800 12px/1 var(--ui); letter-spacing: 1px; color: var(--dim); }
.volume-control b { width: 40px; text-align: right; color: var(--bone); font-variant-numeric: tabular-nums; }
.volume-slider { width: 120px; accent-color: var(--red); cursor: pointer; }
.volume-slider.nav-focus { outline-offset: 6px; }
.mute-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.mute-note { font-size: 12px; color: var(--faint); }

/* --------------------------------- pause -------------------------------- */

.pause-panel { position: absolute; left: 60px; right: 60px; top: 40px; bottom: 40px; padding: 20px 24px; display: flex; flex-direction: column; }
.pause-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.pause-title { display: flex; align-items: center; gap: 24px; }
.pause-stats { display: flex; gap: 10px; }
.pause-stats > div { padding: 6px 12px; }
.pause-stats .num { display: block; font-size: 17px; margin-top: 2px; }
.pause-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr .8fr 1.3fr; gap: 18px; margin-top: 16px; }
.pause-col {
  position: relative; min-height: 0; display: flex; flex-direction: column; gap: 6px;
  overflow: hidden auto; overscroll-behavior: contain; scrollbar-width: none;
}
.pause-col::-webkit-scrollbar { display: none; }
.pause-col.scrolls:not(.at-end) {
  -webkit-mask: linear-gradient(#000 calc(100% - 36px), #0000);
  mask: linear-gradient(#000 calc(100% - 36px), #0000);
}
.pause-col h3 { font-size: 14px; color: var(--dim); display: flex; justify-content: space-between; margin: 4px 0 2px; }
.pause-col h3 span { font-family: var(--ui); font-weight: 800; font-size: 13px; }
.bs-row {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center;
  padding: 6px 8px;
  background: #0b0d13cc; border: 1px solid #252b37; border-radius: 8px;
}
.bs-row .bs-name { font-family: var(--display); font-size: 12.5px; color: #fff; }
.bs-row .bs-name b { font-family: var(--ui); font-weight: 900; color: var(--gold); margin-left: 6px; font-size: 12px; }
.bs-row .bs-desc { font-size: 12px; line-height: 1.3; color: var(--dim); }
.bs-row .bs-val { font: 900 14px/1 var(--ui); font-variant-numeric: tabular-nums; }
.bs-row .bs-val.idle { color: var(--faint); }
.bs-row[data-relic] { cursor: grab; }
.bs-row.position-locked { cursor: default; }
.pause-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
/* Wide enough for the armed SURE? and its second line, so arming one never
   moves the buttons beside it. */
.pause-foot .row .btn.ghost { min-width: 164px; }

/* ------------------------------- game over ------------------------------ */

.go { position: absolute; left: 90px; right: 90px; top: 40px; bottom: 40px; padding: 24px 28px; display: flex; flex-direction: column; }
.go-head { text-align: center; }
.go-head .title-xl { font-size: 58px; }
.go-head .title-xl.lose { color: var(--red); text-shadow: 0 5px 0 #000, 0 0 30px #d23a4f55; }
.go-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 22px; margin-top: 20px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.stat-grid > div { padding: 8px 12px; }
.stat-grid .num { display: block; font-size: 20px; margin-top: 3px; }
.dmg-table { display: flex; flex-direction: column; gap: 7px; }
.dmg-row { display: grid; grid-template-columns: 34px 130px 1fr 80px 60px; gap: 10px; align-items: center; font-size: 13px; }
.dmg-row .dr-name { font-family: var(--display); font-size: 12px; }
.dmg-row .dr-bar { height: 14px; background: #0f0b16; border-radius: 7px; overflow: hidden; }
.dmg-row .dr-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); border-radius: 7px; animation: grow .8s ease-out both; }
@keyframes grow { from { width: 0 !important; } }
.dmg-row .dr-num { font-weight: 900; text-align: right; font-variant-numeric: tabular-nums; }
.dmg-row .dr-kills { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.go-build { display: flex; align-items: flex-start; margin-top: 14px; }
/* Each half keeps to one line and fans its items when it runs out of room
   (fanRow in ui.js). */
.go-build .gb-row { display: flex; gap: 6px; min-width: 0; flex: 0 1 auto; }
/* Six tomes at most against any number of relics: the relics give way first. */
.go-build .gb-tomes { flex-shrink: .25; }
.go-build .gb-row > * { flex-shrink: 0; position: relative; }
/* Tomes sit after the relics at the relics' size, split off by a rule. */
.go-build .tslot { width: 60px; height: 60px; border-radius: 10px; }
.go-build .gb-gap { flex-shrink: 0; align-self: stretch; width: 2px; margin: 4px 6px; background: var(--edge); border-radius: 1px; }
.go-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.go-best { padding: 8px 14px; }
.go-best.is-best { border-color: var(--gold); box-shadow: 0 0 20px #f5c65c44; }

/* ------------------------------ accounts -------------------------------- */

/* The sign-in door sits where the menu's right column does, so the logo and
   tagline do not jump when it gives way to the menu. */
.gate {
  position: absolute; right: 70px; top: 50%; transform: translateY(-50%);
  width: 440px; padding: 22px 24px 20px;
}
.gate h3 { font-size: 20px; color: #fff; margin: 2px 0 10px; }
.gate-p { font-size: 15px; line-height: 1.45; color: var(--dim); margin-bottom: 16px; }
.gate-p b { color: var(--bone); }
.gate-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gate-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.btn.ghost.on { --b: var(--gold); --b-lo: var(--gold-lo); color: #2a1a05; text-shadow: none; }
.gate .g-google { width: 100%; }
.g-or { display: flex; align-items: center; gap: 10px; margin: 14px 0 12px; font: 700 12px/1 var(--ui); color: var(--faint); }
.g-or::before, .g-or::after { content: ''; flex: 1; height: 2px; background: #2c2340; border-radius: 1px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
#gateForm .up-only { display: none; }
#gateForm.up .up-only { display: flex; }
.field input, .fb textarea {
  width: 100%;
  font: 600 16px/1.3 var(--ui); color: var(--bone);
  background: #0f0b16; border: 2px solid #2c2340; border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.field input:focus, .fb textarea:focus { border-color: var(--gold); }
.g-err { min-height: 18px; margin: 2px 0 10px; font: 700 13px/1.35 var(--ui); color: var(--bad); }
.g-err.good { color: var(--good); }
.g-link { background: none; border: 0; padding: 0; font: 600 13px/1 var(--ui); color: var(--dim); text-decoration: underline; cursor: pointer; }
.g-link:hover { color: var(--bone); }
.g-dev { display: block; margin-top: 16px; color: var(--faint); }

/* Seats as a row of face-down cards: dealt ones red, open ones dashed. */
.seat-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.seat-row:empty { display: none; }
.seat-pips { display: flex; gap: 5px; }
.seat-pips i { width: 20px; height: 28px; border-radius: 4px; border: 2px dashed #4a3e6399; }
.seat-pips i.taken { border: 2px solid #f07a88; background: var(--red); box-shadow: inset 0 0 0 2px var(--red-lo), 0 2px 0 #000b; }

.gate-wait { display: flex; align-items: center; gap: 12px; padding: 18px 0 8px; }
.dots { display: flex; gap: 5px; }
.dots i { width: 8px; height: 8px; border-radius: 2px; background: var(--gold); animation: dot 1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: .2; transform: translateY(-3px); } }

.acct { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.acct-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.acct-who b { font: 800 15px/1.2 var(--ui); color: var(--bone); max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btns { display: flex; gap: 8px; }
.adm-badge {
  display: inline-block; min-width: 18px; height: 18px; margin: -4px -4px -4px 7px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; text-shadow: none;
  font: 900 11px/18px var(--ui); font-style: normal; text-align: center; vertical-align: middle;
}
/* The menu's top card: leaderboard, what's new and how to play as tabs. The
   height is fixed so switching tabs never moves the lifetime card below. */
.info-card { height: 346px; display: flex; flex-direction: column; }
.info-tabs { margin-bottom: 12px; }
.info-tabs .btn { flex: 1 1 auto; min-width: 0; padding-left: 8px; padding-right: 8px; }
.info-body { flex: 1; min-height: 0; overflow: hidden auto; overscroll-behavior: contain; scrollbar-width: none; }
.info-body::-webkit-scrollbar { display: none; }
.info-body.scrolls:not(.at-end), .news-scroll.scrolls:not(.at-end) {
  -webkit-mask: linear-gradient(#000 calc(100% - 36px), #0000);
  mask: linear-gradient(#000 calc(100% - 36px), #0000);
}
.info-body .formula { margin-bottom: 12px; }
.info-body .formula .f-box { height: 48px; }
.news + .news { margin-top: 14px; padding-top: 12px; border-top: 2px solid #2c2340; }
.news-v { display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px; }
.news-v b { font: 15px/1 var(--display); color: var(--gold); }
.news-v span { font: 600 12px/1 var(--ui); color: var(--faint); }
.news.old .news-v b { color: var(--dim); }
.news.old .how li { color: var(--dim); }
.news.old .how li::before { background: #4a3e63; }
/* The LEADERBOARD window's chips (game, version, difficulty) and rows. */
.board-vers { display: flex; gap: 6px; margin-bottom: 10px; }
.board-vers .bv {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 13px;
  border: 0; background: #0f0b16b3; color: var(--dim); font: 700 13px/1 var(--ui); cursor: pointer;
}
.board-vers .bv span { font-size: 10px; letter-spacing: .06em; color: var(--faint); }
.board-vers .bv.on { background: var(--gold-lo); color: var(--bone); }
.board-vers .bv.on span { color: var(--gold); }
.board-vers .bv:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.board { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.board li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  height: 30px; padding: 0 12px 0 8px; border-radius: 8px; background: #0f0b16b3;
  font: 700 14px/1 var(--ui); color: var(--bone);
}
.board .rk { font-weight: 800; font-size: 13px; color: var(--faint); text-align: right; }
.board li.top .rk { color: var(--gold); }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .far { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--dim); }
.board li.me { box-shadow: inset 0 0 0 2px var(--gold-lo); }
.board li.me .nm { color: var(--gold); }
.board-msg { padding: 22px 2px; font-size: 15px; color: var(--faint); }
.ver-link { display: block; margin-top: 22px; }
.modal-card.news-modal { width: 540px; }
.news-scroll { max-height: 470px; overflow: hidden auto; scrollbar-width: none; }

.menu-card h3.rec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 20px; }
.rec-fav { display: flex; align-items: center; gap: 8px; font: 600 12px/1 var(--ui); letter-spacing: 0; color: var(--dim); }
.rec-fav b { color: var(--bone); }

/* --------------------------------- modal -------------------------------- */

#modal {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(8, 6, 13, .66);
  animation: fadeIn .15s ease-out;
}
.modal-card { width: 560px; max-height: 660px; padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.modal-card h3 { font-size: 20px; color: #fff; }
.fb-sub { font-size: 14px; line-height: 1.4; color: var(--dim); }
.fb-kinds { display: flex; gap: 6px; }
.fb textarea { height: 190px; resize: none; font-weight: 500; font-size: 15px; line-height: 1.45; }
.fb-foot { display: flex; align-items: center; gap: 10px; }
.fb-msg { flex: 1; font: 600 13px/1.3 var(--ui); color: var(--faint); }
.fb-msg.bad { color: var(--bad); }

.modal-card.adm { width: 1060px; height: 640px; max-height: none; }
.adm-head { display: flex; align-items: center; gap: 18px; }
.adm-head .gate-tabs { margin: 0; }
.adm-head #admDownload { margin-left: auto; }
.adm-body { flex: 1; min-height: 0; overflow: hidden auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.adm-empty { padding: 30px 0; text-align: center; font-size: 15px; color: var(--faint); }
.adm-sum { margin-bottom: 10px; }
.fb-item { background: #0f0b16cc; border: 2px solid color-mix(in srgb, var(--gold) 55%, #2c2340); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.fb-item.read { border-color: #2c2340; opacity: .72; }
.fbi-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fbi-head b { font-size: 15px; color: var(--bone); }
.fbi-text { margin: 8px 0 6px; font-size: 15px; line-height: 1.45; color: var(--bone); white-space: pre-wrap; overflow-wrap: anywhere; }
.fbi-ctx { font-size: 12px; line-height: 1.4; color: var(--faint); overflow-wrap: anywhere; }
.fbi-act { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.adm-seats { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.adm-seats b { font: 900 20px/1 var(--ui); color: var(--gold); margin-right: 4px; }
/* The pixel face has no plus sign worth the name. */
.adm-seats .btn { font: 900 18px/1 var(--ui); width: 34px; padding-left: 0; padding-right: 0; }
.adm-seats .hint { margin-left: 8px; font-weight: 600; }
.pp-row {
  display: grid; grid-template-columns: 1fr 90px 60px 60px 170px 70px 120px; gap: 10px; align-items: center;
  padding: 9px 10px; border-bottom: 2px solid #2c234088; font-size: 14px; font-variant-numeric: tabular-nums;
}
.pp-row > span:last-child { text-align: right; }
.pp-row.off { color: var(--dim); }
.pp-head { font: 800 11px/1 var(--ui); letter-spacing: 1.5px; color: var(--faint); padding-top: 0; }
.pp-who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.pp-who b { color: var(--bone); }
.pp-who .hint { width: 100%; font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

/* ================================ TOUCH ================================= */

#stick {
  position: absolute; z-index: 6; display: none;
  width: 150px; height: 150px; margin: -75px 0 0 -75px;
  border-radius: 50%;
  border: 3px solid #ffffff38;
  background: radial-gradient(circle, #ffffff10, #ffffff04 70%);
  pointer-events: none;
}
#stick.on { display: block; }
#stick i {
  position: absolute; left: 50%; top: 50%;
  width: 62px; height: 62px; border-radius: 50%;
  background: #ffffff40; border: 3px solid #ffffff70;
  transform: translate(-50%, -50%);
}

#rotateHint {
  position: fixed; inset: 0; z-index: 100;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: var(--ink); color: var(--bone);
  font: 800 18px/1.3 var(--ui); text-align: center;
}
.rh-phone {
  width: 54px; height: 92px; border: 5px solid var(--bone); border-radius: 10px;
  animation: rotatePhone 2s ease-in-out infinite;
}
@keyframes rotatePhone { 40%, 70% { transform: rotate(-90deg); } }

/* Full screen buttons (toggleFull in ui.js). html.fs-ok says the browser can
   go full screen, or is an iPhone that can be told how. */
.fs-btn { display: none; align-items: center; justify-content: center; gap: 10px; }
/* A desktop gets the button on the menu and the pause screen, not over the
   fight, where F11 is a key away. */
.fs-ok .fs-btn:not(#btnFullTouch) { display: inline-flex; }
.fs-btn svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: square; }
.fs-btn .fs-out, .is-full .fs-btn .fs-in { display: none; }
.is-full .fs-btn .fs-out { display: block; }
.menu-btns .fs-btn { justify-content: flex-start; }

/* Sound on and off. Every one of these buttons toggles the same mute as M. */
.snd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.snd-btn svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.snd-btn .snd-off, .is-muted .snd-btn .snd-on { display: none; }
.is-muted .snd-btn .snd-off { display: block; }
.menu-btns .snd-btn { justify-content: flex-start; }
.modal-card.fs-help { width: 520px; }

/* Touch only. A desktop never sees any of this: the stick appears where a
   thumb lands, and the pause button replaces the P key. */
@media (pointer: coarse) {
  #btnPauseTouch { display: block; }
  .fs-ok .fs-btn { display: inline-flex; }
  #tabHint { display: none; }
  /* Under the right thumb: the roll big in the corner, the parry up and in
     from it, where a thumb rocks to. */
  #abil { right: 26px; bottom: 24px; gap: 16px; }
  #abil .ab { width: 92px; height: 92px; border-radius: 50%; }
  #abil .ab-cd { border-radius: 50%; }
  #abil .ab[data-ab="1"] { width: 76px; height: 76px; margin-bottom: 58px; }
  #abil .ab-ico canvas { width: 64px; height: 64px; }
  #abil .ab[data-ab="1"] .ab-ico canvas { width: 54px; height: 54px; }
  /* A thumb reads the keys' labels nowhere; a pad still does. */
  #abil:not(.pad) .ab-key { display: none; }
  /* The relics along the top: each one catches a tap a little past its
     edges, into the gaps, so a thumb that lands between two still reads
     the nearer one (and not the stick under it, main.js). */
  .rslot { position: relative; }
  .rslot::after { content: ''; position: absolute; inset: -5px -4px -3px; }
  /* The shop's row of your relics sat against the top edge, where a phone
     in landscape can take a tap for its own toolbar. Lower, and the shelf
     under it gives up some of the air above its price tags to make room. */
  .shop-relics { height: 172px; padding-top: 34px; }
  .shop-body { top: 184px; }
  .shop-top { height: 268px; }
  .shelf { padding-top: 22px; }
  .shop-btns { padding-top: 24px; }
}
@media (orientation: portrait) and (pointer: coarse) {
  #rotateHint { display: flex; }
}

/* ============================ STRATEGY LAYER ============================ */
/* Schools are Balatro's suits: each has one colour used everywhere it is
   named — card pills, slot feet, relic text and the resonance summary. */

.s-blade { --sch: #cfd8ea; --sch-lo: #3e4860; }
.s-iron  { --sch: #e6b877; --sch-lo: #5a3e1e; }
.s-ash   { --sch: #f5874a; --sch-lo: #6a2412; }
.s-hex   { --sch: #b88cf7; --sch-lo: #3a2068; }
.c-school { color: var(--sch); font-weight: 800; letter-spacing: .5px; }
.paper .c-school { color: color-mix(in srgb, var(--sch-lo) 80%, #000); }
.pill.school { --pc: var(--sch-lo); color: var(--sch); box-shadow: 0 2px 0 #0008, inset 0 0 0 1px color-mix(in srgb, var(--sch) 45%, transparent); }
.lvcard .lv-kind { display: flex; gap: 6px; justify-content: center; }
.bs-row .bs-name .pill { margin-left: 6px; font-size: 8.5px; padding: 2px 5px; vertical-align: 1px; }

/* A weapon slot's bottom edge is its school. */
.wslot.sch { border-bottom-color: var(--sch); box-shadow: 0 3px 0 var(--sch-lo), inset 0 -3px 0 color-mix(in srgb, var(--sch) 30%, transparent); }

.sch-sum { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sch-chip {
  font: 800 11px/1 var(--ui); letter-spacing: .8px;
  padding: 5px 8px; border-radius: 7px;
  color: var(--sch); background: color-mix(in srgb, var(--sch-lo) 70%, #120d1a);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sch) 35%, transparent);
}
.sch-chip b { color: #fff; }
.sch-chip em { font-style: normal; color: var(--mult); margin-left: 3px; }

/* ------------------------------- editions ------------------------------- */
/* Foil is cold silver-blue, Holographic a sliding red-magenta sheen,
   Polychrome a full rainbow, Negative the colours inverted — each readable
   at a glance on a card, a mini and a 60px HUD slot alike. */

.ed-text.ed-foil { color: #8fd8ff; }
.ed-text.ed-holo { color: #ff7ab8; }
.ed-text.ed-poly { color: #ffd166; }
.ed-text.ed-negative { color: #c9b8ff; }
.paper .ed-text.ed-foil { color: #1f6ec4; }
.paper .ed-text.ed-holo { color: #c0286e; }
.paper .ed-text.ed-poly { color: #a0561a; }
.paper .ed-text.ed-negative { color: #5a3aa8; }
.pill.ed-foil { --pc: linear-gradient(90deg, #5a8ab8, #bfe8ff, #5a8ab8); color: #0e2238; }
.pill.ed-holo { --pc: linear-gradient(90deg, #c0286e, #ff9ad0, #c0286e); }
.pill.ed-poly { --pc: linear-gradient(90deg, #e04a4a, #f0c040, #4ac070, #4a8ae0, #a04ae0); }
.pill.ed-negative { --pc: #120a1e; color: #d9c8ff; box-shadow: 0 2px 0 #0008, inset 0 0 0 1px #9a7ae8; }
.pill.ed { background: var(--pc); }

.card.ed-foil, .mini.ed-foil, .rslot.ed-foil .rs-box { --shine: linear-gradient(115deg, transparent 20%, #bfe8ff55 38%, #ffffff88 45%, #bfe8ff55 52%, transparent 70%); }
.card.ed-holo, .mini.ed-holo, .rslot.ed-holo .rs-box { --shine: linear-gradient(115deg, transparent 15%, #ff4a9a44 35%, #ffb0e066 45%, #ff4a9a44 55%, transparent 75%); }
.card.ed-poly, .mini.ed-poly, .rslot.ed-poly .rs-box { --shine: linear-gradient(115deg, #ff5a5a33, #ffd16644, #6fdc9844, #5aa0ff44, #c77df544, #ff5a5a33); }
/* ::before, because a locked mini already uses ::after for its label. The
   sheen sits over the card at inset 0 rather than clipping with overflow,
   which would cut off the price tab that hangs above a shop card. */
.card.ed-foil::before, .card.ed-holo::before, .card.ed-poly::before,
.mini.ed-foil::before, .mini.ed-holo::before, .mini.ed-poly::before,
.rslot.ed-foil .rs-box::before, .rslot.ed-holo .rs-box::before, .rslot.ed-poly .rs-box::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: var(--shine); background-size: 250% 100%;
  mix-blend-mode: screen;
  animation: sheen 3.2s linear infinite;
}
.card.ed-poly::before, .mini.ed-poly::before, .rslot.ed-poly .rs-box::before { background-size: 300% 300%; animation-duration: 5s; }
@keyframes sheen { from { background-position: 150% 0; } to { background-position: -150% 0; } }
.card.ed-foil { border-color: #9fd8ff; }
.card.ed-holo { border-color: #ff8ac4; }
.card.ed-poly { border-color: #ffd166; }
.card.ed-negative .c-art, .mini.ed-negative .m-art, .rslot.ed-negative .rs-box canvas { filter: invert(1) hue-rotate(180deg); }
.card.ed-negative, .mini.ed-negative { background: linear-gradient(180deg, #0a0612, #1c1030); border-color: #9a7ae8; }
.rslot.ed-foil .rs-box { border-color: #9fd8ff; }
.rslot.ed-holo .rs-box { border-color: #ff8ac4; }
.rslot.ed-poly .rs-box { border-color: #ffd166; }
.rslot.ed-negative .rs-box { background: #07030d; border-color: #9a7ae8; }
.rp-row.ed-foil, .bs-row.ed-foil { box-shadow: inset 0 0 0 1px #9fd8ff66; }
.rp-row.ed-holo, .bs-row.ed-holo { box-shadow: inset 0 0 0 1px #ff8ac466; }
.rp-row.ed-poly, .bs-row.ed-poly { box-shadow: inset 0 0 0 1px #ffd16699; }
.rp-row.ed-negative, .bs-row.ed-negative { box-shadow: inset 0 0 0 1px #9a7ae8aa; }

/* -------------------------------- vouchers ------------------------------ */
/* A ticket: gold stock with a perforated edge. Tier two is violet. */

.pack.voucher {
  --pk: #b8841c;
  background:
    repeating-linear-gradient(90deg, #ffffff12 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #f0c860 0%, #b8841c 45%, #6a4a0e 100%);
  border-color: #ffe29a;
}
/* The ticket's torn-stub line: a dashed rule a third of the way down. */
.pack.voucher .c-art { border-bottom: 2px dashed #fff6; border-radius: 9px 9px 0 0; }
.pack.voucher.tier2 { background: repeating-linear-gradient(90deg, #ffffff12 0 2px, transparent 2px 9px), linear-gradient(160deg, #c49aff 0%, #7a4ad0 45%, #34185e 100%); border-color: #e0ccff; }
.pack.voucher .p-desc { color: #fff8e6; }
.packs .cw:first-child .pack.voucher { margin-right: 14px; }

/* ------------------------------ active list ----------------------------- */

.h3-gap { margin-top: 12px !important; }
.act-item {
  display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center;
  padding: 5px 8px; background: #0b0d13cc; border-radius: 8px;
  border: 1px solid #252b37;
}
.act-item .ai-name { font-family: var(--display); font-size: 11.5px; color: #fff; display: flex; align-items: center; gap: 6px; }
.act-item .ai-name .pill { font-size: 8px; padding: 2px 5px; }
.act-item .ai-desc { font-size: 11.5px; line-height: 1.3; color: var(--dim); }
.rp-sub { margin-top: 12px; }
#relicPanel .act-item { margin-bottom: 4px; }
.side-load .act-row .tslot.act { border-color: #9a7ae8; }
.side-load .act-row { flex-wrap: wrap; }
.act-item .ai-name .ai-n { font-family: var(--ui); font-weight: 900; font-size: 12px; color: var(--gold); }

/* ------------------------------ menu settings --------------------------- */
/* Sound, then the doors that are not a run: full screen, the compendium,
   other versions and (on phones, or once a new build is out) refresh. Full
   screen used to be a third big button, and with a saved run the column ran
   50px past the bottom of the frame, taking FEEDBACK and SIGN OUT with it. */

.menu-settings { margin-top: 20px; }
.menu-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.menu-tools .fs-btn { gap: 8px; }
.menu-tools .fs-btn svg { width: 13px; height: 13px; }
.menu-settings [hidden], .pause-title [hidden] { display: none !important; }

/* -------------------------------- versions ------------------------------ */

.modal-card.vers { width: 620px; }
.ver-list { display: grid; gap: 8px; max-height: 420px; overflow: hidden auto; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.ver-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.ver-row.here { border-color: color-mix(in srgb, var(--gold) 40%, #2c2340); }
.ver-txt { flex: 1; min-width: 0; }
.ver-txt .news-v { margin-bottom: 5px; }
.ver-txt .pill { align-self: center; }
.ver-txt p { font-size: 13px; line-height: 1.35; color: var(--dim); }
.ver-row .btn { min-width: 120px; }
.ver-row .btn .sub { font-size: 11px; margin-top: 4px; }
/* VERSIONS, by game: a heading each, and a version's first note in two lines. */
.ver-era { display: flex; align-items: baseline; gap: 10px; margin: 10px 2px 0; font: 17px/1 var(--display); color: var(--gold); }
.ver-era:first-child { margin-top: 0; }
.ver-era span { font: 600 13px/1.2 var(--ui); color: var(--faint); }
.ver-txt p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* LEADERBOARDS: game, version and difficulty, then the board. */
.modal-card.boards { width: 700px; }
.boards .board-vers { flex-wrap: wrap; }
.bd-one { display: flex; align-items: center; height: 26px; font: 600 13px/1 var(--ui); color: var(--faint); }
/* A fixed height, so picking a short or empty board never moves the chips. */
.bd-list { height: 360px; overflow: hidden auto; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }

/* ------------------------------ native modal ---------------------------- */
/* A modal on the page itself rather than in the scaled frame (openModal's
   `native`): real CSS pixels, for reading and typing on a phone, where the
   frame is drawn at a third of its size. Text fields are 16px so iOS does not
   zoom the page when one takes focus. */

#modal.native {
  position: fixed; inset: 0; z-index: 100;
  display: block; overflow: hidden auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(8, 6, 13, .82);
  touch-action: pan-y; overscroll-behavior: contain;
}
#modal.native input, #modal.native textarea, #modal.native .cx-notes p, #modal.native .cx-idea-text { -webkit-user-select: text; user-select: text; }
#modal.native .modal-card { width: min(560px, 100%); max-height: none; margin: 0 auto; }
#modal.native .fb textarea { height: clamp(96px, 32vh, 190px); font-size: 16px; }
#modal.native .fb-kinds, #modal.native .fb-foot { flex-wrap: wrap; }

/* ------------------------------- compendium ----------------------------- */
/* js/codex.js. The whole screen, outside the frame, in real pixels. The same
   palette and paper as the game's cards; names in the display face, every
   rule and number in the UI face. */

.modal-card.codex {
  --cx-pad: clamp(12px, 3vw, 28px);
  position: fixed; inset: 0; width: auto !important; max-height: none; margin: 0 !important;
  padding: 0; gap: 0; border: 0; border-radius: 0; box-shadow: none;
  display: flex; flex-direction: column;
  font: 15px/1.5 var(--ui); color: var(--bone);
  background: radial-gradient(1200px 500px at 50% -180px, #2a1830 0%, transparent 70%), var(--ink);
}
.codex [hidden] { display: none !important; }
.cx-bar { flex: none; background: #0c0912f2; border-bottom: 1px solid var(--edge); padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.cx-bar-in { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; max-width: 1240px; margin: 0 auto; padding: 10px var(--cx-pad) 8px; }
.codex .cx-title { margin: 0; font: 400 24px/1 var(--display); letter-spacing: 1px; color: var(--gold); display: flex; align-items: baseline; gap: 8px; }
.cx-title small { font: 700 12px/1 var(--ui); letter-spacing: .5px; color: var(--faint); }
.cx-search { flex: 1 1 160px; position: relative; display: block; }
.cx-search svg { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; }
.cx-search input { width: 100%; padding: 8px 12px 8px 34px; border-radius: 10px; border: 1px solid var(--edge); background: var(--panel); color: var(--bone); font: 500 16px/1.3 var(--ui); outline: none; }
.cx-search input:focus { border-color: var(--gold); }
.cx-tabs { flex: none; display: flex; gap: 3px; padding: 3px; border-radius: 11px; background: var(--panel); border: 1px solid var(--edge); }
.cx-tab { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border: 0; border-radius: 8px; cursor: pointer; font: 800 12.5px/1 var(--ui); letter-spacing: .9px; text-transform: uppercase; color: var(--dim); background: none; }
.cx-tab:hover { color: var(--bone); }
.cx-tab b { font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.cx-tab b:empty { display: none; }
.cx-tab[aria-selected="true"] { color: var(--ink); background: var(--gold); }
.cx-tab[aria-selected="true"] b { color: var(--gold-lo); }
.cx-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* Something new behind this tab since the last visit. */
.cx-tab.fresh::after { content: ''; position: absolute; top: -2px; right: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--panel); }
.cx-sort { flex: none; display: inline-flex; align-items: center; gap: 8px; font: 800 11px/1 var(--ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); }
.cx-sort select { -webkit-appearance: none; appearance: none; max-width: 100%; padding: 8px 30px 8px 12px; border-radius: 10px; border: 1px solid var(--edge); background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23b1a7c6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px; color: var(--bone); font: 600 14px/1.25 var(--ui); letter-spacing: 0; text-transform: none; cursor: pointer; outline: none; }
.cx-sort select:hover { border-color: var(--edge-hi); }
.cx-sort select:focus-visible { border-color: var(--gold); }
.cx-sort option { color: var(--bone); background: var(--panel); }
.cx-close { flex: none; margin-left: auto; }
/* Portrait phone: the tabs and CLOSE share the top row (the title goes: the
   tabs say where you are), then search and sort. */
@media (max-width: 700px) {
  .cx-close { order: 1; }
  .cx-tabs { order: 0; flex: 1 1 auto; }
  .cx-tab { flex: 1; }
  .cx-search { order: 2; flex: 1 1 180px; min-width: 0; }
  .cx-sort { order: 3; }
  .cx-sort > span { display: none; }
}
@media (max-width: 520px) { .codex .cx-title { display: none; } }
.cx-jump { display: flex; align-items: center; gap: 6px; max-width: 1240px; margin: 0 auto; padding: 0 var(--cx-pad) 10px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
.cx-jump::-webkit-scrollbar { display: none; }
.cx-links { display: contents; }
.cx-jump a, .cx-kind { flex: none; display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; cursor: pointer; text-decoration: none; font: 700 12px/1.2 var(--ui); letter-spacing: .6px; text-transform: uppercase; color: var(--dim); background: var(--panel); border: 1px solid var(--edge); }
.cx-jump a:hover, .cx-jump a:focus-visible, .cx-kind:hover, .cx-kind:focus-visible, .cx-kind[aria-pressed="true"] { color: var(--ink); background: var(--gold); border-color: var(--gold); outline: none; }
.cx-jump a b, .cx-kind b { margin-left: 5px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.cx-jump a:hover b, .cx-jump a:focus-visible b, .cx-kind:hover b, .cx-kind:focus-visible b, .cx-kind[aria-pressed="true"] b { color: var(--gold-lo); }
.cx-kind[style]::before { content: ''; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; background: var(--c); }
.cx-status { flex: none; margin-left: auto; padding-left: 8px; font: 600 12px/1.2 var(--ui); color: var(--faint); white-space: nowrap; }
.cx-body { flex: 1; min-height: 0; overflow: hidden auto; touch-action: pan-y; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.cx-wrap { max-width: 1240px; margin: 0 auto; padding: 18px calc(var(--cx-pad) + env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) calc(var(--cx-pad) + env(safe-area-inset-left)); }

.cx-formula { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; font: 800 17px/1 var(--ui); letter-spacing: .5px; }
.cx-formula .t { padding: 8px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--edge); }
.cx-formula .ch { color: var(--chips); }
.cx-formula .mu { color: var(--mult); }
.cx-formula .op { color: var(--faint); }
.cx-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px; }
.cx-rule { display: grid; gap: 6px; align-content: start; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--edge); }
.cx-rule h4 { margin: 0; font: 800 13px/1.2 var(--ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
.cx-rule p { margin: 0; font-size: 14px; color: var(--dim); }
.cx-rule p b { color: var(--bone); }
.cx-rule .c-chips { color: var(--chips); font-weight: 800; }
.cx-rule .c-mult { color: var(--mult); font-weight: 800; }
.cx-rule .c-xmult { color: var(--xmult); font-weight: 800; }
.cx-ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.cx-ladder div { padding: 6px 8px; border-radius: 8px; background: var(--panel-2); font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.cx-ladder b { display: block; font: 800 11px/1.3 var(--ui); letter-spacing: 1px; color: var(--bone); }

.cx-sec { padding-top: 30px; }
.cx-sec > header { display: grid; gap: 6px; margin-bottom: 12px; }
.codex h2 { margin: 0; display: flex; align-items: baseline; gap: 12px; font: 400 24px/1.1 var(--display); letter-spacing: 1px; color: var(--gold); }
.cx-n { font: 700 14px/1 var(--ui); letter-spacing: .5px; color: var(--faint); }
.cx-sec > header p { margin: 0; max-width: 72ch; color: var(--dim); }
.codex h3 { margin: 22px 0 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font: 800 13px/1.2 var(--ui); letter-spacing: 1.6px; text-transform: uppercase; color: var(--dim); }
.codex h3 small { font: 500 13px/1.3 var(--ui); letter-spacing: 0; text-transform: none; color: var(--faint); }
.cx-sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); align-self: center; }
.cx-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.cx-chip { --c: var(--dim); display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; cursor: pointer; font: 700 12px/1 var(--ui); letter-spacing: .8px; text-transform: uppercase; color: var(--bone); background: var(--panel); border: 1px solid var(--edge); }
.cx-chip::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.cx-chip.plain::before { display: none; }
.cx-chip[aria-pressed="true"], .cx-chip[aria-checked="true"] { background: color-mix(in srgb, var(--c) 26%, var(--panel)); border-color: var(--c); }
.cx-chip.plain[aria-pressed="true"] { color: var(--ink); background: var(--gold); border-color: var(--gold); }
.cx-chip b { font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.cx-empty { padding: 18px; border: 1px dashed var(--edge); border-radius: 12px; color: var(--faint); text-align: center; }

.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
#cx-bosses .cx-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
@media (max-width: 420px) { .cx-grid, #cx-bosses .cx-grid { grid-template-columns: 1fr; } }
.cx-item { --c: var(--edge); min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 2px solid color-mix(in srgb, var(--c) 55%, var(--panel)); }
.cx-top { display: flex; align-items: center; gap: 10px; }
.cx-ico { flex: none; width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: #0f0b16; border: 1px solid #2c2340; }
.cx-ico canvas { max-width: 38px; max-height: 38px; }
.cx-boss-art { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.cx-name { flex: 1; min-width: 0; font: 400 15px/1.15 var(--display); letter-spacing: 1px; color: #fff; overflow-wrap: anywhere; }
.cx-cost { font: 800 15px/1 var(--ui); color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.cx-pill { --pc: var(--faint); padding: 4px 7px 3px; border-radius: 5px; font: 800 10.5px/1 var(--ui); letter-spacing: 1px; text-transform: uppercase; color: color-mix(in srgb, var(--pc) 70%, #fff); background: color-mix(in srgb, var(--pc) 22%, transparent); border: 1px solid color-mix(in srgb, var(--pc) 55%, transparent); }
.cx-desc { padding: 8px 10px; font-size: 14px; line-height: 1.42; }
.cx-desc b { font-weight: 800; }
.cx-flavor { margin: 0; font-size: 13px; font-style: italic; color: var(--faint); }
/* The story's remnants (v0.52): read, not voted on. */
.cx-rem .cx-ico img { display: block; image-rendering: pixelated; }
.cx-rem .cx-desc i { font-style: italic; }
.cx-rem.locked { opacity: .6; border-style: dashed; }
/* The bitmap face has no question mark. */
.cx-rem-q, .cx-rem.locked .cx-name { font: 800 18px/1 var(--ui); letter-spacing: .2em; color: var(--faint); }
.cx-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.cx-meta b { font-weight: 700; color: var(--bone); }
.cx-evo { display: grid; gap: 4px; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; color: var(--dim); background: color-mix(in srgb, var(--gold) 9%, var(--panel)); border: 1px dashed color-mix(in srgb, var(--gold) 45%, transparent); }
.cx-evo-n { font: 800 13px/1.3 var(--ui); letter-spacing: .8px; color: var(--gold); }
.cx-evo-n i { font-style: normal; font-weight: 600; letter-spacing: 0; color: var(--faint); }
.cx-blind { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; background: #2a1119; border: 1px solid #6a2030; font-size: 13.5px; color: #f3c9cf; }
.cx-blind-n { font: 400 17px/1.1 var(--display); letter-spacing: .5px; color: #ff8a98; }
.cx-moves { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13.5px; }
.cx-moves li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline; }
.cx-tell { padding: 2px 6px; border-radius: 4px; font: 700 11px/1.3 var(--ui); white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent); }
.cx-tell.p { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

/* Likes, dislikes and the comment thread, at the foot of every card. */
.cx-react { display: flex; gap: 6px; margin-top: auto; padding-top: 2px; }
.cx-react button { min-height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; cursor: pointer; font: 700 13px/1 var(--ui); font-variant-numeric: tabular-nums; color: var(--dim); background: #0f0b16; border: 1px solid #2c2340; }
.cx-react svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.cx-react button:hover:not(:disabled) { color: var(--bone); border-color: var(--edge-hi); }
.cx-react button:disabled { cursor: default; opacity: .55; }
.cx-talk { position: relative; margin-left: auto; }
/* New comments since this player last opened the compendium. */
.cx-talk.fresh::after { content: ''; position: absolute; top: -4px; right: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--panel-2); }
.cx-vote[data-v="1"][aria-pressed="true"] { color: var(--good); border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, #0f0b16); }
.cx-vote[data-v="1"][aria-pressed="true"] svg { fill: color-mix(in srgb, var(--good) 40%, transparent); }
.cx-vote[data-v="-1"][aria-pressed="true"] { color: var(--bad); border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, #0f0b16); }
.cx-vote[data-v="-1"][aria-pressed="true"] svg { fill: color-mix(in srgb, var(--bad) 40%, transparent); }
.cx-talk[aria-expanded="true"] { color: var(--gold); border-color: var(--gold); }
.cx-err { margin: 0; font-size: 13px; color: var(--bad); }

/* The newest comment on a card, one line; it opens the thread. */
.cx-peek { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 6px 8px; border-radius: 8px; border: 1px solid #2c2340; background: #0f0b16; cursor: pointer; text-align: left; font: 13px/1.3 var(--ui); color: var(--dim); }
.cx-peek:hover, .cx-peek:focus-visible { border-color: var(--edge-hi); color: var(--bone); outline: none; }
.cx-peek-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-peek-t b { color: var(--bone); }
.cx-peek em { flex: none; font-style: normal; font-weight: 700; color: var(--faint); }

/* A player's initial on a hue of their own. */
.cx-av { --h: 260; flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font: 800 15px/1 var(--ui); color: #fff; background: hsl(var(--h) 42% 40%); box-shadow: inset 0 -2px 0 hsl(var(--h) 45% 27%); text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.cx-av.sm { width: 22px; height: 22px; font-size: 11px; box-shadow: none; }
.cx-new { flex: none; padding: 3px 6px 2px; border-radius: 4px; font: 800 10px/1.1 var(--ui); letter-spacing: .8px; text-transform: uppercase; color: #fff; background: var(--red); }
.cx-ver { padding: 1px 5px; border-radius: 4px; border: 1px solid var(--edge); font-size: 11px; color: var(--faint); }
.cx-by { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; font-size: 12.5px; color: var(--faint); }
.cx-by b { font-size: 13px; color: var(--bone); }

/* Latest from the table: the newest comments anywhere, over the rules. */
.cx-feed { margin-bottom: 26px; }
.cx-feed > header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.codex .cx-feed h2 { font-size: 20px; color: var(--bone); }
.cx-feed-l { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.cx-feed-i { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--edge); background: var(--panel); cursor: pointer; text-align: left; font: 14px/1.4 var(--ui); color: var(--bone); }
.cx-feed-i:hover, .cx-feed-i:focus-visible { border-color: var(--gold); outline: none; }
.cx-feed-i.fresh { border-color: color-mix(in srgb, var(--red) 70%, var(--edge)); }
.cx-feed-b { flex: 1; min-width: 0; display: grid; gap: 3px; }
.cx-feed-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font-size: 12px; color: var(--faint); }
.cx-feed-h b { font-size: 13px; color: var(--bone); }
.cx-feed-h i { font-style: normal; font-weight: 700; color: var(--gold); }
.cx-feed-t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; color: var(--dim); }

/* Suggestions. */
.cx-ideas-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 16px; }
.codex .cx-ideas-head h2 { margin-bottom: 8px; font-size: 26px; }
.cx-ideas-head p { margin: 0; max-width: 70ch; color: var(--dim); }
.cx-suggest { display: inline-flex; align-items: center; gap: 8px; }
.cx-suggest svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.cx-pitch { display: grid; gap: 14px; max-width: 760px; margin-bottom: 20px; padding: 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--edge-hi); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.cx-pitch-k { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cx-lab { display: flex; align-items: baseline; gap: 8px; font: 800 12px/1.2 var(--ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
.cx-pitch-k .cx-lab { flex-basis: 100%; margin-bottom: 2px; }
.cx-lab em { margin-left: auto; font-style: normal; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--faint); }
.cx-field { display: grid; gap: 6px; }
.cx-field input, .cx-field textarea { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--edge); background: #0f0b16; color: var(--bone); font: 500 16px/1.4 var(--ui); outline: none; resize: vertical; }
.cx-field input:focus, .cx-field textarea:focus { border-color: var(--gold); }
.cx-pitch-a { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.cx-ideas-msg { margin: 0 0 14px; padding: 22px; border: 1px dashed var(--edge); border-radius: 12px; text-align: center; color: var(--faint); }
.cx-idea { cursor: pointer; }
.cx-idea:hover { border-color: color-mix(in srgb, var(--c) 85%, var(--panel)); }
.cx-idea .cx-name, .cx-drawer.idea .cx-dr-t h2 { font: 800 17px/1.25 var(--ui); letter-spacing: 0; }
.cx-idea-text { white-space: pre-line; overflow-wrap: anywhere; }
.cx-item.cx-idea .cx-idea-text { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cx-idea.shelved { opacity: .72; }
.cx-item.flash { animation: cx-flash 1.8s ease-out; }
@keyframes cx-flash { 0%, 35% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* The comments panel: a drawer over the right of the compendium, the whole
   width on a phone. The item and its thread scroll; the composer stays put. */
.cx-scrim { position: absolute; inset: 0; z-index: 5; background: rgba(8, 6, 13, .62); }
.cx-drawer { --c: var(--edge); position: absolute; top: 0; right: 0; bottom: 0; z-index: 6; width: min(440px, 100%); display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--edge); box-shadow: -18px 0 44px rgba(0,0,0,.5); padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 0; }
.cx-drawer.in { animation: cx-in .2s ease-out; }
@keyframes cx-in { from { transform: translateX(28px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cx-drawer.in, .cx-item.flash { animation: none; } }
.cx-dr-h { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--edge); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 18%, var(--panel-2)), var(--panel)); }
.cx-dr-t { flex: 1; min-width: 0; display: grid; gap: 6px; }
.codex .cx-dr-t h2 { display: block; font-size: 19px; line-height: 1.15; color: #fff; overflow-wrap: anywhere; }
.cx-dr-kind { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; font: 800 11px/1.2 var(--ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); }
.cx-dr-x { flex: none; align-self: flex-start; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--edge); background: var(--panel-2); color: var(--dim); cursor: pointer; }
.cx-dr-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.cx-dr-x:hover, .cx-dr-x:focus-visible { color: var(--bone); border-color: var(--edge-hi); outline: none; }
.cx-dr-list { flex: 1; min-height: 0; overflow: hidden auto; overscroll-behavior: contain; touch-action: pan-y; padding: 14px 16px 18px; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.cx-dr-about { display: grid; gap: 10px; }
.cx-dr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cx-dr-row .cx-react { margin: 0; padding: 0; }
.cx-set { margin-left: auto; }
.cx-set select { padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.codex .cx-dr-sep { margin: 20px 0 12px; display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; font-size: 11.5px; letter-spacing: 1.4px; color: var(--faint); }
.cx-dr-sep::after { content: ''; flex: 1; height: 1px; background: var(--edge); }
.cx-notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.cx-note { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
.cx-note-h { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 20px; font-size: 12px; color: var(--faint); }
.cx-note-h b { font-size: 14px; color: var(--bone); }
.cx-tag { padding: 2px 6px 1px; border-radius: 4px; font: 800 10px/1.2 var(--ui); letter-spacing: .8px; text-transform: uppercase; color: var(--dim); background: var(--panel-3); }
.cx-tag.op { color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent); }
.cx-note p { margin: 5px 0 0; padding: 9px 12px; border-radius: 3px 12px 12px 12px; background: var(--panel-2); border: 1px solid #3a2f50; font-size: 14.5px; line-height: 1.45; color: var(--bone); white-space: pre-wrap; overflow-wrap: anywhere; }
.cx-note.me p { background: color-mix(in srgb, var(--gold) 8%, var(--panel-2)); border-color: color-mix(in srgb, var(--gold) 30%, #3a2f50); }
.cx-note.fresh p { border-color: color-mix(in srgb, var(--red) 70%, #3a2f50); }
.cx-at { font-weight: 700; color: var(--gold); }
.cx-note-a { display: flex; gap: 16px; margin-top: 4px; padding-left: 2px; }
.cx-note-a button, .cx-del { padding: 3px 0; border: 0; background: none; cursor: pointer; font: 700 12px/1.2 var(--ui); color: var(--faint); }
.cx-note-a button:hover, .cx-note-a button:focus-visible { color: var(--bone); outline: none; }
.cx-note-a .cx-del:hover, .cx-del:hover, .cx-del.armed { color: var(--bad); }
.cx-none { margin: 0; padding: 18px; border: 1px dashed var(--edge); border-radius: 12px; text-align: center; font-size: 14px; color: var(--faint); }
.cx-dr-foot { flex: none; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)) 16px; border-top: 1px solid var(--edge); background: var(--ink); }
.cx-compose-box { display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 12px; border-radius: 14px; border: 1px solid var(--edge); background: var(--panel); }
.cx-compose-box:focus-within { border-color: var(--gold); }
.cx-compose textarea { flex: 1; min-width: 0; height: 38px; max-height: 8.6em; padding: 7px 0; border: 0; resize: none; overflow-y: auto; background: none; color: var(--bone); font: 500 16px/1.4 var(--ui); outline: none; }
.cx-send { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 10px; cursor: pointer; color: #fff; background: var(--green); box-shadow: 0 3px 0 var(--green-lo); }
.cx-send svg { width: 18px; height: 18px; fill: currentColor; }
.cx-send:disabled { cursor: default; color: var(--faint); background: var(--panel-3); box-shadow: none; }
.cx-compose-f { display: flex; align-items: center; gap: 10px; margin-top: 5px; font-size: 12px; color: var(--faint); }
.cx-compose-f .cx-err { font-size: 12.5px; }
.cx-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.cx-count.warn { color: var(--bad); }
.cx-count:empty { display: none; }
@media (pointer: coarse) { .cx-hint { display: none; } }
.cx-signin { margin: 0; padding: 6px 0; text-align: center; font-size: 14px; color: var(--dim); }

/* A phone on its side: the header is one tight row and the title goes. */
@media (max-height: 480px) {
  .cx-bar-in { padding-top: 6px; padding-bottom: 6px; gap: 6px 10px; }
  .codex .cx-title { display: none; }
  .cx-jump { padding-bottom: 6px; }
  .cx-tab { padding: 6px 10px; }
  .cx-sort select { padding-top: 6px; padding-bottom: 6px; }
  .cx-sort > span { display: none; }
  .cx-dr-h { padding: 8px 12px 8px 14px; }
  .cx-dr-h .cx-ico { display: none; }
  .cx-dr-list { padding-top: 10px; }
  .cx-dr-foot { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .cx-hint { display: none; }
}

/* ========================== MOURNING (v0.51) ============================ */
/*
 * The story is a sad one, so the chrome grieves with it: the same layout,
 * shapes and type, repainted in cold slate and ash with blood gone dry, and
 * a grain over every surface like old paper or wet stone. Gameplay colours
 * (Chips, Mult, XMult, rarities) only lose a little saturation, so they
 * still read at a glance. Everything is an override here, so the rules
 * above stay the reference for layout.
 */
:root {
  --ink:      #07090d;
  --felt:     #0f1219;
  --panel:    #161a23;
  --panel-2:  #1d222d;
  --panel-3:  #283040;
  --edge:     #384152;
  --edge-hi:  #56617a;
  --bone:     #e3e0d8;
  --dim:      #9ea4b2;
  --faint:    #687082;

  --red:      #a8384a;  --red-lo:    #561522;
  --orange:   #bb7338;  --orange-lo: #6a3612;
  --green:    #3f8c68;  --green-lo:  #173e2d;
  --blue:     #46709f;  --blue-lo:   #1a2f4c;
  --gold:     #d4b36a;  --gold-lo:   #66512a;

  /* Might is steel and Mult is ember (v0.6): the blue and red were the
     game this borrowed from, not this one. */
  --chips:    #c3cad6;
  --mult:     #dd8544;
  /* Rarities the same way: steel, verdigris, old gold, lilac. */
  --r-common:    #647083;
  --r-uncommon:  #4a9573;
  --r-rare:      #a8843f;
  --r-legendary: #8a6cc0;
  --xmult:    #a88ad2;
  --good:     #74c796;
  --bad:      #e0707c;

  --paper:     #d9d4c8;
  --paper-ink: #22262e;

  /* Film grain and a slow drizzle, drawn once as tiny SVGs. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .8  0 0 0 0 .82  0 0 0 0 .88  0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --stain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .02  0 0 0 0 .03  0 0 0 0 .05  0 0 0 .55 -.12'/%3E%3C/filter%3E%3Crect width='420' height='420' filter='url(%23s)'/%3E%3C/svg%3E");
  --rain: repeating-linear-gradient(104deg, transparent 0 22px, rgba(170, 190, 220, .045) 22px 23px, transparent 23px 61px);
}

#stage { background: radial-gradient(ellipse at 50% 35%, #121620 0%, #030406 100%); }
#frame { box-shadow: 0 0 0 2px #1c212c, 0 30px 90px rgba(0,0,0,.85); }

.panel {
  background: var(--grain), var(--stain), linear-gradient(180deg, #1b2029f5, #11141bf5);
  border-color: var(--edge);
  box-shadow: 0 6px 0 #000c, 0 20px 50px #000a, inset 0 1px 0 #ffffff0a;
}
.inset { background: var(--grain), #0b0d13cc; border-color: #252b37; }
.paper { background: var(--grain), var(--paper); box-shadow: inset 0 -3px 0 #b9b2a3; }

#overlay { background: var(--rain), rgba(5, 7, 11, .78); }
#overlay.clear { background: var(--rain), radial-gradient(ellipse at 50% 45%, rgba(5, 7, 11, .6), rgba(3, 4, 7, .86)); }
#overlay.den { background: #06080c; }
#overlay.den::before {
  background:
    var(--rain),
    radial-gradient(ellipse at 50% 40%, rgba(10, 14, 22, .25), rgba(3, 4, 7, .8) 85%),
    linear-gradient(180deg, rgba(8, 11, 18, .55), rgba(5, 7, 11, .75)),
    url('../assets/images/shop-bg.png') center / cover no-repeat;
  filter: saturate(.55) brightness(.9);
}
/* A cold vignette over the menus and screens, never over the fight. */
#overlay::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, .5) 100%);
}
.btn { background: var(--grain), var(--b); }
.field input, .fb textarea, .cx-field input, .cx-field textarea { background: #0a0c11; border-color: #2a303c; }
/* The title bleeds: dried red over tarnished gold, with a tear of rain
   running down it, and no bright glow. */
.logo .l1 { color: #9a3444; text-shadow: 0 8px 0 #2a0810, 0 0 36px #7a1a2a55; }
.logo .l2 { color: #bda46a; text-shadow: 0 8px 0 #3a2c10, 0 0 36px #8a7a5a33; }
/* A slow drizzle over any screen that covers the fight. */
#overlay::before {
  content: ''; position: absolute; inset: -60px 0 0; pointer-events: none; z-index: -1;
  background: repeating-linear-gradient(100deg, transparent 0 38px, rgba(180, 200, 230, .05) 38px 39px, transparent 39px 97px);
  animation: drizzle 1.6s linear infinite;
}
#overlay.den::before { animation: none; inset: 0; }
@keyframes drizzle { to { transform: translate(-10px, 60px); } }
@media (prefers-reduced-motion: reduce) { #overlay::before { animation: none; } }

/* ============================ TEXTURE (v0.52) ============================ */
/*
 * "Also add more textures to the menus and stuff." Each surface gets the
 * material it would be made of, rather than one noise over everything:
 *   - cards are card stock, so they have a playing card's linen finish;
 *   - panels are old stone and pewter: wear streaks across them, and a
 *     rule cut a few pixels inside the edge, like a carved frame;
 *   - the rules text sits on paper with foxing (the brown age spots);
 *   - buttons are lacquer: grain, and a worn highlight along the top lip;
 *   - stat wells are pressed in, darker at the top where the lip shades them.
 * All drawn once as small tiles (no images to load), all under the text,
 * and faint enough that nothing reads worse. Only the frame's own chrome:
 * the fight itself is untouched.
 */
:root {
  --linen:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .1) 0 1px, transparent 1px 3px);
  --wear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.005 .14' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .85  0 0 0 0 .88  0 0 0 0 .95  0 0 0 .16 -.055'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23w)'/%3E%3C/svg%3E");
  --foxing: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.045' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42  0 0 0 0 .3  0 0 0 0 .16  0 0 0 1.25 -.68'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23f)'/%3E%3C/svg%3E");
  --lip: linear-gradient(180deg, rgba(255, 255, 255, .13) 0 2px, rgba(255, 255, 255, .04) 2px 40%, transparent 40%);
  --well: linear-gradient(180deg, rgba(0, 0, 0, .32), transparent 9px);
}

.panel {
  background: var(--grain), var(--wear), var(--stain), linear-gradient(180deg, #1b2029f5, #11141bf5);
  box-shadow: 0 6px 0 #000c, 0 20px 50px #000a, inset 0 1px 0 #ffffff0a,
    inset 0 0 0 5px #0000001c, inset 0 0 0 6px #ffffff08;
}
.inset { background: var(--well), var(--grain), #0b0d13cc; }
.paper { background: var(--foxing), var(--grain), var(--paper); }
.btn { background: var(--lip), var(--grain), var(--b); }

.card { background: var(--grain), var(--linen), linear-gradient(180deg, #2c2240, #1d1629); }
.card.evolve { background: var(--grain), var(--linen), linear-gradient(180deg, #4a3614, #231a0e); }
.card.ed-negative { background: var(--grain), var(--linen), linear-gradient(180deg, #0a0612, #1c1030); }
.mini { background: var(--grain), var(--linen), linear-gradient(180deg, #2c2240, #1d1629); }
.mini.ed-negative { background: var(--grain), var(--linen), linear-gradient(180deg, #0a0612, #1c1030); }
.mini.empty { background: #0c091266; }
.lvcard { background: var(--grain), var(--linen), linear-gradient(180deg, #2c2240, #1a1426); }

/* The side of the run: the blind is pressed into the column like a stat. */
.side-blind { background: var(--well), var(--grain), #0b0d13cc; }
#tooltip { background: var(--grain), var(--wear), #120d1af7; }

/* The fight's plates are panels like the rest, a little see-through. */
#blindPlate, #scorebox { background: var(--grain), var(--wear), linear-gradient(180deg, #1b2029ee, #11141bee); }
.sb-well { background: var(--well), var(--grain), #0b0d13cc; }
#blindBanner { background: var(--grain), var(--wear), var(--stain), linear-gradient(180deg, #1b2029f5, #11141bf5); }
.bcard { background: var(--grain), var(--wear), linear-gradient(180deg, #1b2029f5, #11141bf5); }
.rp-row, .bs-row, .act-item { background: var(--grain), #0b0d13cc; }
.wslot, .tslot { background: var(--grain), #1a1426e6; }
.wslot.empty, .tslot.empty { background: #0c091288; }
.wslot.evolved { background: var(--grain), radial-gradient(circle, #4a3410 0%, #1a1426 75%); }
#abil .ab { background: var(--grain), radial-gradient(circle at 50% 38%, #2b2140 0%, #150f1f 78%); }

/* ============================== STORY (v0.52) ============================= */
/* The last fight's banner. The story itself has no screen of its own: its
 * remnants lie on the arena floor (story.js) and are read in the compendium. */
#blindBanner.final { --bb: #e0507a; }
#blindBanner.final .bb-name { color: #ff8aa6; }

/* ============================ KNIGHT SELECT (v0.6) ============================ */
/* Before every run: four knights dealt like a level-up. The frames are all
 * the same; the knight in each is his own colour. Nearly opaque, since it
 * can open over a paused fight. */
#overlay.ksel-bg { background: var(--rain), radial-gradient(ellipse at 50% 40%, rgba(12, 10, 18, .92), rgba(4, 4, 8, .97)); }
.ksel .lvcard { height: 352px; }
/* The difficulty (v0.7), a row of toggles between the title and the knights. */
.ksel .lv-head { margin-bottom: 12px; }
.diff-pick { display: flex; flex-direction: column; align-items: center; gap: 7px; margin: 0 0 16px; }
.diff-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.diff-row .btn.small { font-size: 13px; padding: 7px 13px 6px; min-width: 88px; }
.diff-desc { font: 600 14px/1.3 var(--ui); color: var(--dim); min-height: 18px; max-width: 760px; text-align: center; }
.kcard { --slot: var(--edge-hi); }
.kcard .k-perk { --pc: var(--gold); color: #2a1a05; }
.kcard .k-art { height: 138px; position: relative; }
.kcard .k-art canvas { width: 120px; height: 130px; image-rendering: pixelated; }
.kcard .k-ico { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; }
.kcard .k-ico canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.kcard .lv-kind { display: flex; gap: 6px; justify-content: center; }
.kw-grid { display: flex; gap: 16px; align-items: flex-start; justify-content: center; }
.kw-col { display: flex; flex-direction: column; gap: 9px; width: 212px; }
.kw-head { text-align: center; margin-bottom: 2px; }
.btn.kw { display: flex; align-items: center; gap: 10px; font-size: 15px; padding: 6px 12px 5px 8px; text-align: left; }
.btn.kw i, .btn.kw canvas { flex: none; }
/* A weapon the Red Knight has taken: the gold toggle (.btn.ghost.on) with
 * its number, 1 or 2, at the right. */
.btn.kw .kw-n { margin-left: auto; font: 900 15px/1 var(--ui); }
