:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --bg-2: #141922;
  --panel: #1a2030;
  --line: #2c3548;
  --text: #efe8dc;
  --muted: #9aa3b5;
  --gold: #e0b56a;
  --danger: #ff8d8d;
  --ok: #8fd0a8;
  --listed: #e7b15a;
  --warn: #ffb199;
  --tabbar-h: 58px;
  --tabbar-gap: 10px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --fury: #e24b4b;
  --calm: #3aaa6d;
  --mind: #4c86e0;
  --body: #e08a32;
  --chaos: #9a62e0;
  --order: #d6b25a;
  --colorless: #8b93a7;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.03em; }
h2 { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.game-switch { display: flex; gap: 6px; flex: none; }
.game-switch button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.game-switch button.active { background: var(--text); color: #16130f; border-color: transparent; }
.mark { width: 18px; height: 42px; border-radius: 9px; background: linear-gradient(var(--fury), var(--chaos)); }
.eyebrow { color: var(--gold); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }
.tabs { display: flex; gap: 6px; }
.tabs button, .btn, .ghost {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 14px;
}
.tabs button.active { background: var(--text); color: #16130f; border-color: transparent; }
.btn { background: var(--gold); color: #1b140c; border-color: transparent; font-weight: 700; }
.ghost { background: transparent; }
.danger { color: var(--danger); }

main { padding: 8px 20px 96px; max-width: 1120px; margin: 0 auto; }
.layout { display: grid; gap: 16px; }
.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 10px; }
label.field { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); flex: 1; min-width: 140px; }
input, select, textarea {
  background: #0e131c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
textarea { min-height: 120px; width: 100%; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-start; align-items: flex-start; }
.checks label { display: flex; flex-direction: row; gap: 8px; align-items: center; justify-content: flex-start; color: var(--text); white-space: nowrap; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.notice { color: var(--gold); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
/* Card face: a two-tone domain frame (split for dual-domain cards), cost gem, type line, rules, footer. */
.card {
  --d: var(--colorless);
  --d2: var(--d);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  padding: 14px 14px 12px;
  border: 2px solid transparent;
  border-radius: 16px;
  background:
    radial-gradient(120% 70% at 0% 0%, color-mix(in srgb, var(--d) 22%, transparent), transparent 60%),
    linear-gradient(180deg, #1d2433, #121721 55%) padding-box,
    linear-gradient(135deg, var(--d) 0%, color-mix(in srgb, var(--d) 35%, #2c3548) 45%, color-mix(in srgb, var(--d2) 35%, #2c3548) 55%, var(--d2) 100%) border-box;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  overflow: hidden;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px color-mix(in srgb, var(--d) 40%, transparent); }
.card.signature { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32), 0 0 18px color-mix(in srgb, var(--gold) 35%, transparent); }
.card.signature { padding-top: 24px; }
.card.signature::after {
  content: "Signature";
  position: absolute; top: 0; right: 14px;
  padding: 2px 8px 3px;
  border-radius: 0 0 8px 8px;
  background: var(--gold); color: #1b140c;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
}
.card.banned { filter: saturate(0.45); }
.kept-split { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.78rem; }
.kept-chip { border-radius: 999px; padding: 2px 9px; background: rgba(143, 208, 168, 0.14); color: var(--ok); border: 1px solid rgba(143, 208, 168, 0.4); font-weight: 700; }
.card.legend-face { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32), 0 0 0 1px color-mix(in srgb, var(--gold) 55%, transparent), 0 0 22px color-mix(in srgb, var(--gold) 22%, transparent); }
.card.legend-face .type-icon { color: var(--gold); }
.deck-row.legend-row { border-left-color: var(--gold); background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 12%, #121722), #121722 50%); }
.mini-cost.legend-mark { background: color-mix(in srgb, var(--gold) 85%, #000); color: #1b140c; }
.legend-note { color: var(--muted); font-size: 0.74rem; white-space: nowrap; padding-right: 4px; }
.card header { display: flex; gap: 10px; align-items: center; }
.card .title { min-width: 0; flex: 1; }
.cost {
  flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--d) 55%, #fff), var(--d) 60%, color-mix(in srgb, var(--d) 70%, #000));
  color: #140f0c; font-weight: 800; font-size: 1.02rem;
  box-shadow: 0 0 0 2px #0c0f14, 0 0 0 3px color-mix(in srgb, var(--d) 60%, transparent);
}
.name { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.08rem; line-height: 1.15; }
.subtitle { color: var(--muted); font-size: 0.8rem; font-style: italic; margin-top: 2px; }
.ban { flex: none; border-radius: 6px; padding: 2px 6px; background: rgba(255, 141, 141, 0.16); color: var(--danger); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.type-line {
  display: flex; gap: 6px; align-items: center;
  padding: 5px 8px; border-radius: 8px;
  background: color-mix(in srgb, var(--d) 12%, #0e131c);
  color: color-mix(in srgb, var(--d) 45%, var(--text));
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.type-icon { flex: none; color: var(--d); }
.meta, .rules, .reason { color: var(--muted); font-size: 0.82rem; }
.rules { color: #d9d3c7; line-height: 1.45; flex: 1; }
.rules .kw { display: inline-block; padding: 0 6px; border-radius: 5px; background: rgba(239, 232, 220, 0.1); color: var(--text); font-weight: 700; font-size: 0.76rem; letter-spacing: 0.02em; }
.rules .sym { display: inline-grid; place-items: center; min-width: 1.15em; height: 1.15em; padding: 0 2px; border-radius: 4px; background: #2c3548; color: var(--text); font-size: 0.7rem; font-weight: 800; vertical-align: 0.05em; }
.rules .sym.gem { border-radius: 50%; background: color-mix(in srgb, var(--d) 70%, #222); color: #140f0c; }
.rules .reminder { color: var(--muted); font-style: italic; }
.reason { color: var(--gold); }
.card-foot { display: flex; gap: 8px; align-items: center; font-size: 0.74rem; color: var(--muted); border-top: 1px solid rgba(154, 163, 181, 0.14); padding-top: 8px; }
.card-foot .domains { display: flex; gap: 3px; }
.card-foot .dot { display: block; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.card-foot .set { margin-left: auto; display: flex; gap: 5px; align-items: center; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.stat { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px 1px 5px; border-radius: 999px; background: #0e131c; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat::before { content: ""; width: 10px; height: 10px; background: currentColor; }
.stat.might::before { color: #e8a87c; clip-path: polygon(50% 0, 62% 62%, 100% 70%, 62% 78%, 50% 100%, 38% 78%, 0 70%, 38% 62%); }
.stat.power::before { color: #9fc3ff; clip-path: polygon(55% 0, 20% 58%, 46% 58%, 38% 100%, 82% 38%, 54% 38%); }
.rarity { display: block; width: 8px; height: 8px; transform: rotate(45deg); background: #6b7385; }
.rarity.uncommon { background: #8fd0a8; }
.rarity.rare { background: #6aa8ff; }
.rarity.epic { background: #c08cff; }
.rarity.showcase { background: linear-gradient(135deg, #ffd27a, #ff8de0, #7ad8ff); }
.card-extra { display: grid; gap: 8px; }
.card .art {
  margin: -14px -14px 0;
  width: calc(100% + 28px);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center 22%;
  border-radius: 0;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(231, 177, 90, 0.16);
  color: var(--listed);
  font-size: 0.75rem;
}
.flag-listed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  background: rgba(255, 107, 74, 0.16);
  color: var(--warn);
  border: 1px solid rgba(255, 138, 91, 0.55);
  font-size: 0.78rem;
  line-height: 1.3;
}
.warn-icon { flex: none; display: block; }
.shop { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.shop li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: baseline; }
.shop .price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shop .price.none { color: var(--muted); }
.cost-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.cost-line .no-price { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.stepper { display: flex; gap: 6px; align-items: center; }
.stepper button { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: #10151f; }

.deck-layout { display: grid; gap: 16px; }
.side { display: grid; gap: 12px; align-content: start; }
/* Deck dashboard */
.deck-hero {
  --d: var(--gold);
  --d2: var(--d);
  border: 2px solid transparent;
  background:
    radial-gradient(140% 80% at 0% 0%, color-mix(in srgb, var(--d) 20%, transparent), transparent 65%),
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    linear-gradient(135deg, var(--d), color-mix(in srgb, var(--d) 30%, #2c3548) 50%, var(--d2)) border-box;
}
.deck-hero #deck-name { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.2rem; background: rgba(14, 19, 28, 0.7); }
.legend-name { display: flex; gap: 6px; align-items: center; color: var(--text); }
.legend-name .type-icon { color: var(--gold); }
.count-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.count-chip { border-radius: 999px; padding: 3px 9px; font-size: 0.78rem; background: #0e131c; border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.count-chip b { color: var(--text); }
.count-chip.ok { border-color: rgba(143, 208, 168, 0.45); }
.count-chip.off { border-color: rgba(255, 141, 141, 0.55); }
.count-chip.off b { color: var(--danger); }
.legal { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.legal::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }

.completion { display: grid; gap: 12px; }
.completion-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.completion .headline { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.25rem; margin-top: 4px; }
.to-complete { color: var(--muted); }
.to-complete strong { color: var(--gold); font-size: 1.15rem; }
.meter { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #0e131c; gap: 2px; }
.meter .seg { display: block; height: 100%; transition: width 300ms ease; }
.meter .seg:empty[style*="width:0%"] { display: none; }
.seg.owned, .meter-key .owned { background: linear-gradient(90deg, #5fae80, var(--ok)); }
.seg.listed, .meter-key .listed { background: var(--listed); }
.seg.missing, .meter-key .missing { background: repeating-linear-gradient(135deg, #4a3a3a 0 4px, #6b4848 4px 8px); }
.meter-key { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.meter-key li { display: flex; gap: 6px; align-items: center; }
.meter-key i { display: block; width: 10px; height: 10px; border-radius: 3px; }
.meter-key b { color: var(--text); font-variant-numeric: tabular-nums; }

.dash { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-curve { grid-column: 1 / -1; }
@media (max-width: 600px) { .dash { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 1240px) { .dash { grid-template-columns: 1.3fr 1fr 1fr; } .dash-curve { grid-column: auto; } }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; }
.bars .bar { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.bars .count { color: var(--text); font-size: 0.78rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.bars .bar.short .count { color: var(--warn); }
.bars .well { position: relative; width: 100%; }
.bars .well span { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 6px 6px 2px 2px; }
.bars .target { border: 1px dashed rgba(239, 232, 220, 0.35); background: rgba(239, 232, 220, 0.05); }
.bars .fill { left: 18%; right: 18%; background: linear-gradient(var(--gold), #8a6230); }
.bars .bar.short .fill { background: linear-gradient(#e0b56a, #6b4f2a); opacity: 0.85; }
.bars .bar.over .fill { background: linear-gradient(#f0c987, #a8722f); }
.bars i { display: block; text-align: center; color: var(--muted); font-style: normal; font-size: 0.72rem; }
.chart-key { display: flex; gap: 6px; align-items: center; font-size: 0.74rem; color: var(--muted); }
.chart-key span { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart-key .key-fill { background: var(--gold); }
.chart-key .key-target { margin-left: 8px; border: 1px dashed rgba(239, 232, 220, 0.5); }

.donut-wrap { display: flex; gap: 14px; align-items: center; }
.donut { width: 120px; height: 120px; flex: none; }
.donut circle { transition: stroke-dasharray 300ms ease; }
.donut-total { fill: var(--text); font-family: Georgia, "Iowan Old Style", serif; font-size: 22px; font-weight: 600; }
.donut-label { fill: var(--muted); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.85rem; min-width: 0; flex: 1; }
.legend li { display: flex; gap: 8px; align-items: center; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend .dot { display: block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

.types { display: grid; gap: 12px; }
.type-row { display: grid; grid-template-columns: 76px 1fr auto; grid-template-areas: "name track count" ". note note"; gap: 2px 10px; align-items: center; }
.type-name { grid-area: name; display: flex; gap: 6px; align-items: center; font-size: 0.85rem; }
.type-name .type-icon { color: var(--muted); }
.track { grid-area: track; position: relative; height: 10px; border-radius: 999px; background: #0e131c; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width 300ms ease; }
.track .fill.type-unit { background: linear-gradient(90deg, #8a6230, var(--gold)); }
.track .fill.type-spell { background: linear-gradient(90deg, #2f5696, #7aa6ef); }
.track .fill.type-gear { background: linear-gradient(90deg, #4d5566, #a6afc2); }
.track .marker { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; box-shadow: 0 0 0 2px var(--bg-2); }
.type-count { grid-area: count; font-variant-numeric: tabular-nums; }
.type-count small { color: var(--muted); margin-left: 3px; }
.type-note { grid-area: note; font-size: 0.74rem; color: var(--warn); }
.type-note.ok { color: var(--ok); }
@media (prefers-reduced-motion: reduce) { .meter .seg, .track .fill, .donut circle { transition: none; } }
.issues { display: grid; gap: 6px; }
.issues p { padding: 8px 10px; border-radius: 10px; background: rgba(255, 141, 141, 0.08); }
.issues .warn { background: rgba(224, 181, 106, 0.08); color: var(--gold); }

dialog {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 18px;
  padding: 18px;
  width: min(420px, calc(100vw - 32px));
}
dialog form { display: grid; gap: 10px; }
footer { padding: 8px 20px 28px; color: var(--muted); font-size: 0.78rem; max-width: 1120px; margin: 0 auto; }
.mtg-shell { display: grid; gap: 16px; }
.mtg-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mtg-hit, .mtg-printing {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  border: 1px solid var(--line); background: #121722; border-radius: 14px; padding: 8px 10px;
}
.mtg-hit { cursor: pointer; }
.mtg-hit.active { border-color: var(--gold); }
.mtg-thumb { width: 52px; height: auto; border-radius: 4px; flex: none; background: #0e131c; }
.mtg-filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.mtg-filters .field { min-width: 0; }
.mtg-filters select, .mtg-filters input { width: 100%; }
.mtg-color-field { display: grid; gap: 6px; }
.mtg-color-field > span { color: var(--muted); font-size: 0.78rem; }
.mtg-colors { display: flex; gap: 6px; flex-wrap: wrap; }
.mtg-colors .pip {
  width: 32px; height: 32px; border-radius: 50%; padding: 0; font-weight: 800; border: 2px solid transparent;
}
.mtg-colors .pip.on, .mtg-colors .pip[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 2px; }
.pip-W { background: #f3ead2; color: #1b140c; }
.pip-U { background: #4c86e0; color: #fff; }
.pip-B { background: #2a2433; color: #efe8dc; border-color: #5c5470; }
.pip-R { background: #e24b4b; color: #fff; }
.pip-G { background: #3aaa6d; color: #fff; }
.pip-C { background: #8b93a7; color: #16130f; }
.mtg-page { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.editor-search { min-width: 0; }
[data-mtg-preview] { cursor: help; }
[data-mtg-preview] button, [data-mtg-preview] select, [data-mtg-preview] a { cursor: pointer; }
.mtg-hero { display: grid; gap: 8px; justify-items: start; }
.mtg-hero img { width: min(260px, 100%); border-radius: 12px; background: #0e131c; }
.mtg-unmatched { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mtg-unmatched li { display: grid; gap: 2px; }
.pop-inner.mtg-pop .pop-art img { aspect-ratio: 488 / 680; object-fit: contain; background: #0e131c; }
@media (max-width: 600px) {
  .pop-inner.mtg-pop.has-art { grid-template-columns: minmax(0, 1fr); }
  .pop-inner.mtg-pop .pop-art img { width: auto; max-height: 48vh; margin: 0 auto; }
}
.mtg-hit-body, .mtg-detail { display: grid; gap: 4px; min-width: 0; }
.mtg-hit-body b, .mtg-detail h2 { font-weight: 700; }
.mtg-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.legality { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--line); }
.legality.ok { color: var(--ok); border-color: rgba(143, 208, 168, 0.45); }
.legality.banned { color: var(--danger); border-color: rgba(255, 141, 141, 0.45); }
.scryfall-credit { font-size: 0.78rem; }
.mtg-printings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mtg-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mtg-line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  background: #121722;
  border-radius: 14px;
  padding: 8px 10px;
}
.mtg-line select { width: 100%; padding: 6px 8px; }
.mtg-hit .btn, .mtg-actions { flex: none; }
.mtg-actions { display: flex; gap: 6px; align-items: center; }
.mtg-commander { border-color: var(--gold); }
.bars.mtg-curve { grid-template-columns: repeat(8, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .mtg-line { grid-template-columns: 40px minmax(0, 1fr); }
  .mtg-line .stepper { grid-column: 1 / -1; }
}
.art { width: 100%; border-radius: 10px; display: block; }

.panel.to-build { box-shadow: inset 3px 0 0 var(--gold), var(--shadow); }
.deck-list { display: grid; gap: 8px; }
.deck-list-item { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.deck-list-item .deck-open { flex: 1 1 12rem; text-align: left; }

.build-layout { align-items: start; }
.build-layout > * { min-width: 0; }
.build-form { min-width: 0; }
.build-form .field { width: 100%; min-width: 0; flex: none; }
.build-form select,
.build-form input:not([type="checkbox"]) { width: 100%; max-width: 100%; min-width: 0; field-sizing: fixed; }
.build-form .checks { flex-direction: column; align-items: flex-start; gap: 8px; }
.build-form .checks label { width: max-content; max-width: 100%; }
.build-form .checks input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  margin: 0;
  padding: 0;
  flex: none;
}
.how-card { height: fit-content; align-self: start; }

@media (min-width: 900px) {
  .deck-layout { grid-template-columns: 280px 1fr; }
  .build-layout { grid-template-columns: 340px 1fr; align-items: start; }
}
@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; }
  h1 { font-size: 1.28rem; }
  .brand { padding-right: 56px; }
  .tabs {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(var(--tabbar-gap) + env(safe-area-inset-bottom, 0px));
    background: #121722;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 6px;
    z-index: 6;
    justify-content: space-between;
  }
  .tabs button { flex: 1; min-height: 44px; padding: 10px 6px; }
  main,
  footer {
    padding-bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + env(safe-area-inset-bottom, 0px) + 16px);
  }
}

button:disabled { opacity: 0.45; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
a { color: var(--gold); }

/* Deck modes */
.mode-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #0e131c; border: 1px solid var(--line); width: fit-content; max-width: 100%; }
.mode-tabs button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 14px; font-weight: 600; white-space: nowrap; }
.mode-tabs button.active { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* Hand simulator */
.draw-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card.compact { min-height: 0; gap: 8px; padding: 12px 12px 10px; }
.card.compact .name { font-size: 0.98rem; }
.card.compact .rules { font-size: 0.76rem; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.card.compact .card-foot { font-size: 0.7rem; }
.card[data-hand] { cursor: pointer; }
.card[data-hand]:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.card.selected { transform: translateY(-8px) rotate(-1.5deg); opacity: 0.6; box-shadow: 0 0 0 2px var(--warn), 0 14px 28px rgba(0, 0, 0, 0.45); }
.aside-tag { color: var(--warn); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.card.deal { animation: deal 420ms cubic-bezier(0.2, 0.8, 0.25, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes deal {
  from { opacity: 0; transform: translate(-40px, -30px) rotate(-8deg) scale(0.92); }
  to { opacity: 1; transform: none; }
}
label.field.odds-pick { flex: 0 1 300px; min-width: 200px; }
.odds-scroll { overflow-x: auto; }
.odds-table { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 0.85rem; min-width: 520px; }
.odds-table th { color: var(--muted); font-weight: 600; text-align: center; font-size: 0.76rem; letter-spacing: 0.04em; }
.odds-table tbody th { text-align: left; color: var(--text); font-weight: 500; font-size: 0.85rem; padding-right: 6px; }
.odds-table td {
  position: relative; text-align: center; padding: 8px 6px; border-radius: 8px; font-variant-numeric: tabular-nums; font-weight: 700;
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 34%, #0e131c) var(--p), #0e131c var(--p));
}
.note { font-size: 0.8rem; }

/* Deck editor */
.editor { display: grid; gap: 16px; align-items: start; }
.editor > * { min-width: 0; }
.editor-search { position: sticky; top: 92px; }
.editor-search .row input { flex: 1; min-width: 0; }
.hint { font-size: 0.8rem; }
.result-list { display: grid; gap: 6px; max-height: 60vh; overflow: auto; padding-right: 2px; }
.result-row, .deck-row {
  --d: var(--colorless);
  display: grid; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--d) 14%, #121722), #121722 45%);
  border: 1px solid #263044; border-left: 3px solid var(--d);
}
.result-row { grid-template-columns: auto minmax(0, 1fr) auto; cursor: grab; }
.result-row:active { cursor: grabbing; }
.result-row.off-domain { opacity: 0.55; }
.result-row .add-one { width: 32px; height: 32px; padding: 0; border-radius: 10px; font-weight: 700; }
.mini-cost { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--d); color: #140f0c; font-weight: 800; font-size: 0.82rem; flex: none; }
.row-name { display: grid; min-width: 0; }
.row-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name small { color: var(--muted); font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 0.84rem; }
.live-issues li { padding: 6px 10px; border-radius: 8px; background: rgba(255, 141, 141, 0.08); color: var(--danger); }
.live-issues li.warn { background: rgba(224, 181, 106, 0.08); color: var(--gold); }
.row-group { display: grid; gap: 6px; }
.row-group h3 { display: flex; gap: 6px; }
.deck-row { grid-template-columns: auto auto minmax(0, 1fr) auto auto; }
.deck-row.is-missing { border-style: dashed; border-left-style: solid; }
.deck-row.is-locked { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 45%, transparent); }
.deck-row .stepper button { width: 28px; height: 28px; }
.row-flags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.missing-badge { background: rgba(255, 141, 141, 0.14); color: var(--danger); }
.lock, .lock-spacer { width: 28px; height: 28px; flex: none; }
.lock { display: grid; place-items: center; padding: 0; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.lock:hover { border-color: var(--line); }
.lock[aria-pressed="true"] { color: var(--gold); background: rgba(224, 181, 106, 0.12); }
.swaps { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.78rem; color: var(--muted); padding-left: 38px; }
.swap { border: 1px solid rgba(143, 208, 168, 0.4); background: rgba(143, 208, 168, 0.08); color: var(--text); border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; }
.swap small { color: var(--ok); }
.drop-hint { display: none; padding: 14px; border: 2px dashed var(--gold); border-radius: 12px; text-align: center; color: var(--gold); font-weight: 700; }
#deck-drop.drop-ready .drop-hint { display: block; }
#deck-drop.drop-over { box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
#deck-drop.drop-over .drop-hint { background: rgba(224, 181, 106, 0.1); }

/* Collection insights */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 2px; }
.tile-label { color: var(--muted); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; }
.tile-value { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tile:first-child .tile-value { color: var(--gold); }
.tile-note { color: var(--muted); font-size: 0.8rem; }
.conflict { border-color: rgba(255, 138, 91, 0.55); background: linear-gradient(180deg, rgba(255, 107, 74, 0.08), var(--bg-2) 70%); }
.conflict h3 { display: flex; gap: 6px; align-items: center; color: var(--warn); }
.conflicts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.conflicts li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.deck-links { display: flex; gap: 10px; flex-wrap: wrap; }
.insight-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.shop li small { display: block; color: var(--muted); font-size: 0.74rem; }
.sets { display: grid; gap: 10px; }
.set-row { display: grid; grid-template-columns: minmax(80px, 1fr) 2fr 4.5em; gap: 10px; align-items: center; font-size: 0.88rem; }
.set-row .track { grid-area: auto; position: relative; height: 10px; border-radius: 999px; background: #0e131c; }
.set-row .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, #8a6230, var(--gold)); }
.set-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.set-count b { color: var(--text); }
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.filters .field { min-width: 0; }
.filters select { width: 100%; }

@media (min-width: 1280px) {
  .editor { grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); }
}
@media (max-width: 1279px) {
  .editor-search { position: static; }
  .result-list { max-height: 320px; }
}
@media (max-width: 600px) {
  .deck-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .deck-row .row-flags { grid-column: 3 / -1; grid-row: 2; justify-content: flex-start; }
  .swaps { padding-left: 0; }
  .mode-tabs { width: 100%; }
  .mode-tabs button { flex: 1; padding: 7px 8px; }
  .hand { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hand .card.compact { padding: 10px 9px 8px; }
  .hand .card.compact .rules { -webkit-line-clamp: 3; }
  .hand .card.compact .type-line { font-size: 0.64rem; }
}
@media (prefers-reduced-motion: reduce) { .card.deal { animation: none; } .card.selected { transform: none; } }

/* Card hover box */
[data-card-id] { cursor: help; }
.card[data-hand], .result-row[data-card-id] { cursor: pointer; }
#card-pop {
  position: fixed;
  z-index: 50;
  width: min(560px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow: auto;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transition: opacity 120ms ease, transform 120ms ease;
}
#card-pop.visible { opacity: 1; transform: none; }
.pop-inner {
  --d: var(--colorless);
  --d2: var(--d);
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 2px solid transparent;
  border-radius: 18px;
  background:
    radial-gradient(120% 60% at 0% 0%, color-mix(in srgb, var(--d) 20%, transparent), transparent 60%),
    linear-gradient(180deg, #1b2231, #10151f) padding-box,
    linear-gradient(135deg, var(--d), color-mix(in srgb, var(--d) 30%, #2c3548) 50%, var(--d2)) border-box;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.pop-inner.has-art { grid-template-columns: 200px minmax(0, 1fr); align-items: start; }
.pop-art img { display: block; width: 100%; border-radius: 12px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45); background: #0e131c; aspect-ratio: 744 / 1039; object-fit: cover; }
.pop-art.landscape { grid-column: 1 / -1; }
.pop-art.landscape img { aspect-ratio: 1039 / 744; }
.pop-inner.has-art:has(.pop-art.landscape) { grid-template-columns: minmax(0, 1fr); }
.pop-body { display: grid; gap: 8px; min-width: 0; }
.pop-name { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.25rem; line-height: 1.15; }
.pop-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.stat-chip { border-radius: 999px; padding: 2px 9px; background: #0e131c; border: 1px solid var(--line); font-size: 0.76rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pop-body .rules { font-size: 0.84rem; }
.pop-meta { color: var(--muted); font-size: 0.76rem; line-height: 1.5; }
.pop-meta .rarity { display: inline-block; margin-right: 6px; vertical-align: 1px; }
.pop-owned { font-size: 0.82rem; }
.pop-owned b { color: var(--ok); }
.pop-prices { display: grid; gap: 8px; border-top: 1px solid rgba(154, 163, 181, 0.16); padding-top: 10px; }
.pop-headline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pop-headline span { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; }
.pop-headline b { font-family: Georgia, "Iowan Old Style", serif; font-size: 1.5rem; color: var(--text); font-variant-numeric: tabular-nums; }
.pop-headline.store span { color: var(--gold); font-weight: 700; }
.pop-headline.store b { color: var(--gold); }
.pop-price-group { display: grid; gap: 4px; }
.pop-price-group h4 { margin: 0; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; }
.store-group h4 { color: var(--gold); }
.pop-price-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.pop-price-group li { display: grid; grid-template-columns: 64px auto 1fr; gap: 10px; align-items: baseline; font-size: 0.86rem; }
.pop-price-group li b { font-variant-numeric: tabular-nums; }
.pop-price-group li small { color: var(--muted); text-align: right; }
.pop-price-group p { font-size: 0.82rem; }
.finish { font-size: 0.74rem; color: var(--muted); }
.finish.foil { background: linear-gradient(90deg, #ffd27a, #ff8de0, #7ad8ff); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }
.pop-note { font-size: 0.74rem; }
.buy-link { display: flex; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 999px; text-decoration: none; text-align: center; }
.buy-link:hover { filter: brightness(1.08); }
.buy-link:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
a.ct-link { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--gold) 60%, transparent); text-underline-offset: 3px; }
a.ct-link:hover { color: var(--gold); }
.pop-loading { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.82rem; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--gold); animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  .pop-inner.has-art { grid-template-columns: 112px minmax(0, 1fr); }
  .pop-body .rules { font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) { #card-pop { transition: none; } .spinner { animation-duration: 2s; } }

/* Accounts */
.top-right { display: flex; gap: 10px; align-items: center; }
.account-chip {
  display: inline-flex; gap: 8px; align-items: center;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 4px 12px 4px 4px; max-width: 200px;
}
.account-chip:hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.account-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--fury), var(--chaos)); color: #fff; font-weight: 800; font-size: 0.85rem;
}
.account-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
body.signed-out .tabs, body.signed-out .account-chip { display: none; }
body.signed-out main { padding-bottom: 48px; }

.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - 220px); padding: 24px 0; }
.auth-card {
  width: min(420px, 100%); display: grid; gap: 14px; padding: 24px;
  border: 2px solid transparent;
  background:
    radial-gradient(120% 70% at 0% 0%, color-mix(in srgb, var(--fury) 16%, transparent), transparent 60%),
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    linear-gradient(135deg, var(--fury), color-mix(in srgb, var(--gold) 40%, #2c3548) 50%, var(--chaos)) border-box;
}
.auth-head { display: flex; gap: 12px; align-items: center; }
.auth-switch { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #0e131c; border: 1px solid var(--line); }
.auth-switch button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 8px 10px; font-weight: 600; }
.auth-switch button.active { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
#auth-form input { width: 100%; }
#auth-form .btn { width: 100%; padding: 11px 14px; }
#auth-form .btn:disabled { opacity: 0.7; }

#account { width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
#account::backdrop { background: rgba(5, 7, 10, 0.6); backdrop-filter: blur(2px); }
.account-box { gap: 16px; }
.account-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.account-head .ghost { width: 34px; height: 34px; padding: 0; border-radius: 10px; }
.owner-tag { color: var(--gold); font-weight: 700; }
#password-form input { width: 100%; }
.user-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.user-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: #0e131c; border: 1px solid var(--line); }
.user-list li span { display: grid; min-width: 0; }
.user-list small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-list .ghost { flex: none; font-size: 0.82rem; padding: 6px 10px; }
.reset-result { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(224, 181, 106, 0.5); background: rgba(224, 181, 106, 0.08); font-size: 0.86rem; }
.reset-result code { font-size: 1.05rem; letter-spacing: 0.04em; color: var(--gold); user-select: all; }
@media (max-width: 720px) {
  .top { position: sticky; }
  .top-right { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; }
  .account-chip { padding-right: 4px; }
  .account-chip .chip-name { display: none; }
}

/* Rules assistant */
.rules-chat { display: grid; gap: 14px; max-width: 860px; margin: 0 auto; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.chat-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; }
.chat-log { display: grid; gap: 16px; }
.chat-empty { display: grid; gap: 12px; padding: 4px 2px; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; }
.suggestion { font-size: 0.85rem; }
.turn { display: grid; gap: 8px; }
.bubble { border-radius: 16px; padding: 12px 14px; line-height: 1.5; max-width: 92%; }
.bubble.you { justify-self: end; background: color-mix(in srgb, var(--gold) 18%, var(--panel)); border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); white-space: pre-wrap; }
.bubble.bot { justify-self: start; background: var(--bg-2); border: 1px solid var(--line); display: grid; gap: 10px; width: 92%; }
.bubble.bot.pending { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.bubble.error-bubble { color: var(--danger); background: rgba(255, 141, 141, 0.08); border: 1px solid rgba(255, 141, 141, 0.35); }
.answer p, .answer ul { margin: 0 0 8px; }
.answer p:last-child, .answer ul:last-child { margin-bottom: 0; }
.answer ul { padding-left: 20px; }
.cite {
  display: inline-block; margin: 0 1px; padding: 0 7px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--mind) 55%, var(--line));
  background: color-mix(in srgb, var(--mind) 16%, transparent); color: var(--text); font-size: 0.78rem; font-weight: 700; line-height: 1.6; vertical-align: 0.05em;
}
.cite:hover { background: color-mix(in srgb, var(--mind) 30%, transparent); }
.not-covered { display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 10px; background: rgba(255, 107, 74, 0.1); color: var(--warn); font-size: 0.85rem; }
.sources summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; }
.sources ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.sources li { padding: 8px 10px; border-radius: 10px; background: #0e131c; border: 1px solid var(--line); font-size: 0.82rem; color: #d9d3c7; }
.sources li b { color: var(--text); margin-right: 4px; }
.sources li.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 30% { border-color: var(--mind); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mind) 40%, transparent); } 100% { border-color: var(--line); box-shadow: none; } }
.no-sources { font-size: 0.8rem; }
.chat-form { display: flex; gap: 10px; align-items: end; position: sticky; bottom: 12px; z-index: 3; }
.chat-form textarea { flex: 1; min-height: 48px; max-height: 180px; resize: vertical; }
.chat-form .btn { padding: 11px 20px; }
.chat-note { font-size: 0.76rem; text-align: center; }
@media (max-width: 720px) {
  .tabs button { font-size: 0.82rem; padding: 10px 2px; }
  .chat-form { bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + env(safe-area-inset-bottom, 0px) + 8px); }
  .bubble { max-width: 100%; }
  .bubble.bot { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .sources li.flash { animation: none; } }

/* Deck advisor popout */
.advisor-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: inline-flex; gap: 8px; align-items: center;
  border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 800;
  color: #1b140c; background: linear-gradient(135deg, var(--gold), #f3d08f);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.advisor-fab:hover { filter: brightness(1.06); }
body.rules-view .advisor-fab { bottom: 104px; }
.advisor-fab:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.advisor {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  width: min(420px, calc(100vw - 32px)); height: min(680px, calc(100vh - 110px));
  display: flex; flex-direction: column;
  border: 2px solid transparent; border-radius: 20px; overflow: hidden;
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--gold) 25%, #2c3548) 50%, var(--chaos)) border-box;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.advisor[hidden], .advisor-fab[hidden] { display: none; }
.advisor-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.advisor-head h2 { font-size: 1.15rem; }
.advisor-head p { font-size: 0.8rem; }
.advisor-head .icon { width: 32px; height: 32px; padding: 0; border-radius: 10px; }
.advisor-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: grid; gap: 14px; align-content: start; }
.advisor-log .bubble { max-width: 100%; }
.advisor-log .bubble.bot { width: 100%; }
.advisor-divider { text-align: center; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }
.advisor-form { display: flex; gap: 8px; align-items: end; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.advisor-form textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; }
.advice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.advice { display: grid; gap: 6px; padding: 10px; border-radius: 12px; background: #0e131c; border: 1px solid var(--line); }
.advice-head { display: flex; gap: 8px; align-items: center; min-width: 0; }
.advice-badge { flex: none; border-radius: 6px; padding: 2px 7px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.advice.add .advice-badge { background: rgba(143, 208, 168, 0.16); color: var(--ok); }
.advice.remove .advice-badge { background: rgba(255, 141, 141, 0.14); color: var(--danger); }
.advice.swap .advice-badge { background: color-mix(in srgb, var(--mind) 20%, transparent); color: #9fc3ff; }
.advice.build .advice-badge { background: rgba(224, 181, 106, 0.16); color: var(--gold); }
.advice-card { --d: var(--colorless); display: flex; gap: 6px; align-items: center; min-width: 0; flex: 1; }
.advice-card .mini-cost { width: 22px; height: 22px; font-size: 0.74rem; }
.advice-card .mini-cost .type-icon { color: #1b140c; }
.advice-card b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.advice-qty { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.advice-replace { font-size: 0.8rem; color: var(--muted); }
.advice-replace span { color: var(--text); text-decoration: underline dotted; }
.advice-reason { font-size: 0.82rem; color: #d9d3c7; }
.advice-apply { justify-self: start; padding: 6px 14px; font-size: 0.82rem; }
.advice-dropped { font-size: 0.78rem; }
@media (max-width: 720px) {
  .advisor-fab { right: 12px; bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + env(safe-area-inset-bottom, 0px) + 10px); padding: 10px 14px; }
  .advisor { left: 8px; right: 8px; width: auto; bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + env(safe-area-inset-bottom, 0px) + 6px); height: min(72vh, calc(100vh - 150px)); }
  /* The chat form on the Rules tab sits where the button would; lift the button above it there. */
  body.rules-view .advisor-fab { bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + env(safe-area-inset-bottom, 0px) + 92px); }
}

/* Pick list */
.pick-progress { display: grid; gap: 4px; text-align: left; border: 1px solid var(--line); background: #0e131c; border-radius: 12px; padding: 8px 10px; font-size: 0.84rem; color: var(--text); }
.pick-progress:hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.pick-progress.done { border-color: rgba(143, 208, 168, 0.5); color: var(--ok); }
.pick-bar { display: block; height: 6px; border-radius: 999px; background: #121722; overflow: hidden; }
.pick-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5fae80, var(--ok)); transition: width 200ms ease; }
.pick-bar.big { height: 10px; }
.pick-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.pick-summary { font-weight: 700; margin-top: 2px; }
.pick-tools { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.pick-tools .field { min-width: 210px; flex: none; }
.pick-tools .checks { align-self: center; }
.pick-group { display: grid; gap: 6px; }
.pick-group h3 { display: flex; gap: 8px; }
.pick-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pick-row {
  --d: var(--colorless);
  display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 12px; border: 1px solid #263044; border-left: 3px solid var(--d);
  background: linear-gradient(90deg, color-mix(in srgb, var(--d) 12%, #121722), #121722 45%);
  transition: opacity 150ms ease;
}
.pick-row.picked { opacity: 0.55; }
.pick-row.picked .pick-name b { text-decoration: line-through; text-decoration-color: rgba(239, 232, 220, 0.5); }
.pick-check input { width: 20px; height: 20px; accent-color: var(--ok); margin: 0; cursor: pointer; }
.pick-qty { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2ch; }
.pick-name { display: grid; min-width: 0; }
.pick-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-name small { color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.pick-flags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pips { display: flex; gap: 5px; }
.pip { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--ok) 55%, var(--line)); background: transparent; }
.pip.on { background: var(--ok); border-color: var(--ok); }
.pip:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 600px) {
  .pick-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .pick-row .mini-cost { display: none; }
  .pick-row .pick-flags { grid-column: 3 / -1; grid-row: 2; justify-content: flex-start; }
  .pick-tools .field { min-width: 0; flex: 1 1 100%; }
}

/* Printable pick list. Hidden on screen so the interactive list stays as it is. */
.print-sheet { display: none; }

@page {
  size: letter;
  margin: 0.55in 0.58in 0.62in;
  @bottom-left {
    content: "Starfoil pick list";
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 8.5pt;
    color: #555;
  }
  @bottom-right {
    content: counter(page) " of " counter(pages);
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 8.5pt;
    color: #555;
  }
}

@media print {
  html, body { background: #fff !important; color: #1a1a1a !important; }
  .top, .tabs, footer, .advisor, .advisor-fab, #account, #card-pop, .side, .mode-tabs, .pick-screen { display: none !important; }
  main { padding: 0 !important; max-width: none !important; margin: 0 !important; }
  .deck-layout, .stack, .pick-panel, .panel {
    display: block !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    gap: 0 !important;
  }
  .print-sheet {
    display: block !important;
    color: #1a1a1a;
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 10.5pt;
    line-height: 1.35;
  }
  .print-banner {
    display: flex;
    align-items: center;
    gap: 0.22in;
    padding-bottom: 8pt;
    border-bottom: 1.5pt solid #1a1a1a;
    break-after: avoid;
    page-break-after: avoid;
  }
  .print-logo { display: block; height: 0.92in; width: auto; max-width: 1.7in; object-fit: contain; object-position: left center; }
  .print-banner-text { min-width: 0; }
  .print-kicker {
    margin: 0 0 2pt;
    font-size: 8pt;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #444;
  }
  .print-sheet h1 {
    margin: 0;
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
    font-size: 16.5pt;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #1a1a1a;
  }
  .print-legend { margin: 3pt 0 0; font-size: 11pt; font-weight: 650; }
  .print-meta { margin: 1pt 0 0; font-size: 9.5pt; color: #333; }
  .print-lead { margin: 8pt 0 0; font-size: 9pt; color: #333; }
  .print-section { margin-top: 2pt; }
  .print-section.short { break-inside: avoid; page-break-inside: avoid; }
  .print-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .print-table .c-tick { width: 20pt; }
  .print-table .c-qty { width: 34pt; }
  .print-table .c-set { width: 40pt; }
  .print-table .c-num { width: 58pt; }
  .print-table .c-dom { width: 88pt; }
  .print-table .c-foil { width: 46pt; }
  .print-table thead { display: table-header-group; }
  .print-table tr { break-inside: avoid; page-break-inside: avoid; }
  .print-table th {
    text-align: left;
    font-size: 7.5pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #333;
    padding: 2pt 8pt 3pt 0;
    border-bottom: 1pt solid #1a1a1a;
    background: #fff;
  }
  .print-section-title th {
    border-bottom: 0;
    padding: 10pt 0 1pt;
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
    font-size: 12.5pt;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: #1a1a1a;
  }
  .print-table td {
    padding: 3.5pt 8pt 3.5pt 0;
    border-bottom: 0.6pt solid #d5d5d5;
    vertical-align: middle;
    background: #fff;
  }
  .print-table .tick { width: 16pt; padding-right: 2pt; }
  .print-table .qty, .print-table .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .print-table .qty { font-weight: 700; padding-right: 8pt; }
  .print-table .set { white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
  .print-table .number { color: #222; padding-right: 8pt; }
  .print-table .domain { color: #222; }
  .print-table .card-name { font-weight: 650; overflow-wrap: anywhere; }
  .print-table .foil { white-space: nowrap; text-align: right; }
  .print-table thead tr:not(.print-section-title) th:last-child { text-align: right; }
  .print-section-title th { text-align: left; }
  .tick-box {
    display: inline-block;
    width: 11pt;
    height: 11pt;
    border: 1.35pt solid #1a1a1a;
    border-radius: 1.5pt;
    box-sizing: border-box;
    position: relative;
    vertical-align: middle;
  }
  .tick-box.on::after {
    content: "";
    position: absolute;
    left: 2.6pt;
    top: 0.4pt;
    width: 3.2pt;
    height: 6.2pt;
    border: solid #1a1a1a;
    border-width: 0 1.5pt 1.5pt 0;
    transform: rotate(40deg);
  }
  .foil-mark {
    display: inline-block;
    border: 1pt solid #1a1a1a;
    border-radius: 999px;
    padding: 0 5pt;
    font-size: 7.5pt;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.45;
  }
  .print-subtotal {
    display: flex;
    justify-content: space-between;
    margin: 0 0 4pt;
    padding-top: 2pt;
    font-size: 8.5pt;
    font-weight: 650;
    letter-spacing: 0.04em;
    break-before: avoid;
    page-break-before: avoid;
  }
  .print-grand {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 8pt 0 0;
    padding-top: 6pt;
    border-top: 2pt solid #1a1a1a;
    font-size: 12pt;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-grand b { font-variant-numeric: tabular-nums; font-weight: 750; }
  .print-empty { margin: 12pt 0; }
  .print-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
}

body.public-read .tabs,
body.public-read .game-switch,
body.public-read .account-chip,
body.public-read .advisor-fab,
body.public-read #advisor { display: none; }
.public-deck .public-lines { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.public-deck .public-lines li { display: flex; justify-content: space-between; gap: 12px; }
.share-path { font-family: ui-monospace, monospace; font-size: 0.85em; }
