// wci26/leaderboard-views.jsx — three view modes: Board, Battle, Race Track

// ───────── Medal SVG (used in board view) ─────────
const Medal = ({ rank, size = 22 }) => {
  if (rank > 3) return <span className="display" style={{ fontSize: size * 0.7, color: 'var(--t3)', width: size, display: 'inline-block', textAlign: 'center' }}>#{rank}</span>;
  const cols = rank === 1 ? ['#FFE85B', '#F5D020', '#A88900'] : rank === 2 ? ['#E8E8F0', '#B8BCC8', '#6E7280'] : ['#F5A464', '#CD7F32', '#7A4A14'];
  return (
    <svg width={size} height={size + 4} viewBox="0 0 22 26" style={{ flexShrink: 0 }}>
      <defs>
        <linearGradient id={`medal-${rank}`} x1="0" y1="0" x2="0" y2="1">
          <stop offset="0%" stopColor={cols[0]} />
          <stop offset="55%" stopColor={cols[1]} />
          <stop offset="100%" stopColor={cols[2]} />
        </linearGradient>
      </defs>
      {/* Ribbon */}
      <path d={`M 6 0 L 8 12 L 5 12 Z`} fill={cols[1]} opacity="0.9" />
      <path d={`M 16 0 L 14 12 L 17 12 Z`} fill={cols[2]} opacity="0.9" />
      {/* Circle */}
      <circle cx="11" cy="16" r="8" fill={`url(#medal-${rank})`} stroke={cols[2]} strokeWidth="0.8" />
      <circle cx="11" cy="16" r="5.5" fill="none" stroke={cols[0]} strokeWidth="0.5" opacity="0.7" />
      <text x="11" y="19" textAnchor="middle" fontSize="9" fontWeight="800" fontFamily="Bricolage Grotesque, sans-serif" fill={cols[2]}>{rank}</text>
    </svg>
  );
};

// ───────── Momentum / streak icons ─────────
const StreakChip = ({ hours }) => (
  <span title={`Streak: ${hours} hrs pumping`} style={{
    display: 'inline-flex', alignItems: 'center', gap: 4,
    padding: '2px 6px', borderRadius: 999,
    background: 'rgba(232,57,44,0.15)', border: '1px solid rgba(232,57,44,0.4)',
    fontSize: 10, fontWeight: 700, color: '#FF7060',
  }}>
    <span style={{ fontSize: 11, lineHeight: 1 }}>🔥</span>
    {hours}h
  </span>
);

const RocketChip = ({ intensity }) => {
  const count = Math.min(3, Math.max(1, intensity));
  return (
    <span title={`Momentum: ${count}x`} style={{
      display: 'inline-flex', alignItems: 'center',
      fontSize: 11, lineHeight: 1, letterSpacing: -1,
    }}>
      {'▲'.repeat(count)}
    </span>
  );
};

