:root {
  --bg: #05070d;
  --bg-soft: #0b1020;
  --card: #0f172a;
  --card-2: #101827;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --muted-2: #94a3b8;
  --gold: #f4c54f;
  --gold-2: #eab308;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 12px 35px rgba(0, 0, 0, 0.35);

  --r32: #1d4ed8;
  --r16: #0ea5e9;
  --qf: #8b5cf6;
  --sf: #f97316;
  --final: #f59e0b;
  --third: #14b8a6;

  --live: #22c55e;
  --upcoming: #38bdf8;
  --finished: #64748b;

  --column-width: 260px;
  --card-width: 220px;
  --radius: 18px;
}

.cpl-bracket-page {
  max-width: 1800px;
  margin: 0 auto;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  direction: ltr;
  color: var(--text);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.title-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  background: rgba(244, 197, 79, 0.08);
  color: var(--gold);
  border: 1px solid rgba(244, 197, 79, 0.2);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.4px;
}

.cpl-bracket-page h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.1;
  letter-spacing: 0.3px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(244, 197, 79, 0.2);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
  max-width: 900px;
}

.bracket-shell {
  position: relative;
  border: 1px solid rgba(244, 197, 79, 0.12);
  background: linear-gradient(180deg, rgba(3, 6, 11, 0.96), rgba(3, 6, 11, 0.99));
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: auto;
  padding: 22px;
  min-height: 700px;
  scrollbar-color: rgba(244, 197, 79, 0.3) rgba(255,255,255,0.06);
}

.bracket-shell::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}

.bracket-shell::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
}

.bracket-shell::-webkit-scrollbar-thumb {
  background: rgba(244, 197, 79, 0.32);
  border-radius: 999px;
}

.bracket {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 46px;
  min-width: max-content;
  padding-bottom: 12px;
  z-index: 2;
}

.round {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  min-width: var(--column-width);
  position: relative;
  z-index: 2;
}

.round.round-0 { margin-top: 36px; }
.round.round-1 { margin-top: 88px; }
.round.round-2 { margin-top: 152px; }
.round.round-3 { margin-top: 218px; }
.round.round-4 { margin-top: 280px; }
.round.round-5 { margin-top: 280px; }

.round-header {
  position: sticky;
  top: 0;
  z-index: 3;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.11);
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
}

.round-header.r32 {
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.22), rgba(29, 78, 216, 0.08));
  color: #bfdbfe;
  border-color: rgba(29, 78, 216, 0.35);
}

.round-header.r16 {
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.22), rgba(14, 165, 233, 0.08));
  color: #bae6fd;
  border-color: rgba(14, 165, 233, 0.35);
}

.round-header.qf {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.22), rgba(139, 92, 246, 0.08));
  color: #ddd6fe;
  border-color: rgba(139, 92, 246, 0.35);
}

.round-header.sf {
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.22), rgba(249, 115, 22, 0.08));
  color: #fed7aa;
  border-color: rgba(249, 115, 22, 0.35);
}

.round-header.final {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.28), rgba(245, 158, 11, 0.08));
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
}

.round-header.third {
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.22), rgba(20, 184, 166, 0.08));
  color: #99f6e4;
  border-color: rgba(20, 184, 166, 0.35);
}

.cpl-bracket-match-card {
  width: var(--card-width);
  min-height: 130px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(12, 18, 33, 0.98));
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 18px;
  box-shadow: 0 14px 24px rgba(0,0,0,0.25);
  padding: 12px;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.cpl-bracket-match-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: rgba(244, 197, 79, 0.28);
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(244, 197, 79, 0.08) inset;
}

.cpl-bracket-match-top,
.match-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.match-top-left,
.match-top-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cpl-bracket-match-id,
.match-id {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.cpl-bracket-match-time,
.match-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  line-height: 1.4;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status.upcoming {
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.25);
}

.status.upcoming::before {
  background: var(--upcoming);
  box-shadow: 0 0 10px var(--upcoming);
}

.status.live {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
}

.status.live::before {
  background: var(--live);
  box-shadow: 0 0 10px var(--live);
  animation: pulse 1.1s infinite;
}

.status.finished {
  color: #cbd5e1;
  background: rgba(100, 116, 139, 0.14);
  border-color: rgba(100, 116, 139, 0.28);
}

.status.finished::before {
  background: var(--finished);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.cpl-bracket-match-teams,
.teams {
  display: grid;
  gap: 8px;
}

.cpl-bracket-team-row,
.team-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  border: 1px solid rgba(255,255,255,0.06);
  transition: 0.2s ease;
}

.cpl-bracket-team-row.cpl-bracket-team-winner,
.team-row.winner {
  border-color: rgba(34, 197, 94, 0.38);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.08);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), rgba(255,255,255,0.02));
}

.cpl-bracket-team-left,
.team-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cpl-bracket-team-name,
.team-name {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cpl-bracket-flag,
.team-flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  object-fit: cover;
  flex: 0 0 auto;
}

.cpl-bracket-flag-empty,
.team-flag-empty {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  background: rgba(255,255,255,0.08);
}

.cpl-bracket-team-score,
.score {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.06);
}

.cpl-bracket-winner-text,
.winner-text {
  margin-top: 10px;
  color: #8cf0b2;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  font-weight: 700;
}

.cpl-bracket-has-winner {
  animation: winnerGlow 1.5s infinite alternate;
}

@keyframes winnerGlow {
  from {
    box-shadow: 0 0 8px rgba(140, 240, 178, 0.15);
  }
  to {
    box-shadow: 0 0 16px rgba(0, 255, 157, 0.28);
  }
}

.cpl-bracket-empty {
  display: block;
  margin-top: 18px;
  padding: 16px;
  color: var(--muted);
  border-radius: 16px;
  border: 1px dashed rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.02);
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

@media (max-width: 768px) {
  .cpl-bracket-page {
    padding: 0 6px;
  }

  .hero {
    margin-bottom: 16px;
  }

  .bracket-shell {
    padding: 16px;
    border-radius: 22px;
  }

  .round-header {
    position: static;
  }

  .bracket {
    gap: 24px;
  }

  .round {
    min-width: 220px;
  }

  .cpl-bracket-match-card {
    width: 200px;
  }

  .cpl-bracket-team-name {
    font-size: 14px;
  }
}
/* ✅ إضافة عرض واضح للـ penalties و extra time */

.penalties {
    margin-top: 6px;
    font-size: 12px;
    color: #f5c542;
    font-weight: 800;
    text-align: center;
    background: rgba(245,197,66,0.08);
    border: 1px solid rgba(245,197,66,0.25);
    padding: 4px 8px;
    border-radius: 10px;
    display: inline-block;
}

.extra-time {
    margin-top: 6px;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

/* ✅ تأكيد تمييز الفريق الفائز */

.team-row.winner {
    border-color: rgba(34, 197, 94, 0.45);
    background: linear-gradient(180deg,
        rgba(34, 197, 94, 0.12),
        rgba(255,255,255,0.02)
    );
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.12);
}

/* ✅ تحسين شكل الكارت عند وجود فائز */

.match-card.has-winner {
    box-shadow:
        0 12px 28px rgba(0,0,0,0.35),
        0 0 10px rgba(34,197,94,0.15);
}