<!DOCTYPE html>
<html lang="en" dir="ltr" data-theme="ww2">
<head>
<script>
  (function() {
    var t = localStorage.getItem('gpc_theme') || 'ww2';
    var v = ['ww2','gold-black','black-white','pure-white'];
    if (v.indexOf(t) < 0) t = 'ww2';
    document.documentElement.setAttribute('data-theme', t);
    var b = document.querySelector('body[data-theme]');
    if (!b) {
      document.addEventListener('DOMContentLoaded', function() {
        document.body.setAttribute('data-theme', t);
      });
    } else {
      b.setAttribute('data-theme', t);
    }
  })();
</script>

  <title>Global Military & Economic Leaderboards | World Military Powers</title>
  <!-- Favicon & Touch Icons -->
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
  <link rel="icon" type="image/png" sizes="48x48" href="/favicon-48x48.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
  <link rel="manifest" href="/manifest.json">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="Explore master categorized global leaderboards ranking 241 countries across military strength, GDP, population, land area, oil, gas, gold, and strategic resources.">
  <meta name="keywords" content="military rankings 2026, global power index, top armies, gdp ranking, strategic resources ranking, nuclear weapons ranking">
  <meta name="author" content="Jir Mirza">

  <!-- Open Graph -->
  <meta property="og:type" content="website">
  <meta property="og:title" content="34 Master Leaderboards | World Military Powers">
  <meta property="og:description" content="Rank 241 countries across master categories: Army, Navy, Air Force, GDP, Natural Resources, and Strategic Arsenal.">
  <meta property="og:url" content="https://worldmilitarypowers.com/rankings.html">
  <meta property="og:image" content="https://worldmilitarypowers.com/og-image.png">

  <!-- Fonts & Icons -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@500;600;700;800;900&family=Rajdhani:wght@500;600;700&display=swap" rel="stylesheet">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@500;600;700;800;900&family=Rajdhani:wght@500;600;700&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="consent.css?v=205">
  <link rel="stylesheet" href="style.css?v=205">
  <link rel="stylesheet" href="country.css?v=205">
    <link rel="stylesheet" href="theme-pure-white.css?v=205">
    <link rel="stylesheet" href="theme-system.css?v=205">

  <style>
    /*  APPLE HIG BENTO GRID & MASTER RANKINGS STYLING */
    body {
      font-family: var(--font-ui);
      background-color: var(--bg-primary);
      color: var(--color-text-primary);
      margin: 0;
      padding: 0;
    }

    .rankings-page {
      max-width: 1400px;
      margin: 0 auto;
      padding: 24px 20px 80px;
    }

    @media (min-width: 1361px) and (max-width: 1780px) {
      .rankings-page {
        max-width: calc(100vw - 370px) !important;
      }
    }

    /* Bento Grid Header */
    .bento-grid {
      display: grid;
      grid-template-columns: repeat(12, 1fr);
      gap: 16px;
      margin-bottom: 24px;
    }

    .bento-card {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 20px;
      padding: 24px;
      backdrop-filter: blur(25px) saturate(180%);
      box-shadow: var(--shadow-glow);
      transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      position: relative;
      overflow: hidden;
    }

    .bento-card:hover {
      border-color: var(--border-glow);
      transform: translateY(-2px);
    }

    .bento-main { grid-column: span 8; }
    .bento-superpower { grid-column: span 4; }
    @media (max-width: 992px) {
      .bento-main { grid-column: span 12; }
      .bento-superpower { grid-column: span 12; }
    }

    .bento-title {
      font-family: var(--font-hud), sans-serif;
      font-size: 1.8rem;
      font-weight: 800;
      color: var(--color-cyan);
      margin: 0 0 8px;
      letter-spacing: 0.5px;
    }

    .bento-desc {
      font-size: 0.95rem;
      color: var(--color-text-secondary);
      margin: 0 0 20px;
      line-height: 1.6;
    }

    .bento-stats {
      display: flex;
      gap: 20px;
      flex-wrap: wrap;
    }

    .bento-stat-item {
      background: var(--panel-highlight);
      border: 1px solid var(--border-color);
      border-radius: 12px;
      padding: 12px 18px;
      flex: 1;
      min-width: 130px;
    }

    .bento-stat-val {
      font-size: 1.4rem;
      font-weight: 800;
      color: var(--color-cyan);
      font-variant-numeric: tabular-nums;
    }

    .bento-stat-lbl {
      font-size: 0.78rem;
      color: var(--color-text-secondary);
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-top: 4px;
    }

    /* Category Segmented Controls */
    .cat-tabs-container {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 18px;
      padding: 8px;
      margin-bottom: 24px;
      display: flex;
      gap: 6px;
      overflow-x: auto;
      backdrop-filter: blur(25px);
    }

    .cat-tab-btn {
      padding: 10px 18px;
      border-radius: 12px;
      border: 1px solid transparent;
      background: transparent;
      color: var(--color-text-secondary);
      font-weight: 700;
      font-size: 0.88rem;
      cursor: pointer;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      transition: all 0.2s ease;
    }

    .cat-tab-btn:hover {
      color: var(--color-text-primary);
      background: var(--panel-highlight);
    }

    .cat-tab-btn.active {
      background: var(--color-cyan);
      color: #ffffff;
      border-color: var(--color-cyan);
      box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.35);
    }

    /* Leaderboards Grid */
    .leaderboards-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
      gap: 24px;
      margin-top: 24px;
    }
    @media (max-width: 480px) {
      .leaderboards-grid {
        grid-template-columns: 1fr;
      }
    }

    /* Board Card */
    .board-card {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 20px;
      padding: 24px;
      backdrop-filter: blur(25px);
      box-shadow: var(--shadow-glow);
      transition: all 0.3s ease;
      position: relative;
      overflow: hidden;
    }

    .board-card:hover {
      border-color: var(--border-glow);
      transform: translateY(-2px);
    }

    .board-header {
      display: flex;
      align-items: center;
      gap: 12px;
      border-bottom: 2px solid rgba(var(--accent-rgb), 0.15);
      padding-bottom: 12px;
      margin-bottom: 16px;
    }

    .board-icon {
      font-size: 1.6rem;
      filter: drop-shadow(0 0 6px var(--color-cyan));
      width: 30px;
      height: 30px;
      display: inline-grid;
      place-items: center;
      flex: 0 0 30px;
    }

    .board-icon svg {
      width: 24px;
      height: 24px;
      stroke: currentColor;
      fill: none;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .board-title {
      font-family: var(--font-hud), sans-serif;
      font-size: 1.25rem;
      font-weight: 700;
      color: var(--color-cyan);
      margin: 0;
      flex-grow: 1;
    }

    .board-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .board-row {
      display: flex;
      align-items: center;
      padding: 8px 12px;
      background: rgba(0, 0, 0, 0.12);
      border: 1px solid rgba(255, 255, 255, 0.02);
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.2s ease;
    }

    .board-row:hover {
      background: var(--panel-highlight);
      border-color: var(--color-cyan);
    }

    .rank-badge {
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      font-family: var(--font-hud), sans-serif;
      font-weight: 700;
      font-size: 0.85rem;
      margin-right: 12px;
      background: rgba(255, 255, 255, 0.08);
      color: var(--color-text-secondary);
      flex-shrink: 0;
    }

    .rank-badge.rank-1 {
      background: #ffd700;
      color: #000;
      box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
    }

    .rank-badge.rank-2 {
      background: #c0c0c0;
      color: #000;
      box-shadow: 0 0 10px rgba(192, 192, 192, 0.4);
    }

    .rank-badge.rank-3 {
      background: #cd7f32;
      color: #000;
      box-shadow: 0 0 10px rgba(205, 127, 50, 0.4);
    }

    .country-flag-wrapper {
      width: 24px;
      height: 18px;
      margin-right: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .flag-icon {
      width: 100%;
      height: auto;
      border-radius: 3px;
      box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }

    .country-name {
      font-weight: 700;
      font-size: 0.92rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      flex-grow: 1;
      padding-right: 8px;
    }

    .metric-value {
      font-family: var(--font-hud), monospace;
      font-size: 1.05rem;
      font-weight: 700;
      color: var(--color-cyan);
      text-align: right;
      font-variant-numeric: tabular-nums;
    }

    /* 📈 Historical Timeline Chart */
    .timeline-card {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 20px;
      padding: 24px;
      margin-bottom: 32px;
      backdrop-filter: blur(25px);
    }

    .timeline-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      flex-wrap: wrap;
      gap: 12px;
    }

    .timeline-title {
      font-family: var(--font-hud), sans-serif;
      font-size: 1.2rem;
      font-weight: 700;
      color: var(--color-cyan);
      margin: 0;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .timeline-legend {
      display: flex;
      flex-wrap: wrap;
      gap: 8px 18px;
      margin-top: 8px;
      padding: 12px 14px;
      border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
      border-radius: 12px;
      background: color-mix(in srgb, var(--bg-secondary) 55%, transparent);
    }

    .timeline-legend-item {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      color: var(--color-text-secondary);
      font-size: .78rem;
      white-space: nowrap;
    }

    .timeline-legend-swatch {
      width: 18px;
      height: 3px;
      border-radius: 999px;
      flex: 0 0 18px;
    }

    .timeline-legend-item strong {
      color: var(--color-text-primary);
      font-weight: 700;
    }

    /* Quick mini buttons */
    .card-export-btn {
      background: transparent;
      border: none;
      color: var(--color-text-secondary);
      cursor: pointer;
      padding: 4px;
      border-radius: 6px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s ease;
    }

    .card-export-btn:hover {
      color: var(--color-cyan);
      background: var(--panel-highlight);
    }

    /* Apple HIG 3D-effect Spotlight Podium */
    .spotlight-podium {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
      margin-bottom: 32px;
    }

    .podium-box {
      background: var(--bg-card);
      border: 1.5px solid var(--border-color);
      border-radius: 24px;
      padding: 24px;
      text-align: center;
      position: relative;
      overflow: hidden;
      backdrop-filter: blur(25px);
      box-shadow: var(--shadow-glow);
      transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .podium-box:hover {
      transform: translateY(-2px);
      border-color: var(--border-glow);
    }

    .podium-box.rank-1 {
      border-color: #ffd700;
      background: linear-gradient(180deg, rgba(255, 215, 0, 0.05) 0%, var(--bg-card) 100%);
    }

    .podium-box.rank-2 {
      border-color: #c0c0c0;
    }

    .podium-box.rank-3 {
      border-color: #cd7f32;
    }

    .podium-rank {
      font-family: var(--font-hud), sans-serif;
      font-size: 1rem;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 8px;
    }

    .podium-rank.rank-1 { color: #ffd700; }
    .podium-rank.rank-2 { color: #c0c0c0; }
    .podium-rank.rank-3 { color: #cd7f32; }

    .podium-flag-img {
      width: 64px;
      height: 44px;
      border-radius: 6px;
      object-fit: cover;
      margin: 0 auto 12px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }

    .podium-country-name {
      font-size: 1.2rem;
      font-weight: 800;
      color: var(--color-text-primary);
      margin: 0 0 4px;
    }

    .podium-value-text {
      font-size: 1.6rem;
      font-weight: 800;
      color: var(--color-cyan);
      font-family: var(--font-hud), monospace;
    }
  
    /* ERA TIME TRAVELER & CATEGORY LINK STYLING */
    .era-time-traveler-card {
      background: linear-gradient(135deg, rgba(14, 21, 36, 0.95), rgba(8, 12, 20, 0.98));
      border: 1.5px solid rgba(0, 243, 255, 0.3);
      border-radius: 20px;
      padding: 20px 24px;
      margin-bottom: 24px;
      box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    }
    .era-header-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 14px;
    }
    .era-title-text {
      font-family: var(--font-hud), sans-serif;
      font-size: 1.15rem;
      font-weight: 800;
      color: #00f3ff;
      letter-spacing: 1px;
      text-transform: uppercase;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .era-badge-tag {
      background: rgba(255, 183, 3, 0.15);
      border: 1px solid var(--color-gold);
      color: var(--color-gold);
      font-size: 0.75rem;
      font-weight: 800;
      padding: 3px 10px;
      border-radius: 20px;
      font-family: var(--font-hud);
      text-transform: uppercase;
    }
    .era-buttons-row {
      display: flex;
      gap: 10px;
      overflow-x: auto;
      padding-bottom: 6px;
    }
    .era-btn {
      background: rgba(16, 24, 40, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.12);
      color: #94a3b8;
      padding: 10px 18px;
      border-radius: 12px;
      font-family: var(--font-hud), sans-serif;
      font-size: 1.05rem;
      font-weight: 800;
      cursor: pointer;
      white-space: nowrap;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      display: inline-flex;
      align-items: center;
      gap: 6px;
      text-decoration: none;
    }
    .era-btn:hover {
      border-color: #00f3ff;
      color: #fff;
      transform: translateY(-2px);
      box-shadow: 0 4px 14px rgba(0, 243, 255, 0.25);
    }
    .era-btn.active {
      background: linear-gradient(135deg, rgba(0,243,255,0.25), rgba(0,255,136,0.25));
      border-color: #00f3ff;
      color: #00f3ff;
      box-shadow: 0 0 16px rgba(0, 243, 255, 0.4);
    }
    .board-title-link {
      color: inherit;
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: color 0.2s;
    }
    .board-title-link:hover {
      color: #00f3ff;
    }
    .board-full-link {
      display: block;
      text-align: center;
      margin-top: 14px;
      padding: 10px 14px;
      background: rgba(0, 243, 255, 0.08);
      border: 1px solid rgba(0, 243, 255, 0.2);
      border-radius: 10px;
      color: #00f3ff;
      font-size: 0.85rem;
      font-weight: 700;
      text-decoration: none;
      transition: all 0.2s ease;
    }
    .board-full-link:hover {
      background: #00f3ff;
      color: #000;
      box-shadow: 0 4px 14px rgba(0, 243, 255, 0.4);
    }

  
    /* MASTER EQUIPMENT HUBS GRID */
    .equipment-hubs-section {
      margin-bottom: 32px;
    }
    .equipment-hubs-title {
      font-family: var(--font-hud), sans-serif;
      font-size: 1.25rem;
      font-weight: 800;
      color: #00f3ff;
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 14px;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .equipment-hubs-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 14px;
    }
    .equipment-hub-card {
      background: linear-gradient(135deg, rgba(16, 24, 40, 0.85), rgba(8, 12, 20, 0.95));
      border: 1px solid var(--border-color);
      border-radius: 14px;
      padding: 16px 20px;
      text-decoration: none;
      color: inherit;
      display: flex;
      align-items: center;
      justify-content: space-between;
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    }
    .equipment-hub-card:hover {
      border-color: #00f3ff;
      transform: translateY(-3px);
      box-shadow: 0 8px 24px rgba(0, 243, 255, 0.25);
      background: linear-gradient(135deg, rgba(0, 243, 255, 0.1), rgba(16, 24, 40, 0.95));
    }
    .equipment-hub-info {
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .equipment-hub-icon {
      font-size: 1.8rem;
    }
    .equipment-hub-name {
      font-family: var(--font-hud);
      font-size: 1.15rem;
      font-weight: 800;
      color: #fff;
    }
    .equipment-hub-sub {
      font-size: 0.78rem;
      color: var(--color-text-secondary);
    }
    .equipment-hub-arrow {
      color: #00f3ff;
      font-size: 1.2rem;
      font-weight: 800;
      transition: transform 0.2s;
    }
    .equipment-hub-card:hover .equipment-hub-arrow {
      transform: translateX(4px);
    }

    /* TOP SUPERPOWERS SILOS DIRECTORY */
    .silos-directory-section {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 20px;
      padding: 28px;
      margin-top: 40px;
      margin-bottom: 40px;
      backdrop-filter: blur(25px);
    }
    .silos-directory-title {
      font-family: var(--font-hud);
      font-size: 1.4rem;
      font-weight: 900;
      color: #00f3ff;
      margin-bottom: 8px;
      letter-spacing: 0.5px;
    }
    .silos-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
      gap: 16px;
      margin-top: 20px;
    }
    .silo-country-box {
      background: rgba(0,0,0,0.2);
      border: 1px solid rgba(255,255,255,0.06);
      border-radius: 12px;
      padding: 14px 16px;
    }
    .silo-country-header {
      display: flex;
      align-items: center;
      gap: 8px;
      font-family: var(--font-hud);
      font-size: 1.05rem;
      font-weight: 800;
      color: #fff;
      margin-bottom: 10px;
    }
    .silo-links {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .silo-link-chip {
      background: rgba(0, 243, 255, 0.08);
      border: 1px solid rgba(0, 243, 255, 0.2);
      color: #94a3b8;
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 0.78rem;
      font-weight: 600;
      text-decoration: none;
      transition: all 0.2s;
    }
    .silo-link-chip:hover {
      background: #00f3ff;
      color: #000;
      border-color: #00f3ff;
    }

  
    /* MILITARY HUD ICON BOXES (NO EMOJIS) */
    .hud-icon-box {
      width: 42px;
      height: 42px;
      border-radius: 10px;
      background: rgba(0, 243, 255, 0.1);
      border: 1px solid rgba(0, 243, 255, 0.3);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--color-cyan);
      flex-shrink: 0;
      box-shadow: 0 0 12px rgba(0, 243, 255, 0.2);
    }
    .hud-icon-box svg {
      width: 22px;
      height: 22px;
      stroke: currentColor;
      fill: none;
    }
    .hud-icon-box.gold {
      color: var(--color-gold);
      background: rgba(255, 183, 3, 0.12);
      border-color: rgba(255, 183, 3, 0.35);
      box-shadow: 0 0 12px rgba(255, 183, 3, 0.2);
    }
    .hud-chip-icon {
      width: 14px;
      height: 14px;
      vertical-align: middle;
      margin-right: 4px;
      display: inline-block;
    }

  </style>
  <!-- Google AdSense -->
  <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3184392404381309" crossorigin="anonymous"></script>
</head>
<body data-theme="ww2">

  <!-- Top Navigation Injected by nav.js -->
  <nav class="top-nav"></nav>

  <!-- Left Vertical Skyscraper Ad -->
  <aside class="wmp-ad-flank wmp-ad-flank-left" aria-label="Advertisement">
    <div class="wmp-ad-flank-inner">
      <div class="wmp-ad-flank-label">ADVERTISEMENT</div>
      <!-- WMP -->
      <ins class="adsbygoogle"
           style="display:block"
           data-ad-client="ca-pub-3184392404381309"
           data-ad-slot="7286923029"
           data-ad-format="auto"
           data-full-width-responsive="true"></ins>
      <script>
           (adsbygoogle = window.adsbygoogle || []).push({});
      </script>
    </div>
  </aside>

  <!-- Right Vertical Skyscraper Ad -->
  <aside class="wmp-ad-flank wmp-ad-flank-right" aria-label="Advertisement">
    <div class="wmp-ad-flank-inner">
      <div class="wmp-ad-flank-label">ADVERTISEMENT</div>
      <!-- WMP -->
      <ins class="adsbygoogle"
           style="display:block"
           data-ad-client="ca-pub-3184392404381309"
           data-ad-slot="7286923029"
           data-ad-format="auto"
           data-full-width-responsive="true"></ins>
      <script>
           (adsbygoogle = window.adsbygoogle || []).push({});
      </script>
    </div>
  </aside>

  <main class="rankings-page">
    
    <!-- Bento Grid Header -->
    
    <!-- HISTORICAL DEFENSE TIME TRAVELER (1940 - 2026) -->
    <div class="era-time-traveler-card">
      <div class="era-header-title">
        <div class="era-title-text" style="display:flex; align-items:center; gap:12px;">
          <div class="hud-icon-box gold"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg></div>
          <span>Global Military Power by Historical Era (1940 – 2026)</span>
        </div>
        <div class="era-badge-tag">Interactive Time Machine</div>
      </div>
      <div class="era-buttons-row">
        <a href="/rankings/1940" class="era-btn">1940 (WWII)</a>
        <a href="/rankings/1950" class="era-btn">1950 (Korean War)</a>
        <a href="/rankings/1960" class="era-btn">1960 (Missile Crisis)</a>
        <a href="/rankings/1970" class="era-btn">1970 (Vietnam Era)</a>
        <a href="/rankings/1980" class="era-btn">1980 (Cold War Peak)</a>
        <a href="/rankings/1990" class="era-btn">1990 (Gulf War)</a>
        <a href="/rankings/2000" class="era-btn">2000 (Millennium)</a>
        <a href="/rankings/2010" class="era-btn">2010 (5th-Gen Rise)</a>
        <a href="/rankings" class="era-btn active">2026 (Live Modern)</a>
      </div>
    </div>

    <div class="bento-grid">
      <div class="bento-card bento-main">
        <h1 class="bento-title" data-i18n="rnk_hero_title">Global Military & Economic Leaderboards</h1>
        <p class="bento-desc" data-i18n="rnk_hero_desc">Explore master categorized global leaderboards ranking 241 countries across military strength, GDP, population, land area, oil, gas, gold, and strategic resources.</p>
        <div class="bento-stats">
          <div class="bento-stat-item">
            <div class="bento-stat-val">241</div>
            <div class="bento-stat-lbl" data-i18n="rnk_stat_countries">Nations</div>
          </div>
          <div class="bento-stat-item">
            <div class="bento-stat-val">34</div>
            <div class="bento-stat-lbl" data-i18n="rnk_stat_categories">Categories</div>
          </div>
          <div class="bento-stat-item">
            <div class="bento-stat-val">$105.8T</div>
            <div class="bento-stat-lbl" data-i18n="rnk_stat_gdp">Global GDP</div>
          </div>
        </div>
      </div>

      <div class="bento-card bento-superpower">
        <div style="display:flex;align-items:center;gap:12px;margin-bottom:12px;">
          <img src="https://flagcdn.com/w80/us.png" alt="USA" style="width:48px;height:32px;border-radius:4px;box-shadow:0 2px 8px rgba(0,0,0,0.3);">
          <div>
            <div style="font-size:0.8rem;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:1px;" data-i18n="rnk_top_superpower">#1 Global Superpower</div>
            <div id="rankings-superpower-name" style="font-size:1.3rem;font-weight:800;color:var(--color-text-primary);">United States 👑</div>
          </div>
        </div>
        <div style="font-size:0.88rem;color:var(--color-text-secondary);line-height:1.5;">
          <span data-i18n="rnk_top_superpower_desc">Leads global GDP ($28.7T), carrier strike fleets (11), defense spending ($877B), and air power.</span>
        </div>
      </div>
    </div>

    
    
    <!-- WORLD WAR I & II HISTORICAL WAR ANALYTICS HUBS -->
    <section class="equipment-hubs-section" style="margin-top: 36px;">
      <div class="equipment-hubs-title" style="display:flex; align-items:center; gap:12px;">
        <div class="hud-icon-box gold"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg></div>
        <span>World War Analytics & Defense Production (1914 – 1945)</span>
      </div>
      <div class="equipment-hubs-grid" style="grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));">
        
        <a href="/rankings/ww2.html" class="equipment-hub-card" style="background: linear-gradient(135deg, rgba(255, 183, 3, 0.12), rgba(8, 12, 20, 0.95)), url('/assets/rankings/bg_ww2.jpg') center/cover no-repeat; border-color: rgba(255, 183, 3, 0.4); padding: 22px;">
          <div class="equipment-hub-info">
            <div class="hud-icon-box gold" style="width:48px; height:48px;"><svg viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M14 9h8v2h-8z"/><rect x="2" y="11" width="18" height="7" rx="2"/><path d="M5 11V7h3l4 4"/><circle cx="5" cy="15" r="2"/><circle cx="11" cy="15" r="2"/><circle cx="17" cy="15" r="2"/></svg></div>
            <div>
              <div class="equipment-hub-name" style="font-size:1.3rem; color:#ffd700;">World War II (1939–1945)</div>
              <div class="equipment-hub-sub" style="color:#e2e8f0; margin-top:3px;">Interactive Year-by-Year Production Charts (Tanks, Aircraft, Soldiers, GDP)</div>
            </div>
          </div>
          <span class="equipment-hub-arrow" style="color:#ffd700; font-size:1.4rem;">→</span>
        </a>

        <a href="/rankings/ww1.html" class="equipment-hub-card" style="background: linear-gradient(135deg, rgba(0, 243, 255, 0.12), rgba(8, 12, 20, 0.95)), url('/assets/rankings/bg_ww1.jpg') center/cover no-repeat; border-color: rgba(0, 243, 255, 0.4); padding: 22px;">
          <div class="equipment-hub-info">
            <div class="hud-icon-box" style="width:48px; height:48px;"><svg viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="5" r="3"/><line x1="12" y1="22" x2="12" y2="8"/><path d="M5 12H2a10 10 0 0 0 20 0h-3"/></svg></div>
            <div>
              <div class="equipment-hub-name" style="font-size:1.3rem; color:#00f3ff;">World War I (1914–1918)</div>
              <div class="equipment-hub-sub" style="color:#e2e8f0; margin-top:3px;">The Great War: Trench Artillery, Zeppelins & Dreadnought Fleets</div>
            </div>
          </div>
          <span class="equipment-hub-arrow" style="color:#00f3ff; font-size:1.4rem;">→</span>
        </a>

      </div>
    </section>

    <!-- MASTER EQUIPMENT DEDICATED LEADERBOARDS -->
    <section class="equipment-hubs-section">
      <div class="equipment-hubs-title" style="display:flex; align-items:center; gap:12px;">
        <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg></div>
        <span>Master Military Equipment Leaderboards (250+ Countries)</span>
      </div>
      <div class="equipment-hubs-grid">
        <a href="/rankings/tanks" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M14 9h8v2h-8z"/><rect x="2" y="11" width="18" height="7" rx="2"/><path d="M5 11V7h3l4 4"/><circle cx="5" cy="15" r="2"/><circle cx="11" cy="15" r="2"/><circle cx="17" cy="15" r="2"/></svg></div>
            <div>
              <div class="equipment-hub-name">Main Battle Tanks</div>
              <div class="equipment-hub-sub">Armored Fleets & MBT Census</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/aircraft" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M12 2L15 9L22 13L15 14L14 20L17 22H7L10 20L9 14L2 13L9 9Z"/><path d="M12 6a1.5 1.5 0 0 1 1.5 1.5v3.5a1.5 1.5 0 0 1-3 0V7.5A1.5 1.5 0 0 1 12 6z"/><path d="M10 11.5L4 13.5M14 11.5L20 13.5"/></svg></div>
            <div>
              <div class="equipment-hub-name">Combat Aircraft</div>
              <div class="equipment-hub-sub">Fighter Jets & Air Superiority</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/navy" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><circle cx="12" cy="5" r="3"/><line x1="12" y1="22" x2="12" y2="8"/><path d="M5 12H2a10 10 0 0 0 20 0h-3"/></svg></div>
            <div>
              <div class="equipment-hub-name">Naval Fleet Power</div>
              <div class="equipment-hub-sub">Warships, Destroyers & Frigates</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/submarines" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M2 13c0-2.5 4-4.5 10-4.5s10 2 10 4.5s-4 4.5-10 4.5S2 15.5 2 13z"/><path d="M10 8.5V5.5h3v3"/><path d="M12 5.5V3.5h2"/><path d="M1 11.5l1 1.5-1 1.5"/></svg></div>
            <div>
              <div class="equipment-hub-name">Submarine Fleets</div>
              <div class="equipment-hub-sub">Nuclear (SSBN) & Attack (SSN)</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/aircraft-carriers" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M2 17l2-5h14l4 5H2z"/><path d="M3 12V8h18v4"/><rect x="15" y="4" width="4" height="4"/><line x1="17" y1="4" x2="17" y2="2"/></svg></div>
            <div>
              <div class="equipment-hub-name">Aircraft Carriers</div>
              <div class="equipment-hub-sub">Supercarriers & Flat-Tops</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/military-personnel" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M4 12a8 8 0 0 1 16 0v1a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-1z"/><rect x="6" y="9" width="12" height="3" rx="1.5"/><path d="M4 10.5h2M18 10.5h2"/><path d="M11 4h2v2h-2z"/><path d="M7 14l2 5h6l2-5"/></svg></div>
            <div>
              <div class="equipment-hub-name">Standing Armies</div>
              <div class="equipment-hub-sub">Active Troops & Manpower</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/defense-budget" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><path d="M22 6L13.5 14.5L8.5 9.5L2 16"/><path d="M17 6h5v5"/><path d="M2 20h20"/><path d="M5 20v-2M10 20v-6M15 20v-3M20 20v-9"/></svg></div>
            <div>
              <div class="equipment-hub-name">Defense Budgets</div>
              <div class="equipment-hub-sub">Military Spending & % of GDP</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>

        <a href="/rankings/nuclear-weapons" class="equipment-hub-card">
          <div class="equipment-hub-info">
            <div class="hud-icon-box"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="3"/><path d="M12 9l-3.5-6M12 15l-3.5 6M9.5 10.5l-6-3.5M14.5 13.5l6 3.5M14.5 10.5l6-3.5M9.5 13.5l-6 3.5"/></svg></div>
            <div>
              <div class="equipment-hub-name">Nuclear Arsenals</div>
              <div class="equipment-hub-sub">Warheads & Strategic Triads</div>
            </div>
          </div>
          <span class="equipment-hub-arrow">→</span>
        </a>
      </div>
    </section>

    <!-- Category Tabs -->
    <div class="cat-tabs-container">
      <button class="cat-tab-btn active" onclick="switchCategory('all')" id="btn-cat-all" data-i18n="rank_cat_all">All</button>
      <button class="cat-tab-btn" onclick="switchCategory('military')" id="btn-cat-military" data-i18n="rank_cat_military">Military</button>
      <button class="cat-tab-btn" onclick="switchCategory('gdp-size')" id="btn-cat-gdp-size" data-i18n="rank_cat_gdp">General</button>
      <button class="cat-tab-btn" onclick="switchCategory('resources')" id="btn-cat-resources" data-i18n="rank_cat_resources">Resources</button>
    </div>

    <!-- 🍎 Apple Spotlight Global Top 3 Podium (GDP) -->
    <div class="spotlight-podium" id="spotlight-podium-container"></div>

    <!-- 📈 2000-2026 Historical Growth & Military Timeline -->
    <div class="timeline-card">
      <div class="timeline-header">
        <h3 class="timeline-title">
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
          <span id="timeline-chart-title">Nominal GDP by Country (2000 – 2026)</span>
        </h3>
        <span style="font-size:0.8rem;color:var(--color-text-secondary);" data-i18n="timeline_subtitle">Historical trends for top nations</span>
      </div>
      <div id="timeline-chart-svg-container" style="width:100%;height:220px;"></div>
      <div id="timeline-chart-legend" class="timeline-legend" aria-label="GDP chart legend"></div>
    </div>

    <!-- Mid Ad Banner Section -->
    <div class="wmp-ad-bottom-card" style="margin-bottom: 24px;">
      <div class="wmp-ad-flank-label">ADVERTISEMENT</div>
      <!-- WMP -->
      <ins class="adsbygoogle"
           style="display:block;width:100%;min-height:100px;"
           data-ad-client="ca-pub-3184392404381309"
           data-ad-slot="7286923029"
           data-ad-format="auto"
           data-full-width-responsive="true"></ins>
      <script>
           (adsbygoogle = window.adsbygoogle || []).push({});
      </script>
    </div>

    <!-- Leaderboards Grid -->
    <div class="leaderboards-grid" id="leaderboards-container"></div>

  
    <!-- SUPERPOWERS BRANCH DEEP-DIVE DIRECTORY -->
    <section class="silos-directory-section">
      <h2 class="silos-directory-title">Global Superpowers: Military Branch Encyclopedias</h2>
      <p style="color:var(--color-text-secondary); font-size:0.92rem;">Direct access to official military branch breakdowns, equipment inventories, and combat fleet numbers.</p>
      
      <div class="silos-grid">
        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/us.png" alt="USA" width="22" height="15" style="border-radius:2px;">
            <span>United States Armed Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/usa/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/usa/tanks" class="silo-link-chip">Tanks</a>
            <a href="/countries/usa/navy" class="silo-link-chip">Navy</a>
            <a href="/countries/usa/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/ru.png" alt="Russia" width="22" height="15" style="border-radius:2px;">
            <span>Russian Armed Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/russia/tanks" class="silo-link-chip">Tanks</a>
            <a href="/countries/russia/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/russia/navy" class="silo-link-chip">Navy</a>
            <a href="/countries/russia/drones" class="silo-link-chip">Drones</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/cn.png" alt="China" width="22" height="15" style="border-radius:2px;">
            <span>Chinese PLA Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/china/navy" class="silo-link-chip">Navy</a>
            <a href="/countries/china/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/china/tanks" class="silo-link-chip">Tanks</a>
            <a href="/countries/china/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/tr.png" alt="Turkey" width="22" height="15" style="border-radius:2px;">
            <span>Turkish Armed Forces (TSK)</span>
          </div>
          <div class="silo-links">
            <a href="/countries/turkey/drones" class="silo-link-chip">Drones & UCAVs</a>
            <a href="/countries/turkey/tanks" class="silo-link-chip">Tanks</a>
            <a href="/countries/turkey/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/turkey/navy" class="silo-link-chip">Navy</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/in.png" alt="India" width="22" height="15" style="border-radius:2px;">
            <span>Indian Armed Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/india/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/india/tanks" class="silo-link-chip">Tanks</a>
            <a href="/countries/india/navy" class="silo-link-chip">Navy</a>
            <a href="/countries/india/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/kr.png" alt="South Korea" width="22" height="15" style="border-radius:2px;">
            <span>South Korean Armed Forces (ROK)</span>
          </div>
          <div class="silo-links">
            <a href="/countries/south-korea/tanks" class="silo-link-chip">Tanks (K2)</a>
            <a href="/countries/south-korea/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/south-korea/navy" class="silo-link-chip">Navy</a>
            <a href="/countries/south-korea/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/gb.png" alt="UK" width="22" height="15" style="border-radius:2px;">
            <span>British Armed Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/united-kingdom/navy" class="silo-link-chip">Royal Navy</a>
            <a href="/countries/united-kingdom/air-force" class="silo-link-chip">RAF Air Force</a>
            <a href="/countries/united-kingdom/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/jp.png" alt="Japan" width="22" height="15" style="border-radius:2px;">
            <span>Japan Self-Defense Forces (JSDF)</span>
          </div>
          <div class="silo-links">
            <a href="/countries/japan/navy" class="silo-link-chip">Maritime SDF</a>
            <a href="/countries/japan/air-force" class="silo-link-chip">Air SDF</a>
            <a href="/countries/japan/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/fr.png" alt="France" width="22" height="15" style="border-radius:2px;">
            <span>French Armed Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/france/air-force" class="silo-link-chip">Air & Space</a>
            <a href="/countries/france/navy" class="silo-link-chip">Marine Nationale</a>
            <a href="/countries/france/tanks" class="silo-link-chip">Army</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/de.png" alt="Germany" width="22" height="15" style="border-radius:2px;">
            <span>German Bundeswehr</span>
          </div>
          <div class="silo-links">
            <a href="/countries/germany/tanks" class="silo-link-chip">Leopard 2 Tanks</a>
            <a href="/countries/germany/air-force" class="silo-link-chip">Luftwaffe</a>
            <a href="/countries/germany/defense-budget" class="silo-link-chip">Budget</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/il.png" alt="Israel" width="22" height="15" style="border-radius:2px;">
            <span>Israel Defense Forces (IDF)</span>
          </div>
          <div class="silo-links">
            <a href="/countries/israel/air-force" class="silo-link-chip">IAF Air Force</a>
            <a href="/countries/israel/drones" class="silo-link-chip">Drones</a>
            <a href="/countries/israel/tanks" class="silo-link-chip">Merkava Tanks</a>
          </div>
        </div>

        <div class="silo-country-box">
          <div class="silo-country-header">
            <img src="https://flagcdn.com/w40/pk.png" alt="Pakistan" width="22" height="15" style="border-radius:2px;">
            <span>Pakistan Armed Forces</span>
          </div>
          <div class="silo-links">
            <a href="/countries/pakistan/tanks" class="silo-link-chip">Tanks</a>
            <a href="/countries/pakistan/air-force" class="silo-link-chip">Air Force</a>
            <a href="/countries/pakistan/navy" class="silo-link-chip">Navy</a>
          </div>
        </div>
      </div>
    </section>

    <!-- Bottom Horizontal Ad Banner -->
    <div class="wmp-ad-bottom-card" style="margin-top: 40px; margin-bottom: 20px;">
      <div class="wmp-ad-flank-label">ADVERTISEMENT</div>
      <!-- WMP -->
      <ins class="adsbygoogle"
           style="display:block;width:100%;min-height:100px;"
           data-ad-client="ca-pub-3184392404381309"
           data-ad-slot="7286923029"
           data-ad-format="auto"
           data-full-width-responsive="true"></ins>
      <script>
           (adsbygoogle = window.adsbygoogle || []).push({});
      </script>
    </div>

  </main>

  <!-- Footers & Scripts -->
  <footer class="corporate-footer">
    <div class="footer-inner">
      <div class="footer-brand-col">
        <span style="font-family:var(--font-hud);font-size:1.1rem;font-weight:700;color:var(--color-text-primary);" data-i18n="app_title">World Military Powers</span>
        <span style="font-size:0.82rem;color:var(--color-text-secondary);" data-i18n="footer_mirza_project">A Jir Mirza project.</span>
      </div>
    </div>
  </footer>

  <script src="i18n.js?v=204"></script>
  <script src="nav.js?v=204"></script>
  <script src="countries_data.js?v=204"></script>
  <script src="historical_military_data.js?v=204"></script>
  <script src="culture_expansion.js?v=204"></script>
  <script src="world_expansion.js?v=204"></script>
  <script src="icons.js?v=204"></script>
  <script src="app.js?v=204"></script>
  <script src="consent-adapter.js?v=204"></script>

  <script>
    (function() {
      "use strict";

      let activeFilter = 'all';
      let lang = localStorage.getItem("gpc_lang") || "en";

      function getStr(key) {
        if (typeof window.getI18n === "function") {
          const translated = window.getI18n(key);
          if (translated && translated !== key) return translated;
        }
        const dict = (typeof I18N_DATA !== "undefined" ? I18N_DATA : (window.I18N_DATA || null));
        if (dict) {
          if (dict[lang] && dict[lang][key]) return dict[lang][key];
          if (dict["en"] && dict["en"][key]) return dict["en"][key];
        }
        return key;
      }

      function applyRankingsStaticTranslations() {
        const title = document.getElementById("timeline-chart-title");
        if (title) {
          const t = getStr("timeline_gdp_title");
          if (t && t !== "timeline_gdp_title") title.textContent = t;
        }
        const description = document.querySelector("[data-i18n='rnk_top_superpower_desc']");
        if (description) {
          const d = getStr("rnk_top_superpower_desc");
          if (d && d !== "rnk_top_superpower_desc") description.textContent = d;
        }
        const superpowerName = document.getElementById("rankings-superpower-name") || document.querySelector(".bento-superpower > div > div > div:nth-child(2)");
        if (superpowerName) {
          const usa = getCountryData("USA");
          superpowerName.textContent = getLocalizedCountryName(usa) || "United States 👑";
        }
      }

      function getCountryData(code) {
        return getRankingsCountries().find(c => c.code === code) || {
          code: code,
          activeSoldiers: 0, tanks: 0, vehicles: 0, aircraft: 0, ships: 0, gdp: 0, population: 0, area: 0,
          resources: { oil: 0, gas: 0, coal: 0, iron: 0, uranium: 0, copper: 0, gold: 0 }
        };
      }

      // countries_data.js exposes the database as a classic-script lexical
      // binding, not as window.COUNTRIES_DATA. Keep rankings resilient to both
      // that shared binding and older pages that may still expose window data.
      function getRankingsCountries() {
        if (typeof COUNTRIES_DATA !== "undefined" && Array.isArray(COUNTRIES_DATA)) {
          return COUNTRIES_DATA;
        }
        return Array.isArray(window.COUNTRIES_DATA) ? window.COUNTRIES_DATA : [];
      }

      function getRankingFlagCode(country) {
        if (country && country.iso2) return String(country.iso2).toLowerCase();
        if (country && typeof getFlag === "function" && typeof get2LetterCode === "function") {
          return get2LetterCode(getFlag(country.code)) || String(country.code || "").slice(0, 2).toLowerCase();
        }
        return String(country && country.code || "").slice(0, 2).toLowerCase();
      }

      function getLocalizedCountryName(country) {
        if (!country) return "";
        if (lang === "tr" && country.nameTr) return country.nameTr;
        if (lang === "en" && country.nameEn) return country.nameEn;
        if (country.iso2 && typeof Intl !== "undefined" && Intl.DisplayNames) {
          try {
            const localized = new Intl.DisplayNames([lang], { type: "region" }).of(String(country.iso2).toUpperCase());
            if (localized) return localized;
          } catch (error) {
            // Fall back to the canonical name when a locale or code is unsupported.
          }
        }
        return country.nameEn || country.nameTr || country.code;
      }

      function getFlagHtml(code) {
        const country = getCountryData(code);
        const code2 = getRankingFlagCode(country);
        return code2
          ? `<img src="https://flagcdn.com/w40/${code2}.png" class="flag-icon" alt="${country.nameEn || code}">`
          : (country.nameEn || code);
      }

      function formatNumber(num) {
        return new Intl.NumberFormat(lang).format(Math.round(num));
      }

      function formatResourceNumber(num) {
        const value = Number(num) || 0;
        return new Intl.NumberFormat(lang, { maximumFractionDigits: 0 }).format(value);
      }

      const categories = [
        { id: "activeSoldiers", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2a5 5 0 0 0-5 5v3H6a2 2 0 0 0-2 2v8h16v-8a2 2 0 0 0-2-2h-1V7a5 5 0 0 0-5-5z"/></svg>', nameEn: "Active Military Personnel", nameTr: "Aktif Askeri Personel", valueFn: c => c.activeSoldiers, formatFn: v => `${formatNumber(v)}` },
        { id: "tanks", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M14 9h8v2h-8z"/><rect x="2" y="11" width="18" height="7" rx="2"/><circle cx="5" cy="15" r="2"/><circle cx="11" cy="15" r="2"/><circle cx="17" cy="15" r="2"/></svg>', nameEn: "Main Battle Tanks", nameTr: "Ana Muharebe Tankları", valueFn: c => c.tanks, formatFn: v => `${formatNumber(v)}` },
        { id: "vehicles", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><rect x="2" y="7" width="20" height="10" rx="2"/><circle cx="6" cy="17" r="2"/><circle cx="18" cy="17" r="2"/></svg>', nameEn: "Armored Fighting Vehicles", nameTr: "Zırhlı Muharebe Araçları", valueFn: c => c.vehicles, formatFn: v => `${formatNumber(v)}` },
        { id: "aircraft", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2L15 9L22 13L15 14L14 20L17 22H7L10 20L9 14L2 13L9 9Z"/></svg>', nameEn: "Combat Aircraft", nameTr: "Savaş Uçakları", valueFn: c => c.aircraft, formatFn: v => `${formatNumber(v)}` },
        { id: "ships", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="5" r="3"/><line x1="12" y1="22" x2="12" y2="8"/><path d="M5 12H2a10 10 0 0 0 20 0h-3"/></svg>', nameEn: "Naval Warships", nameTr: "Savaş Gemileri & Donanma", valueFn: c => c.ships, formatFn: v => `${formatNumber(v)}` },
        { id: "antiAir", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2v20M2 12h20M5 5l14 14M19 5L5 19"/></svg>', nameEn: "Air Defense Systems", nameTr: "Hava Savunma Sistemleri", valueFn: c => c.landDetails ? (c.landDetails.antiAir || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "antiTank", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M4 4l16 16M4 20L20 4"/></svg>', nameEn: "Anti-Tank Guided Missiles", nameTr: "Tanksavar Sistemleri", valueFn: c => c.landDetails ? (c.landDetails.antiTank || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "tankMbt", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M14 9h8v2h-8z"/><rect x="2" y="11" width="18" height="7" rx="2"/><circle cx="5" cy="15" r="2"/><circle cx="11" cy="15" r="2"/><circle cx="17" cy="15" r="2"/></svg>', nameEn: "Heavy MBT Fleets", nameTr: "Ağır Tank Birlikleri", valueFn: c => c.landDetails ? (c.landDetails.tankMbt || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "heliAttack", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M3 10h18M12 2v8M6 14h12l-2 4H8z"/></svg>', nameEn: "Attack Helicopters", nameTr: "Taarruz Helikopterleri", valueFn: c => c.aircraftDetails ? (c.aircraftDetails.heliAttack || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "heliTransport", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M3 10h18M12 2v8M4 14h16l-3 4H7z"/></svg>', nameEn: "Transport Helicopters", nameTr: "Nakliye Helikopterleri", valueFn: c => c.aircraftDetails ? (c.aircraftDetails.heliTransport || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "st_nuclear", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="12" r="3"/><path d="M12 2v4M12 18v4M2 12h4M18 12h4"/></svg>', nameEn: "Nuclear Warheads", nameTr: "Nükleer Savaş Başlıkları", valueFn: c => c.strategic ? (c.strategic.nuclear || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "st_icbm", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2l3 7h-6zM9 9v10l3 3 3-3V9z"/></svg>', nameEn: "ICBM Ballistic Missiles", nameTr: "Kıtalararası Balistik Füzeler", valueFn: c => c.strategic ? (c.strategic.icbm || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "st_drones", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="12" r="2"/><path d="M6 6l12 12M6 18L18 6"/></svg>', nameEn: "Combat Drones (UCAV)", nameTr: "SİHA & Muharip İHA", valueFn: c => c.strategic ? (c.strategic.drones || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "st_suicideDrones", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2l4 8-8 4 4 8"/></svg>', nameEn: "Loitering Munitions (Kamikaze)", nameTr: "Kamikaze Dronlar", valueFn: c => c.strategic ? (c.strategic.suicideDrones || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "st_cruiseMissiles", type: "military", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M4 14l16-6-6 16-2-8z"/></svg>', nameEn: "Cruise Missiles", nameTr: "Seyir Füzeleri", valueFn: c => c.strategic ? (c.strategic.cruiseMissiles || 0) : 0, formatFn: v => `${formatNumber(v)}` },
        { id: "gdp", type: "gdp-size", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><rect x="2" y="4" width="20" height="16" rx="2"/><circle cx="12" cy="12" r="4"/><path d="M6 8h.01M18 16h.01"/></svg>', nameEn: "Nominal GDP", nameTr: "Nominal GSYİH", valueFn: c => c.gdp, formatFn: v => window.formatGDPCompact ? window.formatGDPCompact(v) : `$${v}B` },
        { id: "population", type: "gdp-size", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>', nameEn: "Total Population", nameTr: "Toplam Nüfus", valueFn: c => c.population, formatFn: v => window.formatPopulationCompact ? window.formatPopulationCompact(v) : `${v}` },
        { id: "area", type: "gdp-size", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M3 3h18v18H3zM9 3v18M15 3v18M3 9h18M3 15h18"/></svg>', nameEn: "Territorial Land Area", nameTr: "Yüzölçümü", valueFn: c => c.area || 0, formatFn: v => `${formatNumber(v)} km²` },
        { id: "oil", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2c-3.5 5.5-6 8.5-6 12a6 6 0 0 0 12 0c0-3.5-2.5-6.5-6-12z"/></svg>', nameEn: "Crude Oil Production", nameTr: "Ham Petrol Üretimi", valueFn: c => (c.resources ? c.resources.oil : 0), formatFn: v => `${formatResourceNumber(v)} bbl/d` },
        { id: "gas", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>', nameEn: "Natural Gas Reserves", nameTr: "Doğal Gaz Üretimi", valueFn: c => (c.resources ? c.resources.gas : 0), formatFn: v => `${formatResourceNumber(v)} m³/yr` },
        { id: "coal", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><polygon points="12 2 2 7 12 12 22 7 12 2"/><polygon points="2 17 12 22 22 17 12 12 2 7"/></svg>', nameEn: "Coal Production", nameTr: "Kömür Üretimi", valueFn: c => (c.resources ? c.resources.coal : 0), formatFn: v => `${formatResourceNumber(v)} t/yr` },
        { id: "iron", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M9 9h6v6H9z"/></svg>', nameEn: "Iron Ore Production", nameTr: "Demir Cevheri", valueFn: c => (c.resources ? c.resources.iron : 0), formatFn: v => `${formatResourceNumber(v)} M t/yr` },
        { id: "uranium", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="12" r="3"/><path d="M12 2v4M12 18v4M2 12h4M18 12h4"/></svg>', nameEn: "Uranium Reserves", nameTr: "Uranyum Üretimi", valueFn: c => (c.resources ? c.resources.uranium : 0), formatFn: v => `${formatResourceNumber(v)} t/yr` },
        { id: "copper", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/></svg>', nameEn: "Copper Production", nameTr: "Bakır Üretimi", valueFn: c => (c.resources ? c.resources.copper : 0), formatFn: v => `${formatResourceNumber(v)} kt/yr` },
        { id: "gold", type: "resources", icon: '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2.2"><circle cx="12" cy="8" r="6"/><path d="M15.477 12.89 17 22l-5-3-5 3 1.523-9.11"/></svg>', nameEn: "Gold Mining Reserves", nameTr: "Altın Madenciliği", valueFn: c => (c.resources ? c.resources.gold : 0), formatFn: v => `${formatResourceNumber(v)} t/yr` }
      ];

      function getCategoryIcon(cat) {
        return cat.icon || '<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/></svg>';
      }

      // Historical Trajectory Data (2000, 2005, 2010, 2015, 2020, 2026)
      const HISTORICAL_TIMELINES = {
        USA: [10250, 13090, 14990, 18240, 21060, 28780],
        CHN: [1210, 2290, 6090, 11060, 14690, 18530],
        DEU: [1950, 2850, 3400, 3350, 3880, 4590],
        JPN: [4970, 4830, 5750, 4440, 5040, 4110],
        IND: [470, 820, 1670, 2100, 2670, 3940]
      };

      function renderSpotlightPodium() {
        const container = document.getElementById("spotlight-podium-container");
        if (!container) return;
        const gdpCat = categories.find(c => c.id === 'gdp');

        const top3 = [...getRankingsCountries()]
          .map(country => ({
            code: country.code,
            name: getLocalizedCountryName(country),
            val: gdpCat ? gdpCat.valueFn(country) : (country.gdp || 0)
          }))
          .sort((a, b) => b.val - a.val)
          .slice(0, 3);

        if (top3.length < 3) return;

        const displayOrder = [top3[1], top3[0], top3[2]];

        container.innerHTML = displayOrder.map((country) => {
          const actualRank = country === top3[0] ? 1 : (country === top3[1] ? 2 : 3);
          const flag2 = getRankingFlagCode(getCountryData(country.code));
          
          return `
            <div class="podium-box rank-${actualRank}">
              <div class="podium-rank rank-${actualRank}">Nominal GDP • #${actualRank}</div>
              <img class="podium-flag-img" src="https://flagcdn.com/w80/${flag2}.png" alt="${country.name}">
              <div class="podium-country-name">${country.name}</div>
              <div class="podium-value-text">${gdpCat ? gdpCat.formatFn(country.val) : '$' + country.val + 'B'}</div>
            </div>
          `;
        }).join("");
      }

      function getCategoryUrl(catId) {
        const map = {
          "tanks": "/rankings/tanks",
          "tankMbt": "/rankings/tanks",
          "vehicles": "/rankings/tanks",
          "aircraft": "/rankings/aircraft",
          "heliAttack": "/rankings/aircraft",
          "heliTransport": "/rankings/aircraft",
          "ships": "/rankings/navy",
          "activeSoldiers": "/rankings/military-personnel",
          "gdp": "/rankings/defense-budget",
          "st_nuclear": "/rankings/nuclear-weapons",
          "st_icbm": "/rankings/nuclear-weapons",
          "st_drones": "/rankings/tanks",
          "oil": "/rankings/defense-budget",
          "gas": "/rankings/defense-budget",
          "coal": "/rankings/defense-budget",
          "iron": "/rankings/defense-budget",
          "uranium": "/rankings/nuclear-weapons",
          "copper": "/rankings/defense-budget",
          "gold": "/rankings/defense-budget"
        };
        return map[catId] || ("/rankings/" + catId);
      }

      function renderLeaderboards() {
        const container = document.getElementById("leaderboards-container");
        if (!container) return;
        container.innerHTML = "";

        categories.forEach(cat => {
          if (activeFilter !== 'all' && cat.type !== activeFilter) {
            return;
          }

          const card = document.createElement("div");
          card.className = "board-card";

          const top10 = [...getRankingsCountries()]
            .map(country => ({
              code: country.code,
              name: getLocalizedCountryName(country),
              val: cat.valueFn(country)
            }))
            .filter(item => item.val > 0)
            .sort((a, b) => b.val - a.val)
            .slice(0, 10);

          const displayTitle = lang === 'tr' ? cat.nameTr : cat.nameEn;
          const catLink = getCategoryUrl(cat.id);

          let boardHtml = `
            <div class="board-header">
              <span class="board-icon">${getCategoryIcon(cat)}</span>
              <h2 class="board-title">
                <a href="${catLink}" class="board-title-link">
                  ${displayTitle} <span style="font-size:0.85rem; color:var(--color-cyan); margin-left:4px;">↗</span>
                </a>
              </h2>
              <button class="card-export-btn" title="Download CSV" onclick="event.stopPropagation(); window.exportSingleCSV('${cat.id}')">
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
              </button>
            </div>
            <div class="board-list">
          `;

          top10.forEach((item, index) => {
            const rank = index + 1;
            let rankClass = "";
            if (rank === 1) rankClass = "rank-1";
            else if (rank === 2) rankClass = "rank-2";
            else if (rank === 3) rankClass = "rank-3";

            boardHtml += `
              <div class="board-row" onclick="window.location.href='/country/' + (typeof window.getCountrySlug === 'function' ? window.getCountrySlug(item.code) : item.code.toLowerCase())">
                <span class="rank-badge ${rankClass}">#${rank}</span>
                <div class="country-flag-wrapper">${getFlagHtml(item.code)}</div>
                <span class="country-name">${item.name}</span>
                <span class="metric-value">${cat.formatFn(item.val)}</span>
              </div>
            `;
          });

          if (top10.length === 0) {
            boardHtml += `<div style="text-align:center; padding:20px; color:var(--color-text-secondary); font-style:italic;">${getStr("data_unavailable")}</div>`;
          }

          boardHtml += `</div>`;
          boardHtml += `
            <a href="${catLink}" class="board-full-link">
              ${lang === 'tr' ? `Tüm ${displayTitle} Sıralamasını Gör (250+ Ülke) →` : `View Complete ${displayTitle} Rankings (250+ Countries) →`}
            </a>
          `;
          card.innerHTML = boardHtml;
          container.appendChild(card);
        });
      }

      function renderTimelineChart() {
        const svgContainer = document.getElementById("timeline-chart-svg-container");
        const legendContainer = document.getElementById("timeline-chart-legend");
        const topNations = ['USA', 'CHN', 'DEU', 'JPN', 'IND'];
        const years = [2000, 2005, 2010, 2015, 2020, 2026];
        const colors = ['#0071e3', '#ff2e56', '#ffd700', '#2ecc71', '#9b59b6'];

        let svgHtml = `<svg width="100%" height="220" viewBox="0 0 800 220" preserveAspectRatio="none" style="overflow:visible;">`;

        years.forEach((yr, idx) => {
          const x = 50 + idx * 140;
          svgHtml += `<line x1="${x}" y1="20" x2="${x}" y2="180" stroke="rgba(255,255,255,0.08)" stroke-width="1" stroke-dasharray="4,4"/>`;
          svgHtml += `<text x="${x}" y="202" fill="var(--color-text-secondary)" font-size="11" text-anchor="middle">${yr}</text>`;
        });

        topNations.forEach((code, nIdx) => {
          const data = HISTORICAL_TIMELINES[code] || [100, 200, 300, 400, 500, 600];
          const maxVal = 30000;
          const points = data.map((val, idx) => {
            const x = 50 + idx * 140;
            const y = 180 - (val / maxVal) * 150;
            return `${x},${y}`;
          }).join(" ");

          const strokeColor = colors[nIdx % colors.length];
          svgHtml += `<polyline fill="none" stroke="${strokeColor}" stroke-width="3" points="${points}" opacity="0.9"/>`;
          
          data.forEach((val, idx) => {
            const x = 50 + idx * 140;
            const y = 180 - (val / maxVal) * 150;
            svgHtml += `<circle cx="${x}" cy="${y}" r="4" fill="${strokeColor}"><title>${code} (${years[idx]}): ${window.formatGDPCompact(val)}</title></circle>`;
          });
        });

        svgHtml += `</svg>`;
        svgContainer.innerHTML = svgHtml;

        if (legendContainer) {
          legendContainer.innerHTML = topNations.map((code, nIdx) => {
            const country = getCountryData(code);
            const latest = (HISTORICAL_TIMELINES[code] || []).at(-1) || 0;
            const color = colors[nIdx % colors.length];
            const localizedName = getLocalizedCountryName(country);
            return `<span class="timeline-legend-item" title="${localizedName}: ${years[years.length - 1]} nominal GDP">
              <span class="timeline-legend-swatch" style="background:${color};box-shadow:0 0 8px ${color};"></span>
              <strong>${localizedName}</strong>
              <span>${window.formatGDPCompact(latest)}</span>
            </span>`;
          }).join("");
        }
      }

      window.switchCategory = function(catType) {
        activeFilter = catType;
        document.querySelectorAll(".cat-tab-btn").forEach(btn => {
          btn.classList.remove("active");
        });
        
        let targetBtn = "btn-cat-all";
        if (catType === 'military') targetBtn = "btn-cat-military";
        else if (catType === 'resources') targetBtn = "btn-cat-resources";
        else if (catType === 'gdp-size') targetBtn = "btn-cat-gdp-size";
        
        const btnEl = document.getElementById(targetBtn);
        if (btnEl) btnEl.classList.add("active");
        
        renderLeaderboards();
      };

      window.exportSingleCSV = function(catId) {
        const cat = categories.find(c => c.id === catId);
        if (!cat) return;

        let csv = "Rank,Nation,Code,Value\n";
        const top10 = [...getRankingsCountries()]
          .map(country => ({
            code: country.code,
            name: getLocalizedCountryName(country),
            val: cat.valueFn(country)
          }))
          .filter(item => item.val > 0)
          .sort((a, b) => b.val - a.val)
          .slice(0, 10);

        top10.forEach((item, index) => {
          csv += `${index+1},"${item.name}",${item.code},${item.val}\n`;
        });

        const blob = new Blob([csv], { type: 'text/csv' });
        const link = document.createElement('a');
        link.download = `WMP_Rankings_${catId}.csv`;
        link.href = URL.createObjectURL(blob);
        link.click();
      };

      // Listen for i18n switches
      window.addEventListener("langChanged", function(e) {
        lang = e.detail;
        applyRankingsStaticTranslations();
        renderSpotlightPodium();
        renderLeaderboards();
        renderTimelineChart();
      });

      window.addEventListener("load", () => {
        applyRankingsStaticTranslations();
        renderSpotlightPodium();
        renderLeaderboards();
        renderTimelineChart();
      });
    })();
  </script>
</body>
</html>