:root {
  --color-navy: #f1ebdb;
  --color-surface: #f9f5eb;
  --color-card: #fffefa;
  --color-cyan: #2ba0e0;
  --color-cyan-bright: #1f8fce;
  --color-ice: #bfe6f5;
  --color-orange: #6cbf3c;
  --color-text: #34302a;
  --color-muted: #6c6350;
  --color-faint: #8a7d63;
  --color-border: rgba(150,125,90,0.3);
  --color-border-2: rgba(150,125,90,0.4);
  --color-border-strong: rgba(108,191,60,0.5);
  --color-danger: #e5484d;

  --tier-common: #7d7360;
  --tier-rare: #2ba0e0;
  --tier-epic: #b06be0;
  --tier-legendary: #f4a63c;

  --shadow-card: 0 20px 46px rgba(60,78,112,0.13);
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --pal-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3c-4.4 0-8 3.2-8 7.2 0 2.5 1.4 4.7 3.5 6 .5.3.8.9.7 1.5l-.2 1c-.2.9.5 1.7 1.4 1.6 1-.1 1.7-.9 1.7-1.9v-.6c0-.3.2-.5.5-.5h.6c.3 0 .5.2.5.5v.6c0 1 .7 1.8 1.7 1.9.9.1 1.6-.7 1.4-1.6l-.2-1c-.1-.6.2-1.2.7-1.5 2.1-1.3 3.5-3.5 3.5-6C20 6.2 16.4 3 12 3Zm-3.4 6.4a1.3 1.3 0 1 1 0 2.6 1.3 1.3 0 0 1 0-2.6Zm6.8 0a1.3 1.3 0 1 1 0 2.6 1.3 1.3 0 0 1 0-2.6Z'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable; min-height: 100%; background: var(--color-navy); color-scheme: light; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--color-text);
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1200px 620px at 50% -8%, rgba(108,191,60,0.13), transparent 62%),
    radial-gradient(900px 520px at 88% 4%, rgba(108,191,60,0.09), transparent 60%),
    radial-gradient(760px 520px at 6% 20%, rgba(43,160,224,0.1), transparent 60%),
    linear-gradient(180deg, #fbf5ea 0%, #f1ebdb 46%, #f1ebdb 100%);
  background-attachment: fixed;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.wrap {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

/* ── Hero ─────────────────────────────────── */
.hero { max-width: 800px; margin-bottom: 24px; animation: rise 0.5s var(--ease) both; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 14px; padding: 5px 12px 5px 10px;
  border: 1px solid var(--color-border-2); border-radius: 999px;
  color: var(--color-cyan-bright); background: rgba(108,191,60,0.08);
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
}
.eyebrow::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-cyan); box-shadow: 0 0 10px rgba(108,191,60,0.8);
}
.hero h1 { font-family: "Baloo 2", "Manrope", system-ui, sans-serif;  margin: 0; font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.14; letter-spacing: -0.012em; font-weight: 800; }
.hero h1 .grad {
  color: transparent; background: linear-gradient(120deg, #2494d6, #5aa62e);
  -webkit-background-clip: text; background-clip: text; font-weight: 700;
}
.tagline { max-width: 640px; margin: 14px 0 0; color: var(--color-muted); font-size: clamp(0.95rem, 2vw, 1.04rem); }

/* ── Panel / toolbar ──────────────────────── */
.panel {
  padding: clamp(16px, 2.4vw, 22px);
  border: 1px solid var(--color-border); border-radius: var(--radius-xl);
  background: linear-gradient(150deg, rgba(255,254,249,0.98), rgba(247,240,225,0.98));
  box-shadow: var(--shadow-card);
}
.toolbar-panel { position: relative; z-index: 10; margin-bottom: 20px; animation: rise 0.55s var(--ease) 0.05s both; }

.toolbar { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: end; }

.field { position: relative; }
.field.search { min-width: 0; }
.field input {
  width: 100%; min-height: 50px; padding: 12px 92px 12px 46px;
  border: 1px solid var(--color-border-2); border-radius: 13px; outline: none;
  color: var(--color-text); background: rgba(255,255,255,0.72);
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
}
.field input::placeholder { color: rgba(125,115,96,0.6); }
.field input:focus { border-color: var(--color-cyan); background: rgba(255,254,250,0.96); box-shadow: 0 0 0 3px rgba(108,191,60,0.14); }
.field .ico { position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; color: var(--color-muted); transform: translateY(-50%); pointer-events: none; }
.field .count { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--color-faint); font-size: 0.78rem; font-weight: 700; pointer-events: none; }

