/* ============================================================================
   pokedex.css — the Pokédex modal (pairs with pokedex.js)
   A device-style shell: red lid with the lens up top, dark screen below.
   Load after shell.css.
   ============================================================================ */

/* Header button icon: a tiny Pokédex */
.dex-mini-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 20px;
  border-radius: 3px 3px 4px 4px;
  background: linear-gradient(#e03f30 0 42%, #19181d 42% 48%, #af2216 48%);
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.35);
}
.dex-mini-icon::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px #fff3;
}

html.dex-lock, html.dex-lock body { overflow: hidden; }

/* ── Overlay + shell ────────────────────────────────────────────────────── */
.dex-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: none;
  place-items: center;
  padding: 2vh 2vw;
  /* A plain dark backdrop, no blur: blurring the whole page behind the
     Pokédex had to be redone on every repaint and made scrolling heavy. */
  background: rgba(4, 4, 5, 0.86);
}
/* While scrolling (pokedex.js), decorative loops pause; see the scroll handler. */
.dex-overlay.dx-scrolling *,
.dex-overlay.dx-scrolling *::before,
.dex-overlay.dx-scrolling *::after { animation-play-state: paused !important; }
.dex-overlay.open { display: grid; animation: dex-fade 200ms ease both; }
@keyframes dex-fade { from { opacity: 0; } }

.dex-shell {
  --dex-red: #c62719;
  --dex-red-2: #7a180f;
  --dex-screen: #0e0d10;
  --dex-line: rgba(237, 121, 110, 0.16);
  --dex-soft: #9f9cab;

  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 96vw);
  height: min(900px, 94vh);
  border-radius: 24px;
  overflow: hidden;
  background: var(--dex-screen);
  border: 1px solid rgba(237, 121, 110, 0.35);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.75), 0 0 0 6px rgba(198, 39, 25, 0.12);
  color: var(--ink, #e5ddd3);
  animation: dex-pop 340ms cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes dex-pop { from { opacity: 0; transform: translateY(18px) scale(0.96); } }

:where(.dex-shell) button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dex-shell button:focus-visible,
.dex-shell input:focus-visible,
.dex-shell select:focus-visible { outline: 2px solid #f4ada7; outline-offset: 2px; }

/* ── Lid ────────────────────────────────────────────────────────────────── */
.dex-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem 1rem;
  background:
    var(--dex-red);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35);
}
/* The hinge seam between lid and screen */
.dex-top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 6px;
  background: repeating-linear-gradient(90deg, #17161b 0 18px, #212027 18px 20px);
}

.dex-lens { display: flex; align-items: flex-start; gap: 0.45rem; flex: none; }
.dex-lens-glass {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 4px #f2efea, 0 0 0 6px rgba(0, 0, 0, 0.35);
}
/* The breathing glow is a separate layer that only fades in and out
   (opacity is cheap; animating box-shadow repainted the header every frame). */
.dex-lens-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: none;
  opacity: 0;
  animation: lens-breathe 3.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes lens-breathe { 50% { opacity: 1; } }
