:root {
  --bg: #0b1622;
  --bg-2: #102236;
  --panel: #13283f;
  --panel-2: #1a3350;
  --line: #24425f;
  --text: #eef3f8;
  --muted: #9db0c4;
  --gold: #e8b923;
  --gold-ink: #1b1300;
  --red: #e0384c;
  --ok: #2fbf71;
  --warn: #f2994a;
  --mark: rgba(232, 185, 35, .35);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --tile: #0f1f30;
  --c-red: #e0384c; --c-green: #23a55a; --c-blue: #2f80ed; --c-purple: #9b51e0; --c-black: #8a97a6; --c-yellow: #f2c94c;
  --head-h: 60px;
}
:root[data-theme="light"] {
  --bg: #f6efe0;
  --bg-2: #efe3c8;
  --panel: #fffaf0;
  --panel-2: #f4e9d2;
  --line: #dccaa4;
  --text: #2a1f12;
  --muted: #6e5d45;
  --gold: #b8860b;
  --gold-ink: #fffaf0;
  --red: #c2273a;
  --ok: #1f8a4f;
  --mark: rgba(214, 160, 20, .35);
  --shadow: 0 10px 30px rgba(80, 55, 20, .18);
  --tile: #fffdf7;
  --c-black: #3a3a3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 70% -10%, var(--bg-2), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--gold); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner { max-width: 1680px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand img { width: 40px; height: 40px; border-radius: 50%; display: block; flex-shrink: 0; }
.brand h1 { font-family: "Pirata One", Georgia, serif; font-weight: 400; font-size: 26px; line-height: 1; margin: 0; letter-spacing: .5px; white-space: nowrap; }
.brand h1 span { color: var(--gold); }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-shrink: 0; }
.tabs a { text-decoration: none; color: var(--muted); padding: 6px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--gold); color: var(--gold-ink); }
.theme-toggle .ti { display: flex; }
.search {
  flex: 1 1 300px; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px;
}
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 9px 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; display: none; }
.search.has-text button { display: block; }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px; height: 38px; min-width: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; cursor: pointer; white-space: nowrap;
}
.icon-btn:hover:not(:disabled) { border-color: var(--gold); }
.icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.icon-btn.small { height: 32px; min-width: 32px; padding: 0 8px; font-size: 13px; }
.icon-btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 700; }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.dot { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; font-weight: 700; }
.dot:empty { display: none; }

