/* Aniimo best-in-slot site. Plain CSS, opens from file://, no imports.
   Direction: a field guide printed on cool paper, with timetable numerals.
   Display and numbers: Bahnschrift (condensed DIN, ships with Windows) with narrow fallbacks.
   Reading text: a serif (Charter on Apple, Sitka on Windows, Noto Serif on Android). */

:root {
  --paper: #edf1f4;
  --surface: #ffffff;
  --sunk: #e1e7ec;
  --ink: #14213a;
  --ink-2: #44526b;
  --ink-3: #6b7890;
  --line: #c6d0da;
  --line-soft: #dbe2e9;

  --good: #1f7a4d;
  --warn: #9a6400;
  --bad: #b3261e;

  --accent: #44526b;
  --on-accent: #ffffff;

  --display: Bahnschrift, "DIN Alternate", "Avenir Next Condensed", "Roboto Condensed",
    "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --text: Charter, "Bitstream Charter", "Sitka Text", "Noto Serif", Cambria, Georgia, serif;

  --measure: 68ch;
  --page: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  --r-s: 3px;
  --r-m: 8px;
  --r-l: 18px;

  /* derived from --accent wherever it is set */
  --accent-soft: color-mix(in srgb, var(--accent) 13%, var(--surface));
  --accent-ink: color-mix(in srgb, var(--accent) 62%, var(--ink));
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101a2c;
    --surface: #18243a;
    --sunk: #0c1423;
    --ink: #e9eef5;
    --ink-2: #b4c0d2;
    --ink-3: #8794aa;
    --line: #33435e;
    --line-soft: #26344c;
    --good: #5fcf96;
    --warn: #e6b450;
    --bad: #ff8a7f;
    --accent: #8794aa;
  }
}

