@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,700;0,800;0,900;1,700;1,800&family=Teko:wght@600;700&family=JetBrains+Mono:wght@700;800&display=swap');

:root {
  --wrc-red: #ea1d2d;
  --wrc-dark: rgba(11, 17, 32, 0.94);
  --wrc-card: rgba(30, 41, 59, 0.92);
  --wrc-border: rgba(255, 255, 255, 0.12);
  --wrc-yellow: #facc15;
  --wrc-green: #22c55e;
  --wrc-blue: #38bdf8;
  --font-display: 'Montserrat', sans-serif;
  --font-num: 'Teko', sans-serif;
  --font-chrono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 1920px;
  height: 1080px;
  background-color: transparent;
  color: #fff;
  font-family: var(--font-display);
  overflow: hidden;
  user-select: none;
}

.stream-overlay-container {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* =========================================================================
   ZONE HAUT-GAUCHE : SPÉCIALE ACTIVE & DRAPEAUX FIA
========================================================================= */
.zone-top-left {
  position: absolute;
  top: 35px;
  left: 40px;
  width: 440px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.stage-banner-widget {
  background: var(--wrc-dark);
  border-left: 5px solid var(--wrc-red);
  border-radius: 6px;
  padding: 12px 18px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--wrc-border);
  border-left: 5px solid var(--wrc-red);
}

.stage-tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.badge-fia {
  background: var(--wrc-red);
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 1px;
}

.stage-season {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
}

.stage-name-row h2 {
  font-size: 1.25rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.stage-meta-row {
  font-size: 0.75rem;
  color: var(--wrc-yellow);
  font-weight: 700;
  margin-top: 4px;
}

/* Race Control & Drapeau */
.race-control-widget {
  background: var(--wrc-dark);
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid var(--wrc-border);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.flag-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.rc-message-box {
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 10px;
  font-size: 0.8rem;
  color: #f8fafc;
}

.rc-label {
  font-weight: 900;
  color: var(--wrc-yellow);
  margin-right: 4px;
}

/* =========================================================================
   ZONE HAUT-DROITE : TEAM RADIO
========================================================================= */
.zone-top-right {
  position: absolute;
  top: 35px;
  right: 40px;
  width: 380px;
  display: flex;
  justify-content: flex-end;
  z-index: 10;
}

.radio-widget {
  background: var(--wrc-dark);
  border-radius: 8px;
  border: 1px solid var(--wrc-border);
  border-top: 4px solid var(--wrc-green);
  padding: 12px 18px;
  width: 100%;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
  animation: pulseRadio 2s infinite ease-in-out;
}

@keyframes pulseRadio {
  0%, 100% { border-top-color: var(--wrc-green); }
  50% { border-top-color: #86efac; }
}

.radio-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.radio-waves {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}

.radio-waves span {
  width: 3px;
  background: var(--wrc-green);
  border-radius: 2px;
  animation: waveBar 0.8s infinite ease-in-out alternate;
}
.radio-waves span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.radio-waves span:nth-child(2) { height: 14px; animation-delay: 0.3s; }
.radio-waves span:nth-child(3) { height: 9px; animation-delay: 0.2s; }
.radio-waves span:nth-child(4) { height: 12px; animation-delay: 0.4s; }

@keyframes waveBar {
  0% { transform: scaleY(0.4); }
  100% { transform: scaleY(1); }
}

.radio-title {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--wrc-green);
  letter-spacing: 1px;
}

.radio-body {
  display: flex;
  align-items: center;
  gap: 12px;
}

.radio-avatar-box img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--wrc-green);
  object-fit: cover;
}

.radio-speaker-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
}

