/* badgemaxxing. The badges are the color; the page stays quiet around them:
   neutral surfaces, hairline borders, one violet accent (from the logo's charge bar)
   for selection and focus, ink-colored primary buttons, monospace for links.
   Light and dark follow the visitor's system setting. */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --sunken: #f4f4f5;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --ink: #18181b;
  --muted: #5f5f68;
  --faint: #8b8b94;
  --accent: #6d4aff;
  --accent-soft: #f0ecff;
  --on-ink: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --gh-dark: #0d1117;
  --gh-light: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --surface: #141417;
    --sunken: #1b1b1f;
    --line: #27272c;
    --line-strong: #36363d;
    --ink: #f2f2f4;
    --muted: #a3a3ad;
    --faint: #74747d;
    --accent: #a08cff;
    --accent-soft: #221c3d;
    --on-ink: #0c0c0e;
    --ok: #3fb950;
    --warn: #d29922;
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
code, pre, kbd { font-family: var(--mono); }
code { font-size: .875em; background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; overflow-wrap: anywhere; }
h2, h3 { text-wrap: balance; }
.wrap { width: min(1160px, 100% - 2 * max(16px, env(safe-area-inset-left, 0px))); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.banner { margin: 0; padding: 12px 16px; background: var(--warn); color: #fff; text-align: center; font-weight: 600; }

/* ---------------------------------------------------------------- controls */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, button { font: inherit; color: var(--ink); }
input:not([type="color"]):not([type="checkbox"]), select {
  width: 100%; min-height: 40px; padding: 8px 12px; font-size: 15px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s;
}
input:not([type="color"]):not([type="checkbox"]):hover, select:hover { border-color: var(--faint); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  transition: background .15s, border-color .15s, transform .1s;
}
.button:hover, button:hover { border-color: var(--faint); }
.button:active, button:active { transform: translateY(1px); }
.button.primary, button.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.button.primary:hover, button.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }

.chip {
  min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip[aria-selected="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------------------------------------------------------------- top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.wordmark { font: 600 15px/1 var(--mono); letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); background: var(--sunken); }
.count { font: 12px var(--mono); color: var(--faint); margin-left: 2px; }

/* ---------------------------------------------------------------- hero */
.hero { padding: 72px 0 80px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: center; }
h1.logo { margin: 0 0 28px; line-height: 0; }
/* the logo keeps 8px of room per side for its burst; at 4x that's 32px, pulled back so it lines up */
#logo { display: inline-block; min-height: 80px; max-width: calc(100% + 32px); margin: -32px 0 -32px -32px; }
#logo img { display: block; max-width: 100%; height: auto; }
/* the logo is a button: clicking it copies the badgemaxxing badge */
.logo-button { all: unset; cursor: pointer; }
#logo.logo-button { display: inline-block; }
.logo-button:hover img { filter: brightness(1.06); }
.logo-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -28px; border-radius: 8px; }
.hero-title { margin: 0 0 14px; font-size: clamp(34px, 4.6vw, 54px); line-height: 1.05; font-weight: 700; letter-spacing: -.035em; text-wrap: balance; }
.lede { margin: 0 0 28px; max-width: 44ch; font-size: 18px; color: var(--muted); }
.cta { display: flex; flex-wrap: wrap; gap: 10px; }

.examples {
  margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--line), 0 24px 48px -24px rgba(24, 24, 27, .18);
}
.examples figcaption {
  display: flex; justify-content: space-between; padding: 8px 12px 6px;
  font: 500 12px var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .08em;
}
.examples ol { list-style: none; margin: 0; padding: 0; display: grid; }
.examples li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 12px; border-top: 1px solid var(--line);
}
.examples li code {
  background: none; border: 0; padding: 0; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal;
}
.examples li code b { color: var(--ink); font-weight: 600; }
.examples li img { display: block; height: auto; max-width: 100%; }