/* Element accents. --on-accent is the text colour that sits on a solid accent fill. */
[data-element="dark"]      { --accent: #6a45c2; --on-accent: #ffffff; }
[data-element="grass"]     { --accent: #2e9440; --on-accent: #ffffff; }
[data-element="lightning"] { --accent: #edb800; --on-accent: #14213a; }
[data-element="ice"]       { --accent: #35b6d6; --on-accent: #14213a; }
[data-element="water"]     { --accent: #1f62d8; --on-accent: #ffffff; }
[data-element="wind"]      { --accent: #17a488; --on-accent: #ffffff; }
[data-element="fire"]      { --accent: #d8321f; --on-accent: #ffffff; }
[data-element="earth"]     { --accent: #8c6239; --on-accent: #ffffff; }
[data-element="light"]     { --accent: #f28c28; --on-accent: #14213a; }
[data-element] {
  --accent-soft: color-mix(in srgb, var(--accent) 13%, var(--surface));
  --accent-ink: color-mix(in srgb, var(--accent) 62%, var(--ink));
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  font-stretch: 80%;
  font-weight: 600;
  line-height: 1.1;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 6vw, 3.25rem); letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1em; max-width: var(--measure); }
ul, ol { margin: 0 0 1em; padding-left: 1.2em; max-width: var(--measure); }
li { margin-bottom: 0.35em; }
li::marker { color: var(--accent-ink); }

a { color: var(--accent-ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--r-s); }

img { max-width: 100%; height: auto; }
small { font-size: 0.85em; color: var(--ink-2); }
strong { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* ---------- page frame ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 2rem;
  padding: 0.9rem var(--gutter) 0.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  /* the frame ruler: one tick per frame, a tall one every tenth */
  background-image:
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(90deg, var(--line-soft) 0 1px, transparent 1px 6px);
  background-size: 100% 9px, 100% 5px;
  background-position: left bottom, left bottom;
  background-repeat: no-repeat;
}
.site-header > a:first-child,
.site-header__title,
.site-header h1 {
  font-family: var(--display);
  font-stretch: 78%;
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: 0;
  margin: 0;
  color: var(--ink);
  text-decoration: none;
}
.site-header__sub { color: var(--ink-3); font-size: 0.9rem; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.25rem;
  margin-left: auto;
  font-family: var(--display);
  font-size: 1.02rem;
}
.site-nav a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--r-s);
}
.site-nav a:hover { color: var(--ink); background: var(--sunk); }
.site-nav a[aria-current],
.site-nav a.is-active { color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }

.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) var(--gutter) 4rem;
}
.site-main > * + * { margin-top: 1.5rem; }

.site-footer {
  padding: 1.4rem var(--gutter) 2rem;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 0.92rem;
  background: var(--sunk);
}
.site-footer p { margin: 0 0 0.3em; }

/* ---------- home: element grid ---------- */

.element-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 14px;
  list-style: none;
  padding: 0;
  max-width: none;
}

.element-card {
  --pad-y: 0.85rem;
  --pad-l: 1.15rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "art name mps" "art best mps" "art meta meta";
  grid-template-rows: auto auto 1fr;
  align-items: end;
  gap: 0;
  overflow: hidden;
  padding: var(--pad-y) 1rem var(--pad-y) var(--pad-l);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-left: 10px solid var(--accent);
  border-radius: var(--r-s) var(--r-m) var(--r-m) var(--r-s);
  transition: background-color 120ms ease, border-color 120ms ease;
}
.element-card:hover { background: var(--accent-soft); border-color: var(--accent); }
/* the Aniimo's picture fills the tile's left edge, top to bottom */
.element-card__art {
  grid-area: art;
  align-self: stretch;
  position: relative;
  width: 80px;
  min-height: 112px;
  margin: calc(-1 * var(--pad-y)) 1rem calc(-1 * var(--pad-y)) calc(-1 * var(--pad-l));
  background: var(--accent-soft);
}
.element-card__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 15%;
}
.element-card__mps { padding-left: 0.75rem; }
.element-card__meta { align-self: end; }
.element-card__name {
  grid-area: name;
  font-family: var(--display);
  font-size: 0.98rem;
  color: var(--accent-ink);
  font-weight: 600;
}
.element-card__best {
  grid-area: best;
  font-family: var(--display);
  font-stretch: 78%;
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1.05;
  overflow-wrap: break-word;
}
.element-card__mps {
  grid-area: mps;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 2.3rem;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--accent-ink);
}
.element-card__mps small,
.element-card__unit { display: block; font-size: 0.8rem; font-weight: 400; font-stretch: 100%; color: var(--ink-3); line-height: 1.3; }
.element-card__meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.1em 0.55em 0.12em;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  vertical-align: 0.1em;
}
.badge--well-tested,
.badge--partly-tested,
.badge--thin { padding-left: 0.45em; }
.badge--well-tested::before,
.badge--partly-tested::before,
.badge--thin::before {
  content: "";
  width: 0.62em;
  height: 0.62em;
  border-radius: 50%;
  border: 2px solid currentColor;
}
.badge--well-tested { color: var(--good); border-color: currentColor; }
.badge--well-tested::before { background: currentColor; }
.badge--partly-tested { color: var(--warn); border-color: currentColor; }
.badge--partly-tested::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.badge--thin { color: var(--bad); border-color: currentColor; }
.badge--provisional { color: var(--warn); border: 1px dashed currentColor; }
.badge--unchecked {
  color: var(--ink);
  border-color: var(--ink-3);
  background: repeating-linear-gradient(-45deg, transparent 0 5px, var(--line-soft) 5px 7px);
}
.badge--stated { color: var(--ink-2); }
.badge--inferred { color: var(--ink-2); border-style: dashed; font-style: italic; }
.badge--not-in-sheet { color: var(--ink-3); border-style: dotted; }
.badge--role {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: transparent;
  border-radius: var(--r-s);
}

/* ---------- element page: hero ---------- */

/* The hero is the answer: the Aniimo, its number, what it holds, who it teams with, how it plays.
   The picture stands on the right, cut off by the hero's edge. */
