/* Character select: the Family Portrait (grokification.com) turned into a fighter grid.
   Tile + frame rules are copied from .ref/site/family.css; GROKFIGHT adds the two player
   cursors, the side cards, the random tile, search and the "FIGHT" moment.

   Desktop (>= 1024px): [P1 card] [frame] [P2 card] in one viewport; js/screens/select.js
   picks the column count and tile size (--tile) so every fighter fits without scrolling.
   Below 1024px the cards become sticky bars above the frame and the page scrolls. */

.gf-select {
  --side-w: clamp(196px, 17.5vw, 268px);
  --gap: 5px;
  --tile: 48px;
  position: relative;
}

.gf-select-layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--side-w);
  gap: 18px;
  height: 100dvh;
  padding: 12px 16px;
}

.gf-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.gf-stage { display: grid; place-items: center; min-width: 0; min-height: 0; }

/* the frame shrink-wraps the grid JS sized */
.gf-stage .family-frame { width: max-content; max-width: calc(100% - 36px); }
.gf-select .family-frame-top, .gf-select .family-frame-bottom { padding: 10px 28px; font-size: 14px; }
.gf-select .family-frame-top > span, .gf-select .family-frame-bottom > span { white-space: nowrap; }
.gf-band-mid { color: color-mix(in oklab, var(--foreground) 70%, transparent); font-size: 12px; }

/* ---------- toolbar ---------------------------------------------------------------- */

.gf-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gf-toolbar .btn { min-height: 38px; padding: 6px 14px; font-size: 13px; }
.gf-mode-pill { font-size: 12px; padding: 5px 11px; }

.gf-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 150px;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 2px solid var(--foreground);
  border-radius: 999px;
  background: var(--card-solid);
  box-shadow: var(--shadow-cloud);
  font-family: var(--font-display);
  font-size: 14px;
}
.gf-search:focus-within { outline: 4px solid var(--ring); outline-offset: 1px; }
.gf-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-display);
  font-weight: 600;
}
.gf-search input::placeholder { color: var(--muted-foreground); opacity: .8; }
.gf-search-count { flex: none; color: var(--muted-foreground); font-size: 11px; }

/* difficulty stepper: − chill ●●○○○ + */
.gf-level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 4px;
  border: 2px solid var(--foreground);
  border-radius: 999px;
  background: var(--lemon-soft);
  box-shadow: var(--shadow-cloud);
  font-family: var(--font-display);
  font-size: 12px;
}
.gf-level[hidden] { display: none; }
.gf-level button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--foreground);
  border-radius: 50%;
  background: var(--card-solid);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 1px 2px 0 var(--foreground);
}
.gf-level button:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--foreground); }
.gf-level button:disabled { opacity: .35; cursor: default; }
.gf-level-name { min-width: 46px; text-align: center; }
.gf-level-dots { display: inline-flex; gap: 3px; }
.gf-level-dots i { width: 7px; height: 7px; border: 1.5px solid var(--foreground); border-radius: 50%; background: var(--card-solid); }
.gf-level-dots i.on { background: var(--primary); }

/* map picker: ‹ MAP / name › (select.js; the choice goes to the fight as params.stage,
   Random = null). A row of its own in the desktop toolbar; the compact layouts give it a
   grid area. The short name shows only where the row is tight (a phone on its side). */
.gf-map {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 38px;
  padding: 0 4px;
  border: 2px solid var(--foreground);
  border-radius: 999px;
  background: var(--sky-soft);
  box-shadow: var(--shadow-cloud);
  font-family: var(--font-display);
}
.gf-map[hidden] { display: none; }
.gf-map button {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1.5px solid var(--foreground);
  border-radius: 50%;
  background: var(--card-solid);
  color: var(--foreground);
  cursor: pointer;
  box-shadow: 1px 2px 0 var(--foreground);
}
.gf-map button svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.gf-map button:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--foreground); }
.gf-map-name {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  line-height: 1.05;
  text-align: center;
}
.gf-map-name small {
  color: var(--muted-foreground);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gf-map-name b { max-width: 100%; overflow: hidden; font-size: 12.5px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.gf-map-short { display: none; }
/* vs CPU / watch: the right card sits under three toolbar rows (search, CPU level, map), so
   on a short window its portrait gives up a little height and LOCK IN stays on screen */
@media (max-height: 800px) {
  .gf-select:not(.is-compact):is([data-mode="cpu"], [data-mode="watch"]) .gf-side-2 .gf-card-art { width: min(100%, 23dvh); }
}

/* ---------- grid + tiles (from the site) --------------------------------------------- */

.family-grid {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--cols, 16), var(--tile));
  gap: var(--gap);
}

