/* --- 1. MATCH EVENTS TIMELINE --- */
.timeline-container { position: relative; padding: 20px 0; }
.timeline-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: #e9ecef; transform: translateX(-50%); z-index: 1; }
.event-row { position: relative; margin-bottom: 25px; z-index: 2; }
.event-card { 
    background: #fff; padding: 10px 15px; border-radius: 8px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); border: 1px solid #f0f0f0; 
    font-size: 0.9rem; width: 100%; position: relative; 
}
.event-card.home { border-right: 4px solid #0d6efd; text-align: right; }
.event-card.away { border-left: 4px solid #dc3545; text-align: left; }

.event-time-badge { 
    background: #fff; border: 2px solid #e9ecef; color: #555; 
    font-weight: 700; font-size: 0.85rem; width: 40px; height: 40px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    margin: 0 auto; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Event Icons */
.ev-goal { margin-right: 5px; } 
.ev-card-y { color: #ffc107; font-size: 1.1em; }
.ev-card-r { color: #dc3545; font-size: 1.1em; }
.ev-sub { color: #28a745; font-size: 0.9em; margin-right: 4px; }
.ev-var { font-weight: 800; border: 1px solid #333; padding: 1px 4px; border-radius: 3px; font-size: 0.7em; margin-right: 4px; }

/* --- 2. INLINE REPLACEMENTS --- */
.chart-container { position: relative; width: 100%; min-height: 520px; }
@media (max-width: 992px) { .chart-container { min-height: 680px; } }
@media (max-width: 576px) { .chart-container { min-height: 700px; } }

.ppm-chart,
#ppm-chart {
  width: 100%;
  height: 420px;
  max-width: 95vw;
  background: #eee;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.progress.progress-lg { height: 1.5rem; }
.progress-bar.progress-bar--bold { font-weight: 600; }
.bench-number-badge { min-width: 25px; }

.timeline-marker { z-index: 10; cursor: pointer; }
.timeline-marker--at { left: calc(var(--pct) * 1%); }
.timeline-card-rect { width: 12px; height: 16px; border-radius: 2px; }
.timeline-badge-circle { width: 26px; height: 26px; padding: 0; font-size: 0.8rem; }
.timeline-minute-badge { font-size: 0.7rem; }
.timeline-track { height: 4px; background-color: #e9ecef; border-radius: 2px; }
.timeline-detail-col { width: 30px; text-align: center; }
.timeline-score-badge { min-width: 45px; }

.h2h-pos-text { font-size: 0.8em; }
.h2h-highlight-img { height: 200px; width: auto; object-fit: cover; }

.bg-teama { background-color: var(--team-a, #7A1BA8); }
.bg-teamb { background-color: var(--team-b, #F56EA1); }

/* Container that can scroll horizontally if needed (doesn't affect rest of the page) */
.lineups-pitch-container {
  margin-top: 1rem;
}

/* Single wide pitch (1280×380 example) */
.lineups-pitch {
  width: 90%;   /* Adjust as needed */
  aspect-ratio: 2 / 1;
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  background: none;
}

/* White lines above the grass */
.line-border {
  background: white;
  position: absolute;
  z-index: 2;
}

/* Outer boundary of the pitch */
.outline.line-border {
  border: 4px solid white;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* Vertical center line at 50% (splits left/right) */
.center-line {
  width: 4px;
  height: 100%;
  top: 0;
  left: calc(50% - 2px);
}

/* Center circle */
.center-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid white;
  background: none;
  top: calc(50% - 60px);
  left: calc(50% - 60px);
}

/* Big penalty boxes */
.box {
  top: 25%;
  width: 16%;
  height: 50%;
  background: transparent;
  border: 4px solid white;
}
.box.left {
  left: 0;
}
.box.right {
  right: 0;
}

/* Smaller 6-yard boxes */
.box.small {
  top: 36%;
  width: 8%;
  height: 28%;
}

/* D-shapes outside the box */
.box-d {
  top: 35%;
  width: 15%;
  height: 30%;
  background: transparent;
  border: 4px solid white;
}
.box-d.left {
  left: 5.5%;
  border-left: none;
  border-bottom-right-radius: 1000px;
  border-top-right-radius: 1000px;
  clip-path: inset(0 0 0 70%);
}
.box-d.right {
  right: 5.5%;
  border-right: none;
  border-bottom-left-radius: 1000px;
  border-top-left-radius: 1000px;
  clip-path: inset(0 70% 0 0);
}

/* Penalty spots */
.spot {
  width: 4px;
  height: 4px;
  border-radius: 4px;
  top: calc(50% - 2px);
}
.spot.left {
  left: 11%;
}
.spot.right {
  right: 11%;
}
.spot.center {
  width: 8px;
  height: 8px;
  left: calc(50% - 4px);
}

/* Corner arcs (true quarter circles).
   We draw them with a radial-gradient so they keep looking correct even when the
   pitch is `overflow: visible` (needed for player names / badges). */
:root {
  --htoh-pitch-line: 4px;
  --htoh-corner-r: 22px; /* radius */
}

.corner {
  position: absolute;
  width: var(--htoh-corner-r);
  height: var(--htoh-corner-r);
  z-index: 2;
  pointer-events: none;
  background-repeat: no-repeat;
}

.corner.top.left {
  top: 0;
  left: 0;
  background: radial-gradient(circle at 0 0,
    transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff var(--htoh-corner-r),
    transparent var(--htoh-corner-r)
  );
}
.corner.top.right {
  top: 0;
  right: 0;
  background: radial-gradient(circle at 100% 0,
    transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff var(--htoh-corner-r),
    transparent var(--htoh-corner-r)
  );
}
.corner.bottom.left {
  bottom: 0;
  left: 0;
  background: radial-gradient(circle at 0 100%,
    transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff var(--htoh-corner-r),
    transparent var(--htoh-corner-r)
  );
}
.corner.bottom.right {
  bottom: 0;
  right: 0;
  background: radial-gradient(circle at 100% 100%,
    transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
    #fff var(--htoh-corner-r),
    transparent var(--htoh-corner-r)
  );
}

/* Grass layer (lighter green) behind lines */
.grass {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #5DAC4C; /* Lighter green */
  z-index: 1;
}

/* Player markers */
.player {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #000;  /* black border */
  background-color: #fff;  /* default white */
  color: #000;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3; /* above lines */
  transform: translate(-50%, -50%);
}

/* Mobile adjustments */
/* Base container - on mobile, we hide overflow so no scrolling bar */
  .pitch-vertical {
    width: 90%;
    /* Aspect ratio ~0.5 => vertical (50 wide × 100 tall) */
    aspect-ratio: 50 / 100;
    position: relative;
    margin: 0 auto;
    background: #5DAC4C;  /* Grass */
    overflow: hidden;
    box-sizing: border-box;
  }
  
  /* Outer boundary */
  .pitch-vertical .outline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid white;
    box-sizing: border-box;
  }
  
  /* Center line behind circle & spot (z-index:1) */
  .pitch-vertical .center-line {
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 3px;
    background: white;
    z-index: 1;
  }
  
  /* Center circle in front (z-index:2) - slightly smaller than full 17% for aesthetics */
  .pitch-vertical .center-circle {
    position: absolute;
    width: 20%;       /* diameter */
    height: 10%;
    border: 3px solid white;
    border-radius: 50%;
    top: calc(50% - 5%);   /* half of 16% */
    left: calc(50% - 10%);
    box-sizing: border-box;
  }
  
  .pitch-vertical .spot-center {
    position: absolute;
    top: calc(50% - 0.25%);
    left: calc(50% - 1%);
    width: 2%;
    height: 1%;
    background: white;
    border-radius: 50%;
  }
  
  /* Penalty areas (approx. real proportions) */
  .pitch-vertical .penalty-area-top {
    position: absolute;
    top: 0;
    left: 20%;   /* center horizontally => 50% - (59.3%/2) */
    width: 60%;   /* ~40m wide / 68m total => ~59.3% */
    height: 18%;  /* ~16.5m / 105m => ~15.7% */
    border: 3px solid white;
    box-sizing: border-box;
    background-color: #5DAC4C;
  }
  .pitch-vertical .penalty-area-bottom {
    position: absolute;
    bottom: 0;
    left: 20%;   /* center horizontally => 50% - (59.3%/2) */
    width: 60%;   /* ~40m wide / 68m total => ~59.3% */
    height: 18%;  /* ~16.5m / 105m => ~15.7% */
    border: 3px solid white;
    box-sizing: border-box;
    background-color: #5DAC4C;
  }
  
  /* Six-yard boxes */
  .pitch-vertical .six-yard-box-top {
    position: absolute;
    top: 0;
    left: 32%;   /* 50% - (26.94%/2) */
    width: 36%;  /* ~18.32m / 68m => ~26.94% */
    height: 6%;  /* ~5.5m / 105m => ~5.24% */
    border: 3px solid white;
    border-top: none;
    box-sizing: border-box;
  }
  .pitch-vertical .six-yard-box-bottom {
    position: absolute;
    bottom: 0;
    left: 32%;   /* 50% - (26.94%/2) */
    width: 36%;  /* ~18.32m / 68m => ~26.94% */
    height: 6%;  /* ~5.5m / 105m => ~5.24% */
    border: 3px solid white;
    border-bottom: none;
    box-sizing: border-box;
  }
  
  /* Penalty spots (~11m => ~10.48%) */
  .pitch-vertical .spot-top {
    position: absolute;
    top: 12%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
  }
  .pitch-vertical .spot-bottom {
    position: absolute;
    bottom: 12%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, 50%);
    box-sizing: border-box;
  }
  
  /* Penalty arcs (smaller half-circles) */
  .pitch-vertical .penalty-arc-top {
    position: absolute;
    /* center at penalty spot => top: (spot) - half of arc's height */
    top: calc(12%);
    left: calc(50% - 10%);    
    width: 20%;       /* diameter */
    height: 10%;
    border: 3px solid white;
    /* Open downward => remove top border => half-circle on bottom */
    border-top: none;
    border-radius:0 0 100% 100%;
    box-sizing: border-box;
  }
  
  .pitch-vertical .penalty-arc-bottom {
    position: absolute;
    bottom: calc(12%);
    left: calc(50% - 10%);
    width: 20%;       /* diameter */
    height: 10%;
    border: 3px solid white;
    /* Open upward => remove bottom border => half-circle on top */
    border-bottom: none;
    border-radius: 100% 100% 0 0;
    box-sizing: border-box;
  }
  
  /* Corner arcs (vertical pitch) */
  .pitch-vertical {
    --htoh-pitch-line: 3px;
    --htoh-corner-r: 18px;
  }

  .pitch-vertical .corner {
    position: absolute;
    width: var(--htoh-corner-r);
    height: var(--htoh-corner-r);
    z-index: 2;
    pointer-events: none;
    background-repeat: no-repeat;
  }

  .pitch-vertical .corner-top-left {
    top: 0;
    left: 0;
    background: radial-gradient(circle at 0 0,
      transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff var(--htoh-corner-r),
      transparent var(--htoh-corner-r)
    );
  }
  .pitch-vertical .corner-top-right {
    top: 0;
    right: 0;
    background: radial-gradient(circle at 100% 0,
      transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff var(--htoh-corner-r),
      transparent var(--htoh-corner-r)
    );
  }
  .pitch-vertical .corner-bottom-left {
    bottom: 0;
    left: 0;
    background: radial-gradient(circle at 0 100%,
      transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff var(--htoh-corner-r),
      transparent var(--htoh-corner-r)
    );
  }
  .pitch-vertical .corner-bottom-right {
    bottom: 0;
    right: 0;
    background: radial-gradient(circle at 100% 100%,
      transparent calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff calc(var(--htoh-corner-r) - var(--htoh-pitch-line)),
      #fff var(--htoh-corner-r),
      transparent var(--htoh-corner-r)
    );
  }


  @media (max-width: 767px) {
    .lineups-pitch {
      display: none;
    }
    .pitch-vertical {
      display: block;
    }
  }
  
  /* For screens 768px and larger */
  @media (min-width: 768px) {
    .lineups-pitch {
      display: block;
    }
    .pitch-vertical {
      display: none;
    }
  }

/* --- HTOH Hero Enhancements (Names, Badges, Summary) --- */

/* Allow name labels / badges to render outside the pitch without clipping. */
.lineups-pitch,
.pitch-vertical {
  overflow: visible;
}

/* Player markers (enhanced) */
.player {
  cursor: pointer;
  user-select: none;
}

/* Always-visible name label under each player marker */
.player::after {
  content: attr(data-player-name);
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1.1;
  color: #111;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 8px;
  padding: 1px 5px;
  white-space: nowrap;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.player-badges {
  position: absolute;
  top: -12px;
  right: -14px;
  display: flex;
  gap: 4px;
  z-index: 4;
}

.player-badges .pb {
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 6px rgba(0,0,0,0.22);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.18);
}

.pb .pb-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92em;
  line-height: 1;
}

.pb .pb-count {
  font-size: 0.92em;
  font-weight: 900;
  line-height: 1;
}

/* Goal / Assist / Subs badges (high-contrast on green pitch) */
.pb-goal {
  background: #198754;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.pb-goal .pb-count {
  color: #000;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 0 4px;
  text-shadow: none;
}
.pb-assist {
  background: #0d6efd;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.pb-assist .pb-ico {
  font-weight: 900;
  letter-spacing: 0.02em;
}
.pb-sub {
  background: #6c757d;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  font-variant-numeric: tabular-nums;
}
.pb-sub.pb-sub-in { background: #20c997; }
.pb-sub.pb-sub-out { background: #dc3545; }

/* Card-shaped badges (yellow/red) */
.pb.pb-card {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  padding: 0 2px;
}
.pb.pb-card::before {
  content: '';
  display: inline-block;
  width: 11px;
  height: 16px;
  border-radius: 2px;
  background: var(--card-bg, #ffc107);
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.25));
}
.pb.pb-card.pb-yellow { --card-bg: #ffc107; --card-border: rgba(0,0,0,0.25); color: #664d03; }
.pb.pb-card.pb-red { --card-bg: #dc3545; --card-border: rgba(0,0,0,0.25); color: #fff; }

.player-sub {
  position: absolute;
  top: -10px;
  left: -10px;
  right: auto;
  font-size: 0.60rem;
  font-weight: 800;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.22);
}

/* Bench list badges: override the generic white pill so event colors remain visible */
.htoh-player-badges .pb.pb-goal {
  background: #198754;
  color: #fff;
  border-color: rgba(0, 0, 0, 0.12);
}
.htoh-player-badges .pb.pb-sub {
  background: #6c757d;
  color: #fff;
  border-color: rgba(0, 0, 0, 0.12);
}
.htoh-player-badges .pb.pb-sub.pb-sub-in { background: #20c997; }
.htoh-player-badges .pb.pb-sub.pb-sub-out { background: #dc3545; }
.htoh-player-badges .pb.pb-card {
  background: transparent;
  border: none;
}

.htoh-player-link {
  color: inherit;
  text-decoration: none;
}
.htoh-player-link:hover {
  text-decoration: underline;
}

.htoh-player-badges {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.htoh-player-badges .pb {
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.95);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.14);
}

.htoh-player-badges .pb .pb-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92em;
  line-height: 1;
}
.htoh-player-badges .pb .pb-count {
  font-size: 0.92em;
  font-weight: 900;
  line-height: 1;
}

/* Timeline icons (avoid Bootstrap Icons dependency) */
.timeline-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.95);
  font-size: 0.85rem;
  font-weight: 900;
  line-height: 1;
  color: #0dcaf0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10);
}

.timeline-sub-ico {
  display: inline-block;
  width: 1.1em;
  text-align: center;
  margin-right: 4px;
  font-weight: 900;
}

.htoh-hero-events-summary {
  min-height: 0;
}
.htoh-hero-events-summary .htoh-hero-events-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.htoh-hero-events-summary .htoh-hero-events-col {
  font-size: 0.85rem;
  line-height: 1.2;
}
.htoh-hero-events-summary .htoh-hero-events-line {
  display: block;
  margin: 2px 0;
}

/* Inline icons for the hero summary (under score) */
.htoh-hero-events-summary .ev-ico {
  display: inline-block;
  margin-right: 6px;
  line-height: 1;
  vertical-align: -1px;
}
.htoh-hero-events-summary .ev-ico-goal {
  font-size: 0.95rem;
}
.htoh-hero-events-summary .ev-ico-card {
  width: 10px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.htoh-hero-events-summary .ev-ico-yellow { background: #ffc107; }
.htoh-hero-events-summary .ev-ico-red { background: #dc3545; }
