:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #333333;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #0e7490;
  --accent-soft: #ecfeff;
  --cta: #e8b923;
  --cta-text: #1a1400;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 4px 4px -4px rgba(0, 0, 0, 0.1);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-feature-settings: "palt";
  line-height: 1.7;
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; height: auto; }

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.2rem;
}

.brand:hover { text-decoration: none; color: var(--accent); }
.brand span { color: var(--accent); }

.site-updated {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  line-height: 1.4;
  max-width: 22em;
}
.site-updated[hidden],
.set-updated[hidden] { display: none !important; }

.list-heading { min-width: 0; }
.list-heading h2 { margin: 0; }
.set-updated {
  margin: 2px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.4;
}

nav { display: flex; gap: 20px; font-size: 0.9rem; }
nav a { color: var(--text); }
nav a[aria-current="page"] { color: var(--accent); font-weight: 700; }

.breadcrumb {
  margin: 16px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.breadcrumb a { color: var(--muted); }

.hero { padding: 28px 0 8px; }

.hero h1, #page-title {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hero p, .lede {
  margin: 0;
  color: var(--muted);
  max-width: 42em;
}

.sample-banner {
  margin: 14px 0 0;
  padding: 8px 12px;
  border: 1px dashed #d4a017;
  background: #fffbeb;
  border-radius: 8px;
  color: #92400e;
  font-size: 0.85rem;
}

.section { padding: 24px 0; }

.card-section { scroll-margin-top: 80px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--text);
  padding-bottom: 6px;
}

.density-control {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.density-control button {
  appearance: none;
  border: 0;
  background: transparent;
  width: 36px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  border-right: 1px solid var(--border);
}
.density-control button:last-child { border-right: 0; }
.density-control button:hover:not(.is-active) { background: #f3f4f6; }
.density-control button.is-active {
  background: #111;
  color: #fff;
}
.density-control button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}
.density-control svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.section h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

/* Set banners */
.set-banners {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.set-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  align-items: center;
  min-height: 108px;
  background-color: #ececec;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.55) 0 10px,
    rgba(236, 236, 236, 0.9) 10px 20px
  );
  border: 1px solid #ddd;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.set-banner:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.set-banner.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.set-banner-text {
  text-align: center;
  padding: 10px 6px;
  min-width: 0;
}

.set-banner-code { display: none; }

.set-banner-kicker {
  margin: 0;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: #6b7280;
  font-weight: 700;
}

.set-banner-title {
  margin: 4px 0 2px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
}

.set-banner-sub {
  margin: 0;
  font-size: 0.7rem;
  color: #4b5563;
}
.set-banner-updated {
  margin: 4px 0 0;
  font-size: 0.65rem;
  font-weight: 700;
  color: #6b7280;
}

.set-banner-pack {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 6px 6px 0 0;
}

.set-banner-pack img {
  width: 72px;
  height: auto;
  max-height: 100px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
}

.other-sets {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.other-sets[hidden] { display: none !important; }
.other-sets-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.other-sets select {
  appearance: none;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 28px 8px 10px;
  font: inherit;
  min-width: 220px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.set-all-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.85rem;
}

/* Filter panel */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 8px 0 24px;
  box-shadow: var(--shadow);
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text);
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-size: 0.95rem;
}

.search-wrap input::placeholder { color: #9ca3af; }
.search-wrap input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: #fff;
}

.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn-filter {
  appearance: none;
  border: 0;
  background: var(--cta);
  color: var(--cta-text);
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}