/* ---------- layout ---------- */
.layout { max-width: 1680px; margin: 0 auto; padding: 14px 16px; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.layout.filters-closed { grid-template-columns: minmax(0, 1fr); }
.layout.filters-closed aside.filters { display: none; }
.layout[data-view="decks"] { grid-template-columns: 270px minmax(0, 1fr) 380px; }
.layout[data-view="decks"].filters-closed { grid-template-columns: minmax(0, 1fr) 380px; }
.deck-panel { display: none; }
.layout[data-view="decks"] .deck-panel { display: block; }
.decks-only, .market-only, .deck-fab { display: none !important; }
.layout[data-view="decks"] .decks-only { display: block !important; }
.layout[data-view="market"] .market-only { display: flex !important; }
main { min-width: 0; }

aside.filters, .deck-panel {
  position: sticky; top: calc(var(--head-h) + 14px); max-height: calc(100vh - var(--head-h) - 28px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; scrollbar-width: thin;
}
aside.filters { padding: 12px 14px 16px; }
.scrim { display: none; }
.tips { margin: 2px 0 6px; font-size: 12.5px; color: var(--muted); }
.tips summary { cursor: pointer; padding: 4px 0; list-style: none; font-weight: 600; width: max-content; }
.tips summary:hover { color: var(--gold); }
.tips summary::-webkit-details-marker { display: none; }
.tip-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px 9px; margin: 4px 0 6px; }
.tip-rows { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; align-items: baseline; }
.tip-rows dt { color: var(--gold); font-weight: 700; font-size: 12px; white-space: nowrap; }
.tip-rows dd { margin: 0; color: var(--text); font-size: 12.5px; }
.tip-label { margin: 10px 0 5px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: var(--muted); }
.tip-box .ex { display: flex; flex-wrap: wrap; gap: 5px; }
.tip-foot { margin: 10px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted); }
.tip-box .ex button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; cursor: pointer;
  font-size: 12px; color: var(--text); line-height: 1.3;
}
.tip-box .ex button:hover { border-color: var(--gold); color: var(--gold); }
.filters-head + .tips + .fgroup { border-top: 0; }
.filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.filters-head h2 { font-family: "Pirata One", Georgia, serif; font-weight: 400; font-size: 22px; margin: 0; }
.link-btn { border: 0; background: none; color: var(--gold); cursor: pointer; padding: 4px; font-weight: 600; font-size: 13px; }
#closeFilters { display: none; }
.fgroup { border-top: 1px dashed var(--line); padding: 10px 0 4px; }
.filters-head + .fgroup { border-top: 0; }
.fgroup h3 { margin: 0 0 7px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.fgroup h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.fgroup h3.fold { cursor: pointer; display: flex; align-items: center; gap: 6px; margin: 0; padding: 2px 0; user-select: none; }
.fgroup h3.fold:hover, .fgroup h3.fold:focus-visible { color: var(--text); outline: 0; }
.fgroup h3.fold::after { content: '▾'; margin-left: auto; font-size: 12px; transition: transform .15s; }
.fgroup.closed h3.fold::after { transform: rotate(-90deg); }
.fgroup .fbody { margin-top: 7px; }
.fgroup.closed .fbody { display: none; }
.fgroup.closed { padding-bottom: 8px; }
.fcount { background: var(--gold); color: var(--gold-ink); border-radius: 999px; font-size: 10.5px; padding: 0 6px; letter-spacing: 0; }
.fcount:empty { display: none; }
.mt { margin-top: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 3px 9px;
  font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; user-select: none;
}
.chip:hover { border-color: var(--gold); }
.chip[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 600; }
.chip .sw { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); }
.chip .sw.multi { background: conic-gradient(var(--c-red) 0 33%, var(--c-blue) 0 66%, var(--c-yellow) 0); }
.chip.num { min-width: 31px; justify-content: center; padding: 3px 7px; }
.chip .x { opacity: .7; }
select.field, input.field, textarea.field {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; outline: 0;
}
select.field:focus, input.field:focus, textarea.field:focus { border-color: var(--gold); }
.field.small { width: auto; padding: 5px 8px; font-size: 13px; border-radius: 9px; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.range span { color: var(--muted); font-size: 13px; }
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.toggle.small { font-size: 13px; color: var(--muted); }
.toggle input { width: 17px; height: 17px; accent-color: var(--gold); margin: 0; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.seg.small button { padding: 3px 9px; font-size: 12.5px; }
.seg svg { width: 16px; height: 16px; display: block; }
#f-art { display: flex; }
#f-art button { flex: 1; }
.show-btn {
  display: none; position: sticky; bottom: 0; width: 100%; margin-top: 12px; border: 0; border-radius: 12px; padding: 12px;
  background: var(--gold); color: var(--gold-ink); font-weight: 700; cursor: pointer; box-shadow: 0 -8px 16px var(--panel);
}

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.count { font-size: 14px; color: var(--muted); }
.count b { color: var(--text); font-size: 18px; }
.count .ex { color: var(--gold); font-weight: 600; }
.active-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.active-tags:empty { display: none; }
.tag { font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 10px; display: inline-flex; align-items: center; gap: 4px; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 14px; line-height: 1; }
.tag button:hover { color: var(--red); }
.hint { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; padding: 9px 12px; margin-bottom: 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.layout[data-view="decks"] .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.card {
  background: var(--tile); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column; position: relative; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--gold); }
.card.in-deck { border-color: var(--gold); }
.card .open { border: 0; padding: 0; background: none; cursor: pointer; text-align: left; display: block; width: 100%; }
.card .open:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.pic { aspect-ratio: 600 / 838; background: var(--panel-2); position: relative; overflow: hidden; }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .2s; }
.pic img.loaded { opacity: 1; }
/* The card pictures have a big white "SAMPLE" printed across the middle (about 38–54% down).
   A second copy of the picture sits on top; the #tameWhite filter (in index.html) keeps only its
   near-white pixels and turns them grey, and the mask limits that to the SAMPLE strip.
   So only the white letters get dimmer; the artwork is untouched. */
.pic img.tame, .d-img img.tame {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none;
  box-shadow: none; background: none; filter: url(#tameWhite);
  -webkit-mask-image: linear-gradient(to bottom, transparent 35%, #000 39%, #000 54%, transparent 58%);
  mask-image: linear-gradient(to bottom, transparent 35%, #000 39%, #000 54%, transparent 58%);
}
.pic img:first-child:not(.loaded) + img.tame { visibility: hidden; }
.d-img { position: relative; align-self: start; }
.d-img.nosample img.tame { display: none; }
.noimg { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; text-align: center; color: var(--muted); font-size: 12px; }
.card .meta { padding: 7px 9px 9px; display: grid; gap: 1px; }
.card .row1 { display: flex; justify-content: space-between; gap: 6px; font-size: 11.5px; color: var(--muted); }
.card .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { color: var(--gold); font-weight: 700; font-size: 12.5px; }
.card .row3 { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.ribbon {
  position: absolute; top: 7px; left: 7px; z-index: 1; max-width: calc(100% - 50px);
  background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  border-radius: 6px; padding: 2px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.ribbon.promo { background: #6c3fc5; }
.ribbon.don { background: #222; border: 1px solid var(--gold); color: var(--gold); }
.badge-own { position: absolute; top: 7px; right: 7px; z-index: 1; background: var(--ok); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 2px 6px; }
.badge-deck { position: absolute; top: 7px; right: 7px; z-index: 1; background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 800; border-radius: 6px; padding: 1px 7px; }
.tier { font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 0 5px; white-space: nowrap; }
.tier.t3 { background: var(--gold); color: var(--gold-ink); }
.tier.t2 { border: 1px solid var(--gold); color: var(--gold); }
.tier.t1 { color: var(--muted); border: 1px solid var(--line); }
.qty { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 7px 8px; }
.qty button {
  flex: 1; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 800; font-size: 16px;
}
.qty button:hover:not(:disabled) { border-color: var(--gold); }
.qty button.add { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.qty b { min-width: 22px; text-align: center; }
.qty .lead { font-size: 13px; font-weight: 700; }
.sentinel { height: 1px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); grid-column: 1 / -1; }
.empty h3 { font-family: "Pirata One", Georgia, serif; font-weight: 400; font-size: 30px; color: var(--text); margin: 0 0 6px; }
.status { text-align: center; padding: 80px 20px; color: var(--muted); }
.spinner { width: 46px; height: 46px; margin: 0 auto 14px; animation: spin 1.4s linear infinite; color: var(--gold); display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- list view ---------- */
.list { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  background: var(--tile); border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; text-align: left; width: 100%;
}
.row:hover { border-color: var(--gold); }
.row .thumb { width: 64px; aspect-ratio: 600 / 838; border-radius: 6px; overflow: hidden; background: var(--panel-2); position: relative; }
.row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .r-title { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.row .r-title b { font-size: 15px; }
.row .r-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.row .r-text { font-size: 13px; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row .r-right { text-align: right; display: grid; gap: 3px; justify-items: end; }
.vtag { font-size: 11px; color: #fff; background: var(--red); border-radius: 5px; padding: 0 6px; font-weight: 700; }
.vtag.promo { background: #6c3fc5; }
.own-tag { font-size: 11px; color: var(--ok); font-weight: 700; }

/* ---------- market ---------- */
.market-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 12px; }
.mcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.mcard small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; margin-bottom: 3px; }
.mcard .big { font-size: 22px; font-weight: 700; color: var(--gold); }
.mcard ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; max-height: 120px; overflow: auto; }
.mcard li { display: flex; justify-content: space-between; gap: 8px; }
.mcard li button { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard li button:hover { color: var(--gold); }
.mrow { grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; }
.mrow .thumb { width: 48px; }
.mrow .r-right .price { font-size: 16px; }
.vs { font-size: 11.5px; color: var(--muted); }
.vrow { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px; }
.vchip { flex: 0 0 auto; display: grid; grid-template-columns: 34px auto; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px 3px 3px; background: var(--panel-2); font-size: 11.5px; cursor: pointer; text-align: left; }
.vchip:hover { border-color: var(--gold); }
.vchip img { width: 34px; aspect-ratio: 600 / 838; object-fit: cover; border-radius: 4px; display: block; }
.vchip b { color: var(--gold); display: block; }

/* ---------- meta (tournament results) ---------- */
.layout[data-view="meta"] { grid-template-columns: minmax(0, 1fr); }
.layout[data-view="meta"] aside.filters, .layout[data-view="meta"] .toolbar, .layout[data-view="meta"] #tags { display: none !important; }
/* overview: filter row */
.mo-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 4px 0 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.mo-ctrl label { display: flex; align-items: center; gap: 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.mo-ctrl .field.small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); }
.mo-num { width: 64px !important; }
.mo-inc input { width: 220px !important; }
.mo-count { margin-left: auto; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.mo-count b { color: var(--text); font-size: 14px; }
/* overview: All Decks banner */
.mo-banner {
  display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 24px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; padding: 0 22px 0 0; margin-bottom: 18px; min-height: 150px;
}
.mo-banner:hover { border-color: var(--gold); }
.mo-banner-art {
  width: 220px; height: 100%; min-height: 150px; align-self: stretch; object-fit: cover; object-position: center 14%; display: block; opacity: .8;
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent); mask-image: linear-gradient(to right, #000 55%, transparent);
}
.mo-banner-text { display: grid; gap: 6px; padding: 16px 0; }
.mo-banner-text b { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.mo-banner-text span { color: var(--muted); font-size: 14px; }
.mo-banner-text small { color: var(--muted); font-size: 12px; }
.mo-pill { font-size: 11px !important; color: var(--text) !important; border: 1px solid var(--gold); border-radius: 999px; padding: 1px 9px; background: color-mix(in srgb, var(--gold) 18%, transparent); }
.mo-go { color: var(--gold); font-weight: 700; white-space: nowrap; }
/* overview: Leader tiles */
.mo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.mo-tile { display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; transition: transform .12s, border-color .12s; }
.mo-tile:hover { border-color: var(--gold); transform: translateY(-2px); }
/* show only the character art at the top of the card (above the SAMPLE print) */
.mo-art { display: block; aspect-ratio: 1 / 1; overflow: hidden; background: var(--panel-2); }
.mo-art img { width: 100%; height: 100%; object-fit: cover; object-position: center top; transform: scale(1.9); transform-origin: 50% 4%; display: block; }
.mo-body { display: grid; gap: 4px; padding: 8px 9px 9px; }
.mo-line { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-width: 0; }
.mo-line b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-line small { color: var(--muted); font-size: 11px; }
.mo-pct { font-weight: 800; font-size: 12.5px; color: var(--gold); white-space: nowrap; }
.mo-foot { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 6px; font-size: 11.5px; color: var(--muted); text-align: center; }
/* Leader page */
.mp-head { text-align: center; margin: 4px 0 18px; }
.mp-crumbs { font-size: 12.5px; color: var(--muted); }
.mp-crumbs span { color: var(--text); font-weight: 600; }
.mp-head h2 { font-size: 30px; margin: 4px 0; font-weight: 800; }
.mp-head p { margin: 0; color: var(--muted); font-size: 14px; }
.mp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.mp-tools #metaCardQ { width: 260px; }
.mp-build { border-color: var(--gold); color: var(--gold); font-weight: 700; }
.mp-src { border-color: #2f80ed; color: #6fa8ff; font-weight: 700; }
.mp-src.on { background: color-mix(in srgb, #2f80ed 18%, transparent); }
.mp-legend { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.mp-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.mp-legend i.staple, .mp-card.staple { --tier: #3fbf5a; }
.mp-legend i.key, .mp-card.key { --tier: #f2994a; }
.mp-legend i.common, .mp-card.common { --tier: #2f80ed; }
.mp-legend i.tech, .mp-card.tech { --tier: #8a97a6; }
.mp-legend i { background: var(--tier); }
.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.mp-card { position: relative; display: flex; flex-direction: column; padding: 0; background: none; border: 0; cursor: pointer; text-align: center; }
.mp-card .pic { border: 3px solid var(--tier); border-radius: 10px; box-shadow: 0 0 12px color-mix(in srgb, var(--tier) 45%, transparent); }
.mp-card:hover .pic { transform: translateY(-2px); }
.mp-copies {
  position: absolute; top: 9px; right: 9px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: #111; color: #fff; font-weight: 800; font-size: 13px; border: 2px solid #fff;
}
.mp-info { display: grid; gap: 3px; justify-items: center; margin-top: 8px; padding: 8px 6px 9px; background: var(--panel); border-radius: 10px; border-top: 3px solid var(--tier); }
.mp-pct { color: var(--tier); font-size: 15px; }
.mp-info small { color: var(--muted); font-size: 11.5px; }
.mp-price { font-size: 12.5px; }
.mp-price b { color: var(--text); }
.mp-hist { display: flex; gap: 4px; margin-top: 2px; }
.mp-hist i { font-style: normal; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--panel-2); color: var(--muted); }
.mp-hist i.some { color: var(--text); }
.mp-hist i.on { background: #2f80ed; color: #fff; }
.noart { display: grid; place-items: center; background: var(--panel); color: var(--muted); font-size: 8px; text-align: center; }
.wr.good, .wr.good b { color: var(--ok); }
.wr.bad, .wr.bad b { color: var(--red); }
.wr.low, .wr.low b { color: var(--muted); }
.meta-note { margin: 8px 2px 0; font-size: 11.5px; color: var(--muted); }
.dl-list { display: grid; gap: 6px; }
.dl-row { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.dl-main { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.dl-place { font-weight: 800; font-size: 13px; color: var(--muted); }
.dl-place.top { color: var(--gold); }
.dl-info b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-info small { color: var(--muted); font-size: 11.5px; }
.dl-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.dl-cards button { border: 0; background: none; text-align: left; padding: 2px 0; cursor: pointer; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-cards button:hover { color: var(--gold); }
.dl-cards small { color: var(--muted); }
.meta-use { margin-top: 2px; }
.meta-use .link-btn { padding: 0; font-weight: 500; }

/* ---------- deck panel ---------- */
.deck-panel { padding: 0; }
.dp-sec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dp-sec:last-child { border-bottom: 0; }
.dp-head { display: flex; gap: 6px; align-items: center; }
.dp-head input { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; outline: 0; }
.dp-head input:hover, .dp-head input:focus { border-color: var(--line); background: var(--panel-2); }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; min-width: 190px; display: grid; }
.menu-list button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.menu-list button:hover { background: var(--panel-2); }
.menu-list button.danger { color: var(--red); }
.leader-box { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: center; }
.leader-box img { width: 62px; border-radius: 6px; display: block; aspect-ratio: 600 / 838; object-fit: cover; cursor: pointer; }
.leader-box .ph { width: 62px; aspect-ratio: 600 / 838; border: 2px dashed var(--line); border-radius: 6px; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.sumline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.pill { font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; background: var(--panel-2); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--red); border-color: var(--red); }
.pill.gold { color: var(--gold); border-color: var(--gold); }
.problems { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; }
.problems li { color: var(--red); display: flex; gap: 6px; }
.problems li.warn { color: var(--warn); }
.dgroup h4 { margin: 10px 0 5px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; }
.dgroup:first-child h4 { margin-top: 0; }
.drow { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 3px 0; }
.drow .cst { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--panel-2); border: 1px solid var(--line); }
.drow .nm { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; min-width: 0; }
.drow .nm b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drow .nm small { color: var(--muted); font-size: 11.5px; }
.drow .nm:hover b { color: var(--gold); }
.drow.bad .nm b { color: var(--red); }
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 800; line-height: 1; padding: 0; }
.stepper button:hover:not(:disabled) { border-color: var(--gold); }
.stepper b { min-width: 20px; text-align: center; font-size: 14px; }
.stepper .rm { margin-left: 4px; color: var(--muted); border-color: transparent; background: none; }
.stepper .rm:hover { color: var(--red); }
.stats h4 { margin: 12px 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stats h4:first-child { margin-top: 0; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 86px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10.5px; color: var(--muted); }
.bars .b i { display: block; width: 100%; background: var(--gold); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b span { margin-top: 2px; }
.bars .b em { font-style: normal; color: var(--text); font-weight: 700; font-size: 11px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.hbar { display: grid; grid-template-columns: 78px 1fr 28px; gap: 6px; align-items: center; font-size: 12.5px; margin: 2px 0; }
.hbar div { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.hbar div i { display: block; height: 100%; background: var(--gold); }
.hbar b { text-align: right; }
.dp-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 16px 6px; }

/* deck gallery */
.dlg-body { padding: 22px; }
.dlg-body h2 { font-family: "Pirata One", Georgia, serif; font-weight: 400; font-size: 30px; margin: 0 0 12px; padding-right: 40px; }
.dg-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.dcard { display: grid; grid-template-columns: 64px 1fr; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px; }
.dcard.current { border-color: var(--gold); }
.dcard img, .dcard .ph { width: 64px; aspect-ratio: 600 / 838; border-radius: 6px; object-fit: cover; display: block; background: var(--panel); }
.dcard h3 { margin: 0; font-size: 15px; }
.dcard .sub { color: var(--muted); font-size: 12.5px; }
.dcard .acts { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.cdots { display: inline-flex; gap: 3px; vertical-align: middle; }
.cdots i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
textarea.field { min-height: 220px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.io-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.muted { color: var(--muted); }

/* ---------- dialogs ---------- */
dialog.sheet {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--panel); color: var(--text);
  width: min(1000px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow);
}
dialog.sheet.wide { width: min(1100px, calc(100vw - 32px)); }
dialog.sheet.narrow { width: min(560px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: rgba(3, 8, 14, .78); }
.d-wrap { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: 22px; padding: 22px; }
.d-img img { width: 100%; border-radius: 14px; display: block; box-shadow: var(--shadow); background: var(--panel-2); aspect-ratio: 600 / 838; object-fit: cover; }
.d-info h2 { font-family: "Pirata One", Georgia, serif; font-weight: 400; font-size: 34px; line-height: 1.05; margin: 0 0 4px; padding-right: 40px; }
.d-sub { color: var(--muted); margin-bottom: 8px; font-size: 14px; }
.d-sub b { color: var(--gold); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 7px; margin: 10px 0; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.stat small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat span { font-weight: 600; }
.d-text { background: var(--panel-2); border-left: 3px solid var(--gold); border-radius: 8px; padding: 11px 14px; white-space: pre-wrap; margin: 10px 0; }
.kw { display: inline-block; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; border-radius: 5px; padding: 0 6px; margin: 0 1px; }
.kw.blue { background: #2f80ed; }
.kw.don { background: #222; color: var(--gold); border: 1px solid var(--gold); }
.kw.hit { outline: 2px solid var(--gold); outline-offset: 1px; }
.d-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.actions { display: grid; gap: 8px; margin: 12px 0; }
.act-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 14px; }
.act-row .lbl { font-weight: 600; margin-right: auto; }
.act-row .lbl small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.d-nav { display: flex; gap: 8px; margin-top: 12px; }
.versions h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 8px; }
.versions .strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.versions button { border: 0; padding: 0; background: none; border-radius: 8px; cursor: pointer; flex: 0 0 auto; width: 78px; text-align: center; color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.versions button img { width: 78px; aspect-ratio: 600 / 838; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 3px; background: var(--panel-2); }
.versions button[aria-current="true"] img { outline: 2px solid var(--gold); outline-offset: 1px; }
.versions button b { color: var(--gold); }
.color-pill { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; }
.color-pill i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; border-radius: 10px; padding: 9px 16px; box-shadow: var(--shadow);
  transition: opacity .15s, transform .15s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.to-top {
  position: fixed; right: 16px; bottom: 16px; z-index: 15; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--gold); color: var(--gold-ink); cursor: pointer; box-shadow: var(--shadow);
  display: none; align-items: center; justify-content: center;
}
.to-top.show { display: flex; }
body:has(.layout[data-view="decks"]) .to-top { right: 412px; }

/* ---------- footer ---------- */
footer { max-width: 1680px; margin: 30px auto 0; padding: 22px 16px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; gap: 14px 30px; flex-wrap: wrap; justify-content: space-between; }
footer p { margin: 0 0 6px; max-width: 780px; }
footer .data { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bottom-nav { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .top-inner { flex-wrap: wrap; }
  .search { order: 5; flex-basis: 100%; }
  :root { --head-h: 108px; }
  .layout[data-view="decks"] { grid-template-columns: minmax(0, 1fr) 340px; }
  .layout[data-view="decks"] aside.filters { display: none; }
  .layout[data-view="decks"].filters-open aside.filters { display: block; }
}
@media (max-width: 1180px) and (min-width: 901px) {
  .layout[data-view="decks"] aside.filters {
    position: fixed; top: 0; left: 0; bottom: 0; width: 320px; max-height: none; z-index: 40; border-radius: 0 16px 16px 0;
  }
  .layout[data-view="decks"].filters-open .scrim { display: block; position: fixed; inset: 0; background: rgba(3, 8, 14, .6); z-index: 35; }
  .layout[data-view="decks"] .show-btn { display: block; }
}
@media (max-width: 900px) {
  :root { --head-h: 104px; }
  .top-inner { gap: 8px 10px; padding: 8px 16px; }
  .tabs { display: none; }
  .brand h1 { font-size: 22px; }
  .brand img { width: 34px; height: 34px; }
  #themeBtn { margin-left: auto; }
  .layout, .layout[data-view="decks"], .layout.filters-closed, .layout[data-view="decks"].filters-closed { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  #closeFilters { display: inline-flex; }
  .show-btn { display: block; }
  aside.filters, .layout.filters-closed aside.filters, .layout[data-view="decks"] aside.filters {
    display: block; position: fixed; top: 0; left: 0; bottom: 0; width: min(340px, 88vw); max-height: none; z-index: 40; border-radius: 0 16px 16px 0;
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .layout.filters-open aside.filters { transform: none; }
  .layout.filters-open .scrim { display: block; position: fixed; inset: 0; background: rgba(3, 8, 14, .6); z-index: 35; }
  .layout[data-view="decks"] .deck-panel {
    position: fixed; inset: auto 0 0 0; top: 0; max-height: none; z-index: 45; border-radius: 0; display: none; padding-bottom: 70px;
  }
  .layout[data-view="decks"].deck-open .deck-panel { display: block; }
  .layout[data-view="decks"] ~ .deck-fab { display: inline-flex !important; }
  .layout[data-view="decks"].deck-open ~ .deck-fab { display: none !important; }
  .deck-fab {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 72px; z-index: 46; border: 0; border-radius: 999px; padding: 10px 18px;
    background: var(--gold); color: var(--gold-ink); font-weight: 800; box-shadow: var(--shadow); cursor: pointer; align-items: center; gap: 8px; white-space: nowrap;
  }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--panel); border-top: 1px solid var(--line);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 5px 0; border-radius: 10px; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a[aria-current="page"] { color: var(--gold); }
  footer { padding-bottom: 90px; }
  .to-top, body:has(.layout[data-view="decks"]) .to-top { bottom: 76px; right: 14px; }
  .d-wrap { grid-template-columns: 1fr; padding: 16px; gap: 14px; }
  .d-img { max-width: 340px; width: 100%; margin: 0 auto; }
  .d-info h2 { font-size: 28px; }
  .toast { bottom: 84px; }
}
@media (max-width: 560px) {
  .grid, .layout[data-view="decks"] .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
  .card .meta { padding: 5px 7px 7px; }
  .card .name { font-size: 12px; }
  .card .row1, .price { font-size: 11px; }
  .ribbon { font-size: 9px; top: 5px; left: 5px; padding: 1px 5px; max-width: calc(100% - 36px); }
  .badge-own, .badge-deck { top: 5px; right: 5px; }
  .qty { padding: 0 5px 6px; }
  .qty button { height: 28px; }
  .toolbar .tools { margin-left: 0; width: 100%; }
  .toolbar .tools .field.small { flex: 1 1 140px; min-width: 0; }
  .row { grid-template-columns: 52px minmax(0, 1fr); }
  .row .thumb { width: 52px; }
  .row .r-right { grid-column: 2; justify-items: start; display: flex; gap: 10px; align-items: center; }
  .mrow { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .mrow .r-right { grid-column: auto; display: grid; justify-items: end; }
  .mo-banner { grid-template-columns: 70px minmax(0, 1fr); padding-right: 12px; min-height: 110px; }
  .mo-banner-art { width: 70px; min-height: 110px; }
  .mo-go { display: none; }
  .mo-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
  .mo-inc input { width: 160px !important; }
  .mo-count { margin-left: 0; }
  .mp-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .mp-tools #metaCardQ { width: 100%; }
  .mp-legend { margin-left: 0; }
  .mp-head h2 { font-size: 23px; }
  .dl-main { grid-template-columns: 54px minmax(0, 1fr); }
  .dl-acts { grid-column: 1 / -1; justify-content: flex-start; }
  dialog.sheet, dialog.sheet.wide, dialog.sheet.narrow { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .d-close { position: fixed; background: var(--panel); box-shadow: var(--shadow); }
  .dlg-body { padding: 16px; }
}