.dex-led {
  width: 11px;
  height: 11px;
  margin-top: 2px;
  border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 0 0 1.5px rgba(0, 0, 0, 0.35);
}
.dex-led.r { background: #eb6c61; animation: led 2.4s steps(1) infinite; }
.dex-led.y { background: #ffd23f; animation: led 2.4s steps(1) 0.8s infinite; }
.dex-led.g { background: #5bc892; animation: led 2.4s steps(1) 1.6s infinite; }
@keyframes led { 0%, 70% { opacity: 1; } 71%, 100% { opacity: 0.45; } }

.dex-heading { min-width: 0; }
.dex-heading h2 {
  margin: 0;
  font-family: var(--pixel-font);
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  letter-spacing: 0.06em;
  color: #ffffff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.dex-heading p {
  margin: 0.2rem 0 0;
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(246, 243, 239, 0.75);
}
.dex-x {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: background 140ms ease, transform 140ms ease;
}
.dex-x:hover { background: rgba(0, 0, 0, 0.4); transform: rotate(90deg); }

/* ── Screen: list + detail side by side ─────────────────────────────────── */
.dex-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  min-height: 0;
  transition: grid-template-columns 320ms cubic-bezier(.3, .9, .3, 1);
}
.dex-layout.detail-open { grid-template-columns: minmax(0, 1fr) 420px; }
/* Less room while the detail panel is open: stats wrap to three across. */
.dex-layout.detail-open .dx-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.dex-main {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  padding: 1.2rem 1.2rem 1.6rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(237, 121, 110, 0.35) transparent;
}

/* ── Stats ──────────────────────────────────────────────────────────────── */
.dx-stats {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.dx-stat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--dex-line);
  background: rgba(255, 255, 255, 0.025);
  animation: dx-rise 380ms ease both;
}
.dx-stat:nth-child(2) { animation-delay: 60ms; }
.dx-stat:nth-child(3) { animation-delay: 120ms; }
.dx-stat:nth-child(4) { animation-delay: 180ms; }
.dx-stat[hidden] { display: none; }
@keyframes dx-rise { from { opacity: 0; transform: translateY(8px); } }

.dx-stat-text { display: grid; gap: 0.2rem; min-width: 0; }
.dx-stat-text strong {
  font-family: var(--pixel-font);
  font-size: 0.95rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-stat-text strong small { font-size: 0.7rem; color: var(--dex-soft); }
.dx-stat-text > span {
  font-family: var(--pixel-font);
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dex-soft);
}
.dx-stat-icon { font-size: 1.4rem; flex: none; }
.dx-stat-streak.hot .dx-stat-icon { animation: flame 1.1s ease-in-out infinite; }
@keyframes flame { 50% { transform: scale(1.15) rotate(-6deg); filter: none; } }

.dx-stat-ring { padding-left: 0.6rem; }
.dx-stat-ring svg { flex: none; width: 64px; height: 64px; transform: rotate(-90deg); }
.dx-ring-track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 8; }
.dx-ring-fill {
  fill: none;
  stroke: url(#dexRingGrad);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1100ms cubic-bezier(.2, .8, .2, 1);
  filter: none;
}
.dx-ring-pct {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  width: 64px;
  transform: translateY(-50%);
  text-align: center;
  font-family: var(--pixel-font);
  font-size: 0.72rem;
  color: #ffffff;
}
.dx-stat-ring strong { font-size: 1.15rem; }

.dx-mini-track {
  display: block;
  height: 4px;
  margin-top: 0.15rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.dx-mini-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #f59e0b;
  transition: width 900ms cubic-bezier(.2, .8, .2, 1) 200ms;
}

.dx-stat-latest { cursor: pointer; transition: border-color 140ms ease, background 140ms ease; }
.dx-stat-latest:hover { border-color: rgba(237, 121, 110, 0.5); background: rgba(237, 121, 110, 0.06); }
.dx-stat-latest img {
  flex: none;
  width: 52px;
  height: 52px;
  margin: -0.4rem 0;
  image-rendering: pixelated;
  animation: hop 2.6s ease-in-out infinite;
}
@keyframes hop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-6px); } 90% { transform: translateY(0); } }

/* ── Banner (new catches / milestones) ──────────────────────────────────── */
.dx-banner {
  position: relative;
  display: flex;
  justify-content: center;
  margin: -0.2rem 0 0.9rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-family: var(--pixel-font);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: #ffffff;
  background: rgba(224, 63, 48, 0.25);
  border: 1px solid rgba(237, 121, 110, 0.5);
  animation: dx-banner 420ms cubic-bezier(.2, .7, .3, 1) both;
}
.dx-banner.new { background: rgba(75, 181, 171, 0.2); border-color: rgba(75, 181, 171, 0.55); }
.dx-banner[hidden] { display: none; }
@keyframes dx-banner { from { opacity: 0; transform: scale(0.9); } }
.dx-confetti {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti 1300ms cubic-bezier(.15, .8, .3, 1) var(--d) both;
}
@keyframes confetti {
  0% { transform: translate(-50%, -50%) rotate(0); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y) + 120px)) rotate(var(--r)); opacity: 0; }
}

/* ── Type strip ─────────────────────────────────────────────────────────── */
.dx-types {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.dx-type {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0 0.4rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--tc) 40%, transparent);
  background: rgba(255, 255, 255, 0.02);
  color: #ffffff;
  animation: dx-rise 320ms ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.dx-type:hover { transform: translateY(-2px); border-color: var(--tc); }
