:root {
  color-scheme: light;
  --bg: #eef2f3;
  --surface: #f9fbfa;
  --surface-strong: #ffffff;
  --ink: #14211f;
  --muted: #667370;
  --line: #d8e0df;
  --accent: #0e7668;
  --accent-strong: #074f47;
  --gold: #b8842f;
  --blue: #325d8d;
  --red: #9f403e;
  --shadow: 0 18px 44px rgba(21, 35, 32, 0.12);
  --shadow-soft: 0 8px 22px rgba(21, 35, 32, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1414;
  --surface: #131d1c;
  --surface-strong: #1a2624;
  --ink: #edf7f3;
  --muted: #9aaba7;
  --line: #2a3b38;
  --accent: #5bcabb;
  --accent-strong: #a8f3e8;
  --gold: #d3a557;
  --blue: #7fb3e4;
  --red: #ef8d87;
  --shadow: 0 20px 52px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(14, 118, 104, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(50, 93, 141, 0.08), transparent 38%),
    var(--bg);
}

html[data-theme="dark"] {
  background:
    linear-gradient(135deg, rgba(91, 202, 187, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(211, 165, 87, 0.07), transparent 38%),
    var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(350px, 440px) minmax(0, 1fr);
  gap: 0;
}

.quiz-panel,
.results-panel {
  min-width: 0;
  padding: clamp(18px, 3vw, 36px);
}

.quiz-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 251, 250, 0.98)),
    var(--surface);
}

.results-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(247, 250, 249, 0.72)),
    var(--bg);
}

html[data-theme="dark"] .quiz-panel {
  background:
    linear-gradient(180deg, rgba(22, 33, 31, 0.94), rgba(16, 25, 24, 0.98)),
    var(--surface);
}

html[data-theme="dark"] .results-panel {
  background:
    linear-gradient(180deg, rgba(18, 29, 28, 0.64), rgba(12, 20, 20, 0.82)),
    var(--bg);
}

.brand-row,
.results-header,
.results-tools,
.card-topline,
.progress-label,
.card-actions,
.filters-row,
.tag-row,
.mana-row {
  display: flex;
  align-items: center;
}

.brand-row,
.results-header,
.card-topline,
.progress-label {
  justify-content: space-between;
  gap: 16px;
}

.brand-actions {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 3.2vw, 2.72rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  max-width: 780px;
  font-size: clamp(1.7rem, 3vw, 2.95rem);
  line-height: 1;
}

h3 {
  margin-bottom: 4px;
  font-size: 1.15rem;
  line-height: 1.15;
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover {
  border-color: var(--accent);
}

.progress-block {
  margin: 24px 0;
}

.progress-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e5db;
}

html[data-theme="dark"] .progress-track {
  background: #243330;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.question-stack {
  display: grid;
  gap: 14px;
}

