/* ==========================================================================
   Demonic Defense — site styles
   An 8-bit design system built from the game's own palette: the ember ramp
   from store_assets/generate_assets.py, the rarity and resource colours from
   data/*.json. Nothing is rounded, nothing is smoothed, every border is a
   whole number of pixels, and every sprite renders nearest-neighbour.
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  /* the capsule art's ember ramp */
  --ink: #120503;
  --night: #0a0504;
  --ember-deep: #3a0c05;
  --fire-hi: #fff0b8;
  --fire-mid: #ffae3a;
  --fire-lo: #ee5c16;
  --glow: #ff6014;

  /* surfaces */
  --bg: #0b0708;
  --bg-2: #100a09;
  --panel: #181110;
  --panel-2: #211714;
  --panel-3: #2b1e19;
  --line: #402a22;
  --line-hi: #5c3d2f;

  /* type */
  --text: #ece0cc;
  --dim: #a89076;
  --dimmer: #7a6553;

  /* game accents (data/rarity_colors.json, db.gd) */
  --common: #bfbfbf;
  --rare: #4d99ff;
  --epic: #b366f2;
  --legendary: #ffa61a;
  --soul: #c7dbff;
  --gold: #f5cc40;
  --mana: #66a6ff;
  --heat: #ff9640;
  --frost: #8cd9f2;
  --blood: #d92651;
  --nature: #9ecf72;
  --hostile: #bf3333;
  --ally: #4d99ff;

  --px: 4px;
  --notch: 8px;
  --shell: 1280px;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "JetBrains Mono",
    "Roboto Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --wordmark-ink: var(--ink);
  --wordmark-flat: #f0dcbc;
}

/* ---------------------------------------------------------------- base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* A faint ember haze at the top of every page, echoing the capsule art. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(238, 92, 22, 0.16), transparent 60%),
    radial-gradient(80% 50% at 80% 100%, rgba(58, 12, 5, 0.5), transparent 70%);
}

/* Pixel grain: a 2px checker at very low alpha keeps flat fills from looking
   like flat web fills. Cheap, tiles forever, no image request. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.055) 1px, transparent 1px);
  background-size: 3px 3px, 3px 3px;
}

main,
.topbar,
.footer {
  position: relative;
  z-index: 2;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Every sprite the build renders out of art.gd is a tiny pixel map blown up. */
.px,
img.px {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

a {
  color: var(--fire-mid);
  text-decoration: none;
}
a:hover {
  color: var(--fire-hi);
}

p {
  margin: 0 0 1em;
}

::selection {
  background: var(--fire-lo);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--fire-mid);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--fire-mid);
  color: var(--ink);
  padding: 10px 16px;
  z-index: 100;
}
.skip:focus {
  left: 8px;
  top: 8px;
}

.shell {
  width: min(100% - 40px, var(--shell));
  margin-inline: auto;
}

/* ---------------------------------------------------------------- type */
.wordmark {
  display: block;
  width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.6em;
  letter-spacing: 0.02em;
}

.h2 {
  font-size: clamp(20px, 3vw, 30px);
  text-transform: uppercase;
  color: var(--fire-hi);
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 0.5em;
}
.h2::after {
  content: "";
  flex: 1;
  height: var(--px);
  background: repeating-linear-gradient(
    90deg,
    var(--line-hi) 0 var(--px),
    transparent var(--px) calc(var(--px) * 2)
  );
}

.h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fire-mid);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--dimmer);
  margin: 0 0 10px;
}

.lead {
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--dim);
  max-width: 74ch;
}

.micro {
  font-size: 12px;
  line-height: 1.6;
  color: var(--dimmer);
}

.dim {
  color: var(--dim);
}
.nowrap {
  white-space: nowrap;
}

strong,
b {
  color: var(--fire-hi);
  font-weight: 700;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--ink);
  border: 1px solid var(--line);
  padding: 1px 6px;
  color: var(--fire-mid);
}
kbd {
  box-shadow: 0 2px 0 var(--line);
  color: var(--text);
}

