/* ===== Resultado Carrera — Race Results ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');

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

html, body {
  min-height: 100%;
  background: #1a1a2e;
  color: #fff;
  font-family: 'Inter', Arial, sans-serif;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  min-height: 100vh;
  height: auto;
}

/* ===== Título ===== */
.page-title {
  font-size: clamp(18px, 3.5vw, 28px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #e0e0e0;
  margin-bottom: 8px;
  text-align: center;
}

.page-subtitle {
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 600;
  color: #888;
  margin-bottom: 20px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== Contenedor tabla ===== */
.table-wrapper {
  width: 100%;
  max-width: 1100px;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
.table-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrapper::-webkit-scrollbar-track { background: #1a1a2e; }
.table-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.35); }

/* ===== Tabla ===== */
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

/* ===== Cabecera ===== */
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #16162b;
  padding: 12px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #888;
  border-bottom: 2px solid rgba(255,255,255,.1);
  text-align: center;
  white-space: nowrap;
}

thead th.th-name { text-align: left; }

/* ===== Filas ===== */
tr { transition: background .15s ease; }
tr:hover { filter: brightness(1.12); }

/* ===== Celdas ===== */
td {
  padding: 9px 10px;
  font-size: clamp(12px, 1.8vw, 14px);
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.06);
  white-space: nowrap;
  text-align: center;
}

/* Posición */
td.pos {
  width: 44px;
  font-weight: 800;
  font-size: clamp(13px, 2.2vw, 17px);
}

/* Nombre */
td.name {
  text-align: left;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .3px;
  padding-left: 14px;
}

/* Categoría */
td.cat {
  font-weight: 700;
  font-size: clamp(10px, 1.5vw, 12px);
}

