/* PitchView — sizes derive from the pitch width (cqw), so it scales anywhere. */
.pitch {
  container-type: inline-size;
  position: relative;
  width: 100%;
  aspect-ratio: var(--pitch-aspect, 4 / 5);
  border-radius: var(--radius-lg);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(60% 40% at 0% 0%, rgb(220 240 255 / 0.16), transparent 70%),
    radial-gradient(60% 40% at 100% 0%, rgb(220 240 255 / 0.16), transparent 70%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgb(0 10 5 / 0.55)),
    repeating-linear-gradient(
      180deg,
      var(--pitch-stripe-a) 0 8.333%,
      var(--pitch-stripe-b) 8.333% 16.666%
    );
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.06),
    0 0 0 1px rgb(0 0 0 / 0.4),
    var(--shadow-lg);
  /* The token follows the pitch's width. A slot — marks and boost chip 0.58 token over its
     centre, the name label's foot 0.64 token + one label line under it — must fit between two
     lines (--row, PitchView rowRoom: the least distance in cqw), so formations whose lines are
     close (six lines, a squat pitch) get a smaller token; the second term is for the label's
     9 px floor. Everything on a token is sized from it. */
  --token: clamp(
    20px,
    min(12.4cqw, calc(var(--row, 25cqw) / 1.72), calc((var(--row, 25cqw) - 17px) / 1.22)),
    58px
  );
  --label: clamp(9px, calc(var(--token) * 0.25), 13px);
  --mark: max(11px, calc(var(--token) * 0.3));
}
.pitch__lines,
.pitch__links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.pitch__lines {
  fill: none;
  stroke: var(--pitch-line);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}
.pitch__lines * {
  vector-effect: non-scaling-stroke;
}
.pitch__spot {
  fill: var(--pitch-line);
}
.pitch__link {
  --link: rgb(186 220 255);
  --link-w: 2px;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.pitch__link line {
  stroke: var(--link);
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
/* Glow: a wide, soft stroke under the line. */
.pitch__link-glow {
  stroke-width: calc(var(--link-w) * 4);
  opacity: 0.22;
  filter: blur(2px);
}
.pitch__link-core {
  stroke-width: var(--link-w);
  opacity: 0.95;
}
/* Pulse: a short bright dash running along the link, staggered by strength. */
.pitch__link-flow {
  stroke: #fff !important;
  stroke-width: calc(var(--link-w) * 0.8);
  stroke-dasharray: 10 90;
  opacity: 0.85;
  animation: link-flow 2.4s linear infinite;
}
/* Other (1): sky, dashed. Club mates (2): volt. Nation mates (3): gold, thickest. */
.pitch__link--1 {
  --link: rgb(150 205 255);
  --link-w: 1.75px;
}
.pitch__link--1 .pitch__link-core {
  stroke-dasharray: 5 4;
}
.pitch__link--1 .pitch__link-flow {
  animation-duration: 3s;
}
.pitch__link--2 {
  --link: var(--volt-400);
  --link-w: 2.5px;
}
.pitch__link--3 {
  --link: var(--gold-400);
  --link-w: 3.25px;
}
.pitch__link--3 .pitch__link-glow {
  opacity: 0.35;
}
.pitch__link--3 .pitch__link-flow {
  animation-duration: 1.8s;
}
/* A duo (4): a bright violet double line — a wide core with a dark seam down its middle — and a
   strong glow, above the mates' lines and never faded; it draws itself in when it appears. */
.pitch__link--4 {
  --link: #d4c4ff;
  --link-w: 6px;
}
.pitch__link--4 .pitch__link-glow {
  stroke: var(--violet-400);
  stroke-width: 16px;
  opacity: 0.55;
}
.pitch__link--4 .pitch__link-core {
  opacity: 1;
}
.pitch__link--4 .pitch__link-gap {
  stroke: #3a2470;
  stroke-width: 2px;
}
.pitch__link--4 .pitch__link-flow {
  animation-duration: 1.4s;
}
.pitch__link--4 .pitch__link-core,
.pitch__link--4 .pitch__link-gap {
  stroke-dasharray: 100;
  animation: duo-draw 700ms var(--ease-out) both;
}
.pitch .pitch__link--4,
.pitch.has-link-focus .pitch__link--4 {
  opacity: 1;
}
@keyframes duo-draw {
  from {
    stroke-dashoffset: 100;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion='full']) .pitch__link--4 .pitch__link-core,
  :root:not([data-motion='full']) .pitch__link--4 .pitch__link-gap {
    animation: none;
  }
}
:root[data-motion='reduce'] .pitch__link--4 .pitch__link-core,
:root[data-motion='reduce'] .pitch__link--4 .pitch__link-gap {
  animation: none;
}
@keyframes link-flow {
  from {
    stroke-dashoffset: 100;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion='full']) .pitch__link-flow {
    display: none;
  }
}
:root[data-motion='reduce'] .pitch__link-flow {
  display: none;
}
/* Link modes: 'quiet' (a busy pitch) keeps every link visible but lighter; a hovered/focused or
   selected player lights his own links and fades the rest. 'focus' draws only those. */