.radio-speaker-team {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* =========================================================================
   ZONE CENTRE-HAUT : FEUX DE DÉPART FIA (COUNTDOWN)
========================================================================= */
.zone-center-countdown {
  position: absolute;
  top: 160px;
  left: 50%;
  transform: translateX(-50%);
  width: 440px;
  z-index: 30;
}

.countdown-widget {
  background: var(--wrc-dark);
  border: 2px solid var(--wrc-red);
  border-radius: 12px;
  padding: 18px 26px;
  text-align: center;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
}

.countdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.countdown-stage {
  font-size: 0.85rem;
  font-weight: 800;
  color: #cbd5e1;
}

.countdown-driver {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.cd-number {
  font-family: var(--font-num);
  font-size: 2.8rem;
  color: var(--wrc-yellow);
  line-height: 1;
}

.cd-name {
  font-size: 1.4rem;
  font-weight: 900;
}

.countdown-lights {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.light {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #334155;
  border: 2px solid #0f172a;
  transition: all 0.2s ease;
}

.light.red-active {
  background: #ef4444;
  box-shadow: 0 0 18px #ef4444;
}

.light.green-active {
  background: #22c55e;
  box-shadow: 0 0 25px #22c55e;
}

.countdown-text {
  font-family: var(--font-num);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f8fafc;
}

/* =========================================================================
   ZONE BAS-GAUCHE : CARTE PILOTE, CHRONO LIVE & POP-UPS
========================================================================= */
.zone-bottom-left {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 640px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
  z-index: 20;
}

/* Pop-up Split */
.split-banner {
  background: #000;
  border: 1px solid var(--wrc-border);
  border-radius: 6px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 440px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7);
  animation: slideInUp 0.3s ease-out;
}

.split-badge {
  background: var(--wrc-yellow);
  color: #0b1120;
  font-weight: 900;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 4px;
}

.split-time-box {
  font-family: var(--font-chrono);
  font-size: 1.15rem;
  font-weight: 800;
}

.split-delta-box {
  font-family: var(--font-chrono);
  font-size: 1.15rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
}
.delta-minus { background: #15803d; color: #fff; } /* Vert si en avance */
.delta-plus { background: #b91c1c; color: #fff; }  /* Rouge si retard */

/* Bannière d'Arrivée */
.finish-banner {
  background: #000;
  border: 2px solid var(--wrc-yellow);
  border-radius: 6px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  animation: slideInUp 0.3s ease-out;
}

.finish-badge {
  background: var(--wrc-yellow);
  color: #000;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 4px;
}

.finish-time {
  font-family: var(--font-chrono);
  font-size: 1.4rem;
  font-weight: 900;
}

.finish-pos {
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--wrc-yellow);
}

/* Carte Pilote WRC Style */
.live-driver-hud {
  background: var(--wrc-dark);
  border-radius: 8px;
  border: 1px solid var(--wrc-border);
  overflow: hidden;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.8);
}

.driver-banner {
  display: flex;
  align-items: center;
  position: relative;
}

.team-strip {
  width: 6px;
  align-self: stretch;
  background: var(--wrc-red);
}

.driver-num-badge {
  font-family: var(--font-num);
  font-size: 3.2rem;
  line-height: 1;
  color: var(--wrc-yellow);
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.5);
  font-weight: 700;
}

.driver-names-box {
  padding: 8px 18px;
  flex: 1;
}

.pilot-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.pilot-name {
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
}

.codriver-name {
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 700;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.category-badge {
  font-size: 0.7rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 3px;
  background: #334155;
  color: #fff;
}
.cat-WRC { background: #ef4444; }
.cat-RALLY2 { background: #38bdf8; color: #0b1120; }
.cat-RGT { background: #22c55e; color: #0b1120; }
.cat-HISTORIC { background: #facc15; color: #0b1120; }

.team-name {
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 700;
}

.chrono-box {
  background: #000;
  padding: 10px 22px;
  text-align: right;
  border-left: 1px solid var(--wrc-border);
}

.chrono-label {
  display: block;
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 800;
  letter-spacing: 1px;
}

.chrono-val {
  font-family: var(--font-chrono);
  font-size: 1.85rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

/* =========================================================================
   ZONE BAS-DROITE : TÉLÉMÉTRIE COCKPIT (SPEED / GEAR / RPM)
========================================================================= */
.zone-bottom-right {
  position: absolute;
  bottom: 40px;
  right: 40px;
  width: 280px;
  display: flex;
  justify-content: flex-end;
  z-index: 20;
}

.telemetry-widget {
  background: var(--wrc-dark);
  border: 1px solid var(--wrc-border);
  border-radius: 8px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.speed-dial-box {
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  padding-right: 14px;
}

.speed-main-val {
  font-family: var(--font-chrono);
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}

.speed-main-unit {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--wrc-yellow);
}

.gear-rpm-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.gear-val {
  font-family: var(--font-num);
  font-size: 2.4rem;
  line-height: 1;
  font-weight: 700;
  color: var(--wrc-yellow);
}

.gear-label {
  font-size: 0.6rem;
  color: #94a3b8;
  font-weight: 800;
}

.rpm-bar-container {
  width: 100px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.rpm-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #22c55e, #facc15 70%, #ef4444 90%);
  transition: width 0.08s linear;
}

/* =========================================================================
   ZONE LATÉRALE DROITE : LEADERBOARD LATÉRAL (TOP 8)
========================================================================= */
.zone-side-leaderboard {
  position: absolute;
  top: 110px;
  right: 40px;
  bottom: 40px;
  width: 440px;
  z-index: 15;
}

.side-lb-card {
  background: var(--wrc-dark);
  border-radius: 8px;
  border: 1px solid var(--wrc-border);
  border-top: 5px solid var(--wrc-red);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.side-lb-header {
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--wrc-border);
}

.side-lb-stage {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--wrc-yellow);
}

.side-lb-list {
  padding: 8px 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-lb-row {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  border-left: 3px solid transparent;
}
.side-lb-row.p1 {
  border-left-color: var(--wrc-yellow);
  background: rgba(250, 204, 21, 0.08);
}

.side-pos {
  font-family: var(--font-num);
  font-size: 1.6rem;
  width: 32px;
  line-height: 1;
  font-weight: bold;
}
.p1 .side-pos { color: var(--wrc-yellow); }

.side-num {
  font-family: var(--font-num);
  font-size: 1.3rem;
  color: #94a3b8;
  width: 42px;
}

.side-driver {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-gap {
  font-family: var(--font-chrono);
  font-size: 0.85rem;
  font-weight: 800;
  color: #cbd5e1;
}

/* =========================================================================
   ZONE PLEIN ÉCRAN : GRAND LEADERBOARD INTER-MANCHES
========================================================================= */
.zone-fullscreen-leaderboard {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 17, 32, 0.88);
  backdrop-filter: blur(10px);
  z-index: 50;
  animation: fadeIn 0.3s ease-out;
}

.full-lb-modal {
  width: 1400px;
  max-height: 860px;
  background: var(--wrc-dark);
  border-radius: 12px;
  border: 1px solid var(--wrc-border);
  border-top: 6px solid var(--wrc-red);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.full-lb-header {
  background: #000;
  padding: 22px 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--wrc-border);
}

.full-lb-header h1 {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.full-lb-stage {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--wrc-yellow);
}

.full-lb-table-wrap {
  overflow-y: auto;
  flex: 1;
  padding: 10px 24px;
}

.full-lb-table {
  width: 100%;
  border-collapse: collapse;
}

.full-lb-table th {
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.4);
  color: #94a3b8;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-align: left;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.full-lb-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 1.05rem;
}

/* Animations */
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