.section {
  padding: 56px 0;
}
.section + .section {
  border-top: 2px solid var(--line);
}

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.5),
    0 var(--px) 0 rgba(0, 0, 0, 0.45);
  padding: 20px;
}
.panel.tone-fire {
  border-color: #6d3a15;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.5),
    inset 0 3px 0 rgba(255, 174, 58, 0.14),
    0 var(--px) 0 rgba(0, 0, 0, 0.45);
}
.panel.tone-soul {
  border-color: #3a4a6b;
}
.panel.tone-flat {
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Auto-fit tracks are written as minmax(min(Npx, 100%), 1fr): the plain
   minmax(Npx, 1fr) form cannot shrink below N and blows the page out
   horizontally on a narrow phone. Same reason every grid child gets
   min-width: 0 — an image or a long word otherwise sets a floor on its track. */
.grid {
  display: grid;
  gap: 18px;
}
.g2 {
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}
.g3 {
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}
.g4 {
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}
.grid > *,
.split > *,
.shots > *,
.card-grid > *,
.hero-in > *,
.beast-layout > * {
  min-width: 0;
}

/* ---------------------------------------------------------------- chips */
.chip {
  --chip: var(--dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  color: var(--chip);
  background: color-mix(in srgb, var(--chip) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 40%, transparent);
  white-space: nowrap;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips img.px {
  vertical-align: -2px;
  margin-right: 3px;
}

/* A chip that's actually a button — the enchant previews in the card
   lightbox. Same face as a static chip, but interactive. */
button.chip {
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.ench-chip:hover,
.ench-chip:focus-visible {
  background: color-mix(in srgb, var(--chip) 34%, transparent);
  color: var(--fire-hi);
  outline: none;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  --btn-bg: var(--panel-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 3px var(--ink);
  filter: drop-shadow(var(--px) var(--px) 0 rgba(0, 0, 0, 0.6));
  clip-path: polygon(
    0 var(--notch), var(--notch) var(--notch), var(--notch) 0,
    calc(100% - var(--notch)) 0, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)),
    calc(100% - var(--notch)) 100%, var(--notch) 100%,
    var(--notch) calc(100% - var(--notch)), 0 calc(100% - var(--notch))
  );
  transition: transform 0.08s steps(2), filter 0.08s steps(2);
}
.btn:hover {
  color: var(--btn-fg);
  transform: translate(-2px, -2px);
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, 0.6));
}
.btn:active {
  transform: translate(2px, 2px);
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0.6));
}
.btn-primary {
  --btn-bg: var(--fire-lo);
  --btn-fg: #fff4dd;
}
.btn-primary:hover {
  --btn-bg: var(--fire-mid);
  --btn-fg: var(--ink);
}
.btn-steam {
  --btn-bg: #1b2838;
  --btn-fg: #c7d5e0;
}
.btn-steam:hover {
  --btn-bg: #2a475e;
  --btn-fg: #fff;
}
.btn-discord {
  --btn-bg: #4b56d1;
  --btn-fg: #eef0ff;
}
.btn-discord:hover {
  --btn-bg: #5865f2;
  --btn-fg: #fff;
}
.btn-ghost {
  --btn-bg: transparent;
  box-shadow: inset 0 0 0 3px var(--line-hi);
}
.btn-ghost:hover {
  --btn-bg: var(--panel-2);
}
.btn-sm {
  padding: 8px 14px;
  font-size: 11px;
  --notch: 6px;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 7, 8, 0.94);
  border-bottom: 2px solid var(--line);
  backdrop-filter: blur(6px);
}
.topbar-in {
  width: min(100% - 32px, 1440px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.brand-mark {
  width: 45px;
  height: 45px;
}
.brand-word {
  height: 32px;
  width: auto;
  image-rendering: pixelated;
}
.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.nav-link:hover {
  color: var(--fire-hi);
  background: var(--panel);
}
.nav-link.is-current,
.nav-group.is-current > .nav-link {
  color: var(--fire-mid);
  border-bottom-color: var(--fire-lo);
}
.nav-group {
  position: relative;
}
.caret {
  font-size: 9px;
  opacity: 0.7;
}
.nav-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 290px;
  background: var(--panel);
  border: 2px solid var(--line-hi);
  box-shadow: 0 var(--px) 0 rgba(0, 0, 0, 0.6);
  padding: 6px;
  display: none;
}
.nav-group:hover .nav-menu,
.nav-group.open .nav-menu {
  display: block;
}
.nav-item {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  border-left: 3px solid transparent;
}
.nav-item b {
  display: block;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: inherit;
}
.nav-item i {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: var(--dimmer);
}
.nav-item:hover,
.nav-item.is-current {
  background: var(--panel-2);
  border-left-color: var(--fire-lo);
  color: var(--fire-hi);
}
.nav-cta {
  margin-left: 10px;
  --notch: 6px;
  padding: 9px 16px;
  font-size: 11px;
}
.nav-burger {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 38px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.nav-burger span {
  display: block;
  width: 20px;
  height: 3px;
  background: var(--fire-mid);
}

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 2px solid var(--line);
  padding: clamp(40px, 7vw, 96px) 0 clamp(36px, 6vw, 76px);
}
.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.42;
  filter: saturate(0.85);
}
.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 7, 8, 0.55) 0%, rgba(11, 7, 8, 0.8) 55%, var(--bg) 100%);
}
.hero-in {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 48px;
  align-items: center;
}
.hero-word {
  max-width: 620px;
  margin-bottom: 22px;
  filter: drop-shadow(0 0 26px rgba(255, 96, 20, 0.45));
}
.hero-tag {
  font-size: clamp(16px, 2vw, 21px);
  color: var(--fire-hi);
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.hero p.lead {
  margin-bottom: 26px;
}
.hero-art {
  position: relative;
  display: flex;
  justify-content: center;
}
.hero-art img {
  width: 100%;
  max-width: min(100%, 520px);
  border: 3px solid var(--ink);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.55), 0 0 60px rgba(255, 96, 20, 0.25);
}
.hero-flame {
  position: absolute;
  inset: -12% -6%;
  background: radial-gradient(closest-side, rgba(255, 96, 20, 0.35), transparent 70%);
  animation: flicker 2.4s steps(4) infinite;
  pointer-events: none;
}
@keyframes flicker {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  25% { opacity: 1; transform: scale(1.04); }
  50% { opacity: 0.6; transform: scale(0.98); }
  75% { opacity: 0.92; transform: scale(1.02); }
}

