/* The website Codex (codex/index.php + codex.js, docs/CodexSystem.md "Website"). The game's Northwyn interface on the web:
   thin gilded frames round navy panels, gold titles, a crimson primary action (docs/UIStyle.md), plus the app's motion. */
@font-face { font-family: "Jacquard"; src: url("/assets/fonts/Jacquard24-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Jersey20"; src: url("/assets/fonts/Jersey20-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Jersey15"; src: url("/assets/fonts/Jersey15-Regular.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #080b13;
  --navy: #0d111e;
  --navy-2: #121728;
  --navy-3: #181e31;
  --field: #202436;
  --slate: #2c3243;
  --gold: #e4ab52;
  --gold-hi: #f1be59;
  --gold-pale: #fff4ab;
  --bronze: #6a453c;
  --copper: #956041;
  --outline: #09060b;
  --crimson: #901f30;
  --crimson-hi: #b02a3e;
  --text: #ddd6c8;
  --muted: #9a96a0;
  --dim: #6d6f80;
  --live: #6fd08c;
  --line: rgba(228, 171, 82, 0.22);
  --gilded: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--bronze), inset 0 0 0 2px var(--outline);
  --gilded-gold: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold), inset 0 0 0 2px var(--copper), inset 0 0 0 3px var(--outline);
  --panel: linear-gradient(180deg, rgba(20, 25, 42, 0.96), rgba(13, 17, 30, 0.96));
  --r-common: #e9e6df;
  --r-uncommon: #4ef02c;
  --r-rare: #3f9bff;
  --r-epic: #c06bff;
  --r-legendary: #ff9a2e;
  --top-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 16px); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 19px/1.38 "Jersey20", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(144, 31, 48, 0.18), transparent 60%),
    radial-gradient(900px 500px at 0% 20%, rgba(228, 171, 82, 0.07), transparent 60%),
    linear-gradient(30deg, rgba(255, 255, 255, 0.012) 12%, transparent 12.5%, transparent 87%, rgba(255, 255, 255, 0.012) 87.5%) 0 0 / 64px 32px,
    linear-gradient(150deg, rgba(255, 255, 255, 0.012) 12%, transparent 12.5%, transparent 87%, rgba(255, 255, 255, 0.012) 87.5%) 0 0 / 64px 32px,
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-hi); text-decoration: none; }
a:hover { color: var(--gold-pale); }
img { image-rendering: pixelated; image-rendering: crisp-edges; }
h1, h2 { font-weight: 400; margin: 0; }
h1 { font-family: "Jacquard", "Times New Roman", serif; font-size: 50px; line-height: 1; color: var(--gold); text-shadow: 0 3px 0 var(--outline), 0 0 28px rgba(228, 171, 82, 0.22); }
h2 { font-family: "Jacquard", "Times New Roman", serif; font-size: 30px; line-height: 1.05; color: var(--gold-hi); text-shadow: 0 2px 0 var(--outline); }
p { margin: 0 0 10px; }
kbd { font: 14px "Jersey15", monospace; padding: 0 6px; color: var(--gold-hi); background: var(--field); border: 1px solid var(--outline); box-shadow: inset 0 -2px 0 var(--navy), inset 0 0 0 1px #3a4152; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.cx-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cx-skip { position: absolute; left: -999px; top: 8px; z-index: 50; padding: 6px 12px; background: var(--crimson); color: #fff; }
.cx-skip:focus { left: 8px; }
.cx-noicon { display: inline-block; flex: none; }
::selection { background: rgba(228, 171, 82, 0.35); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--slate); border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Top bar ---------- */
.cx-progress { position: fixed; left: 0; top: 0; z-index: 40; height: 3px; width: 0; background: linear-gradient(90deg, var(--crimson), var(--gold-hi)); box-shadow: 0 0 10px var(--gold); opacity: 0; transition: width .3s var(--ease), opacity .3s; }
.cx-progress.is-on { opacity: 1; }
.cx-top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 18px; padding: 0 24px;
  background: rgba(8, 11, 19, 0.86); backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--outline); box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(0, 0, 0, 0.35);
}
.cx-brand img { display: block; height: 28px; width: auto; image-rendering: auto; }
.cx-title { display: flex; align-items: center; gap: 8px; font-family: "Jacquard", serif; font-size: 30px; color: var(--gold); text-shadow: 0 2px 0 var(--outline); }
.cx-title img { width: 32px; height: 32px; }
.cx-search { position: relative; display: flex; align-items: center; flex: 1 1 auto; max-width: 560px; margin: 0 auto; }
.cx-search input, .cx-bigsearch input, .cx-filter input, .cx-table__filter, .cx-pal__input {
  width: 100%; font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--outline);
  box-shadow: inset 0 2px 0 var(--navy), inset 0 0 0 1px #2e3447; transition: box-shadow .15s, background .15s;
}
.cx-search input { height: 38px; padding: 0 74px 0 38px; font-size: 18px; cursor: pointer; }
.cx-search input:focus, .cx-bigsearch input:focus, .cx-filter input:focus, .cx-table__filter:focus { outline: none; background: #252a3e; box-shadow: inset 0 2px 0 var(--navy), inset 0 0 0 1px var(--gold); }
.cx-search input::placeholder, .cx-bigsearch input::placeholder, .cx-filter input::placeholder { color: var(--dim); }
.cx-search__glass { position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; margin-top: -8px; border: 2px solid var(--muted); pointer-events: none; }
.cx-search__glass::after { content: ""; position: absolute; right: -6px; bottom: -6px; width: 5px; height: 5px; background: var(--muted); }
.cx-search__key { position: absolute; right: 8px; pointer-events: none; }
.cx-toplinks { display: flex; align-items: center; gap: 16px; font-size: 18px; }
.cx-toplinks a:not(.cx-cta) { color: var(--muted); }
.cx-toplinks a:not(.cx-cta):hover { color: var(--gold-pale); }
.cx-cta, .cx-bigsearch button {
  display: inline-flex; align-items: center; padding: 7px 16px; font: inherit; font-size: 18px; color: var(--gold-pale); cursor: pointer;
  background: linear-gradient(180deg, var(--crimson-hi), var(--crimson)); border: 0; box-shadow: var(--gilded-gold); transition: filter .15s, transform .15s;
}
.cx-cta:hover, .cx-bigsearch button:hover { color: #fff; filter: brightness(1.15); }
.cx-menu { display: none; width: 38px; height: 38px; padding: 0; background: var(--slate); border: 0; box-shadow: var(--gilded); cursor: pointer; }
.cx-menu span, .cx-menu span::before, .cx-menu span::after { display: block; width: 18px; height: 2px; margin: 0 auto; background: var(--gold); position: relative; }
.cx-menu span::before, .cx-menu span::after { content: ""; position: absolute; left: 0; }
.cx-menu span::before { top: -6px; }
.cx-menu span::after { top: 6px; }

/* ---------- Shell ---------- */
.cx-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; max-width: 1480px; margin: 0 auto; padding: 28px 24px 56px; }
.cx-shell.has-rail { grid-template-columns: 250px minmax(0, 1fr) 210px; }
.cx-side, .cx-rail { position: sticky; top: calc(var(--top-h) + 20px); align-self: start; max-height: calc(100vh - var(--top-h) - 40px); overflow-y: auto; scrollbar-width: thin; }
.cx-rail { display: none; }
.cx-shell.has-rail .cx-rail { display: block; }
.cx-main { min-width: 0; outline: none; }
.cx-main.is-leaving { opacity: .35; transition: opacity .15s; }
.cx-main.is-entering > * { animation: cx-in .35s var(--ease) both; }
.cx-main.is-entering > *:nth-child(2) { animation-delay: .03s; }
.cx-main.is-entering > *:nth-child(3) { animation-delay: .06s; }
.cx-main.is-entering > *:nth-child(n+4) { animation-delay: .09s; }
@keyframes cx-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Chapters */
.cx-chapters { display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--panel); box-shadow: var(--gilded); }
.cx-chap { position: relative; display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 8px; color: var(--text); font-size: 18px; transition: background .15s, color .15s; }
.cx-chap img, .cx-chap .cx-noicon { width: 28px; height: 28px; flex: none; opacity: .85; transition: transform .2s var(--ease), opacity .15s; }
.cx-chap:hover { background: var(--field); color: var(--gold-pale); }
.cx-chap:hover img { transform: scale(1.08); opacity: 1; }
.cx-chap.is-active { background: linear-gradient(90deg, rgba(228, 171, 82, 0.16), rgba(228, 171, 82, 0.02)); color: var(--gold-pale); }
.cx-chap.is-active::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.cx-chap.is-active img { opacity: 1; }
.cx-recent { margin-top: 14px; padding: 10px 12px; background: var(--panel); box-shadow: var(--gilded); }
.cx-recent h2, .cx-rail h2 { font: 15px "Jersey15", sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-shadow: none; margin-bottom: 6px; }
.cx-recent ul { list-style: none; margin: 0; padding: 0; }
.cx-recent a { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 17px; color: var(--text); }
.cx-recent a:hover { color: var(--gold-pale); }
.cx-recent img { width: 24px; height: 24px; flex: none; object-fit: contain; }
.cx-side__note { margin-top: 14px; padding: 0 4px; font-size: 15px; color: var(--dim); }