/* ---------------------------------------------------------------- sections */
.section { padding: 88px 0; }
.section.alt { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { max-width: 60ch; margin-bottom: 32px; }
.kicker { margin: 0 0 8px; font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--accent); }
.section-head h2 { margin: 0 0 8px; font-size: clamp(28px, 3.4vw, 38px); line-height: 1.1; letter-spacing: -.03em; }
.section-head p:last-child { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------- builder */
.builder {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: clip;
}
.fields { display: grid; min-width: 0; }
.step { margin: 0; padding: 28px; border: 0; border-bottom: 1px solid var(--line); min-width: 0; display: grid; gap: 16px; }
.step:last-child { border-bottom: 0; }
.step legend, .step-title {
  float: left; width: 100%; margin: 0 0 4px; padding: 0;
  display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 650; color: var(--ink);
}
.step legend small { font-size: 13px; font-weight: 400; color: var(--faint); }
.step-n {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font: 600 12px var(--mono); background: var(--ink); color: var(--on-ink);
}
.row2, .row3 { display: grid; gap: 12px; }
.row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row4 { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mono-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.mono-switch small { font-weight: 400; color: var(--faint); }
/* mono: one field, one color; the label fields step aside */
.mono .label-only { display: none; }
.mono .row2:has(.label-only) { grid-template-columns: minmax(0, 1fr); }
.color { display: flex; gap: 8px; }
.color input[type="color"] {
  flex: none; width: 40px; height: 40px; padding: 3px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.color input:not([type="color"]) { font-family: var(--mono); font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button {
  width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%;
  border: 0; box-shadow: inset 0 0 0 1px var(--line-strong); cursor: pointer;
}
.swatches button:hover { transform: scale(1.12); }

/* animation window */
.anim-jump { display: flex; flex-wrap: wrap; gap: 6px; }
.anim-jump .chip { min-height: 28px; padding: 2px 10px; font-size: 13px; }
.anim-picked { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; color: var(--faint); }
.anim-picked .chip { min-height: 26px; padding: 1px 10px; font-size: 13px; background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.anim-scroll {
  position: relative; max-height: min(440px, 58vh); overflow-y: auto; overscroll-behavior: contain;
  padding: 0 12px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm);
  scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin;
}
#b-anims { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; }
.anim-group {
  position: sticky; top: 0; z-index: 1; grid-column: 1 / -1; margin: 0; padding: 12px 0 6px;
  background: var(--sunken); font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--faint);
}
label.anim {
  position: relative; display: grid; gap: 6px; align-content: start; padding: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 400; color: var(--muted); transition: border-color .15s, box-shadow .15s;
}
label.anim:hover { border-color: var(--line-strong); }
label.anim input { position: absolute; opacity: 0; pointer-events: none; }
label.anim img { display: block; max-width: 100%; height: auto; }
label.anim small { font-size: 12px; line-height: 1.35; }
label.anim:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
label.anim:has(input:checked)::after {
  content: "✓"; position: absolute; top: 6px; right: 8px; font-size: 12px; font-weight: 700; color: var(--accent);
}
label.anim:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.anim-none { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.anim-options { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; }
.anim-options > label:first-child { width: 150px; }
label.compact { flex: 1 1 240px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
label.compact small { flex-basis: 100%; padding-left: 24px; font-size: 12px; font-weight: 400; color: var(--faint); }

/* preview */
.preview {
  position: sticky; top: 72px; align-self: start; display: grid; gap: 16px; padding: 28px;
  border-left: 1px solid var(--line); background: var(--bg); min-width: 0;
}
.stages { display: grid; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: clip; }
.stage { display: grid; place-items: center; min-height: 120px; padding: 20px; overflow-x: auto; }
.stage.dark { background: var(--gh-dark); }
.stage.light { background: var(--gh-light); border-top: 1px solid var(--line); }
.stage img { max-width: 100%; height: auto; transform: scale(1.6); }
.stage.sized img { transform: none; }
.urlbox small { margin-left: 6px; font-weight: 400; }
.urlbox small.ok { color: var(--ok); }
.urlbox small.warn { color: var(--warn); }
.urlbox input { font-family: var(--mono); font-size: 13px; color: var(--muted); background: var(--surface); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .primary { flex: 1 1 auto; }
.more-actions summary { cursor: pointer; font-size: 14px; color: var(--muted); list-style: none; width: max-content; }
.more-actions summary::before { content: "+ "; font-family: var(--mono); }
.more-actions[open] summary::before { content: "− "; }
.more-actions .actions { margin-top: 10px; }
.more-actions button { min-height: 34px; font-size: 14px; font-weight: 500; }

/* ---------------------------------------------------------------- README check */
#check { padding-top: 0; }
.check-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 48px; align-items: start; }
.check { display: grid; gap: 20px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.check-form { display: flex; gap: 8px; }
.check-form input { font-family: var(--mono); font-size: 14px; }
.check-note { margin: 0; color: var(--muted); font-size: 15px; }
.check-score { display: flex; align-items: center; gap: 18px; }
.check-n { font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.check-rank { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.check-n small { margin-left: 4px; font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--faint); }
.check-tagline { margin: 2px 0 0; font-size: 15px; color: var(--ink); }
.check-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.check-meter { height: 8px; margin-top: 16px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.check-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ff4fa3, #8b7bff, #2ef2ff); }
.check-services { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
.check-services li { padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); }
.check-services b { color: var(--ink); font-weight: 600; }
.check-links { margin-top: 12px; font-size: 14px; color: var(--muted); }
.check-links summary { cursor: pointer; width: max-content; }
.check-links ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.check-links code { font-size: 12px; background: none; border: 0; padding: 0; }
.check-links li { display: grid; gap: 1px; }
.check-links .pts { font-size: 13px; font-weight: 600; color: var(--ink); }
.check-suggest-title { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.check-suggest { grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); }


/* ---------------------------------------------------------------- trophies */
#achievements { padding: 0 0 56px; }
.shelf-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 12px; }
.shelf-head .kicker { margin: 0; }
.shelf-note { margin: 0; font-size: 13px; color: var(--faint); }
/* equal tiles; each trophy centred in the same art box, whatever room it keeps around itself */
.achv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; }
.achv {
  display: grid; grid-template-rows: 52px auto auto; align-items: center; justify-items: center; gap: 4px;
  min-height: 0; padding: 8px; white-space: normal;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 500;
}
.achv:hover { border-color: var(--accent); }
.achv img { display: block; width: 100%; height: 100%; object-fit: contain; }
.achv span { font-size: 12px; font-weight: 600; color: var(--ink); }
.achv small { margin-top: -4px; font-size: 11px; color: var(--faint); text-align: center; overflow-wrap: anywhere; }

/* a card in the top-right corner when a trophy unlocks, like a game achievement */
.pops {
  position: fixed; z-index: 30; display: grid; gap: 8px;
  top: calc(66px + env(safe-area-inset-top, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  width: min(280px, calc(100% - 32px)); pointer-events: none;
}
.pop-card {
  pointer-events: auto; display: grid; justify-items: start; gap: 4px; padding: 10px 12px 12px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22); animation: pop-in .45s cubic-bezier(.2, 1.3, .4, 1);
  transition: transform .3s ease-in, opacity .3s ease-in;
}
.pop-card.leaving { transform: translateX(120%); opacity: 0; }
@keyframes pop-in { from { transform: translateX(120%); opacity: 0; } }
.pop-head { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.pop-head span { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.pop-head button { min-height: 24px; padding: 0 8px; font-size: 18px; line-height: 1; border: 0; background: none; color: var(--faint); }
.pop-head button:hover { color: var(--ink); }
.pop-art { display: grid; place-items: center; width: 100%; min-height: 44px; padding: 6px; border-radius: var(--radius-sm); background: var(--sunken); }
.pop-art img { display: block; max-width: 100%; height: auto; }
.pop-card strong { font-size: 14px; }
.pop-card p { margin: -3px 0 2px; font-size: 12px; color: var(--muted); }
.pop-card > button { min-height: 28px; padding: 2px 10px; font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .pop-card { animation: none; transition: none; } }

/* ---------------------------------------------------------------- gallery */
.controls { display: grid; grid-template-columns: minmax(0, 1fr) 170px 200px; gap: 12px; align-items: end; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 0; }
.result-count { margin: 20px 0 12px; font: 13px var(--mono); color: var(--faint); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; }
.card {
  display: grid; gap: 10px; align-content: space-between; justify-content: stretch; justify-items: start; min-height: 88px; padding: 14px;
  text-align: left; cursor: pointer; white-space: normal;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 400;
}
.card:hover { border-color: var(--line-strong); background: var(--surface); }
.card img { height: 22px; max-width: 100%; object-fit: contain; object-position: left center; }
.card small { max-width: 100%; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.copied { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: var(--muted); }
.more { display: flex; margin: 28px auto 0; }

/* ---------------------------------------------------------------- docs */
.docs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.docs article { min-width: 0; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.docs h3 { margin: 0 0 8px; font-size: 17px; letter-spacing: -.01em; }
.docs p { margin: 0 0 16px; color: var(--muted); font-size: 15px; }
pre {
  margin: 0; padding: 14px 16px; overflow-x: auto; white-space: pre;
  font-size: 13px; line-height: 1.6; color: var(--ink);
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------- the badge, kept in view on narrow screens */
.mini-preview {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0, 0, 0, .12);
  animation: mini-in .25s ease-out;
}
.mini-preview[hidden] { display: none; }
@keyframes mini-in { from { transform: translateY(100%); } }
.mini-stage {
  flex: 1; min-width: 0; display: grid; place-items: center; min-height: 52px; padding: 8px;
  border-radius: var(--radius-sm); background: var(--gh-dark); overflow: hidden;
}
.mini-stage img { display: block; max-width: 100%; max-height: 64px; height: auto; transform: scale(1.3); }
.mini-preview button { flex: none; }
/* wide screens keep the real preview in view, so the bar isn't needed */
@media (min-width: 901px) { .mini-preview { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .mini-preview { animation: none; } }

/* ---------------------------------------------------------------- footer and toast */
.foot { padding: 32px 0 48px; color: var(--faint); font-size: 14px; }
.foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); z-index: 20;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--on-ink);
  font-size: 14px; font-weight: 600; box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .hero { padding: 48px 0 56px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; border-left: 0; border-top: 1px solid var(--line); }
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls input[type="search"] { grid-column: 1 / -1; }
  .docs { grid-template-columns: minmax(0, 1fr); }
  .check-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .section { padding: 64px 0; }
}
@media (max-width: 560px) {
  .step, .preview { padding: 20px; }
  .row3, .row4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check { padding: 20px; }
  .check-n { font-size: 48px; }
  .section { padding: 48px 0; }

  /* no top bar on phones: the page starts right away (the hero's buttons lead on) */
  .top { display: none; }
  html { scroll-padding-top: 12px; }

  /* two badges a row in the gallery and the animation picker, not one */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { min-height: 0; padding: 10px; gap: 6px; }
  .card img { height: 18px; }
  .card small { font-size: 11px; }
  #b-anims { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .anim-scroll { padding: 0 8px 8px; }

  /* a trophy is just a slim bar at the top: its badge, its name, × */
  .pops {
    top: calc(6px + env(safe-area-inset-top, 0px)); bottom: auto; gap: 4px;
    left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); width: auto;
  }
  @keyframes pop-in { from { transform: translateY(-140%); opacity: 0; } }
  .pop-card.leaving { transform: translateY(-140%); }
  .pop-card {
    display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 6px;
    border-radius: 999px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  }
  .pop-head { display: contents; }
  .pop-head span, .pop-card p, .pop-card > button { display: none; }
  .pop-card .pop-art { order: 1; flex: 0 1 auto; width: auto; max-width: 45%; min-height: 0; padding: 0; background: none; }
  .pop-card .pop-art img { width: auto; max-width: 100%; height: auto; max-height: 20px; }
  .pop-card strong { flex: 1 0 auto; }
  .pop-card strong { order: 2; flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pop-card strong::before { content: "🏆 "; }
  .pop-head button { order: 3; flex: none; min-height: 28px; }

  .achv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .achv { grid-template-rows: 40px auto auto; padding: 6px; gap: 2px; }
  .achv span { font-size: 11px; }
  .achv small { margin-top: -2px; font-size: 10px; }
  /* the "copied" message sits above the badge bar while that's showing */
  .mini-on .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