/* the marching sprite strip under the hero */
.marquee {
  border-block: 2px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  overflow: hidden;
  padding: 12px 0;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track {
  display: flex;
  gap: 34px;
  width: max-content;
  animation: march 100s linear infinite;
}
.marquee-track img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  opacity: 0.8;
}
@keyframes march {
  to { transform: translateX(-50%); }
}

/* ---------------------------------------------------------------- stat counters */
.counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
  gap: 2px;
  background: var(--line);
  border: 2px solid var(--line);
}
.counter {
  background: var(--panel);
  padding: 16px 12px;
  text-align: center;
}
.counter b {
  display: block;
  font-size: clamp(22px, 3vw, 30px);
  color: var(--fire-mid);
  line-height: 1.1;
}
.counter span {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dimmer);
}

/* ---------------------------------------------------------------- feature cards */
.feature {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
  align-items: start;
}
.feature img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.feature h3 {
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fire-hi);
  margin-bottom: 6px;
}
.feature p {
  margin: 0;
  font-size: 13.5px;
  color: var(--dim);
}

/* split media/text rows */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 32px;
  align-items: center;
}
.split.reverse > :first-child {
  order: 2;
}

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  position: sticky;
  top: 62px;
  z-index: 20;
  background: rgba(16, 10, 9, 0.97);
  border: 2px solid var(--line);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
  backdrop-filter: blur(6px);
}
.field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field > label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dimmer);
}
input[type="search"],
input[type="text"],
select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--ink);
  border: 2px solid var(--line);
  padding: 8px 10px;
  min-width: 0;
}
input[type="search"] {
  min-width: 210px;
  flex: 1 1 210px;
}
input:focus,
select:focus {
  border-color: var(--fire-lo);
  outline: none;
}
select {
  cursor: pointer;
}