.question-card {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

html[data-theme="dark"] .question-card {
  background: rgba(26, 38, 36, 0.82);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.question-card legend {
  width: 100%;
  padding: 0 0 10px;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.25;
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-pill {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid #d9dfd4;
  border-radius: 8px;
  background: #fffefa;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

html[data-theme="dark"] .option-pill {
  border-color: #31433f;
  background: #172220;
}

.option-pill:hover {
  border-color: rgba(35, 104, 91, 0.46);
  background: #fbfdfc;
  transform: translateY(-1px);
}

html[data-theme="dark"] .option-pill:hover {
  border-color: rgba(91, 202, 187, 0.46);
  background: #1c2a27;
}

.option-pill input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.option-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  font-weight: 800;
  line-height: 1.18;
}

.option-note {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.28;
}

.option-pill:has(input:checked) {
  border-color: var(--accent);
  background: #edf8f5;
  box-shadow: inset 4px 0 0 var(--accent);
}

html[data-theme="dark"] .option-pill:has(input:checked) {
  background: rgba(91, 202, 187, 0.12);
}

.mobile-next-button {
  display: none;
}

.results-header {
  margin-bottom: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(20, 33, 31, 0.08);
}

html[data-theme="dark"] .results-header {
  border-bottom-color: rgba(237, 247, 243, 0.08);
}

.results-tools {
  flex: 0 0 auto;
  gap: 10px;
}

.tool-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.tool-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button:hover {
  border-color: var(--accent);
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.result-count {
  min-width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 1.22rem;
  font-weight: 900;
}

html[data-theme="dark"] .result-count {
  background: #0f4f49;
  color: #eafffb;
}

.filters-row,
.tag-row,
.mana-row {
  flex-wrap: wrap;
  gap: 8px;
}

.filters-row {
  min-height: 34px;
  margin-bottom: 14px;
}

.commander-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.commander-tab {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
}

.commander-tab span {
  margin-left: 6px;
  color: var(--accent-strong);
}

.commander-tab.is-active {
  border-color: var(--accent);
  background: #eff8f1;
  color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(35, 104, 91, 0.1);
}

html[data-theme="dark"] .commander-tab.is-active {
  background: rgba(91, 202, 187, 0.14);
  box-shadow: 0 0 0 3px rgba(91, 202, 187, 0.14);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 9px 10px;
  border: 1px solid rgba(35, 104, 91, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .pagination-bar {
  border-color: rgba(91, 202, 187, 0.14);
  background: rgba(22, 32, 30, 0.84);
}

.pagination-bar[hidden] {
  display: none;
}

.page-info {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.page-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  font-weight: 900;
  cursor: pointer;
}

html[data-theme="dark"] .page-button {
  background: var(--surface-strong);
}

.page-button:hover {
  border-color: var(--accent);
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.chip,
.mana-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
}

.chip {
  padding: 7px 10px;
  border: 1px solid rgba(14, 118, 104, 0.22);
  background: rgba(255, 255, 255, 0.86);
  color: var(--accent-strong);
}

html[data-theme="dark"] .chip {
  border-color: rgba(91, 202, 187, 0.28);
  background: rgba(26, 38, 36, 0.9);
}

.filter-chip {
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}

.filter-chip-kicker {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.filter-chip-value {
  font-weight: 900;
}

.color-filter-chip {
  padding-left: 9px;
}

.color-filter-chip .color-symbols {
  gap: 2px;
}

.color-filter-chip .mana-symbol {
  width: 18px;
  height: 18px;
}

.filter-chip:hover {
  border-color: var(--accent);
  background: #eff8f1;
}

html[data-theme="dark"] .filter-chip:hover {
  background: rgba(91, 202, 187, 0.14);
}

.filter-chip:focus-visible {
  outline: 3px solid rgba(14, 118, 104, 0.18);
  outline-offset: 2px;
}

.mana-chip {
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border: 1px solid #bfc9bf;
  background: #fbfaf4;
  color: #223026;
}

html[data-theme="dark"] .mana-chip {
  border-color: rgba(237, 247, 243, 0.16);
}

.mana-chip svg,
.mana-symbol svg {
  width: 72%;
  height: 72%;
  display: block;
}

.mana-chip.white {
  background: #f7f2da;
}

.mana-chip.blue {
  background: #dfeaf5;
  color: #183d62;
}

.mana-chip.black {
  background: #ded9dd;
  color: #19161a;
}

.mana-chip.red {
  background: #f2ded7;
  color: #7d2f2d;
}

.mana-chip.green {
  background: #dfeee0;
  color: #185236;
}

.color-symbols {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
}

.mana-symbol {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(30, 39, 32, 0.22);
  border-radius: 50%;
  color: #1e2720;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.65);
}

.mana-symbol.white {
  background: #f7f2da;
}

.mana-symbol.blue {
  background: #cfe4f8;
  color: #183d62;
}

.mana-symbol.black {
  background: #cac4cc;
  color: #171318;
}

.mana-symbol.red {
  background: #f3c8bc;
  color: #7d2f2d;
}

.mana-symbol.green {
  background: #cce8d1;
  color: #185236;
}

.mana-symbol.colorless {
  border-radius: 6px;
  background: #e5e2d7;
  color: #3d403b;
}

.question-card[data-question-id="colors"],
.question-card[data-question-id="manaValue"] {
  padding: 14px 16px;
}

.question-card[data-question-id="colors"] legend,
.question-card[data-question-id="manaValue"] legend {
  padding-bottom: 10px;
}

.compact-selector {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.compact-selector-controls {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.color-selector-controls {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.mana-selector-controls {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.color-toggle,
.mana-toggle {
  width: 38px;
  height: 38px;
  min-width: 0;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5ca;
  border-radius: 8px;
  background: #fffefa;
  color: #1e2720;
  cursor: pointer;
}

html[data-theme="dark"] .color-toggle,
html[data-theme="dark"] .mana-toggle {
  border-color: #334641;
  background: #172220;
}

.color-toggle {
  width: 100%;
}

.color-toggle .mana-symbol {
  width: 28px;
  height: 28px;
}

.mana-toggle {
  width: 100%;
  padding: 0;
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 950;
  white-space: nowrap;
}

.color-toggle:hover,
.mana-toggle:hover {
  border-color: var(--accent);
}

.color-toggle.is-selected,
.mana-toggle.is-selected {
  border-color: var(--accent);
  background: #eff8f1;
  box-shadow: 0 0 0 3px rgba(35, 104, 91, 0.12);
}

html[data-theme="dark"] .color-toggle.is-selected,
html[data-theme="dark"] .mana-toggle.is-selected {
  background: rgba(91, 202, 187, 0.14);
  box-shadow: 0 0 0 3px rgba(91, 202, 187, 0.16);
}

.compact-selector-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.2;
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

.commander-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(132px, 176px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(25, 48, 40, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

html[data-theme="dark"] .commander-card {
  border-color: rgba(237, 247, 243, 0.09);
  background: rgba(22, 32, 30, 0.96);
}

.commander-card:hover {
  border-color: rgba(14, 118, 104, 0.3);
  box-shadow: 0 22px 48px rgba(21, 35, 32, 0.16);
  transform: translateY(-1px);
}

html[data-theme="dark"] .commander-card:hover {
  border-color: rgba(91, 202, 187, 0.32);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
}

.commander-card.is-random-pick {
  border-color: rgba(184, 137, 45, 0.72);
  box-shadow:
    0 0 0 3px rgba(184, 137, 45, 0.18),
    var(--shadow);
}

.random-chip {
  border-color: rgba(184, 137, 45, 0.5);
  background: #fff7df;
  color: #6c4a0d;
}

html[data-theme="dark"] .random-chip {
  background: rgba(211, 165, 87, 0.16);
  color: #f4d89d;
}

.card-art-frame {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 100%;
  padding: 10px;
  background:
    linear-gradient(135deg, rgba(14, 118, 104, 0.1), transparent 34%),
    linear-gradient(315deg, rgba(184, 132, 47, 0.1), transparent 42%),
    #dfe4e1;
  position: relative;
}

html[data-theme="dark"] .card-art-frame {
  background:
    linear-gradient(135deg, rgba(91, 202, 187, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(211, 165, 87, 0.1), transparent 42%),
    #1d2826;
}

.card-art-frame::before {
  content: "";
  width: min(84%, 132px);
  aspect-ratio: 488 / 680;
  grid-area: 1 / 1;
  border: 1px solid rgba(20, 33, 31, 0.08);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.16)),
    rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  opacity: 0.9;
}

html[data-theme="dark"] .card-art-frame::before {
  border-color: rgba(237, 247, 243, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.card-art-link {
  display: grid;
  place-items: center;
  width: 100%;
  text-decoration: none;
  grid-area: 1 / 1;
  z-index: 1;
}

.card-art-frame.multi-card .card-art-link {
  grid-area: auto;
}

.card-art-frame.multi-card {
  grid-template-columns: 1fr;
  align-content: center;
}

.card-art-frame.multi-card::before {
  display: none;
}

.card-art {
  width: 100%;
  height: auto;
  max-height: 100%;
  aspect-ratio: 488 / 680;
  display: block;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(25, 31, 27, 0.22);
}

.card-body {
  min-width: 0;
  padding: 17px;
  display: grid;
  gap: 11px;
}

.type-line,
.why-text {
  color: var(--muted);
  line-height: 1.35;
}

.type-line {
  margin-bottom: 0;
  font-size: 0.84rem;
}

.why-text {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.match-score {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 8px 9px;
  border-radius: 8px;
  background: #edf8f5;
  color: var(--accent-strong);
  text-align: center;
  font-weight: 900;
}

html[data-theme="dark"] .match-score {
  background: rgba(91, 202, 187, 0.14);
}

.card-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
}

html[data-theme="dark"] .link-button {
  background: var(--surface-strong);
}

.link-button:hover {
  border-color: var(--accent);
  background: #f7fbfa;
}

html[data-theme="dark"] .link-button:hover {
  background: rgba(91, 202, 187, 0.12);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  border: 1px dashed rgba(35, 104, 91, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-weight: 700;
}

html[data-theme="dark"] .empty-state {
  border-color: rgba(91, 202, 187, 0.34);
  background: rgba(22, 32, 30, 0.74);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .quiz-panel {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .quiz-panel,
  .results-panel {
    padding: 18px 14px;
  }

  .question-stack {
    gap: 8px;
  }

  .question-card.is-mobile-future {
    display: none;
  }

  .question-card.is-mobile-collapsed {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.58);
    cursor: pointer;
  }

  html[data-theme="dark"] .question-card.is-mobile-collapsed {
    background: rgba(22, 32, 30, 0.58);
  }

  .question-card.is-mobile-collapsed legend {
    padding: 0;
    color: var(--muted);
    font-size: 0.88rem;
  }

  .question-card.is-mobile-collapsed .option-grid,
  .question-card.is-mobile-collapsed .mobile-next-button {
    display: none;
  }

  .mobile-next-button {
    width: 100%;
    min-height: 40px;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(14, 118, 104, 0.28);
    border-radius: 8px;
    background: #ffffff;
    color: var(--accent-strong);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 900;
    cursor: pointer;
  }

  html[data-theme="dark"] .mobile-next-button {
    border-color: rgba(91, 202, 187, 0.3);
    background: var(--surface-strong);
  }

  .mobile-next-button:hover,
  .mobile-next-button:focus-visible {
    border-color: var(--accent);
    background: #eff8f1;
  }

  html[data-theme="dark"] .mobile-next-button:hover,
  html[data-theme="dark"] .mobile-next-button:focus-visible {
    background: rgba(91, 202, 187, 0.14);
  }

  .results-list {
    grid-template-columns: 1fr;
  }

  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .commander-card {
    grid-template-columns: 122px minmax(0, 1fr);
  }

  .card-body {
    padding: 12px;
  }

}

@media (max-width: 430px) {
  .commander-card {
    grid-template-columns: 1fr;
  }

  .card-art-frame {
    padding: 12px;
  }

  .card-art {
    width: min(100%, 260px);
  }

  .card-art-frame.multi-card .card-art {
    width: min(100%, 230px);
  }
}
