/* poke.study: a Pokédex-inspired, modern, mobile-first stylesheet. */

:root {
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pixel: "Silkscreen", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 20px;
  --wrap: 1120px;
  --header-h: 64px;
  --lip: 9px;
  --nav-h: 48px;

  --bg: #f3efe9;
  --bg-dots: rgba(120, 90, 60, .07);
  --surface: #fffdfa;
  --surface-2: #f5f0e9;
  --line: #e7dfd4;
  --text: #201a15;
  --muted: #74695f;
  --red: #dc1e26;
  --red-2: #b3141b;
  --red-3: #8a0e14;
  --bezel: #efebe5;
  --lcd: #dde9e1;
  --lcd-ink: #21382c;
  --lcd-grid: rgba(33, 56, 44, .055);
  --chip: #eee7de;
  --chip-on: #201a15;
  --chip-on-ink: #fff;
  --shadow: 0 1px 1px rgba(40, 25, 10, .04), 0 6px 20px rgba(40, 25, 10, .07);
  --focus: #2563eb;
  --link: #b8121a;
  --phys-bg: #fde3cf; --phys-ink: #9a3f06;
  --spec-bg: #dbe6ff; --spec-ink: #2643a0;
  --s1: #e4553f; --s2: #ef8a25; --s3: #e9b913; --s4: #8fc43a; --s5: #36b06a; --s6: #1ea0a6;
  /* Charts: one series hue, plus text for good/bad changes (always with an arrow) */
  --series-1: #2a78d6; --good-ink: #006300; --bad-ink: #d03b3b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --bg-dots: rgba(255, 255, 255, .035); --surface: #1a1b1f; --surface-2: #22242a;
    --line: #2d3037; --text: #efece8; --muted: #a59d94; --red: #e2333a; --red-2: #b0161d; --red-3: #6e0b10;
    --bezel: #2a2c32; --lcd: #0e1b16; --lcd-ink: #b5efcd; --lcd-grid: rgba(181, 239, 205, .045);
    --chip: #282a30; --chip-on: #efece8; --chip-on-ink: #111214;
    --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --link: #ff7b80;
    --phys-bg: #4a2a12; --phys-ink: #ffb27a; --spec-bg: #1d2c55; --spec-ink: #a9c1ff;
    --series-1: #3987e5; --good-ink: #0ca30c; --bad-ink: #e66767;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --bg-dots: rgba(255, 255, 255, .035); --surface: #1a1b1f; --surface-2: #22242a;
  --line: #2d3037; --text: #efece8; --muted: #a59d94; --red: #e2333a; --red-2: #b0161d; --red-3: #6e0b10;
  --bezel: #2a2c32; --lcd: #0e1b16; --lcd-ink: #b5efcd; --lcd-grid: rgba(181, 239, 205, .045);
  --chip: #282a30; --chip-on: #efece8; --chip-on-ink: #111214;
  --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --link: #ff7b80;
  --phys-bg: #4a2a12; --phys-ink: #ffb27a; --spec-bg: #1d2c55; --spec-ink: #a9c1ff;
  --series-1: #3987e5; --good-ink: #0ca30c; --bad-ink: #e66767;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + var(--nav-h) + 8px); }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--text);
  background: var(--bg); background-image: radial-gradient(var(--bg-dots) 1px, transparent 1px); background-size: 18px 18px;
  overflow-x: hidden;
}
img { max-width: 100%; }
a { color: var(--link); }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 640px; padding-top: 40px; padding-bottom: 40px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 16px; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .8rem; margin: 12px 0 0; }
.empty { color: var(--muted); margin: 4px 0; }

/* ---------- header: the Pokédex lid ---------- */
.dex-top { position: sticky; top: 0; z-index: 50; height: var(--header-h); color: #fff; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .2)); }
.dex-top::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-2) 100%);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--lip)), 41% calc(100% - var(--lip)), calc(41% - 14px) 100%, 0 100%);
}
.dex-top__inner { position: relative; height: calc(var(--header-h) - var(--lip)); max-width: var(--wrap); margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex: none; }
.lens {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; flex: none;
  background: radial-gradient(circle at 32% 30%, #e6f8ff 0 12%, #74cbff 24%, #1d8fe6 56%, #0b4f93 100%);
  box-shadow: 0 0 0 2px var(--red-3), inset 0 -4px 8px rgba(0, 0, 0, .35), 0 0 12px rgba(116, 203, 255, .5);
  animation: lens 4s ease-in-out infinite;
}
@keyframes lens { 50% { box-shadow: 0 0 0 2px var(--red-3), inset 0 -4px 8px rgba(0, 0, 0, .35), 0 0 22px rgba(116, 203, 255, .95); } }
.leds { display: flex; gap: 5px; align-self: flex-start; margin-top: 9px; }
.leds i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(0, 0, 0, .3); }
.leds i:nth-child(1) { background: #ff5a5a; }
.leds i:nth-child(2) { background: #ffd23f; }
.leds i:nth-child(3) { background: #45d483; }
.brand__name { font-weight: 800; font-size: 1.25rem; letter-spacing: .01em; text-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
.brand__tld { opacity: .72; }
.search { position: relative; flex: 1; min-width: 0; max-width: 520px; margin-left: auto; display: flex; align-items: center; }
.search > .i { position: absolute; left: 12px; color: var(--lcd-ink); opacity: .7; pointer-events: none; }
.search input {
  width: 100%; height: 40px; border-radius: 12px; border: 2px solid rgba(0, 0, 0, .28); background: var(--lcd); color: var(--lcd-ink);
  padding: 0 12px 0 38px; font-weight: 500; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .2); -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--lcd-ink); opacity: .6; }
.search__results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .25);
}
.search__results a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 600; }
.search__results a > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search__results small { font-family: var(--pixel); font-size: .62rem; color: var(--muted); font-weight: 400; }
.search__results li[aria-selected="true"] a, .search__results a:hover { background: var(--surface-2); }
.search__results img { width: 40px; height: 40px; image-rendering: pixelated; flex: none; }
.search__none { padding: 10px; color: var(--muted); }
.icon-btn {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: rgba(0, 0, 0, .2); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .22);
}
.icon-btn:hover { background: rgba(0, 0, 0, .3); }
@media (max-width: 560px) {
  .brand__name { display: none; }
  .lens { width: 36px; height: 36px; }
  /* The header's filter makes it the containing block, so this spans the full header width. */
  .search__results { position: fixed; top: calc(var(--header-h) - 4px); left: 10px; right: 10px; }
}