/* segmented mana/burn switch */
.seg {
  display: inline-flex;
  border: 2px solid var(--line);
  background: var(--ink);
}
.seg button {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 14px;
  background: none;
  border: 0;
  color: var(--dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg button img {
  width: 14px;
  height: 14px;
}
.seg button[aria-pressed="true"] {
  background: var(--panel-3);
  color: var(--fire-hi);
}
.seg button[data-mode="mana"][aria-pressed="true"] {
  color: var(--mana);
  box-shadow: inset 0 -3px 0 var(--mana);
}
.seg button[data-mode="burn"][aria-pressed="true"] {
  color: var(--heat);
  box-shadow: inset 0 -3px 0 var(--heat);
}

.result-count {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--dimmer);
  border: 2px dashed var(--line);
}

/* ---------------------------------------------------------------- support form */
.support-form {
  display: grid;
  gap: 16px;
}
.field-block {
  display: grid;
  gap: 6px;
}
.field-block > label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fire-mid);
}
.field-block > label .micro {
  text-transform: none;
  letter-spacing: normal;
  color: var(--dimmer);
}
.support-form select,
.support-form input[type="text"],
.support-form textarea {
  width: 100%;
}
.support-form textarea {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--ink);
  border: 2px solid var(--line);
  padding: 10px;
  resize: vertical;
  min-height: 120px;
}
.support-form textarea:focus {
  border-color: var(--fire-lo);
  outline: none;
}
.support-form .micro {
  margin: 0;
}
/* Honeypot: present in the DOM and tab-order-skipped (tabindex=-1) so a
   script filling every input still catches it, but invisible and unreachable
   to an actual visitor — off-screen rather than display:none, since some bots
   skip fields hidden that obviously. */
.sf-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.sf-status {
  font-size: 12px;
  letter-spacing: 0.06em;
}
.sf-status[data-state="sending"] {
  color: var(--dimmer);
}
.sf-status[data-state="ok"] {
  color: var(--nature);
}
.sf-status[data-state="error"] {
  color: var(--blood);
}
.support-form[data-sent="true"] .field-block,
.support-form[data-sent="true"] #sf-note {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------------------------------------------------------------- card tile */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(172px, 100%), 1fr));
  gap: 16px;
}
/* An author rule setting `display` always beats the UA [hidden] rule,
   regardless of specificity — origin outranks specificity in the cascade.
   Every element the filters below toggle via the `hidden` IDL property
   (.card, .beast-row) needs its own `&[hidden] { display: none }` for that
   toggle to actually do anything. */
.card {
  --rar: var(--common);
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 3px solid var(--rar);
  box-shadow:
    inset 0 0 0 2px var(--ink),
    0 var(--px) 0 rgba(0, 0, 0, 0.5);
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform 0.1s steps(2), box-shadow 0.1s steps(2);
}
.card[hidden] {
  display: none;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow:
    inset 0 0 0 2px var(--ink),
    0 8px 0 rgba(0, 0, 0, 0.5),
    0 0 22px color-mix(in srgb, var(--rar) 45%, transparent);
  z-index: 2;
}
.card-art {
  position: relative;
  height: 104px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, color-mix(in srgb, var(--rar) 22%, transparent), transparent),
    var(--ink);
  border-bottom: 2px solid color-mix(in srgb, var(--rar) 55%, var(--ink));
}
.card-art img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}
.card-cost {
  position: absolute;
  top: 5px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(10, 5, 4, 0.9);
  border: 2px solid var(--ink);
  line-height: 1;
}
.card-cost img {
  width: 14px;
  height: 14px;
}
.card-cost.mana {
  left: 5px;
  color: var(--mana);
  border-color: color-mix(in srgb, var(--mana) 55%, var(--ink));
}
.card-cost.burn {
  right: 5px;
  color: var(--heat);
  border-color: color-mix(in srgb, var(--heat) 55%, var(--ink));
}
/* The Mana/Burn switch sets data-mode on the grid, so the cost gem for the
   cast you are *not* looking at recedes. */