// ───────── Board view (table) — current row layout but with medals + momentum
const BoardView = ({ countries, onPick }) => {
  const maxVol = Math.max(1, ...countries.map(c => c.volume24h || 0));
  return (
    <div style={{
      borderRadius: 18,
      background: 'linear-gradient(180deg, rgba(41,31,82,0.4), rgba(20,16,40,0.9))',
      border: '1px solid var(--hair)',
      overflow: 'hidden',
    }}>
      {/* Header */}
      <div style={{
        display: 'grid',
        gridTemplateColumns: '46px 50px 200px 1fr 110px 90px 90px 100px 60px',
        gap: 12, padding: '12px 18px',
        background: 'rgba(0,0,0,0.4)',
        borderBottom: '1px solid var(--hair)',
      }}>
        {['', 'FLAG', 'COUNTRY', '24H VOLUME', 'PRICE', '24h %', 'HOLDERS', 'MCAP', 'GROUP'].map(h => (
          <div key={h} className="label" style={{ fontSize: 9 }}>{h}</div>
        ))}
      </div>
      {countries.map((c) => {
        const pct = ((c.volume24h || 0) / maxVol) * 100;
        const streakHrs = Math.floor((c.momentum * 12 + (c.change24h > 0 ? c.change24h / 4 : 0)));
        return (
          <button key={c.code} onClick={() => onPick(c)} style={{
            display: 'grid',
            gridTemplateColumns: '46px 50px 200px 1fr 110px 90px 90px 100px 60px',
            gap: 12, padding: '12px 18px',
            background: 'transparent', border: 0,
            borderBottom: '1px solid rgba(255,255,255,0.03)',
            width: '100%', textAlign: 'left', cursor: 'pointer',
            alignItems: 'center', color: 'inherit',
            transition: 'background 160ms',
          }}
          onMouseEnter={e => e.currentTarget.style.background = `rgba(${parseInt(c.color.slice(1,3),16)}, ${parseInt(c.color.slice(3,5),16)}, ${parseInt(c.color.slice(5,7),16)}, 0.06)`}
          onMouseLeave={e => e.currentTarget.style.background = 'transparent'}>
            <Medal rank={c.rank} />
            <FlagRect code={c.code} w={28} h={19} />
            <div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                <span className="display" style={{ fontSize: 14, color: '#fff' }}>{c.code}</span>
                {c.change24h > 8 && streakHrs > 4 && <StreakChip hours={streakHrs} />}
              </div>
              <div style={{ fontSize: 11, color: 'var(--t3)' }}>{c.name}</div>
            </div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
              <div style={{
                flex: 1, height: 8, borderRadius: 4,
                background: 'rgba(255,255,255,0.05)',
                overflow: 'hidden', position: 'relative',
                boxShadow: 'inset 0 1px 2px rgba(0,0,0,0.5)',
              }}>
                <div style={{
                  position: 'absolute', inset: 0, width: pct + '%',
                  background: `linear-gradient(90deg, ${c.color}, ${c.secondary})`,
                  boxShadow: `0 0 12px ${c.color}, inset 0 1px 0 rgba(255,255,255,0.4)`,
                }} />
              </div>
            <span className="mono" style={{ fontSize: 11, color: 'var(--t2)', fontWeight: 700, minWidth: 70 }}>{typeof wciFormatCountryVolume === 'function' ? wciFormatCountryVolume(c) : fmtVol(c.volume24h)}</span>
            </div>
            <span className="mono" style={{ fontSize: 13, fontWeight: 700 }}>{typeof wciFormatCountryPrice === 'function' ? wciFormatCountryPrice(c) : fmtPrice(c.price)}</span>
            <span className="mono" style={{ fontSize: 13, fontWeight: 700, display: 'inline-flex', gap: 4, color: c.change24h >= 0 ? 'var(--lime)' : 'var(--coral)' }}>
              <RocketChip intensity={Math.abs(c.change24h / 8)} />
              {c.change24h >= 0 ? '+' : ''}{c.change24h.toFixed(1)}%
            </span>
            <span className="mono" style={{ fontSize: 13 }}>{fmtNum(c.holders)}</span>
            <span className="mono" style={{ fontSize: 13 }}>{typeof wciFormatCountryMarketCap === 'function' ? wciFormatCountryMarketCap(c) : fmtMcap(c.mcap)}</span>
            <div style={{ display: 'flex', justifyContent: 'center' }}>
              <span style={{
                width: 28, height: 28, borderRadius: 7,
                background: `var(--grp-${c.group.toLowerCase()})`,
                display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                color: '#0a0615', fontWeight: 800, fontSize: 13,
                fontFamily: 'Bricolage Grotesque, sans-serif',
                boxShadow: 'inset 0 1.5px 0 rgba(255,255,255,0.4), inset 0 -1px 0 rgba(0,0,0,0.2), 0 2px 0 rgba(0,0,0,0.4)',
              }}>{c.group}</span>
            </div>
          </button>
        );
      })}
    </div>
  );
};

// ───────── Battle View — head-to-head pairs ─────────
const BattleView = ({ countries, onPick }) => {
  // Group by adjacent ranks: (1,2) (3,4) (5,6) ... only top 16 → 8 battles
  const pairs = [];
  const slice = countries.slice(0, 16);
  for (let i = 0; i < slice.length; i += 2) {
    pairs.push([slice[i], slice[i + 1]]);
  }
  return (
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 16 }}>
      {pairs.map(([a, b], i) => <BattleCard key={i} a={a} b={b} onPick={onPick} />)}
    </div>
  );
};

