/* Phase B: match interaction and complete player-data workspace. */
.momentum-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.momentum-legend > span { min-width: 0; display: grid; grid-template-columns: 28px 1fr; align-items: center; column-gap: 9px; }
.momentum-legend > span:last-child { text-align: right; grid-template-columns: 1fr 28px; }
.momentum-legend > span:last-child .team-identity { grid-column: 2; grid-row: 1/3; }
.momentum-legend b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.momentum-legend small { grid-column: 2; color: var(--text-secondary); }
.momentum-legend > span:last-child small { grid-column: 1; }
.momentum { min-height: 220px; padding: 6px 0; overflow: visible; }
.momentum-zero { stroke: var(--text-muted); stroke-width: .65; }
.momentum-guide { stroke: var(--border-subtle); stroke-width: .34; stroke-dasharray: 1.5 1.5; }
.momentum-guide.half { stroke: var(--border-strong); stroke-width: .55; }
.momentum-bar { transition: opacity var(--motion-base) var(--motion-ease), filter var(--motion-base) var(--motion-ease); }
.momentum-bar:hover { opacity: 1; filter: brightness(1.3); }
/* Keyboard focus must stay visible. The SVG rect cannot take an outline
   reliably across engines, so the indicator is a stroke on the bar itself. */
.momentum-bar:focus-visible {
  opacity: 1;
  filter: brightness(1.3);
  outline: none;
  stroke: var(--focus-ring);
  stroke-width: 1.6;
  paint-order: stroke;
}

