/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg:        #07090e;
  --surf:      #0d1422;
  --surf2:     #111d2c;
  --surf3:     #162030;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --text:      #e8f1f8;
  --muted:     #5c7080;
  --muted2:    #8fa4b3;
  --accent:    #1de07a;
  --accent-bg: rgba(29,224,122,0.1);
  --red:       #ff4d5e;
  --gold:      #ffd166;
  --psg-navy:  #004170;
  --psg-blue:  #0060a8;
  --cyan:      #5df4ff;
  --blue:      #3268ff;
  --green:     #70ff9d;
  --lime:      #b7ff55;
  --line:      rgba(179,236,255,0.12);
  --line-hot:  rgba(93,244,255,0.42);
  --blur:      blur(24px);
  --r:         10px;
  --r-sm:      7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
img { display: block; }

/* ─── Stadium background ─────────────────────────────────────── */
.stadium-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(7,9,14,0.82) 0%, rgba(7,9,14,0.55) 40%, rgba(7,9,14,0.9) 100%),
    url("https://images.unsplash.com/photo-1522778119026-d647f0596c20?auto=format&fit=crop&w=2400&q=80") center/cover;
}

/* ─── App wrapper ────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Top bar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(7,9,14,0.92);
  backdrop-filter: var(--blur);
  flex-shrink: 0;
  z-index: 10;
}

.club-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.club-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(29,224,122,0.2));
}

.club-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.club-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.club-meta {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.formation-chip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid rgba(29,224,122,0.25);
  border-radius: 6px;
  padding: 3px 9px;
}

.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.app-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.live-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid rgba(29,224,122,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  letter-spacing: 0.04em;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:0.5; transform:scale(0.75); }
}

/* ─── Main 3-column grid ─────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 252px 1fr 284px;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ─── Shared sidebar styles ──────────────────────────────────── */
.squad-sidebar,
.intel-sidebar {
  background: rgba(7,10,16,0.7);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.intel-sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
  gap: 10px;
}

/* ─── Squad sidebar ──────────────────────────────────────────── */
.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 8px;
  margin-bottom: 4px;
}

.bench-head { margin-top: 16px; }

.section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted2);
}

.count-chip {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 20px;
  padding: 2px 8px;
}

.count-chip.muted {
  color: var(--muted);
  background: rgba(92,112,128,0.12);
}

.player-list { display: flex; flex-direction: column; gap: 2px; }

.squad-player {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  cursor: pointer;
}

.squad-player:hover {
  background: var(--surf2);
  border-color: var(--border);
}

.squad-player.active {
  background: rgba(29,224,122,0.08);
  border-color: rgba(29,224,122,0.22);
}

.squad-player .avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surf3);
  border: 1.5px solid var(--border2);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted2);
  flex-shrink: 0;
  position: relative;
}

.squad-player .avatar-fallback::after {
  content: attr(data-initials);
  position: absolute;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted2);
}

.squad-player .avatar-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  position: relative;
  z-index: 1;
}

.squad-player span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.squad-player span strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.squad-player span small {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.squad-player b {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
  min-width: 28px;
  text-align: right;
}

.bench-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(92,112,128,0.12);
  border: 1px solid rgba(92,112,128,0.18);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

/* ─── Pitch section ──────────────────────────────────────────── */
.pitch-section {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  overflow: hidden;
}

.pitch-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.pitch-meta-left { display: flex; flex-direction: column; gap: 4px; }

.eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.strategy-line {
  margin: 0;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted2);
  max-width: 420px;
  line-height: 1.5;
}

.formation-big {
  font-size: 32px;
  font-weight: 900;
  color: rgba(255,255,255,0.06);
  letter-spacing: -0.02em;
  line-height: 1;
  user-select: none;
}

.pitch-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* ─── Formation map ──────────────────────────────────────────── */
.formation-map {
  position: relative;
  /* Portrait pitch: real ratio 68:105 ≈ 0.648 */
  aspect-ratio: 0.648;
  height: calc(100% - 8px);
  max-height: 620px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.pitch-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ─── Pitch player dots ──────────────────────────────────────── */
.pitch-player {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.15s;
  z-index: 2;
}

.pitch-player:hover { transform: translate(-50%, -50%) scale(1.12); }

.pitch-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--psg-navy);
  border: 2px solid rgba(255,255,255,0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  transition: all 0.15s;
  letter-spacing: -0.01em;
}

.pitch-player.selected .pitch-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #001a10;
  box-shadow: 0 0 18px rgba(29,224,122,0.55);
}