.family-tile {
  position: relative;
  display: block;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--sky-soft);
  cursor: pointer;
  transform-origin: 50%;
  transition: transform .22s cubic-bezier(.2, 1.6, .35, 1), box-shadow .22s, filter .22s, opacity .22s;
  -webkit-tap-highlight-color: transparent;
}
.family-tilt-left { --family-tilt: -4deg; }
.family-tilt-right { --family-tilt: 4deg; }
.family-tile:nth-child(9n+2) { background: var(--pink-soft); }
.family-tile:nth-child(9n+4) { background: var(--lemon-soft); }
.family-tile:nth-child(9n+7) { background: var(--mint-soft); }
.family-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* featured tiers glow and slowly spin their hue (needs @property --feature-hue) */
.family-featured-50k { --feature-glow: 45%; --feature-glow-max: 70%; --feature-glow-speed: 2.6s; --feature-hue-speed: 12s; }
.family-featured-100k { --feature-glow: 55%; --feature-glow-max: 85%; --feature-glow-speed: 1.9s; --feature-hue-speed: 8s; }
.family-featured-1m { --feature-glow: 65%; --feature-glow-max: 100%; --feature-glow-speed: 1.4s; --feature-hue-speed: 5.5s; }
.family-featured {
  --family-feature-color: oklch(.75 .16 var(--feature-hue, 0));
  animation: family-hue-spin var(--feature-hue-speed, 10s) linear infinite;
  box-shadow:
    inset 0 0 0 3px var(--family-feature-color),
    0 0 0 4px color-mix(in oklab, var(--family-feature-color) 65%, transparent),
    0 0 14px 4px color-mix(in oklab, var(--family-feature-color) 60%, transparent),
    0 0 34px 10px color-mix(in oklab, var(--family-feature-color) 48%, transparent),
    0 0 60px 18px color-mix(in oklab, var(--family-feature-color) 28%, transparent);
}
@keyframes family-hue-spin {
  0% { --feature-hue: var(--feature-hue-base, 0); }
  to { --feature-hue: calc(var(--feature-hue-base, 0) + 360); }
}
.family-featured img {
  border: 3px solid var(--family-feature-color);
  box-shadow: 0 0 12px 2px color-mix(in oklab, var(--family-feature-color) var(--feature-glow, 50%), transparent);
  animation: family-feature-glow var(--feature-glow-speed, 2.4s) ease-in-out infinite;
}
@keyframes family-feature-glow {
  0%, to { box-shadow: 0 0 8px 2px color-mix(in oklab, var(--family-feature-color) calc(var(--feature-glow, 50%) - 15%), transparent); }
  50% { box-shadow: 0 0 20px 6px color-mix(in oklab, var(--family-feature-color) var(--feature-glow-max, 75%), transparent); }
}
.family-featured-mark {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: clamp(12px, calc(var(--tile) * .3), 20px);
  height: clamp(12px, calc(var(--tile) * .3), 20px);
  border: 1px solid var(--foreground);
  border-radius: 50%;
  background: var(--family-feature-color);
  color: var(--foreground);
  box-shadow: 1px 2px 0 var(--foreground);
  font-size: clamp(8px, calc(var(--tile) * .2), 13px);
  line-height: 1;
}

/* "★ today", "✿ new", "★ boss" */
.family-spotlight-mark, .family-new-mark, .gf-boss-mark {
  position: absolute;
  z-index: 6;
  padding: 1px 4px;
  border: 1px solid var(--foreground);
  border-radius: 999px;
  color: var(--foreground);
  box-shadow: 1px 2px 0 var(--foreground);
  font-family: var(--font-display);
  font-size: clamp(7px, calc(var(--tile) * .15), 9px);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}
.family-spotlight-mark { top: 3px; left: 3px; background: var(--lemon-soft); }
.family-new-mark { z-index: 7; right: 3px; bottom: 3px; background: var(--mint-soft); }
.gf-boss-mark { top: 3px; left: 3px; background: var(--violet-soft); }
.family-spotlight-tile {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
  animation: family-spotlight-tile-glow 2.2s ease-in-out infinite;
}
@keyframes family-spotlight-tile-glow {
  0%, to { box-shadow: 0 0 0 3px var(--lemon-soft), 0 0 14px 3px color-mix(in oklab, var(--primary) 40%, transparent); }
  50% { box-shadow: 0 0 0 3px var(--lemon-soft), 0 0 30px 9px color-mix(in oklab, var(--primary) 65%, transparent); }
}

/* the hover sprinkle: stars, hearts or cash */
.family-reaction {
  position: absolute;
  top: 10%;
  left: 10%;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: clamp(14px, 1.6vw, 24px);
  line-height: 1;
  text-shadow: 1px 2px var(--foreground);
}
.family-reaction::before, .family-reaction::after { position: absolute; display: block; }
.family-reaction-stars::before { content: "✦"; color: var(--lemon-soft); }
.family-reaction-stars::after { content: "✧"; top: -15px; left: 32px; color: var(--sky-soft); }
.family-reaction-hearts::before { content: "♥"; color: var(--primary); }
.family-reaction-hearts::after { content: "♡"; top: -14px; left: 30px; color: var(--pink-soft); }
.family-reaction-cash::before {
  content: "$";
  padding: 1px 4px;
  border: 1px solid var(--foreground);
  border-radius: 3px;
  background: var(--mint-soft);
  color: var(--foreground);
  transform: rotate(-18deg);
}
.family-reaction-cash::after { content: "✳"; top: -12px; left: 32px; color: var(--lemon-soft); }
.family-tile-active .family-reaction { animation: family-sprinkle .78s ease-out both; }
@keyframes family-sprinkle {
  0% { opacity: 0; transform: translateY(8px) scale(.3) rotate(-25deg); }
  30% { opacity: 1; transform: translate(-7px, -18px) scale(1.15) rotate(8deg); }
  to { opacity: 0; transform: translate(-18px, -42px) scale(.9) rotate(18deg); }
}
@keyframes family-twinkle {
  0%, 92%, to { filter: brightness(1); }
  95% { filter: brightness(1.25) saturate(1.25); }
}
.family-idle:not(.family-tile-active) img { animation: family-twinkle 11s ease-in-out infinite; }