.btn-filter.is-active { box-shadow: 0 0 0 2px #111 inset; }

.sort-label select,
.set-label select {
  appearance: none;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 28px 8px 10px;
  font: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.filter-body {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  transition: grid-template-rows 0.28s ease, opacity 0.2s ease, margin-top 0.28s ease, visibility 0.28s;
}

.filter-body.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 14px;
  visibility: visible;
  pointer-events: auto;
}

.filter-body-inner {
  overflow: hidden;
  min-height: 0;
}

.filter-body.is-open.is-settled .filter-body-inner {
  overflow: visible;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.chip-row-split { gap: 16px; }

.chip {
  appearance: none;
  border: 2px solid transparent;
  background: #f3f4f6;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  line-height: 1;
}

.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip.is-on {
  border-color: var(--cta);
  background: #fffbeb;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cta) 40%, transparent);
}

.chip-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  padding: 0;
  border-width: 2px;
}

.chip-dot[data-color="赤"] { background: #c62828; }
.chip-dot[data-color="緑"] { background: #2e7d32; }
.chip-dot[data-color="青"] { background: #1565c0; }
.chip-dot[data-color="紫"] { background: #7b1fa2; }
.chip-dot[data-color="黒"] { background: #212121; }
.chip-dot[data-color="黄"] { background: #f9a825; }

.chip-pill {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
}

.chip-round {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0;
}

.chip-wide {
  border-radius: 999px;
  min-width: 48px;
  height: 36px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.set-label, .sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch-ui {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  flex-shrink: 0;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-ui { background: var(--cta); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-reset {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  margin-left: auto;
}

.btn-reset:hover { color: var(--text); border-color: var(--accent); }

.keyword-wrap { position: relative; }

.keyword-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.keyword-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.keyword-menu label:hover { background: #f3f4f6; }

/* Cards */
.rarity-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}
.rarity-pill {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #2b2b2b;
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.rarity-pill:focus-visible {
  outline: 2px solid var(--cta);
  outline-offset: 2px;
}
.rarity-pill.is-empty {
  background: #d1d5db;
  color: #6b7280;
}
.rarity-pill.is-hot {
  background: #1a1a1a;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cta) 70%, #fff);
}
.rarity-pill.is-on {
  background: #111;
  color: #fff;
  box-shadow: 0 0 0 2px var(--cta);
}
.rarity-pill-total {
  background: #111;
  color: #fff;
  cursor: default;
  box-shadow: none;
}
.rarity-pill-total strong { color: var(--cta); font-weight: 800; }

.card-grid {
  display: grid;
  gap: 12px;
}
.card-grid[data-density="lg"] { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card-grid[data-density="md"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card-grid[data-density="sm"] { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.card-grid[data-density="list"] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-grid .empty { grid-column: 1 / -1; }

.card-grid[data-density="lg"] .card-meta .name { font-size: 0.92rem; }
.card-grid[data-density="sm"] .card-meta { padding: 5px 6px 8px; }
.card-grid[data-density="sm"] .card-meta .id { font-size: 0.65rem; }
.card-grid[data-density="sm"] .card-meta .name { font-size: 0.72rem; }

.card-grid[data-density="list"] .card-btn,
.card-grid[data-density="list"] .card-btn.is-unknown {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
}
.card-grid[data-density="list"] .card-btn img,
.card-grid[data-density="list"] .unknown-art {
  width: 64px;
  height: auto;
  aspect-ratio: 120 / 167;
}
.card-grid[data-density="list"] .unknown-art { font-size: 1.35rem; }
.card-grid[data-density="list"] .card-meta { padding: 8px 12px; }
.card-grid[data-density="list"] .card-meta .name {
  -webkit-line-clamp: 1;
  font-size: 0.95rem;
}

.card-btn {
  appearance: none;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  text-align: left;
  font: inherit;
  box-shadow: var(--shadow);
}

.card-btn:hover,
.card-btn:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.card-btn img {
  width: 100%;
  aspect-ratio: 120 / 167;
  object-fit: cover;
  background: #eee;
}

.card-meta { padding: 8px 8px 10px; }

.card-meta .id {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.card-meta .name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-break: strict;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge-new {
  position: absolute;
  top: 6px;
  left: 6px;
  margin: 0;
  background: var(--cta);
  color: var(--cta-text);
  border: 0;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.empty {
  color: var(--muted);
  padding: 32px 0;
}

.card-btn.is-unknown {
  cursor: default;
  background: #f8f8f8;
}

.card-btn.is-unknown:hover { border-color: var(--border); }

.unknown-art {
  aspect-ratio: 120 / 167;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(135deg, #ececec 0 8px, #f6f6f6 8px 16px);
  color: #9ca3af;
  font-size: 2.4rem;
  font-weight: 700;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  margin-top: 40px;
  padding: 20px 0 32px;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer .wrap { display: block; }
.site-footer p { margin: 0; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox.is-open { display: flex; }

.lightbox-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(920px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(220px, 1fr);
  gap: 20px;
  padding: 20px;
  position: relative;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.lightbox-panel img {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 480 / 671;
  object-fit: contain;
  background: #f3f4f6;
  border-radius: 8px;
}

.lightbox-details h2 { margin: 0 0 8px; font-size: 1.35rem; }

.lightbox-details dl {
  margin: 0;
  display: grid;
  grid-template-columns: 6em 1fr;
  gap: 6px 10px;
  font-size: 0.92rem;
}

.lightbox-details dt { color: var(--muted); }
.lightbox-details dd { margin: 0; }

.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.lightbox-close:hover { background: #f3f4f6; }

@media (max-width: 720px) {
  .set-banners {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 8px;
  }
  .set-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 0;
    min-width: 0;
    border-radius: 10px;
    padding: 6px 4px 8px;
  }
  .set-banner:hover { transform: none; }
  .set-banner.is-active {
    border-color: var(--cta);
    box-shadow: 0 0 0 2px var(--cta);
  }
  .set-banner-pack {
    order: -1;
    width: 100%;
    height: auto;
    padding: 2px 0 0;
  }
  .set-banner-pack img {
    width: auto;
    max-width: 100%;
    height: 70px;
    max-height: 70px;
    margin: 0 auto;
  }
  .set-banner-text {
    padding: 4px 2px 0;
    width: 100%;
  }
  .set-banner-kicker,
  .set-banner-sub { display: none; }
  .set-banner-code {
    display: block;
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.2;
  }
  .set-banner-title {
    margin: 2px 0 0;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.3;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lightbox-panel { grid-template-columns: 1fr; padding: 16px; }
  .card-grid[data-density="lg"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-grid[data-density="md"] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .card-grid[data-density="sm"] { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .result-count { margin-left: 0; width: 100%; text-align: right; }
  .btn-reset { margin-left: 0; }
  .density-control button { width: 34px; height: 32px; }
  .rarity-summary {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .rarity-summary::-webkit-scrollbar { display: none; }
  .rarity-pill { font-size: 0.72rem; padding: 6px 10px; }

  .site-updated { font-size: 0.68rem; max-width: 14em; }
  .set-banner-updated {
    margin: 2px 0 0;
    font-size: 0.58rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