const BattleCard = ({ a, b, onPick }) => {
  // Volume gap → percent of a's volume that b lags
  const total = a.volume24h + b.volume24h;
  const aPct = total ? (a.volume24h / total) * 100 : 50;
  const bPct = 100 - aPct;
  return (
    <div style={{
      position: 'relative',
      padding: 16, borderRadius: 16,
      background: `
        linear-gradient(90deg, ${a.color}11 0%, transparent 40%, transparent 60%, ${b.color}11 100%),
        linear-gradient(180deg, rgba(29,23,64,0.6), rgba(20,16,40,0.95))`,
      border: '1px solid var(--hair-strong)',
      boxShadow: 'inset 0 1.5px 0 rgba(255,255,255,0.08), 0 8px 24px -8px rgba(0,0,0,0.7)',
      overflow: 'hidden',
    }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 12 }}>
        <Chip kind="gold" style={{ background: 'rgba(245,208,32,0.1)', fontSize: 10 }}>#{a.rank} vs #{b.rank}</Chip>
        <span className="label" style={{ fontSize: 9 }}>VOLUME BATTLE</span>
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr auto 1fr', gap: 14, alignItems: 'center', marginBottom: 12 }}>
        {/* A */}
        <button onClick={() => onPick(a)} style={{
          background: 'transparent', border: 0, padding: 0, cursor: 'pointer', textAlign: 'left',
          display: 'flex', alignItems: 'center', gap: 10,
        }}>
          <FlagRect code={a.code} w={42} h={28} />
          <div>
            <div className="display" style={{ fontSize: 18, color: '#fff', lineHeight: 1 }}>{a.code}</div>
            <div className="mono" style={{ fontSize: 11, color: a.color, fontWeight: 700, marginTop: 2 }}>
              {typeof wciFormatCountryVolume === 'function' ? wciFormatCountryVolume(a) : fmtVol(a.volume24h)}
            </div>
          </div>
        </button>

        {/* VS center */}
        <div style={{
          width: 36, height: 36, borderRadius: '50%',
          background: 'radial-gradient(circle, rgba(245,208,32,0.25), rgba(245,208,32,0.05))',
          border: '1.5px solid var(--gold)',
          display: 'grid', placeItems: 'center',
          boxShadow: '0 0 20px -4px var(--gold), inset 0 1px 0 rgba(255,255,255,0.2)',
        }}>
          <span className="display" style={{ fontSize: 12, color: 'var(--gold)' }}>VS</span>
        </div>

        {/* B */}
        <button onClick={() => onPick(b)} style={{
          background: 'transparent', border: 0, padding: 0, cursor: 'pointer', textAlign: 'right',
          display: 'flex', alignItems: 'center', gap: 10, justifyContent: 'flex-end',
        }}>
          <div style={{ textAlign: 'right' }}>
            <div className="display" style={{ fontSize: 18, color: '#fff', lineHeight: 1 }}>{b.code}</div>
            <div className="mono" style={{ fontSize: 11, color: b.color, fontWeight: 700, marginTop: 2 }}>
              {typeof wciFormatCountryVolume === 'function' ? wciFormatCountryVolume(b) : fmtVol(b.volume24h)}
            </div>
          </div>
          <FlagRect code={b.code} w={42} h={28} />
        </button>
      </div>

      {/* Tug-of-war bar */}
      <div style={{
        position: 'relative',
        height: 12, borderRadius: 6,
        background: 'rgba(0,0,0,0.4)',
        overflow: 'hidden', display: 'flex',
        boxShadow: 'inset 0 1px 2px rgba(0,0,0,0.6)',
      }}>
        <div style={{
          width: aPct + '%',
          background: `linear-gradient(90deg, ${a.color}, ${a.color}cc)`,
          boxShadow: `inset 0 1px 0 rgba(255,255,255,0.4), 0 0 10px ${a.color}`,
          transition: 'width 1.5s var(--ease)',
        }} />
        <div style={{
          width: bPct + '%',
          background: `linear-gradient(90deg, ${b.color}cc, ${b.color})`,
          boxShadow: `inset 0 1px 0 rgba(255,255,255,0.4), 0 0 10px ${b.color}`,
          transition: 'width 1.5s var(--ease)',
        }} />
        {/* Center divider */}
        <div style={{
          position: 'absolute', left: '50%', top: 0, bottom: 0, width: 1,
          background: 'rgba(255,255,255,0.3)',
        }} />
      </div>

      {/* Gap stat */}
      <div style={{ marginTop: 8, display: 'flex', justifyContent: 'space-between', fontSize: 10 }}>
        <span className="mono" style={{ color: a.color, fontWeight: 700 }}>{aPct.toFixed(1)}%</span>
        <span style={{ color: 'var(--t3)' }}>
          gap · {typeof wciCountryVolumeUsd === 'function' && typeof wciFormatCompactUsd === 'function'
            ? wciFormatCompactUsd(Math.abs(wciCountryVolumeUsd(a) - wciCountryVolumeUsd(b)), '$0')
            : fmtVol(Math.abs(a.volume24h - b.volume24h))}
        </span>
        <span className="mono" style={{ color: b.color, fontWeight: 700 }}>{bPct.toFixed(1)}%</span>
      </div>
    </div>
  );
};

