:root {
  color-scheme: dark;
  --surface-base: #0a0c12;
  --surface-raised: #141923;
  --surface-soft: #1b2230;
  --text-primary: #f6f8fb;
  --text-secondary: #aab4c5;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #b9ff66;
  --accent-ink: #142207;
  --focus: #80c7ff;
  --warning: #ffd37a;
  --prismatic: #c9a7ff;
  --gold: #ffd66b;
  --silver: #d5dbe7;
  --shell: 1160px;
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 85% -5%, rgba(185, 255, 102, 0.1), transparent 28rem),
    var(--surface-base);
  color: var(--text-primary);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.app-shell { width: min(calc(100% - 32px), var(--shell)); margin-inline: auto; min-width: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); background: var(--accent); color: var(--accent-ink); }
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.offline-banner { padding: 8px 16px; background: #4a3510; color: #fff2cf; text-align: center; font-size: 0.85rem; }
.app-header { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid var(--line); background: rgba(10, 12, 18, 0.94); backdrop-filter: blur(18px); }
.header-row { display: flex; min-height: 64px; align-items: center; gap: 24px; }
.brand { flex: 0 0 auto; font-size: 1.12rem; font-weight: 900; letter-spacing: -0.05em; text-decoration: none; }
.brand span { color: var(--accent); }
.desktop-nav { display: flex; gap: 18px; color: var(--text-secondary); }
.desktop-nav a { padding: 10px 2px; text-decoration: none; }
.desktop-nav a:hover { color: var(--text-primary); }
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.patch-chip { padding: 6px 10px; border: 1px solid rgba(185, 255, 102, 0.3); border-radius: 999px; color: var(--accent); font-size: 0.78rem; font-weight: 800; }
.locale-select, .filter-bar select, .filter-bar input, .compare-form select {
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--text-primary);
}
.locale-select { padding: 0 30px 0 10px; }
.search-row { padding-bottom: 12px; }
.global-search { position: relative; display: flex; width: min(100%, 680px); }
.global-search input { width: 100%; min-width: 0; min-height: 46px; padding: 0 112px 0 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-raised); color: var(--text-primary); }
.global-search button { position: absolute; inset: 5px 5px 5px auto; min-width: 92px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 850; }
.search-results { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; left: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #171c26; box-shadow: 0 20px 50px rgba(0,0,0,.42); }
.search-results a { display: flex; justify-content: space-between; gap: 16px; padding: 11px 14px; text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--surface-soft); }
.search-results small { color: var(--text-secondary); }

.app-main { min-height: calc(100vh - 120px); padding-block: 42px 96px; }
h1, h2, h3, p { margin-top: 0; overflow-wrap: anywhere; }
h1 { margin-bottom: 16px; font-size: clamp(2.3rem, 7vw, 5.1rem); line-height: .98; letter-spacing: -.06em; }
h2 { margin-bottom: 14px; font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: -.035em; }
h3 { margin-bottom: 8px; line-height: 1.25; }
.eyebrow { margin-bottom: 12px; color: var(--accent); font-size: .76rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.product-hero { max-width: 800px; padding: 42px 0 28px; }
.product-hero > p:not(.eyebrow), .page-heading > p { max-width: 700px; color: var(--text-secondary); font-size: 1.05rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.primary-button, .secondary-button, .filter-bar button {
  display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 10px; font-weight: 850; text-decoration: none; cursor: pointer;
}
.primary-button, .filter-bar button { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.secondary-button { border: 1px solid var(--line); background: var(--surface-raised); }
.inline-action { margin: 26px 0; }
.boundary-card { margin: 12px 0 48px; padding: 16px 18px; border: 1px solid rgba(255, 211, 122, .3); border-radius: 14px; background: rgba(255, 211, 122, .07); }
.boundary-card strong { color: var(--warning); }
.boundary-card p { margin: 4px 0 0; color: var(--text-secondary); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 32px 0 14px; }
.section-heading h2 { margin: 0; }
.section-heading span { color: var(--text-secondary); }
.page-heading { margin-bottom: 24px; }

.entity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.entity-card { display: flex; min-width: 0; min-height: 76px; align-items: center; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-raised); text-decoration: none; }
.entity-card:hover { border-color: rgba(185, 255, 102, .45); transform: translateY(-1px); }
.entity-card img { flex: 0 0 52px; border-radius: 10px; background: var(--surface-soft); }
.entity-card > span:nth-child(2) { display: grid; min-width: 0; }
.entity-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-card small { overflow: hidden; color: var(--text-secondary); text-overflow: ellipsis; white-space: nowrap; }
.rarity { flex: 0 0 auto; margin-left: auto; font-size: .68rem; font-weight: 850; text-transform: uppercase; }
.rarity.prismatic { color: var(--prismatic); } .rarity.gold { color: var(--gold); } .rarity.silver { color: var(--silver); }
.empty-copy { color: var(--text-secondary); }
.search-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.search-chip { min-height: 40px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-raised); color: var(--text-primary); cursor: pointer; }
.search-chip:hover { border-color: rgba(185, 255, 102, .45); }

.filter-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 220px) auto; align-items: end; gap: 10px; margin-bottom: 20px; }
.filter-bar label, .compare-form label { display: grid; min-width: 0; gap: 5px; color: var(--text-secondary); font-size: .8rem; font-weight: 750; }
.filter-bar input, .filter-bar select, .compare-form select { width: 100%; min-width: 0; padding: 8px 11px; }
.filter-bar button { min-width: 92px; }

