:root {
  --bg: #12141a;
  --panel: #191c24;
  --panel-2: #1f2330;
  --line: #2b3040;
  --text: #e7e9f0;
  --muted: #99a1b3;
  --accent: #c8963e;
  --ok: #4ea87a;
  --err: #d4665f;
  --radius: 8px;
  color-scheme: dark;
}

/* ------------------------------------------------------- analysis & plans */

.decktabs {
  display: flex;
  gap: 4px;
  margin: 18px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.decktabs a {
  padding: 9px 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.decktabs a:hover,
.decktabs a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.analysis-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.statstrip,
.metricline {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.analysis-grid,
.prob-grid,
.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.analysis-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}

.analysis-card.wide {
  margin-bottom: 14px;
}

.analysis-card > h3 {
  color: var(--text);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.bar-chart {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.bar-row {
  display: grid;
  grid-template-columns: 42px minmax(60px, 1fr) 30px;
  align-items: center;
  gap: 8px;
}

.bar-label,
.bar-value {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.bar-track,
.demand-track {
  display: block;
  height: 12px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill,
.demand-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.analysis-table th,
.analysis-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.analysis-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.domain-analysis {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.domain-row {
  display: grid;
  grid-template-columns: 90px minmax(80px, 1fr) repeat(4, auto);
  gap: 10px;
  align-items: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.observations {
  margin: 0;
  padding-left: 20px;
}

.warntext {
  color: var(--accent);
}

.probability-view label,
.plan-fields label,
.plan-editor > label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.prob-cards {
  width: 100%;
}

.shortinput {
  width: 72px;
}

.prob-result {
  display: grid;
  gap: 6px;
  padding: 18px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--panel-2);
}

.prob-result strong {
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
}

.plan-selector {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.sideboard-view {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.plan-list {
  display: grid;
  gap: 5px;
  position: sticky;
  top: 72px;
}

.plan-list a {
  display: grid;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.plan-list a:hover,
.plan-list a.active {
  border-color: var(--accent);
  background: var(--panel-2);
}

.plan-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 180px;
  gap: 10px;
}

.move-list {
  display: grid;
  gap: 5px;
  max-height: 480px;
  overflow: auto;
}

.move-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto 130px 60px;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 5px 0;
}

.move-qty {
  width: 60px;
}

.plan-editor textarea {
  width: 100%;
  resize: vertical;
}

.plan-actions {
  flex-wrap: wrap;
  margin: 8px 0;
}

.plan-balance {
  padding: 10px 12px;
  margin: 16px 0;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.plan-balance.ok {
  border-color: var(--ok);
}

.builder-analysis {
  margin: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.builder-analysis > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.builder-analysis .analysis-view {
  margin-top: 12px;
}

@media (max-width: 760px) {
  .analysis-grid,
  .prob-grid,
  .plan-grid,
  .sideboard-view,
  .plan-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .plan-list {
    position: static;
  }

  .domain-row {
    grid-template-columns: 80px minmax(70px, 1fr) auto;
  }

  .domain-row span:nth-last-child(-n + 3) {
    display: none;
  }

  .move-row {
    grid-template-columns: minmax(100px, 1fr) 60px;
  }

  .move-row > :nth-child(2),
  .move-row > :nth-child(3) {
    display: none;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-2: #eef0f4;
    --line: #dcdfe6;
    --text: #191c22;
    --muted: #5c6373;
    --accent: #8a5f1e;
    color-scheme: light;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

h2 {
  font-size: 16px;
  margin: 0 0 8px;
}

h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 8px;
}

.boot {
  padding: 40px;
  color: var(--muted);
}

/* ------------------------------------------------------------------- bars */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar nav a:hover {
  color: var(--accent);
}

.share-badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
}

.selbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 49px;
  z-index: 9;
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.layout.nosidebar {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 4px;
}

.totals {
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.facet {
  margin-bottom: 16px;
}

.facet ul,
ul.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}

.facet li {
  margin: 2px 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar input[type="search"] {
  flex: 1;
}

.activefilters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

/* -------------------------------------------------------------- controls */

input,
select,
textarea {
  padding: 7px 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button,
.btn {
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #15171c;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}

button:hover,
.btn:hover {
  filter: brightness(1.1);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}

button.ghost,
.ghost.btn {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  font-weight: 500;
}

button.ghost:hover {
  color: var(--text);
}

button.danger:hover {
  color: var(--err);
  border-color: var(--err);
}

button.small {
  padding: 3px 8px;
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.chip:hover {
  background: var(--panel-2);
  filter: none;
}

.chip.active {
  background: var(--panel-2);
  border-color: var(--accent);
  color: var(--text);
}

.chip .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.inline {
  display: inline-flex;
  gap: 8px;
}

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

.deckgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.deckcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.deckcard.selected {
  border-color: var(--accent);
}

.deckcard-main {
  display: flex;
  gap: 10px;
  padding: 10px;
  min-width: 0;
}

.deckcard img {
  width: 54px;
  height: 76px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--panel-2);
  flex: none;
}

.noart {
  width: 54px;
  height: 76px;
  border-radius: 4px;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--muted);
  flex: none;
}

.deckcard-body {
  min-width: 0;
}

.deckcard h3 {
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin: 0 0 2px;
  overflow-wrap: anywhere;
}

.pick {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.small {
  font-size: 12px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 4px;
}

.tag {
  font-size: 11px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

.tag.warn {
  color: var(--accent);
  border-color: var(--accent);
}

.domains {
  display: flex;
  gap: 3px;
  margin: 4px 0;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  padding: 30px 0;
}

/* ----------------------------------------------------------- deck detail */

.detail {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.notice {
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.notes {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  white-space: pre-wrap;
}

/*
 * Deck sections flow into as many columns as fit, so a full list is visible
 * without scrolling. Sections are deliberately not height-capped — an inner
 * scrollbar would defeat the point.
 */
/*
 * Multi-column rather than grid: a CSS grid gives every section a full-height
 * row slot, so one-card sections like Legend and Champion left large gaps
 * beside them. Column flow packs short sections together instead.
 */
.zones {
  columns: 250px;
  column-gap: 14px;
  margin-top: 16px;
}

.zones .zone {
  break-inside: avoid;
  margin: 0 0 14px;
}

/* The comparison matrix needs full width, so it opts out of column flow. */
.zones.cmpzones {
  columns: auto;
}

@media (min-width: 1500px) {
  .detail {
    max-width: 1440px;
  }
}

.zone {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}

.cardlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cardlist li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  min-width: 0;
}

.cardlist li:last-child {
  border-bottom: none;
}

.cardlist .qty {
  width: 22px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.thumb {
  width: 24px;
  height: 34px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--panel-2);
  flex: none;
}

.cname {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.energy {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
  flex: none;
}

.cdomains {
  display: flex;
  gap: 2px;
  flex: none;
}

.unresolved .cname {
  color: var(--err);
  text-decoration: underline dotted;
}

/* --------------------------------------------------------------- compare */

.cmp-summary,
.simgrid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.simgrid {
  flex-direction: column;
  gap: 6px;
  max-width: 620px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  color: var(--text);
  font-size: 16px;
}

.sim {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 48px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.sim .bar {
  height: 7px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.sim .fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* Comparison zones are full width — the matrix needs the room. */
.cmpzone {
  grid-column: 1 / -1;
}

/* Let a wide matrix scroll inside its own box instead of stretching the page. */
.tablewrap {
  overflow-x: auto;
  max-width: 100%;
}

table.cmp {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

table.cmp th,
table.cmp td {
  padding: 4px 6px;
  text-align: center;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  /* Quantity columns stay narrow so the card name gets the space. */
  width: 44px;
}

table.cmp .cardcol {
  text-align: left;
  width: auto;
  min-width: 180px;
}

/*
 * The card cell used to be `display: flex`, which takes the <td> out of table
 * layout and was what pushed content outside the grid once a third deck column
 * appeared. The flex row now lives in an inner span instead.
 */
.cardcell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cardcell .cname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.colhead {
  display: inline-block;
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Key mapping the D1..D4 column codes back to real decks. */
.deckkey {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}

.keyrow {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-width: 0;
}

.keycode {
  flex: none;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}

.keytitle {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.keytitle:hover {
  color: var(--accent);
}

.grouprow td {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-top: 12px;
  border-bottom: 1px solid var(--line);
}

.grp.unique .grouprow td {
  color: var(--accent);
}

td.missing {
  color: color-mix(in srgb, var(--muted) 50%, transparent);
}

td.has {
  font-weight: 600;
}

/* -------------------------------------------------------------- settings */

.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.login {
  width: min(360px, 100%);
}

.login label {
  display: block;
  margin: 12px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.login input {
  width: 100%;
}

.login button[type="submit"] {
  width: 100%;
  margin-top: 16px;
}

ul.plain li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

ul.plain li:last-child {
  border-bottom: none;
}

code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.copyable {
  cursor: copy;
}

.status {
  margin: 10px 0 0;
  min-height: 1em;
  color: var(--muted);
  font-size: 13px;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--err);
}

/* ---------------------------------------------------------- card preview --- */

/*
 * Floating card panel for hover/click preview. Fixed positioning keeps it clear
 * of the multi-column deck layout, which would otherwise clip it.
 */
.cardpreview {
  position: fixed;
  z-index: 50;
  width: 320px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  padding: 10px;
  pointer-events: none;
}

/* Pinned previews are interactive so long rules text can be scrolled. */
.cardpreview[data-pinned='true'] {
  pointer-events: auto;
  border-color: var(--accent);
}

.previewart {
  display: block;
  width: 100%;
  border-radius: 6px;
  background: var(--panel-2);
}

.previewbody h4 {
  margin: 8px 0 2px;
  font-size: 14px;
}

.previewmeta {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.previewtext {
  margin: 0;
  font-size: 13px;
  white-space: pre-wrap;
}

.previewhint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.cardlist li.previewable {
  cursor: help;
  border-radius: 4px;
}

.cardlist li.previewable:hover,
.cardlist li.previewable:focus-visible {
  background: var(--panel-2);
  outline: none;
}

/* ---------------------------------------------------------------- folders --- */

/* A folder pill holds a browse link plus an unfile button, so it lays its own
   children out rather than being a plain text badge like other tags. */
.tag.folder {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-color: var(--accent);
  color: var(--accent);
}

.tag.folder:hover {
  background: var(--panel-2);
}

.tag.folder a {
  color: inherit;
  text-decoration: none;
}

/* The × stays dim until the pill is hovered: removing a deck from a folder
   should be reachable, but it should not read as the pill's main action. */
.tag.folder .unfile {
  padding: 0 1px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
}

.tag.folder:hover .unfile,
.tag.folder .unfile:focus-visible {
  opacity: 0.75;
}

.tag.folder .unfile:hover {
  opacity: 1;
  color: var(--err);
}

/* Sidebar folder row: the chip takes the space, management controls sit at the
   end and appear on hover or keyboard focus. */
.folderrow {
  display: flex;
  align-items: center;
  gap: 2px;
}

.folderrow .chip {
  flex: 1;
  min-width: 0;
}

.folderadmin {
  display: inline-flex;
  gap: 2px;
  opacity: 0;
}

.folderrow:hover .folderadmin,
.folderrow:focus-within .folderadmin {
  opacity: 1;
}

.iconbtn {
  padding: 2px 5px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.iconbtn:hover {
  background: var(--panel-2);
  color: var(--text);
}

.iconbtn.danger:hover {
  color: var(--err);
}

/* Inline badge standing in for a Riftbound icon token in rules text. */
.rbicon {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  padding: 0 4px;
  margin: 0 1px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--accent);
  white-space: nowrap;
  vertical-align: baseline;
}

/* ------------------------------------------------------------ tournament --- */

.tourney {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.tourney dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 18px;
  margin: 0;
}

.tourney dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 1px;
}

.tourney dd {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

/* dt/dd pairs stack within each auto-fit column. */
.tourney dl > dt {
  grid-column: auto;
}

.exlink {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.exlink:hover {
  text-decoration-color: var(--accent);
}

/* Energy-cost column in the comparison matrix. Narrow, and visually distinct
   from the deck quantity columns so the two are not confused. */
table.cmp .costcol {
  width: 46px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--line);
}

table.cmp th.costcol {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Deck is exposed through library share links. */
.tag.shared {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 55%, transparent);
}

/* ---------------------------------------------------------------- builder --- */

.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  padding: 20px;
  align-items: start;
}

@media (max-width: 1000px) {
  .builder {
    grid-template-columns: minmax(0, 1fr);
  }
}

.inlinecheck {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 10px;
  text-transform: none;
  letter-spacing: 0;
}

.inlinecheck input {
  width: auto;
}

.cardresults {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}

.cardtile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.cardtile:hover {
  border-color: var(--accent);
  filter: none;
}

.cardtile img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 4px;
  background: var(--panel-2);
}

.tilename {
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tilemeta {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Deck pane sticks so counts stay visible while scrolling the card list. */
.builderdeck {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.bstats {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.bstat {
  flex: 1;
  text-align: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.bstat strong {
  display: block;
  font-size: 15px;
  color: var(--err);
  font-variant-numeric: tabular-nums;
}

.bstat.ok strong {
  color: var(--ok);
}

.bstat span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.blegend {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.legendpick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legendpick > div {
  flex: 1;
  min-width: 0;
}

.bproblems {
  border-color: var(--accent);
}

.bproblems ul {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12px;
}

.bzones {
  margin-bottom: 8px;
}

.bzone h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 0 4px;
}

.bzone ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bzone li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  font-size: 13px;
  min-width: 0;
}

.bzone .cname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bzone .qty {
  width: 18px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.step {
  padding: 0 5px;
  min-width: 20px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.step:hover {
  color: var(--accent);
  border-color: var(--accent);
  filter: none;
}

.step.wide {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ toast --- */

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: min(760px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.45);
  padding: 10px 12px;
}

/* Toast contents wrap onto multiple lines when it holds a folder picker. */
.toast input {
  min-width: 160px;
}

.toast code {
  max-width: min(520px, 60vw);
  overflow-wrap: anywhere;
}

/* Cost / type filter row in the builder. */
.filterrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.flabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.costchips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chipbtn {
  padding: 3px 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chipbtn:hover {
  color: var(--text);
  filter: none;
}

.chipbtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #15171c;
}

/* Legend tiles are wider: the label carries champion + title. */
.legendtile .tilename {
  font-weight: 600;
}

.legendtile .tilemeta .domains {
  display: inline-flex;
  gap: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/*
 * Count badge inside a filter chip. A divider keeps a numeric label and its
 * count from reading as one number ("2" + "71" must not look like 271).
 */
.chipn {
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid currentColor;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

.chipbtn.active .chipn {
  opacity: 0.8;
}

.chipbtn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Signature-card marker on a builder tile. */
.sigbadge {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Your own legend's signature, as opposed to another champion's. */
.sigbadge.mine {
  color: var(--accent);
}