.hero {
  --hero-pad: clamp(1.1rem, 3.5vw, 2rem);
  --art-w: clamp(200px, 30%, 320px);
  position: relative;
  overflow: hidden;
  padding: var(--hero-pad);
  background: var(--accent-soft);
  border-top: 12px solid var(--accent);
  border-radius: 0 0 var(--r-l) var(--r-l);
}
.hero--art { padding-right: calc(var(--art-w) + var(--hero-pad)); }
.hero__art {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--art-w);
}
.hero__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
  /* the sheet's pictures are cut square at the side, so the cut edge fades out */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 24%);
  mask-image: linear-gradient(90deg, transparent, #000 24%);
}
.hero__body > * { margin: 0; }
.hero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.hero__kicker {
  margin-right: 0.35rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-ink);
}
.hero .hero__unit {
  margin-top: 0.35rem;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: clamp(2.6rem, 11vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.hero .hero__figure {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.8rem;
  max-width: none;
}
.hero__mps {
  flex: none;
  min-width: 3.6ch;
  padding: 0.14em 0.24em 0.08em;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--r-m);
}
.hero__label {
  max-width: 44ch;
  font-family: var(--display);
  font-size: 0.98rem;
  line-height: 1.35;
  color: var(--ink-2);
}

.hero .loadout { margin-top: 1.3rem; }
.loadout { display: grid; margin: 0; max-width: none; }
.loadout__row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.2rem 1rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-top: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.loadout dt { font-family: var(--display); font-size: 0.98rem; color: var(--ink-2); }
.loadout dd { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.4rem; margin: 0; min-width: 0; }
.loadout .chip { background: var(--surface); }
.loadout .chip--item { background: var(--surface); }
.loadout__mps {
  margin-left: auto;
  padding-left: 0.6rem;
  font-family: var(--display);
  font-stretch: 78%;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}
.loadout__mps small { font-size: 0.8rem; font-weight: 400; font-stretch: 100%; color: var(--ink-3); }
.loadout__mps .missing { font-size: 0.9rem; font-weight: 400; font-stretch: 100%; }
.loadout__rotation { font-family: var(--display); font-size: 1.08rem; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  /* on a phone the picture sits beside the name and the loadout takes the full width below it */
  .hero { --art-w: 104px; }
  .hero--art { padding-right: var(--hero-pad); }
  .hero__art { bottom: auto; height: 150px; }
  .hero--art .hero__meta,
  .hero--art .hero__unit { margin-right: calc(var(--art-w) - var(--hero-pad) + 0.5rem); }
  .hero--art .hero__meta { min-height: 1.8rem; }
  .hero .hero__figure { flex-wrap: wrap; gap: 0.5rem 0.8rem; }
  .loadout__row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- panels ---------- */

/* A section is a ruled title and its text on the page itself. Only a thing made of data
   (a build, a ranked Aniimo, a table, an item comparison) sits in a box. */
.panel { min-width: 0; }
.site-main > .panel { margin-top: 2.75rem; }
.panel > :last-child { margin-bottom: 0; }
.panel > * + * { margin-top: 1rem; }
.panel__title {
  font-family: var(--display);
  font-stretch: 80%;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.1;
  margin: 0 0 0.9rem;
  padding-bottom: 0.45rem;
  border-bottom: 3px solid var(--accent);
}
.panel__lead { font-size: 1.08rem; }
.panel__grid,
.builds { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }

/* ---------- builds, chips, rotation ---------- */

.build {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 1rem;
  align-items: baseline;
  align-content: start; /* a short card beside a tall one keeps its rows together */
  padding: 0.9rem 1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
}
.build > * { grid-column: 1 / -1; margin: 0; }
.build--solo { border-top: 4px solid var(--accent); padding-top: calc(0.9rem + 4px); }
/* co-op: a doubled rule, because more than one player brings it */
.build--coop { border-top: 4px double var(--accent); border-top-width: 8px; }
.build .build__title {
  grid-column: 1;
  font-family: var(--display);
  font-stretch: 80%;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.15;
}
.build .build__mps {
  grid-column: 2;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 2.2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  text-align: right;
}
.build__mps small { font-size: 0.8rem; font-weight: 400; font-stretch: 100%; color: var(--ink-3); }
@media (max-width: 480px) {
  /* on a phone the title takes its own line, so "co-op" is not split beside the number */
  .build .build__title { grid-column: 1 / -1; }
  .build .build__mps { grid-column: 1 / -1; text-align: left; font-size: 2rem; }
}
.build__team {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  max-width: none;
}
.build__team li { margin: 0; }
.build__buffs { font-size: 0.95rem; color: var(--ink-2); }
.build__note { font-size: 0.95rem; color: var(--ink-2); max-width: var(--measure); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.22em 0.7em 0.26em;
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.3;
  color: var(--ink);
  background: var(--sunk);
  border: 1px solid transparent;
  border-radius: 999px;
}
/* the held item is a different kind of thing from a team-mate: squared, outlined, tagged */
.chip--item {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-radius: var(--r-s);
  font-weight: 600;
}
.chip--item::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  background: var(--accent);
  transform: rotate(45deg);
}
.chip--main { background: var(--accent); color: var(--on-accent); font-weight: 600; }
/* chips written one after another in a table cell or paragraph: keep each whole,
   and give a run that wraps to several lines even gaps both ways */
.chip { max-width: 100%; }
td > .chip, p > .chip { white-space: nowrap; margin: 0.14rem 0.3rem 0.14rem 0; vertical-align: middle; }
td > .chip + .badge { margin-right: 0.5rem; }

.rotation {
  display: block;
  margin: 0;
  padding: 0.7rem 0.9rem;
  font-family: var(--display);
  font-size: 1.18rem;
  font-weight: 500;
  line-height: 1.5;
  word-spacing: 0.08em;
  color: var(--ink);
  background: var(--sunk);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--r-m) var(--r-m) 0;
  overflow-wrap: anywhere;
  max-width: none;
}
.rotation__step { white-space: nowrap; }
.rotation__sep { color: var(--ink-3); padding: 0 0.15em; }
@media (max-width: 480px) {
  /* a long step may break rather than push the page sideways */
  .rotation { font-size: 1.08rem; padding: 0.6rem 0.75rem; }
  .rotation__step { white-space: normal; }
}