.card-grid[data-mode="mana"] .card-cost.mana,
.card-grid[data-mode="burn"] .card-cost.burn {
  box-shadow: 0 0 0 2px currentColor;
}
.card-grid[data-mode="mana"] .card-cost.burn,
.card-grid[data-mode="burn"] .card-cost.mana {
  opacity: 0.45;
}
.card-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 7px 6px 5px;
  color: var(--fire-hi);
  background: color-mix(in srgb, var(--rar) 14%, transparent);
  border-bottom: 1px solid var(--line);
  line-height: 1.25;
}
.card-text {
  flex: 1;
  padding: 8px 9px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--dim);
  min-height: 76px;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  color: var(--dimmer);
}
.card-foot .rar {
  color: var(--rar);
  font-weight: 700;
}
.card-badges {
  position: absolute;
  top: 34px;
  right: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card-badges img {
  width: 18px;
  height: 18px;
}
.card .kw,
.card-text .tok {
  font-weight: 700;
}

/* Both casts are rendered into every tile; the toolbar's Mana/Burn switch
   decides which one is showing. Without JS the mana face shows, which is the
   card as you first meet it. */
.card-text[data-face="burn"] {
  display: none;
}
.card-grid[data-mode="burn"] .card-text[data-face="mana"] {
  display: none;
}
.card-grid[data-mode="burn"] .card-text[data-face="burn"] {
  display: block;
}

/* ---------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(5, 3, 3, 0.86);
  backdrop-filter: blur(3px);
}
.lightbox.open {
  display: grid;
}
.lightbox-in {
  position: relative;
  width: min(100%, 780px);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--panel);
  border: 3px solid var(--line-hi);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.6);
}
.lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  background: var(--panel-2);
  color: var(--fire-mid);
  border: 2px solid var(--line);
  cursor: pointer;
  z-index: 2;
}
.lb-head {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 20px;
  padding: 22px;
  border-bottom: 2px solid var(--line);
  background: radial-gradient(closest-side at 12% 50%, color-mix(in srgb, var(--rar, var(--common)) 20%, transparent), transparent);
}
.lb-portrait {
  display: grid;
  place-items: center;
  background: var(--ink);
  border: 3px solid var(--rar, var(--line));
  aspect-ratio: 1;
}
.lb-portrait img {
  width: 84px;
  height: 84px;
  object-fit: contain;
}
.lb-title {
  font-size: clamp(19px, 3vw, 26px);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fire-hi);
  margin: 0 0 8px;
}
.lb-body {
  padding: 22px;
  display: grid;
  gap: 18px;
}
.cast {
  border: 2px solid var(--line);
  background: var(--bg-2);
  padding: 14px 16px;
}
.cast-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.cast-head img {
  width: 18px;
  height: 18px;
}
.cast.mana {
  border-left: 5px solid var(--mana);
}
.cast.mana .cast-head {
  color: var(--mana);
}
.cast.burn {
  border-left: 5px solid var(--heat);
}
.cast.burn .cast-head {
  color: var(--heat);
}
.cast-cost {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--fire-hi);
}
/* Extra cost badges an enchant preview can turn on — Golden's gold,
   Bloodbound's HP. Sit right after cast-cost, so margin-left:auto on that
   element carries this whole cluster to the right edge with it. */
.cast-extra {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
}
/* The [hidden] attribute is how app.js turns these on/off; without this the
   class rule above (same specificity as the UA [hidden] rule, but later in
   the cascade) would win and the badge would never actually disappear. */
.cast-extra[hidden] {
  display: none;
}
.cast-extra img {
  width: 13px;
  height: 13px;
}
.cast-extra.gold {
  color: var(--gold);
}
.cast-extra.hp {
  color: var(--blood);
}
.cast p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

/* The "Enchantable with" heading + instructions and the hovered enchant's
   own description occupy the exact same box, in the exact same place, and
   never shift the chip row below by so much as a pixel either way.
   .ench-static is never removed from flow — only visibility:hidden — so it
   keeps sizing .ench-header (its natural two-line height) whether or not
   it's the thing actually showing. .ench-note is laid on top of that same,
   now-fixed-size box via inset:0, so it can never be taller or shorter than
   the text it's standing in for; overflow:hidden is there only as a safety
   net if some future enchant's description is unusually long. */
.ench-header {
  position: relative;
}
.ench-header.is-active .ench-static {
  visibility: hidden;
}
.ench-note {
  display: none;
}
.ench-header.is-active .ench-note {
  display: flex;
  align-items: center;
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding-left: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  border-left: 3px solid currentColor;
}

/* ---------------------------------------------------------------- bestiary */
.beast-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.beast-list {
  border: 2px solid var(--line);
  background: var(--bg-2);
  max-height: 74vh;
  overflow: auto;
  position: sticky;
  top: 140px;
}
.beast-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.beast-row[hidden] {
  display: none;
}
.beast-row:hover {
  background: var(--panel);
}
.beast-row.is-active {
  background: var(--panel-2);
  border-left-color: var(--fire-lo);
}
.beast-row img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.beast-row b {
  display: block;
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: 0.04em;
}
.beast-row i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.beast-detail {
  display: grid;
  gap: 18px;
}
.beast-panel {
  scroll-margin-top: 150px;
}
/* With JS on, one entry at a time; with JS off the page degrades to the whole
   bestiary printed end to end, which is still perfectly readable. */
.js .beast-panel:not(.is-active) {
  display: none;
}
.beast-hero {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 22px;
  align-items: start;
}
.portrait {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background:
    radial-gradient(closest-side, rgba(255, 96, 20, 0.13), transparent),
    var(--ink);
  border: 3px solid var(--line-hi);
}
.portrait img {
  width: 72%;
  height: 72%;
  object-fit: contain;
}
.stat {
  display: grid;
  grid-template-columns: 92px 1fr 62px;
  gap: 10px;
  align-items: center;
  font-size: 11.5px;
  margin-bottom: 6px;
}
.stat-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dimmer);
  font-size: 10px;
}
.stat-track {
  height: 12px;
  background: var(--ink);
  border: 2px solid var(--line);
  display: block;
  overflow: hidden;
}
.stat-fill {
  display: block;
  height: 100%;
  background: var(--bar);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28);
}
.stat-val {
  text-align: right;
  color: var(--text);
  font-weight: 700;
}
.trait-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.trait-list li {
  position: relative;
  padding-left: 20px;
  font-size: 13px;
  color: var(--dim);
}
.trait-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 6px;
  height: 6px;
  background: var(--fire-lo);
}

