/* Timewalked — "Nightfall" design tokens and base styles. */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Figtree:wght@400;500;600;700&display=swap");

/* Mana symbol font -- npm package mana-font v1.18.0, font under SIL OFL
   1.1, CSS under MIT. Glyph codes: see .mana-pip below and the
   MANA_GLYPHS mapping wherever pips are rendered server-side. */
@font-face {
  font-family: "Mana";
  src: url("../fonts/mana.woff2") format("woff2");
  font-display: block;
}

:root {
  /* Light mode (derived from Nightfall; not yet mocked up) */
  --bg: #f1ebe3;
  --surface: #faf6ef;
  --surface-sunk: #ece5dc;
  --line: #d6cbdc;
  --line-strong: #b9aac4;
  --text: #1c1726;
  --text-muted: #5a4f68;
  --accent: #b4461a;          /* ember, darkened for contrast on light */
  --on-accent: #ffffff;
  --link: #9c3c16;
  --flag-gc: var(--accent);   /* Game Changer */
  --flag-warm: #8a6a1c;       /* Tutor, Fast mana */
  --flag-cool: #3f6b52;       /* Extra turn, Turn skip */
  --flag-danger: #a93a3a;     /* Mass land denial, Banned */

  /* Atmosphere (light defaults -- daylight sky, not yet visually reviewed) */
  --sky-1: #fdeccd; --sky-2: #f7dfb0; --sky-3: #ecd9be; --sky-4: #f1ebe3;
  --sky-q1: #fdeccd; --sky-q2: #f3ddb8; --sky-q3: #ecd9be;
  --atmo-star-color: #d8cfe0;
  --atmo-star-opacity: 0;
  --atmo-cloud-opacity: 1;
  --atmo-hill-1: #c9a869; --atmo-hill-2: #b98f5a; --atmo-hill-3: #8fae7a;
  --atmo-hill-4: #6f9463; --atmo-hill-5: #4f6b4a;
  --atmo-sundial-shadow: #8a7550; --atmo-sundial-base: #fff8ec;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;

  --radius-sm: 4px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;
  --tap: 44px;                /* minimum touch target */

  /* Mana (light) -- deck builder handoff, 2026-09-28. Used only for
     mana costs/pips/sources, never as general chart or UI colors. */
  --mana-w: #d9c690; --mana-u: #7fa6c9; --mana-b: #7d7089;
  --mana-r: #c96a47; --mana-g: #6f9660; --mana-c: #b3aabd;
  --on-mana: #1a0f0a;
  --mana-outline: #5a4f68;
  --scrim: rgba(28, 23, 38, 0.55);
}

/* Dark mode = the approved Nightfall mockups */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #130f1d;
    --surface: #221b2d;
    --surface-sunk: #1b1625;
    --line: #3e3350;
    --line-strong: #5d4f6a;
    --text: #efe6da;
    --text-muted: #b9aec4;
    --accent: #e0662e;
    --on-accent: #1a0f0a;
    --link: #e8804f;
    --flag-gc: var(--accent);
    --flag-warm: #c9a24a;
    --flag-cool: #8fb39a;
    --flag-danger: #e07a7a;

    --sky-1: #241c33; --sky-2: #170f26; --sky-3: #130f1d; --sky-4: #0d0a15;
    --sky-q1: #1c1c30; --sky-q2: #15121f; --sky-q3: #130f1d;
    --atmo-star-color: #d8cfe0;
    --atmo-star-opacity: 1;
    --atmo-cloud-opacity: 0;
    --atmo-hill-1: #5a4a60; --atmo-hill-2: #46394f; --atmo-hill-3: #4a6356;
    --atmo-hill-4: #36493f; --atmo-hill-5: #1b2420;
    --atmo-sundial-shadow: #2c2438; --atmo-sundial-base: #e8dcc0;

    /* Mana (dark) */
    --mana-w: #e8dcc0; --mana-u: #a9c4dc; --mana-b: #9b8fa6;
    --mana-r: #de8a68; --mana-g: #93b483; --mana-c: #cdc6d3;
    --on-mana: #1a0f0a;
    --mana-outline: transparent;
    --scrim: #0b0911;
  }
}
:root[data-theme="dark"] {
  --bg: #130f1d;
  --surface: #221b2d;
  --surface-sunk: #1b1625;
  --line: #3e3350;
  --line-strong: #5d4f6a;
  --text: #efe6da;
  --text-muted: #b9aec4;
  --accent: #e0662e;
  --on-accent: #1a0f0a;
  --link: #e8804f;
  --flag-gc: var(--accent);
  --flag-warm: #c9a24a;
  --flag-cool: #8fb39a;
  --flag-danger: #e07a7a;

  --sky-1: #241c33; --sky-2: #170f26; --sky-3: #130f1d; --sky-4: #0d0a15;
  --sky-q1: #1c1c30; --sky-q2: #15121f; --sky-q3: #130f1d;
  --atmo-star-color: #d8cfe0;
  --atmo-star-opacity: 1;
  --atmo-cloud-opacity: 0;
  --atmo-hill-1: #5a4a60; --atmo-hill-2: #46394f; --atmo-hill-3: #4a6356;
  --atmo-hill-4: #36493f; --atmo-hill-5: #1b2420;
  --atmo-sundial-shadow: #2c2438; --atmo-sundial-base: #e8dcc0;

  /* Mana (dark) */
  --mana-w: #e8dcc0; --mana-u: #a9c4dc; --mana-b: #9b8fa6;
  --mana-r: #de8a68; --mana-g: #93b483; --mana-c: #cdc6d3;
  --on-mana: #1a0f0a;
  --mana-outline: transparent;
  --scrim: #0b0911;
}

*, *::before, *::after { box-sizing: border-box; }

/* A later class rule with equal specificity (e.g. display:flex on an
   element that also toggles [hidden]) beats the UA default [hidden]
   { display: none } otherwise -- this bit the old /rate page once
   already (both answer-option groups showed at once). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--link); }
h1, h2, .display { font-family: var(--font-display); font-weight: 500; line-height: 1.1; }
img { max-width: 100%; height: auto; }

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn {
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--on-accent); border: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); }

.flag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
}
.flag-gc { color: var(--flag-gc); }
.flag-tu, .flag-fm { color: var(--flag-warm); }
.flag-xt, .flag-sk, .flag-fi { color: var(--flag-cool); }
.flag-ld, .flag-ban, .flag-nc { color: var(--flag-danger); }

/* Layer 2's per-card delta number -- deliberately NOT styled like .flag
   (no bordered box) per Chris's stated preference to avoid Layer 2
   turning into more badge-wall clutter: a small plain number instead of
   another letter code, see docs/layer2-design-decisions.md. */
.card-delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* Mana cost/pip/source symbol -- deck builder, 2026-09-28. A colored
   circle with the real Mana-font glyph, never a letter in a circle.
   The inset outline is invisible in dark and keeps pale fills (white,
   colorless) readable against the light-mode paper background --
   see docs/deck-builder-handoff/deck-builder-claude-code-handoff.md
   section 7. Wrap costs/pip groups in one element with role="img" and
   a readable aria-label; mark individual .mana-pip spans aria-hidden. */
.mana-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-family: "Mana";
  font-size: 11px;
  line-height: 1;
  color: var(--on-mana);
  box-shadow: inset 0 0 0 1px var(--mana-outline);
}
.mana-pip--lg { width: 18px; height: 18px; font-size: 13px; }
.mana-pip--w { background: var(--mana-w); }
.mana-pip--u { background: var(--mana-u); }
.mana-pip--b { background: var(--mana-b); }
.mana-pip--r { background: var(--mana-r); }
.mana-pip--g { background: var(--mana-g); }
.mana-pip--c { background: var(--mana-c); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Layout shell ---------- */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-6);
}
.page--wide { max-width: 900px; }
.page--builder { max-width: 1320px; }

/* Wizards of the Coast Fan Content Policy requires this notice on
   every page that uses mana symbols or other WotC materials -- see
   docs/deck-builder-handoff/deck-builder-claude-code-handoff.md
   section 7d. Verified against the policy's own published wording. */