.select { display: grid; gap: 5px; }
.select > span { color: var(--color-faint); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding-left: 2px; }

/* custom dropdown */
.dd { position: relative; }
.dd-trigger {
  width: 100%; min-width: 150px; min-height: 44px; padding: 8px 12px 8px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--color-border-2); border-radius: 12px;
  color: var(--color-text); background: rgba(255,255,255,0.72); cursor: pointer;
  font-weight: 650; transition: border-color 140ms, box-shadow 140ms;
}
.dd-trigger:hover { border-color: var(--color-border-strong); }
.dd.open .dd-trigger { border-color: var(--color-cyan); box-shadow: 0 0 0 3px rgba(108,191,60,0.14); }
.dd-caret { width: 15px; height: 15px; color: var(--color-muted); transition: transform 180ms var(--ease); flex: 0 0 auto; }
.dd.open .dd-caret { transform: rotate(180deg); }

.dd-menu {
  position: absolute; z-index: 90; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  border: 1px solid var(--color-border-strong); border-radius: 13px;
  background: #fbf5ea; box-shadow: 0 22px 55px rgba(60,78,112,0.15);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.dd.open .dd-menu { opacity: 1; transform: none; pointer-events: auto; }
.dd-menu li {
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font-weight: 650; font-size: 0.9rem;
  color: var(--color-text); transition: background 120ms;
}
.dd-menu li:hover { background: rgba(108,191,60,0.1); }
.dd-menu li.sel { color: var(--color-cyan-bright); background: rgba(108,191,60,0.12); }

/* ── Filter rows ──────────────────────────── */
.filter-group { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.filter-label { flex: 0 0 62px; color: var(--color-faint); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.fchip {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--color-border); border-radius: 11px;
  background: rgba(255,255,255,0.5); cursor: pointer;
  transition: 150ms var(--ease); filter: saturate(1.08) opacity(0.9);
}
.fchip img { width: 24px; height: 24px; object-fit: contain; }
.fchip:hover { border-color: var(--color-border-strong); filter: none; transform: translateY(-1px); }
.fchip.on {
  border-color: var(--color-border-strong); filter: none;
  background: linear-gradient(135deg, rgba(108,191,60,0.2), rgba(108,191,60,0.1));
  box-shadow: 0 0 0 1px var(--color-border-strong), 0 6px 16px rgba(60,78,112,0.1);
}

.filter-foot { margin-top: 14px; min-height: 0; }
.clear-filters {
  padding: 7px 14px; border: 1px solid var(--color-border-2); border-radius: 10px;
  color: var(--color-muted); background: transparent; cursor: pointer; font-size: 0.82rem;
}
.clear-filters:hover { color: var(--color-text); border-color: var(--color-border-strong); }

/* ── Portrait frame (shared) ──────────────── */
.pf {
  --zoom: 1.16; position: relative; width: var(--s, 48px); height: var(--s, 48px);
  flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 50%;
  border: 1px solid rgba(150,125,90,0.14);
  background: radial-gradient(circle at 50% 34%, #fffefa 0%, #faf4e8 58%, #f7f1e4 100%);
  box-shadow: inset 0 0 0 1px rgba(60,78,112,0.08), inset 0 -6px 15px rgba(60,78,112,0.09);
}
.pf img { width: 100%; height: 100%; object-fit: contain; transform: scale(var(--zoom)); filter: drop-shadow(0 4px 7px rgba(60,78,112,0.12)); }
.pf.failed img { display: none; }
.pf.failed::before {
  content: ""; width: 46%; height: 46%; background: var(--color-faint); opacity: 0.5;
  -webkit-mask: var(--pal-glyph) center / contain no-repeat; mask: var(--pal-glyph) center / contain no-repeat;
}

.type-ico { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(60,78,112,0.12)); }
.type-ico.sm { width: 18px; height: 18px; }
.type-row { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.type-row.big .type-ico { width: 26px; height: 26px; }

/* ── Grid + card ──────────────────────────── */
.grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 13px; }

.pal-card {
  position: relative; padding: 16px 12px 14px; display: grid; justify-items: center; gap: 9px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(0,0,0,0.035), transparent 60%), rgba(255,255,255,0.55);
  cursor: pointer; text-align: center; color: var(--color-text);
  transition: transform 170ms var(--ease), border-color 170ms, background 170ms, box-shadow 170ms;
  animation: rise 0.35s var(--ease) both;
}
.pal-card:hover {
  border-color: var(--color-border-strong); transform: translateY(-3px);
  background: linear-gradient(180deg, rgba(108,191,60,0.06), transparent 60%), rgba(255,255,255,0.8);
  box-shadow: 0 16px 34px rgba(60,78,112,0.11);
}

.card-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; pointer-events: none; }
.card-top .work-row { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; max-width: 92px; }