/* Long URLs and build strings in running text break instead of overflowing. */
p, li, dd, dt, figcaption { overflow-wrap: break-word; }

/* ---------- item comparison ---------- */

.compare {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0.3rem 1rem;
  list-style: none;
  max-width: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
}
.compare__row {
  display: grid;
  grid-template-columns: minmax(7rem, 14rem) minmax(0, 1fr) auto;
  gap: 0.2rem 0.9rem;
  align-items: center;
  padding: 0.55rem 0;
  margin: 0;
  border-top: 1px solid var(--line-soft);
}
.compare__row:first-child { border-top: 0; }
.compare__item { font-family: var(--display); font-size: 1.05rem; }
.compare__row--best .compare__item { font-weight: 700; }
.compare__bar {
  height: 0.7rem;
  background: var(--sunk);
  border-radius: 2px;
  overflow: hidden;
}
.compare__fill { display: block; height: 100%; width: var(--w, 50%); background: var(--ink-3); border-radius: 2px; }
.compare__row--best .compare__fill { background: var(--accent); }
.compare__mps {
  font-family: var(--display);
  font-stretch: 78%;
  font-weight: 700;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.compare__context { grid-column: 1 / -1; font-size: 0.9rem; color: var(--ink-2); }
@media (max-width: 480px) {
  .compare__row { grid-template-columns: minmax(0, 1fr) auto; }
  .compare__bar { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- the other units ---------- */

/* one column that may shrink: a wide table scrolls inside its card instead of
   pushing the card past the panel edge and the page sideways */
.unit-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 0; padding: 0; list-style: none; max-width: none; }

.unit-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
}
.unit-card[open] { border-color: var(--accent); }
.unit-card__head {
  display: grid;
  /* rank, name, role badge, mps and the open/close arrow share one row */
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 0.2rem 0.8rem;
  align-items: baseline;
  padding: 0.65rem 1rem;
  cursor: pointer;
  list-style: none;
  border-radius: var(--r-m);
}
.unit-card__head::-webkit-details-marker { display: none; }
.unit-card__head::after {
  content: "";
  width: 0.55em;
  height: 0.55em;
  align-self: center;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg) translateY(-0.15em);
  transition: transform 150ms ease;
}
.unit-card[open] > .unit-card__head::after { transform: rotate(-135deg) translateY(-0.15em); }
.unit-card__head:hover { background: var(--accent-soft); }
.unit-card__rank {
  min-width: 1.7em;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
.unit-card__name {
  font-family: var(--display);
  font-stretch: 80%;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.15;
}
.unit-card__mps {
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  text-align: right;
}
@media (max-width: 480px) {
  /* on a phone the role badge drops under the name, so the name is not cut short */
  .unit-card__head { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .unit-card__head > .badge { grid-row: 2; grid-column: 2; justify-self: start; }
}
.unit-card__verdict,
.unit-card__meta { grid-column: 2 / -1; font-size: 0.95rem; color: var(--ink-2); font-family: var(--text); }
.unit-card__body {
  padding: 0.4rem 1rem 1.1rem;
  border-top: 1px solid var(--line-soft);
}
.unit-card__body > * + * { margin-top: 1rem; }
.unit-card__body > :last-child { margin-bottom: 0; }
.unit-card__body h3, .unit-card__body h4 { margin-top: 1.3rem; }
/* rank 1 keeps its accent on the number */
.unit-card--best .unit-card__rank,
.unit-card:first-child .unit-card__rank { color: var(--accent-ink); }

.why-behind {
  padding: 0.7rem 0.95rem;
  background: var(--sunk);
  border-radius: var(--r-m);
  max-width: none;
}
.why-behind > :last-child { margin-bottom: 0; }
.why-behind__title { font-family: var(--display); font-weight: 600; font-size: 1.05rem; margin: 0 0 0.3rem; }
ul.why-behind { padding-left: 2.1em; }

/* ---------- coverage, caveats, missing, cell refs ---------- */

.coverage > * + * { margin-top: 0.7rem; }
.coverage__status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-family: var(--display); font-size: 1.1rem; font-weight: 600; margin: 0; }
.coverage__reason { color: var(--ink-2); margin: 0; }
.coverage__unfinished { font-size: 0.95rem; color: var(--ink-2); }
.coverage__grid {
  border-collapse: collapse;
  font-family: var(--display);
  font-size: 0.95rem;
  min-width: 100%;
}
.coverage__grid th,
.coverage__grid td { padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line-soft); text-align: center; }
.coverage__grid th { font-weight: 500; color: var(--ink-2); vertical-align: bottom; line-height: 1.2; }
.coverage__grid th:first-child,
.coverage__grid td:first-child { text-align: left; font-weight: 600; color: var(--ink); white-space: nowrap; }
.coverage__grid .yes { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); font-weight: 600; }
.coverage__grid .no {
  color: var(--ink-3);
  background: repeating-linear-gradient(-45deg, transparent 0 5px, var(--line-soft) 5px 6px);
}

