/* ═══ Single-player analysis — responsive layout ═══ */

.analysis-page {
  min-height: 100vh;
  overflow-x: hidden;
}

#analysis-app {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 0 16px 32px;
  box-sizing: border-box;
}

.analysis-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 16px;
  background: rgba(7, 9, 14, 0.94);
  text-align: center;
}

.loader-ring {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Header ─── */
.analysis-header {
  margin: 16px 0;
  padding: 16px 20px;
  border-radius: 20px;
  border: 1px solid rgba(179, 236, 255, 0.1);
  background: rgba(9, 18, 27, 0.78);
  backdrop-filter: blur(24px);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-title {
  flex: 1;
  min-width: 0;
}

.header-title h1 {
  margin: 4px 0 0;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.header-meta span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted2);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .header-meta span { white-space: normal; }
}

/* ─── Grid ─── */
.player-report-grid.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr) minmax(240px, 280px);
  grid-template-areas:
    "target pitch stats"
    "analytics analytics analytics";
  gap: 16px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.player-report-grid .players-panel  { grid-area: target; min-width: 0; }
.player-report-grid .pitch-panel    { grid-area: pitch; min-width: 0; display: flex; flex-direction: column; }
.player-report-grid .player-stats-panel { grid-area: stats; min-width: 0; }
.player-report-grid .analytics-panel { grid-area: analytics; min-width: 0; }

.glass-card {
  border-radius: 18px;
  border: 1px solid rgba(179, 236, 255, 0.12);
  background: rgba(9, 18, 27, 0.74);
  backdrop-filter: blur(24px);
  padding: 16px 18px;
  overflow: visible;
}

.player-report-grid h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
}

.panel-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 12px;
}

@media (min-width: 720px) {
  .panel-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.panel-head h2 { margin: 0; flex-shrink: 0; }

/* ─── Tracking target + rating ─── */
.player-focus-card {
  border: 1px solid rgba(29, 224, 122, 0.35);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(0, 65, 112, 0.35), rgba(9, 18, 27, 0.9));
  padding: 14px;
  overflow: visible;
}

.player-focus-card .focus-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.player-focus-card .focus-info {
  flex: 1;
  min-width: 0;
}

.player-focus-card .avatar-fallback {
  width: auto;
  height: auto;
  border-radius: 12px;
  border: 2px solid rgba(29, 224, 122, 0.4);
  overflow: hidden;
  flex-shrink: 0;
}

.player-focus-card .avatar-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-focus-card strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  word-break: break-word;
}

.player-focus-card small {
  color: var(--muted2);
  font-size: 11px;
  line-height: 1.4;
}

.focus-rating-row {
  margin-bottom: 12px;
}

.player-focus-card .focus-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-bg);
  border: 1px solid rgba(29, 224, 122, 0.4);
  box-sizing: border-box;
}

.player-focus-card .focus-rating b {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.player-focus-card .focus-rating span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.focus-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.focus-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted2);
}

.focus-tag.accent {
  color: var(--accent);
  border-color: rgba(29, 224, 122, 0.35);
  background: var(--accent-bg);
}

/* ─── Pitch — full width ─── */
.layer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.layer-tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.layer-tab:hover {
  color: var(--text);
  border-color: var(--line-hot);
}

.layer-tab.active {
  color: var(--accent);
  border-color: rgba(29, 224, 122, 0.45);
  background: var(--accent-bg);
}

.pitch-canvas-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 280px;
  aspect-ratio: 105 / 68;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #1a6b3f;
}

#analysis-pitch {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.pitch-legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ─── Player stats ─── */
.player-stats-panel .stat-hero {
  text-align: center;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.player-stats-panel .stat-hero b {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}

.player-stats-panel .stat-hero span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.player-stats-panel dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  margin: 0;
  font-size: 13px;
}

.player-stats-panel dt { color: var(--muted); margin: 0; }
.player-stats-panel dd { margin: 0; font-weight: 800; color: var(--text); }

.zone-mini {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.zone-mini-row {
  display: grid;
  grid-template-columns: 72px 1fr 32px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.zone-mini-row .track {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.zone-mini-row .fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--accent));
}

/* ─── Analytics bottom ─── */
.rating-pill {
  font-size: 14px;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-bg);
  border: 1px solid rgba(29, 224, 122, 0.4);
  color: var(--accent);
  flex-shrink: 0;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.subhead {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.details-grid > div {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.details-grid span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.details-grid strong {
  font-size: 16px;
  font-weight: 800;
}

.skill-bars { display: grid; gap: 12px; }

.skill-row {
  display: grid;
  grid-template-columns: 72px 1fr 28px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.skill-row .track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.skill-row .fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--accent));
  transition: width 0.6s ease;
}

.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.timeline-track {
  display: flex;
  align-items: flex-end;
  gap: 0;
  min-height: 88px;
  position: relative;
  padding-top: 24px;
}

.timeline-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  opacity: 0.35;
}

.timeline-event {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.timeline-event .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  flex-shrink: 0;
}

.timeline-event.goal .dot { background: var(--gold); }
.timeline-event.shot .dot { background: var(--cyan); }

.timeline-event span { font-size: 11px; font-weight: 700; color: var(--muted); }
.timeline-event small {
  font-size: 10px;
  color: var(--muted2);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insights-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.insights-list li {
  padding: 10px 12px 10px 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(29, 224, 122, 0.04);
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted2);
  position: relative;
}

.insights-list li::before {
  content: "◆";
  position: absolute;
  left: 10px;
  top: 10px;
  font-size: 9px;
  color: var(--accent);
}

/* ─── Responsive breakpoints ─── */
@media (max-width: 1200px) {
  .player-report-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "target stats"
      "pitch pitch"
      "analytics analytics";
  }

  .pitch-canvas-wrap {
    min-height: 340px;
  }
}

@media (max-width: 768px) {
  #analysis-app { padding: 0 12px 24px; }

  .player-report-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "target" "pitch" "stats" "analytics";
  }

  .analytics-grid { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }

  .panel-head .layer-tabs {
    width: 100%;
  }

  .header-meta span {
    flex: 1 1 auto;
    min-width: calc(50% - 8px);
  }
}

@media (max-width: 480px) {
  .details-grid { grid-template-columns: 1fr; }
  .player-focus-card .focus-rating b { font-size: 28px; }
}
