/* Hallmark · macrostructure: Workbench · tone: playful-game · anchor hue: crimson-amber
 * theme: custom (pokemon battle HUD) · paper: oklch(14% 0.03 250) · accent: oklch(58% 0.2 25)
 * fonts: Chakra Petch + IBM Plex Sans · nav: dock · enrichment: none
 */
:root {
  --paper: oklch(14% 0.025 250);
  --paper-2: oklch(18% 0.03 250);
  --paper-3: oklch(22% 0.035 250);
  --ink: oklch(96% 0.01 95);
  --ink-dim: oklch(78% 0.02 250);
  --ink-mute: oklch(62% 0.02 250);
  --line: oklch(40% 0.04 250 / 0.45);
  --accent: oklch(62% 0.22 25);
  --accent-2: oklch(78% 0.16 85);
  --good: oklch(72% 0.14 180);
  --bad: oklch(62% 0.2 20);
  --focus: oklch(78% 0.14 210);
  --font-display: "Chakra Petch", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px oklch(0% 0 0 / 0.35);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 160ms;

  --t-normal: #A8A878;
  --t-fighting: #C03028;
  --t-flying: #A890F0;
  --t-poison: #A040A0;
  --t-ground: #E0C068;
  --t-rock: #B8A038;
  --t-bug: #A8B820;
  --t-ghost: #705898;
  --t-steel: #B8B8D0;
  --t-fire: #F08030;
  --t-water: #6890F0;
  --t-grass: #78C850;
  --t-electric: #F8D030;
  --t-psychic: #F85888;
  --t-ice: #98D8D8;
  --t-dragon: #7038F8;
  --t-dark: #705848;
  --t-fairy: #EE99AC;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, oklch(35% 0.12 25 / 0.35), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, oklch(30% 0.1 250 / 0.4), transparent 55%),
    var(--paper);
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent-2); text-underline-offset: 2px; }
a:hover { color: var(--ink); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--accent); color: #fff; padding: var(--space-2) var(--space-3);
}
.skip:focus { left: var(--space-3); top: var(--space-3); }

.scanlines {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    oklch(0% 0 0 / 0.04) 2px,
    oklch(0% 0 0 / 0.04) 4px
  );
  opacity: 0.35;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: oklch(14% 0.025 250 / 0.88);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.brand {
  display: flex; align-items: center; gap: var(--space-3);
  text-decoration: none; color: inherit; min-width: 0;
}
.brand__orb {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background:
    linear-gradient(180deg, var(--accent) 49%, #f8f9fa 51%),
    #111;
  border: 2px solid oklch(90% 0.01 95);
  box-shadow: inset 0 0 0 6px #111, 0 0 0 1px oklch(0% 0 0 / 0.4);
  position: relative;
}
.brand__orb::after {
  content: "";
  position: absolute; inset: 11px;
  border-radius: 50%;
  background: #f8f9fa;
  border: 2px solid #111;
}
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__text strong {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__text em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar__nav { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }

.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out), background var(--dur), border-color var(--dur);
}
.btn:hover { background: var(--paper-3); border-color: oklch(55% 0.05 250); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn--ghost { background: transparent; }
.btn--accent {
  background: linear-gradient(135deg, var(--accent), oklch(55% 0.18 40));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px oklch(45% 0.18 25 / 0.35);
}
.btn--accent:hover { filter: brightness(1.08); }

main { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); }
.view[hidden] { display: none !important; }

.hero { margin-bottom: var(--space-6); max-width: 42rem; }
.eyebrow {
  margin: 0 0 var(--space-2);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 600;
}
.hero h1, .panel__head h2, .party-dock h2, .howto h2 {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 var(--space-3);
  line-height: 1.15;
}
.hero h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
.lede { margin: 0; color: var(--ink-dim); font-size: 1.05rem; max-width: 38rem; }

.panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
.panel--soft { margin-top: var(--space-5); background: oklch(16% 0.03 250 / 0.7); }
.panel__head { margin-bottom: var(--space-4); }
.panel__head p, .howto p { margin: 0; color: var(--ink-dim); }

.game-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
}
.game-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  text-align: left;
  width: 100%;
  min-height: 96px;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, oklch(24% 0.04 250), oklch(18% 0.03 250));
  color: inherit;
  cursor: pointer;
  transition: border-color var(--dur), transform var(--dur) var(--ease-out), box-shadow var(--dur);
}
.game-card:hover {
  border-color: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.25);
}
.game-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.game-card:disabled, .game-card[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none;
}
.game-card__gen {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.game-card__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
}

.howto__steps {
  margin: var(--space-3) 0;
  padding-left: 1.2rem;
  color: var(--ink-dim);
}
.howto__steps li { margin-bottom: var(--space-2); }
.fineprint { font-size: 0.8rem; color: var(--ink-mute); }

/* Planner layout */
.plan-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.party-dock {
  position: sticky;
  top: 72px;
  max-height: calc(100dvh - 88px);
  overflow: auto;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}