/* Fill rises with how much of that type you've caught. */
.dx-type-fill {
  position: absolute;
  inset: auto 0 0 0;
  height: var(--f);
  background: linear-gradient(0deg, color-mix(in srgb, var(--tc) 45%, transparent), color-mix(in srgb, var(--tc) 18%, transparent));
  transition: height 700ms ease;
}
.dx-type-icon, .dx-type-name { position: relative; }
.dx-type-icon { font-size: 0.9rem; }
.dx-type-name {
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-type.on {
  border-color: var(--tc);
  background: color-mix(in srgb, var(--tc) 28%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tc) 50%, transparent);
}
.dx-type.full::after {
  content: "★";
  position: absolute;
  top: 1px;
  right: 4px;
  font-size: 0.55rem;
  color: #ffd23f;
}

/* ── Tabs + toolbar ─────────────────────────────────────────────────────── */
.dx-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.dx-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--dex-line);
}
.dx-tabs button {
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  font-family: var(--pixel-font);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dex-soft);
  transition: background 160ms ease, color 160ms ease;
}
.dx-tabs button[aria-selected="true"] {
  color: #ffffff;
  background: var(--dex-red);
  box-shadow: none;
}
.dx-showing {
  font-family: var(--pixel-font);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dex-soft);
}
.dex-main:not([data-view="dex"]) .dx-showing { visibility: hidden; }

.dx-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.dex-main[data-view="progress"] .dx-toolbar { display: none; }
.dex-main[data-view="log"] .dx-seg { display: none; }

.dx-search {
  flex: 1 1 14rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0 0.8rem;
  border-radius: 11px;
  border: 1px solid var(--dex-line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--dex-soft);
}
.dx-search:focus-within { border-color: rgba(237, 121, 110, 0.6); }
.dx-search input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 0.86rem;
}
.dx-search input::placeholder { color: rgba(159, 156, 171, 0.75); }

.dx-seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--dex-line);
  background: rgba(0, 0, 0, 0.35);
}
.dx-seg button {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  min-height: 34px;
  border-radius: 8px;
  font-family: var(--pixel-font);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dex-soft);
}
.dx-seg button[aria-pressed="true"] { color: #ffffff; background: rgba(237, 121, 110, 0.22); box-shadow: inset 0 0 0 1px rgba(237, 121, 110, 0.55); }

.dx-select {
  min-height: 42px;
  padding: 0 2rem 0 0.8rem;
  border-radius: 11px;
  border: 1px solid var(--dex-line);
  background: rgba(0, 0, 0, 0.35)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%23b394ad'/></svg>") no-repeat right 0.75rem center;
  color: #ffffff;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  appearance: none;
}

/* ── Dex grid ───────────────────────────────────────────────────────────── */
/* Virtual grid: pokedex.js sets --cols/--cw and the total height, and only
   puts the visible rows in the page. Card height is fixed so rows line up
   with that math. */
.dx-grid {
  --card-min: 112px;
  --card-h: 142px;
  --gap: 9px;
  box-sizing: border-box;
  position: relative;
  display: block;
  /* What happens inside the grid never re-lays-out the page around it. */
  contain: layout style;
}
/* Each card sits at its own slot (pokedex.js sets left/top/width), so
   cards entering or leaving the screen never move the others. */
.dx-grid > .dx-card {
  position: absolute;
  width: var(--cw, 120px);
  height: var(--card-h);
  contain: layout paint style;
}
/* Loading skeleton: a plain grid until the real cards arrive. */
.dx-grid.is-skel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  grid-auto-rows: var(--card-h);
  gap: var(--gap);
}
.dx-grid.is-skel > .dx-card { position: relative; width: auto; }
.dx-grid[hidden] { display: none; }