/* ---------------------------------------------------------------- tables + dl */
.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--line);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 460px;
}
.tbl th,
.tbl td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.tbl th {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fire-mid);
  background: var(--panel-2);
  white-space: nowrap;
}
.tbl tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.018);
}
.tbl tbody tr:hover {
  background: var(--panel);
}

.dl {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 2px solid var(--line);
}
.dl dt,
.dl dd {
  margin: 0;
  padding: 9px 12px;
  background: var(--panel);
  font-size: 13px;
}
.dl dt {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
  background: var(--panel-2);
  display: flex;
  align-items: center;
}

.cost-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
.cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.cost img {
  width: 16px;
  height: 16px;
}
.cost-row.free {
  color: var(--dimmer);
  font-size: 12px;
}

/* ---------------------------------------------------------------- misc pages */
.hero-card {
  display: grid;
  gap: 14px;
}
.hero-card .portrait {
  aspect-ratio: 4 / 3;
}
.locked {
  color: var(--dimmer);
}

.map-card .map-swatch {
  height: 8px;
  margin: -20px -20px 0;
  border-bottom: 2px solid var(--ink);
}
.map-shot {
  display: block;
  margin: 0 -20px 16px;
  border-bottom: 2px solid var(--line);
  background: var(--ink);
}
.map-shot img {
  width: 100%;
  height: auto;
}
.map-shot:hover {
  filter: brightness(1.15);
}