/* the name tag slides up; it may run wider than a small tile */
.family-tile-name {
  position: absolute;
  bottom: 4px;
  left: 50%;
  z-index: 7;
  max-width: max(calc(100% - 6px), 132px);
  overflow: hidden;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--card-solid);
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px);
  transition: opacity .16s, transform .16s;
}
.family-tile-active .family-tile-name { opacity: 1; transform: translate(-50%); }
.family-tile-active .family-new-mark { opacity: 0; }

/* cursor tiles zoom like the site's hovered tile (mouse, keyboard and pad all move a cursor) */
.family-tile-active {
  z-index: 4;
  outline: 3px solid var(--card-solid);
  outline-offset: 0;
  transform: scale(1.2) translateY(-4px) rotate(var(--family-tilt));
  box-shadow: 0 0 0 5px var(--family-feature-color, var(--primary)), 0 15px 25px color-mix(in oklab, var(--foreground) 35%, transparent);
}
.family-tile-close {
  z-index: 2;
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 0 0 2px var(--lemon-soft), 0 5px 12px color-mix(in oklab, var(--foreground) 20%, transparent);
}
.family-tile-near { z-index: 1; transform: scale(1.035); }
.family-tile:focus-visible { outline: 3px solid var(--card-solid); }

/* player cursors: 1P pink ring + tag, 2P blue ring + tag, both on one tile = two rings */
.family-tile.gf-cur1 { z-index: 5; box-shadow: 0 0 0 6px var(--p1), 0 15px 25px color-mix(in oklab, var(--foreground) 35%, transparent); }
.family-tile.gf-cur2 { z-index: 5; box-shadow: 0 0 0 6px var(--p2), 0 15px 25px color-mix(in oklab, var(--foreground) 35%, transparent); }
.family-tile.gf-cur1.gf-cur2 { box-shadow: 0 0 0 6px var(--p1), 0 0 0 10px var(--p2), 0 15px 25px color-mix(in oklab, var(--foreground) 35%, transparent); }
.family-tile.gf-cur1::before,
.family-tile.gf-cur2::after {
  position: absolute;
  top: -13px;
  z-index: 9;
  padding: 1px 5px;
  border: 1.5px solid var(--foreground);
  border-radius: 999px;
  color: #fff;
  box-shadow: 1px 2px 0 var(--foreground);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  pointer-events: none;
}
.family-tile.gf-cur1::before { content: attr(data-tag1); left: -10px; background: var(--p1); transform: rotate(-9deg); }
.family-tile.gf-cur2::after { content: attr(data-tag2); right: -10px; background: var(--p2); transform: rotate(9deg); }
.family-tile.gf-lock1.gf-cur1, .family-tile.gf-lock2.gf-cur2 { animation: gf-lock-bump .42s cubic-bezier(.2, 1.6, .35, 1) both; }
@keyframes gf-lock-bump { 40% { transform: scale(1.34) translateY(-6px) rotate(var(--family-tilt)); } }

/* search: everything that does not match fades back */
.family-tile.is-dim { opacity: .22; filter: grayscale(.85); }
.family-tile.is-dim.family-tile-active { opacity: .7; }

/* the "?" random tile */
.gf-random {
  display: grid;
  place-items: center;
  container-type: inline-size;
  background: repeating-linear-gradient(135deg, var(--lemon-soft) 0 6px, var(--card-solid) 6px 12px) !important;
}
.gf-random-q {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 64cqi;
  font-weight: 700;
  line-height: 1;
  -webkit-text-stroke: 1.5px var(--foreground);
  paint-order: stroke fill;
  text-shadow: 1px 2px 0 var(--foreground);
}

/* ---------- side cards (the site's profile popup, turned into a player card) ---------- */

.gf-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 18px 12px 12px;
  border-radius: 14px;
}
.gf-card[data-side="1"] { --primary: var(--p2); --primary-border: var(--p2-border); }
.gf-card[data-side="0"] { --primary: var(--p1); --primary-border: var(--p1-border); }

.gf-card-ribbon {
  position: absolute;
  top: -14px;
  left: 12px;
  z-index: 3;
  font-size: 12px;
  padding: 3px 11px;
}
.gf-card-ribbon b { color: var(--primary-border); }

.gf-card-art {
  position: relative;
  width: min(100%, 31dvh);
  aspect-ratio: 1;
  align-self: center;
  flex: none;
  border: 2px solid var(--foreground);
  border-radius: 6px;
  background: var(--pink-soft);
}
.gf-card-art img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.gf-card-art.family-featured { border-color: var(--foreground); }
.gf-card-art .gf-art-tier { position: absolute; left: 8px; bottom: 8px; z-index: 2; }
.gf-card-art .gf-art-marks { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; gap: 4px; }
.gf-card-art .gf-art-marks .sticker:nth-child(1) { transform: rotate(-5deg); }