.dx-card {
  --t1: #565362;
  --t2: #565362;
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.2rem;
  padding: 0.5rem 0.4rem 0.6rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  height: 100%;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.dx-card[hidden] { display: none; }
.dx-card.enter { animation: dx-rise 340ms ease both; animation-delay: calc(var(--i, 0) * 16ms); }

.dx-num {
  justify-self: start;
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  color: rgba(159, 156, 171, 0.7);
}
.dx-art {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-top: -0.2rem;
  border-radius: 50%;
}
.dx-art img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 220ms cubic-bezier(.2, .7, .3, 1), filter 300ms ease;
}
.dx-name {
  max-width: 100%;
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-dots { display: flex; gap: 4px; }
.dx-dots i { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }

/* Caught: tinted by its types, with a soft glow under the sprite */
.dx-card.caught {
  border-color: color-mix(in srgb, var(--t1) 35%, transparent);
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--t1) 10%, transparent), color-mix(in srgb, var(--t2) 8%, transparent));
}
.dx-card.caught .dx-name { color: #ffffff; }
.dx-card.caught .dx-num { color: color-mix(in srgb, var(--t1) 60%, #ffffff); }
.dx-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--t1) 70%, transparent); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45); }
.dx-card.caught:hover .dx-art img { transform: translateY(-4px) scale(1.08); }
.dx-card.selected { border-color: #ed796e; box-shadow: 0 0 0 2px rgba(237, 121, 110, 0.6); }

/* Missing: a silhouette that hints at the shape without spoiling it */
.dx-card.missing .dx-art img { filter: brightness(0) opacity(0.5); }
.dx-card.missing .dx-name { color: rgba(159, 156, 171, 0.55); letter-spacing: 0.2em; }
.dx-card.missing:hover .dx-art img { filter: brightness(0) opacity(0.75) drop-shadow(0 0 6px color-mix(in srgb, var(--t1) 70%, transparent)); }

.dx-card.recent::before {
  content: "NEW";
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 5px;
  border-radius: 5px;
  font-family: var(--pixel-font);
  font-size: 0.45rem;
  letter-spacing: 0.06em;
  color: #2a1400;
  background: #ffd23f;
  box-shadow: none;
}
.dx-card.rare::after {
  content: "✦";
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.7rem;
  color: #ffd23f;
  text-shadow: none;
}
/* Shiny shimmer: a warm glow behind the sprite that fades in and out
   (opacity only, so scrolling past shinies stays cheap). */
.dx-card.shiny .dx-art { position: relative; }
.dx-card.shiny .dx-art::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: transparent;
  opacity: 0.25;
  animation: shiny 3s ease-in-out infinite;
  pointer-events: none;
}
.dx-card.shiny .dx-art img { position: relative; }
@keyframes shiny { 50% { opacity: 1; } }

/* Reveal: a just-registered entry flips from silhouette to full colour */
.dx-card.reveal { animation: reveal-card 900ms cubic-bezier(.2, .7, .3, 1) both; }
.dx-card.reveal .dx-art img { animation: reveal-img 900ms ease both; }
.dx-card.fresh { border-color: rgba(75, 181, 171, 0.7); box-shadow: 0 0 0 1px rgba(75, 181, 171, 0.5); }
@keyframes reveal-card {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7); }
  100% { transform: scale(1); }
}
@keyframes reveal-img {
  0%, 30% { filter: brightness(0) opacity(0.5); }
  45% { filter: brightness(3) saturate(0); }
  100% { filter: none; }
}

/* Skeleton while the first load is in flight */
.dx-skel {
  min-height: 0;
  background: rgba(255, 255, 255, 0.03);
  background-size: 300% 100%;
  animation: skel 1.3s linear infinite;
  animation-delay: calc(var(--i, 0) * 30ms);
}
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.dx-empty {
  margin: 2rem auto;
  max-width: 34ch;
  text-align: center;
  font-family: var(--pixel-font);
  font-size: 0.66rem;
  line-height: 1.7;
  color: var(--dex-soft);
}
.dx-empty[hidden] { display: none; }