.work-badge { display: inline-flex; align-items: center; gap: 1px; }
.work-badge img { width: 19px; height: 19px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(60,78,112,0.13)); }
.work-badge b { color: #5a8f3e; font-size: 0.64rem; font-weight: 800; }

.pal-card .pf { margin-top: 14px; }
.card-name { font-size: 0.92rem; font-weight: 750; letter-spacing: -0.01em; }
.card-name .dex { color: var(--color-faint); font-size: 0.76rem; font-weight: 700; }

.rarity-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 4px;
  border: 1px solid color-mix(in srgb, var(--tier, var(--tier-common)) 45%, transparent);
  border-radius: 999px; background: color-mix(in srgb, var(--tier, var(--tier-common)) 14%, transparent);
  font-size: 0.72rem; font-weight: 750;
}
.rarity-pill b {
  display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--tier, var(--tier-common)); color: #f5efe2; font-weight: 800; font-size: 0.72rem;
}
.rarity-pill span { color: color-mix(in srgb, var(--tier, var(--tier-common)) 82%, #ffffff); }
.rarity-pill[data-tier="common"] { --tier: var(--tier-common); }
.rarity-pill[data-tier="rare"] { --tier: var(--tier-rare); }
.rarity-pill[data-tier="epic"] { --tier: var(--tier-epic); }
.rarity-pill[data-tier="legendary"] { --tier: var(--tier-legendary); }

/* ── Status / footer ──────────────────────── */
.status { min-height: 1.4em; margin-top: 18px; color: var(--color-muted); font-size: 0.86rem; text-align: center; }
.status .err { color: var(--color-danger); }
.loading { display: inline-flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(108,191,60,0.16); border-top-color: var(--color-cyan); border-radius: 50%; animation: spin 0.65s linear infinite; }
.foot { margin: 28px 0 0; color: rgba(125,115,96,0.46); font-size: 0.72rem; text-align: center; }

/* ── Modal ────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 12000; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(60,78,112,0.14); backdrop-filter: blur(6px); animation: fade 0.2s var(--ease); }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: 88vh; overflow: auto;
  padding: clamp(18px, 3vw, 30px); border: 1px solid var(--color-border-strong); border-radius: var(--radius-xl);
  background: linear-gradient(160deg, #fbf6ec, #f7f1e4);
  box-shadow: 0 40px 90px rgba(60,78,112,0.15); animation: pop 0.22s var(--ease);
}
.modal-close {
  position: sticky; float: right; top: 0; width: 36px; height: 36px; margin: -6px -6px 0 0;
  border: 1px solid var(--color-border-2); border-radius: 10px; color: var(--color-muted);
  background: rgba(255,255,255,0.7); cursor: pointer; font-size: 0.9rem;
}
.modal-close:hover { color: var(--color-text); border-color: var(--color-border-strong); }

.modal-head { display: flex; align-items: center; gap: 20px; }
.modal-head .pf { box-shadow: 0 0 30px rgba(108,191,60,0.14), inset 0 -6px 15px rgba(60,78,112,0.09); }
.mh-info { min-width: 0; display: grid; gap: 9px; }
.mh-top { display: flex; align-items: baseline; gap: 10px; }
.mh-top h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; letter-spacing: -0.04em; }
.dex.big { color: var(--color-faint); font-size: 1rem; font-weight: 700; }
.mh-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tagpill { padding: 3px 11px; border: 1px solid var(--color-border-2); border-radius: 999px; color: var(--color-muted); font-size: 0.72rem; font-weight: 700; }
.tagpill.night { color: #cbb2ff; border-color: rgba(150, 120, 220, 0.4); }
.tagpill.danger { color: var(--color-orange); border-color: rgba(108,191,60,0.4); }

.breed-cta {
  display: inline-flex; align-items: center; gap: 9px; margin: 20px 0 6px; padding: 11px 18px;
  border: 1px solid var(--color-border-strong); border-radius: 13px;
  background: linear-gradient(135deg, rgba(108,191,60,0.18), rgba(108,191,60,0.12));
  color: var(--color-cyan-bright); font-weight: 750; text-decoration: none; transition: 150ms;
}
.breed-cta svg { width: 19px; height: 19px; }
.breed-cta:hover { border-color: var(--color-cyan); box-shadow: 0 8px 22px rgba(60,78,112,0.1); transform: translateY(-1px); }

.lore { margin: 16px 0 4px; color: var(--color-muted); font-size: 0.9rem; line-height: 1.6; }

.modal-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 22px; }
.block h3 { margin: 0 0 12px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-cyan); }
.muted { color: var(--color-faint); font-size: 0.85rem; }

.stats { display: grid; gap: 9px; }
.stat { display: grid; grid-template-columns: 96px 1fr 42px; align-items: center; gap: 10px; }
.stat-l { color: var(--color-muted); font-size: 0.8rem; }
.stat-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.8); overflow: hidden; }
.stat-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--color-orange), var(--color-cyan)); }
.stat-v { text-align: right; font-size: 0.82rem; font-weight: 750; }

.work-list { display: grid; gap: 8px; }
.work-item { display: flex; align-items: center; gap: 9px; }
.work-item img { width: 24px; height: 24px; object-fit: contain; }
.work-item span { flex: 1; color: var(--color-text); font-size: 0.85rem; }
.work-item b { color: #4e9a44; font-size: 0.78rem; font-weight: 800; }

.partner { display: flex; gap: 13px; align-items: flex-start; padding: 13px; border: 1px solid var(--color-border); border-radius: 14px; background: rgba(255,255,255,0.4); }
.partner img { width: 40px; height: 40px; flex: 0 0 40px; object-fit: contain; }
.partner b { font-size: 0.92rem; }
.partner p { margin: 5px 0 0; color: var(--color-muted); font-size: 0.82rem; line-height: 1.5; }
.block > .partner { margin-top: 0; }
.modal-body > .block { margin-top: 22px; }

.skills { display: grid; gap: 11px; }
.skill { padding: 11px 13px; border: 1px solid var(--color-border); border-radius: 12px; background: rgba(255,255,255,0.4); }
.skill-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.skill-head b { font-size: 0.86rem; }
.skill-meta { color: #7a94a6; font-size: 0.72rem; font-weight: 800; }
.skill p { margin: 6px 0 0; color: var(--color-muted); font-size: 0.8rem; line-height: 1.5; }

.drops { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.drops li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--color-border); border-radius: 11px; background: rgba(255,255,255,0.4); font-size: 0.84rem; }
.drops li em { color: var(--color-muted); font-style: normal; font-size: 0.78rem; }

:focus-visible { outline: 2px solid var(--color-cyan); outline-offset: 3px; }

/* ── Scrollbars ───────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(108,191,60,0.4) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent; border-radius: 999px; background-clip: padding-box;
  background-color: rgba(150,125,90,0.28);
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(108,191,60,0.5); }
.modal-card::-webkit-scrollbar-thumb { background-color: rgba(108,191,60,0.32); }

/* ── Responsive ───────────────────────────── */
@media (max-width: 760px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .field.search { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .modal-cols { grid-template-columns: 1fr; gap: 20px; }
  .filter-label { flex-basis: 100%; margin-bottom: -4px; }
  .filter-group { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

.pal-card { text-decoration: none; color: inherit; }

/* perf: skip offscreen card render */
.pal-card, .item-card { content-visibility: auto; contain-intrinsic-size: 190px 210px; }