.gf-random-art {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: repeating-linear-gradient(135deg, var(--lemon-soft) 0 18px, var(--card-solid) 18px 36px);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: min(9rem, 20dvh);
  font-weight: 700;
  line-height: 1;
  -webkit-text-stroke: 4px var(--foreground);
  paint-order: stroke fill;
  text-shadow: 3px 5px 0 var(--foreground);
}
.gf-empty-art { background: repeating-linear-gradient(135deg, var(--muted) 0 18px, var(--card-solid) 18px 36px); }
.gf-empty-art .gf-random-art { background: none; color: var(--card-solid); font-size: min(6rem, 13dvh); }

/* READY ✓ stamp over a locked card */
.gf-ready {
  position: absolute;
  top: 42%;
  left: 50%;
  z-index: 4;
  padding: 6px 16px 5px;
  border: 3px solid var(--foreground);
  border-radius: 10px;
  background: var(--mint-soft);
  color: var(--foreground);
  box-shadow: 3px 4px 0 var(--foreground);
  font-family: var(--font-display);
  font-size: clamp(20px, 2.4vw, 32px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-10deg);
  animation: gf-stamp .34s cubic-bezier(.2, 1.6, .35, 1) both;
}
@keyframes gf-stamp { from { opacity: 0; transform: translate(-50%, -50%) rotate(-10deg) scale(1.9); } }

.gf-card-id {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-left: 9px;
  border-left: 6px solid var(--tier-base);
  font-family: var(--font-display);
}
.gf-card-id[data-tier="5k"] { border-left-color: var(--tier-5k); }
.gf-card-id[data-tier="10k"] { border-left-color: var(--tier-10k); }
.gf-card-id[data-tier="50k"] { border-left-color: var(--tier-50k); }
.gf-card-id[data-tier="100k"] { border-left-color: var(--tier-100k); }
.gf-card-id[data-tier="1m"] { border-left-color: var(--tier-1m); }
.gf-card-id .gf-x { font-size: 13px; }
.gf-handle { min-width: 0; overflow: hidden; font-size: clamp(16px, 1.45vw, 21px); font-weight: 700; line-height: 1.15; white-space: nowrap; text-overflow: ellipsis; }
.gf-card-pills { display: flex; flex-wrap: wrap; gap: 5px; }

/* the fighter's skill: prop sticker, name + template tag, one line of what it does */
.gf-skill {
  --skill: var(--primary);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 10px;
  flex: none;
  padding: 6px 10px 7px 7px;
  border: 2px solid var(--foreground);
  border-radius: 12px;
  background:
    repeating-linear-gradient(135deg, color-mix(in oklab, var(--skill) 10%, transparent) 0 8px, transparent 8px 16px),
    linear-gradient(110deg, color-mix(in oklab, var(--skill) 22%, var(--card-solid)), var(--card-solid) 72%);
  box-shadow: 0 3px 0 var(--foreground);
}
.gf-skill-prop { width: 38px; height: 38px; transform: rotate(-8deg); }
.gf-skill-body { min-width: 0; }
.gf-skill-head { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; margin: 0; font-family: var(--font-display); font-size: 15px; line-height: 1.15; }
.gf-skill-name { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.gf-skill-desc { margin: 2px 0 0; color: var(--muted-foreground); font-size: 11.5px; font-weight: 800; line-height: 1.3; }
.gf-card-special { margin: 0; font-family: var(--font-display); font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--muted-foreground); }
.gf-card-special b { color: var(--primary-border); font-weight: 700; }
.gf-card-bio {
  margin: 0;
  padding: 5px 9px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: color-mix(in oklab, var(--muted) 40%, transparent);
  color: var(--muted-foreground);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
}
/* the clamp sits on an inner span, so the third line cannot peek into the padding */
.gf-card-bio span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.gf-card-bio:empty { display: none; }

.gf-stats { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px; margin: 0; }
.gf-stats dt { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.gf-stats dd { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; margin: 0; }
.gf-stats dd i { height: 9px; border: 1.5px solid var(--foreground); border-radius: 3px; background: var(--card-solid); }
.gf-stats dd.pow i.on { background: var(--magenta-soft); }
.gf-stats dd.spd i.on { background: var(--buy-fomo); }
.gf-stats dd.def i.on { background: var(--buy-pump); }

/* move list: only where the screen is tall enough to hold it */
.gf-moves { display: none; margin: 0; padding: 7px 9px; border: 2px dashed var(--border); border-radius: 10px; list-style: none; font-size: 11.5px; }
.gf-moves li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.gf-moves span { color: var(--muted-foreground); font-weight: 800; }
.gf-moves b { font-family: var(--font-display); font-weight: 700; white-space: nowrap; }
@media (min-height: 860px) {
  .gf-select:not(.is-compact) .gf-moves { display: block; }
}

.gf-card-actions { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.gf-lock { min-height: 52px; font-size: 19px; letter-spacing: .02em; }
.gf-card-hint { margin: 0; text-align: center; color: var(--muted-foreground); font-family: var(--font-display); font-size: 11px; font-weight: 600; }
.gf-card.is-locked .gf-card-art { box-shadow: 0 0 0 4px var(--mint-soft), 0 0 0 6px var(--foreground); }
.gf-card.is-waiting { opacity: .88; }
.gf-card.is-waiting .gf-card-art { filter: saturate(.7); }

/* arcade: the road to the boss */
.gf-ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gf-ladder-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.gf-ladder-face {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--foreground);
  border-radius: 6px;
  background: repeating-linear-gradient(135deg, var(--sky-soft) 0 9px, var(--card-solid) 9px 18px);
  box-shadow: 2px 3px 0 var(--foreground);
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}
.gf-ladder-slot:nth-child(2) .gf-ladder-face { background: repeating-linear-gradient(135deg, var(--mint-soft) 0 9px, var(--card-solid) 9px 18px); }
.gf-ladder-slot:nth-child(3) .gf-ladder-face { background: repeating-linear-gradient(135deg, var(--lemon-soft) 0 9px, var(--card-solid) 9px 18px); }
.gf-ladder-slot:nth-child(4) .gf-ladder-face { background: repeating-linear-gradient(135deg, var(--peach-soft) 0 9px, var(--card-solid) 9px 18px); }
.gf-ladder-slot:nth-child(5) .gf-ladder-face { background: repeating-linear-gradient(135deg, var(--pink-soft) 0 9px, var(--card-solid) 9px 18px); }
.gf-ladder-face.is-boss { background: var(--foreground); color: var(--lemon-soft); }
.gf-ladder-face.is-boss img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(0) saturate(0); opacity: .9; }
.gf-ladder-face.is-boss span { position: relative; z-index: 1; text-shadow: 0 2px 0 var(--foreground); }
.gf-ladder-label { font-family: var(--font-display); font-size: 10.5px; color: var(--muted-foreground); white-space: nowrap; }
.gf-ladder-label.is-boss { color: var(--foreground); }
.gf-card-note { margin: 0; font-size: 12px; color: var(--muted-foreground); line-height: 1.35; }
.gf-card-title { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; line-height: 1.1; }