/* ── Catch log ──────────────────────────────────────────────────────────── */
.dx-log { display: grid; gap: 1rem; }
.dx-log[hidden] { display: none; }
.dx-day { animation: dx-rise 340ms ease both; animation-delay: calc(var(--i, 0) * 50ms); }
.dx-day h3 {
  position: sticky;
  top: -1.2rem;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.2rem;
  background: linear-gradient(var(--dex-screen) 75%, transparent);
  font-family: var(--pixel-font);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
}
.dx-day-count { font-size: 0.55rem; color: var(--dex-soft); }
.dx-day-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.45rem; }
.dx-logrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem 0.4rem 0.4rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--t1) 30%, transparent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--t1) 16%, transparent), transparent 70%);
  transition: transform 140ms ease, border-color 140ms ease;
}
.dx-logrow:hover { transform: translateX(3px); border-color: var(--t1); }
.dx-logrow img { width: 48px; height: 48px; flex: none; image-rendering: pixelated; }
.dx-logmain { display: grid; gap: 0.2rem; min-width: 0; }
.dx-logname {
  font-family: var(--pixel-font);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
}
.dx-logrules {
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dex-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Progress ───────────────────────────────────────────────────────────── */
.dx-progress {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.dx-progress[hidden] { display: none; }
.dx-pcard {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--dex-line);
  background: rgba(255, 255, 255, 0.02);
  animation: dx-rise 360ms ease both;
}
.dx-pcard:nth-child(2) { animation-delay: 70ms; }
.dx-pcard:nth-child(3) { animation-delay: 140ms; }
.dx-pcard-wide { grid-column: 1 / -1; }
.dx-pcard h3 {
  margin: 0 0 0.7rem;
  font-family: var(--pixel-font);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
}
.dx-bar-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.2rem; }
.dx-bar {
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
}
.dx-bar-label {
  font-family: var(--pixel-font);
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #e5ddd3;
  white-space: nowrap;
}
.dx-bar-icon { opacity: 0.85; }
.dx-bar-track { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.dx-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--bc);
  box-shadow: none;
  transition: width 900ms cubic-bezier(.2, .8, .2, 1);
}
.dx-progress.grow .dx-bar-fill { width: max(var(--w), 0%); }
.dx-bar-num { font-family: var(--pixel-font); font-size: 0.56rem; color: #ffffff; white-space: nowrap; }
.dx-bar-num small { color: var(--dex-soft); }
.dx-bar.full .dx-bar-num::after { content: " ★"; color: #ffd23f; }
.dx-shiny-note { margin: 0.6rem 0 0; font-family: var(--pixel-font); font-size: 0.58rem; color: #ffe9a8; }

/* ── Detail panel ───────────────────────────────────────────────────────── */
.dex-detail {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border-left: 1px solid var(--dex-line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), #0b0a0d;
  scrollbar-width: thin;
}
.dex-layout:not(.detail-open) .dex-detail { visibility: hidden; transition: visibility 0s 320ms; }
#dexDetailInner { width: 420px; max-width: 100%; }

.dx-hero {
  --t1: #cc3022;
  --t2: #db9824;
  position: relative;
  display: grid;
  justify-items: center;
  padding: 0.9rem 1.2rem 1.1rem;
  text-align: center;
  background: transparent;
  animation: dx-rise 300ms ease both;
}
.dx-dnav { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 0.4rem; }
.dx-back, .dx-dnav-step button {
  min-height: 34px;
  padding: 0 0.75rem;
  border-radius: 9px;
  font-family: var(--pixel-font);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
}
.dx-dnav-step { display: inline-flex; gap: 0.35rem; }
.dx-dnav-step button { width: 34px; justify-content: center; padding: 0; font-size: 1rem; }
.dx-back:hover, .dx-dnav-step button:hover { background: rgba(237, 121, 110, 0.25); }

.dx-stage { position: relative; display: grid; place-items: center; width: 190px; height: 170px; }
.dx-stage-ring {
  position: absolute;
  bottom: 14px;
  width: 150px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--t1) 35%, transparent);
  animation: stage 2.8s ease-in-out infinite;
}
@keyframes stage { 50% { transform: scale(0.88); opacity: 0.7; } }
.dx-hero-img {
  position: relative;
  width: 168px;
  height: 168px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55));
  animation: float 2.8s ease-in-out infinite, pop-in 420ms cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.6); } }
.dx-hero.shiny .dx-hero-img { filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55)); }
.dx-hero.mystery .dx-hero-img { filter: brightness(0) opacity(0.6) drop-shadow(0 0 14px color-mix(in srgb, var(--t1) 70%, transparent)); animation: float 2.8s ease-in-out infinite; }