// ───────── Race Track View — the wow shot ─────────
const RaceTrackView = ({ countries, onPick }) => {
  // Top 20 in the race — lanes
  const racers = countries.slice(0, 24);
  const maxVol = Math.max(1, ...racers.map(c => c.volume24h || 0));
  return (
    <div style={{
      position: 'relative',
      padding: '40px 32px 32px',
      borderRadius: 20,
      background: `
        radial-gradient(ellipse 60% 40% at 50% 50%, rgba(245,208,32,0.06), transparent 70%),
        linear-gradient(180deg, rgba(29,23,64,0.6), rgba(10,6,21,0.95))`,
      border: '1px solid var(--hair-strong)',
      boxShadow: 'inset 0 1.5px 0 rgba(255,255,255,0.08), 0 12px 32px -10px rgba(0,0,0,0.7)',
      overflow: 'hidden',
    }}>
      {/* Stadium scanlines bg */}
      <div style={{
        position: 'absolute', inset: 0, pointerEvents: 'none',
        backgroundImage: 'repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255,255,255,0.04) calc(10% - 1px) 10%)',
        opacity: 0.6,
      }} />

      {/* START / FINISH labels */}
      <div style={{
        position: 'absolute', top: 14, left: 220, right: 80,
        display: 'flex', justifyContent: 'space-between',
        pointerEvents: 'none',
      }}>
        <span className="label" style={{ color: 'var(--t3)', fontSize: 9 }}>START</span>
        <span className="label" style={{ color: 'var(--gold)', fontSize: 9 }}>FINISH ▶</span>
      </div>

      {/* Lanes */}
      <div style={{ position: 'relative', display: 'flex', flexDirection: 'column', gap: 6, marginTop: 16 }}>
        {racers.map((c, i) => {
          const progress = ((c.volume24h || 0) / maxVol) * 100;
          return (
            <RaceLane key={c.code} c={c} progress={progress} onPick={onPick} index={i} />
          );
        })}
      </div>

      {/* Footer */}
      <div style={{ marginTop: 20, paddingTop: 14, borderTop: '1px solid var(--hair)',
        display: 'flex', justifyContent: 'space-between', alignItems: 'center',
      }}>
        <div style={{ fontSize: 11, color: 'var(--t3)' }}>
          Showing top {racers.length} · positions update every tick · click any lane to back that country
        </div>
        <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
          <span className="label">PACE</span>
          <span className="mono" style={{ fontSize: 12, color: 'var(--lime)', fontWeight: 700 }}>
            {typeof wciFormatAggregateCountryVolume === 'function' ? wciFormatAggregateCountryVolume(racers) : fmtVol(racers.reduce((s, c) => s + c.volume24h, 0))} / 24h
          </span>
        </div>
      </div>
    </div>
  );
};