.caveat {
  position: relative;
  margin: 0;
  padding: 0.15rem 0 0.15rem 0.9rem;
  font-size: 0.93rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-2);
  border-left: 2px dashed var(--warn);
  max-width: var(--measure);
}
ul.caveat, ol.caveat { padding-left: 2em; }
.caveat + .caveat { margin-top: 0.5rem; }

.missing {
  font-style: italic;
  color: var(--ink-3);
  text-decoration: underline dotted var(--line);
  text-underline-offset: 0.2em;
}

.cell-ref {
  display: inline-block;
  margin-left: 0.3em;
  padding: 0 0.32em;
  font-family: var(--display);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  vertical-align: 0.15em;
  white-space: nowrap;
}
.hero__mps .cell-ref, .chip--main .cell-ref { color: inherit; border-color: currentColor; opacity: 0.75; }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-3) transparent;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--display);
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums;
}
.data-table caption { caption-side: top; text-align: left; padding: 0.6rem 0.8rem; font-weight: 600; font-size: 1.05rem; }
.data-table th,
.data-table td { padding: 0.5rem 0.8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.data-table thead th {
  font-weight: 600;
  color: var(--ink-2);
  background: var(--sunk);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody tr:hover > * { background: var(--accent-soft); }
.data-table td.num, .data-table th.num,
.data-table td[data-num], .data-table th[data-num] { text-align: right; white-space: nowrap; }
.data-table tr.is-best > * { font-weight: 700; box-shadow: inset 0 0 0 999px var(--accent-soft); }
/* Wide tables keep readable columns and scroll sideways inside .table-wrap
   instead of crushing a column into a one-word-per-line stack. */
.data-table { min-width: max-content; }
.data-table th,
.data-table td { max-width: 26rem; overflow-wrap: break-word; }
.data-table thead th { white-space: normal; vertical-align: bottom; }
.data-table td:first-child, .data-table th:first-child { min-width: 9rem; max-width: 20rem; }
.data-table td:not(.num):not([data-num]) { min-width: 7rem; }
@media (min-width: 900px) {
  /* a table with a long run of chips in one cell fits its panel: the chips wrap
     inside their column instead of widening the table past the edge */
  .data-table:has(td > .chip ~ .chip ~ .chip ~ .chip ~ .chip ~ .chip) { min-width: 0; }
  /* a table of four columns or fewer has room on a desktop: long cells wrap in
     their column and the table stays inside its panel */
  .data-table:not(:has(thead th:nth-child(5))) { min-width: 0; }
  .data-table:not(:has(thead th:nth-child(5))) td { overflow-wrap: anywhere; }
}
@media (max-width: 640px) {
  /* on a phone the table scrolls, so columns shrink to their content and more fit per screen */
  .data-table { font-size: 0.94rem; }
  .data-table th,
  .data-table td { padding: 0.45rem 0.6rem; max-width: 17rem; }
  .data-table td:first-child, .data-table th:first-child { min-width: 0; max-width: 11rem; }
  .data-table td:not(.num):not([data-num]) { min-width: 0; }
  /* a cell of chips stays wide, so its row is not five chip-lines tall */
  .data-table td:has(> .chip) { max-width: 24rem; }
}

/* ---------- tier list ---------- */

.tier {
  --tier: var(--ink-2);
  --on-tier: var(--surface);
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  grid-template-areas: "label units" "threshold units";
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
}
.tier + .tier { margin-top: 8px; }
.tier--s { --tier: #c8102e; --on-tier: #ffffff; }
.tier--a { --tier: #e2711d; --on-tier: #14213a; }
.tier--b { --tier: #d9a400; --on-tier: #14213a; }
.tier--c { --tier: #2f7d4f; --on-tier: #ffffff; }
.tier--d { --tier: #47689c; --on-tier: #ffffff; }
.tier__label {
  grid-area: label;
  margin: 0;
  padding: 0.6rem 0.4rem 0;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 3.2rem;
  line-height: 1;
  text-align: center;
  color: var(--on-tier);
  background: var(--tier);
}
.tier__threshold {
  grid-area: threshold;
  margin: 0;
  padding: 0.2rem 0.4rem 0.7rem;
  font-family: var(--display);
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
  color: var(--on-tier);
  background: var(--tier);
}
.tier__units {
  grid-area: units;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 10px;
  list-style: none;
  max-width: none;
}
.tier-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0.45rem 0.35rem 0.5rem;
  text-align: center;
  background: var(--accent-soft);
  border-bottom: 4px solid var(--accent);
  border-radius: var(--r-s);
  color: var(--ink);
  text-decoration: none;
}
.tier-unit__img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 0.3rem;
  background: var(--surface);
  border-radius: 50%;
  font-size: 0.6rem;
  color: var(--ink-3);
}
/* a long tag wraps inside its tile instead of running over the next one */
.tier-unit .badge { max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; border-radius: var(--r-s); }
.tier-unit__name { font-family: var(--display); font-stretch: 85%; font-weight: 600; font-size: 0.98rem; line-height: 1.15; overflow-wrap: anywhere; }
.tier-unit__mps { font-family: var(--display); font-stretch: 78%; font-weight: 700; font-size: 1.2rem; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--accent-ink); }
@media (max-width: 480px) {
  .tier { grid-template-columns: 3.6rem minmax(0, 1fr); }
  .tier__label { font-size: 2.3rem; }
  .tier__units { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; padding: 6px; }
  .tier-unit__img { width: 48px; height: 48px; }
}

/* ---------- mechanics and guide ---------- */

.mech-section {
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 1rem;
}
.mech-section:first-of-type { border-top: 0; padding-top: 0; }
.mech-section > * + * { margin-top: 1rem; }
.mech-section__title { font-size: 1.7rem; margin: 0; }

.key-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: none;
  border-top: 3px solid var(--ink);
}
.key-number {
  margin: 0;
  padding: 0.6rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.key-number__value {
  display: block;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 2.1rem;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.key-number__label { display: block; margin-top: 0.15rem; font-size: 0.93rem; line-height: 1.35; color: var(--ink-2); }

.formula {
  display: block;
  margin: 0;
  padding: 0.75rem 1rem;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.5;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: none;
}

.glossary {
  display: grid;
  grid-template-columns: fit-content(13rem) minmax(0, 1fr);
  gap: 0 1.2rem;
  margin: 0;
  max-width: 54rem;
}
.glossary dt, .glossary dd { min-width: 0; overflow-wrap: break-word; }
.glossary dd > :last-child { margin-bottom: 0; }
.glossary dt {
  padding: 0.5rem 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.08rem;
  border-top: 1px solid var(--line-soft);
}
.glossary dd { margin: 0; padding: 0.5rem 0; border-top: 1px solid var(--line-soft); }
@media (max-width: 640px) {
  .glossary { grid-template-columns: minmax(0, 1fr); }
  .glossary dt { padding-bottom: 0.15rem; }
  .glossary dd { border-top: 0; padding-top: 0; }
}

.takeaways {
  margin: 0;
  padding: 0.8rem 1rem 0.8rem 2.2rem;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--r-m) var(--r-m) 0;
  max-width: none;
}
.takeaways li { max-width: var(--measure); }
.takeaways > :last-child { margin-bottom: 0; }
div.takeaways { padding-left: 1rem; }

/* ---------- notices ---------- */

.notice {
  margin: 0;
  padding: 0.7rem 1rem;
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--ink-3);
  border-radius: var(--r-s);
  max-width: none;
}
.notice > :last-child { margin-bottom: 0; }
.site-main > * + .notice { margin-top: 1.25rem; }
.notice > ul, .notice > ol { margin-top: 0; padding-left: 1.2rem; max-width: var(--measure); }
.notice + .table-wrap, .notice + .data-table, .notice + .panel { margin-top: 0.9rem; }
.notice--unchecked {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  border-color: var(--warn);
  border-left-color: var(--warn);
  background:
    repeating-linear-gradient(-45deg, transparent 0 10px, color-mix(in srgb, var(--warn) 14%, transparent) 10px 14px),
    var(--surface);
}

/* ---------- page-specific touches ---------- */

body[data-page="home"] .site-main > h1 { margin-bottom: 0.2rem; }
.page-summary { font-size: 1.14rem; line-height: 1.55; }
.home__note { color: var(--ink-2); font-size: 0.98rem; }
body[data-page="mechanics"] .site-main,
body[data-page="guide"] .site-main { max-width: 900px; }

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

@media print {
  body { background: #fff; }
  .site-nav { display: none; }
  .unit-card__body { display: block; }
}

