/**
 * Historico — Podio + Ranking
 */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0f1116; color: #e8e6e3; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hist-container { max-width: 960px; margin: 0 auto; padding: 24px 16px 60px; }

/* Header */
.hist-header { margin-bottom: 24px; }
.hist-header h1 { font-family: 'Bebas Neue', sans-serif; font-size: 42px; letter-spacing: 2px; color: #e8e6e3; line-height: 1; }
.hist-header .sub { font-size: 14px; color: #9a9a9a; margin-top: 4px; }
.hist-header .stats { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.stat-pill {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: rgba(201,168,76,0.15); color: #C9A84C; border: 1px solid rgba(201,168,76,0.25);
}

/* Event Tabs */
.event-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.event-tab {
  flex: 1; padding: 12px; text-align: center; font-family: 'Bebas Neue', sans-serif;
  font-size: 20px; letter-spacing: 1.5px; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; border: 1px solid #2a2d35;
  background: #181b20; color: #9a9a9a;
}
.event-tab.active { background: rgba(201,168,76,0.15); color: #C9A84C; border-color: rgba(201,168,76,0.4); }
.event-tab:hover:not(.active) { background: #1e2128; color: #e8e6e3; }

/* View Tabs — full width like event tabs */
.view-tabs { display: flex; gap: 8px; margin-bottom: 16px; align-items: stretch; }
.view-tab {
  flex: 1; padding: 9px 8px; text-align: center;
  font-size: 13px; cursor: pointer; border-radius: 8px;
  background: #181b20; color: #9a9a9a; border: 1px solid #2a2d35;
  transition: all 0.2s; font-family: 'Outfit', sans-serif; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  min-height: 42px;
}
.view-tab.active { background: #e8e6e3; color: #0f1116; border-color: #e8e6e3; font-weight: 600; }
.view-tab:hover:not(.active) { background: #1e2128; border-color: #3a3f47; color: #e8e6e3; }

/* Year Navigator */
.year-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
.year-arrow {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid #2a2d35; background: #181b20;
  color: #9a9a9a; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; user-select: none; line-height: 1;
}
.year-arrow:hover { border-color: #C9A84C; color: #C9A84C; background: rgba(201,168,76,0.15); }
.year-arrow.hidden { opacity: 0; pointer-events: none; }

.year-bar-wrap { position: relative; flex: 1; overflow: hidden; }
.year-bar-wrap::before, .year-bar-wrap::after {
  content: ''; position: absolute; top: 0; bottom: 4px;
  width: 36px; z-index: 2; pointer-events: none; transition: opacity 0.2s;
}
.year-bar-wrap::before { left: 0; background: linear-gradient(to right, #0f1116, transparent); opacity: 0; }
.year-bar-wrap::after { right: 0; background: linear-gradient(to left, #0f1116, transparent); opacity: 1; }
.year-bar-wrap.fade-left::before { opacity: 1; }
.year-bar-wrap.no-fade-right::after { opacity: 0; }

.year-bar {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px;
  scroll-behavior: smooth; -ms-overflow-style: none; scrollbar-width: none;
}
.year-bar::-webkit-scrollbar { display: none; }
.year-pill {
  padding: 6px 16px; border-radius: 20px; font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
  background: #181b20; color: #9a9a9a;
  border: 1px solid #2a2d35; flex-shrink: 0;
}
.year-pill.active { background: #C9A84C; color: #0f1116; border-color: #C9A84C; font-weight: 700; }
.year-pill:hover:not(.active) { border-color: #9a9a9a; color: #e8e6e3; }

/* Podium */
.podium-section { margin-bottom: 24px; }
.podium-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .podium-grid { grid-template-columns: 1fr; } }

.podium-col-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 18px; letter-spacing: 2px;
  color: #9a9a9a; padding-bottom: 10px;
  border-bottom: 1px solid #2a2d35; margin-bottom: 10px;
}

.podium-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: #181b20; border: 1px solid #2a2d35;
  border-radius: 10px; margin-bottom: 8px; transition: all 0.2s;
  border-left: 3px solid transparent; position: relative;
}
.podium-card:hover { background: #1e2128; border-color: #2f3441; border-left-color: #C9A84C; }
.podium-card.rank-1st {
  border-left-color: #fbbf24;
  background: linear-gradient(135deg, rgba(251,191,36,0.06) 0%, #181b20 60%);
}

.medal {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-family: 'Bebas Neue', sans-serif; font-size: 20px;
  letter-spacing: 1px; flex-shrink: 0;
}
.medal-1 { background: rgba(251,191,36,0.22); color: #fbbf24; border: 1.5px solid rgba(251,191,36,0.55); }
.medal-2 { background: rgba(148,163,184,0.18); color: #cbd5e1; border: 1.5px solid rgba(148,163,184,0.45); }
.medal-3 { background: rgba(249,115,22,0.18); color: #fb923c; border: 1.5px solid rgba(249,115,22,0.45); }
.medal-4 {
  background: linear-gradient(135deg, rgba(180,200,210,0.15), rgba(120,140,150,0.18));
  color: #b8c5cc;
  border: 1.5px solid rgba(160,180,190,0.4);
}

.podium-info { flex: 1; min-width: 0; }
.podium-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: #5a5a5a; margin-bottom: 3px; font-weight: 500; }
.podium-name {
  font-size: 16px; font-weight: 600; color: #e8e6e3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
  cursor: pointer; position: relative;
}
.podium-name:hover { color: #C9A84C; }
.podium-criador { font-size: 12px; color: #9a9a9a; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tooltips */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute;
  background: #23262e; color: #e8e6e3; font-size: 11px; font-weight: 500;
  font-family: 'Outfit', sans-serif; letter-spacing: 0.3px;
  padding: 5px 10px; border-radius: 6px; border: 1px solid #2a2d35;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.15s, transform 0.15s; z-index: 100;
}
[data-tip]:hover::after { opacity: 1; }
.podium-name[data-tip]::after { top: calc(100% + 6px); left: 0; transform: translateY(-3px); }
.podium-name[data-tip]:hover::after { transform: translateY(0); }
.photo-icon[data-tip]::after { right: calc(100% + 8px); top: 50%; transform: translateY(-50%) translateX(3px); }
.photo-icon[data-tip]:hover::after { transform: translateY(-50%) translateX(0); }

/* Medal cells: tooltip on inner span (above) */
.medal-count span[data-tip] { position: relative; display: inline-block; }
.medal-count span[data-tip]::after {
  bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  z-index: 200;
}
.medal-count span[data-tip]:hover::after { transform: translateX(-50%) translateY(0); }

/* Ensure ranking rows don't clip tooltips */
.ranking-table, .ranking-table tbody, .ranking-table tr, .ranking-table td { overflow: visible !important; }

/* Photo icon — has photo */
.photo-icon {
  position: absolute; bottom: 8px; right: 10px;
  width: 16px; height: 16px; opacity: 0.7; transition: opacity 0.2s, color 0.2s;
  color: #d0d0d0; cursor: pointer; z-index: 2;
}
.podium-card:hover .photo-icon { opacity: 0.9; }
.photo-icon:hover { opacity: 1 !important; color: #C9A84C; }
.photo-icon svg { width: 16px; height: 16px; display: block; stroke-width: 2; }

/* No photo icon — red tint */
.photo-icon.no-photo { opacity: 0.5; color: #b04040; }
.photo-icon.no-photo:hover { color: #ef4444 !important; opacity: 0.85 !important; }
.photo-icon.no-photo svg .slash { display: block; }
.photo-icon:not(.no-photo) svg .slash { display: none; }

/* Lightbox (same as ficha) */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox-img-wrap {
  position: relative; max-width: min(90vw, 1200px); max-height: 85vh;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-img {
  max-width: 100%; max-height: 85vh; object-fit: contain;
  border-radius: 10px; box-shadow: 0 32px 80px rgba(0,0,0,0.8);
  transition: opacity 0.25s ease; display: block; opacity: 0;
}
.lightbox-img.fading { opacity: 0; }
.lb-btn {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: all 0.15s; backdrop-filter: blur(8px);
}
.lb-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.3); }
.lb-btn:disabled { opacity: 0.25; pointer-events: none; }
.lb-prev { left: 1.5rem; }
.lb-next { right: 1.5rem; }
.lb-close {
  position: fixed; top: 1.5rem; right: 1.5rem;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: all 0.15s; backdrop-filter: blur(8px); z-index: 1001;
}
.lb-close:hover { background: rgba(232,185,80,0.2); border-color: rgba(232,185,80,0.4); color: #C9A84C; }
.lb-info {
  position: fixed; bottom: 1.8rem; left: 50%; transform: translateX(-50%);
  text-align: center; color: #e8e6e3; z-index: 1001;
}
.lb-info-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.lb-info-criador { font-size: 13px; color: #9a9a9a; margin-bottom: 10px; }
.lb-info-btn {
  display: inline-block; padding: 7px 16px; border-radius: 6px;
  background: rgba(201,168,76,0.15); color: #C9A84C;
  border: 1px solid rgba(201,168,76,0.35); font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background 0.2s;
}
.lb-info-btn:hover { background: rgba(201,168,76,0.25); }
.lb-no-photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #5a5a5a; font-size: 14px; min-height: 300px;
}

/* Empty */
.empty-event {
  text-align: center; padding: 40px; color: #5a5a5a; font-size: 14px;
  border: 1px dashed #2a2d35; border-radius: 10px; margin: 16px 0;
}

/* Loading */
.hist-loading { text-align: center; padding: 40px; color: #5a5a5a; }
.hist-spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 2px solid #2a2d35; border-top-color: #C9A84C;
  border-radius: 50%; animation: histSpin 0.6s linear infinite;
}
@keyframes histSpin { to { transform: rotate(360deg); } }

/* === RANKING === */
.ranking-section { margin-top: 16px; }
.ranking-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #2a2d35;
}
.ranking-header h2 { font-family: 'Bebas Neue', sans-serif; font-size: 28px; letter-spacing: 1.5px; }
.ranking-header .sub { font-size: 12px; color: #5a5a5a; }

.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #5a5a5a; text-align: left; padding: 8px 10px;
  border-bottom: 1px solid #2a2d35; font-weight: 500;
}
.ranking-table th.center { text-align: center; }
.ranking-table td { padding: 10px; border-bottom: 1px solid rgba(42,45,53,0.5); font-size: 14px; }
.ranking-table tr:hover td { background: #1e2128; }

.rank-pos {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.rank-1 { background: rgba(251,191,36,0.15); color: #fbbf24; }
.rank-2 { background: rgba(148,163,184,0.12); color: #94a3b8; }
.rank-3 { background: rgba(249,115,22,0.12); color: #f97316; }
.rank-other { color: #5a5a5a; }

.rank-name { font-weight: 500; }
.rank-link { cursor: pointer; transition: color 0.15s; }
.rank-link:hover { color: #C9A84C; }
.sex-icon { font-size: 14px; vertical-align: 1px; margin-left: 2px; }
.medal-count { text-align: center; font-size: 13px; }
.medal-count .g { color: #fbbf24; }
.medal-count .s { color: #94a3b8; }
.medal-count .b { color: #f97316; }
.medal-count .c { color: #6b7280; }
.total-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px; font-weight: 600;
  font-size: 13px; background: rgba(201,168,76,0.15); color: #C9A84C;
}
.rank-bar-wrap { display: flex; align-items: center; gap: 8px; }
.rank-bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #fbbf24, #C9A84C); transition: width 0.5s ease; }

/* Medal Modal — full screen lightbox style */
.medal-modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.85);
  align-items: center; justify-content: center;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; transition: opacity 0.25s ease;
}
.medal-modal.open { display: flex; opacity: 1; }
.medal-modal-box {
  background: #181b20; border: 1px solid #2a2d35; border-radius: 14px;
  max-width: 480px; width: calc(100% - 32px); max-height: 80vh;
  display: flex; flex-direction: column; position: relative;
  box-shadow: 0 32px 80px rgba(0,0,0,0.8);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.medal-modal-header {
  padding: 18px 20px 14px; border-bottom: 1px solid #2a2d35;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.medal-modal-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 1.5px;
  color: #C9A84C; flex: 1; line-height: 1.1;
}
.modal-subtitle {
  display: block; font-family: 'Outfit', sans-serif; font-size: 12px;
  font-weight: 400; letter-spacing: 0.3px; color: #9a9a9a;
  margin-top: 4px; text-transform: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.medal-modal-count {
  background: rgba(201,168,76,0.18); color: #C9A84C;
  padding: 4px 12px; border-radius: 16px; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(201,168,76,0.4);
}
.medal-modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: 16px; cursor: pointer; line-height: 1; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.medal-modal-close:hover { background: rgba(232,185,80,0.2); border-color: rgba(232,185,80,0.4); color: #C9A84C; }
.medal-modal-list {
  overflow-y: auto; padding: 8px 0;
}
.medal-modal-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.medal-modal-item:hover {
  background: rgba(201,168,76,0.06);
  border-left-color: #C9A84C;
}
.medal-modal-item .mm-year {
  font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 1px;
  color: #C9A84C; min-width: 56px;
}
.medal-modal-item .mm-info { flex: 1; min-width: 0; }
.medal-modal-item .mm-event {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: #5a5a5a; margin-bottom: 2px; font-weight: 500;
}
.medal-modal-item .mm-name {
  font-size: 15px; font-weight: 600; color: #e8e6e3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.medal-modal-item:hover .mm-name { color: #C9A84C; }
.medal-modal-item .mm-arrow {
  color: #5a5a5a; font-size: 18px; opacity: 0; transition: opacity 0.15s;
}
.medal-modal-item:hover .mm-arrow { opacity: 1; color: #C9A84C; }
.medal-modal-loading { text-align: center; padding: 30px; color: #5a5a5a; font-size: 13px; }

/* Mobile: full width */
@media (max-width: 640px) {
  .medal-modal-box { max-width: none; width: calc(100% - 24px); max-height: 85vh; }
  .medal-modal-title { font-size: 18px; letter-spacing: 1px; }
  .medal-modal-item { padding: 12px 16px; gap: 10px; }
  .medal-modal-item .mm-year { font-size: 19px; min-width: 48px; }
  .medal-modal-item .mm-name { font-size: 14px; }
}

/* Clickable medal cells — hover lights up */
.medal-click {
  cursor: pointer; position: relative; transition: all 0.15s;
  border-radius: 6px;
}
.medal-click:hover {
  background: rgba(201,168,76,0.12) !important;
  box-shadow: 0 0 0 1px rgba(201,168,76,0.4);
}

/* Show tooltip on cell hover (not just span hover) */
.medal-click:hover span[data-tip]::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* View containers */
.view-content { display: none; }
.view-content.active { display: block; }

/* === MOBILE: Ranking as Cards === */
@media (max-width: 640px) {
  /* Hide table layout, show card layout */
  .ranking-table thead { display: none; }
  .ranking-table, .ranking-table tbody, .ranking-table tr, .ranking-table td { display: block; width: 100%; }

  .ranking-table tr {
    background: #181b20; border: 1px solid #2a2d35; border-radius: 10px;
    padding: 14px 16px 12px 50px; margin-bottom: 10px; position: relative;
  }
  .ranking-table tr:hover td { background: transparent; }

  .ranking-table td {
    padding: 0; border: none;
  }

  /* Position badge in top-left */
  .ranking-table td:first-child {
    position: absolute; top: 14px; left: 14px; width: auto;
  }
  .rank-pos { width: 28px; height: 28px; font-size: 13px; }

  /* === ANIMALES (10 columns) === */
  /* Name */
  #rankingAnimalesBody td:nth-child(2) {
    font-size: 15px; font-weight: 600; margin-bottom: 2px; color: #e8e6e3;
    padding-right: 30px;
  }
  /* Criador */
  #rankingAnimalesBody td:nth-child(3) {
    font-size: 11px; color: #9a9a9a; margin-bottom: 10px;
    text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%;
  }
  /* Sex now inline with name (column hidden) */
  #rankingAnimalesBody td:nth-child(4) { display: none !important; }
  /* Medals row container */
  #rankingAnimalesBody td:nth-child(5),
  #rankingAnimalesBody td:nth-child(6),
  #rankingAnimalesBody td:nth-child(7),
  #rankingAnimalesBody td:nth-child(8),
  #rankingAnimalesBody td:nth-child(9) {
    display: inline-block; width: auto; min-width: 42px;
    padding: 5px 8px; background: rgba(255,255,255,0.04);
    border-radius: 6px; margin-right: 5px; font-size: 12px; text-align: center;
    margin-bottom: 4px;
  }
  #rankingAnimalesBody td:nth-child(5)::before { content: '🥇 '; font-size: 11px; }
  #rankingAnimalesBody td:nth-child(6)::before { content: '🥈 '; font-size: 11px; }
  #rankingAnimalesBody td:nth-child(7)::before { content: '🥉 '; font-size: 11px; }
  #rankingAnimalesBody td:nth-child(8)::before {
    content: '';
    display: inline-block;
    width: 13px; height: 13px;
    margin-right: 4px;
    vertical-align: -2px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><defs><linearGradient id='g4' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%23c5cdd4'/><stop offset='50%25' stop-color='%238a949c'/><stop offset='100%25' stop-color='%235a6470'/></linearGradient></defs><path d='M7 2h10l-2 5h-6z' fill='%2370788a'/><circle cx='12' cy='14' r='8' fill='url(%23g4)' stroke='%234a525d' stroke-width='1'/><circle cx='12' cy='14' r='5.5' fill='none' stroke='%23485058' stroke-width='0.4'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
  }
  /* Total badge: big, right side */
  #rankingAnimalesBody td:nth-child(9) {
    position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
    width: auto; min-width: 56px; padding: 10px 0;
    background: rgba(201,168,76,0.18); border: 1px solid rgba(201,168,76,0.4);
    border-radius: 10px; text-align: center; margin: 0;
  }
  #rankingAnimalesBody td:nth-child(9) .total-badge {
    background: transparent; padding: 0; font-size: 22px; font-weight: 700; color: #C9A84C;
  }
  /* Hide bar in mobile */
  #rankingAnimalesBody td:nth-child(10) { display: none; }
  /* Add right padding to make space for total badge */
  #rankingAnimalesBody tr { padding-right: 80px; }

  /* === CABAÑAS (8 columns) === */
  /* Criador name */
  #rankingBody td:nth-child(2) {
    font-size: 15px; font-weight: 600; margin-bottom: 10px; color: #e8e6e3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
    padding-right: 10px;
  }
  /* Medals row */
  #rankingBody td:nth-child(3),
  #rankingBody td:nth-child(4),
  #rankingBody td:nth-child(5),
  #rankingBody td:nth-child(6),
  #rankingBody td:nth-child(7) {
    display: inline-block; width: auto; min-width: 42px;
    padding: 5px 8px; background: rgba(255,255,255,0.04);
    border-radius: 6px; margin-right: 5px; font-size: 12px; text-align: center;
    margin-bottom: 4px;
  }
  #rankingBody td:nth-child(3)::before { content: '🥇 '; font-size: 11px; }
  #rankingBody td:nth-child(4)::before { content: '🥈 '; font-size: 11px; }
  #rankingBody td:nth-child(5)::before { content: '🥉 '; font-size: 11px; }
  #rankingBody td:nth-child(6)::before {
    content: '';
    display: inline-block;
    width: 13px; height: 13px;
    margin-right: 4px;
    vertical-align: -2px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><defs><linearGradient id='g4b' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%23c5cdd4'/><stop offset='50%25' stop-color='%238a949c'/><stop offset='100%25' stop-color='%235a6470'/></linearGradient></defs><path d='M7 2h10l-2 5h-6z' fill='%2370788a'/><circle cx='12' cy='14' r='8' fill='url(%23g4b)' stroke='%234a525d' stroke-width='1'/><circle cx='12' cy='14' r='5.5' fill='none' stroke='%23485058' stroke-width='0.4'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
  }
  /* Total badge: big, right side */
  #rankingBody td:nth-child(7) {
    position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
    width: auto; min-width: 56px; padding: 10px 0;
    background: rgba(201,168,76,0.18); border: 1px solid rgba(201,168,76,0.4);
    border-radius: 10px; text-align: center; margin: 0;
  }
  #rankingBody td:nth-child(7) .total-badge {
    background: transparent; padding: 0; font-size: 22px; font-weight: 700; color: #C9A84C;
  }
  /* Hide bar */
  #rankingBody td:nth-child(8) { display: none; }
  /* Add right padding to make space for total badge */
  #rankingBody tr { padding-right: 80px; }
}

/* Responsive (general) */
@media (max-width: 640px) {
  .hist-container { padding: 16px 12px 40px; }
  .hist-header h1 { font-size: 28px; }
  .hist-header .sub { font-size: 12px; }
  .stat-pill { font-size: 10px; padding: 3px 8px; }

  .event-tabs { gap: 6px; }
  .event-tab { font-size: 15px; padding: 10px 6px; }

  .view-tabs { flex-wrap: wrap; gap: 4px; }
  .view-label { font-size: 10px; width: 100%; margin-bottom: 2px; }
  .view-tab { font-size: 12px; padding: 4px 12px; }

  .year-pill { padding: 5px 12px; font-size: 13px; }
  .year-arrow { width: 26px; height: 26px; font-size: 12px; }

  .podium-grid { grid-template-columns: 1fr; gap: 20px; }
  .podium-col-title { font-size: 16px; }
  .podium-card { padding: 12px; gap: 10px; }
  .medal { width: 36px; height: 36px; font-size: 17px; border-radius: 8px; }
  .podium-title { font-size: 10px; }
  .podium-name { font-size: 14px; }
  .podium-criador { font-size: 11px; }
  .photo-icon { width: 14px; height: 14px; bottom: 6px; right: 8px; }
  .photo-icon svg { width: 14px; height: 14px; }

  .ranking-table { font-size: 12px; }
  .ranking-table th, .ranking-table td { padding: 6px 4px; }
  .ranking-table th:last-child, .ranking-table td:last-child { display: none; }
  .ranking-table th:nth-child(3), .ranking-table td:nth-child(3) { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rank-pos { width: 24px; height: 24px; font-size: 11px; }
  .total-badge { font-size: 11px; padding: 2px 7px; }

  .ranking-header h2 { font-size: 22px; }

  .lb-info-name { font-size: 14px; }
  .lb-info-criador { font-size: 12px; }
  .lb-info-btn { font-size: 11px; padding: 6px 14px; }

  .medal-pop { min-width: 180px; max-width: 260px; }
}