.pitch--links-quiet .pitch__link,
.pitch--links-focus .pitch__link {
  opacity: 0.8;
}
.pitch--links-quiet .pitch__link-flow,
.pitch--links-focus .pitch__link-flow {
  opacity: 0.5;
}
.pitch.has-link-focus .pitch__link {
  opacity: 0.15;
}
.pitch.has-link-focus .pitch__link.is-on {
  opacity: 1;
  --link-w: 3.5px;
}
.pitch.has-link-focus .pitch__link.is-on .pitch__link-flow {
  opacity: 1;
}
.pitch__slots {
  position: absolute;
  inset: 0;
}

/* Slot */
.pitch-slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: calc(var(--token) * 1.9);
  transform: translate(-50%, calc(var(--token) * -0.5));
  border: 0;
  padding: 0;
  background: none;
  color: var(--text-1);
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
button.pitch-slot {
  cursor: pointer;
}
.pitch-slot:focus-visible {
  outline: none;
}
.pitch-slot:focus-visible .pitch-slot__ring {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
.pitch-slot__ring {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--token);
  height: var(--token);
  border-radius: 50%;
  transition:
    transform var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-base) var(--ease-out);
}
.pitch-slot__token {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 2.5px;
  background: var(--tier-starter-frame);
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.5);
}
.pitch-slot__token--superstar {
  background: var(--tier-superstar-frame);
}
.pitch-slot__token--star {
  background: var(--tier-star-frame);
}
.pitch-slot__token--normal {
  background: var(--tier-normal-frame);
}
/* The top two tiers stand out a little: a thin ring in the tier's colour around the token. */
.pitch-slot__token--superstar {
  outline: 1.5px solid color-mix(in srgb, var(--tier-superstar) 80%, transparent);
  outline-offset: 1.5px;
}
.pitch-slot__token--star {
  outline: 1.5px solid color-mix(in srgb, var(--tier-star) 70%, transparent);
  outline-offset: 1.5px;
}
.pitch-slot__token--bench {
  background: var(--tier-bench-frame);
}
/* Drafted from a Golden Spin: a soft gold aura around the token — no ring of its own (the
   tier's ring stays). Shadows only: the token's box does not grow. */
.pitch-slot__token--golden {
  box-shadow:
    0 0 6px 2px rgb(245 200 76 / 0.55),
    0 0 16px 7px rgb(245 200 76 / 0.38),
    0 0 28px 12px rgb(245 200 76 / 0.16),
    0 3px 8px rgb(0 0 0 / 0.5);
}
.pitch-slot__token--hidden {
  background: var(--tier-hidden-frame);
}
.pitch-slot__face {
  display: grid;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}
.pitch-slot__face .flag,
.pitch-slot__face .crest {
  --flag-h: 100% !important;
  --flag-w: 100% !important;
  --crest: calc(var(--token) - 5px) !important;
  width: 100%;
  height: 100%;
  box-shadow: none;
}
.pitch-slot__token--empty {
  padding: 0;
  background: rgb(3 25 12 / 0.38);
  border: 2px dashed rgb(236 255 240 / 0.45);
  box-shadow: none;
}
.pitch-slot__role {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: calc(var(--token) * 0.3);
  font-weight: var(--weight-heavy);
  letter-spacing: 0.04em;
  color: rgb(236 255 240 / 0.9);
  pointer-events: none;
}
/* The selected player's overall in an open slot: the number to compare positions by. */
.pitch-slot__rating {
  font-family: inherit;
  font-size: calc(var(--token) * 0.42);
  letter-spacing: 0;
  color: #fff;
}
.pitch-slot.is-fit-best .pitch-slot__rating {
  color: var(--volt-400);
  font-size: calc(var(--token) * 0.48);
}
.pitch-slot.is-fit-penalty .pitch-slot__rating {
  color: var(--amber-400);
}
.pitch-slot.is-fit-neutral .pitch-slot__rating {
  color: rgb(236 255 240 / 0.6);
}
.pitch-slot__ovr {
  position: absolute;
  left: 50%;
  bottom: calc(var(--token) * -0.12);
  transform: translateX(-50%);
  min-width: calc(var(--token) * 0.52);
  padding: 1px 4px 0;
  border-radius: 5px;
  background: var(--tier-starter-frame);
  color: #0b0f18;
  font-size: calc(var(--token) * 0.27);
  font-weight: var(--weight-heavy);
  line-height: 1.1;
  text-align: center;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.55);
}
.pitch-slot__token--superstar .pitch-slot__ovr {
  background: var(--tier-superstar-frame);
}
.pitch-slot__token--star .pitch-slot__ovr {
  background: var(--tier-star-frame);
}
.pitch-slot__token--normal .pitch-slot__ovr {
  background: var(--tier-normal-frame);
}
.pitch-slot__token--bench .pitch-slot__ovr {
  background: var(--tier-bench-frame);
  color: var(--text-1);
}
/* A little wider than the slot (centred, it spills evenly both ways): "Matheus Cunha" and
   "Bruno Guimarães" fit whole. Between close neighbours PitchView's fitNames narrows it (an
   inline max-width) so it never runs into the next slot; a short name lends its room. */