.detail-page { min-width: 0; }
.detail-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.detail-header img { flex: 0 0 88px; border-radius: 18px; background: var(--surface-raised); }
.detail-header h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4.6rem); }
.canonical-key { margin: 5px 0 0; color: var(--text-secondary); }
.effect-card { padding: clamp(18px, 4vw, 30px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface-raised); }
.effect-card p, .effect-text { color: #d9dfeb; white-space: pre-line; }
.fact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.fact-card, .comparison-column, .mini-fact { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); }
.fact-card p, .mini-fact p { margin-bottom: 0; color: var(--text-secondary); font-size: .9rem; }
.provenance { display: inline-flex; margin-bottom: 10px; padding: 4px 8px; border-radius: 999px; font-size: .68rem; font-weight: 850; }
.provenance.explicit_source { background: rgba(128, 199, 255, .12); color: #9dd7ff; }
.provenance.derived_unreviewed { background: rgba(255, 211, 122, .1); color: var(--warning); }
.provenance.reviewed { background: rgba(185, 255, 102, .12); color: var(--accent); }
.unknown-state, .error-state { padding: 20px; border: 1px dashed var(--line); border-radius: 14px; color: var(--text-secondary); }
.source-details { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 18px; }
.source-details summary { min-height: 44px; cursor: pointer; color: var(--text-secondary); font-weight: 750; }
.source-details dl { display: grid; gap: 8px; }
.source-details dl div { display: grid; grid-template-columns: minmax(100px, .3fr) 1fr; gap: 12px; }
.source-details dt { color: var(--text-secondary); }
.source-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.checksum { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }

.compare-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 10px; margin-bottom: 28px; }
.comparison-section { margin-top: 28px; }
.comparison-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.comparison-column > h3 { font-size: 1.25rem; }
.mini-fact { margin-top: 9px; background: var(--surface-soft); }
.mini-fact strong { display: block; }

.loading-state { padding-top: 40px; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, #141923 25%, #1d2532 50%, #141923 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton-title { width: min(70%, 560px); height: 72px; margin-bottom: 22px; }
.skeleton-card { width: 100%; height: 220px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.app-footer { border-top: 1px solid var(--line); padding: 28px 0 96px; color: var(--text-secondary); font-size: .82rem; }
.footer-grid { display: flex; justify-content: space-between; gap: 24px; }
.footer-grid p { max-width: 760px; margin: 0; }
.footer-grid div { display: flex; gap: 14px; }
.mobile-nav { display: none; }

@media (max-width: 899px) {
  .desktop-nav { display: none; }
  .entity-grid, .fact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare-form button { grid-column: 1 / -1; }
  .comparison-grid { grid-template-columns: 1fr; }
}

@media (max-width: 599px) {
  .app-shell { width: min(calc(100% - 24px), var(--shell)); }
  .header-row { gap: 10px; }
  .patch-chip { display: none; }
  .locale-select { max-width: 106px; }
  .search-row { padding-bottom: 10px; }
  .app-main { padding-top: 28px; padding-bottom: 92px; }
  .product-hero { padding-top: 18px; }
  .product-hero h1 { font-size: clamp(2.5rem, 13vw, 4rem); }
  .entity-grid, .fact-grid, .filter-bar, .compare-form { grid-template-columns: 1fr; }
  .entity-card { min-height: 70px; }
  .detail-header { align-items: flex-start; gap: 14px; }
  .detail-header img { flex-basis: 70px; width: 70px; height: 70px; }
  .source-details dl div { grid-template-columns: 1fr; gap: 2px; }
  .footer-grid { display: grid; }
  .mobile-nav {
    position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    min-height: 64px; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(12, 15, 22, .97); backdrop-filter: blur(18px);
  }
  .mobile-nav a { display: grid; place-items: center; min-width: 0; padding: 8px 3px; color: var(--text-secondary); font-size: .72rem; font-weight: 800; text-align: center; text-decoration: none; }
  .app-footer { padding-bottom: 94px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