.timeline-filters { display: flex; gap: 7px; margin-bottom: 16px; overflow-x: auto; }
.filter-chip, .segmented-control button, .swap-ends, .shot-player-filter button {
  min-height: 44px; padding: 9px 13px; color: var(--text-secondary); background: var(--surface-sunken);
  border: 1px solid var(--border-strong); border-radius: var(--radius-control); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.filter-chip:hover, .filter-chip.active, .segmented-control button:hover,
.segmented-control button.active, .swap-ends:hover, .swap-ends.active,
.shot-player-filter button:hover, .shot-player-filter button.active {
  color: var(--text-on-accent); background: var(--surface-overlay); border-color: var(--border-strong);
}

/* The quiet counterpart to a filter chip: a reset that has to be findable
   without competing with the control it clears. It shipped with no rule at all
   and was rendering as a default browser button. */
.ghost-button {
  min-height: 44px; padding: 9px 13px; color: var(--text-secondary); background: none;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-control);
  font: inherit; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.ghost-button:hover, .ghost-button:focus-visible {
  color: var(--text-on-accent); background: var(--surface-overlay); border-color: var(--border-strong);
}
.timeline-row {
  position: relative; display: grid; grid-template-columns: 52px 34px 34px minmax(0,1fr) auto;
  gap: 11px; align-items: center; min-height: 70px; padding: 10px 8px 10px 12px;
  border-bottom: 1px solid var(--border-subtle); font-size: 14px;
}
.timeline-row::before { content: ""; position: absolute; inset: 9px auto 9px 0; width: 3px; background: var(--brand-secondary); }
.timeline-row.basel::before { background: var(--brand-primary); }
.timeline-row time { color: var(--info-text); font-weight: 800; font-variant-numeric: tabular-nums; }
.timeline-people { min-width: 0; }
.timeline-people strong { display: flex; align-items: center; gap: 9px; }
.timeline-people strong > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-people > small { display: flex; align-items: center; gap: 7px; margin-top: 5px; color: var(--text-secondary); }
.timeline-people .event-icon, .participant-icon { width: 23px; height: 23px; display: inline-grid; place-items: center; flex: none; background: transparent; border: 0; }
.timeline-people .event-icon svg, .participant-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.timeline-score { min-width: 42px; padding: 5px 7px; color: var(--text-on-accent); background: var(--surface-overlay); text-align: center; }

/* Half headers. Without them a match whose first half had no goal, card or
   substitution appeared to start at 45′ with its data missing. */
.timeline-half + .timeline-half { margin-top: 18px; }
.timeline-half > h4 {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 6px; padding-bottom: 6px; color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}
.timeline-half > h4 span { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.timeline-quiet { margin: 0; padding: 14px 12px; color: var(--text-muted); font-size: 13px; }

/* Both players in a change carry the same weight: one is not a footnote to
   the other, and at a glance the pair reads as the swap it was. */
.timeline-swap { display: grid; gap: 6px; }
.timeline-swap strong { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.timeline-swap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-swap i {
  flex: none; margin-left: auto; padding: 2px 7px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-round); font-size: 12px; font-style: normal;
  font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.timeline-swap .swap-on { color: var(--success-on-subtle); background: var(--success-subtle); border-color: var(--success-subtle); }
.timeline-swap .swap-off { color: var(--text-muted); }

.shot-explorer { display: grid; gap: 16px; }
.shot-controls { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px; }
.segmented-control { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented-control button { display: inline-flex; align-items: center; gap: 8px; }
.shot-layout { grid-template-columns: minmax(0, 1.25fr) minmax(390px, .75fr); gap: 22px; }
.shot-visual-column { display: grid; align-content: start; gap: 16px; }
.shot-pitch-wrap { padding: 20px; }
.shot-map { background: var(--pitch-surface); }
.shot-point { cursor: pointer; }
.shot-hit { fill: transparent; pointer-events: all; }
.shot-point .shot-dot { stroke: var(--text-on-accent); stroke-width: .65; transition: r .15s, opacity .15s; }
.shot-point.basel .shot-dot { fill: var(--brand-primary); }
.shot-point.opponent .shot-dot { fill: var(--brand-secondary); }
.shot-point.goal .shot-dot { fill: var(--goal-marker); }
.shot-point.missed .shot-dot { opacity: .58; }
/* Hover and focus lift a mark by opacity and a ring, not by growing it.
   Growing on hover made a crowded box shuffle under the pointer. */
.shot-point:hover .shot-dot, .shot-point:focus .shot-dot { opacity: 1; }
.shot-point.selected .shot-dot { opacity: 1; stroke-width: .9; }
.shot-point:focus { outline: none; }
/* Rings, not fills: the hit circle is only a little wider than the dot now, so
   a filled disc over it would hide the mark it belongs to. */
.shot-point:focus .shot-hit { fill: none; stroke: var(--focus-ring); stroke-width: .5; }
.shot-point.selected .shot-hit { fill: none; stroke: var(--text-on-accent); stroke-width: .45; }
/* A goal is marked by size and colour. It is not the attempt the reader
   picked, and giving it the selected ring made every goal look chosen. */
.shot-point.goal-highlight .shot-dot { stroke-width: .9; }
.shot-direction { display: flex; justify-content: space-between; gap: 16px; margin-top: 11px; color: var(--text-secondary); font-size: 12px; }
.shot-direction span { display: flex; align-items: center; gap: 7px; }
.shot-direction span:last-child { margin-left: auto; text-align: right; }
.shot-list { max-height: 850px; padding: 0; overflow: hidden; }
.shot-list-head { padding: 20px 20px 10px; background: var(--surface-raised); border-bottom: 1px solid var(--border-subtle); }
.shot-player-filter { display: flex; gap: 7px; padding-bottom: 10px; overflow-x: auto; }
.shot-player-filter button { display: flex; align-items: center; gap: 8px; }
.shot-rows { max-height: 650px; overflow: auto; scrollbar-color: var(--border-subtle) var(--surface-raised); }
.shot-item {
  width: 100%; min-height: 78px; display: grid; grid-template-columns: 44px 32px 34px minmax(0,1fr) auto;
  gap: 9px; align-items: center; padding: 10px 13px; color: var(--text-primary); background: transparent;
  border: 0; border-bottom: 1px solid var(--border-subtle); border-radius: 0; font-size: 14px; text-align: left;
}
.shot-item:hover, .shot-item.selected { background: var(--surface-overlay); }
.shot-item.selected { box-shadow: inset 4px 0 var(--brand-accent); }
.shot-copy { min-width: 0; }
.shot-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-copy small { display: block; margin-top: 3px; color: var(--text-secondary); line-height: 1.35; }
.selected-shot-card { overflow: hidden; }
/* Five children — crest, face, name, result, stepper — and the track list had
   four entries, so the stepper wrapped onto a second row and landed in the
   34px crest column, where its buttons were squeezed to slivers and "3 / 26"
   broke over three lines. The stepper gets its own track. */
.selected-shot-head { display: grid; grid-template-columns: 34px 64px minmax(0,1fr) auto auto; gap: 12px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border-subtle); }
.selected-shot-head h3 { margin: 3px 0; }
.selected-shot-head small, .selected-shot-head span { color: var(--text-secondary); }
.shot-result { padding: 7px 9px; color: var(--text-on-accent); background: var(--brand-secondary); font-size: 12px; text-transform: uppercase; }
.shot-result.goal { color: var(--warning-ink); background: var(--goal-marker); }
.shot-result.blocked { background: var(--shot-blocked); }
.shot-result.woodwork { color: var(--warning-ink); background: var(--warning-surface); }
.selected-shot-body { display: grid; grid-template-columns: minmax(300px,1.2fr) minmax(230px,.8fr); gap: 18px; padding: 20px; }
/* One goal, always the same size. The frame itself carries no data, so scaling
   it per attempt only made two attempts impossible to compare. */
.goal-view-wrap { display: grid; align-content: center; padding: 14px; background: linear-gradient(var(--surface-sunken), var(--surface-raised)); border: 1px solid var(--border-subtle); }
.goal-view-wrap .goal-frame { max-width: 100%; }
.goal-frame .goal-ball.goal { fill: var(--goal-marker); }
.goal-frame .goal-ball.blocked { fill: var(--shot-blocked-mark); }
.goal-frame .goal-ball.woodwork { fill: var(--warning-surface); }
.goal-view-note { display: flex; justify-content: space-between; gap: 14px; margin-top: 8px; color: var(--text-secondary); font-size: 12px; }

/* --- Blocked: the end of the pitch instead of a goal it never reached ----- */

.block-view {
  display: block;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  overflow: visible;      /* the goal frame is drawn above y=0 */
}

.block-turf { fill: var(--pitch-surface); }
.block-lines { fill: none; stroke: var(--overlay-medium); stroke-width: .3; }
.block-goal { fill: none; stroke: var(--text-primary); stroke-width: .5; }
.block-goal-line { stroke: var(--overlay-strong); stroke-width: .3; }

/* The ground the ball actually covered, from the strike to where it was
   stopped. Dashed because it is the inference between two measured points,
   not a tracked path. */
.block-travel { stroke: var(--text-on-accent); stroke-width: .3; stroke-dasharray: 1 .8; opacity: .8; }
.block-strike { fill: none; stroke: var(--text-on-accent); stroke-width: .45; }

/* The block itself, as a cross: it is the event the figure is about, and a
   second dot would have read as a second shot. */
.block-point circle { fill: var(--shot-blocked-mark); }
.block-point path { stroke: var(--surface-base); stroke-width: .4; fill: none; }

.goal-view-note.blocked { display: grid; gap: 4px; color: var(--text-muted); }
.goal-view-note.blocked strong { color: var(--text-secondary); }
.shot-detail-grid, .drawer-profile dl { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; background: var(--border-subtle); }
.shot-detail-grid > div, .drawer-profile dl > div { padding: 12px; background: var(--surface-sunken); }
.shot-detail-grid .wide { grid-column: 1/-1; }
.shot-detail-grid dt, .drawer-profile dt { color: var(--text-secondary); font-size: 12px; text-transform: uppercase; }
.shot-detail-grid dd, .drawer-profile dd { margin: 5px 0 0; font-weight: 800; }

.formation-card { padding: 20px; }
.formation-pitch { height: 650px; }
.formation-player {
  position: absolute; z-index: 2; width: 136px; min-height: 0; padding: 3px; transform: translate(-50%,-50%);
  color: var(--text-on-accent); background: transparent; border: 0; border-radius: 4px; text-align: center;
}
.formation-player:hover, .formation-player:focus { background: var(--scrim-soft); }
.formation-player .formation-face { position: relative; display: block; width: 44px; height: 44px; margin: 0 auto; overflow: visible; }
.formation-player .formation-face > .identity-image { display: inline-grid; }
.formation-player > strong { display: block; margin-top: 4px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px var(--surface-base); }
.formation-player > small { display: block; overflow: hidden; color: var(--text-primary); font-size: 12px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px var(--surface-base); }
.player-facts { display: flex !important; justify-content: center; gap: 3px; margin-top: 4px; overflow: visible !important; }
.player-facts > span { display: inline-flex; align-items: center; gap: 2px; padding: 2px 3px; color: var(--text-on-accent); background: var(--scrim-strong); font-size: 12px; }
.player-facts .event-icon, .player-facts .participant-icon { width: 17px; height: 17px; border: 0; background: transparent; }
.player-facts svg { width: 15px; height: 15px; }
.bench { margin-top: 18px; }
.bench-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.bench-player { min-height: 60px; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 9px; align-items: center; padding: 8px; color: var(--text-primary); background: var(--surface-sunken); border: 1px solid var(--border-strong); text-align: left; }
.bench-player:hover { background: var(--surface-overlay); }
.bench-player strong, .bench-player small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench-player small { margin-top: 3px; color: var(--text-secondary); }

.player-stat-workspace { display: grid; gap: 16px; }
.player-table-controls { display: flex; align-items: end; gap: 16px; padding: 13px; flex-wrap: wrap; }
.player-table-controls label { display: grid; gap: 5px; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; }
.player-table-controls .display-control { margin-left: auto; }
/* `overflow: hidden` here clipped the table's own scroller, so the columns past
   the right edge could not be reached at all. The panel clips nothing; the
   scroller inside it does the scrolling. */
/* Grid items default to min-width:auto, so the scroller grew to its widest
   column and pushed the page sideways instead of scrolling inside itself —
   which is why the right-hand columns could not be reached at all. */
.player-stat-workspace, .player-metric-table { min-width: 0; }
.player-metric-table > .panel-title { margin: 0; padding: 18px 20px; }
.player-metric-table .table-frame, .player-metric-table .table-frame-scroll { max-width: 100%; }
.player-metric-table .compare-legend { padding: 0 20px 12px; }
.table-note { margin: 0; padding: 0 20px 14px; color: var(--text-muted); font-size: 12px; }
.full-player-table { min-width: max-content; }
/* Abbreviated headings, so a screen holds a useful number of columns. */
.full-player-table th, .full-player-table td { min-width: 74px; height: 46px; padding: 7px 9px; white-space: nowrap; }
.full-player-table th abbr { border: 0; text-decoration: none; cursor: help; }
.full-player-table th small, .full-player-table td small { display: block; margin-top: 3px; color: var(--text-secondary); }
.full-player-table .sticky-player { position: sticky; left: 0; z-index: 2; min-width: 200px; background: var(--surface-raised); box-shadow: 1px 0 var(--border-subtle); }
.full-player-table thead .sticky-player { z-index: 3; background: var(--surface-sunken); }
.player-table-controls .position-control { flex-wrap: wrap; }
.table-player.player-open { width: 100%; min-height: 44px; padding: 0; color: var(--text-primary); background: transparent; border: 0; text-align: left; }

.drawer-open { overflow: hidden; }
.drawer-backdrop { position: fixed; z-index: 80; inset: 0; background: var(--backdrop); backdrop-filter: blur(3px); }
.player-drawer { position: fixed; z-index: 81; inset: 0 0 0 auto; width: min(720px, 94vw); padding: 26px; overflow-y: auto; color: var(--text-primary); background: var(--surface-raised); border-left: 1px solid var(--border-subtle); box-shadow: var(--elevation-drawer); }
.drawer-close { position: sticky; z-index: 2; top: 0; float: right; width: 46px; height: 46px; display: grid; place-items: center; color: var(--text-on-accent); background: var(--surface-overlay); border: 1px solid var(--border-strong); font-size: 28px; }
.player-drawer > header { display: grid; grid-template-columns: 112px 1fr; gap: 20px; align-items: center; padding: 22px 54px 24px 0; border-bottom: 1px solid var(--border-subtle); }
.player-identity.drawer-large { width: 112px; height: 126px; border-radius: 0; }
.player-identity.drawer { width: 64px; height: 64px; }
.player-drawer header > div > span { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 12px; }
.player-drawer h2 { margin: 7px 0; font-size: 38px; }
.player-drawer header p { margin: 0; color: var(--text-secondary); }
.drawer-profile, .drawer-events, .drawer-spatial, .drawer-statistics { margin-top: 24px; }
.drawer-profile dd small { display: block; margin-top: 4px; color: var(--text-secondary); font-weight: 400; }
.drawer-events { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drawer-events h3 { width: 100%; }
.drawer-events > span { display: flex; align-items: center; gap: 5px; min-height: 40px; padding: 7px 9px; background: var(--surface-sunken); border: 1px solid var(--border-subtle); }
.drawer-spatial { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drawer-spatial h3, .drawer-statistics > h3 { margin-bottom: 10px; }
.drawer-stat-group { margin-top: 18px; }
.drawer-stat-group h4 { padding-bottom: 8px; color: var(--interactive-active); border-bottom: 1px solid var(--border-subtle); font-size: 14px; text-transform: uppercase; }
.drawer-stat-group dl { margin: 0; }
.drawer-stat-group dl > div { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); }
.drawer-stat-group dt { color: var(--text-secondary); }
.drawer-stat-group dd { margin: 0; font-weight: 700; text-align: right; }
.drawer-player-link { display: block; margin-top: 24px; padding: 14px; background: var(--surface-overlay); font-weight: 800; text-align: center; }

@media (max-width: 1050px) {
  .shot-layout { grid-template-columns: 1fr; }
  .shot-list { max-height: none; }
  .shot-rows { max-height: 580px; }
  .selected-shot-body { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .timeline-row { grid-template-columns: 45px 32px 28px minmax(0,1fr); }
  .timeline-score { grid-column: 4; justify-self: start; }
  .shot-controls { align-items: stretch; flex-direction: column; }
  .swap-ends { align-self: flex-start; }
  .selected-shot-head { grid-template-columns: 32px 54px minmax(0,1fr); }
  /* Both trailing controls drop under the name rather than squeezing the row:
     the result reads as a label of the attempt, the stepper as the way to the
     next one, so they share a line in that order. */
  .selected-shot-head .shot-result { grid-column: 3; justify-self: start; }
  .selected-shot-head .shot-stepper { grid-column: 3; justify-self: start; margin-inline-start: 0; }
  .formation-pitch { height: 590px; }
  .formation-player { width: 112px; }
  .bench-grid { grid-template-columns: 1fr; }
  .player-table-controls .display-control { margin-left: 0; }
  .player-drawer { width: 100vw; }
}

@media (max-width: 520px) {
  .momentum-legend { grid-template-columns: 1fr; }
  .momentum-legend > span:last-child { text-align: left; grid-template-columns: 28px 1fr; }
  .momentum-legend > span:last-child .team-identity { grid-column: 1; }
  .momentum-legend > span:last-child small { grid-column: 2; }
  .timeline-row { grid-template-columns: 40px 32px minmax(0,1fr); gap: 7px; }
  .timeline-row > .team-identity { display: none; }
  .timeline-score { grid-column: 3; }
  .shot-pitch-wrap, .selected-shot-body, .shot-list-head { padding: 14px; }
  .shot-item { grid-template-columns: 38px 28px 30px minmax(0,1fr); }
  .shot-item > .xg-chip { display: none; }
  .selected-shot-head { grid-template-columns: 30px 48px minmax(0,1fr); padding: 14px; }
  .selected-shot-head > .shot-result { grid-column: 1/-1; }
  .goal-view-note { align-items: start; flex-direction: column; }
  .shot-detail-grid, .drawer-profile dl { grid-template-columns: 1fr; }
  .formation-pitch { height: 560px; }
  .formation-player { width: 96px; }
  .formation-player > small { display: none; }
  .player-drawer { padding: 18px; }
  .player-drawer > header { grid-template-columns: 82px 1fr; gap: 13px; padding-right: 45px; }
  .player-identity.drawer-large { width: 82px; height: 94px; }
  .player-drawer h2 { font-size: 28px; }
  .drawer-spatial { grid-template-columns: 1fr; }
}

/* --- Goals on the momentum chart ------------------------------------------ */

/* The chart stretches horizontally (preserveAspectRatio="none"), so only the
   stem lives in the SVG — a vertical line is the one shape a horizontal stretch
   leaves alone. Everything with a shape or a glyph sits in this overlay. */
.momentum-wrap { position: relative; }

.momentum-goals {
  position: absolute;
  inset: 6px 0;
  pointer-events: none;
}

.momentum-goal {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 2px;
  transform: translateX(-50%);
  pointer-events: auto;
}

/* Above the line for the home side, below for the away side — the same halves
   their pressure bars occupy, so a goal against the run of play shows up as a
   marker on the thin side. */
.momentum-goal.home { bottom: 50%; margin-bottom: 3px; }
.momentum-goal.away { top: 50%; margin-top: 3px; grid-template-areas: "m" "d"; }
.momentum-goal.away i { grid-area: d; }
.momentum-goal.away b { grid-area: m; }

.momentum-goal i {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-round);
  border: 2px solid var(--surface-raised);
}

.momentum-goal.home i { background: var(--team-home); }
.momentum-goal.away i { background: var(--team-away); }

.momentum-goal b {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  background: var(--surface-raised);
  padding: 0 3px;
  white-space: nowrap;
}

.momentum-goal-stem { stroke: var(--text-muted); stroke-width: .28; stroke-dasharray: .8 .8; }
