:root {
  color-scheme: light;
  --page: #f7f5ef;
  --panel: #ffffff;
  --ink: #191714;
  --muted: #69645c;
  --line: #d8d1c4;
  --accent: #23685b;
  --accent-strong: #164b42;
  --warn: #9b3f2f;
  --blue: #2f5f8f;
  --gold: #8b6f2e;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent-strong);
}

button,
input,
select {
  font: inherit;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 56px) 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
  letter-spacing: 0;
}

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

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a,
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 12px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
nav a:hover {
  border-color: var(--accent);
}

main {
  padding: 20px clamp(16px, 4vw, 56px) 48px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(150px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 22px;
}

label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 9px;
}

input:focus,
select:focus,
button:focus,
a:focus {
  outline: 3px solid rgb(35 104 91 / 25%);
  outline-offset: 2px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  white-space: nowrap;
}

.toggle input {
  width: auto;
  min-height: auto;
}

.toggle span {
  color: var(--ink);
  font-size: 0.95rem;
}

.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.results-header h2,
.results-header p {
  margin-bottom: 0;
}

#result-count {
  color: var(--muted);
}

.results {
  display: grid;
  gap: 10px;
}

.results.image-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  align-items: start;
}

.land-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.land-card.with-image {
  grid-template-columns: 128px 1fr;
}

.image-grid .land-card.with-image {
  grid-template-columns: 1fr;
}

.land-card img {
  width: 100%;
  max-width: 265px;
  aspect-ratio: 265 / 370;
  border-radius: 4px;
  object-fit: cover;
  background: #e7e1d5;
}

.land-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.land-title h3 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.type-line {
  margin-bottom: 6px;
  color: var(--muted);
}

.oracle {
  margin-bottom: 10px;
  white-space: pre-line;
}

.tags,
.mana-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge,
.mana-symbol {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  line-height: 1.2;
}

.badge {
  border: 1px solid var(--line);
  background: #f7f5ef;
  color: var(--ink);
}

.badge.family {
  border-color: rgb(35 104 91 / 35%);
  background: rgb(35 104 91 / 10%);
  color: var(--accent-strong);
}

.badge.identity {
  border-color: rgb(139 111 46 / 35%);
  background: rgb(139 111 46 / 12%);
  color: #614a17;
}

.badge.upcoming {
  border-color: rgb(155 63 47 / 35%);
  background: rgb(155 63 47 / 10%);
  color: var(--warn);
}

.badge.muted {
  color: var(--muted);
}

.mana-symbol {
  width: 24px;
  justify-content: center;
  border: 1px solid rgb(0 0 0 / 18%);
  color: #171717;
  font-weight: 700;
}

.mana-w { background: #f4efd7; }
.mana-u { background: #c8dfee; }
.mana-b { background: #c9c4be; }
.mana-r { background: #e7b8a6; }
.mana-g { background: #b9d4b7; }
.mana-c { background: #dedbd2; }

.noscript {
  margin: 0 clamp(16px, 4vw, 56px) 32px;
  color: var(--warn);
}

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

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .site-header,
  .results-header {
    align-items: start;
    flex-direction: column;
  }

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

  .land-card.with-image {
    grid-template-columns: 1fr;
  }

  .land-title {
    flex-direction: column;
  }
}