/* ---------- the FIGHT moment --------------------------------------------------------- */

.gf-fight-moment {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, color-mix(in oklab, var(--card-solid) 70%, transparent), transparent 60%);
  animation: sheet-fade .2s ease-out both;
}
.gf-fight-moment[hidden] { display: none; }
.gf-fight-word {
  color: var(--primary);
  font-family: var(--font-display);
  font-size: clamp(72px, 13vw, 190px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
  -webkit-text-stroke: 10px var(--foreground);
  paint-order: stroke fill;
  text-shadow: 0 10px 0 var(--foreground), 0 22px 40px color-mix(in oklab, var(--foreground) 30%, transparent);
  animation: gf-fight-pop .55s cubic-bezier(.2, 1.6, .35, 1) both;
}
.gf-fight-word small { color: var(--lemon-soft); font-size: .55em; vertical-align: .35em; }
@keyframes gf-fight-pop {
  0% { opacity: 0; transform: scale(.3) rotate(-12deg); }
  60% { opacity: 1; transform: scale(1.08) rotate(3deg); }
  to { transform: scale(1) rotate(-3deg); }
}

/* ---------- compact: the page scrolls, a pick dock sits in thumb reach --------------------
   select.js sets .is-compact below 1024px wide and on touch-first screens (big tiles for
   fingers); mouse users at 1024px and up keep the one-screen layout. The side cards give
   way to .gf-dock (below); only the arcade ladder card stays, above the frame. */

.gf-select.is-compact .gf-select-layout {
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "back mode search level map" "c2 c2 c2 c2 c2" "stage stage stage stage stage";
  align-items: center;
  gap: 12px 10px;
  height: auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--dock-h, 160px) + 36px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
/* the two toolbars melt into one bar: back, mode, search, CPU level */
.gf-select.is-compact .gf-side, .gf-select.is-compact .gf-toolbar { display: contents; }
.gf-select.is-compact .gf-back { grid-area: back; }
.gf-select.is-compact .gf-mode-pill { grid-area: mode; justify-self: start; }
.gf-select.is-compact .gf-search { grid-area: search; }
.gf-select.is-compact .gf-level { grid-area: level; justify-self: end; }
.gf-select.is-compact .gf-map { grid-area: map; width: clamp(150px, 24vw, 230px); height: 44px; padding: 0 5px; }
.gf-select.is-compact .gf-map button { position: relative; width: 34px; height: 34px; }
.gf-select.is-compact .gf-map button::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; }
.gf-select.is-compact .gf-card:not(.is-ladder) { display: none; }
.gf-select.is-compact .gf-side-2 .gf-card { grid-area: c2; }
.gf-select.is-compact .gf-stage { grid-area: stage; padding: 22px 0 10px; }
.gf-select.is-compact .gf-stage .family-frame { width: calc(100% - 26px); max-width: none; }
.gf-select.is-compact .family-grid { grid-template-columns: repeat(var(--cols, 9), minmax(0, 1fr)); }

/* thumb-sized toolbar; 16px text in the search box so iOS does not zoom the page */
.gf-select.is-compact .gf-toolbar .btn { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.gf-select.is-compact .gf-mode-pill { padding: 7px 12px; }
.gf-select.is-compact .gf-search { height: 44px; }
.gf-select.is-compact .gf-search input { font-size: 16px; }
.gf-select.is-compact .gf-level { height: 44px; padding: 0 5px; }
.gf-select.is-compact .gf-level button { position: relative; width: 34px; height: 34px; font-size: 18px; }
/* the drawn circle stays 34px; a thumb gets the pill's full 44px height */
.gf-select.is-compact .gf-level button::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; }