/* ---------- prev / next ---------- */
.pager { display: flex; justify-content: space-between; gap: 8px; margin: 18px 0 10px; }
.pager__btn {
  display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 48%; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.pager__btn--next { padding: 6px 6px 6px 12px; text-align: right; }
.pager__btn span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pager__btn span, .pager__btn span small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager__btn small { font-family: var(--pixel); font-size: .6rem; color: var(--muted); font-weight: 400; }

/* ---------- hero ---------- */
.hero { display: grid; gap: 16px 28px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "device" "facts" "entry"; }
.hero__body { display: contents; }
.hero__head { grid-area: head; min-width: 0; }
.device { grid-area: device; }
.hero__facts { grid-area: facts; min-width: 0; }
.hero__entry { grid-area: entry; min-width: 0; }
@media (min-width: 860px) {
  .hero { grid-template-columns: minmax(0, 430px) minmax(0, 1fr); grid-template-areas: "device head" "device facts" "device entry"; grid-template-rows: auto auto 1fr; align-items: start; }
  .hero__head { align-self: end; }
}
.dex-entry {
  margin: 0; padding: 14px 16px 12px; border-radius: 16px; color: var(--lcd-ink); background-color: var(--lcd);
  background-image: linear-gradient(var(--lcd-grid) 1px, transparent 1px), linear-gradient(90deg, var(--lcd-grid) 1px, transparent 1px);
  background-size: 14px 14px; border: 2px solid color-mix(in srgb, var(--lcd-ink) 20%, transparent); box-shadow: inset 0 2px 8px rgba(0, 0, 0, .12);
}
.dex-entry__label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; font-family: var(--pixel); font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.dex-entry__text { margin: 8px 0 6px; font-size: 1.02rem; font-weight: 500; line-height: 1.55; }
.dex-entry__more { color: inherit; font-size: .8rem; font-weight: 700; opacity: .85; }
.hero__num { margin: 0; font-family: var(--pixel); color: var(--red); font-size: .95rem; letter-spacing: .04em; }
.hero__name { margin: 2px 0 4px; font-size: clamp(2.1rem, 8vw, 3.4rem); line-height: 1.02; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.hero__genus { margin: 0; color: var(--muted); font-weight: 500; }
.form-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding: 2px; }
.form-chips::-webkit-scrollbar { display: none; }

.device {
  position: relative; padding: 16px 16px 14px; border-radius: 26px;
  background: linear-gradient(155deg, var(--red) 0%, var(--red-2) 72%, var(--red-3) 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), inset 0 -4px 0 rgba(0, 0, 0, .25), var(--shadow);
}
.bezel {
  background: var(--bezel); border-radius: 14px; padding: 10px 14px 12px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 44px 100%, 0 calc(100% - 44px));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08);
}
.bezel__leds { display: flex; justify-content: center; gap: 10px; margin-bottom: 8px; }
.bezel__leds i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: inset 0 -1px 1px rgba(0, 0, 0, .3); }
.lcd {
  position: relative; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; border-radius: 10px;
  background-color: var(--lcd);
  background-image: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, .22), transparent 65%);
  border: 2px solid rgba(0, 0, 0, .18); box-shadow: inset 0 3px 10px rgba(0, 0, 0, .18);
}
/* The screen grid stays near the edges and fades out behind the Pokémon. */
.lcd::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--lcd-grid) 1px, transparent 1px), linear-gradient(90deg, var(--lcd-grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: center;
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, transparent 25%, #000 90%);
  mask-image: radial-gradient(ellipse at 50% 45%, transparent 25%, #000 90%);
}
.lcd.is-loading::after {
  content: "Loading…"; position: absolute; top: 8px; right: 10px; font-family: var(--pixel); font-size: .62rem;
  color: var(--lcd-ink); animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }
.lcd__no { position: absolute; top: 8px; left: 10px; font-family: var(--pixel); font-size: .72rem; color: var(--lcd-ink); opacity: .75; }
.lcd { padding-bottom: 52px; perspective: 900px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.lcd.can-turn { cursor: grab; }
.lcd.is-dragging { cursor: grabbing; }
.sprite-main {
  position: relative; z-index: 1; width: 84%; height: 84%; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .22)); -webkit-user-drag: none; user-select: none;
}

/* 360° tab: the rotatable model replaces the sprite while it's up. */
.lcd model-viewer {
  position: absolute; inset: 0 0 52px 0; z-index: 1; width: 100%; height: calc(100% - 52px);
  background: transparent; --poster-color: transparent; --progress-bar-color: var(--red); --progress-bar-height: 3px;
}
.device:not(.is-model) .lcd model-viewer { display: none; }
/* While the 3D model loads (or if it can't), the last picture stays up instead of an empty screen. */
.device.is-model .lcd:not(.model-loading):not(.model-failed) .sprite-main { display: none; }
.device.is-model .lcd.model-loading model-viewer, .device.is-model .lcd.model-failed model-viewer { opacity: 0; }
.model-note { margin: 10px 2px 0; font-size: .74rem; line-height: 1.4; color: rgba(255, 255, 255, .82); }
.select--dark { margin-top: 10px; background: rgba(0, 0, 0, .26); border-color: rgba(0, 0, 0, .2); color: #fff; }
.select--dark span { color: rgba(255, 255, 255, .75); }
.select.select--dark select { background-color: transparent; color: #fff; }
.select.select--dark select::picker-icon { color: rgba(255, 255, 255, .75); }
.model-note a { color: #fff; }

/* Turn arrows either side of the Pokémon: tap to turn a step (or round, for sprites), hold to keep turning. */
.turn-arrows { position: absolute; z-index: 2; left: 10px; right: 10px; bottom: 48px; display: flex; justify-content: space-between; pointer-events: none; }
.turn-btn {
  pointer-events: auto; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  color: var(--lcd-ink); background: color-mix(in srgb, var(--lcd-ink) 14%, transparent);
  touch-action: none; -webkit-touch-callout: none; user-select: none; transition: background .15s, transform .15s;
}
.turn-btn:hover { background: color-mix(in srgb, var(--lcd-ink) 24%, transparent); }
.turn-btn.is-held { background: color-mix(in srgb, var(--lcd-ink) 32%, transparent); transform: scale(.94); }

/* Turntable ring (used by the 3D lab page). */
.turn-ring {
  position: absolute; z-index: 2; left: 50%; bottom: 42px; width: 62%; aspect-ratio: 4 / 1; padding: 0; transform: translateX(-50%);
  border: 0; border-radius: 50%; background: none; color: var(--lcd-ink); cursor: pointer; opacity: .7;
  touch-action: none; -webkit-touch-callout: none; transition: opacity .2s, filter .2s;
}
.turn-ring:hover, .turn-ring:focus-visible, .turn-ring.is-held { opacity: 1; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--lcd-ink) 45%, transparent)); }
.turn-ring__svg { display: block; width: 100%; height: 100%; overflow: visible; fill: none; stroke: currentColor; stroke-linecap: round; }
.turn-ring__back { stroke-width: 1.6; stroke-dasharray: 3 6; opacity: .5; }
.turn-ring__front { stroke-width: 2.6; }
.turn-ring__head { fill: currentColor; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; }
.sprite-main.is-pixel { width: 72%; height: 72%; image-rendering: pixelated; }
.sprite-main.is-opaque { width: 62%; height: 62%; padding: 4px; border-radius: 6px; background: #fff; filter: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, .15); }
.lcd__bar {
  position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; padding: 3px; border-radius: 10px;
  background: color-mix(in srgb, var(--lcd-ink) 9%, transparent);
}
.lcd__btn {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; cursor: pointer;
  color: var(--lcd-ink); background: color-mix(in srgb, var(--lcd-ink) 14%, transparent);
}
.lcd__btn:hover { background: color-mix(in srgb, var(--lcd-ink) 24%, transparent); }
.lcd__btn .i { width: 18px; height: 18px; }
.lcd__label {
  flex: 1; min-width: 0; text-align: center; font-family: var(--pixel); font-size: .62rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--lcd-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bezel__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-left: 26px; }
.big-led { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff9e9e, var(--red) 60%, var(--red-3)); box-shadow: 0 0 0 2px rgba(0, 0, 0, .2); }
.grille { display: flex; flex-direction: column; gap: 4px; }
.grille b { display: block; width: 34px; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, .22); }
.src-picker { display: grid; gap: 8px; margin-top: 14px; }
.src-groups, .src-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
.src-chips { padding-top: 8px; border-top: 1px dashed rgba(255, 255, 255, .3); }
.src-break { flex-basis: 100%; height: 0; }
.src-gen { margin-right: 2px; font-family: var(--pixel); font-size: .56rem; text-transform: uppercase; color: rgba(255, 255, 255, .75); }
.src-btn, .src-chip {
  border: 0; border-radius: 999px; cursor: pointer; font-weight: 700; color: #fff;
  background: rgba(0, 0, 0, .26); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.src-btn { min-width: 26px; padding: 6px 7px; font-size: .76rem; }
.src-chip { padding: 5px 11px; font-size: .78rem; }
.src-chip.has-anim::after { content: "▶"; margin-left: 5px; font-size: .5rem; vertical-align: 1px; opacity: .75; }
.src-btn[aria-pressed="true"], .src-chip[aria-pressed="true"] { background: #fff; color: #1f1b17; box-shadow: none; }
.device__btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.i--fill { fill: currentColor; stroke: none; }
.round-btn .i--pause, .round-btn[aria-pressed="true"] .i--play { display: none; }
.round-btn[aria-pressed="true"] .i--pause { display: block; }
.round-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: #23252b; color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .45), 0 2px 0 rgba(0, 0, 0, .25);
}
.round-btn[aria-pressed="true"] { background: #ffd23f; color: #3b2a00; }
.round-btn.is-playing { background: #45d483; color: #062b16; }
.round-btn:disabled { opacity: .45; cursor: not-allowed; }
/* Shiny is on but the picture on screen has no shiny version */
.round-btn.is-unavailable { position: relative; }
.round-btn.is-unavailable::after { content: ""; position: absolute; left: 10px; right: 10px; top: calc(50% - 1px); height: 2.5px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); }
.round-btn--text { font-family: var(--pixel); font-size: .6rem; }
.round-btn--sm { width: 36px; height: 36px; flex: none; }
.round-btn--sm .i { width: 18px; height: 18px; }

.types { display: flex; flex-wrap: wrap; gap: 6px; }
.type {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; line-height: 1.3; white-space: nowrap;
  background: var(--tc); color: var(--tt, #fff); font-weight: 700; font-size: .85rem;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .28); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
}
.type--sm { padding: 1px 8px; font-size: .72rem; }
.types--lg .type { padding: 6px 18px; font-size: 1rem; }
.t-normal { --tc: #9fa19f; } .t-fire { --tc: #e62829; } .t-water { --tc: #2980ef; }
.t-electric { --tc: #f5bc00; --tt: #3a2c00; } .t-grass { --tc: #3fa129; } .t-ice { --tc: #3dcef3; --tt: #063845; }
.t-fighting { --tc: #ff8000; } .t-poison { --tc: #9141cb; } .t-ground { --tc: #915121; } .t-flying { --tc: #6fa9e6; }
.t-psychic { --tc: #ef4179; } .t-bug { --tc: #91a119; } .t-rock { --tc: #a49c74; } .t-ghost { --tc: #704170; }
.t-dragon { --tc: #5060e1; } .t-dark { --tc: #624d4e; } .t-steel { --tc: #5a9ab0; } .t-fairy { --tc: #e862e8; }
.t-stellar { --tc: #40b5a5; } .t-unknown { --tc: #68a090; }
.t-electric.type, .t-ice.type { text-shadow: none; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0 0; }
.facts > div { min-width: 0; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.facts dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.facts dd { margin: 2px 0 0; font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.facts dd small { display: block; font-weight: 500; font-size: .78rem; color: var(--muted); }
@media (min-width: 600px) { .hero .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facts--compact { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin: 0; }
.facts--compact > div { background: var(--surface-2); border-color: transparent; }
.facts--compact dd { font-size: .98rem; }
.facts--stack { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.abil-row { margin-top: 14px; }
.abil-row__label { display: block; margin-bottom: 6px; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.abil-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.abil-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; cursor: help; }
.abil-chip small { font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.abil-chip .i { width: 16px; height: 16px; color: var(--muted); }
.abil-chip.is-hidden { border-style: dashed; }
.abil-chip:hover, .abil-chip[aria-describedby] { border-color: color-mix(in srgb, var(--text) 35%, var(--line)); }
.abil-chip:hover .i, .abil-chip[aria-describedby] .i { color: var(--text); }

/* Descriptions shown on hover or tap (ability names) */
.tip-term { padding: 0; border: 0; background: none; text-align: left; cursor: help; text-decoration: underline dotted color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
.tip-term:hover, .tip-term[aria-describedby] { color: var(--link); }
.tip {
  position: fixed; z-index: 80; left: 0; top: 0; width: max-content; max-width: min(320px, calc(100vw - 16px));
  padding: 10px 12px; border-radius: 12px; background: var(--text); color: var(--surface);
  font-size: .86rem; line-height: 1.45; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); pointer-events: none;
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .12s, transform .12s, visibility 0s .12s;
}
.tip.is-below { transform: translateY(-4px); }
.tip.is-open { opacity: 1; visibility: visible; transform: none; transition: opacity .12s, transform .12s; }
.tip::after { content: ""; position: absolute; top: 100%; left: var(--arrow-x, 50%); margin-left: -7px; border: 7px solid transparent; border-top-color: var(--text); }
.tip.is-below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--text); }
@media (prefers-reduced-motion: reduce) { .tip, .tip.is-open { transition: none; } }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.abil__name .badge { margin-left: 8px; }
.badge--gold { background: #f6d77a; color: #4d3800; }
.badge--violet { background: #dccaff; color: #3b1d73; }

/* ---------- chips & segmented controls ---------- */
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--chip);
  font-weight: 600; font-size: .88rem; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--chip-on); color: var(--chip-on-ink); border-color: transparent; }
.chip--static { cursor: default; background: var(--surface); }
/* Rows of chips and tabs wrap instead of scrolling sideways (only the section nav scrolls). */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px; margin: 0 -2px; min-width: 0; }
.chip small { font-size: .78em; font-weight: 600; opacity: .65; margin-left: 2px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row--wrap { flex-wrap: wrap; overflow: visible; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .85rem; color: var(--muted); white-space: nowrap; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.seg--sm button { padding: 4px 9px; font-size: .76rem; }
.seg--dark { background: rgba(0, 0, 0, .28); border-color: rgba(0, 0, 0, .2); }
.seg--dark button { color: rgba(255, 255, 255, .85); }
.seg--dark button[aria-pressed="true"] { background: #fff; color: #1f1b17; }

/* ---------- section nav ---------- */
.section-nav {
  position: sticky; top: calc(var(--header-h) - var(--lip)); z-index: 40; margin: 14px -16px 0; padding: calc(var(--lip) + 2px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.section-nav__inner { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.section-nav__inner::-webkit-scrollbar { display: none; }
.section-nav a { flex: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .85rem; text-decoration: none; white-space: nowrap; }
.section-nav a:hover { color: var(--text); }
.section-nav a.is-active { background: var(--chip-on); color: var(--chip-on-ink); }

/* ---------- cards ---------- */
.sections { display: grid; gap: 16px; padding: 14px 0 36px; }
@media (min-width: 960px) {
  .sections { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; align-items: start; }
  .card[data-section="competitive"], .card[data-section="moves"], .card[data-section="evolution"],
  .card[data-section="sprites"], .card[data-section="lore"] { grid-column: 1 / -1; }
}
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
/* Sections below the screen aren't laid out until scrolled near, so pages show up sooner */
.sections > .card { content-visibility: auto; contain-intrinsic-size: auto 480px; }
.card__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 10px; padding: 14px 16px 0; cursor: pointer; }
.card__head:hover .collapse-btn { color: var(--text); border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.card__head h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 800; }
.card__head h2::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent); }
.card__tools { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.collapse-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); cursor: pointer; }
.collapse-btn .i { width: 18px; height: 18px; transition: transform .2s; }
.card.is-collapsed .collapse-btn .i { transform: rotate(-90deg); }
.card.is-collapsed .card__body, .card.is-collapsed .card__tools > :not(.collapse-btn) { display: none; }
.card.is-collapsed .card__head { padding-bottom: 14px; }
.card__body { padding: 14px 16px 16px; min-width: 0; }
.card h1 { margin-top: 0; }

/* ---------- stats ---------- */
.stats-bars { display: grid; gap: 8px; }
.stat { display: grid; grid-template-columns: 2.6rem 2.4rem minmax(0, 1fr) 3.4rem 5.6rem; align-items: center; gap: 10px; }
.stat__rank { justify-self: end; }
.stat--head .stat__rank { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rank-chip {
  padding: 2px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: .76rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help;
}
.rank-chip.is-top { color: var(--text); border-color: color-mix(in srgb, var(--series-1) 45%, var(--line)); }
.rank-chip:hover, .rank-chip[aria-describedby] { color: var(--text); border-color: var(--series-1); }
.stat__label { font-weight: 700; color: var(--muted); font-size: .85rem; }
.stat__val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08); }
.bar__fill { display: block; height: 100%; border-radius: inherit; background: var(--s3); }
.bar__fill.s1, .ms.s1 { --c: var(--s1); } .bar__fill.s2, .ms.s2 { --c: var(--s2); } .bar__fill.s3, .ms.s3 { --c: var(--s3); }
.bar__fill.s4, .ms.s4 { --c: var(--s4); } .bar__fill.s5, .ms.s5 { --c: var(--s5); } .bar__fill.s6, .ms.s6 { --c: var(--s6); }
.bar__fill { background: var(--c); }
.stat__range { text-align: right; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat--head .stat__range { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat--total { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; }
.stat__note { grid-column: 3; font-size: .8rem; color: var(--muted); }
html[data-statlevel="off"] .stat__range, html[data-statlevel="off"] .stat--head { display: none; }
html[data-statlevel="off"] .stat { grid-template-columns: 2.6rem 2.4rem minmax(0, 1fr) 3.4rem; }
@media (max-width: 420px) {
  .stat { gap: 8px; grid-template-columns: 2.3rem 2.2rem minmax(0, 1fr) 3.1rem 4.9rem; }
  html[data-statlevel="off"] .stat { grid-template-columns: 2.3rem 2.2rem minmax(0, 1fr) 3.1rem; }
}
html[data-statlevel="50"] .lv100, html[data-statlevel="100"] .lv50, html:not([data-statlevel]) .lv50 { display: none; }
.hex-wrap { display: none; }
html[data-statstyle="hex"] .hex-wrap { display: block; }
html[data-statstyle="hex"] .stats-bars .stat:not(.stat--total) { display: none; }
html[data-statstyle="hex"] .stat--total { border-top: 0; }
.hex { display: block; width: 100%; max-width: 360px; margin: 0 auto; }
.hex__ring { fill: none; stroke: var(--line); }
.hex__axis { stroke: var(--line); }
.hex__shape { fill: color-mix(in srgb, var(--red) 26%, transparent); stroke: var(--red); stroke-width: 2.5; stroke-linejoin: round; }
.hex__k { font-size: 11px; font-weight: 700; fill: var(--muted); text-anchor: middle; }
.hex__v { font-size: 13px; font-weight: 800; fill: var(--text); text-anchor: middle; }

/* ---------- speed tiers ---------- */
.spd-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.spd-chip { display: inline-flex; flex-direction: column; align-items: center; min-width: 4.4rem; padding: 6px 10px; border-radius: 12px; background: var(--surface-2); font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.spd-chip small { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.spd-summary { margin: 0 0 10px; }
.spd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 470px; overflow-y: auto; scrollbar-width: thin; }
.spd-row { display: grid; grid-template-columns: 2.6rem minmax(56px, 1fr) minmax(0, 1.7fr); align-items: center; gap: 10px; min-height: 34px; padding: 2px 6px; border-radius: 10px; }
.spd-row__val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.spd-row__bar i { display: block; height: 10px; width: var(--w); border-radius: 0 4px 4px 0; background: color-mix(in srgb, var(--muted) 40%, transparent); }
.spd-row__who { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; min-width: 0; color: inherit; text-decoration: none; }
.spd-row__who img { width: 32px; height: 32px; margin: -8px 0 -10px; align-self: center; image-rendering: pixelated; flex: none; }
.spd-row__who b { min-width: 0; font-size: .88rem; overflow-wrap: anywhere; }
.spd-row__who small { min-width: 0; font-size: .76rem; color: var(--muted); }
@media (max-width: 520px) {
  .spd-row { grid-template-columns: 2.3rem minmax(40px, .7fr) minmax(0, 2fr); gap: 8px; }
  .spd-row__who img { display: none; }
  .spd-row__who small { flex-basis: 100%; }
}
a.spd-row__who:hover b { color: var(--link); }
.spd-row.is-mine { background: color-mix(in srgb, var(--series-1) 12%, transparent); }
.spd-row.is-mine .spd-row__bar i { background: var(--series-1); }

/* ---------- matchups & abilities ---------- */
.mu-group { margin-bottom: 14px; }
.mu-group:last-child { margin-bottom: 0; }
.mu-group h3, .comp-box h3, .mv-group h3, .gen-block h3, .sheet__body h3 {
  margin: 0 0 8px; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.mu-list { display: flex; flex-wrap: wrap; gap: 8px; }
.mu { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.mu b { font-size: .9rem; font-variant-numeric: tabular-nums; }
.mu-group--neutral summary { cursor: pointer; color: var(--muted); font-size: .85rem; font-weight: 600; }
.mu-group--neutral .mu-list { margin-top: 8px; }
.mu-note { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; font-size: .88rem; }
.abil-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.abil-list li { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.abil__name { display: flex; align-items: center; flex-wrap: wrap; font-weight: 800; }
.abil-list p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }

/* ---------- competitive ---------- */
.tiers { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tier { display: inline-flex; flex-direction: column; padding: 6px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-family: var(--pixel); font-size: .9rem; }
.tier small { font-family: var(--font); font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fmt-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 4px; margin: 0 -2px; }
@media (max-width: 520px) {
  .fmt-tabs { gap: 6px; }
  .fmt-tabs .fmt-tab { padding: 6px 10px; font-size: .82rem; }
}
.fmt-tabs::-webkit-scrollbar { display: none; }
.fmt-tab { flex: none; display: flex; flex-direction: column; align-items: flex-start; padding: 8px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); text-align: left; cursor: pointer; }
.fmt-tab span { font-weight: 700; font-size: .9rem; }
.fmt-tab small { color: var(--muted); font-weight: 600; }
.fmt-tab[aria-selected="true"] { background: var(--chip-on); color: var(--chip-on-ink); border-color: transparent; }
.fmt-tab[aria-selected="true"] small { color: inherit; opacity: .75; }
.fmt-head { margin: 12px 0; font-size: .92rem; }
.comp-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .comp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .comp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.comp-box { min-width: 0; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.comp-grid--top { margin-bottom: 12px; }

/* Small one-series line charts: hover, tap or focus a point for its value */
.spark { display: block; width: 100%; height: auto; margin: 4px 0 2px; overflow: visible; }
.spark__line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark__base { stroke: var(--line); stroke-width: 1; }
.spark__end, .spark__dot { fill: var(--series-1); stroke: var(--surface-2); stroke-width: 2; }
.spark__dot { opacity: 0; pointer-events: none; }
.spark__hit { fill: transparent; cursor: help; outline: none; }
.spark__hit:hover + .spark__dot, .spark__hit:focus-visible + .spark__dot, .spark__hit[aria-describedby] + .spark__dot { opacity: 1; }
.spark__axis { display: flex; justify-content: space-between; gap: 8px; font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Most common build */
.build { min-width: 0; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.build__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.build__head h3 { margin: 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.build__facts { display: grid; gap: 4px; margin: 0; }
.build__facts div { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; }
.build__facts dt { color: var(--muted); }
.build__facts dd { margin: 0; font-weight: 700; text-align: right; }
.build__moves { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.build__moves li { padding: 6px 8px; border-radius: 10px; background: var(--surface); font-size: .86rem; font-weight: 600; }
.build .fine { margin-top: 8px; }

/* In-game ladder */
.ladder { margin: 4px 0 16px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); }
.ladder__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ladder__head h3 { margin: 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ladder__grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .ladder__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ladder__card { min-width: 0; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.ladder__card h4 { margin: 0; font-size: .82rem; font-weight: 700; color: var(--muted); }
.ladder__rank { margin: 2px 0 4px; }
.ladder__rank b { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.ladder__picks { margin: 6px 0 0; font-size: .84rem; }
.ladder[data-show="week"] [data-win="month"], .ladder[data-show="month"] [data-win="week"] { display: none; }
.delta { font-size: .8rem; font-weight: 700; color: var(--muted); }
.delta--up { color: var(--good-ink); }
.delta--down { color: var(--bad-ink); }

/* Replica Team codes */
.replica { margin-top: 16px; }
.replica h3 { margin: 0 0 8px; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.replica__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 760px) { .replica__list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.replica__team { min-width: 0; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.replica__top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.replica__top .muted { font-size: .8rem; }
.replica__mons { display: flex; flex-wrap: wrap; gap: 2px; margin: 8px 0; }
.replica__mon img { display: block; width: 44px; height: 44px; image-rendering: pixelated; }
.replica__code { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; font-size: .86rem; }
.replica__code code { padding: 4px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-family: var(--pixel); font-size: .8rem; letter-spacing: .08em; }
.pl { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.pl li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 3px 8px; font-size: .9rem; }
.pl__label { min-width: 0; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.pl__label b { flex: none; }
.pl__label .muted { min-width: 0; }
.pl__label a { display: inline-flex; align-items: center; gap: 4px; color: inherit; font-weight: 600; text-decoration: none; }
.pl__label a:hover { color: var(--link); }
.pl__label img { width: 32px; height: 32px; margin: -6px 0; image-rendering: pixelated; flex: none; }
.pl__val { font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; }
.pl__bar { grid-column: 1 / -1; position: relative; height: 4px; border-radius: 4px; overflow: hidden; background: var(--line); }
.pl__bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: inherit; background: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tc); flex: none; }

/* ---------- evolution ---------- */
.evo-tree, .evo-children { list-style: none; margin: 0; padding: 0; }
.evo-tree { display: flex; justify-content: center; }
.evo-item { display: flex; flex-direction: column; align-items: center; }
.evo-children { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 14px; margin-top: 4px; }
.evo-method { display: flex; flex-direction: column; align-items: center; max-width: 150px; margin: 8px 0 6px; text-align: center; font-size: .78rem; font-weight: 600; color: var(--muted); }
.evo-method::before { content: "↓"; margin-bottom: 2px; font-size: 1.1rem; line-height: 1; color: var(--red); }
.evo-mon { display: flex; flex-direction: column; align-items: center; width: 132px; padding: 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none; }
.evo-mon:hover { border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
.evo-mon img { width: 80px; height: 80px; image-rendering: pixelated; }
.evo-mon.is-current { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent); }
.evo-mon__num { font-family: var(--pixel); font-size: .62rem; color: var(--muted); }
.evo-mon__name { font-weight: 700; text-align: center; }
.evo-mon .types { justify-content: center; margin-top: 4px; }
@media (min-width: 760px) {
  .evo-item { flex-direction: row; }
  .evo-children { flex-direction: column; flex-wrap: nowrap; margin: 0; }
  .evo-children:has(> :nth-child(4)) { display: grid; grid-template-columns: repeat(2, auto); }
  .evo-method { margin: 0 12px; min-width: 70px; }
  .evo-method::before { content: "→"; }
}

/* ---------- moves ---------- */
.moves__controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.moves__controls .seg { align-self: center; }
@media (max-width: 420px) { .moves__controls .seg button { padding: 6px 9px; } }
.select { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; padding-left: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.select:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.select:focus-within { border-color: var(--focus); }
.select span { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
/* Dropdowns. Browsers that can style the whole list (Chrome, Edge) get a themed panel; the rest get
   their own list in the page's colours instead of a plain white one. */
.select select {
  min-width: 0; max-width: 100%; padding: 9px 10px 9px 2px; border: 0; font-weight: 600; cursor: pointer;
  background-color: var(--surface-2); color: var(--text);
}
.select select:focus-visible { outline: none; }
.select option { background-color: var(--surface); color: var(--text); }
@supports (appearance: base-select) {
  .select select, .select select::picker(select) { appearance: base-select; }
  .select select { display: flex; align-items: center; gap: 8px; padding: 9px 12px 9px 2px; background: transparent; }
  .select select::picker-icon {
    content: ""; width: 14px; height: 14px; background: currentColor; color: var(--muted); transition: rotate .2s;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .select select:open::picker-icon { rotate: 180deg; }
  .select select::picker(select) {
    margin-top: 6px; padding: 6px; max-height: min(60vh, 420px); overflow-y: auto; scrollbar-width: thin;
    border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text);
    box-shadow: var(--shadow), 0 16px 40px rgba(0, 0, 0, .18);
    opacity: 0; translate: 0 -4px; transition: opacity .15s, translate .15s, overlay .15s allow-discrete, display .15s allow-discrete;
  }
  .select select:open::picker(select) { opacity: 1; translate: 0 0; }
  @starting-style { .select select:open::picker(select) { opacity: 0; translate: 0 -4px; } }
  .select option { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; }
  .select option:hover, .select option:focus-visible { background: var(--surface-2); outline: none; }
  .select option:checked { background: var(--chip-on); color: var(--chip-on-ink); }
  .select option::checkmark { order: 1; margin-left: auto; content: "✓"; }
  .select optgroup { font-weight: 800; color: var(--muted); }
}
@media (prefers-reduced-motion: reduce) {
  .select select::picker(select), .select select::picker-icon { transition: none; }
}
.input { flex: 1; min-width: 150px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.moves__list { margin-top: 6px; transition: opacity .2s; }
.moves__list.is-loading { opacity: .45; }
.mv-group { margin-top: 14px; }
.mv-group h3 { display: flex; align-items: center; gap: 8px; }
.mv-group__count { padding: 0 8px; border-radius: 999px; background: var(--chip); font-size: .7rem; }
.mv-head { display: none; }
.mv {
  display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; grid-template-areas: "lv main type" "lv nums cls";
  align-items: center; gap: 4px 10px; padding: 9px 2px; border-top: 1px solid var(--line);
}
.mv__lv { grid-area: lv; align-self: start; padding: 6px 2px; border-radius: 8px; background: var(--surface-2); text-align: center; font-family: var(--pixel); font-size: .7rem; color: var(--muted); }
.mv__main { grid-area: main; min-width: 0; }
.mv__name { display: block; font-weight: 700; }
.mv__fx { display: block; margin-top: 1px; color: var(--muted); font-size: .8rem; line-height: 1.35; }
html[data-fx="off"] .mv__fx { display: none; }
.mv__type { grid-area: type; justify-self: end; }
.cls { grid-area: cls; justify-self: end; padding: 2px 7px; border-radius: 6px; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.cls--physical { background: var(--phys-bg); color: var(--phys-ink); }
.cls--special { background: var(--spec-bg); color: var(--spec-ink); }
.cls--status { background: var(--chip); color: var(--muted); }
.mv__nums { grid-area: nums; display: flex; gap: 12px; font-size: .82rem; font-variant-numeric: tabular-nums; }
.mv__nums span::before { content: attr(data-label) " "; font-size: .7rem; font-weight: 600; color: var(--muted); }
@media (min-width: 760px) {
  .mv, .mv-head { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) 6.2rem 4.4rem 10rem; grid-template-areas: "lv main type cls nums"; gap: 12px; }
  .mv-head { padding: 2px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  /* Column headers sort the list */
  .mv-head button {
    padding: 2px 0; border: 0; background: none; font: inherit; color: inherit; text-transform: inherit;
    letter-spacing: inherit; text-align: inherit; cursor: pointer;
  }
  .mv-head button:hover, .mv-head button.is-active { color: var(--text); }
  .mv-head button.is-active::after { content: " ▾"; }
  .mv__type, .cls { justify-self: start; }
  .mv__nums { display: grid; grid-template-columns: repeat(3, 1fr); text-align: right; }
  .mv__nums span::before { content: none; }
}

/* ---------- lore ---------- */
.dexnums { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.form-note { margin: 12px 0 0; font-size: .9rem; color: var(--muted); }
.form-note b { color: var(--text); }
.lore-sub { margin: 18px 0 8px; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.world-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; }
.world-names div { padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.world-names dt { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.world-names dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.dexnum { display: inline-flex; flex-direction: column; padding: 6px 10px; border-radius: 12px; background: var(--surface-2); font-family: var(--pixel); font-size: .85rem; }
.dexnum small { font-family: var(--font); font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.entries { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.entries li { padding: 12px 14px; border-radius: 14px; background: var(--lcd); color: var(--lcd-ink); border: 1px solid rgba(0, 0, 0, .08); }
.entries p { margin: 0; }
.entry__games { display: block; margin-top: 6px; font-family: var(--pixel); font-size: .64rem; opacity: .75; }
.entries li.is-extra { display: none; }
.entries.is-expanded li.is-extra { display: block; }
.more-btn { margin-top: 10px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; cursor: pointer; }

/* ---------- sprites ---------- */
.sprite-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.sprite-grid--sm { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.sprite-fig { margin: 0; text-align: center; }
.sprite-fig__btn { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: center; cursor: pointer; }
.sprite-fig__box { position: relative; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.sprite-fig__btn:hover .sprite-fig__box { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); }
.sprite-fig img { width: 86%; height: 86%; object-fit: contain; }
.sprite-fig img.is-pixel { width: 80%; height: 80%; image-rendering: pixelated; }
.sprite-fig__box.is-opaque img { width: 70%; height: 70%; border-radius: 4px; background: #fff; }
.anim-badge { position: absolute; top: 6px; right: 7px; font-size: .55rem; color: var(--red); }
.sprite-fig img.is-icon { width: 64%; height: 64%; }
.model-tile { font-family: var(--pixel); font-size: .6rem; color: var(--muted); text-transform: uppercase; }

/* ---------- stat calculator ---------- */
.calc { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.calc > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; list-style: none; cursor: pointer; font-weight: 800; }
.calc > summary::-webkit-details-marker { display: none; }
.calc > summary::before { content: "▸"; color: var(--red); transition: transform .2s; }
.calc[open] > summary::before { transform: rotate(90deg); }
.calc > summary small { flex-basis: 100%; padding-left: 16px; font-size: .78rem; font-weight: 500; color: var(--muted); }
.calc__body { display: grid; gap: 12px; margin-top: 12px; }
.calc__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.calc__note { font-size: .78rem; color: var(--muted); }
.select--num input { width: 4.2em; padding: 9px 10px 9px 2px; border: 0; background: transparent; font-weight: 600; }
.calc__presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.calc__presets > span { margin-right: 2px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chip--preset { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; max-width: 100%; text-align: left; white-space: normal; line-height: 1.25; border-radius: 12px; }
.chip--preset small { font-size: .68rem; font-weight: 500; color: var(--muted); }
.calc__rows { display: grid; gap: 8px; }
.calc-row { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) 3.4rem 3rem; align-items: center; gap: 8px; }
.calc-row__label { display: flex; flex-direction: column; font-weight: 700; line-height: 1.1; }
.calc-row__label small { font-size: .68rem; font-weight: 500; color: var(--muted); }
.calc-range { width: 100%; min-width: 0; accent-color: var(--red); }
.calc-num { width: 100%; min-width: 0; padding: 6px 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); text-align: center; font-variant-numeric: tabular-nums; }
.calc-row__out { text-align: right; font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.calc-row__out.is-up { color: var(--red); }
.calc-row__out.is-up::after { content: "▲"; margin-left: 2px; font-size: .55rem; vertical-align: 3px; }
.calc-row__out.is-down { color: #3b7be0; }
.calc-row__out.is-down::after { content: "▼"; margin-left: 2px; font-size: .55rem; vertical-align: 3px; }
.calc__cols { display: none; }
.calc__body[data-mode="main"] .calc-row { grid-template-columns: 3.2rem minmax(0, 1fr) 3.4rem 2.8rem 3rem; }
.calc__foot { display: flex; align-items: center; justify-content: space-between; font-size: .9rem; font-weight: 700; }
@media (max-width: 480px) {
  /* Too narrow for a slider plus EV and IV boxes: type the numbers instead. */
  .calc__body[data-mode="main"] .calc-range { display: none; }
  .calc__body[data-mode="main"] .calc-row { grid-template-columns: 3.2rem minmax(0, 1fr) minmax(0, 1fr) 3rem; }
  .calc__body[data-mode="main"] .calc__cols { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) minmax(0, 1fr) 3rem; gap: 8px; margin: 0 0 -6px; font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; }
  .calc__body[data-mode="main"] .calc__cols span:first-child { grid-column: 2; }
}
.sprite-fig__cap { display: block; margin-top: 4px; font-size: .74rem; font-weight: 600; color: var(--muted); }
.fine--top { margin: 0 0 6px; }
.sub { margin: 20px 0 4px; font-size: .95rem; }
.gen-block h3 { margin: 12px 0 6px; }

/* ---------- breeding & locations ---------- */
.gender { min-width: 0; }
.gender__bar { display: block; height: 10px; border-radius: 999px; background: linear-gradient(90deg, #4c8df6 calc(100% - var(--f)), #f472b6 0); }
.gender__labels { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; font-size: .82rem; font-weight: 700; }
.gender-view {
  margin-top: 14px; padding: 12px; border-radius: 16px; color: var(--lcd-ink); background-color: var(--lcd);
  border: 2px solid color-mix(in srgb, var(--lcd-ink) 18%, transparent); box-shadow: inset 0 2px 8px rgba(0, 0, 0, .1);
}
.gender-view__title { margin: 0 0 8px; font-family: var(--pixel); font-size: .6rem; text-transform: uppercase; letter-spacing: .03em; opacity: .8; }
.gender-view__pics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gv { margin: 0; text-align: center; }
.gv__box { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; background: color-mix(in srgb, var(--lcd-ink) 6%, transparent); }
.gv__box img { width: 82%; height: 82%; object-fit: contain; }
.gv__box img.is-pixel { width: 70%; height: 70%; image-rendering: pixelated; }
.gv__box.is-loading::after { content: "Loading…"; position: absolute; top: 6px; right: 8px; font-family: var(--pixel); font-size: .55rem; animation: blink 1s steps(2, start) infinite; }
.gv figcaption { margin-top: 4px; font-size: .85rem; font-weight: 800; }
.gender-view__controls { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.gender-view__bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 3px; border-radius: 10px; background: color-mix(in srgb, var(--lcd-ink) 9%, transparent); }
.male { color: #3b7be0; } .female { color: #d6458f; }
.loc { padding: 10px 0; border-top: 1px solid var(--line); }
.loc:first-child { border-top: 0; padding-top: 0; }
.loc summary { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; cursor: pointer; }
.loc ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.loc li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; font-size: .9rem; }

/* ---------- customize sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 8, 6, .45); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s;
}
.sheet.is-open { opacity: 1; visibility: visible; transition: opacity .2s; }
.sheet__panel {
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .3); transform: translateY(24px); transition: transform .25s;
}
.sheet.is-open .sheet__panel { transform: none; }
@media (min-width: 760px) { .sheet { align-items: center; } .sheet__panel { border-radius: 22px; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 18px; color: #fff; background: linear-gradient(180deg, var(--red), var(--red-2)); }
.sheet__head h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 1.1rem; }
.sheet__head h2::before { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: radial-gradient(circle at 32% 30%, #e6f8ff 0 14%, #74cbff 26%, #1d8fe6 60%, #0b4f93); }
.sheet__body { overflow: auto; padding: 4px 18px 24px; overscroll-behavior: contain; }
.sheet__body section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.sheet__body section:last-child { border-bottom: 0; }
.hint { margin: -4px 0 10px; font-size: .85rem; color: var(--muted); }
.opt { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; padding: 6px 0; }
.opt > span { font-weight: 600; }
.layout-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.layout-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 12px; background: var(--surface-2); }
.layout-list label { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.layout-list input { width: 20px; height: 20px; accent-color: var(--red); }
.row-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }
.row-btn:disabled { opacity: .35; cursor: default; }
.text-btn, .link-btn { padding: 8px 0; border: 0; background: none; color: var(--link); font-weight: 700; cursor: pointer; }
body.sheet-open { overflow: hidden; }

/* ---------- index page ---------- */
.intro { padding: 24px 0 4px; }
.intro h1 { margin: 0; font-size: clamp(1.9rem, 6vw, 2.7rem); font-weight: 800; letter-spacing: -.02em; }
.intro p { max-width: 62ch; margin: 6px 0 0; color: var(--muted); }
.top { margin: 20px 0 4px; }
.top__head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; }
.top__head h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.top__head .muted { font-size: .85rem; }
.top__list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin: 10px 0 0; padding: 4px 0 10px; }
.top__list a { position: relative; display: flex; flex-direction: column; align-items: center; height: 100%; padding: 12px 6px 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
@media (max-width: 520px) {
  .top__list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .top__list a { padding: 10px 2px 8px; border-radius: 12px; }
  .top__list img { width: 48px; height: 48px; }
  .top__name { font-size: .72rem; }
  .top__pct { font-size: .7rem; }
  .top__rank { top: 4px; left: 6px; font-size: .58rem; }
}
.top__rank { position: absolute; top: 6px; left: 9px; font-family: var(--pixel); font-size: .7rem; color: var(--red); }
.top__list img { width: 64px; height: 64px; image-rendering: pixelated; }
.top__name { font-weight: 700; font-size: .84rem; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.top__pct { font-size: .78rem; font-weight: 600; color: var(--muted); }

.list-tools { display: grid; gap: 10px; margin: 18px 0 10px; min-width: 0; }
.list-tools__row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-tools__row--split { justify-content: space-between; flex-wrap: wrap; }
.list-tools__selects { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }

/* Ad units (only present once AdSense is set up in render.py); the space is kept so nothing jumps */
.ad { margin: 16px 0; min-height: 132px; padding: 8px; border-radius: 14px; border: 1px dashed var(--line); text-align: center; }
.ad__label { display: block; margin-bottom: 4px; font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
@media (max-width: 520px) {
  .chip-row--types { gap: 6px; }
  .chip-row--types .type-chip { padding: 4px 9px; font-size: .76rem; }
  .list-tools .chip { padding: 5px 10px; font-size: .8rem; }
}
.type-chip {
  flex: none; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .82rem; cursor: pointer; color: var(--text);
  background: color-mix(in srgb, var(--tc) 14%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--tc) 45%, transparent);
}
.type-chip[aria-pressed="true"] { background: var(--tc); color: var(--tt, #fff); border-color: transparent; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.list-meta { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; color: var(--muted); font-size: .9rem; font-weight: 600; }

.mon-list { list-style: none; margin: 0 0 40px; padding: 0; }
.mon a { color: var(--text); text-decoration: none; }
.mon__num { font-family: var(--pixel); font-size: .66rem; color: var(--muted); }
.mon__name { font-weight: 700; overflow-wrap: anywhere; }
.mon__img { display: grid; place-items: center; }
.mon__img img { width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated; }
.mon__stats { display: none; }
.mon-list[data-view="grid"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 440px) {
  .mon-list[data-view="grid"] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .mon-list[data-view="grid"] a { padding: 6px 6px 8px; border-radius: 14px; }
  .mon-list[data-view="grid"] .mon__img { aspect-ratio: 1; margin-bottom: 4px; border-radius: 10px; }
  .mon-list[data-view="grid"] .mon__img img { width: 72px; height: 72px; }
  .mon-list[data-view="grid"] .mon__name { font-size: .8rem; line-height: 1.2; }
  .mon-list[data-view="grid"] .mon__num { font-size: .56rem; }
  .mon-list[data-view="grid"] .types { gap: 3px; }
  .mon-list[data-view="grid"] .type--sm { padding: 0 5px; font-size: .6rem; }
}
.mon-list[data-view="grid"] a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; padding: 10px 10px 12px; text-align: center;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.mon-list[data-view="grid"] a:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(40, 25, 10, .14); }
.mon-list[data-view="grid"] .mon__img {
  width: 100%; aspect-ratio: 5 / 4; margin-bottom: 6px; border-radius: 12px; background-color: var(--lcd);
  background-image: linear-gradient(var(--lcd-grid) 1px, transparent 1px), linear-gradient(90deg, var(--lcd-grid) 1px, transparent 1px); background-size: 12px 12px;
}
.mon-list[data-view="grid"] .types { justify-content: center; margin-top: 4px; }
.mon-list[data-view="list"], .mon-list[data-view="stats"] { display: grid; gap: 6px; }
.mon-list[data-view="list"] a {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "img num meta" "img name types"; align-items: center; gap: 2px 12px;
  padding: 6px 12px 6px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.mon__meta { display: none; }
.mon-list[data-view="list"] .mon__meta { grid-area: meta; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.tier-badge { padding: 1px 7px; border-radius: 6px; background: var(--chip); font-size: .7rem; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.mon__bst { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.mon__bst b { color: var(--text); font-variant-numeric: tabular-nums; }
/* Big renders scale smoothly; pixel sprites stay crisp */
.mon-list[data-sprites="home"] .mon__img img, .mon-list[data-sprites="home-anim"] .mon__img img,
.mon-list[data-sprites="art"] .mon__img img { image-rendering: auto; object-fit: contain; }
/* Only rows near the screen are laid out, so the long list opens quickly */
.mon-list > li { content-visibility: auto; contain-intrinsic-size: auto 70px; }
.mon-list[data-view="grid"] > li { contain-intrinsic-size: auto 190px; }
.mon-list[data-view="list"] .mon__img { grid-area: img; }
.mon-list[data-view="list"] .mon__img img, .mon-list[data-view="stats"] .mon__img img { width: 56px; height: 56px; }
.mon-list[data-view="list"] .mon__num { grid-area: num; align-self: end; }
.mon-list[data-view="list"] .mon__name { grid-area: name; align-self: start; }
.mon-list[data-view="list"] .types { grid-area: types; justify-content: flex-end; }
.mon-list[data-view="stats"] a {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-areas: "img name" "img stats"; align-items: center; column-gap: 10px;
  padding: 6px 10px 8px 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.mon-list[data-view="stats"] .mon__img { grid-area: img; }
.mon-list[data-view="stats"] .mon__img img { width: 44px; height: 44px; }
.mon-list[data-view="stats"] .mon__num, .mon-list[data-view="stats"] .types { display: none; }
.mon-list[data-view="stats"] .mon__name { grid-area: name; font-size: .92rem; }
.mon-list[data-view="stats"] .mon__stats { grid-area: stats; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ms { padding: 1px 0; border-radius: 6px; text-align: center; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--c, var(--s3)) 24%, transparent); }
.ms--bst { background: var(--chip); }
.list-head { display: none; }
.list-page:has(.mon-list[data-view="stats"]) .list-head {
  position: sticky; top: calc(var(--header-h) - var(--lip)); z-index: 30; display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 10px;
  padding: calc(var(--lip) + 6px) 10px 6px 4px; margin: 0 -2px 6px; background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.list-head > span:first-child { overflow: hidden; color: transparent; }
.list-head__stats { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.list-head__stats button { padding: 2px 0; border: 0; border-radius: 6px; background: none; font-size: .7rem; font-weight: 800; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.list-head__stats button.is-active { background: var(--chip-on); color: var(--chip-on-ink); }
@media (min-width: 760px) {
  .mon-list[data-view="stats"] a { grid-template-columns: 44px 220px minmax(0, 1fr); grid-template-areas: "img name stats"; }
  .list-page:has(.mon-list[data-view="stats"]) .list-head { grid-template-columns: 44px 220px minmax(0, 1fr); }
  .list-head > span:first-child { grid-column: span 2; color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
}

/* ---------- footer ---------- */
.site-foot { padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.site-foot p { max-width: 80ch; margin: 0 0 8px; }

/* ---------- compact density ---------- */
html[data-density="compact"] body { font-size: 15px; }
html[data-density="compact"] .sections { gap: 10px; }
html[data-density="compact"] .card__head { padding: 10px 12px 0; }
html[data-density="compact"] .card__body { padding: 10px 12px 12px; }
html[data-density="compact"] .card.is-collapsed .card__head { padding-bottom: 10px; }
html[data-density="compact"] .stats-bars { gap: 4px; }
html[data-density="compact"] .mv { padding: 6px 2px; }
html[data-density="compact"] .facts > div { padding: 8px 10px; }
html[data-density="compact"] .entries li, html[data-density="compact"] .abil-list li { padding: 9px 12px; }
html[data-density="compact"] .mon-list[data-view="grid"] { gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
