/* RB Top8 — single stylesheet. Sections: tokens, base, layout, header,
   components, tables, deck pages, forms, builder, utilities. */

/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #1d1b22;
  --muted: #6b6774;
  --border: #e2ded6;
  --accent: #0a7f8c;
  --accent-text: #ffffff;
  --gold: #c89b3c;
  --header: #0f1424;
  --ok: #16884f;
  --warn: #b26a00;
  --danger: #c0262f;
  --fury: #cb212d;
  --calm: #16aa71;
  --mind: #227799;
  --body: #e2710c;
  --chaos: #6b4891;
  --order: #cda902;
  --radius: 8px;
  --shadow: 0 6px 24px rgba(15, 20, 36, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --surface: #1b1e27;
    --surface-2: #20242f;
    --text: #e8e6ef;
    --muted: #a19eac;
    --border: #2f3343;
    --accent: #3cc3cf;
    --accent-text: #0b1016;
    --header: #0a0d16;
    --ok: #3ccf87;
    --warn: #f0a63c;
    --danger: #ff6b72;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 1.2rem 0 0.4rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 0.8rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.3rem; }
code, kbd { background: var(--surface-2); border: 1px solid var(--border); padding: 0 0.35em; border-radius: 4px; font-size: 0.85em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .sub { color: var(--muted); }
.sub { font-size: 0.85em; font-weight: normal; }
.sub.inline, td .sub.inline { display: inline; }
.nowrap { white-space: nowrap; }
.hint { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.error-text { color: var(--danger); }
.danger-text { color: var(--danger) !important; }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; margin-top: 16px; align-items: start; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 16px; }
@media (max-width: 860px) { .grid-2, .grid-2.even { grid-template-columns: 1fr; } }
.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; min-width: 0; overflow-x: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 0.2rem; }
.page-head .buttons { margin-bottom: 8px; }
.empty-state { text-align: center; padding: 32px 16px; }
.empty-state h1, .empty-state h2 { margin-top: 0; }
.hero p { color: var(--muted); max-width: 70ch; margin-top: 0; }
.crumbs { margin: 1rem 0 -0.8rem; font-size: 0.9rem; color: var(--muted); }
.event-meta { color: var(--muted); margin-top: 0; }
.more { margin: 0.6rem 0 0; text-align: right; font-size: 0.9rem; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 8px 0 20px; }

/* ---------------------------------------------------------------- header */
.site-header { background: var(--header); color: #fff; border-bottom: 3px solid var(--gold); position: relative; z-index: 20; }
.header-row { display: flex; align-items: center; gap: 8px 20px; min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { color: #fff; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--gold); color: var(--header); padding: 1px 6px; border-radius: 4px; margin-right: 2px; }
.main-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.main-nav a { color: #cfd3e3; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.main-nav a:hover, .main-nav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; text-decoration: none; }
.header-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.site-search input { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); color: #fff; width: 230px; }
.site-search input::placeholder { color: #9aa0b4; }
.header-link { color: #cfd3e3; white-space: nowrap; }
.header-link:hover { color: #fff; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; color: #fff; padding: 4px 6px; border-radius: 6px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255, 255, 255, 0.1); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--header); display: inline-grid; place-items: center; font-weight: 700; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { .user-name { display: none; } }
@media (max-width: 900px) {
  .header-tools { width: 100%; margin-left: 0; order: 3; }
  .site-search { flex: 1; }
  .site-search input { width: 100%; }
}

/* menus (user menu, builder "More", row actions) */
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 30; display: flex; flex-direction: column; }
.menu a, .menu .link-button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.menu a:hover, .menu .link-button:hover { background: var(--surface-2); text-decoration: none; }
.menu form { margin: 0; }
details > summary { cursor: pointer; }
.more-menu, .row-menu { position: relative; }
.more-menu summary, .row-menu summary { list-style: none; }
.more-menu summary::-webkit-details-marker, .row-menu summary::-webkit-details-marker { display: none; }

/* ---------------------------------------------------------------- footer */
.site-footer { margin-top: 48px; padding: 20px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }

/* ------------------------------------------------------------ components */
.notice { background: color-mix(in srgb, var(--gold) 15%, var(--surface)); border: 1px solid var(--gold); padding: 10px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 0.9rem; }
.notice ul { margin: 0; padding-left: 18px; }
.notice.error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pip { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.2); }
.pip-fury { background: var(--fury); }
.pip-calm { background: var(--calm); }
.pip-mind { background: var(--mind); }
.pip-body { background: var(--body); }
.pip-chaos { background: var(--chaos); }
.pip-order { background: var(--order); }
.tier { font-size: 0.75rem; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); white-space: nowrap; }
.tier-major { background: var(--gold); color: #1d1b22; border-color: var(--gold); }
.tier-regional { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.tag { font-size: 0.72rem; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.tag-error { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--text); }
.tag-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.tag-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.vis-public { color: var(--accent); }
.bar-col { width: 40%; white-space: nowrap; }
.bar { display: inline-block; height: 14px; background: var(--accent); opacity: 0.8; border-radius: 2px; vertical-align: middle; }
.bar-label { margin-left: 6px; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
#card-preview { position: fixed; z-index: 50; pointer-events: none; width: 250px; }
#card-preview.landscape { width: 340px; }
#card-preview img { width: 100%; border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); display: block; background: var(--surface); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--header); color: #fff; padding: 9px 16px; border-radius: 999px; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.15s, transform 0.15s; pointer-events: none; z-index: 60; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ----------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-bottom: 2px solid var(--border); padding: 6px 8px; }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:nth-child(even) { background: var(--surface-2); }
.num { text-align: right; width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }
td .sub { display: block; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 3px 0; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* ------------------------------------------------------------ deck pages */
.deck-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; margin-top: 16px; align-items: start; }
.decklist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.decklist.grouped { display: block; columns: 3 230px; column-gap: 20px; }
.decklist.grouped .deck-section { break-inside: avoid; }
.deck-section { margin-bottom: 14px; }
.deck-section ul { list-style: none; margin: 0; padding: 0; }
.deck-section li { padding: 2px 0; border-bottom: 1px dotted var(--border); display: flex; gap: 6px; align-items: baseline; }
.muted-block { opacity: 0.75; }
.qty { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 1.6em; text-align: right; color: var(--muted); }
.cost { margin-left: auto; min-width: 1.5em; height: 1.5em; border-radius: 50%; display: inline-grid; place-items: center; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.cost:empty { visibility: hidden; }
.rate { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.agg { columns: 2 220px; column-gap: 20px; }
.agg .deck-section { break-inside: avoid; }
.deck-description { white-space: pre-line; max-width: 75ch; }
.issues { margin: 0; padding-left: 18px; font-size: 0.9rem; }
.issues li { margin: 2px 0; }
#deck-code, #export-code { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; margin: 4px 0; }
.card-detail { display: flex; gap: 24px; align-items: flex-start; margin: 16px 0; flex-wrap: wrap; }
.card-detail h1 { margin-top: 0; }
.card-image { width: 260px; max-width: 100%; border-radius: 12px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25); }
.card-image.landscape { width: 360px; }
.rules { white-space: pre-line; max-width: 60ch; }
.unresolved { color: var(--muted); border-bottom: 1px dashed var(--muted); }
@media (max-width: 960px) { .deck-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .decklist { grid-template-columns: 1fr; } }

/* energy curve */
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; align-items: end; height: 110px; }
.curve-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 2px; }
.curve-bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: 0.85; }
.curve-n { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.curve-x { font-size: 0.75rem; font-weight: 600; }

/* ----------------------------------------------------------------- forms */
input, select, textarea, button, .button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 11px;
}
input:disabled { opacity: 0.7; }
textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
button, .button { cursor: pointer; display: inline-block; line-height: 1.3; text-align: center; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.small { padding: 4px 10px; font-size: 0.9rem; }
.full { width: 100%; margin-top: 8px; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.buttons form { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.filters input[type=search] { flex: 1 1 240px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label, .form-grid label, .standing label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.stack input, .stack select, .stack textarea { color: var(--text); font-size: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.standing { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; display: grid; grid-template-columns: 80px 1fr 100px 1fr; gap: 10px; }
.standing label.full { grid-column: 1 / -1; }
@media (max-width: 640px) { .standing { grid-template-columns: 1fr; } }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select, .inline-form button { padding: 3px 8px; font-size: 0.85rem; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.auth-card { max-width: 420px; margin: 32px auto; padding: 24px; }
.auth-card h1 { margin-top: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.active-link { font-weight: 700; text-decoration: underline; }

/* modal dialogs */
dialog.modal { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal.wide { width: min(900px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 13, 22, 0.55); }
dialog.modal h2 { margin-top: 0; }
dialog.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; }
dialog.modal .buttons { justify-content: flex-end; margin-top: 12px; }

/* --------------------------------------------------------------- builder */
.builder-head { margin-bottom: 12px; }
.builder-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 8px; }
.title-input { font-size: 1.6rem; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 2px 6px; margin-left: -7px; flex: 1 1 300px; min-width: 0; }
.title-input:hover { border-color: var(--border); }
.title-input:focus { border-color: var(--accent); background: var(--surface); }
.save-status { font-size: 0.85rem; color: var(--muted); }
.save-status.ok::before { content: "✓ "; color: var(--ok); }
.save-status.pending { color: var(--warn); }
.save-status.error { color: var(--danger); }
.builder-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.builder-main { display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; gap: 20px; align-items: start; }
.builder-deck, .builder-search { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.builder-search { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.builder-tabs { display: none; }
@media (max-width: 900px) {
  .builder-main { grid-template-columns: 1fr; }
  .builder-search { position: static; max-height: none; }
  .builder-tabs { display: flex; gap: 4px; margin-bottom: 12px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 0; }
  .builder-tabs button { flex: 1; }
  .builder-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
  .builder[data-tab="deck"] [data-pane="search"], .builder[data-tab="search"] [data-pane="deck"] { display: none; }
}
.view-toggle { display: inline-flex; margin: 8px 0 4px; }
.view-toggle button { border-radius: 0; padding: 4px 12px; font-size: 0.85rem; }
.view-toggle button:first-child { border-radius: 6px 0 0 6px; }
.view-toggle button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.view-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.deck-checks { margin-bottom: 8px; }
.check-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.check-pill { font-size: 0.8rem; border-radius: 999px; padding: 2px 10px; border: 1px solid var(--border); white-space: nowrap; }
.check-pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.check-pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.check-ok { color: var(--ok); font-weight: 600; margin: 8px 0 0; }
.issues-box { margin-top: 8px; font-size: 0.9rem; }
.issues-box summary { color: var(--warn); font-weight: 600; }
.deck-block-title { margin: 18px 0 6px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; }
.deck-block { margin: 10px 0; }
.deck-block h3 { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.deck-block.sub-block h3 { font-size: 0.75rem; }
.count { font-variant-numeric: tabular-nums; font-weight: 600; }
.count.ok { color: var(--ok); }
.count.warn { color: var(--warn); }
.empty-hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0; font-style: italic; }
.deck-rows { list-style: none; margin: 0; padding: 0; }
.deck-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; border-bottom: 1px dotted var(--border); }
.deck-row:hover { background: var(--surface-2); }
.row-qty { display: inline-flex; align-items: center; gap: 2px; }
.qty-btn { width: 24px; height: 24px; padding: 0; line-height: 1; border-radius: 50%; font-weight: 700; opacity: 0.55; }
.deck-row:hover .qty-btn, .qty-btn:focus-visible { opacity: 1; }
.row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.row-menu summary { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.row-menu summary:hover { background: var(--border); }
.row-menu .menu { min-width: 190px; }
@media (hover: none) { .qty-btn { opacity: 1; width: 30px; height: 30px; } }
.deck-stats { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.deck-stats h3 { font-size: 0.8rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }
.stats-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 500px) { .stats-grid { grid-template-columns: 1fr; } }
.description-box { margin-top: 12px; }
.description-box textarea { margin-top: 6px; font-family: inherit; font-size: 0.95rem; }

/* search */
.search-bar input { width: 100%; font-size: 1rem; padding: 9px 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border-radius: 999px; padding: 3px 11px; font-size: 0.82rem; display: inline-flex; align-items: center; gap: 5px; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 0.9rem; }
.builder-search .hint { margin: 6px 0 10px; }

/* card tiles (search results, visual view, sample hand) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.card-grid.compact { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.card-grid.hand { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card-tile { position: relative; padding: 0; border: 0; background: none; aspect-ratio: 744 / 1039; border-radius: 9px; overflow: hidden; cursor: pointer; display: block; width: 100%; }
.card-tile.landscape { aspect-ratio: 1039 / 744; grid-column: span 2; }
.card-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; border-radius: 9px; }
.card-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-tile:focus-visible { outline: 3px solid var(--accent); }
.tile-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 4px; padding: 8px; text-align: left; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); border-top: 6px solid var(--muted); color: var(--text); }
.tile-fallback.dom-fury { border-top-color: var(--fury); }
.tile-fallback.dom-calm { border-top-color: var(--calm); }
.tile-fallback.dom-mind { border-top-color: var(--mind); }
.tile-fallback.dom-body { border-top-color: var(--body); }
.tile-fallback.dom-chaos { border-top-color: var(--chaos); }
.tile-fallback.dom-order { border-top-color: var(--order); }
.tile-cost { font-weight: 800; font-size: 1rem; min-height: 1.2em; }
.tile-name { font-weight: 600; font-size: 0.85rem; line-height: 1.2; }
.tile-type { font-size: 0.72rem; color: var(--muted); margin-top: auto; }
.tile-badge { position: absolute; z-index: 2; top: 6px; right: 6px; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 0.8rem; border-radius: 999px; min-width: 24px; height: 24px; display: grid; place-items: center; padding: 0 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.builder[data-loading] .builder-search { opacity: 0.8; }
.builder-guide { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; font-size: 0.92rem; }
.builder-guide[hidden] { display: none; }

/* ------------------------------------------------- review round 1 (UX) */
::placeholder { color: var(--muted); opacity: 0.75; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.req { color: var(--danger); font-weight: 700; }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 6px 6px 0 0; color: var(--muted); border: 1px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--border); border-bottom-color: var(--bg); background: var(--bg); font-weight: 600; }
.tabs .count { font-size: 0.8em; color: var(--muted); }
.list-preview summary { color: var(--accent); }
.list-preview pre { font-size: 0.8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; max-height: 320px; overflow: auto; }
td > .pips:first-child { min-width: 26px; }
table.list td a, table.list td .sub.inline { white-space: nowrap; }
.inline-form .danger { padding: 3px 8px; }

/* mobile header: one swipeable nav row */
@media (max-width: 700px) {
  .main-nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; order: 2; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .main-nav::-webkit-scrollbar { display: none; }
  .header-row { gap: 6px 12px; }
  .header-tools { order: 1; width: auto; flex: 1; justify-content: flex-end; }
  .site-search { flex: 1; }
  .header-link { font-size: 0.9rem; }
}

/* builder: no holes in the card grids */
.card-grid { grid-auto-flow: row dense; }

/* richer text tile (shown when no image) */
.tile-top { display: flex; justify-content: space-between; align-items: center; min-height: 1.3em; }
.tile-cost { font-size: 0.85rem; }
.tile-text { font-size: 0.68rem; line-height: 1.3; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; margin-top: 2px; white-space: pre-line; }
.tile-type { margin-top: 0; }
.card-grid.compact .tile-text { -webkit-line-clamp: 3; }

/* visual-view deck tiles */
.deck-tile { cursor: default; }
.deck-tile:hover { transform: none; }
.tile-controls { position: absolute; z-index: 3; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; gap: 6px; opacity: 0; transition: opacity 0.12s; }
.deck-tile:hover .tile-controls, .deck-tile:focus-within .tile-controls { opacity: 1; }
@media (hover: none) { .tile-controls { opacity: 1; } }
.tile-controls button { width: 30px; height: 30px; padding: 0; border-radius: 50%; font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }

/* copy-limit feedback */
.tile-badge.over { background: var(--danger); color: #fff; }
.deck-row.over .row-name, .deck-row.over .qty { color: var(--danger); }
.over-flag { font-size: 0.72rem; font-weight: 700; color: var(--danger); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; }
.qty-spacer { width: 24px; display: inline-block; }

/* add-to target */
.add-target { display: flex; align-items: center; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.add-target button { padding: 3px 10px; font-size: 0.85rem; border-radius: 999px; }
.add-target button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.touch-only { display: none; }
@media (hover: none) { .touch-only { display: block; } .pointer-only { display: none; } }

/* text preview behind the hover image */
#card-preview { pointer-events: none; }
#card-preview > img { position: absolute; inset: 0; }
#card-preview { aspect-ratio: 744 / 1039; }
#card-preview.landscape { aspect-ratio: 1039 / 744; }
.preview-text { position: absolute; inset: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-top: 8px solid var(--muted); border-radius: 12px; padding: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.preview-text.dom-fury { border-top-color: var(--fury); }
.preview-text.dom-calm { border-top-color: var(--calm); }
.preview-text.dom-mind { border-top-color: var(--mind); }
.preview-text.dom-body { border-top-color: var(--body); }
.preview-text.dom-chaos { border-top-color: var(--chaos); }
.preview-text.dom-order { border-top-color: var(--order); }
.preview-top { display: flex; justify-content: space-between; gap: 8px; }
.preview-cost { font-weight: 800; white-space: nowrap; }
.preview-type { font-size: 0.8rem; color: var(--muted); }
.preview-rules { font-size: 0.85rem; white-space: pre-line; }

/* ------------------------------------------------- review round 2 (UX) */
[hidden] { display: none !important; }
.form-grid label > span:first-child { display: block; }
.show-more summary { color: var(--accent); font-size: 0.9rem; margin-top: 4px; }
.show-more ul { margin-top: 4px; }
.add-to-deck { margin-top: 8px; }
.search-filters > summary { font-weight: 600; font-size: 0.9rem; margin-top: 10px; }
.search-filters:not([open]) > summary::after { content: " …"; color: var(--muted); }

/* card text preview sized to its text unless an image is shown */
#card-preview { aspect-ratio: auto; }
#card-preview.has-img { aspect-ratio: 744 / 1039; }
#card-preview.has-img.landscape { aspect-ratio: 1039 / 744; }
#card-preview .preview-text { position: static; }
#card-preview.has-img .preview-text { position: absolute; }

/* visual tiles: badge at the bottom-right so it never covers cost or domains */
.tile-badge { top: auto !important; bottom: 6px; right: 6px; }
.deck-tile .tile-controls { justify-content: flex-start; padding-left: 6px; }

/* mobile: hint that the nav scrolls; keep tables inside the screen */
@media (max-width: 700px) {
  .main-nav { mask-image: linear-gradient(to right, #000 85%, transparent); -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 24px; }
  table.list td a, table.list td .sub.inline { white-space: normal; }
  .bar-col { width: 30%; }
  .bar-label { font-size: 0.8rem; }
  .inline-form select, .inline-form input { max-width: 120px; }
}
@media (min-width: 701px) { table.list td a { white-space: nowrap; } }

/* ------------------------------------------------- review round 3 (UX) */
.empty-results { padding: 12px 0; }
.empty-results button { margin-top: 4px; }
.button-group { display: inline-flex; }
.button-group button:first-child { border-radius: 6px 0 0 6px; }
.button-group button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
#toast.actionable { pointer-events: auto; }
.toast-action { color: var(--gold); font-weight: 700; margin-left: 10px; }
.record { white-space: nowrap; }
.stats-cell { max-width: 360px; white-space: normal; overflow-wrap: anywhere; }
.deck-tile .tile-fallback { padding-bottom: 38px; }
.confirm-text { font-size: 1rem; margin-top: 0; }
table.list td { overflow-wrap: break-word; }
table.list td.num, table.list td.nowrap { overflow-wrap: normal; }
@media (max-width: 480px) {
  .card-box { padding: 12px; }
  table.list td, table.list th { padding: 6px 5px; }
}
table.list td .sub.inline.record, table.list td.num.record { white-space: nowrap; overflow-wrap: normal; }

/* ------------------------------------------------- review round 4 (UX) */
/* WCAG AA contrast in light mode (text on --bg / --surface) */
@media (prefers-color-scheme: light), (prefers-color-scheme: no-preference) {
  :root { --accent: #08666f; --warn: #8f5200; --ok: #137a46; }
}

/* ------------------------------------------------------- plan 2 additions */
.verify-bar { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border-bottom: 1px solid var(--gold); font-size: 0.88rem; padding: 6px 0; }
.mail-body { white-space: pre-wrap; font-size: 0.85rem; background: var(--surface-2); padding: 10px; border-radius: 6px; border: 1px solid var(--border); overflow-x: auto; }
.prose { max-width: 75ch; }
.prose h2 { margin-top: 1rem; }
.prose h2:first-child { margin-top: 0; }

/* guide */
.guide-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.guide-banner p { margin: 0; }
.learn { max-width: 900px; }
.learn-hero p { max-width: 65ch; }
.learn-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 20px; }
.learn-toc a { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; background: var(--surface); }
.learn-section { scroll-margin-top: 16px; }
.learn-section h2 { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; }
.step-no { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: inline-grid; place-items: center; font-size: 1rem; flex: none; }
.learn-points li, .learn-steps li { margin: 6px 0; }
.anatomy { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.anatomy-part { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); position: relative; }
.anatomy-part.wide { grid-column: span 2; }
@media (max-width: 500px) { .anatomy-part.wide { grid-column: auto; } }
.anatomy-part h3 { margin: 0 0 4px; font-size: 1rem; }
.anatomy-part p { margin: 0; font-size: 0.88rem; color: var(--muted); }
.anatomy-n { position: absolute; top: 8px; right: 10px; font-weight: 800; color: var(--accent); }
.domain-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.domain-legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* builder tour */
.tour { position: fixed; inset: 0; z-index: 80; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10, 13, 22, 0.6); outline: 2px solid var(--gold); pointer-events: none; transition: all 0.12s ease-out; }
.tour-card { position: fixed; width: min(360px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.tour-card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.tour-card p { margin: 0 0 10px; }
.tour-count { font-size: 0.8rem; color: var(--muted); }
.tour-card .spacer { flex: 1; }

/* calendar */
.calendar-layout { display: grid; grid-template-columns: 1fr 420px; gap: 20px; align-items: start; }
.cal-aside { position: sticky; top: 12px; }
.cal-map { height: 520px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 960px) { .calendar-layout { grid-template-columns: 1fr; } .cal-aside { position: static; } .cal-map { height: 280px; } }
.cal-day h2 { font-size: 1rem; text-transform: capitalize; }
.cal-events { list-style: none; margin: 0; padding: 0; }
.cal-event { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cal-event:last-child { border-bottom: 0; }
.cal-event.flash { background: color-mix(in srgb, var(--gold) 20%, transparent); }
.cal-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.2em; color: var(--muted); }
.cal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cal-main .sub { display: block; }
.cal-meta { font-size: 0.85rem; }
.cal-when { font-weight: 600; text-transform: capitalize; }
.calendar-layout.no-map { grid-template-columns: 1fr; }

/* live */
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 60%, transparent); animation: live-pulse 1.6s infinite; vertical-align: middle; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.live-banner { display: block; margin: 12px 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); color: var(--text); font-weight: 600; }
.live-banner:hover { text-decoration: none; border-color: var(--danger); }
.live-card { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.live-card:hover { text-decoration: none; border-color: var(--accent); }
.live-top { margin: 6px 0 0; padding-left: 20px; font-size: 0.9rem; }

/* follow */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.title-row h1 { margin-bottom: 0.4rem; }
.follow-bar { display: flex; gap: 6px; align-items: center; }
.follow-bar form { margin: 0; }
.follow-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.follow-row form { margin: 0; }
.tag-banned { color: #fff; background: var(--danger); border-color: var(--danger); }

/* history / compare / odds / mulligan */
.diff td { vertical-align: middle; }
.diff-add td:last-child { color: var(--ok); }
.diff-del td:last-child { color: var(--danger); }
.compare-heads .card-box { display: flex; flex-direction: column; gap: 2px; }
.odds-box { margin-top: 12px; }
.odds-box > summary { font-weight: 600; }
.odds-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.odds-pick select { max-width: 100%; }
table.odds td, table.odds th { padding: 4px 6px; }
.hand .card-tile[data-selected] { outline: 3px solid var(--gold); outline-offset: 2px; opacity: 0.8; }

/* collection */
.owned-form { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.owned-form button { width: 26px; height: 26px; padding: 0; border-radius: 50%; font-weight: 700; }
.owned-n { min-width: 2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.owned-n.zero { color: var(--muted); font-weight: 400; }
.owned-flag { font-size: 0.72rem; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; white-space: nowrap; }

/* community */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .chip { text-decoration: none; }
.deck-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 4px; }
.deck-tags .tag { text-decoration: none; }
button.liked { color: var(--danger); border-color: var(--danger); }
.likes { color: var(--muted); padding: 7px 4px; }
.tags-box { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); margin-top: 12px; }
.csv-box { margin: 12px 0; }
.csv-box > summary { color: var(--accent); }

/* Matchup matrix */
.table-scroll { overflow-x: auto; }
table.matchups { border-collapse: collapse; font-size: 0.85rem; }
table.matchups th { font-weight: 600; white-space: nowrap; padding: 4px 6px; text-align: left; }
table.matchups thead th { vertical-align: bottom; }
table.matchups thead th span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; max-height: 9em; overflow: hidden; text-overflow: ellipsis; }
table.matchups td.mu { min-width: 52px; text-align: center; padding: 6px 4px; border: 1px solid var(--surface); background: hsl(var(--mu) 55% 45% / 0.35); font-variant-numeric: tabular-nums; }
table.matchups td.mu .sub { display: block; font-size: 0.7rem; color: var(--muted); }
table.matchups td.mu.low { opacity: 0.5; }
table.matchups td.mirror, table.matchups td.empty { background: var(--surface-2, transparent); color: var(--muted); }

/* Single sign-on */
.sso { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px; }
.sso-button { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; padding: 10px 14px; }
.sso-button svg { width: 20px; height: 20px; flex: none; }
.sso-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.sso-discord:hover { background: #4752c4; border-color: #4752c4; color: #fff; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.signin-methods { list-style: none; margin: 0; padding: 0; }
.signin-methods li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.signin-methods li:first-child { border-top: 0; }
.signin-methods form { display: flex; align-items: center; gap: 8px; margin: 0; }
.signin-methods .method { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.signin-methods .method-icon { display: inline-flex; width: 20px; justify-content: center; }
.signin-methods .method-icon svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- motion
   Short, subtle transitions that make the site feel responsive. Everything
   here is switched off for visitors who ask for reduced motion. */
:root { --ease: cubic-bezier(0.2, 0.7, 0.3, 1); --t-fast: 120ms; --t: 200ms; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  /* Cross-fade between pages in browsers that support it. */
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: ease-out; }

  /* Page content rises in, one block after another. `backwards` so nothing
     stays transformed afterwards (sticky/fixed children keep working). */
  main > * { animation: rise 280ms var(--ease) backwards; }
  main > :nth-child(2) { animation-delay: 40ms; }
  main > :nth-child(3) { animation-delay: 80ms; }
  main > :nth-child(4) { animation-delay: 120ms; }
  main > :nth-child(n + 5) { animation-delay: 160ms; }

  /* Interactive elements */
  a, button, .button, input, select, textarea, .chip, .tabs a, .main-nav a, .menu a, .menu .link-button, summary, tbody tr, .card-tile {
    transition: color var(--t-fast) ease, background-color var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t) ease, transform var(--t) var(--ease), opacity var(--t) ease;
  }
  button:not(:disabled):active, .button:active, .chip:active { transform: translateY(1px) scale(0.98); }
  .primary:hover, .sso-button:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
  .card-tile:hover { transform: translateY(-3px); }

  /* Menus and disclosures */
  details[open] > .menu { animation: pop 160ms var(--ease); transform-origin: top right; }
  details[open] > :not(summary):not(.menu) { animation: fade-in 200ms ease; }
  .notice, .errors { animation: rise 260ms var(--ease) backwards; }

  /* Charts grow into place */
  .bar { animation: grow-x 600ms var(--ease) backwards; transform-origin: left center; }
  .curve-bar { animation: grow-y 500ms var(--ease) backwards; transform-origin: bottom center; }
  .curve-col:nth-child(2) .curve-bar { animation-delay: 30ms; }
  .curve-col:nth-child(3) .curve-bar { animation-delay: 60ms; }
  .curve-col:nth-child(4) .curve-bar { animation-delay: 90ms; }
  .curve-col:nth-child(n + 5) .curve-bar { animation-delay: 120ms; }
  table.matchups td.mu { animation: fade-in 400ms ease backwards; }
}

/* Row highlight helps scanning long standings (no motion involved). */
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }

/* ------------------------------------------------------------ UX polish
   Header, tables, empty states and mobile fixes from the UX review. */
@media (max-width: 1360px) { .user-name { display: none; } .site-search input { width: 190px; } }
@media (max-width: 900px) { .site-search input { width: 100%; } }
.site-header :focus-visible { outline-color: var(--gold); }
.site-search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 155, 60, 0.35); }
.menu-head { margin: 0 0 4px; padding: 6px 10px 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; line-height: 1.3; }
.menu-head span { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; }
.menu-sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* Domain pips stay next to the name they belong to. */
.arch, .deck-cell { display: inline-flex; align-items: baseline; gap: 5px; }
.arch .pips, .deck-cell .pips { flex: none; }
/* Top 8 cut in standings */
tr.cut td { border-top: 2px solid color-mix(in srgb, var(--gold) 70%, var(--border)); }
/* Bars never push their label out of the cell. */
.bar-col .bar { max-width: calc(100% - 3.8em); }

.feed-link { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; color: var(--muted); }
.feed-link svg { width: 16px; height: 16px; }
.feed-link:hover { color: var(--body); background: var(--surface-2); }

.hero-cta { margin-top: 14px; }
.text-link { margin-left: 4px; font-size: 0.92rem; }
.export-more { margin-top: 8px; }
.export-more > summary { color: var(--muted); font-size: 0.88rem; }
.export-more[open] > summary { margin-bottom: 8px; }
.export-more input { width: 100%; margin-bottom: 6px; }
.muted-link a { color: var(--muted); }
.empty-state.small { padding: 18px 8px; }
.empty-state .muted { max-width: 52ch; margin-inline: auto; }
.center { justify-content: center; }
.cal-add { display: inline-flex; align-items: center; gap: 5px; }
.cal-add svg { width: 16px; height: 16px; }

/* Forms: one input size everywhere (16px also stops iOS from zooming). */
input, select { font-size: 1rem; }
.stack label.toggle { flex-direction: row; align-items: center; color: var(--text); font-size: 0.92rem; }
.standing { grid-template-columns: 80px 1fr 120px 1fr; }
@media (max-width: 640px) { .standing { grid-template-columns: 1fr 1fr; } .standing label:nth-child(2), .standing label.full { grid-column: 1 / -1; } }

/* Mobile layouts */
@media (max-width: 640px) {
  .filters > input[type="search"] { flex: 1 1 100%; }
  .filters > select { flex: 1 1 40%; min-width: 0; }
  .page-head { align-items: flex-start; }
  .page-head .buttons { margin-bottom: 0; }
}
@media (max-width: 960px) { .cal-map { height: 200px; } }
table.matchups tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); }

/* Motion additions */
@media (prefers-reduced-motion: no-preference) {
  #card-preview:not([hidden]) { animation: fade-in 120ms ease; }
  [data-dismiss].leaving { opacity: 0; transform: translateY(-4px); transition: opacity 180ms ease, transform 180ms ease; }
  .feed-link, .export-more > summary { transition: color var(--t-fast) ease, background-color var(--t-fast) ease; }
}

/* ---------------------------------------------------------- builder polish
   Deck builder editor: compact "More" menu, and subtle feedback when cards
   are added or counts change. Motion only for visitors who allow it. */
.menu .menu-sep { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
.stats-empty { margin: 4px 0 0; font-size: 0.9rem; }

@media (prefers-reduced-motion: no-preference) {
  /* The editor re-renders constantly: no page-entrance rise, and the energy
     curve doesn't regrow from zero on every click. */
  main > .builder { animation: none; }
  #deck-stats .curve-bar { animation: none; }

  /* Selected states and small controls change smoothly. */
  .qty-btn, .view-toggle button, .owned-form button, .builder-tabs button {
    transition: color var(--t-fast) ease, background-color var(--t-fast) ease, border-color var(--t-fast) ease, opacity var(--t) ease, transform var(--t) var(--ease);
  }
  .check-pill { transition: color var(--t) ease, border-color var(--t) ease, background-color var(--t) ease; }
  .save-status { transition: color var(--t) ease, opacity var(--t) ease; }
  .save-status.changed { animation: fade-in var(--t) ease; }

  /* The card just added or recounted: row flash and count bump. */
  .deck-row.flash { animation: builder-flash 700ms ease-out; }
  .qty.bump, .tile-badge.bump { animation: builder-bump 260ms var(--ease); }

  /* Newly shown pane: mobile Deck / Add cards tabs, List / Visual toggle. */
  #deck-sections.swap { animation: fade-in var(--t) ease; }
  @media (max-width: 900px) {
    .builder[data-tab="deck"] [data-pane="deck"], .builder[data-tab="search"] [data-pane="search"] { animation: fade-in var(--t) ease; }
  }

  /* Modals (confirm, export, import, sample hand) */
  dialog.modal[open] { animation: pop 180ms var(--ease); }
  dialog.modal[open]::backdrop { animation: fade-in var(--t) ease; }
}
@keyframes builder-flash { from { background-color: color-mix(in srgb, var(--accent) 24%, transparent); } }
@keyframes builder-bump { 40% { transform: scale(1.3); } }
.empty-state form { max-width: 560px; margin-inline: auto; }
.empty-state form input[type="search"] { flex: 1; }

/* Deck comparison: picking, basket bar, matrix */
.pick-col { display: none; width: 1%; }
.js .pick-col { display: table-cell; }
.pick-col input { margin: 0; width: 16px; height: 16px; cursor: pointer; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.box-head h2 { margin-bottom: 0.5rem; }
#compare-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 55; display: flex; align-items: center; gap: 12px; background: var(--header); color: #fff; padding: 8px 10px 8px 16px; border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100vw - 24px); }
#compare-bar .link-button { color: #cfd3e3; }
#compare-bar .button.disabled { opacity: 0.6; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) { #compare-bar { animation: bar-in 220ms var(--ease); } }
@keyframes bar-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.compare-add input[name="add"] { min-width: 260px; }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--border); padding: 4px 8px; }
table.matrix thead th { vertical-align: bottom; background: var(--surface); }
table.matrix .card-col, table.matrix tbody th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
table.matrix .deck-col { position: relative; min-width: 108px; max-width: 150px; text-align: center; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.8rem; color: var(--text); padding: 6px 18px 6px 6px; }
table.matrix .deck-col .sub { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.matrix .deck-col-title { font-weight: 600; display: block; }
table.matrix .remove { position: absolute; top: 2px; right: 4px; color: var(--muted); font-size: 1rem; line-height: 1; }
table.matrix .remove:hover { color: var(--danger); text-decoration: none; }
table.matrix .section-row th { background: var(--surface-2); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.05em; color: var(--muted); position: sticky; left: 0; }
table.matrix .section-row td { background: var(--surface-2); color: var(--muted); font-size: 0.75rem; }
table.matrix td.cnt { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 34px; }
table.matrix td.c1 { background: color-mix(in srgb, var(--accent) 12%, transparent); }
table.matrix td.c2 { background: color-mix(in srgb, var(--accent) 24%, transparent); }
table.matrix td.c3, table.matrix td.c4 { background: color-mix(in srgb, var(--accent) 38%, transparent); }
table.matrix tr.core th[scope="row"] { box-shadow: inset 3px 0 0 var(--gold); }
table.matrix.only-diff tr.core { display: none; }
table.matrix tbody tr:hover td.cnt, table.matrix tbody tr:hover th[scope="row"] { filter: brightness(0.96); }

/* Deck search, metagame styles, deck navigation */
.deck-search .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .deck-search .form-grid { grid-template-columns: 1fr; } }
.deck-search textarea { font-family: inherit; font-size: 0.95rem; }
.style-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.style-chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 0.88rem; }
.tag.style-aggro, .style-chip.style-aggro { border-color: color-mix(in srgb, var(--fury) 55%, var(--border)); }
.tag.style-control, .style-chip.style-control { border-color: color-mix(in srgb, var(--mind) 55%, var(--border)); }
.tag.style-midrange, .style-chip.style-midrange { border-color: color-mix(in srgb, var(--calm) 55%, var(--border)); }
.tag.style-combo, .style-chip.style-combo { border-color: color-mix(in srgb, var(--chaos) 55%, var(--border)); }
.crumbs-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.deck-nav { display: flex; gap: 12px; align-items: baseline; font-size: 0.9rem; }
table.matrix tbody th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.9rem; color: var(--text); }
table.matrix thead th.num, table.matrix thead th.card-col { vertical-align: bottom; }
@media (max-width: 640px) {
  table.matrix .card-col, table.matrix tbody th[scope="row"] { max-width: 128px; font-size: 0.82rem; }
  table.matrix .avg-col { display: none; }
  table.matrix .deck-col { min-width: 86px; }
}

/* Final polish (delivery review) */
.notice.ok { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.button, a.button { line-height: 1.3; }
.danger { font-weight: 600; }
.grid-2.even { row-gap: 20px; }
.grid-2.even > .card-box { margin-bottom: 0; }
.pick-col input { vertical-align: middle; }
.box-head { align-items: center; }
.box-head h2 { margin: 0.2rem 0 0.6rem; }
.sym { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; padding: 0 3px; margin: 0 1px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.78em; font-weight: 700; line-height: 1; vertical-align: 0.05em; }
/* Header on phones: the search box keeps a usable width */
@media (max-width: 700px) {
  .site-search { min-width: 110px; }
  .header-tools .button { white-space: nowrap; }
}
@media (max-width: 420px) { .header-tools .header-link { display: none; } }
/* Deck search filters on phones */
@media (max-width: 700px) { .deck-search .filters > select, .deck-search .filters > input { flex: 1 1 100%; } }
/* Comparison grid: headers stay visible, totals aligned with counts */
.matrix-scroll { max-height: 80vh; overflow: auto; }
table.matrix thead th { position: sticky; top: 0; z-index: 2; }
table.matrix thead th.card-col { z-index: 3; }
table.matrix .section-row td.num { text-align: center; }
@media (max-width: 480px) {
  table.matrix .decks-col { display: none; }
  table.matrix .deck-col { min-width: 72px; max-width: 96px; }
}
/* Compare bar never hides the footer; compact on phones */
body.has-compare-bar { padding-bottom: 80px; }
#compare-bar .button.disabled { opacity: 0.85; background: transparent; border-color: rgba(255, 255, 255, 0.4); color: #fff; }
@media (max-width: 480px) { #compare-bar { gap: 8px; padding: 6px 8px 6px 12px; font-size: 0.9rem; } }
