:root {
  --bg: #f6f2e8;
  --ink: #151515;
  --ink-muted: #5a5a56;
  --panel: #fffdf9;
  --panel-edge: #d7d1c3;
  --pill: #efe8d8;
  --price: #1d6e48;
  --color-w: #f5e8a7;
  --color-u: #9cc8f7;
  --color-b: #7a6f79;
  --color-r: #e89a8c;
  --color-g: #97c391;
  --mtg-card-radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, #efe4cd 0%, transparent 36%),
    radial-gradient(circle at 88% 8%, #e5dcc5 0%, transparent 33%),
    var(--bg);
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1300px, 96vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.hero {
  margin-bottom: 1.2rem;
  padding: 2rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: linear-gradient(140deg, #fffdf8 0%, #f4ecd9 100%);
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
  font-size: 0.75rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
  color: #111;
}

h1 {
  margin-top: 0.5rem;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.lead {
  margin-top: 0.7rem;
  color: var(--ink-muted);
  max-width: 60ch;
}

.terms-button {
  border: 1px solid #cabfaa;
  border-radius: 999px;
  background: #fff8ea;
  color: #2d261e;
  height: 38px;
  padding: 0 0.95rem;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.terms-button:hover {
  background: #fff1d7;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid #cabfaa;
  border-radius: 999px;
  background: #fff8ea;
  height: 38px;
  padding: 2px 4px;
  flex: 0 0 auto;
}

.theme-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #2a241d;
  width: 30px;
  height: 30px;
  font-size: 0.98rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-btn:hover {
  background: #f2e8d3;
}

.theme-btn.active {
  background: #e8dcc3;
  border-color: #cbbca0;
}

.controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.8rem;
  padding: 0.85rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: var(--panel);
}

.hero-controls {
  margin-top: 1rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.control {
  display: grid;
  gap: 0.35rem;
}

.control span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.control input,
.control select {
  border: 1px solid #c9c2b2;
  border-radius: var(--mtg-card-radius);
  height: 42px;
  padding: 0 0.7rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
}

.section-title-wrap {
  margin: 1.5rem 0 1rem;
}

.section-title-wrap p {
  margin: 0.2rem 0 0;
  color: var(--ink-muted);
}

.grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 290px);
  grid-template-columns: none;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-inline-start: max(2vw, calc((100vw - min(1300px, 96vw)) / 2));
  padding-inline-end: max(2vw, calc((100vw - min(1300px, 96vw)) / 2));
  padding-bottom: 0.45rem;
  scroll-snap-type: x proximity;
  scroll-padding-inline-start: max(2vw, calc((100vw - min(1300px, 96vw)) / 2));
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail .deck-card {
  scroll-snap-align: start;
}

.rail-sentinel {
  width: 1px;
  height: 1px;
}

.deck-type-group {
  margin: 0.65rem 0 1rem;
}

.deck-type-heading {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #3c342b;
}

.deck-card {
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: var(--panel);
  overflow: hidden;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  height: 100%;
}

.deck-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(31, 31, 29, 0.13);
  border-color: #c8bfab;
}

.card-hitbox {
  all: unset;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.commander-image {
  width: 100%;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: #ede7d8;
  border-bottom: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  box-shadow: 0 8px 14px -10px rgba(0, 0, 0, 0.45);
}

.deck-meta {
  padding: 1rem 1rem 1rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.deck-release {
  margin: 0;
  width: 100%;
  min-height: 1.05rem;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: #6a6257;
}

.meta-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.color-line,
.commander-line {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.commander-line {
  margin-top: 0.2rem;
}

.commander-label {
  font-weight: 600;
  color: #40372f;
}

.commander-name {
  font-weight: 800;
  color: #111;
}

.set-footnote {
  margin: auto 0 0;
  width: 100%;
  color: #969287;
  font-size: 0.76rem;
  line-height: 1.25;
}

.pip-row {
  display: inline-flex;
  gap: 0.34rem;
}

.pip {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 800;
  color: #111;
  line-height: 1;
}

.pip.w { background: var(--color-w); }
.pip.u { background: var(--color-u); }
.pip.b { background: var(--color-b); color: #f4f2f4; }
.pip.r { background: var(--color-r); }
.pip.g { background: var(--color-g); }
.pip.c { background: #d8d4ca; }

.section-pill {
  display: inline-block;
  margin-top: 0.55rem;
  margin-bottom: 0;
  max-width: 100%;
  padding: 0.26rem 0.68rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-pill {
  background: var(--pill);
  color: #4c4436;
  border: 1px solid #d4cab4;
}

.color-pill {
  display: inline-block;
  margin: 0;
  max-width: 100%;
  padding: 0.26rem 0.68rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #4c4436;
  background: #efe8d8;
  border: 1px solid #d4cab4;
}

.deck-title {
  margin-top: 0.36rem;
  font-size: 1.14rem;
  font-weight: 800;
  color: #111;
  line-height: 1.2;
}

.hidden {
  display: none;
}

.terms-dialog {
  border: none;
  padding: 0;
  background: transparent;
  width: min(860px, 92vw);
}

.terms-dialog::backdrop {
  background: rgba(20, 20, 20, 0.52);
}

.terms-panel {
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: #fffdf9;
  padding: 1rem;
  max-height: 84vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.terms-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.terms-close {
  border: 1px solid #d4cab6;
  background: #f5efe0;
  border-radius: var(--mtg-card-radius);
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.terms-search-wrap {
  display: grid;
  gap: 0.35rem;
}

.terms-search-wrap span {
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 700;
}

.terms-search-wrap input {
  border: 1px solid #cfc4ae;
  border-radius: var(--mtg-card-radius);
  padding: 0.62rem 0.72rem;
  font-size: 0.93rem;
}

.terms-list {
  overflow: auto;
  display: grid;
  gap: 0.55rem;
  padding-right: 0.25rem;
}

.term-item {
  border: 1px solid #e1d9c8;
  background: #fffaf0;
  border-radius: var(--mtg-card-radius);
  padding: 0.7rem 0.75rem;
}

.term-item h3 {
  margin: 0;
  font-size: 0.95rem;
}

.term-item p {
  margin: 0.3rem 0 0;
  color: #4f4a42;
  font-size: 0.87rem;
  line-height: 1.38;
}

.terms-empty {
  margin: 0.2rem 0;
  color: var(--ink-muted);
}

.zoomable-card-image {
  cursor: zoom-in;
}

.image-lightbox {
  border: none;
  background: transparent;
  padding: 0;
  width: min(92vw, 860px);
}

.image-lightbox::backdrop {
  background: rgba(10, 10, 10, 0.82);
}

.image-lightbox-img {
  width: 100%;
  max-height: 86vh;
  object-fit: contain;
  border-radius: var(--mtg-card-radius);
  border: 1px solid #7b705f;
  background: #101010;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
}

.image-lightbox-close {
  position: fixed;
  top: 16px;
  right: 18px;
  border: 1px solid #8f8472;
  background: #f0e6d2;
  color: #1f1b16;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #25559a;
  text-decoration: none;
  font-weight: 700;
}

.detail-head {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.detail-image {
  width: 100%;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  object-position: center;
  background: #ede7d8;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  position: sticky;
  top: 14px;
}

.detail-side {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  align-content: start;
  grid-auto-rows: min-content;
  min-width: 0;
}

.detail-meta {
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: linear-gradient(180deg, #fffefb 0%, #fbf7ef 100%);
  width: 100%;
  padding: 1rem 1.05rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}

.detail-title {
  margin-top: 0.5rem;
  font-size: clamp(1.28rem, 1.5vw, 1.64rem);
  line-height: 1.2;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.62rem;
}

.detail-facts {
  margin-top: 0.68rem;
  display: grid;
  gap: 0.38rem;
}

.detail-fact-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
}

.detail-fact-key {
  font-size: 0.78rem;
  color: #6a645d;
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.detail-fact-value {
  min-width: 0;
  font-size: 0.95rem;
  color: #2f2a23;
  font-weight: 600;
}

.color-value-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.detail-facts .color-line {
  margin: 0;
  font-size: 0.95rem;
  color: #2f2a23;
}

.detail-label {
  font-size: 0.78rem;
  color: #6a645d;
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.archetype-pill {
  display: inline-block;
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid #cfc0a7;
  background: #f2e7d2;
  color: #322a20;
}

.theme-tags {
  margin-top: 0.58rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.theme-chip {
  display: inline-block;
  padding: 0.26rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid #e0d5c1;
  background: #f9f2e5;
  color: #433b31;
}

.set-commanders {
  border: none;
  border-radius: 0;
  background: transparent;
  width: 100%;
  padding: 0.2rem 0;
  box-shadow: none;
}

.set-commanders-strip {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.set-commanders-strip::-webkit-scrollbar {
  display: none;
}

.set-commander-thumb-link {
  flex: 0 0 auto;
  border-radius: var(--mtg-card-radius);
  text-decoration: none;
  border: 1px solid #d5c7af;
  background: #f7efdf;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.1);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.set-commander-thumb-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
}

.set-commander-thumb {
  display: block;
  width: 152px;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  border-radius: var(--mtg-card-radius);
}


.type-switcher {
  margin-top: 1.25rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: var(--panel);
  padding: 1rem;
}

.type-switcher-title {
  margin: 0 0 0.6rem;
  font-size: 1.2rem;
}

.type-toolbar {
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.type-meta {
  margin: 0;
  font-size: 0.82rem;
  color: #5e584f;
  font-weight: 600;
}

.type-clear {
  border: 1px solid #d8ceba;
  background: #f7f1e4;
  color: #4d453b;
  border-radius: 999px;
  padding: 0.35rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.compare-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: var(--panel);
  padding: 0.8rem;
}

.compare-panel {
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: var(--panel);
  padding: 1rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.compare-card {
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  background: #fffdfa;
  padding: 0.72rem;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 0.72rem;
}

.compare-image {
  width: 100%;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  object-position: center top;
  border-radius: var(--mtg-card-radius);
  background: #ede7d8;
  border: 1px solid var(--panel-edge);
}

.compare-meta h3 {
  margin-top: 0.35rem;
  font-size: 1.03rem;
  line-height: 1.26;
}

.compare-line {
  margin: 0.26rem 0 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.compare-stats {
  margin-top: 0.58rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.compare-stats span {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ded2bc;
  background: #f8f0e0;
  color: #41392e;
  border-radius: 999px;
  padding: 0.24rem 0.52rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.compare-table {
  margin-top: 0.92rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  overflow: hidden;
}

.compare-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--panel-edge);
  background: #fffdfa;
}

.compare-row:first-child {
  border-top: none;
}

.compare-label {
  text-align: center;
  color: #5d574e;
  font-size: 0.8rem;
  font-weight: 700;
}

.compare-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1d1a16;
}

.compare-row .compare-value:first-child {
  text-align: left;
}

.compare-row .compare-value:last-child {
  text-align: right;
}

.type-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.type-pill {
  border: 1px solid #d8ceba;
  background: #f7f1e4;
  color: #4d453b;
  border-radius: 999px;
  padding: 0.4rem 0.74rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.type-pill.active {
  background: #e7dcc5;
  border-color: #cbbca0;
  color: #2f2a23;
}

.deck-search {
  width: 100%;
  border: 1px solid #cfc4ae;
  border-radius: var(--mtg-card-radius);
  padding: 0.68rem 0.72rem;
  font-size: 0.96rem;
  margin-bottom: 0.7rem;
}

.card-list {
  display: grid;
  gap: 0.85rem;
  padding: 0.3rem 0.1rem;
}

.card-list-panel {
  max-height: none;
  overflow: visible;
  padding-right: 0;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card-list-panel[data-count="1"] {
  grid-template-columns: minmax(240px, 320px);
}

.card-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.52rem;
  border: 1px solid var(--panel-edge);
  border-radius: var(--mtg-card-radius);
  padding: 0.58rem;
  background: #fffdfa;
  box-shadow: 0 6px 14px rgba(22, 16, 9, 0.06);
}

.card-row img {
  width: 100%;
  aspect-ratio: 63 / 88;
  height: auto;
  object-fit: cover;
  border-radius: var(--mtg-card-radius);
  background: #ece7dc;
  box-shadow: 0 8px 18px -14px rgba(0, 0, 0, 0.62);
}

.card-main strong {
  display: block;
  font-size: 1rem;
  line-height: 1.32;
  color: #161515;
}

.card-type {
  margin: 0.25rem 0 0;
  color: #5f5a53;
  font-size: 0.84rem;
  line-height: 1.3;
}

.card-group {
  margin: 0.26rem 0 0;
  display: inline-block;
  width: fit-content;
  border: 1px solid #ded3bf;
  background: #f8f0e0;
  color: #433b31;
  border-radius: 999px;
  padding: 0.14rem 0.46rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.card-meta-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.qty {
  font-weight: 700;
  color: #4a4338;
  border: 1px solid #dfd2bb;
  background: #f7eddb;
  border-radius: 999px;
  padding: 0.24rem 0.56rem;
  font-size: 0.76rem;
}

.card-price {
  font-size: 0.74rem;
  font-weight: 800;
  color: #1f5f3f;
  border: 1px solid #9fd2b4;
  background: #daf3e6;
  border-radius: 999px;
  padding: 0.24rem 0.56rem;
  margin-left: auto;
}

.skeleton-card {
  pointer-events: none;
}

.skeleton-block,
.skeleton-line,
.skeleton-pill,
.skeleton-row {
  position: relative;
  overflow: hidden;
  background: #e8e1d0;
}

.skeleton-block::after,
.skeleton-line::after,
.skeleton-pill::after,
.skeleton-row::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 1.2s infinite;
}

.skeleton-line {
  display: block;
  border-radius: var(--mtg-card-radius);
  height: 12px;
  margin: 0.45rem 0 0;
}

.skeleton-pill {
  display: inline-block;
  width: 98px;
  height: 24px;
  border-radius: 999px;
  margin-top: 0.55rem;
}

.s-sm { width: 38%; }
.s-md { width: 58%; }
.s-lg { width: 84%; }
.s-xs { width: 22%; }

.skeleton-accordion-head {
  height: 48px;
}

.skeleton-row {
  min-height: 118px;
  border-radius: var(--mtg-card-radius);
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

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

  .rail {
    grid-auto-columns: minmax(235px, 255px);
    grid-template-columns: none;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .hero-top {
    flex-direction: column;
    gap: 0.7rem;
  }

  .hero-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .detail-head {
    grid-template-columns: 1fr;
  }

  .detail-image {
    position: static;
  }

  .detail-side {
    grid-template-columns: 1fr;
  }

  .terms-header {
    flex-direction: column;
    align-items: stretch;
  }

  .card-list-panel {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .compare-controls {
    grid-template-columns: 1fr;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

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

  .compare-row {
    grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr);
  }
}

body[data-theme="dark"] {
  --bg: #121417;
  --ink: #ecedf1;
  --ink-muted: #b1b7c3;
  --panel: #1a1f27;
  --panel-edge: #313745;
  --pill: #2a313d;
  --color-w: #d5c892;
  --color-u: #7ea9d9;
  --color-b: #8b7f90;
  --color-r: #cc7f75;
  --color-g: #83ae7d;
  background:
    radial-gradient(circle at 15% 12%, #232a36 0%, transparent 38%),
    radial-gradient(circle at 88% 8%, #1f2430 0%, transparent 35%),
    var(--bg);
}

body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3 {
  color: #f4f6fb;
}

body[data-theme="dark"] .hero,
body[data-theme="dark"] .controls,
body[data-theme="dark"] .deck-card,
body[data-theme="dark"] .detail-meta,
body[data-theme="dark"] .type-switcher,
body[data-theme="dark"] .compare-controls,
body[data-theme="dark"] .compare-panel,
body[data-theme="dark"] .compare-card,
body[data-theme="dark"] .compare-table,
body[data-theme="dark"] .compare-row,
body[data-theme="dark"] .card-row,
body[data-theme="dark"] .terms-panel,
body[data-theme="dark"] .term-item {
  background: #1a1f27;
  border-color: #313745;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.32);
}

body[data-theme="dark"] .hero-controls {
  background: transparent;
  border: none;
  box-shadow: none;
}

body[data-theme="dark"] .control input,
body[data-theme="dark"] .control select,
body[data-theme="dark"] .deck-search,
body[data-theme="dark"] .terms-search-wrap input {
  background: #12161d;
  border-color: #3a4252;
  color: #eceff5;
}

body[data-theme="dark"] .terms-button,
body[data-theme="dark"] .theme-switcher,
body[data-theme="dark"] .type-pill,
body[data-theme="dark"] .type-clear,
body[data-theme="dark"] .theme-chip,
body[data-theme="dark"] .archetype-pill,
body[data-theme="dark"] .qty,
body[data-theme="dark"] .terms-close {
  background: #252c38;
  border-color: #3a4354;
  color: #e7eaf0;
}

body[data-theme="dark"] .type-pill.active {
  background: #334055;
  border-color: #4b5d78;
  color: #f2f5fa;
}

body[data-theme="dark"] .theme-btn {
  color: #e7eaf0;
}

body[data-theme="dark"] .theme-btn:hover {
  background: #2e3747;
}

body[data-theme="dark"] .theme-btn.active {
  background: #334055;
  border-color: #4b5d78;
  color: #f2f5fa;
}

body[data-theme="dark"] .deck-type-heading,
body[data-theme="dark"] .detail-label {
  color: #b8c2d2;
}

body[data-theme="dark"] .detail-fact-key {
  color: #b8c2d2;
}

body[data-theme="dark"] .detail-fact-value,
body[data-theme="dark"] .detail-facts .color-line {
  color: #f2f5fb;
}

body[data-theme="dark"] .section-pill,
body[data-theme="dark"] .color-pill {
  background: #283242;
  border-color: #40516a;
  color: #e5ecf7;
}

body[data-theme="dark"] .compare-label,
body[data-theme="dark"] .compare-line {
  color: #b7bfcc;
}

body[data-theme="dark"] .compare-value {
  color: #f2f5fb;
}

body[data-theme="dark"] .compare-stats span {
  background: #283142;
  border-color: #40506a;
  color: #dce3ef;
}

body[data-theme="dark"] .commander-label {
  color: #c6d0df;
}

body[data-theme="dark"] .commander-name,
body[data-theme="dark"] .deck-title,
body[data-theme="dark"] .card-main strong,
body[data-theme="dark"] .detail-meta .commander-line {
  color: #f2f5fb;
}

body[data-theme="dark"] .set-footnote,
body[data-theme="dark"] .card-type,
body[data-theme="dark"] .term-item p,
body[data-theme="dark"] .color-line,
body[data-theme="dark"] .deck-release,
body[data-theme="dark"] .type-meta,
body[data-theme="dark"] .terms-empty {
  color: #b7bfcc;
}

body[data-theme="dark"] .card-group {
  background: #283142;
  border-color: #40506a;
  color: #dce3ef;
}

body[data-theme="dark"] .card-price {
  background: #1f3a2d;
  border-color: #2f6a4f;
  color: #9fe0bf;
}

body[data-theme="dark"] .set-commander-thumb-link {
  background: #232c38;
  border-color: #3e4f69;
}

body[data-theme="dark"] .skeleton-block,
body[data-theme="dark"] .skeleton-line,
body[data-theme="dark"] .skeleton-pill,
body[data-theme="dark"] .skeleton-row {
  background: #262d39;
}

body[data-theme="dark"] .skeleton-block::after,
body[data-theme="dark"] .skeleton-line::after,
body[data-theme="dark"] .skeleton-pill::after,
body[data-theme="dark"] .skeleton-row::after {
  background: linear-gradient(90deg, transparent, rgba(187, 201, 227, 0.18), transparent);
}

body[data-theme="dark"] .back-link {
  color: #8bb8ff;
}

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

  .rail {
    grid-auto-columns: minmax(220px, 235px);
    grid-template-columns: none;
  }
}

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

  .rail {
    grid-auto-columns: minmax(200px, 88vw);
    grid-template-columns: none;
  }
}