/* home-page arena gallery */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 16px;
}
.shot {
  position: relative;
  display: block;
  border: 2px solid var(--line);
  background: var(--ink);
  overflow: hidden;
}
.shot img {
  width: 100%;
  height: auto;
  display: block;
}
.shot figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fire-hi);
  background: linear-gradient(180deg, transparent, rgba(10, 5, 4, 0.92));
}

.mods {
  display: grid;
  gap: 4px;
  font-size: 12.5px;
}
.mod {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line);
}
.mod b {
  white-space: nowrap;
}
.mod .up {
  color: var(--nature);
}
.mod .down {
  color: var(--blood);
}

/* patch notes */
.release-layout {
  display: grid;
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}
.release-index {
  position: sticky;
  top: 90px;
}
@media (max-width: 860px) {
  .release-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .release-index {
    position: static;
  }
}
.release {
  border-left: 3px solid var(--line-hi);
  padding-left: 22px;
  margin-left: 8px;
  padding-bottom: 34px;
  position: relative;
}
.release::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 6px;
  width: 15px;
  height: 15px;
  background: var(--fire-lo);
  box-shadow: 0 0 0 3px var(--bg), 0 0 14px var(--glow);
}
.release.latest::before {
  background: var(--fire-hi);
}
.release-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.release-ver {
  font-size: 20px;
  font-weight: 700;
  color: var(--fire-hi);
  letter-spacing: 0.06em;
}
.release-date {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.release h4 {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fire-mid);
  margin: 18px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.release h4::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
}
.release ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}
.release li {
  font-size: 13.5px;
  color: var(--dim);
}
.release li::marker {
  color: var(--line-hi);
}

/* press kit asset grid */
.asset {
  display: grid;
  gap: 10px;
}
.asset-shot {
  display: grid;
  place-items: center;
  padding: 10px;
  background:
    repeating-conic-gradient(#1a1211 0 25%, #141010 0 50%) 0 0 / 20px 20px;
  border: 2px solid var(--line);
  min-height: 130px;
}
.asset-shot img {
  max-height: 190px;
  width: auto;
}
.asset-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--dimmer);
}

/* FAQ */
details.qa {
  border: 2px solid var(--line);
  background: var(--panel);
  margin-bottom: 10px;
}
details.qa > summary {
  cursor: pointer;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--fire-hi);
  list-style: none;
  display: flex;
  gap: 12px;
  align-items: center;
}
details.qa > summary::-webkit-details-marker {
  display: none;
}
details.qa > summary::before {
  content: "+";
  color: var(--fire-lo);
  font-size: 18px;
  width: 14px;
}
details.qa[open] > summary::before {
  content: "\2212";
}
details.qa > div {
  padding: 0 18px 16px 44px;
  color: var(--dim);
  font-size: 13.5px;
}

/* deck lists */
.deck-list {
  display: grid;
  gap: 3px;
}
.deck-row {
  display: grid;
  grid-template-columns: 26px 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  background: var(--bg-2);
  border-left: 3px solid var(--rar, var(--common));
  font-size: 12.5px;
}
.deck-row .qty {
  color: var(--fire-mid);
  font-weight: 700;
  font-size: 11px;
}
.deck-row img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.deck-row .costs {
  display: flex;
  gap: 6px;
  font-size: 11px;
}