.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.cat-badge.cat390 { background: #c0392b; color: #fff; }
.cat-badge.cat270 { background: #2471a3; color: #fff; }
.cat-badge.pro    { background: #e8942d; color: #fff; }
.cat-badge.grupo1 { background: #2471a3; color: #fff; }
.cat-badge.grupo2 { background: #3b8ac4; color: #fff; }
.cat-badge.other  { background: #555; color: #ccc; }

/* Numéricos */
td.num { font-weight: 700; }

/* Tiempo */
td.time {
  font-weight: 700;
  font-size: clamp(12px, 1.8vw, 14px);
  font-variant-numeric: tabular-nums;
}

/* Puntos totales */
td.pts-total {
  font-weight: 900;
  font-size: clamp(13px, 2vw, 16px);
  color: #e8942d;
}

/* ===== Podio: top 3 ===== */
tr.top1 { background: linear-gradient(90deg, #c87a1a 0%, #e8942d 50%, #d4851f 100%); }
tr.top1 td { color: #fff; }
tr.top1 td.pts-total { color: #fff; }

tr.top2 { background: linear-gradient(90deg, #1a5276 0%, #2471a3 50%, #1a5276 100%); }
tr.top2 td { color: #fff; }
tr.top2 td.pts-total { color: #fff; }

tr.top3 { background: linear-gradient(90deg, #2e6ea0 0%, #3b8ac4 50%, #2e6ea0 100%); }
tr.top3 td { color: #fff; }
tr.top3 td.pts-total { color: #fff; }

/* ===== Resto filas ===== */
tr.normal:nth-child(odd)  { background: #2a2a3e; }
tr.normal:nth-child(even) { background: #232337; }

/* ===== Filas descalificadas (DSQ) ===== */
tr.dsq-row { background: rgba(192,57,43,.12); }
tr.dsq-row td { color: #9aa0ab; }
tr.dsq-row td.name { text-decoration: line-through; text-decoration-color: rgba(255,107,107,.7); }
.dsq-tag {
  display: inline-block; background: #c0392b; color: #fff;
  border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 900; letter-spacing: .5px;
}
.dsq-badge {
  display: inline-block; background: #c0392b; color: #fff;
  border-radius: 999px; padding: 1px 8px; margin-left: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  text-decoration: none; vertical-align: middle;
}

/* ===== Lista de carreras (index) ===== */
.race-list {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.race-link {
  display: block;
  padding: 16px 24px;
  background: #232337;
  border-radius: 10px;
  text-decoration: none;
  color: #ddd;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .5px;
  transition: background .15s, transform .15s;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

.race-link:hover {
  background: #2e6ea0;
  color: #fff;
  transform: translateX(6px);
}

.race-link .race-icon {
  margin-right: 10px;
  font-size: 18px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: #888;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .5px;
  transition: color .15s;
}

.back-link:hover { color: #e8942d; }

/* ===== Títulos de sección ===== */
/* ===== Puntos por equipo en la carrera ===== */
.team-points-table .team-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.team-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 13px;
  flex-shrink: 0;
}
.team-name { font-weight: 800; }
.team-pilots { font-size: 13px; color: #cfd3e0; }
.team-pilot b { color: #ffd873; font-weight: 800; }
.team-total { font-weight: 900; }

.adjust-banner {
  width: 100%;
  max-width: 1100px;
  margin: 4px auto 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(226,171,37,.16), rgba(226,171,37,.06));
  border: 1px solid rgba(226,171,37,.5);
  border-left: 4px solid #e2ab25;
  color: #f2e6c8;
  font-size: 13.5px;
  line-height: 1.4;
}
.adjust-banner .adjust-ico { font-size: 22px; flex-shrink: 0; }
.adjust-banner b { color: #ffd873; }

.section-title {
  width: 100%;
  max-width: 1100px;
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #e0e0e0;
  margin-top: 28px;
  margin-bottom: 10px;
  text-align: center;
  padding: 10px 0;
  border-bottom: 2px solid rgba(255,255,255,.1);
}

.cat-section-title.cat390-title {
  color: #ff6b6b;
  border-bottom-color: rgba(192, 57, 43, .4);
}

.cat-section-title.cat270-title {
  color: #74b9ff;
  border-bottom-color: rgba(36, 113, 163, .4);
}

/* ===== Timestamp ===== */
.timestamp {
  margin-top: 14px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

/* ===== Live dot ===== */
.live-dot {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.8); }
}

/* ===== Estado vacío ===== */
.empty-msg {
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
  color: #888;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  body { padding: 12px 6px; }
  table { min-width: 700px; }
  td { padding: 7px 5px; font-size: 11px; }
  thead th { padding: 8px 5px; font-size: 9px; }
  td.pos { width: 32px; font-size: 13px; }
  td.name { padding-left: 8px; }
  .section-title { font-size: 14px; margin-top: 20px; }
  .race-link { padding: 14px 16px; font-size: 14px; }
}

@media (max-width: 480px) {
  body { padding: 8px 4px; }
  table { min-width: 620px; }
  td { padding: 6px 4px; font-size: 10px; }
  thead th { padding: 6px 4px; font-size: 8px; letter-spacing: .5px; }
  td.pos { width: 28px; font-size: 12px; }
  td.name { padding-left: 6px; font-size: 10px; }
  .page-title { font-size: 16px; margin-bottom: 4px; }
  .page-subtitle { font-size: 11px; margin-bottom: 12px; }
  .race-link { padding: 12px 12px; font-size: 13px; }
}

/* ===== Botón descarga CSV (admin) ===== */
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  background: #16213e;
  color: #a0c4ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-decoration: none;
  cursor: pointer;
  transition: all .2s ease;
  margin-left: 10px;
  vertical-align: middle;
}
.download-btn:hover {
  background: #1a3a5c;
  border-color: rgba(160,196,255,.4);
  color: #fff;
}

/* ===== Botón Inicio ===== */
.home-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  background: #16213e;
  color: #a0c4ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-decoration: none;
  z-index: 100;
  transition: all .2s ease;
}
.home-btn:hover {
  background: #1a3a5c;
  border-color: rgba(160,196,255,.4);
  color: #fff;
}

/* Penalty badge */
.penalty-badge {
  display: inline-block;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Bonus badge */
.bonus-badge {
  display: inline-block;
  background: #2ecc71;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ===================== MODO CLARO ===================== */
:root[data-theme="light"] body { background: #eef1f6; color: #1f2733; }
:root[data-theme="light"] .page-title { color: #24303f; }
:root[data-theme="light"] .home-btn { background: #ffffff; color: #5a6472; border-color: rgba(0,0,0,.12); }
:root[data-theme="light"] .home-btn:hover { color: #1f2733; }
:root[data-theme="light"] .table-wrapper { box-shadow: 0 8px 28px rgba(20,30,50,.12); }
:root[data-theme="light"] .table-wrapper::-webkit-scrollbar-track { background: #e2e6ee; }
:root[data-theme="light"] .table-wrapper::-webkit-scrollbar-thumb { background: rgba(0,0,0,.22); }
:root[data-theme="light"] thead th { background: #e7ebf3; color: #5a6472; border-bottom-color: rgba(0,0,0,.14); }
:root[data-theme="light"] tr.normal:nth-child(odd)  { background: #ffffff; }
:root[data-theme="light"] tr.normal:nth-child(even) { background: #f4f6fa; }
:root[data-theme="light"] tr.normal td { color: #24303f; border-bottom-color: rgba(0,0,0,.06); }
/* Podios (top1/2/3) conservan su color y texto blanco */
/* Filas DSQ */
:root[data-theme="light"] tr.dsq-row { background: rgba(192,57,43,.10); }
:root[data-theme="light"] tr.dsq-row td { color: #7a828f; }
/* Lista de carreras */
:root[data-theme="light"] .race-link { background: #ffffff; color: #2b3442; box-shadow: 0 4px 14px rgba(20,30,50,.10); }
:root[data-theme="light"] .race-link:hover { background: #2e6ea0; color: #fff; }
/* Títulos de sección / vacío */
:root[data-theme="light"] .section-title { color: #24303f; border-bottom-color: rgba(0,0,0,.12); }
:root[data-theme="light"] .empty-msg { color: #5a6472; }

/* La distancia al primero es contexto, no el dato principal: se atenua para
   que el intervalo con el de delante siga leyendose primero. */
td.gap-lider {
  opacity: .72;
  font-variant-numeric: tabular-nums;
}