/* Rail */
.cx-rail__box { padding: 12px 14px; background: var(--panel); box-shadow: var(--gilded); margin-bottom: 14px; }
.cx-toc { list-style: none; margin: 0; padding: 0; border-left: 1px solid #2a3044; }
.cx-toc a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; border-left: 2px solid transparent; font-size: 17px; color: var(--muted); transition: color .15s, border-color .15s; }
.cx-toc a:hover { color: var(--text); }
.cx-toc a.is-active { color: var(--gold-pale); border-left-color: var(--gold); }
.cx-rail__actions { display: flex; flex-direction: column; gap: 6px; }
.cx-btn { display: block; width: 100%; padding: 6px 10px; text-align: center; font: inherit; font-size: 17px; color: var(--text); cursor: pointer; background: var(--slate); border: 0; box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--copper); transition: color .15s, background .15s; }
.cx-btn:hover { color: var(--gold-pale); background: #353c50; }
.cx-btn.is-done { color: var(--live); }

/* ---------- Shared pieces ---------- */
.cx-kicker { margin: 0 0 4px; font: 15px "Jersey15", sans-serif; text-transform: uppercase; letter-spacing: .12em; color: var(--copper); filter: brightness(1.5); }
.cx-hero__sub { margin: 6px 0 0; font-size: 20px; color: var(--muted); }
.cx-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.cx-tag { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; font: 15px "Jersey15", sans-serif; letter-spacing: .04em; color: #c9cbd6; background: var(--field); border: 1px solid var(--outline); box-shadow: inset 0 0 0 1px #343b4f; }
.cx-tag--live { color: var(--live); background: #12261c; box-shadow: inset 0 0 0 1px #24573a; }
.cx-tag--live i { width: 7px; height: 7px; background: var(--live); box-shadow: 0 0 6px var(--live); animation: cx-pulse 1.8s ease-in-out infinite; }
.cx-tag--guide { color: var(--gold-hi); background: #2a2116; box-shadow: inset 0 0 0 1px #5d4426; }
@keyframes cx-pulse { 50% { opacity: .35; } }
.cx-rar.r-common { color: var(--r-common); }
.cx-rar.r-uncommon { color: var(--r-uncommon); }
.cx-rar.r-rare { color: var(--r-rare); }
.cx-rar.r-epic { color: var(--r-epic); }
.cx-rar.r-legendary { color: var(--r-legendary); }
.cx-tag.cx-rar { background: #161a28; }

.cx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.cx-cards--tight { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cx-card {
  --rc: transparent; position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; color: var(--text);
  background: var(--panel); box-shadow: var(--gilded); transition: transform .18s var(--ease), box-shadow .18s, background .18s;
}
.cx-card::before { content: ""; position: absolute; left: 2px; top: 2px; bottom: 2px; width: 3px; background: var(--rc); }
.cx-card:hover { transform: translateY(-2px); color: var(--text); background: linear-gradient(180deg, rgba(30, 36, 58, 0.98), rgba(17, 22, 38, 0.98)); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold), inset 0 0 0 2px var(--outline), 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 18px rgba(228, 171, 82, 0.12); }
.cx-card__icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; background: radial-gradient(circle at 50% 40%, #2a3045, #161a28); box-shadow: inset 0 0 0 1px var(--outline), inset 0 0 0 2px #2b3144; }
.cx-card--mob .cx-card__icon { width: 72px; height: 72px; background: radial-gradient(ellipse at 50% 85%, rgba(228, 171, 82, 0.18), transparent 60%), radial-gradient(circle at 50% 40%, #232a3e, #121626); }
.cx-card--mob .cx-card__icon img { max-width: 64px; max-height: 64px; width: auto; height: auto; }
.cx-card__text { display: flex; flex-direction: column; min-width: 0; }
.cx-card strong { font-weight: 400; font-size: 19px; color: var(--gold-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-card:hover strong { color: var(--gold-pale); }
.cx-card small { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-card.r-common { --rc: #8c8a85; }
.cx-card.r-uncommon { --rc: var(--r-uncommon); }
.cx-card.r-rare { --rc: var(--r-rare); }
.cx-card.r-epic { --rc: var(--r-epic); }
.cx-card.r-legendary { --rc: var(--r-legendary); }
.cx-card.r-uncommon strong { color: var(--r-uncommon); }
.cx-card.r-rare strong { color: var(--r-rare); }
.cx-card.r-epic strong { color: var(--r-epic); }
.cx-card.r-legendary strong { color: var(--r-legendary); }
.cx-card.is-hidden, .cx-group.is-hidden { display: none; }

/* ---------- Home ---------- */
.cx-home-hero {
  position: relative; overflow: hidden; padding: 44px 40px 34px; margin-bottom: 34px; text-align: center;
  background: linear-gradient(180deg, rgba(8, 11, 19, 0.15), rgba(8, 11, 19, 0.92)), url("/assets/img/hero-bg.png") center 30% / cover no-repeat, var(--navy);
  box-shadow: var(--gilded-gold);
}
.cx-home-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(600px 220px at 50% 0%, rgba(241, 190, 89, 0.18), transparent 70%); }
.cx-home-hero > * { position: relative; z-index: 1; }
.cx-home-hero h1 { font-size: 72px; }
.cx-home-hero__sub { max-width: 640px; margin: 12px auto 22px; font-size: 21px; color: #e7e0cf; text-shadow: 0 2px 0 var(--outline); }
.cx-bigsearch { position: relative; display: flex; max-width: 620px; margin: 0 auto; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5); }
.cx-bigsearch input { height: 52px; padding: 0 16px 0 44px; font-size: 21px; }
.cx-bigsearch .cx-search__glass { left: 16px; }
.cx-bigsearch button { padding: 0 22px; font-size: 20px; }
.cx-popular { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 16px 0 0; font-size: 17px; }
.cx-popular span { color: var(--muted); margin-right: 4px; }
.cx-popular a { padding: 2px 10px; color: var(--text); background: rgba(13, 17, 30, 0.8); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px #4a3a2c; transition: color .15s, box-shadow .15s; }
.cx-popular a:hover { color: var(--gold-pale); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold); }
.cx-home-block { margin-bottom: 36px; }
.cx-home-block > h2 { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cx-home-block > h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold), transparent); box-shadow: 0 1px 0 var(--outline); opacity: .6; }
.cx-chapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.cx-chapcard {
  position: relative; display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto 1fr; column-gap: 14px; padding: 14px; color: var(--text);
  background: var(--panel); box-shadow: var(--gilded); transition: transform .2s var(--ease), box-shadow .2s;
}
.cx-chapcard:hover { transform: translateY(-3px); color: var(--text); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold), inset 0 0 0 2px var(--outline), 0 12px 28px rgba(0, 0, 0, 0.5), 0 0 22px rgba(228, 171, 82, 0.14); }
.cx-chapcard__icon { grid-row: 1 / span 3; display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; background: radial-gradient(circle at 50% 40%, #2a3045, #141826); box-shadow: inset 0 0 0 1px var(--outline), inset 0 0 0 2px #3a3022; }
.cx-chapcard:hover .cx-chapcard__icon img { animation: cx-bob .6s var(--ease); }
@keyframes cx-bob { 40% { transform: translateY(-4px); } }
.cx-chapcard strong { font: 26px/1 "Jacquard", serif; color: var(--gold); text-shadow: 0 2px 0 var(--outline); }
.cx-chapcard__desc { margin-top: 4px; font-size: 16px; line-height: 1.25; color: var(--text); }
.cx-chapcard__sample { margin-top: 6px; font-size: 14px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-classgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cx-classcard { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 18px 14px 16px; color: var(--text); background: radial-gradient(ellipse at 50% 0%, rgba(144, 31, 48, 0.3), transparent 70%), var(--panel); box-shadow: var(--gilded); transition: transform .2s var(--ease), box-shadow .2s; }
.cx-classcard:hover { transform: translateY(-3px); color: var(--text); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold), inset 0 0 0 2px var(--outline), 0 12px 28px rgba(0, 0, 0, 0.5); }
.cx-classcard strong { font: 30px/1 "Jacquard", serif; color: var(--gold); text-shadow: 0 2px 0 var(--outline); }
.cx-classcard span { font-size: 16px; line-height: 1.25; color: var(--muted); }
.cx-mobgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cx-mobcard { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px 12px; text-align: center; color: var(--text); background: var(--panel); box-shadow: var(--gilded); transition: transform .2s var(--ease), box-shadow .2s; }
.cx-mobcard:hover { transform: translateY(-3px); color: var(--text); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold), inset 0 0 0 2px var(--outline), 0 12px 28px rgba(0, 0, 0, 0.5); }
.cx-mobcard__art { display: flex; align-items: flex-end; justify-content: center; width: 100%; height: 112px; padding-bottom: 8px; background: radial-gradient(ellipse 46% 12% at 50% 90%, rgba(0, 0, 0, 0.55), transparent 100%), radial-gradient(ellipse at 50% 80%, rgba(228, 171, 82, 0.12), transparent 65%); }
.cx-mobcard:hover .cx-mobcard__art img { animation: cx-bob .6s var(--ease); }
.cx-mobcard strong { font-weight: 400; font-size: 19px; color: var(--gold-hi); }
.cx-mobcard small { font-size: 15px; color: var(--muted); }
.cx-live { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--panel); box-shadow: var(--gilded); }
.cx-live p { margin: 0; font-size: 17px; color: var(--muted); }
.cx-live strong { font-weight: 400; color: var(--text); }

/* ---------- Chapter and search ---------- */
.cx-chaphead { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; padding: 18px 20px; background: radial-gradient(500px 160px at 0% 0%, rgba(228, 171, 82, 0.12), transparent 70%), var(--panel); box-shadow: var(--gilded); }
.cx-chaphead__icon { display: flex; align-items: center; justify-content: center; width: 84px; height: 84px; flex: none; background: radial-gradient(circle at 50% 40%, #2a3045, #141826); box-shadow: var(--gilded-gold); }
.cx-toolbar { position: sticky; top: var(--top-h); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; margin-bottom: 8px; background: linear-gradient(180deg, var(--bg) 70%, rgba(8, 11, 19, 0)); }
.cx-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.cx-tab { padding: 4px 12px; font-size: 17px; color: var(--muted); background: var(--navy-2); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px #2b3144; transition: color .15s, background .15s, box-shadow .15s; }
.cx-tab:hover { color: var(--text); }
.cx-tab.is-active { color: var(--gold-pale); background: #2a2116; box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold); }
.cx-filter { flex: 1 1 200px; max-width: 320px; margin-left: auto; }
.cx-filter input { height: 34px; padding: 0 10px; font-size: 17px; }
.cx-group { margin-bottom: 22px; }
.cx-group > h2 { margin-bottom: 10px; font-size: 26px; }
.cx-empty { padding: 18px; text-align: center; color: var(--muted); background: var(--panel); box-shadow: var(--gilded); }
.cx-blank { padding: 40px; text-align: center; background: var(--panel); box-shadow: var(--gilded); }
.cx-blank h1 { margin-bottom: 12px; }

/* ---------- Page ---------- */
.cx-crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-size: 16px; color: var(--dim); }
.cx-crumbs a { color: var(--muted); }
.cx-crumbs a:hover { color: var(--gold-pale); }
.cx-crumbs [aria-current] { color: var(--text); }
.cx-hero {
  --rc: var(--gold); position: relative; display: flex; align-items: center; gap: 22px; padding: 20px 22px; overflow: hidden;
  background: radial-gradient(520px 200px at 0% 50%, color-mix(in srgb, var(--rc) 16%, transparent), transparent 70%), var(--panel); box-shadow: var(--gilded-gold);
}
.cx-hero.r-uncommon { --rc: var(--r-uncommon); }
.cx-hero.r-rare { --rc: var(--r-rare); }
.cx-hero.r-epic { --rc: var(--r-epic); }
.cx-hero.r-legendary { --rc: var(--r-legendary); }
.cx-hero.r-uncommon h1, .cx-hero.r-rare h1, .cx-hero.r-epic h1, .cx-hero.r-legendary h1 { color: var(--rc); }
.cx-hero__art { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; flex: none; background: radial-gradient(circle at 50% 40%, #2b3247, #121626); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px color-mix(in srgb, var(--rc) 70%, #000), inset 0 0 0 2px var(--outline), 0 0 24px color-mix(in srgb, var(--rc) 20%, transparent); }
.cx-hero--mob .cx-hero__art { width: 200px; height: 200px; align-items: flex-end; padding-bottom: 18px; background: radial-gradient(ellipse 40% 9% at 50% 88%, rgba(0, 0, 0, 0.6), transparent 100%), radial-gradient(ellipse at 50% 75%, rgba(228, 171, 82, 0.16), transparent 62%), radial-gradient(circle at 50% 40%, #222940, #10131f); }
.cx-hero--mob .cx-hero__art img { animation: cx-idle 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes cx-idle { 50% { transform: scaleY(1.025); } }
.cx-hero__text { min-width: 0; }
.cx-hero h1 { font-size: 54px; overflow-wrap: anywhere; }
.cx-lead { margin: 18px 0 6px; padding-left: 14px; font-size: 22px; line-height: 1.35; color: #ebe4d4; border-left: 3px solid var(--gold); }
.cx-section { margin-top: 26px; }
.cx-section > h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cx-section > h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(228, 171, 82, 0.5), transparent); }
.cx-prose { max-width: 75ch; }
.cx-prose p { font-size: 20px; line-height: 1.45; }
.cx-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 0; }
.cx-stat { position: relative; padding: 10px 12px 9px; background: linear-gradient(180deg, #1e2335, #171b2a); box-shadow: 0 0 0 1px var(--outline), inset 0 1px 0 rgba(255, 255, 255, 0.04), inset 0 0 0 1px #2b3144; transition: box-shadow .15s; }
.cx-stat:hover { box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--bronze); }
.cx-stat dt { font: 14px "Jersey15", sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cx-stat dd { margin: 2px 0 0; font-size: 22px; line-height: 1.15; color: var(--gold-pale); overflow-wrap: anywhere; }
.cx-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 80ch; }
.cx-steps li { display: flex; align-items: flex-start; gap: 12px; font-size: 19px; }
.cx-steps__n { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: none; font-size: 18px; color: var(--gold-pale); background: linear-gradient(180deg, var(--crimson-hi), var(--crimson)); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold); }
.cx-steps li > span:last-child { padding-top: 3px; }
.cx-steps--cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); max-width: none; }
.cx-steps--cards li { flex-direction: column; gap: 8px; padding: 12px; background: var(--panel); box-shadow: var(--gilded); font-size: 18px; }
.cx-steps--cards li > span:last-child { padding: 0; }

.cx-table { background: var(--panel); box-shadow: var(--gilded); }
.cx-table__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; border-bottom: 1px solid var(--outline); box-shadow: 0 1px 0 #20263a; }
.cx-table__bar h2 { font-size: 26px; }
.cx-table__count { font: 15px "Jersey15", sans-serif; color: var(--dim); }
.cx-table__filter { width: 200px; height: 30px; margin-left: auto; padding: 0 10px; font-size: 16px; }
.cx-table__scroll { overflow-x: auto; max-height: 640px; overflow-y: auto; }
.cx-table table { width: 100%; border-collapse: collapse; font-size: 18px; }
.cx-table th { position: sticky; top: 0; z-index: 1; padding: 0; text-align: left; font-weight: 400; background: #1a1f30; box-shadow: inset 0 -1px 0 var(--outline); }
.cx-table th button { display: flex; align-items: center; gap: 6px; width: 100%; padding: 7px 12px; font: 15px "Jersey15", sans-serif; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: none; border: 0; cursor: pointer; white-space: nowrap; }
.cx-table th button:hover { color: var(--gold-pale); }
.cx-sort { width: 0; height: 0; border: 4px solid transparent; opacity: .35; }
[aria-sort="ascending"] .cx-sort { border-bottom-color: var(--gold); border-top-width: 0; opacity: 1; }
[aria-sort="descending"] .cx-sort { border-top-color: var(--gold); border-bottom-width: 0; opacity: 1; }
[aria-sort] button { color: var(--gold-hi); }
.cx-table td { padding: 6px 12px; border-top: 1px solid #191e2d; vertical-align: middle; }
.cx-table tbody tr { transition: background .12s; }
.cx-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.018); }
.cx-table tbody tr[data-href] { cursor: pointer; }
.cx-table tbody tr:hover { background: rgba(228, 171, 82, 0.07); }
.cx-table tbody tr:hover a { color: var(--gold-pale); }
.cx-table__icon { width: 46px; padding-right: 0 !important; }
.cx-table__icon img { display: block; }
.cx-table__none { margin: 0; padding: 14px; text-align: center; color: var(--muted); }
.cx-table mark, .cx-card mark, .cx-pal mark { color: inherit; background: rgba(228, 171, 82, 0.28); }

.cx-spoiler { margin-top: 26px; background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.015) 0 8px, transparent 8px 16px), var(--navy); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px #3a3446; }
.cx-spoiler summary { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; list-style: none; }
.cx-spoiler summary::-webkit-details-marker { display: none; }
.cx-spoiler summary strong { display: block; font: 24px/1.05 "Jacquard", serif; color: #c7a7ff; }
.cx-spoiler summary small { display: block; font-size: 15px; color: var(--muted); }
.cx-spoiler summary:hover strong { color: #e1d0ff; }
.cx-spoiler__lock { position: relative; width: 22px; height: 18px; margin-top: 8px; flex: none; background: #7a5cc0; box-shadow: 0 0 0 1px var(--outline), 0 0 14px rgba(160, 120, 255, 0.4); }
.cx-spoiler__lock::before { content: ""; position: absolute; left: 4px; top: -10px; width: 10px; height: 10px; border: 2px solid #7a5cc0; border-bottom: 0; }
.cx-spoiler__lock::after { content: ""; position: absolute; left: 9px; top: 6px; width: 4px; height: 6px; background: var(--outline); }
.cx-spoiler[open] .cx-spoiler__lock::before { left: 12px; }
.cx-spoiler__body { padding: 0 16px 16px; animation: cx-reveal .45s var(--ease); }
.cx-spoiler__body > h2 { display: none; }
@keyframes cx-reveal { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: none; } }

.cx-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 36px; }
.cx-pager a { display: flex; flex-direction: column; padding: 10px 14px; background: var(--panel); box-shadow: var(--gilded); transition: box-shadow .15s, transform .15s var(--ease); }
.cx-pager a:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold), inset 0 0 0 2px var(--outline); }
.cx-pager small { font: 14px "Jersey15", sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.cx-pager strong { font-weight: 400; font-size: 19px; }
.cx-pager__next { text-align: right; grid-column: 2; }

/* ---------- Search palette (codex.js) ---------- */
.cx-pal { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding: 9vh 16px 16px; background: rgba(4, 6, 11, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: cx-fade .15s ease both; }
.cx-pal[hidden] { display: none; }
@keyframes cx-fade { from { opacity: 0; } }
.cx-pal__box { display: flex; flex-direction: column; width: 100%; max-width: 680px; max-height: 76vh; background: rgba(13, 17, 30, 0.98); box-shadow: var(--gilded-gold), 0 30px 80px rgba(0, 0, 0, 0.7); animation: cx-pop .2s var(--ease) both; }
@keyframes cx-pop { from { opacity: 0; transform: translateY(-10px) scale(.985); } }
.cx-pal__head { position: relative; padding: 12px; border-bottom: 1px solid var(--outline); box-shadow: 0 1px 0 #20263a; }
.cx-pal__head .cx-search__glass { left: 26px; }
.cx-pal__input { height: 48px; padding: 0 70px 0 42px; font-size: 21px; }
.cx-pal__input::-webkit-search-cancel-button { display: none; }
.cx-pal__input:focus { outline: none; box-shadow: inset 0 2px 0 var(--navy), inset 0 0 0 1px var(--gold); }
.cx-pal__esc { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); }
.cx-pal__kinds { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px 0; }
.cx-pal__kinds button { padding: 1px 9px; font: 15px "Jersey15", sans-serif; color: var(--muted); cursor: pointer; background: var(--navy-2); border: 0; box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px #2b3144; }
.cx-pal__kinds button[aria-pressed="true"] { color: var(--gold-pale); background: #2a2116; box-shadow: 0 0 0 1px var(--outline), inset 0 0 0 1px var(--gold); }
.cx-pal__list { flex: 1; overflow-y: auto; margin: 0; padding: 8px; list-style: none; }
.cx-pal__group { padding: 10px 8px 4px; font: 14px "Jersey15", sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); }
.cx-pal__item { display: flex; align-items: center; gap: 12px; padding: 6px 8px; color: var(--text); cursor: pointer; }
.cx-pal__item[aria-selected="true"] { background: linear-gradient(90deg, rgba(228, 171, 82, 0.18), rgba(228, 171, 82, 0.03)); box-shadow: inset 2px 0 0 var(--gold); }
.cx-pal__item .cx-card__icon { width: 36px; height: 36px; }
.cx-pal__item .cx-card__icon img { max-width: 32px; max-height: 32px; width: auto; height: auto; }
.cx-pal__item strong { display: block; font-weight: 400; font-size: 19px; color: var(--gold-hi); }
.cx-pal__item small { display: block; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-pal__item .cx-pal__kind { margin-left: auto; flex: none; font: 14px "Jersey15", sans-serif; color: var(--dim); }
.cx-pal__item > span:nth-child(2) { min-width: 0; }
.cx-pal__empty { padding: 26px; text-align: center; color: var(--muted); }
.cx-pal__foot { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 14px; font-size: 15px; color: var(--dim); border-top: 1px solid var(--outline); box-shadow: inset 0 1px 0 #20263a; }
.cx-pal__foot a { margin-left: auto; }

/* ---------- Link preview (codex.js) ---------- */
.cx-peek { position: fixed; z-index: 55; width: 320px; padding: 12px 14px; pointer-events: none; background: rgba(13, 17, 30, 0.98); box-shadow: var(--gilded-gold), 0 16px 40px rgba(0, 0, 0, 0.6); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s var(--ease); }
.cx-peek.is-on { opacity: 1; transform: none; }
.cx-peek__head { display: flex; align-items: center; gap: 10px; }
.cx-peek__head .cx-card__icon { width: 44px; height: 44px; }
.cx-peek__head .cx-card__icon img { max-width: 40px; max-height: 40px; width: auto; height: auto; }
.cx-peek strong { display: block; font-weight: 400; font-size: 20px; line-height: 1.1; color: var(--gold-hi); }
.cx-peek small { display: block; font-size: 15px; color: var(--muted); }
.cx-peek p { margin: 8px 0 0; font-size: 16px; line-height: 1.3; color: var(--text); }
.cx-peek .r-uncommon strong, .cx-peek strong.r-uncommon { color: var(--r-uncommon); }
.cx-peek strong.r-rare { color: var(--r-rare); }
.cx-peek strong.r-epic { color: var(--r-epic); }
.cx-peek strong.r-legendary { color: var(--r-legendary); }
.cx-toast { position: fixed; left: 50%; bottom: 24px; z-index: 70; padding: 8px 16px; transform: translate(-50%, 20px); opacity: 0; color: var(--gold-pale); background: var(--navy); box-shadow: var(--gilded-gold); transition: opacity .2s, transform .2s var(--ease); }
.cx-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.cx-footer { text-align: center; color: var(--dim); font-size: 16px; padding: 22px 16px 34px; border-top: 1px solid var(--line); }
.cx-footer a { color: var(--muted); }

/* ---------- Narrower screens ---------- */
@media (max-width: 1240px) {
  .cx-shell.has-rail { grid-template-columns: 230px minmax(0, 1fr); }
  .cx-shell.has-rail .cx-rail { display: none; }
}
@media (max-width: 900px) {
  :root { --top-h: 56px; }
  body { font-size: 18px; }
  .cx-top { gap: 10px; padding: 0 16px; }
  .cx-menu { display: block; flex: none; }
  .cx-brand, .cx-toplinks a:not(.cx-cta), .cx-search__key { display: none; }
  .cx-title span { display: none; }
  .cx-search input { padding-right: 10px; }
  .cx-cta { padding: 6px 10px; font-size: 16px; }
  .cx-shell, .cx-shell.has-rail { grid-template-columns: minmax(0, 1fr); padding: 18px 16px 40px; }
  .cx-side { position: fixed; z-index: 30; top: var(--top-h); left: 0; bottom: 0; width: min(300px, 86vw); max-height: none; padding: 14px; background: var(--bg); box-shadow: 1px 0 0 var(--line), 20px 0 50px rgba(0, 0, 0, 0.6); transform: translateX(-105%); transition: transform .25s var(--ease); }
  body.cx-drawer .cx-side { transform: none; }
  body.cx-drawer::after { content: ""; position: fixed; inset: var(--top-h) 0 0; z-index: 25; background: rgba(0, 0, 0, 0.5); }
  h1, .cx-hero h1 { font-size: 40px; }
  .cx-home-hero { padding: 30px 18px 24px; }
  .cx-home-hero h1 { font-size: 50px; }
  .cx-hero { flex-direction: column; align-items: flex-start; gap: 14px; padding: 16px; }
  .cx-hero--mob .cx-hero__art { width: 100%; height: 190px; }
  .cx-chaphead { padding: 14px; gap: 14px; }
  .cx-chaphead__icon { width: 64px; height: 64px; }
  .cx-filter { max-width: none; margin-left: 0; }
  .cx-table__filter { width: 100%; }
  .cx-pal { padding: 0; }
  .cx-pal__box { max-height: 100vh; height: 100%; max-width: none; }
  .cx-peek { display: none; }
}
@media (max-width: 520px) {
  .cx-cta { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