.site-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-4);
  text-align: center;
}
.site-footer p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---------- Header / nav ---------- */

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
}
.site-header--overlay { border-bottom: none; }
/* The header has no background fill, but its box still spans the full
   width at z-index:1 -- without this, empty space between the wordmark
   and header-actions silently blocks clicks on anything in the
   atmosphere layer underneath it (e.g. a moon toggle positioned high
   enough to sit behind the header). */
.site-header { pointer-events: none; }
.site-header > * { pointer-events: auto; }

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.header-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.header-account-email { font-size: 13px; color: var(--text-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-signout-form { display: contents; }
@media (max-width: 719px) {
  .header-account-email { display: none; }
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { border-color: var(--line-strong); }

.nav-links {
  list-style: none;
  margin: 0;
  padding: var(--space-2) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.nav-links[hidden] { display: none; }
.nav-links a {
  display: block;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.nav-links a:hover { background: var(--surface-sunk); }
.nav-links a[aria-current="page"] { color: var(--accent); }

@media (min-width: 720px) {
  #nav-toggle { display: none; }
  .nav-links {
    position: static;
    flex-direction: row;
    gap: var(--space-4);
    padding: 0;
    background: none;
    border-bottom: none;
  }
  /* Beats the global [hidden] { display: none !important; } reset above --
     on desktop the nav is always shown regardless of the hidden attribute,
     since #nav-toggle is hidden here too and there'd be no way to reveal it
     otherwise. */
  .nav-links[hidden] { display: flex !important; }
  .nav-links a { padding: var(--space-2); font-size: 14px; }
}

/* "Rate a card" nav dropdown -- the button is styled to look identical
   to the plain <a> nav items next to it; data-active mirrors what
   aria-current="page" drives for links, since that attribute is
   link-specific. */
.nav-item-submenu { position: relative; }
.nav-submenu-toggle {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.nav-submenu-toggle:hover { background: var(--surface-sunk); }
.nav-submenu-toggle[data-active="true"] { color: var(--accent); }

.nav-submenu {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0 0 0 var(--space-4);
}
.nav-submenu a {
  display: block;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-submenu a:hover { background: var(--surface-sunk); color: var(--text); }

@media (min-width: 720px) {
  .nav-submenu-toggle { padding: var(--space-2); font-size: 14px; width: auto; }
  .nav-submenu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 20;
    min-width: 180px;
    margin: 0;
    padding: var(--space-1);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  }
  .nav-submenu a { padding: var(--space-2) var(--space-3); }
}

/* ---------- Buttons ---------- */

.btn-primary:hover { background: var(--link); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- Segmented toggle ---------- */

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.segmented--block { display: flex; width: 100%; }
.segmented button {
  min-height: 38px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}
.segmented button[aria-pressed="true"] { background: var(--line); color: var(--text); }

/* ---------- Panel ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

/* ---------- Flags ---------- */

.flag-list { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.flag-legend { margin: var(--space-3) 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }

/* ---------- Atmosphere (shared backdrop, all six pages) ----------
   Layered/tiling, not one flat picture: a CSS gradient sky (never
   crops, any width) + a repeating SVG star tile (resolution-independent)
   + one fixed-position moon/sun + one wide hill/sundial SVG strip.
   Replaces the old single 390x844 night-backdrop SVG, which cropped the
   moon/stars out of frame at desktop widths -- see BACKLOG.md's
   "Night-sky backdrop is inconsistent" bug and
   docs/design-handoff-backdrop.md for the full history. */

.backdrop-wrap { position: relative; overflow: hidden; background: var(--bg); }
.backdrop-wrap > .site-header,
.backdrop-wrap > .nav-links,
.backdrop-wrap > .page { position: relative; z-index: 1; }

.atmo {
  position: absolute; top: 0; left: 0; width: 100%;
  height: 100vh; max-height: 844px; z-index: 0;
  overflow: hidden; pointer-events: none;
}
.atmo--hero { height: 170px; max-height: none; }
@media (min-width: 720px) { .atmo--hero { height: 280px; } }
.atmo-toggle { pointer-events: auto; }

.atmo-sky { position: absolute; inset: 0; transition: background .5s ease; }
.atmo-sky--full  { background: radial-gradient(ellipse 900px 500px at var(--sky-cx, 80%) var(--sky-cy, 8%), var(--sky-1) 0%, var(--sky-2) 42%, var(--sky-3) 75%, var(--sky-4) 100%); }
.atmo-sky--quiet { background: radial-gradient(ellipse 900px 400px at var(--sky-cx, 50%) var(--sky-cy, 0%), var(--sky-q1) 0%, var(--sky-q2) 55%, var(--sky-q3) 90%); }

/* The "journey": each page's sky gradient is centered differently and
   the moon sits in a different spot, so the scene subtly shifts as you
   move around the site instead of resetting to one fixed image. */
.atmo--home       .atmo-sky { --sky-cx: 78%; --sky-cy: 14%; }
.atmo--rate        .atmo-sky { --sky-cx: 82%; --sky-cy: 8%; }
.atmo--leaderboard .atmo-sky { --sky-cx: 55%; --sky-cy: 6%; }
.atmo--commander   .atmo-sky { --sky-cx: 50%; --sky-cy: 0%; }
.atmo--insights    .atmo-sky { --sky-cx: 70%; --sky-cy: 0%; }
.atmo--decks       .atmo-sky { --sky-cx: 40%; --sky-cy: 6%; }

.atmo-stars  { position: absolute; top: 0; left: 0; width: 100%; height: 55%; opacity: var(--atmo-star-opacity); }
.atmo-clouds { position: absolute; top: 0; left: 0; width: 100%; height: 55%; opacity: var(--atmo-cloud-opacity); }
.atmo--quiet .atmo-stars  { height: 40%; opacity: calc(var(--atmo-star-opacity) * .5); }
.atmo--quiet .atmo-clouds { height: 40%; opacity: calc(var(--atmo-cloud-opacity) * .8); }
/* Insights is the last stop on the "journey" -- dimmer than /commander's
   quiet sky, reading as later and quieter rather than just "same minus
   a moon". */
.atmo--insights.atmo--quiet .atmo-stars  { opacity: calc(var(--atmo-star-opacity) * .3); }
.atmo--insights.atmo--quiet .atmo-clouds { opacity: calc(var(--atmo-cloud-opacity) * .6); }
.atmo--home  .atmo-stars, .atmo--home  .atmo-clouds { height: 65%; }
.atmo--hero  .atmo-stars, .atmo--hero  .atmo-clouds { height: 100%; }

/* Wide and short on purpose (1600x260) -- the entire reason
   preserveAspectRatio="xMidYMid slice" is safe here: at any real browser
   width, slicing only trims empty margin off the sides, never the
   content in the middle. Don't shrink this viewBox. */
.atmo-hills { position: absolute; bottom: 0; left: 0; width: 100%; height: 34%; display: block; }
/* Hero mode's band is too short and sits right behind page heading text
   for the full-width hill/sundial strip to have anywhere safe to go --
   sky + stars + moon only here, same restraint the old hero-band SVG
   had (its own small sundial lived off to the side, clear of the
   heading, which a full-bleed 1600-wide strip can't replicate at every
   viewport width). */
.atmo--hero .atmo-hills { display: none; }

.atmo-toggle {
  position: absolute; z-index: 2; background: none; border: none;
  padding: 16px; margin: -16px; cursor: pointer; border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.atmo-toggle:hover { background: rgba(255, 255, 255, .06); }
.atmo-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.atmo-icon { position: absolute; inset: 16px; transition: opacity .5s ease, transform .5s ease; }
.atmo-icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }
.atmo-icon-sun  { opacity: 0; transform: scale(.4) rotate(-90deg); }
:root[data-theme="light"] .atmo-icon-moon { opacity: 0; transform: scale(.4) rotate(90deg); }
:root[data-theme="light"] .atmo-icon-sun  { opacity: 1; transform: scale(1) rotate(0deg); }

.atmo--home        .atmo-toggle { top: 10%; right: 12%; width: 44px; height: 44px; }
.atmo--rate        .atmo-toggle { top: 8%; right: 10%; width: 110px; height: 110px; }
.atmo--leaderboard .atmo-toggle { top: 8%; left: 50%; width: 96px; height: 96px; margin-left: -48px; }
@media (max-width: 600px) {
  .atmo--rate        .atmo-toggle { width: 70px; height: 70px; }
  .atmo--leaderboard .atmo-toggle { width: 56px; height: 56px; }
  .atmo--home        .atmo-toggle { width: 40px; height: 40px; }
}

/* Header fallback toggle -- present on every page next to the nav
   hamburger, since /commander and /insights have no visible moon. */
.header-theme-btn { position: relative; overflow: hidden; }
.header-theme-btn .atmo-icon { inset: 8px; }

/* ---------- Hero (decklist classifier) ---------- */

.hero {
  position: relative;
  padding-top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { margin: 0; font-size: 34px; max-width: 26ch; }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.field textarea,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  box-sizing: border-box;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
}
.field textarea { resize: vertical; }
.field textarea:focus,
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.commander-input-row { display: flex; gap: var(--space-4); flex-wrap: wrap; }

.auth-panel { max-width: 420px; margin: var(--space-6) auto 0; }
.auth-divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; color: var(--text-muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex-grow: 1; height: 1px; background: var(--line); }
.auth-error-panel { border-color: var(--flag-danger); color: var(--flag-danger); }
.commander-input-group { flex: 1 1 240px; position: relative; display: flex; flex-direction: column; gap: var(--space-2); }
.commander-autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  max-height: 260px;
  overflow-y: auto;
}
.commander-autocomplete li { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }
.commander-autocomplete li:hover,
.commander-autocomplete li.is-active { background: var(--surface-sunk); color: var(--accent); }

.commander-flag-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.commander-flag-list li { color: var(--accent); font-size: 14px; font-weight: 600; }

/* ---------- Verdict panel ---------- */

.verdict {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.verdict-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 72px;
  line-height: 0.85;
  color: var(--accent);
}
.verdict.is-illegal .verdict-number { color: var(--flag-danger); font-size: 40px; }
.verdict-name { font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.verdict-secondary { display: flex; align-items: baseline; gap: var(--space-2); }
.verdict-number-secondary {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  line-height: 0.85;
  color: var(--text);
}
.verdict-name-secondary { font-size: 14px; color: var(--text-muted); }
.verdict ul, .panel ul.reasons {
  margin: var(--space-4) 0 0;
  padding: 0 0 0 1.1em;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 15px;
  line-height: 1.45;
  width: 100%;
}

/* ---------- Stat tiles ---------- */

.stats-grid {
  margin: var(--space-4) 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}
.stat-tile {
  padding: var(--space-3) var(--space-2);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-tile-n { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-tile-label { font-size: 12px; line-height: 1.25; color: var(--text-muted); }

/* ---------- Card list ---------- */

.card-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-6) 0 var(--space-3);
}
.card-list-header h2 { margin: 0; font-size: 22px; }

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
}
.card-list li:last-child .card-row { border-bottom: none; }
.card-thumb {
  flex-shrink: 0;
  width: 40px;
  height: 56px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--line) center/cover no-repeat;
  object-fit: cover;
}
.card-row-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card-row-top { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.card-row-name { font-size: 16px; font-weight: 600; }
.card-row-cost { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-row-type { font-size: 13px; color: var(--text-muted); margin-right: 2px; }
.card-row.not-found { color: var(--text-muted); font-style: italic; }

/* Desktop: return to a real table */
@media (min-width: 720px) {
  .card-list--table { display: table; width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface-sunk); }
  .card-list--table .card-row { display: table-row; padding: 0; }
  .card-list--table .card-row > * { display: table-cell; padding: 10px var(--space-3); vertical-align: middle; }
}

/* ---------- Rate: player status bar ---------- */

.status-bar { display: flex; align-items: center; gap: var(--space-3); }
.status-bar-main { display: flex; flex-direction: column; gap: 6px; flex-grow: 1; min-width: 0; }
.status-bar-row { display: flex; justify-content: space-between; font-size: 14px; gap: var(--space-2); }
.status-bar-row .name { font-weight: 700; }
.status-bar-row .muted { color: var(--text-muted); font-weight: 500; }
.xp-track { height: 6px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.xp-fill { height: 100%; background: var(--accent); border-radius: var(--radius-pill); transition: width 0.6s ease; }
.streak-block { flex-shrink: 0; padding-left: var(--space-3); border-left: 1px solid var(--line); text-align: center; }
.streak-number { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1; }
.streak-label { font-size: 11px; color: var(--text-muted); }
.name-form { margin-top: var(--space-3); display: flex; gap: var(--space-2); }
.name-form input { flex-grow: 1; font-size: 14px; padding: var(--space-2) var(--space-3); }

/* ---------- Rate: card stage ---------- */

.card-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-6);
  min-height: 420px;
}
.prompt { text-align: center; margin: 0 0 var(--space-1); font-size: 17px; max-width: 34ch; }
.calibration-note { text-align: center; font-size: 13px; color: var(--text-muted); margin: 0; }

.card-image-btn {
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
}
.card-image-btn:disabled { cursor: default; }
.card-image-btn:not(:disabled):hover .card-image,
.card-image-btn:focus-visible .card-image { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-image {
  display: block;
  width: 232px;
  max-width: 70vw;
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  background: var(--surface-sunk);
}
.flip-hint { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text-muted); }

.card-name { text-align: center; font-family: var(--font-display); font-size: 20px; font-weight: 500; margin: var(--space-2) 0; }
.example-decklist-wrap { margin: 0 0 var(--space-2); }

.answer-options { display: flex; justify-content: center; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
.answer-options label {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  cursor: pointer;
  font-weight: 600;
}
.answer-options input { position: absolute; opacity: 0; }
.answer-options label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.answer-options label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-label { align-self: center; font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.notes-field textarea { min-height: 64px; }

/* ---------- Rate: result banner ---------- */

.result-banner {
  position: relative;
  padding: var(--space-4) var(--space-5) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.result-points {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.result-points-row { display: flex; align-items: baseline; gap: var(--space-2); }
.result-points-unit { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.result-message { margin: 0; font-size: 16px; line-height: 1.45; }
.result-dist { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; gap: 2px; }
.result-dist span { display: block; background: var(--line); }
.result-dist span.is-majority { background: var(--accent); }
.result-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.result-hint { font-size: 13px; color: var(--text-muted); }
.result-calibration { font-size: 13px; color: var(--flag-warm); margin: 0; }

.spark {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 20;
  animation: spark-burst 0.7s ease-out forwards;
}
@keyframes spark-burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}
.result-points.pop { animation: points-pop 0.5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes points-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}
.level-up-flash { animation: flash 1s ease; }
@keyframes flash {
  0% { color: var(--flag-warm); transform: scale(1.4); display: inline-block; }
  100% { color: inherit; transform: scale(1); display: inline-block; }
}

/* ---------- Help popover ---------- */

.help-popover {
  position: fixed;
  top: 64px;
  right: var(--space-4);
  width: min(320px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-size: 14px;
  z-index: 30;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.help-popover[hidden] { display: none; }
.help-popover p { margin: 0 0 var(--space-3); line-height: 1.4; }
.help-popover p:last-child { margin-bottom: 0; }
.help-popover strong, .intro-panel strong { color: var(--accent); }

/* ---------- Commander lookup ---------- */

.commander-header { display: flex; gap: var(--space-5); align-items: flex-start; flex-wrap: wrap; }
.commander-header img { width: 160px; border-radius: var(--radius); flex-shrink: 0; }
.commander-name { font-family: var(--font-display); font-size: 26px; font-weight: 500; margin: 0; }
.commander-type { color: var(--text-muted); margin: var(--space-1) 0; }
.commander-sample-size { color: var(--text-muted); font-size: 14px; }
.commander-common-bracket { color: var(--accent); font-size: 14px; font-weight: 600; margin: var(--space-1) 0 0; }
.commander-links { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-2); }
.back-to-rating { font-weight: 600; }

.bracket-bars { list-style: none; padding: 0; margin: var(--space-3) 0 0; }
.bracket-bars li { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); font-size: 14px; }
.bar-track { background: var(--line); border-radius: var(--radius-sm); height: 10px; overflow: hidden; }
.bar-fill { display: block; background: var(--line-strong); height: 100%; }
.bar-fill.is-max { background: var(--accent); }

.category-block { margin-top: var(--space-5); }
.category-block h2 { font-size: 18px; margin: 0 0 var(--space-1); }
.card-pct-list { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px var(--space-5); }
.card-pct-list li { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 14px; border-bottom: 1px dotted var(--line); padding-bottom: 3px; }
.card-pct-list .pct { color: var(--text-muted); white-space: nowrap; }
.card-image-grid { display: none; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-3) var(--space-2); margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.card-image-item { text-align: center; font-size: 13px; }
.card-image-item img { width: 100%; border-radius: 4.5% / 3.5%; display: block; }
.card-image-item .thumb-wrap { width: 100%; }
.card-image-item .thumb-zoom { width: 280px; max-width: 65vw; border-radius: var(--radius); }
.card-image-item .card-image-name { margin-top: 5px; line-height: 1.2; }
.card-image-item .card-image-pct { color: var(--text-muted); }
body[data-view="images"] .card-pct-list { display: none; }
body[data-view="images"] .card-image-grid { display: grid; }

@media (max-width: 600px) {
  .card-pct-list { grid-template-columns: 1fr; }
  .commander-header { flex-direction: column; }
}

/* ---------- Leaderboard ---------- */

.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td { padding: var(--space-3); text-align: left; border-bottom: 1px solid var(--line); }
.leaderboard-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.leaderboard-table .rank { font-family: var(--font-display); font-size: 18px; font-weight: 700; width: 2.5em; }
.leaderboard-table .rank.top-three { color: var(--accent); }
.leaderboard-table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .leaderboard-table .col-longest { display: none; }
}

/* ---------- Intro ---------- */

.intro-panel { max-width: 520px; margin: var(--space-6) auto 0; text-align: left; }
.intro-panel .eyebrow { text-align: center; display: block; }
.intro-panel h1 { text-align: center; margin: var(--space-2) 0 var(--space-4); }
.intro-lede { text-align: center; color: var(--text-muted); margin: 0 0 var(--space-5); }

/* ---------- Misc ---------- */

.not-found-msg { color: var(--flag-danger); font-weight: 600; }
.page--xwide { max-width: 1120px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--text); }
.back-link svg { width: 14px; height: 14px; }

/* ---------- Insights: stat tiles ---------- */

.stat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-tile { background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; line-height: 1.25; color: var(--text-muted); }

.section-head { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); max-width: 640px; }
.section-head h2 { margin: 0; font-size: 22px; }
@media (min-width: 720px) { .section-head h2 { font-size: 28px; } }
.muted-panel { background: var(--surface-sunk); border-style: dashed; }

/* ---------- Insights: VoteSpread (new 8th component -- per-card dot plot of
   individual votes across 1-5 plus a separate "any" count; DistributionBar
   is only built for a single aggregate percentage, not a raw spread) ---- */

.vote-card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
@media (min-width: 860px) { .vote-card-list { grid-template-columns: repeat(2, 1fr); } }
.vote-card { background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); }
.vote-card-head { display: flex; align-items: center; gap: var(--space-3); }
.vote-card-name { font-weight: 600; font-size: 15px; flex: 1 1 auto; }
.spread-badge { flex: none; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 7px; border-radius: var(--radius-sm); border: 1px solid var(--flag-danger); color: var(--flag-danger); }
.vote-card.is-agreed .spread-badge { border-color: var(--flag-cool); color: var(--flag-cool); }
.vote-card-meta { font-size: 12px; color: var(--text-muted); margin: 0; }

.thumb-wrap { flex: none; position: relative; padding: 0; margin: 0; border: none; background: none; cursor: zoom-in; border-radius: var(--radius-sm); display: block; }
.thumb { display: block; width: 56px; height: 78px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.thumb-zoom { position: absolute; top: 0; left: calc(100% + 10px); z-index: 30; width: 280px; max-width: 65vw; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line-strong); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5); opacity: 0; visibility: hidden; transform: translateX(-6px); pointer-events: none; transition: opacity 0.12s ease, transform 0.12s ease; }
.thumb-wrap:hover .thumb-zoom, .thumb-wrap:focus-visible .thumb-zoom, .thumb-wrap:focus-within .thumb-zoom { opacity: 1; visibility: visible; transform: translateX(0); }
.thumb-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 700px) {
  .thumb-zoom { top: calc(100% + 10px); left: 0; transform: translateY(-6px); }
  .thumb-wrap:hover .thumb-zoom, .thumb-wrap:focus-visible .thumb-zoom, .thumb-wrap:focus-within .thumb-zoom { transform: translateY(0); }
}

.vote-spread { display: flex; align-items: flex-end; gap: var(--space-3); }
.vs-track { flex: 1 1 auto; display: flex; align-items: flex-end; gap: 6px; height: 52px; }
.vs-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; }
.vs-dots { display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; }
.vs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.is-agreed .vs-dot { background: var(--flag-cool); }
.vs-baseline { width: 100%; height: 1px; background: var(--line); }
.vs-num { font-size: 11px; color: var(--text-muted); }
.vs-any { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 8px; border-radius: var(--radius); border: 1px dashed var(--line-strong); }
.vs-any-count { font-size: 13px; font-weight: 700; }
.vs-any-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; }

.view-all-link { margin-top: var(--space-4); }

/* ---------- Insights: category comparison ---------- */

.category-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.category-row { display: grid; grid-template-columns: 128px 1fr auto; align-items: center; gap: var(--space-3); }
.category-name { font-size: 14px; font-weight: 600; }
.category-track { height: 10px; border-radius: var(--radius-pill); background: var(--surface-sunk); border: 1px solid var(--line); overflow: hidden; }
.category-fill { display: block; height: 100%; background: var(--line-strong); border-radius: var(--radius-pill); }
.category-fill.is-top { background: var(--accent); }
.category-value { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.category-avg { font-size: 15px; font-weight: 700; }
.category-row.is-top .category-avg, .category-row.is-top .category-name { color: var(--accent); }
.category-n { font-size: 12px; color: var(--text-muted); }
@media (max-width: 560px) {
  .category-row { grid-template-columns: 1fr; gap: var(--space-1); }
  .category-value { order: 2; }
}

/* ---------- Insights: bar charts + votes-over-time ---------- */

.charts-row { display: grid; gap: var(--space-5); }
@media (min-width: 780px) { .charts-row { grid-template-columns: 1fr 1fr; } }
.chart-block { display: flex; flex-direction: column; gap: var(--space-2); }
.chart-block svg { width: 100%; height: auto; }
.chart-title { margin: 0 0 var(--space-1); font-size: 18px; }
.time-chart { display: flex; flex-direction: column; gap: var(--space-2); }
.time-chart svg { width: 100%; max-width: 420px; height: auto; }
.muted-note { color: var(--text-muted); font-size: 13px; }

/* ---------- Insights: calibration bar ---------- */

.calibration-bar { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; gap: 2px; margin-top: var(--space-3); max-width: 220px; }
.calibration-bar span { display: block; height: 100%; background: var(--surface); }
.calibration-bar span.is-filled { background: var(--flag-cool); }

/* ---------- Insights/cards: sortable table ---------- */

.table-scroll { overflow: auto; max-height: 70vh; }
table.ratings { width: 100%; border-collapse: collapse; min-width: 520px; }
table.ratings th, table.ratings td { padding: var(--space-3); text-align: left; border-bottom: 1px solid var(--line); }
table.ratings thead th { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; position: sticky; top: 0; z-index: 5; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
table.ratings tbody tr:hover { background: var(--surface-sunk); }
th.is-sortable { padding: 0; }
.sort-btn { width: 100%; height: 100%; padding: var(--space-3); border: none; background: none; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); }
.sort-btn:hover { color: var(--text); }
.sort-arrow { width: 10px; height: 10px; opacity: 0; flex: none; }
.sort-btn[aria-sort="ascending"] .sort-arrow, .sort-btn[aria-sort="descending"] .sort-arrow { opacity: 1; color: var(--accent); }
.sort-btn[aria-sort="ascending"] .sort-arrow { transform: rotate(180deg); }

.row-card { display: flex; align-items: center; gap: var(--space-3); }
.row-thumb { display: block; flex: none; width: 32px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); overflow: hidden; background: var(--surface-sunk); }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.row-name { font-weight: 600; }
.num-cell { font-variant-numeric: tabular-nums; }
.any-cell { color: var(--text-muted); }

/* ---------- Deck Builder: /decks (library + new-deck flow) ---------- */
/* Step 2 of docs/deck-builder-handoff/deck-builder-claude-code-handoff.md's
   build order -- desktop layout matches mockups/decks-library.html. */

.decks-layout { display: flex; gap: var(--space-6); align-items: flex-start; flex-wrap: wrap; }
.decks-layout--solo .deck-new-panel { max-width: 560px; }
.deck-new-panel { width: 100%; max-width: 480px; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.deck-new-panel h2 { margin: 0; }
.deck-saved-panel { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.deck-saved-panel h2 { margin: 0; }
.deck-saved-header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.deck-saved-header .count { font-size: 14px; color: var(--text-muted); }

.deck-tab-panel[hidden] { display: none; }

.deck-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.deck-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-sunk);
  border-radius: var(--radius);
}
.deck-row-image { width: 104px; height: 76px; flex-shrink: 0; border-radius: var(--radius); background: linear-gradient(160deg, var(--line), var(--surface) 70%); border: 1px solid var(--line); object-fit: cover; display: block; }
.deck-row-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.deck-row-name { font-family: var(--font-display); font-size: 20px; font-weight: 500; color: var(--text); text-decoration: none; }
.deck-row-name:hover { color: var(--link); }
.deck-row-commander { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--text-muted); }
.deck-row-meta { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.deck-row-stat { width: 72px; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.deck-row-stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.deck-row-stat-n { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.1; }
.deck-row-menu-wrap { position: relative; flex-shrink: 0; }
.deck-row-menu {
  margin: 0;
  padding: var(--space-1);
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  min-width: 160px;
}
.deck-row-menu button {
  width: 100%;
  text-align: left;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.deck-row-menu button:hover { background: var(--surface-sunk); }
.deck-row-menu button.is-danger { color: var(--flag-danger); }
.deck-empty-note { padding: var(--space-4); color: var(--text-muted); font-size: 14px; }

@media (max-width: 719px) {
  .deck-row { flex-wrap: wrap; row-gap: var(--space-2); }
  .deck-row-body { flex: 1 1 100%; }
  .deck-row-stat { width: auto; }
}

/* ---------- Deck Builder: /decks/<id> header ---------- */

/* ---------- Commander-art deck header (card-detail-handoff, step 7) ----------
   Imagery exception: the banner may show the commander's (or chosen
   deck-image card's) Scryfall art_crop, since it depicts that specific
   card in this specific deck -- never page decoration, always credited
   (see .deck-hero-credit). Falls back to the plain surface color with
   no art loads; never a broken image (renderDeckHero in deck-builder.js). */
.deck-hero {
  position: relative;
  height: 380px;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  display: flex;
  align-items: flex-end;
}
.deck-hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.deck-hero-scrim { position: absolute; inset: 0; }
.deck-hero-scrim--side {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--bg) 92%, transparent) 0%,
    color-mix(in srgb, var(--bg) 55%, transparent) 45%,
    color-mix(in srgb, var(--bg) 12%, transparent) 100%
  );
}
.deck-hero-scrim--bottom {
  background: linear-gradient(180deg, transparent 45%, var(--bg) 100%);
}
.deck-hero-glow { position: absolute; inset: 0; }
.deck-hero-credit {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 11px;
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border-radius: 4px;
  padding: 2px 8px;
}
.deck-hero-content {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0 var(--space-5) var(--space-5);
  display: flex;
  align-items: flex-end;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.deck-header-info { flex: 1 1 320px; display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.deck-header-info h1 { margin: 0; font-size: 60px; line-height: 1.02; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); }
.deck-header-meta { margin: 0; color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.deck-header-meta strong { color: var(--text); font-weight: 600; }
.deck-hero-verdict { margin: 4px 0 0; font-family: var(--font-display); font-size: 20px; line-height: 1.35; font-style: italic; color: var(--text); }
.deck-hero-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.deck-header-save-note { margin: 0; font-size: 13px; color: var(--text-muted); }
#deck-sync-status.is-error { color: var(--flag-danger); }

.deck-score-tiles { display: flex; gap: var(--space-3); flex-shrink: 0; }
.deck-score-tile {
  width: 168px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--text-muted) 25%, transparent);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.deck-score-label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.deck-score-n { font-family: var(--font-display); font-size: 56px; line-height: 0.9; font-weight: 700; color: var(--line-strong); }
.deck-score-n.is-live { color: var(--accent); }
.deck-score-note { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.deck-score-tile { position: relative; }
.deck-score-roll-box { display: block; overflow: hidden; }
.deck-score-delta {
  position: absolute;
  right: var(--space-4);
  top: 38px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--flag-danger);
  opacity: 0;
  pointer-events: none;
}
.deck-score-delta.is-down { color: var(--text-muted); }

/* ---------- Score motion (card-detail-handoff, step 8) ----------
   "Motion shows cause and effect" -- animate only what changed, in
   order, after a single user edit; never on load, import, undo or a
   batched multi-edit response (see scheduleScoreRecompute's own
   single-edit tracking). Keyframes ported directly from the handoff's
   score-moment-demo.html. */
@keyframes twPop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes twSlide { 0% { transform: translateY(14px) scale(0.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes twRoll { 0% { transform: translateY(45%); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes twFloat { 0% { transform: translateY(8px); opacity: 0; } 15% { transform: none; opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }
@keyframes twGlow { 0% { background-color: color-mix(in srgb, var(--accent) 24%, transparent); } 100% { background-color: transparent; } }
@keyframes twFade { from { opacity: 0; } to { opacity: 1; } }
.tw-pop { animation: twPop 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tw-slide { animation: twSlide 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tw-roll { animation: twRoll 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tw-float { animation: twFloat 1.8s ease-out both; }
.tw-glow { animation: twGlow 1.6s ease-out both; border-radius: 6px; }
.tw-fade { animation: twFade 0.4s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .tw-pop, .tw-slide, .tw-roll, .tw-glow, .tw-fade { animation: none !important; }
  .tw-float { display: none; }
  .ratio-row-fill { transition: none; }
}

@media (max-width: 719px) {
  /* height:auto + min-height rather than a fixed height -- stacking the
     title, commander line, verdict and tiles vertically (below) can run
     taller than 240px, and a fixed height + overflow:hidden would clip
     the title clean off (caught live: "Untitled deck" wasn't rendering
     at all under the fold). */
  .deck-hero { height: auto; min-height: 240px; align-items: stretch; }
  .deck-hero-content { flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-4); }
  .deck-header-info h1 { font-size: 30px; line-height: 1.08; }
  .deck-hero-verdict { font-size: 16px; }
  .deck-score-tiles { flex-wrap: wrap; width: 100%; }
  .deck-score-tile { width: auto; flex: 1 1 130px; }
}

.deck-builder-body { display: flex; gap: var(--space-6); align-items: flex-start; flex-wrap: wrap; }
.deck-builder-main { flex: 1 1 600px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.deck-builder-sidebar { width: 100%; max-width: 360px; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.deck-sidebar-content { display: flex; flex-direction: column; gap: var(--space-4); min-width: 300px; }

.deck-sidebar-toggle { align-self: flex-end; }
.deck-sidebar-toggle svg { transition: transform 0.15s ease; }

/* Collapsed: shrink to just the toggle button and let the grid reclaim
   the freed width -- the toggle itself stays put so it's always there
   to expand again (section 9's phone-layout pass didn't cover this;
   added per Chris's own review asking for a way to shrink this column). */
.deck-builder-sidebar--collapsed { width: auto; max-width: none; gap: 0; }
.deck-builder-sidebar--collapsed .deck-sidebar-content { display: none; }
.deck-builder-sidebar--collapsed .deck-sidebar-toggle svg { transform: rotate(180deg); }

.deck-search { position: relative; max-width: 520px; }
.deck-search input[type="search"] {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4) 0 42px;
  background: var(--surface-sunk);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 15px;
}
.deck-search input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.deck-search-icon { position: absolute; left: 14px; top: 13px; color: var(--text-muted); pointer-events: none; }
.deck-search-option { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; }
.deck-search-option-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.deck-search-option-name { font-weight: 600; }
.deck-search-option-type { font-size: 13px; color: var(--text-muted); }
.deck-search-option-pips { display: flex; gap: 3px; flex-shrink: 0; }
.deck-search-empty { padding: var(--space-3); font-size: 14px; color: var(--text-muted); }

.deck-empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}
.deck-empty-state h2 { margin: 0; }
.deck-empty-state p { margin: 0; max-width: 460px; color: var(--text-muted); }

/* ---------- Deck Builder: grid, step 3 ---------- */

.switch {
  width: 60px;
  height: 44px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}
.switch-track {
  width: 44px;
  height: 26px;
  box-sizing: border-box;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  border: 1px solid var(--line-strong);
  padding: 2px;
  display: flex;
  justify-content: flex-start;
  transition: background 0.15s ease;
}
.switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { background: var(--on-accent); transform: translateX(18px); }

.deck-toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.deck-toolbar-spacer { flex-grow: 1; }
.deck-toolbar select {
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.deck-toolbar .btn-ghost { min-height: 44px; }
.deck-card-count { font-size: 15px; }
.deck-card-count.is-over { color: var(--flag-danger); font-weight: 700; }
.deck-card-count-note { display: block; font-size: 13px; font-weight: 600; color: var(--flag-danger); }

.deck-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.deck-group:first-child { margin-top: 0; }
.deck-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.deck-group-header h2 { margin: 0; font-size: 22px; }
.deck-group-count { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.deck-group-collapse {
  margin-left: auto;
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.deck-group[data-collapsed="true"] .deck-grid { display: none; }
.deck-group[data-collapsed="true"] .deck-group-collapse svg { transform: rotate(180deg); }

.deck-outside-divider { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-6); }
.deck-outside-divider-line { height: 1px; flex-grow: 1; background: var(--line-strong); }
.deck-outside-divider-label { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.deck-outside-divider-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.deck-outside-divider-note { font-size: 13px; color: var(--text-muted); }

.deck-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 20px var(--space-4);
}
@media (max-width: 1279px) {
  .deck-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .deck-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 719px) {
  .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.deck-card-tile { position: relative; display: flex; flex-direction: column; gap: var(--space-2); }
.deck-card-open { display: block; width: 100%; padding: 0; border: none; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.deck-card-open .deck-card-frame { width: 100%; }
.deck-card-frame {
  position: relative;
  aspect-ratio: 63 / 88;
  box-sizing: border-box;
  border-radius: 7px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: box-shadow 0.1s ease;
}
/* Real Scryfall images carry the card's own printed border, and some
   printings (retro/old-white-border frames, some silver-bordered/
   showcase treatments) are genuinely white or light instead of black --
   Scryfall has no image variant that strips a card's own border, so
   there's no clean crop fix. A soft inset vignette darkens just the
   edges to keep those outliers from popping jarringly against the dark
   theme, without meaningfully touching the art/text in the middle.
   A pseudo-element rather than the frame's own box-shadow, so it
   doesn't fight the hover/selection/off-identity outline states below,
   which need the full box-shadow slot to themselves. */
.deck-card-frame::after,
.cd-pg-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 14px 3px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.deck-card-tile:hover .deck-card-frame,
.deck-card-tile.is-jump-highlight .deck-card-frame,
.deck-card-open:focus-visible .deck-card-frame { box-shadow: 0 0 0 2px var(--text-muted); }
/* Bulk multi-select (ctrl/cmd+click) -- a stronger accent ring than plain
   hover/focus, plus a checkmark badge, so it reads as a distinct sticky
   state rather than momentary hover. */
.deck-card-tile.is-selected .deck-card-frame { box-shadow: 0 0 0 3px var(--accent); }
.deck-card-select-check {
  display: none;
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  align-items: center;
  justify-content: center;
}
.deck-card-tile.is-selected .deck-card-select-check { display: flex; }
.deck-card-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.deck-card-placeholder {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 10px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.deck-card-placeholder-name { font-family: var(--font-display); font-size: 13px; line-height: 1.2; font-weight: 500; display: block; }
.deck-card-placeholder-mana { display: flex; gap: 2px; min-height: 16px; margin-top: 6px; }
.deck-card-placeholder-type { font-size: 11px; line-height: 1.3; color: var(--text-muted); }

.deck-card-remove {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
.deck-card-tile:hover .deck-card-remove,
.deck-card-remove:focus,
.deck-card-tile.is-selected .deck-card-remove { opacity: 1; pointer-events: auto; }

.deck-card-badge {
  position: absolute;
  top: -13px;
  right: -13px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.deck-card-badge-circle {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--flag-danger);
  color: var(--on-accent);
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
}

.deck-card-qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.deck-card-qty button {
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.deck-card-qty button:disabled { color: var(--line-strong); cursor: default; }
.deck-card-qty-n { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.deck-card-qty-placeholder { height: var(--tap); }

/* ---------- Card detail dialog (card-detail-handoff, steps 2+) ---------- */

dialog.dialog.dialog--card { max-width: 940px; }
.cd-header { display: flex; align-items: center; gap: var(--space-3); border-bottom: 1px solid var(--line); padding-bottom: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.cd-header-title { flex-grow: 1; min-width: 160px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cd-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-header-title h2 { margin: 0; display: flex; align-items: center; gap: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-mana-cost { display: inline-flex; gap: 3px; flex-shrink: 0; }
.cd-nav-btn { display: flex; align-items: center; gap: 6px; white-space: nowrap; max-width: 180px; overflow: hidden; }
.cd-nav-btn span { overflow: hidden; text-overflow: ellipsis; }
.cd-nav-btn:disabled { opacity: 0.4; cursor: default; }
.cd-nav-btn:disabled:hover { border-color: var(--line-strong); color: var(--text); }
.cd-nav-btn[hidden] { display: none; }

.cd-body { display: flex; gap: var(--space-6); }
.cd-body--printings { display: flex; flex-direction: column; gap: var(--space-4); }
.cd-image-col { width: 280px; flex-shrink: 0; }
.cd-image-col .deck-card-frame { width: 280px; height: 391px; }
.cd-fields { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-5); }
.cd-row { display: flex; gap: var(--space-4); align-items: flex-start; }
.cd-field { display: flex; flex-direction: column; gap: 6px; }
.cd-field--grow { flex-grow: 1; }
.cd-field-label { font-size: 14px; font-weight: 600; }
.cd-field-value { min-height: var(--tap); display: flex; align-items: center; font-size: 14px; color: var(--text-muted); }
.cd-field-help { font-size: 13px; line-height: 1.4; color: var(--text-muted); }
#cd-copies-area .deck-card-qty { width: 170px; }

.cd-cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cd-cat-chip { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); box-sizing: border-box; padding: 0 4px; background: var(--line); border-radius: var(--radius-pill); }
.cd-cat-chip-star { width: var(--tap); height: var(--tap); display: flex; align-items: center; justify-content: center; color: var(--text-muted); background: none; border: none; cursor: pointer; }
.cd-cat-chip-star.is-primary { color: var(--text); cursor: default; }
.cd-cat-chip-name { font-size: 14px; font-weight: 600; padding: 0 2px; }
.cd-cat-chip-remove { width: var(--tap); height: var(--tap); border: none; border-radius: 50%; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cd-cat-chip--suggested { background: transparent; border: 1px dashed var(--line-strong); padding: 0 4px 0 12px; gap: 6px; }
.cd-cat-chip-pin { display: flex; color: var(--text-muted); }
.cd-cat-chip-suggested-label { font-size: 12px; color: var(--text-muted); }
.cd-cat-chip-add { width: var(--tap); height: var(--tap); border: none; border-radius: 50%; background: var(--line); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cd-cat-input { width: 100%; height: var(--tap); box-sizing: border-box; background: var(--surface-sunk); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 14px; color: var(--text); font: inherit; font-size: 15px; }
.cd-cat-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.cd-cat-quick button { min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.cd-cat-quick button.is-added { opacity: 0.45; cursor: default; }
.cd-cat-manage-btn { margin-top: 6px; padding: 4px 0; border: none; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: var(--tap); }
.cat-tpl-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.cat-tpl-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--tap); padding: 0 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.cat-tpl-list li:last-child { border-bottom: none; }
.cat-tpl-empty { color: var(--text-muted); font-size: 14px; padding: 4px 2px; }

.cd-print-row { display: flex; gap: 8px; }
#cd-print-select {
  flex-grow: 1;
  min-width: 0;
  height: var(--tap);
  box-sizing: border-box;
  background: var(--surface-sunk);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
#cd-print-select:disabled { color: var(--text-muted); }
.cd-print-all-btn { white-space: nowrap; }

.cd-pg-controls { display: flex; gap: 10px; align-items: center; }
.cd-pg-filter-wrap { position: relative; flex-grow: 1; }
.cd-pg-filter-icon { position: absolute; left: 14px; top: 13px; color: var(--text-muted); }
#cd-pg-filter { width: 100%; height: var(--tap); box-sizing: border-box; background: var(--surface-sunk); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 14px 0 42px; color: var(--text); font: inherit; font-size: 15px; }
#cd-pg-sort { min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.cd-pg-status { margin: 0; font-size: 13px; color: var(--text-muted); }
.cd-pg-empty { margin: var(--space-4) 0; color: var(--text-muted); font-size: 14px; }

.cd-pg-grid { margin: 0; padding: 14px 4px 4px; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 20px; max-height: 55vh; overflow-y: auto; }
.cd-pg-item { display: flex; flex-direction: column; gap: 8px; }
.cd-pg-tile-btn { position: relative; padding: 0; border: none; background: transparent; cursor: pointer; display: block; width: 100%; border-radius: 8px; }
.cd-pg-frame { position: relative; aspect-ratio: 63 / 88; box-sizing: border-box; border-radius: 8px; background: var(--surface-sunk); border: 1px solid var(--line); overflow: hidden; }
.cd-pg-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cd-pg-item.is-selected .cd-pg-tile-btn { box-shadow: 0 0 0 3px var(--accent); border-radius: 8px; }
.cd-pg-pill { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); white-space: nowrap; background: var(--accent); color: var(--on-accent); border-radius: var(--radius-pill); padding: 2px 12px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.cd-pg-meta { display: flex; flex-direction: column; gap: 1px; }
.cd-pg-set-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.cd-pg-set-code { font-size: 12px; color: var(--text-muted); }

@media (max-width: 719px) {
  .cd-pg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.cd-more { display: flex; flex-wrap: wrap; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-4); }
.cd-remove-btn { border-color: var(--flag-danger); color: var(--flag-danger); margin-left: auto; }
.cd-remove-btn:hover { border-color: var(--flag-danger); color: var(--flag-danger); opacity: 0.8; }

.cd-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-3); margin-top: var(--space-4); }
.cd-footer-note { font-size: 13px; color: var(--text-muted); }

/* ---------- Set as commander confirmation (step 5) ---------- */

dialog.dialog--card .cd-body--confirm { display: flex; flex-direction: column; gap: var(--space-4); max-width: 480px; }
.cd-cc-compare { display: flex; align-items: center; gap: 14px; background: var(--surface-sunk); border-radius: var(--radius); padding: 12px 14px; }
.cd-cc-compare-side { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cd-cc-compare-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.cd-cc-compare-name { font-weight: 600; }
.cd-cc-compare-pips { display: flex; gap: 3px; margin-top: 2px; }
.cd-cc-fieldset { margin: 0; padding: 0; border: none; display: flex; flex-direction: column; gap: 4px; }
.cd-cc-fieldset legend { padding: 0; margin-bottom: 6px; }
.cd-cc-radio { min-height: var(--tap); display: flex; align-items: center; gap: 10px; font-size: 15px; }
.cd-cc-radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--text-muted); }
.cd-cc-partner-note { font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.cd-cc-warning { border: 1px solid var(--flag-danger); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; }
.cd-cc-warning-icon { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; background: var(--flag-danger); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.cd-cc-warning-text { font-size: 14px; line-height: 1.45; color: var(--text-muted); }
.cd-cc-actions { display: flex; justify-content: flex-end; gap: 10px; }

.deck-card-tile.is-off-identity .deck-card-frame { box-shadow: 0 0 0 2px var(--flag-danger); }

/* ---------- Add to another deck (step 6) ---------- */

dialog.dialog--card .cd-body--addother { display: flex; flex-direction: column; gap: var(--space-3); max-width: 560px; }
.cd-ao-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.cd-ao-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--surface-sunk); border-radius: var(--radius); }
.cd-ao-info { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cd-ao-name { font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.cd-ao-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.cd-ao-meta .mana-pip { flex-shrink: 0; }
.cd-ao-status { min-height: var(--tap); display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.cd-ao-status.is-added { color: var(--flag-cool); }
.cd-ao-empty { color: var(--text-muted); font-size: 14px; padding: var(--space-3) 0; }

@media (max-width: 900px) {
  .cd-body { flex-wrap: wrap; }
  .cd-image-col { width: 200px; }
  .cd-image-col .deck-card-frame { width: 200px; height: 279px; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: 40;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 4px 6px 4px var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.toast-message { flex-grow: 1; font-size: 14px; font-weight: 600; }

.select-bar {
  position: fixed;
  left: var(--space-5);
  bottom: var(--space-5);
  z-index: 40;
  max-width: calc(100% - 32px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.select-bar-count { font-size: 14px; font-weight: 700; white-space: nowrap; }
.select-bar-actions { display: flex; gap: var(--space-2); }
@media (max-width: 719px) {
  .select-bar { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); flex-wrap: wrap; }
}
.toast button {
  min-height: 44px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--bg);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

dialog.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 420px;
}
dialog.dialog::backdrop { background: var(--scrim); }
/* Section 8: dialogs become full-width bottom sheets under 720px --
   native <dialog> already gives modal behavior, a backdrop and focus
   trapping for free, so this only needs to reposition it. */
@media (max-width: 719px) {
  dialog.dialog {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    max-width: none;
    max-height: 85vh;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    overflow-y: auto;
  }
  /* dialog.dialog.dialog--card's own max-width (940px, needed at desktop
     widths so the card-detail dialog has room for the image + fields
     side by side) outranks the plain dialog.dialog rule above on
     specificity alone, regardless of media query nesting -- confirmed
     live, it was pinning the dialog to 940px on a 375px viewport instead
     of collapsing to the bottom sheet. Matching specificity here to
     actually override it. */
  dialog.dialog.dialog--card { max-width: none; }
}
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.dialog-header h2 { margin: 0; }
.dialog-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}
.dialog-row:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.dialog-row-info { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; }
.dialog-row-title { font-size: 15px; font-weight: 600; }
.dialog-row-help { font-size: 13px; line-height: 1.4; color: var(--text-muted); }

/* ---------- Deck Builder: scoring, step 4 ---------- */

.deck-score-n.is-updating { opacity: 0.45; }
.deck-score-tile.is-illegal .deck-score-n { color: var(--flag-danger); }

.deck-card-badge-tooltip {
  position: absolute;
  top: -14px;
  left: calc(100% + 14px);
  width: 300px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 5;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
.deck-card-badge:hover ~ .deck-card-badge-tooltip,
.deck-card-badge:focus ~ .deck-card-badge-tooltip,
.deck-card-badge-tooltip:hover {
  opacity: 1;
  pointer-events: auto;
}
.deck-card-badge-tooltip-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 600; }
.deck-card-badge-tooltip-total span:last-child { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--flag-danger); }
.deck-card-badge-tooltip ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.deck-card-badge-tooltip li { display: flex; gap: var(--space-2); }
.deck-card-badge-tooltip li .amount { flex-shrink: 0; width: 44px; font-weight: 700; color: var(--flag-danger); }
.deck-card-badge-tooltip li.is-gc { border-top: 1px solid var(--line); padding-top: var(--space-2); color: var(--text-muted); }
.deck-card-badge-tooltip li.is-gc .amount { color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; font-size: 11px; width: auto; height: 20px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

.why-line { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; border-top: 1px solid var(--line); font-size: 14px; }
.why-line:first-child { border-top: none; }
.why-line-main { display: flex; justify-content: space-between; gap: var(--space-3); }
.why-line-amount { font-weight: 700; }
.why-line-amount.is-danger { color: var(--flag-danger); }
.why-line-amount.is-muted { color: var(--text-muted); }
.why-line-detail { font-size: 13px; line-height: 1.4; color: var(--text-muted); }

/* ---------- Deck Builder: card ratios, step 5 ---------- */

.ratio-row-plain {
  min-height: var(--tap);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.ratio-row-plain span:last-child { font-family: var(--font-display); font-size: 18px; font-weight: 700; }

.ratio-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.ratio-row-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.ratio-row-count { color: var(--text-muted); }
.ratio-row-count strong { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text); }
.ratio-row-track { flex-grow: 1; height: 6px; border-radius: var(--radius-pill); background: var(--surface-sunk); overflow: hidden; }
.ratio-row-fill { height: 6px; border-radius: var(--radius-pill); transition: width 0.6s ease, background-color 0.6s ease; }
.ratio-row-fill.tw-no-transition { transition: none; }
.ratio-row-fill.is-met { background: var(--flag-cool); }
.ratio-row-fill.is-short { background: var(--flag-danger); }
.ratio-row-bottom { display: flex; align-items: center; gap: 10px; }
.ratio-row-status { width: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.ratio-row-status.is-met { color: var(--flag-cool); justify-content: flex-end; }
.ratio-row-status.is-short { color: var(--flag-danger); justify-content: flex-end; text-align: right; }

.ratio-finisher-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-top: 6px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}
.ratio-finisher-row span:last-child { font-size: 13px; font-weight: 500; }

.ratio-tpl-row {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-top: 1px solid var(--line);
}
.ratio-tpl-row label { font-size: 15px; font-weight: 600; }
.ratio-tpl-row label span { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.ratio-tpl-stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-sunk); }
.ratio-tpl-stepper button { width: var(--tap); height: var(--tap); border: none; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ratio-tpl-stepper input {
  width: 48px;
  height: 44px;
  box-sizing: border-box;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Deck Builder: combos, step 6 ---------- */

.combo-card {
  background: var(--surface-sunk);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.combo-card + .combo-card { margin-top: var(--space-2); }
.combo-card-top { display: flex; justify-content: space-between; gap: var(--space-3); align-items: flex-start; }
.combo-card-cards { font-size: 14px; font-weight: 600; }
.combo-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  border-radius: 4px;
  padding: 1px 5px;
  border: 1px solid var(--flag-cool);
}
.combo-tag.is-danger { border-color: var(--flag-danger); }
.combo-tag.is-warm { border-color: var(--flag-warm); }
.combo-card-description { font-size: 13px; color: var(--text-muted); }

.combos-status-row { display: flex; align-items: center; gap: var(--space-3); padding-top: 2px; }
.combos-status-text { flex-grow: 1; font-size: 13px; line-height: 1.4; color: var(--text-muted); }
.combos-empty { font-size: 14px; color: var(--text-muted); }

.combos-loading { display: flex; align-items: center; gap: var(--space-3); }
.combos-spinner {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: combos-spin 0.8s linear infinite;
}
@keyframes combos-spin { to { transform: rotate(360deg); } }

/* ---------- Deck Builder: Mana section, step 7 ---------- */

.mana-section { margin-top: var(--space-4); }
.mana-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.mana-header h2 { margin: 0; font-size: 26px; line-height: 1.1; }
.mana-header-note { flex-shrink: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); }

.mana-row { display: flex; gap: var(--space-6); align-items: stretch; margin-top: var(--space-5); flex-wrap: wrap; }
.mana-pips-sources { width: 540px; max-width: 100%; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.mana-pips-sources h3 { margin: 0; font-size: 14px; }

.mana-stat-block { display: flex; flex-direction: column; gap: 6px; }
.mana-stat-label-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.mana-stacked-bar { height: 32px; border-radius: 8px; overflow: hidden; display: flex; }
.mana-stacked-bar-segment {
  color: var(--on-mana);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: inset 0 0 0 1px var(--mana-outline);
  overflow: hidden;
  white-space: nowrap;
}
.mana-stacked-bar-segment .mana-glyph { font-family: "Mana"; font-size: 15px; font-weight: 400; }

.mana-color-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.mana-color-card { background: var(--surface-sunk); border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.mana-color-card-head { display: flex; align-items: center; gap: 8px; }
.mana-color-card-head .mana-pip { width: 24px; height: 24px; font-size: 15px; }
.mana-color-card-head span:last-child { font-size: 14px; font-weight: 600; }
.mana-color-stat-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.mana-color-stat-n { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.mana-color-stat-detail { font-size: 12px; color: var(--text-muted); }

.mana-curve-col { flex-grow: 1; min-width: 320px; display: flex; flex-direction: column; gap: var(--space-3); border-left: 1px solid var(--line); padding-left: var(--space-6); }
.mana-curve-col-head { display: flex; justify-content: space-between; align-items: baseline; }
.mana-curve-col-head h3 { margin: 0; font-size: 14px; }
.mana-curve-col-head .mana-curve-avg { font-size: 14px; color: var(--text-muted); }
.mana-curve-col-head .mana-curve-avg strong { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--text); }
.mana-curve-col-head .mana-curve-total { margin-left: 10px; }

.mana-curve-chart { flex-grow: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.mana-curve-bars {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.mana-curve-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mana-curve-bar-n { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.mana-curve-bar { width: 100%; max-width: 56px; border-radius: 4px 4px 0 0; background: var(--text-muted); }
.mana-curve-bar.is-tallest { background: var(--accent); }
.mana-curve-axis { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 14px; padding-top: 6px; }
.mana-curve-axis span { text-align: center; font-size: 14px; font-weight: 700; }

.mana-split { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-3); }
.mana-split-head { display: flex; align-items: center; gap: 12px; }
.mana-split-head h3 { margin: 0; flex-grow: 1; font-size: 14px; }
.mana-split-head select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.mana-split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.mana-split-card { background: var(--surface-sunk); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.mana-split-card-head { display: flex; align-items: center; gap: 8px; }
.mana-split-card-head .mana-pip { width: 22px; height: 22px; font-size: 14px; }
.mana-split-card-head span:nth-child(2) { flex-grow: 1; font-size: 14px; font-weight: 600; }
.mana-split-card-head span:last-child { font-size: 13px; color: var(--text-muted); }
.mana-split-bars {
  height: 110px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.mana-split-bar-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mana-split-bar-n { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.mana-split-bar { width: 100%; border-radius: 3px 3px 0 0; box-shadow: inset 0 0 0 1px var(--mana-outline); }
.mana-split-axis { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.mana-split-axis span { text-align: center; font-size: 12px; font-weight: 700; }

.mana-empty { padding: var(--space-4); color: var(--text-muted); font-size: 14px; }

@media (max-width: 900px) {
  .mana-curve-col { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: var(--space-5); }
}
@media (max-width: 480px) {
  .mana-color-grid { grid-template-columns: 1fr; }
}