.party-dock__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.party-dock h2 { font-size: 1.25rem; margin: 0; }
.chip-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-3);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn[aria-pressed="true"] {
  background: oklch(35% 0.08 180 / 0.4);
  border-color: var(--good);
  color: var(--good);
}

.party {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.slot {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--space-3);
  align-items: center;
  min-height: 64px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: oklch(12% 0.02 250 / 0.5);
  transition: border-color var(--dur), background var(--dur);
}
.slot.is-filled {
  border-style: solid;
  border-color: oklch(45% 0.06 250);
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--slot-t1, var(--paper-3)) 35%, transparent), transparent 70%),
    var(--paper-3);
  cursor: pointer;
}
.slot.is-filled:hover { border-color: var(--accent-2); }
.slot.is-dim { filter: grayscale(0.85); opacity: 0.45; }
.slot__sprite {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: oklch(10% 0.02 250 / 0.6);
  border-radius: 10px;
}
.slot__sprite img { width: 48px; height: 48px; image-rendering: pixelated; object-fit: contain; }
.slot__meta { min-width: 0; }
.slot__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot__form { display: block; font-size: 0.72rem; color: var(--ink-mute); }
.slot__types { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.type-pill {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: #111;
  background: var(--t-normal);
}
.slot__empty-label { color: var(--ink-mute); font-size: 0.85rem; grid-column: 2 / -1; }
.slot__actions { display: flex; flex-direction: column; gap: 4px; }
.icon-btn {
  appearance: none;
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}
.icon-btn:hover { border-color: var(--accent-2); }
.icon-btn[hidden] { display: none !important; }

.analysis { border-top: 1px solid var(--line); padding-top: var(--space-3); }
.analysis[hidden] { display: none !important; }
.analysis__block { margin-bottom: var(--space-3); }
.analysis__block h3 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
}
.analysis__block h3 span {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--ink-mute);
  font-size: 0.75rem;
  margin-left: 0.4rem;
}
.tally-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.tally {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  background: oklch(12% 0.02 250 / 0.7);
  border: 1px solid transparent;
  font-size: 0.7rem;
}
.tally.is-warn { border-color: color-mix(in oklch, var(--bad) 60%, transparent); background: oklch(25% 0.08 20 / 0.25); }
.tally__name {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #111;
  border-radius: 4px;
  padding: 2px 4px;
  text-align: center;
  background: var(--t-normal);
}
.tally__marks { display: flex; gap: 2px; }
.mark {
  width: 14px; height: 16px;
  border-radius: 3px;
  background: oklch(30% 0.02 250);
  color: transparent;
  font-size: 0.55rem;
  font-weight: 700;
  display: grid; place-items: center;
  cursor: default;
}
.mark.is-pos { background: var(--good); color: #062; }
.mark.is-neg { background: var(--bad); color: #fff; }
.analysis__note { margin: 0; font-size: 0.72rem; color: var(--ink-mute); }

.dex-pane {
  min-width: 0;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}
.filters { display: grid; gap: var(--space-3); margin-bottom: var(--space-4); }
.search input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}
.search input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-row--meta { gap: var(--space-3); }
.type-filter {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #111;
  cursor: pointer;
  opacity: 0.35;
}
.type-filter.is-on { opacity: 1; box-shadow: 0 0 0 1px oklch(100% 0 0 / 0.25); }
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--ink-dim); cursor: pointer; user-select: none;
}
.toggle input { accent-color: var(--good); }

.dex-block { margin-bottom: var(--space-5); }
.dex-block h3 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-size: 1rem;
  display: flex; align-items: baseline; gap: var(--space-2);
}
.dex-block h3 span { font-family: var(--font-body); font-size: 0.75rem; color: var(--ink-mute); font-weight: 500; }
.dex-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: var(--space-2);
}
.mon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: oklch(12% 0.02 250 / 0.55);
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out), border-color var(--dur), background var(--dur);
  color: inherit;
  width: 100%;
  min-width: 0;
}
.mon:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.mon:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mon.is-picked {
  border-color: var(--good);
  background: oklch(30% 0.08 180 / 0.2);
}
.mon.is-picked::after {
  content: "IN PARTY";
  position: absolute; top: 4px; right: 4px;
  font-size: 0.5rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--good);
}
.mon img {
  width: 64px; height: 64px;
  image-rendering: pixelated;
  object-fit: contain;
}
.mon__name {
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.mon__types { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.mon__types .type-pill { font-size: 0.55rem; padding: 0.1rem 0.3rem; }

.site-foot {
  position: relative; z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-6);
  color: var(--ink-mute);
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: oklch(92% 0.02 95);
  color: #111;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none !important; }

@media (max-width: 900px) {
  .plan-layout { grid-template-columns: 1fr; }
  .party-dock {
    position: static;
    max-height: none;
  }
  .tally-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .topbar__inner { flex-direction: column; align-items: stretch; }
  .topbar__nav { justify-content: flex-start; }
  .brand__text em { display: none; }
  .tally-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dex-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .mon img { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