const RaceLane = ({ c, progress, onPick, index }) => {
  return (
    <button onClick={() => onPick(c)} style={{
      position: 'relative',
      display: 'grid',
      gridTemplateColumns: '36px 30px 78px 1fr 80px',
      gap: 10, alignItems: 'center',
      padding: '6px 10px', borderRadius: 10,
      background: index < 3 ? `linear-gradient(90deg, ${c.color}10, transparent 60%)` : 'transparent',
      border: '1px solid ' + (index === 0 ? c.color + '66' : 'rgba(255,255,255,0.04)'),
      cursor: 'pointer', textAlign: 'left',
      transition: 'background 160ms, transform 160ms',
    }}
    onMouseEnter={e => e.currentTarget.style.transform = 'translateX(3px)'}
    onMouseLeave={e => e.currentTarget.style.transform = 'translateX(0)'}>
      <span className="display" style={{
        fontSize: 13, width: 36, textAlign: 'center',
        color: index === 0 ? 'var(--gold)' : index < 3 ? 'var(--fifa-yellow)' : 'var(--t3)',
      }}>P{c.rank}</span>
      <FlagRect code={c.code} w={26} h={18} />
      <span className="display" style={{ fontSize: 13, color: '#fff' }}>{c.code}</span>

      {/* Lane / track */}
      <div style={{
        position: 'relative',
        height: 16, borderRadius: 999,
        background: `linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2))`,
        boxShadow: 'inset 0 1px 2px rgba(0,0,0,0.5)',
        overflow: 'visible',
      }}>
        {/* Lane track marks (yard lines) */}
        <div style={{
          position: 'absolute', inset: 0, borderRadius: 999, overflow: 'hidden',
          backgroundImage: 'repeating-linear-gradient(90deg, transparent 0 9.9%, rgba(255,255,255,0.08) 9.9% 10%)',
        }} />
        {/* Trail glow */}
        <div style={{
          position: 'absolute', top: 0, left: 0, bottom: 0, width: progress + '%',
          background: `linear-gradient(90deg, transparent, ${c.color}55, ${c.color})`,
          borderRadius: 999,
          transition: 'width 1.5s var(--ease)',
        }} />
        {/* Runner dot at progress */}
        <div style={{
          position: 'absolute', left: `calc(${progress}% - 12px)`, top: '50%',
          width: 24, height: 24, borderRadius: '50%',
          background: `radial-gradient(circle at 30% 30%, #fff, ${c.color} 50%, ${c.secondary} 100%)`,
          border: `1.5px solid ${c.color}`,
          boxShadow: `0 0 14px ${c.color}, inset 0 1px 0 rgba(255,255,255,0.6)`,
          transform: 'translateY(-50%)',
          transition: 'left 1.5s var(--ease)',
          display: 'grid', placeItems: 'center',
          fontSize: 9, fontWeight: 800, color: '#0a0615',
          fontFamily: 'Bricolage Grotesque, sans-serif',
          animation: 'runner-bob 1.2s ease-in-out infinite',
        }}>{c.code.slice(0, 1)}</div>
        {/* Sparks behind leader */}
        {index === 0 && (
          <>
            <div style={{
              position: 'absolute', left: `calc(${progress}% - 28px)`, top: '50%',
              width: 6, height: 6, borderRadius: '50%',
              background: c.color, opacity: 0.6,
              transform: 'translateY(-50%)',
              animation: 'pulse-ring 0.9s ease-out infinite',
            }} />
          </>
        )}
      </div>

      {/* Volume readout */}
      <span className="mono" style={{ fontSize: 11, color: 'var(--t2)', fontWeight: 700, textAlign: 'right' }}>
        {typeof wciFormatCountryVolume === 'function' ? wciFormatCountryVolume(c) : fmtVol(c.volume24h)}
      </span>
    </button>
  );
};