.pitch-lbl {
  font-size: 9px;
  font-weight: 800;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 5px rgba(0,0,0,0.9), 0 0 10px rgba(0,0,0,0.9);
  white-space: nowrap;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ─── Intel / right sidebar ──────────────────────────────────── */
.card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-head h3 {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ─── Upload card ────────────────────────────────────────────── */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 16px;
  border: 1.5px dashed rgba(255,255,255,0.12);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  min-height: 96px;
  margin-bottom: 10px;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: rgba(29,224,122,0.4);
  background: var(--accent-bg);
}

.drop-zone input { display: none; }

.upload-icon {
  font-size: 22px;
  color: var(--muted);
  line-height: 1;
}

.drop-zone strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.drop-zone small {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.primary-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--accent);
  color: #001a10;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.primary-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

/* ─── Progress card ──────────────────────────────────────────── */
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
}

.progress-head b { color: var(--accent); font-size: 13px; }

.progress-track {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--psg-blue), var(--accent));
  border-radius: inherit;
  transition: width 0.4s ease;
}

.status-text {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.pipeline-steps {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.pipeline-steps span {
  flex: 1;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 2px;
  border-radius: 4px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.pipeline-steps span.active {
  color: var(--accent);
  background: var(--accent-bg);
  border-color: rgba(29,224,122,0.25);
}

/* ─── Player card ────────────────────────────────────────────── */
.state-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 5px;
  padding: 3px 8px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(29,224,122,0.22);
  white-space: nowrap;
}

.state-badge.danger {
  background: rgba(255,77,94,0.1);
  color: var(--red);
  border-color: rgba(255,77,94,0.2);
}

.target-body { min-height: 60px; }

.target-empty {
  padding: 20px 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.target-photo-wrap {
  width: 54px;
  height: auto;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border2);
  flex-shrink: 0;
}

.target-photo-wrap .avatar-fallback {
  width: 100%;
  height: 100%;
  background: var(--surf3);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--muted2);
  position: relative;
}

.target-photo-wrap .avatar-fallback::after {
  content: attr(data-initials);
  position: absolute;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted2);
}

.target-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  position: relative;
  z-index: 1;
}

.target-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.target-header div { flex: 1; }

.target-header strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.target-header span {
  font-size: 11px;
  color: var(--muted);
}

.target-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.target-metrics div {
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.target-metrics span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.target-metrics b {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.form-bars {
  display: flex;
  gap: 3px;
  height: 28px;
  align-items: flex-end;
}

.form-bars i {
  display: block;
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent) 0%, rgba(29,224,122,0.4) 100%);
  min-height: 4px;
}

/* ─── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }


/* ════════════════════════════════════════════════════════════════
   DASHBOARD (match.html)
   ════════════════════════════════════════════════════════════════ */

/* re-use base variables from above */

.topbar-dashboard {
  margin: 24px auto 0;
  width: min(1680px, calc(100% - 48px));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(9,18,27,0.74);
  backdrop-filter: var(--blur);
  padding: 18px 22px;
}

.topbar-dashboard h1 { font-size: 28px; }

.back-link,
.text-link {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 900;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 300px minmax(480px, 1fr) 300px;
  grid-template-areas:
    "players pitch teams"
    "video video analytics";
  gap: 16px;
  width: min(1680px, calc(100% - 48px));
  margin: 16px auto 28px;
}

.players-panel  { grid-area: players;   padding: 16px; }
.pitch-panel    { grid-area: pitch;     padding: 16px; }
.team-panel     { grid-area: teams;     padding: 16px; }
.video-panel    { grid-area: video;     padding: 16px; }
.analytics-panel{ grid-area: analytics; padding: 16px; }

/* ─ glass panel used on dashboard ─ */
.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: 18px;
}

#pitch-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.players-list { display: grid; gap: 9px; }

.player-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-radius: 14px;
  padding: 10px;
  text-align: left;
}

.team-dot { width:10px; height:10px; border-radius:50%; background:var(--muted); }
.team-A   { background: var(--cyan); }
.team-B   { background: var(--red);  }

.team-card {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  padding: 14px;
}

.team-card > div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

dl { display:grid; grid-template-columns:1fr auto; gap:8px; margin:0; color:var(--muted); }
dd { margin:0; color:var(--text); font-weight:900; }

video {
  width: 100%;
  max-height: 500px;
  border-radius: 16px;
  background: #050705;
}

.speed-bars  { display:grid; gap:10px; margin-top:16px; }

.speed-row {
  display: grid;
  grid-template-columns: 90px 1fr 44px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.speed-row div {
  height: 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.speed-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.toggle { color:var(--muted); font-size:13px; }

.empty-state {
  display: grid;
  min-height: 100vh;
  place-content: center;
  text-align: center;
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes gridFlow {
  from { transform: translateY(0); }
  to   { transform: translateY(72px); }
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 220px 1fr 260px;
  }
}

@media (max-width: 860px) {
  .main-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .intel-sidebar { border-left: none; border-top: 1px solid var(--border); }
  .squad-sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .pitch-section { min-height: 400px; }
  .dashboard-grid { grid-template-columns: 1fr; grid-template-areas: "pitch" "players" "teams" "video" "analytics"; }
}