.dx-hero-num { margin: 0.2rem 0 0; font-family: var(--pixel-font); font-size: 0.66rem; letter-spacing: 0.1em; color: color-mix(in srgb, var(--t1) 55%, #ffffff); }
.dx-hero-name {
  margin: 0.25rem 0 0.6rem;
  font-family: var(--pixel-font);
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  overflow-wrap: anywhere;
}
.dx-hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; }
.dx-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-family: var(--pixel-font);
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e5ddd3;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.dx-tag.type { font-weight: 700; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
.dx-tag.gold { color: #ffd23f; box-shadow: inset 0 0 0 1px rgba(255, 210, 63, 0.5); }
.dx-tag.myth { color: #f4e0be; box-shadow: inset 0 0 0 1px rgba(237, 204, 147, 0.5); }
.dx-tag.shiny { color: #fff1b8; box-shadow: inset 0 0 0 1px rgba(255, 241, 184, 0.5); }
.dx-hero-caught {
  margin: 0.8rem 0 0;
  font-family: var(--pixel-font);
  font-size: 0.56rem;
  line-height: 1.8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dex-soft);
}
.dx-how { color: #ffffff; }
.dx-mystery-copy { margin: 0.9rem 0 0; max-width: 30ch; font-size: 0.8rem; line-height: 1.55; color: var(--dex-soft); }
.dx-detail-loading { display: flex; gap: 6px; margin-top: 1rem; }
.dx-detail-loading i { width: 8px; height: 8px; border-radius: 50%; background: #ed796e; animation: dots 900ms ease-in-out infinite; }
.dx-detail-loading i:nth-child(2) { animation-delay: 150ms; }
.dx-detail-loading i:nth-child(3) { animation-delay: 300ms; }
@keyframes dots { 50% { transform: translateY(-6px); opacity: 0.5; } }
.dx-detail-err { padding: 0 1.2rem; font-size: 0.8rem; color: #f5b6b0; }

.dx-sec { --sc: #ed796e; padding: 0.9rem 1.2rem; border-top: 1px solid var(--dex-line); animation: dx-rise 320ms ease both; }
.dx-sec.abilities { --sc: #4bb5ab; animation-delay: 60ms; }
.dx-sec.moves { --sc: #f59e0b; animation-delay: 120ms; }
.dx-sec header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.45rem; }
.dx-sec h4 { margin: 0; font-family: var(--pixel-font); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--sc); }
.dx-sec-count { font-family: var(--pixel-font); font-size: 0.52rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dex-soft); }
.dx-sec-bar { display: block; height: 4px; margin-bottom: 0.7rem; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.dx-sec-bar span { display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--sc); box-shadow: none; animation: grow-w 800ms cubic-bezier(.2, .8, .2, 1) both; }
@keyframes grow-w { from { width: 0; } }
.dx-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.dx-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  font-family: var(--pixel-font);
  font-size: 0.55rem;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  animation: dx-rise 260ms ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.dx-chip.on {
  color: #ffffff;
  background: color-mix(in srgb, var(--sc) 22%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sc) 70%, transparent);
}
.dx-chip.locked { color: var(--dex-soft); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.02); }
.dx-chip.info { color: var(--dex-soft); background: rgba(255, 255, 255, 0.04); }
.dx-lock { font-size: 0.6rem; filter: grayscale(0.4); }
.dx-blur { filter: blur(4px); user-select: none; }
.dx-more {
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  font-family: var(--pixel-font);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sc);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sc) 45%, transparent);
}
.dx-more:hover { background: color-mix(in srgb, var(--sc) 14%, transparent); }
.dx-none { font-size: 0.75rem; color: var(--dex-soft); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Tablet ─────────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .dx-stats { grid-template-columns: 1fr 1fr; }
  .dex-layout.detail-open { grid-template-columns: minmax(0, 1fr) 360px; }
  #dexDetailInner { width: 360px; }
  .dx-bar-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Shinies ────────────────────────────────────────────────────────────── */
.dx-stat-shiny { cursor: pointer; border-color: rgba(255, 217, 90, 0.3); background: rgba(255, 217, 90, 0.08); }
.dx-stat-shiny .charm-gem { width: 34px; height: 34px; }
.dx-stat-shiny strong { color: #ffe9a8; }
.dx-stat-shiny:hover { border-color: rgba(255, 217, 90, 0.6); }

/* A shiny you found in an earlier run: still a silhouette this run, with a mark. */
.dx-card.shiny-kept::after {
  content: "✨";
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 0.7rem;
  filter: none;
}
/* Caught shinies in the grid: gold edge and twinkle (replaces the old glow) */
.dx-card.caught.shiny {
  border-color: rgba(255, 217, 90, 0.65);
  background:
    rgba(243, 163, 155, 0.12);
}
.dx-card.caught.shiny .dx-name { color: #ffe9a8; }
.dx-card.caught.shiny .dx-num::after { content: " ✨"; }

.dx-sealbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: -0.2rem 0 0.9rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 217, 90, 0.55);
  background: rgba(255, 217, 90, 0.16);
  font-family: var(--pixel-font);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  color: #fff3c4;
}
.dx-sealbar[hidden] { display: none; }
.dx-sealbar button, .dx-seal-btn {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2a1400;
  background: #ffe27a;
  box-shadow: none;
}

.dx-shinycard { border-color: rgba(255, 217, 90, 0.35); background: rgba(255, 217, 90, 0.07); }
.dx-shiny-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.9rem; }
.dx-shiny-head h3 { margin: 0 0 0.3rem; }
.charm-gem.big { width: 64px; height: 64px; }
.dx-odds { margin: 0; font-family: var(--pixel-font); font-size: 0.7rem; color: #e5ddd3; }
.dx-odds b { font-size: 1.15rem; color: #ffe9a8; }
.dx-odds small { display: block; margin-top: 0.25rem; font-size: 0.5rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dex-soft); }
.dx-shiny-count { margin-left: auto; display: grid; justify-items: end; font-family: var(--pixel-font); }
.dx-shiny-count b { font-size: 1.4rem; color: #ffffff; }
.dx-shiny-count small { font-size: 0.5rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dex-soft); }
.dx-rolls { display: grid; gap: 0.35rem; margin: 0 0 0.8rem; padding: 0; list-style: none; }
.dx-rolls li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.8rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.dx-rolls span { font-family: var(--pixel-font); font-size: 0.58rem; letter-spacing: 0.05em; text-transform: uppercase; color: #ffffff; }
.dx-rolls b { font-family: var(--pixel-font); font-size: 0.7rem; color: #ffe9a8; text-align: right; }
.dx-rolls small { grid-column: 1 / -1; font-size: 0.72rem; color: var(--dex-soft); }
.dx-shiny-note2 { margin: 0 0 0.8rem; font-size: 0.74rem; line-height: 1.5; color: var(--dex-soft); }
.dx-seal-btn { display: block; width: 100%; text-align: center; min-height: 44px; line-height: 44px; padding: 0; margin-bottom: 0.8rem; }
.dx-history { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.dx-history li { display: flex; align-items: center; gap: 0.6rem; font-family: var(--pixel-font); font-size: 0.56rem; text-transform: uppercase; color: #ffffff; }
.dx-history .charm-gem { width: 22px; height: 22px; }
.dx-history small { margin-left: auto; color: var(--dex-soft); }

/* Shiny/normal flip in the detail panel */
.dx-shiny-flip {
  position: absolute;
  top: 6px;
  right: -8px;
  z-index: 2;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e5ddd3;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.dx-shiny-flip.on { color: #2a1400; background: #ffe27a; box-shadow: none; }
.dx-hero-img.swap { animation: swap 420ms cubic-bezier(.2, .7, .3, 1); }
@keyframes swap { 0% { transform: scale(0.8); filter: brightness(2.5); } }

/* Seal confirmation */
.dx-confirm {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(6, 5, 7, 0.7);
  
  animation: dex-fade 180ms ease both;
}
.dx-confirm-card {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  width: min(92%, 24rem);
  padding: 1.4rem 1.2rem 1.2rem;
  border-radius: 18px;
  text-align: center;
  background: #121215;
  border: 1px solid rgba(255, 217, 90, 0.5);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
  animation: dex-pop 320ms cubic-bezier(.2, .7, .3, 1) both;
}
.dx-confirm-card .charm-gem.big { width: 72px; height: 72px; }
.dx-confirm-card.sealed .charm-gem { animation: gem-earn 800ms cubic-bezier(.2, .7, .3, 1) both; }
@keyframes gem-earn { 0% { transform: scale(0.4) rotate(-90deg); } 60% { transform: scale(1.4) rotate(20deg); filter: brightness(2); } 100% { transform: scale(1); } }
.dx-confirm-card h3 { margin: 0; font-family: var(--pixel-font); font-size: 0.9rem; color: #ffffff; }
.dx-confirm-card p { margin: 0; font-size: 0.82rem; line-height: 1.5; color: #e2dad0; }
.dx-confirm-card .dx-keep { font-size: 0.74rem; color: var(--dex-soft); }
.dx-confirm-actions { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.dx-confirm-actions button {
  min-height: 42px;
  padding: 0 1rem;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dx-cancel { color: #e5ddd3; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.dx-confirm-actions .dx-go { color: #2a1400; background: #ffe27a; box-shadow: none; }
.dx-confirm-err { color: #f5b6b0; font-size: 0.78rem; }

/* ── Phones: full-screen device, detail slides over the list ────────────── */
@media (max-width: 767px) {
  .dex-overlay { padding: 0; }
  .dex-shell {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    animation: dex-up 320ms cubic-bezier(.2, 1, .3, 1) both;
  }
  @keyframes dex-up { from { transform: translateY(30px); opacity: 0; } }
  .dex-top { padding: calc(0.7rem + env(safe-area-inset-top, 0px)) 0.9rem 0.8rem; gap: 0.7rem; }
  .dex-lens-glass { width: 38px; height: 38px; }
  .dex-led { width: 9px; height: 9px; }
  .dex-heading p { display: none; }

  .dex-layout, .dex-layout.detail-open { grid-template-columns: minmax(0, 1fr); }
  .dex-main { padding: 0.9rem 0.8rem calc(1.4rem + env(safe-area-inset-bottom, 0px)); }
  .dex-detail {
    position: absolute;
    inset: 0;
    z-index: 3;
    border-left: 0;
    transform: translateX(100%);
    transition: transform 300ms cubic-bezier(.3, .9, .3, 1), visibility 0s 300ms;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .dex-layout.detail-open .dex-detail { transform: none; visibility: visible; transition: transform 300ms cubic-bezier(.3, .9, .3, 1); }
  #dexDetailInner { width: auto; }

  .dx-stats { gap: 0.45rem; margin-bottom: 0.7rem; }
  .dx-stat { padding: 0.55rem 0.6rem; gap: 0.5rem; border-radius: 12px; }
  .dx-stat-ring { grid-column: 1 / -1; }
  .dx-stat-ring svg { width: 54px; height: 54px; }
  .dx-ring-pct { width: 54px; font-size: 0.62rem; }
  .dx-stat-icon { font-size: 1.15rem; }
  .dx-stat-text strong { font-size: 0.8rem; }
  .dx-stat-text > span { font-size: 0.46rem; }
  .dx-stat-latest { grid-column: 1 / -1; }
  .dx-stat-latest img { width: 40px; height: 40px; }

  /* Types become one swipeable row */
  .dx-types {
    display: flex;
    gap: 0.35rem;
    margin: 0 -0.8rem 0.8rem;
    padding: 0.1rem 0.8rem 0.3rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .dx-types::-webkit-scrollbar { display: none; }
  .dx-type { flex: none; min-height: 36px; padding: 0 0.6rem; scroll-snap-align: start; }

  .dx-bar-row { margin-bottom: 0.55rem; }
  .dx-tabs { flex: 1; }
  .dx-tabs button { flex: 1; text-align: center; padding: 0.55rem 0.3rem; font-size: 0.56rem; }
  .dx-showing { display: none; }
  .dx-toolbar { gap: 0.4rem; }
  .dx-search { flex-basis: 100%; }
  .dx-search input { font-size: 16px; }   /* stops iOS zooming into the field */
  .dx-seg { flex: 1; }
  .dx-select { flex: 1; }
  .dx-seg button { flex: 1; justify-content: center; padding: 0 0.2rem; font-size: 0.5rem; }
  .dx-stat-shiny { grid-column: auto; }
  .dx-stat-latest { grid-column: auto; }
  .dx-shiny-head { flex-wrap: wrap; }

  .dx-grid { --card-min: 92px; --card-h: 124px; --gap: 6px; }
  .dx-card { padding: 0.4rem 0.3rem 0.5rem; border-radius: 12px; }
  .dx-card:hover { transform: none; }
  .dx-art { width: 64px; height: 64px; }
  .dx-art img { width: 72px; height: 72px; }
  .dx-name { font-size: 0.5rem; }

  .dx-day-list { grid-template-columns: 1fr; }
  .dx-progress { grid-template-columns: 1fr; }
  .dx-bar-cols { grid-template-columns: 1fr; }
  .dx-bar { grid-template-columns: 5.6rem minmax(0, 1fr) auto; }
  .dx-day h3 { top: -0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .dex-shell, .dex-shell *, .dex-shell *::before, .dex-shell *::after {
    animation: none !important;
    transition: none !important;
  }
}