// ───────── View switcher + main leaderboard component ─────────
const LeaderboardPage = ({ countries, onPick }) => {
  const [view, setView] = React.useState('race');
  const [groupFilter, setGroupFilter] = React.useState('all');

  const filtered = React.useMemo(() => {
    if (groupFilter === 'all') return countries;
    return countries.filter(c => c.group === groupFilter);
  }, [countries, groupFilter]);

  const VIEWS = [
    { k: 'race', label: 'Race Track', sub: 'live positions', icon: '🏁' },
    { k: 'battle', label: 'Battle', sub: 'head-to-head', icon: '⚔' },
    { k: 'board', label: 'Board', sub: 'classic table', icon: '≡' },
  ];

  return (
    <div style={{ padding: '32px 40px 80px', maxWidth: 1400, margin: '0 auto' }}>
      {/* Header */}
      <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', marginBottom: 24, flexWrap: 'wrap', gap: 16 }}>
        <div>
          <div className="label" style={{ color: 'var(--gold)' }}>LIVE BUY PRESSURE BATTLE</div>
          <div className="display" style={{ fontSize: 44, letterSpacing: '-0.03em', lineHeight: 1 }}>The race.</div>
          <div style={{ color: 'var(--t2)', marginTop: 6 }}>
            All 48 country tokens battling for #1. Click any country to back them with a buy.
          </div>
        </div>

        {/* View switcher */}
        <div style={{ display: 'flex', gap: 4, padding: 4, borderRadius: 14,
          background: 'rgba(255,255,255,0.04)', border: '1px solid var(--hair)',
        }}>
          {VIEWS.map(v => (
            <button key={v.k} onClick={() => setView(v.k)} style={{
              padding: '10px 16px', borderRadius: 10,
              background: view === v.k ? 'linear-gradient(180deg, rgba(245,208,32,0.2), rgba(245,208,32,0.08))' : 'transparent',
              border: '1px solid ' + (view === v.k ? 'rgba(245,208,32,0.4)' : 'transparent'),
              color: view === v.k ? 'var(--gold)' : 'var(--t2)',
              cursor: 'pointer',
              display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 2,
              minWidth: 120,
            }}>
              <div style={{ display: 'flex', gap: 8, alignItems: 'center', fontFamily: 'Bricolage Grotesque, sans-serif', fontWeight: 700, fontSize: 13, letterSpacing: '0.04em', textTransform: 'uppercase' }}>
                <span>{v.icon}</span>{v.label}
              </div>
              <div style={{ fontSize: 10, color: 'var(--t3)', fontWeight: 500, textTransform: 'lowercase' }}>{v.sub}</div>
            </button>
          ))}
        </div>
      </div>

      {/* Group filter row */}
      <div style={{ display: 'flex', gap: 6, marginBottom: 20, alignItems: 'center', flexWrap: 'wrap' }}>
        <span className="label" style={{ marginRight: 6 }}>FILTER GROUP:</span>
        <button onClick={() => setGroupFilter('all')} style={groupBtnStyle(groupFilter === 'all')}>All 48</button>
        {'ABCDEFGHIJKL'.split('').map(g => (
          <button key={g} onClick={() => setGroupFilter(g)} style={{
            ...groupBtnStyle(groupFilter === g),
            background: groupFilter === g ? `var(--grp-${g.toLowerCase()})` : 'rgba(255,255,255,0.04)',
            color: groupFilter === g ? '#0a0615' : 'var(--t2)',
            borderColor: groupFilter === g ? `var(--grp-${g.toLowerCase()})` : 'var(--hair)',
            fontWeight: 800,
          }}>{g}</button>
        ))}
      </div>

      {/* Active view */}
      {view === 'race' && <RaceTrackView countries={filtered} onPick={onPick} />}
      {view === 'battle' && <BattleView countries={filtered} onPick={onPick} />}
      {view === 'board' && <BoardView countries={filtered} onPick={onPick} />}
    </div>
  );
};

const groupBtnStyle = (active) => ({
  padding: '6px 12px', borderRadius: 8,
  background: active ? 'rgba(245,208,32,0.15)' : 'rgba(255,255,255,0.04)',
  border: '1px solid ' + (active ? 'var(--gold)' : 'var(--hair)'),
  color: active ? 'var(--gold)' : 'var(--t2)',
  fontSize: 11, fontWeight: 700, cursor: 'pointer',
  fontFamily: 'Bricolage Grotesque, sans-serif',
  letterSpacing: '0.04em', textTransform: 'uppercase',
  minWidth: 32,
});

window.LeaderboardPage = LeaderboardPage;
window.Medal = Medal;