/* arcade: the road to the boss, a row of six above the frame */
.gf-select.is-compact .gf-card.is-ladder {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 16px 12px 10px;
  border-width: 3px;
  box-shadow: 0 4px 0 var(--primary-border), 0 10px 20px color-mix(in oklab, var(--primary) 20%, transparent);
}
.gf-select.is-compact .gf-card-ribbon { top: -11px; font-size: 10px; padding: 2px 8px; }
.gf-select.is-compact .gf-card-title { font-size: 15px; }
.gf-select.is-compact .gf-card-note { display: none; }
.gf-select.is-compact .gf-card.is-ladder .gf-ladder { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.gf-select.is-compact .gf-card.is-ladder .gf-ladder-face { font-size: 16px; }
.gf-select.is-compact .gf-card.is-ladder .gf-ladder-label { display: none; }
@media (min-width: 640px) {
  .gf-select.is-compact .gf-card.is-ladder { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 16px; }
  .gf-select.is-compact .gf-card.is-ladder .gf-ladder { max-width: 420px; }
}

/* narrow: back, mode and level on one row, the search box under them
   (phones on their side keep the single row: height is what they are short of) */
@media (max-width: 639px) {
  .gf-select.is-compact .gf-select-layout {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "back mode . level" "search search search search" "map map map map" "c2 c2 c2 c2" "stage stage stage stage";
  }
  .gf-select.is-compact .gf-map { width: auto; }
}
.gf-toolbar .gf-back { gap: .22em; }
@media (max-width: 419px) {
  .gf-select.is-compact .gf-toolbar .gf-back { width: 44px; padding: 0; font-size: 18px; }
  .gf-select.is-compact .gf-back-label { display: none; }
}

@media (max-width: 639px) {
  .gf-select.is-compact .gf-select-layout { gap: 10px 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .gf-select.is-compact .gf-stage { padding-top: 16px; }
  .gf-select.is-compact .gf-stage .family-frame { width: calc(100% - 20px); }
  .gf-select.is-compact .family-frame-top, .gf-select.is-compact .family-frame-bottom { padding: 8px 14px; font-size: 11px; }
  .gf-select.is-compact .gf-band-mid { display: none; }
  .gf-select.is-compact .family-tile-name { font-size: 9px; }
  .gf-select.is-compact .family-tile.gf-cur1::before, .gf-select.is-compact .family-tile.gf-cur2::after { font-size: 9px; top: -11px; }
}
@media (max-width: 419px) {
  .gf-select.is-compact .family-frame-top, .gf-select.is-compact .family-frame-bottom { gap: 4px 8px; padding: 8px 12px; font-size: 10px; }
}
/* phones on their side: the dock already says how to pick, and every px of height
   goes to faces — one toolbar row, a tight gap above the frame, slim bands */
@media (orientation: landscape) and (max-height: 520px) {
  .gf-select.is-compact .gf-band-mid { display: none; }
  .gf-select.is-compact .gf-select-layout { gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .gf-select.is-compact .gf-stage { padding-top: 14px; }
  .gf-select.is-compact .gf-level-dots { display: none; }
  .gf-select.is-compact .gf-map { width: 138px; padding: 0 4px; gap: 2px; }
  .gf-select.is-compact .gf-map button { width: 30px; height: 30px; }
  .gf-select.is-compact .gf-map button::after { inset: -7px; }
  .gf-select.is-compact .gf-map-name small, .gf-select.is-compact .gf-map-full { display: none; }
  .gf-select.is-compact .gf-map-short { display: block; }
  .gf-select.is-compact .gf-toolbar .gf-back { width: 44px; padding: 0; font-size: 18px; }
  .gf-select.is-compact .gf-back-label { display: none; }
  .gf-select.is-compact .family-frame-top, .gf-select.is-compact .family-frame-bottom { padding: 6px 14px; font-size: 11px; }
}

/* anything scrolled into view (a focused tile, a keyboard move) lands above the dock */
html:has(.gf-select.is-compact) { scroll-padding-bottom: 196px; }
@media (orientation: landscape) and (max-height: 520px) {
  html:has(.gf-select.is-compact) { scroll-padding-bottom: 16px; }
}

/* a search on a phone keeps only the matches, so they line up under the box */
.gf-select.is-compact .family-grid.is-filtering .family-tile.is-dim { display: none; }

/* ---------- the pick dock ------------------------------------------------------------ */

.gf-dock { display: none; }
.gf-select.is-compact .gf-dock {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  padding: 0 max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  pointer-events: none;
}
.gf-dock[data-side="0"] { --primary: var(--p1); --primary-border: var(--p1-border); }
.gf-dock[data-side="1"] { --primary: var(--p2); --primary-border: var(--p2-border); }

.gf-dock-card {
  --art: 66px;
  display: grid;
  grid-template-columns: var(--art) minmax(0, 1fr);
  grid-template-areas: "art info" "act act";
  align-items: center;
  gap: 10px 12px;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 20px 12px 12px;
  border-width: 3px;
  border-radius: 20px;
  background: linear-gradient(180deg, color-mix(in oklab, var(--primary) 16%, var(--card-solid)), var(--card-solid) 58%);
  box-shadow: 0 5px 0 var(--primary-border), 0 14px 34px color-mix(in oklab, var(--foreground) 26%, transparent);
  pointer-events: auto;
}
.gf-dock-card.is-turn { animation: gf-dock-turn .5s cubic-bezier(.2, 1.5, .35, 1) both; }
@keyframes gf-dock-turn { from { opacity: .3; transform: translateY(46px) scale(.94); } }

/* whose pick it is: a solid 1P-pink / 2P-blue pill on the top edge */
.gf-dock-ribbon {
  position: absolute;
  top: -14px;
  left: 14px;
  z-index: 2;
  padding: 3px 12px;
  box-shadow: 1px 2px 0 var(--foreground);
  font-size: 12.5px;
  transform: rotate(-2deg);
}
.gf-dock-ribbon b { font-weight: 700; margin-right: 2px; }

/* both picks, as chips on the top-right edge; a set one can be tapped to change it */
.gf-dock-chips { position: absolute; top: -14px; right: 12px; z-index: 2; display: flex; gap: 6px; }
.gf-dock-chip {
  position: relative;
  gap: 4px;
  padding: 1px 8px 1px 2px;
  box-shadow: 1px 2px 0 var(--foreground);
  font-size: 11px;
  cursor: default;
}
.gf-dock-chip img, .gf-dock-chip i {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--foreground);
  border-radius: 50%;
  background: var(--card-solid);
  color: var(--foreground);
  object-fit: cover;
  font-size: 11px;
  font-style: normal;
}
.gf-dock-chip:not(.is-now):not(.is-set) { border-style: dashed; background: var(--card-solid); color: var(--muted-foreground); box-shadow: none; }
.gf-dock-chip.is-now { box-shadow: 1px 2px 0 var(--foreground), 0 0 0 3px color-mix(in oklab, var(--card-solid) 80%, transparent); }
button.gf-dock-chip { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.gf-dock-chip::after { content: ""; position: absolute; inset: -10px -3px; }

.gf-dock-art {
  position: relative;
  grid-area: art;
  width: var(--art);
  aspect-ratio: 1;
  border: 2.5px solid var(--foreground);
  border-radius: 12px;
  background: var(--pink-soft);
  box-shadow: 2px 3px 0 var(--foreground);
  transform: rotate(-3deg);
}
.gf-dock-art img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
/* the featured glow, held still (the tiles pulse; the dock does not repaint every frame) */
.gf-dock-art.family-featured {
  --feature-hue: var(--feature-hue-base, 0);
  animation: none;
  box-shadow: 2px 3px 0 var(--foreground), 0 0 0 3px var(--family-feature-color), 0 0 16px 5px color-mix(in oklab, var(--family-feature-color) 55%, transparent);
}
.gf-dock-art.family-featured img { border: 0; box-shadow: none; animation: none; }
.gf-dock-art .gf-random-art { border-radius: 9px; font-size: calc(var(--art) * .62); -webkit-text-stroke: 2.5px var(--foreground); text-shadow: 1px 2px 0 var(--foreground); }
.gf-dock-art .gf-ready { top: 50%; padding: 3px 6px; border-width: 2px; box-shadow: 1px 2px 0 var(--foreground); font-size: 12px; animation: none; }

.gf-dock-info { grid-area: info; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gf-dock-info .gf-card-id { padding-left: 7px; border-left-width: 4px; }
.gf-dock-info .gf-card-id .gf-x { font-size: 12px; }
.gf-dock-info .gf-handle { font-size: 18px; }
.gf-dock-pills { display: flex; flex-wrap: nowrap; gap: 4px; min-width: 0; overflow: hidden; }
.gf-dock-pills .pill { box-shadow: none; }
.gf-dock-special {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted-foreground);
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.gf-dock-special b { color: var(--primary-border); font-weight: 700; }
/* the skill in the dock: sticker, name, tag, then what it does (two lines at most) */
.gf-dock-skill b { color: var(--foreground); }
.gf-dock-skill .gf-tag { margin: 0 2px 0 5px; vertical-align: 1px; }
.gf-dock-prop { --ring: 1.5px; --ink: 1.2px; --drop: 1.2px; width: 22px; height: 22px; margin: -3px 6px 0 1px; vertical-align: middle; transform: rotate(-8deg); }

.gf-dock-actions { grid-area: act; display: flex; gap: 10px; min-width: 0; }
.gf-dock-lock { flex: 1 1 auto; min-width: 0; min-height: 54px; font-size: 20px; letter-spacing: .02em; }
.gf-dock-random {
  flex: none;
  width: 54px;
  min-height: 54px;
  padding: 0;
  border: 3px solid var(--foreground);
  background: repeating-linear-gradient(135deg, var(--lemon-soft) 0 7px, var(--card-solid) 7px 14px);
  box-shadow: 0 4px 0 var(--foreground);
}
.gf-dock-random span {
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
  -webkit-text-stroke: 1.5px var(--foreground);
  paint-order: stroke fill;
  text-shadow: 1px 2px 0 var(--foreground);
}
.gf-dock-random:disabled { opacity: .45; }

/* short phones (SE): a slimmer dock */
@media (orientation: portrait) and (max-height: 700px) {
  .gf-dock-card { --art: 56px; gap: 8px 10px; padding: 18px 10px 10px; }
  .gf-dock-info { gap: 3px; }
  .gf-dock-info .gf-handle { font-size: 16px; }
  .gf-dock-special { -webkit-line-clamp: 1; font-size: 12px; }
  .gf-dock-lock, .gf-dock-random { min-height: 50px; }
  .gf-dock-random { width: 50px; }
}
/* tablets: a roomier dock */
@media (min-width: 700px) and (min-height: 700px) {
  .gf-dock-card { --art: 84px; width: min(100%, 600px); padding: 22px 16px 14px; }
  .gf-dock-info .gf-handle { font-size: 21px; }
  .gf-dock-special { font-size: 13.5px; }
  .gf-dock-lock { min-height: 58px; font-size: 22px; }
  .gf-dock-random { width: 58px; min-height: 58px; }
}
/* phones on their side: the dock stands at the right, the grid fills the rest */
@media (orientation: landscape) and (max-height: 520px) {
  .gf-select.is-compact .gf-select-layout {
    padding-right: calc(clamp(216px, 31vw, 270px) + max(12px, env(safe-area-inset-right)) + 14px);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .gf-select.is-compact .gf-dock {
    top: 0;
    left: auto;
    display: flex;
    align-items: center;
    width: calc(clamp(216px, 31vw, 270px) + max(12px, env(safe-area-inset-right)));
    padding: 16px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) 0;
  }
  .gf-dock-card {
    --art: min(104px, 25dvh);
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 8px;
    max-height: 100%;
    padding: 22px 10px 10px;
    text-align: center;
  }
  .gf-dock-card.is-turn { animation-name: gf-dock-turn-side; }
  @keyframes gf-dock-turn-side { from { opacity: .3; transform: translateX(40px) scale(.94); } }
  .gf-dock-info { align-items: center; width: 100%; }
  .gf-dock-info .gf-card-id { max-width: 100%; }
  .gf-dock-info .gf-handle { font-size: 16px; }
  .gf-dock-pills { flex-wrap: wrap; justify-content: center; }
  .gf-dock-special { font-size: 12px; }
  .gf-dock-actions { width: 100%; }
  .gf-dock-lock, .gf-dock-random { min-height: 48px; font-size: 18px; }
  .gf-dock-random { width: 48px; }
  .gf-dock-ribbon { left: 50%; top: -13px; font-size: 11.5px; white-space: nowrap; transform: translateX(-50%) rotate(-2deg); }
  .gf-dock-card { grid-template-areas: "chips" "art" "info" "act"; }
  .gf-dock-chips { position: static; grid-area: chips; justify-content: center; }
}

/* ---------- compact screens: the same look for a fraction of the work ------------------
   272 tiles with glows that re-colour every frame keep a phone's main thread busy all the
   time. Here the featured glow holds its own hue, sits on a separate layer (.gf-glow)
   and only pulses its opacity while the tile is on screen (.is-live, from an
   IntersectionObserver in select.js). No filter or shadow animations on tiles.
   Measured on a 390x844 phone profile (4x CPU throttle): 13 fps before, 60 after. */
.gf-glow { display: none; }
.gf-select.is-compact .family-featured { --feature-hue: var(--feature-hue-base, 0); animation: none; }
.gf-select.is-compact .family-featured:not(.family-tile-active):not(.gf-cur1):not(.gf-cur2) {
  box-shadow: inset 0 0 0 3px var(--family-feature-color), 0 0 0 4px color-mix(in oklab, var(--family-feature-color) 65%, transparent);
}
.gf-select.is-compact .family-featured img { animation: none; box-shadow: none; }
.gf-select.is-compact .gf-glow {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  box-shadow:
    0 0 14px 4px color-mix(in oklab, var(--family-feature-color) 60%, transparent),
    0 0 30px 9px color-mix(in oklab, var(--family-feature-color) 42%, transparent);
  pointer-events: none;
}
/* paused, not removed, off screen: starting and stopping an animation re-layers the page
   (a long frame mid-swipe); a paused one keeps its layer and costs nothing */
.gf-select.is-compact .family-featured .gf-glow { animation: gf-glow-pulse var(--feature-glow-speed, 2.4s) ease-in-out infinite paused; }
.gf-select.is-compact .family-featured.is-live .gf-glow { animation-play-state: running; }
@keyframes gf-glow-pulse { 50% { opacity: .35; } }
.gf-select.is-compact .family-spotlight-tile { animation: none; }
.gf-select.is-compact .family-spotlight-tile:not(.family-tile-active):not(.gf-cur1):not(.gf-cur2) {
  box-shadow: 0 0 0 3px var(--lemon-soft), 0 0 22px 6px color-mix(in oklab, var(--primary) 55%, transparent);
}
.gf-select.is-compact .family-idle img { animation: none; }
.gf-select.is-compact .candy-tag { animation: none; }

/* no text selection, image callouts or drag ghosts on a long press */
.family-tile, .gf-dock-card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.family-tile img { -webkit-user-drag: none; }

/* touch screens have no hover: only the cursor tile zooms */
@media (hover: none) {
  .family-tile:hover:not(.family-tile-active) { transform: none; box-shadow: none; outline: none; }
}

@media (prefers-reduced-motion: reduce) {
  .family-reaction, .family-idle img, .family-featured img, .family-featured, .family-spotlight-tile,
  .gf-ready, .gf-fight-word, .gf-fight-moment, .family-tile.gf-lock1, .family-tile.gf-lock2, .gf-glow, .gf-dock-card { animation: none !important; }
  .family-tile, .family-tile-name { transition: none; }
}