.pitch-slot__name {
  width: max-content;
  max-width: calc(var(--token) * 2.15);
  margin-top: calc(var(--token) * 0.14);
  padding: 1px 5px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgb(3 12 8 / 0.55);
  font-size: var(--label);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
}
.pitch-slot__fit {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.5));
}
.pitch-slot.is-filled .pitch-slot__fit {
  bottom: calc(100% + 2px);
}
.pitch-slot__fit .fit-tag {
  background-color: rgb(6 14 10 / 0.92);
  box-shadow: inset 0 0 0 1px currentColor;
}
.pitch-slot__fit .fit-tag--best {
  background: var(--volt-400);
  box-shadow: none;
}

/* Hover / selection / fit states */
button.pitch-slot:hover .pitch-slot__ring {
  transform: scale(1.06);
}
.pitch-slot.is-selected .pitch-slot__ring {
  transform: scale(1.1);
  box-shadow:
    0 0 0 3px var(--volt-400),
    0 0 18px 2px var(--volt-glow);
}
/* Press and hold (PitchView onHold): no OS long-press behaviours on the slots; the token lifts
   while it is held (after a beat, so a plain tap barely moves it) and stays lifted while picked. */
.pitch--holdable .pitch-slot {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.pitch--holdable .pitch-slot img,
.pitch--holdable .pitch-slot svg {
  -webkit-user-drag: none;
  pointer-events: none;
}
.pitch--holdable .pitch-slot.is-pressing .pitch-slot__ring {
  transform: scale(1.16) translateY(-3px);
  box-shadow:
    0 0 0 3px var(--volt-400),
    0 10px 18px rgb(0 0 0 / 0.55);
  transition:
    transform var(--dur-slow) var(--ease-out) var(--dur-instant),
    box-shadow var(--dur-slow) var(--ease-out) var(--dur-instant);
}
.pitch--holdable .pitch-slot.is-selected .pitch-slot__ring {
  transform: scale(1.14) translateY(-3px);
  box-shadow:
    0 0 0 3px var(--volt-400),
    0 10px 18px rgb(0 0 0 / 0.55),
    0 0 18px 2px var(--volt-glow);
}
.pitch-slot.is-fit-best .pitch-slot__ring,
.pitch-slot.is-fit-ok .pitch-slot__ring {
  box-shadow: 0 0 0 3px var(--green-400);
}
.pitch-slot.is-fit-best .pitch-slot__ring {
  box-shadow: 0 0 0 3px var(--volt-400);
  --pulse-color: rgb(205 245 69 / 0.55);
  animation: pulse-ring 1.6s var(--ease-out) infinite;
}
.pitch-slot.is-fit-ok .pitch-slot__token--empty,
.pitch-slot.is-fit-best .pitch-slot__token--empty {
  border-style: solid;
  border-color: transparent;
  background: rgb(205 245 69 / 0.16);
}
.pitch-slot.is-fit-penalty .pitch-slot__ring {
  box-shadow: 0 0 0 3px var(--amber-400);
}
.pitch-slot.is-fit-penalty .pitch-slot__token--empty {
  border-style: solid;
  border-color: transparent;
  background: rgb(255 181 71 / 0.16);
}
.pitch-slot.is-fit-swap .pitch-slot__ring {
  box-shadow: 0 0 0 3px var(--sky-400);
}
.pitch-slot.is-fit-blocked {
  cursor: not-allowed;
}
.pitch-slot.is-fit-blocked .pitch-slot__ring {
  opacity: 0.4;
}
.pitch-slot.is-fit-blocked .pitch-slot__token--empty {
  border-color: rgb(255 111 97 / 0.7);
}
button.pitch-slot.is-fit-blocked:hover .pitch-slot__ring {
  transform: none;
}
.pitch-slot__face .flag .flag__initials {
  font-size: calc(var(--token) * 0.34);
}
.pitch-slot__face .flag[data-code='3'] .flag__initials {
  font-size: calc(var(--token) * 0.28);
}
/* The boost chip (mates): green, on the token's other shoulder. */
.pitch-slot__boost {
  position: absolute;
  top: calc(var(--token) * -0.08);
  right: calc(var(--token) * -0.2);
  z-index: 1;
  min-width: calc(var(--token) * 0.46);
  padding: 1px 3px 0;
  border-radius: 999px;
  background: var(--green-400);
  color: #04130a;
  font-size: calc(var(--token) * 0.25);
  font-weight: var(--weight-heavy);
  line-height: 1.15;
  text-align: center;
  box-shadow:
    0 0 0 1.5px rgb(3 12 8 / 0.75),
    0 1px 4px rgb(0 0 0 / 0.5);
}

/* The marks (PitchView TokenMarks): compact symbols, two to a row, on the token's top-left
   shoulder — the boost chip has the other one. Never past 0.26 of a token beyond the disc, so
   a neighbour one and a half tokens away keeps clear (tests/browser/flows.mjs pitch-tokens). */
.pitch-slot__marks {
  position: absolute;
  top: calc(var(--token) * -0.08);
  left: calc(var(--token) * -0.26);
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  width: calc(var(--mark) * 2 + 2px);
  pointer-events: none;
}
.pitch-slot__marks > * {
  width: var(--mark);
  height: var(--mark);
  padding: 0;
  border-radius: 50%;
  font-size: calc(var(--mark) * 0.7);
}
.pitch-slot__marks .icon {
  width: 72%;
  height: 72%;
}
/* A double (Captain and Game Changer): one pill over both cells, C and the bolt. */
.pitch-slot__marks > .pitch-slot__double {
  display: inline-flex;
  justify-content: center;
  gap: 1px;
  width: calc(var(--mark) * 2 + 2px);
  border-radius: 999px;
}
.pitch-slot__double .double-mark__c {
  font-size: calc(var(--mark) * 0.75);
}
.pitch-slot__double .icon {
  width: auto;
  height: 72%;
}
.pitch-slot__marks .gc-mark--t1::before {
  inset: -3px;
}
/* An era card's year ("’18"): gold, under the armband corner. */
.pitch-slot__era {
  position: absolute;
  left: calc(var(--token) * -0.24);
  bottom: calc(var(--token) * 0.02);
  z-index: 1;
  padding: 1px 3px 0;
  border-radius: 4px;
  background: linear-gradient(160deg, var(--gold-300), var(--gold-500));
  color: var(--on-gold);
  font-size: calc(var(--token) * 0.23);
  font-weight: var(--weight-heavy);
  line-height: 1.15;
  box-shadow: 0 0 0 1.5px rgb(3 12 8 / 0.75);
}
/* A Prime boost is available for him: a small gold spark. */
.pitch-slot__prime {
  position: absolute;
  right: calc(var(--token) * -0.12);
  bottom: calc(var(--token) * 0.02);
  z-index: 1;
  width: calc(var(--token) * 0.24);
  height: calc(var(--token) * 0.24);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--gold-400) 55%, var(--gold-500));
  box-shadow:
    0 0 0 1.5px rgb(3 12 8 / 0.75),
    0 0 6px rgb(245 200 76 / 0.7);
}

/* A Game Changer of tier 1 or 2 on the pitch: a holographic ring; the bolt sits where the
   armband would be. */
.pitch-slot__token--gc .pitch-slot__face {
  box-shadow:
    0 0 0 2px #f5c84c,
    0 0 0 4px rgb(155 231 255 / 0.45),
    0 0 14px rgb(245 200 76 / 0.6);
}
/* A duo just completed (pulse): its tokens pulse once and the duo lines flare. */
.pitch-slot.is-pulse .pitch-slot__ring {
  animation: duo-token-pulse 1.1s var(--ease-out) 1;
}
.pitch.has-pulse .pitch__link--4 .pitch__link-glow {
  animation: duo-line-flare 1.2s var(--ease-out) 1;
}
@keyframes duo-token-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.22);
  }
  60% {
    transform: scale(0.96);
  }
}
@keyframes duo-line-flare {
  0%,
  100% {
    opacity: 0.55;
  }
  35% {
    opacity: 1;
  }
}