.curve {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 70px;
  margin-top: 10px;
}
.curve div {
  flex: 1;
  background: var(--fire-lo);
  position: relative;
  min-height: 2px;
}
.curve div span {
  position: absolute;
  bottom: -18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--dimmer);
}

/* rail of small sprite portraits */
.sprite-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sprite-rail figure {
  margin: 0;
  width: 78px;
  text-align: center;
}
.sprite-rail img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin: 0 auto 4px;
}
.sprite-rail figcaption {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dimmer);
  line-height: 1.3;
}
/* A whole tile linked to its compendium entry (Night's draw, milestone
   bosses) rather than a bare figure — same layout, just clickable. */
.sprite-link {
  display: block;
  color: inherit;
}
.sprite-link:hover img,
.sprite-link:focus-visible img {
  filter: drop-shadow(0 0 6px var(--glow));
}
.sprite-link:hover figcaption,
.sprite-link:focus-visible figcaption {
  color: var(--fire-mid);
}

/* callout */
.callout {
  border-left: 5px solid var(--fire-lo);
  background: var(--panel);
  padding: 16px 20px;
  font-size: 13.5px;
  color: var(--dim);
}
.callout b {
  color: var(--fire-hi);
}

/* CTA band */
.cta {
  border-block: 2px solid var(--line);
  background:
    radial-gradient(80% 140% at 50% 0%, rgba(238, 92, 22, 0.22), transparent 65%),
    var(--bg-2);
  padding: 54px 0;
  text-align: center;
}
.cta .wordmark {
  max-width: 460px;
  margin: 0 auto 18px;
}

/* ---------------------------------------------------------------- footer */
.footer {
  border-top: 2px solid var(--line);
  background: var(--bg-2);
  margin-top: 40px;
}
.footer-in {
  width: min(100% - 40px, var(--shell));
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr);
  gap: 40px;
  padding: 40px 0 28px;
}
.footer-tag {
  color: var(--fire-mid);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  margin: 10px 0 8px;
}
.footer-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 20px;
}
.footer-nav h3 {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dimmer);
  margin-bottom: 10px;
}
.footer-nav a {
  display: block;
  font-size: 13px;
  color: var(--dim);
  padding: 3px 0;
}
.footer-nav a:hover {
  color: var(--fire-mid);
}
.footer-legal {
  border-top: 1px solid var(--line);
  padding: 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dimmer);
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .hero-in {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .hero-art {
    order: -1;
  }
  .beast-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .beast-list {
    position: static;
    max-height: 320px;
  }
}

@media (max-width: 860px) {
  .nav-burger {
    display: flex;
  }
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--panel);
    border-bottom: 2px solid var(--line-hi);
    padding: 10px;
    gap: 2px;
    max-height: calc(100vh - 62px);
    overflow: auto;
  }
  .topbar.open .nav {
    display: flex;
  }
  .nav-link {
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }
  .nav-menu {
    position: static;
    display: block;
    border: 0;
    box-shadow: none;
    background: var(--bg-2);
    padding: 0 0 0 10px;
  }
  .nav-cta {
    margin: 10px 0 0;
    justify-content: center;
  }
  .beast-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  /* stacked, the square portrait would otherwise inflate to the full column */
  .beast-hero .portrait {
    max-width: 200px;
    margin-inline: auto;
  }
  .lb-head {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
  }
  .lb-portrait {
    max-width: 150px;
    margin: 0 auto;
  }
  .footer-in {
    grid-template-columns: minmax(0, 1fr);
  }
  .split.reverse > :first-child {
    order: 0;
  }
  .toolbar {
    top: 0;
  }
}

@media (max-width: 520px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  }
  .brand-word {
    height: 14px;
  }
  .result-count {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .topbar,
  .footer,
  .toolbar,
  .marquee {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
}
