// wci26/trophies.jsx — Golden Boot (fills with gold) + Buyback Soccer Ball (fills with $)

// ───────── Golden Boot ─────────────────────────────────
const GoldenBoot = ({ champion, dailyVolume, dailyTarget = 2_500_000 }) => {
  const fillPct = Math.min(100, (dailyVolume / dailyTarget) * 100);
  const [tilt, setTilt] = React.useState({ x: 0, y: 0 });
  const ref = React.useRef(null);

  const handleMove = (e) => {
    if (!ref.current) return;
    const r = ref.current.getBoundingClientRect();
    const cx = (e.clientX - r.left) / r.width - 0.5;
    const cy = (e.clientY - r.top) / r.height - 0.5;
    setTilt({ x: cy * -10, y: cx * 16 });
  };
  const handleLeave = () => setTilt({ x: 0, y: 0 });

  return (
    <div
      ref={ref}
      onMouseMove={handleMove}
      onMouseLeave={handleLeave}
      style={{
        position: 'relative',
        borderRadius: 22,
        padding: 28,
        background: `
          radial-gradient(ellipse 70% 50% at 50% 20%, rgba(245,208,32,0.22), transparent 70%),
          linear-gradient(180deg, rgba(41,31,82,0.6) 0%, rgba(20,16,40,0.95) 100%)`,
        border: '1px solid rgba(245,208,32,0.3)',
        boxShadow: `
          inset 0 1.5px 0 rgba(255,255,255,0.1),
          inset 0 -1px 0 rgba(0,0,0,0.5),
          0 8px 16px -6px rgba(0,0,0,0.6),
          0 24px 48px -16px rgba(0,0,0,0.8),
          0 0 80px -20px var(--gold)
        `,
        perspective: 1400,
        overflow: 'hidden',
      }}
    >
      {/* Top label */}
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 14 }}>
        <Chip kind="gold">DAILY · GOLDEN BOOT</Chip>
        <div className="label" style={{ marginLeft: 'auto' }}>HIGHEST 24H VOLUME</div>
      </div>

      {/* 3D Boot */}
      <div style={{
        position: 'relative', height: 240, margin: '8px 0',
        transformStyle: 'preserve-3d',
        transform: `rotateX(${tilt.x}deg) rotateY(${tilt.y}deg)`,
        transition: 'transform 320ms var(--ease)',
      }}>
        <svg viewBox="0 0 320 240" width="100%" height="100%" style={{ overflow: 'visible' }}>
          <defs>
            {/* Side-view soccer boot silhouette, toe pointing right */}
            <clipPath id="bootClip">
              <path d="M 30 158
                       L 32 116
                       Q 35 88 60 88
                       L 78 88
                       Q 86 70 102 68
                       Q 118 66 134 80
                       L 158 90
                       Q 195 96 232 106
                       Q 275 116 298 134
                       Q 308 142 305 152
                       L 296 168
                       Q 285 184 250 186
                       L 92 184
                       Q 50 184 36 174
                       Q 28 170 30 158 Z" />
            </clipPath>
            {/* Boot outer gradient — leather */}
            <linearGradient id="bootLeather" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0%" stopColor="#3a2a5a" />
              <stop offset="60%" stopColor="#1d1740" />
              <stop offset="100%" stopColor="#0a0615" />
            </linearGradient>
            {/* Gold fill gradient */}
            <linearGradient id="goldFill" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0%" stopColor="#FFF1A0" />
              <stop offset="30%" stopColor="#FFE85B" />
              <stop offset="65%" stopColor="#F5D020" />
              <stop offset="100%" stopColor="#A88900" />
            </linearGradient>
            <linearGradient id="goldShine" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0%" stopColor="rgba(255,255,255,0.7)" />
              <stop offset="100%" stopColor="rgba(255,255,255,0)" />
            </linearGradient>
            <filter id="goldGlow">
              <feGaussianBlur stdDeviation="3" result="blur" />
              <feMerge>
                <feMergeNode in="blur" />
                <feMergeNode in="SourceGraphic" />
              </feMerge>
            </filter>
            <linearGradient id="soleGrad" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0%" stopColor="#0a0615" />
              <stop offset="100%" stopColor="#1d1740" />
            </linearGradient>
          </defs>

          {/* Ground shadow */}
          <ellipse cx="160" cy="212" rx="135" ry="6" fill="rgba(0,0,0,0.5)" />

          {/* Boot outer shell + gold fill clipped */}
          <g clipPath="url(#bootClip)">
            <rect width="320" height="240" fill="url(#bootLeather)" />

            {/* Liquid gold fill (animated height) */}
            <rect x="0" y={186 - (fillPct / 100) * 118} width="320" height="240" fill="url(#goldFill)" style={{ transition: 'y 1.2s var(--ease)' }} />

            {/* Surface wave */}
            <path
              d={`M 0 ${186 - (fillPct / 100) * 118} Q 80 ${186 - (fillPct / 100) * 118 - 4} 160 ${186 - (fillPct / 100) * 118} T 320 ${186 - (fillPct / 100) * 118} L 320 200 L 0 200 Z`}
              fill="url(#goldShine)" opacity="0.5">
              <animate attributeName="d"
                values={`
                  M 0 ${186 - (fillPct / 100) * 118} Q 80 ${186 - (fillPct / 100) * 118 - 4} 160 ${186 - (fillPct / 100) * 118} T 320 ${186 - (fillPct / 100) * 118} L 320 200 L 0 200 Z;
                  M 0 ${186 - (fillPct / 100) * 118} Q 80 ${186 - (fillPct / 100) * 118 + 4} 160 ${186 - (fillPct / 100) * 118 - 2} T 320 ${186 - (fillPct / 100) * 118} L 320 200 L 0 200 Z;
                  M 0 ${186 - (fillPct / 100) * 118} Q 80 ${186 - (fillPct / 100) * 118 - 4} 160 ${186 - (fillPct / 100) * 118} T 320 ${186 - (fillPct / 100) * 118} L 320 200 L 0 200 Z
                `}
                dur="2.6s"
                repeatCount="indefinite" />
            </path>

            {/* Sparkles in gold liquid */}
            {Array.from({ length: 12 }).map((_, i) => {
              const x = 40 + (i * 27) % 240;
              const y = 186 - (fillPct / 100) * 118 + 5 + (i * 11) % 100;
              if (y > 180) return null;
              return (
                <circle key={i} cx={x} cy={y} r="1.2" fill="#fff" opacity="0.9">
                  <animate attributeName="opacity" values="0.2;1;0.2" dur={`${1.5 + i * 0.3}s`} repeatCount="indefinite" />
                </circle>
              );
            })}

            {/* Three angled stripes along the side */}
            <g stroke="rgba(255,255,255,0.18)" strokeWidth="3" fill="none" strokeLinecap="round">
              <path d="M 130 110 L 155 150" />
              <path d="M 160 105 L 185 145" />
              <path d="M 190 105 L 215 145" />
            </g>

            {/* Laces band */}
            <g fill="rgba(0,0,0,0.45)">
              <path d="M 85 95 Q 100 92 115 95 L 120 130 Q 105 132 90 130 Z" />
            </g>
            <g stroke="rgba(255,255,255,0.5)" strokeWidth="1.2" fill="none" strokeLinecap="round">
              <path d="M 86 100 L 116 105" />
              <path d="M 86 110 L 116 115" />
              <path d="M 86 120 L 116 125" />
            </g>

            {/* Heel cap */}
            <path d="M 30 158 L 32 116 Q 35 88 60 88 L 60 112 Q 50 114 48 158 Z" fill="rgba(0,0,0,0.35)" />

            {/* Sole (darker band along bottom) */}
            <path d="M 30 168 L 80 184 L 250 186 Q 285 184 296 168 L 296 178 Q 285 188 250 190 L 80 188 Q 50 188 30 178 Z"
              fill="url(#soleGrad)" opacity="0.6" />

            {/* Studs */}
            {[55, 95, 135, 175, 215, 255].map((x, i) => (
              <ellipse key={i} cx={x} cy="185" rx="6" ry="3" fill="#0a0615" opacity="0.85" />
            ))}
          </g>

          {/* Boot outline */}
          <path d="M 30 158
                   L 32 116
                   Q 35 88 60 88
                   L 78 88
                   Q 86 70 102 68
                   Q 118 66 134 80
                   L 158 90
                   Q 195 96 232 106
                   Q 275 116 298 134
                   Q 308 142 305 152
                   L 296 168
                   Q 285 184 250 186
                   L 92 184
                   Q 50 184 36 174
                   Q 28 170 30 158 Z"
            stroke="rgba(245,208,32,0.85)" strokeWidth="1.8" fill="none" filter="url(#goldGlow)" />

          {/* Top highlight along upper edge */}
          <path d="M 65 92 Q 95 75 130 80 Q 200 95 270 120" stroke="rgba(255,255,255,0.35)" strokeWidth="1.2" fill="none" />

          {/* Soccer ball bouncing */}
          <g transform="translate(258, 32)">
            <circle r="14" fill="#fff" stroke="#000" strokeWidth="1.2">
              <animateTransform attributeName="transform" type="translate"
                values="0,0; 0,-10; 0,0" dur="1.4s" repeatCount="indefinite" />
            </circle>
            <polygon points="0,-7 5,-3 4,3 -4,3 -5,-3" fill="#0a0615" transform="scale(0.8)">
              <animateTransform attributeName="transform" type="translate"
                values="0,0; 0,-10; 0,0" dur="1.4s" repeatCount="indefinite" />
            </polygon>
          </g>
        </svg>
      </div>

      {/* Champion + progress */}
      <div style={{
        display: 'flex', alignItems: 'center', gap: 12, marginTop: 4,
        padding: '12px 14px', borderRadius: 12,
        background: 'rgba(245,208,32,0.08)',
        border: '1px solid rgba(245,208,32,0.2)',
      }}>
        {champion && <FlagRect code={champion.code} w={32} h={22} />}
        <div style={{ flex: 1 }}>
          <div className="label" style={{ fontSize: 9, color: 'var(--gold)' }}>CURRENT LEADER</div>
          <div className="display" style={{ fontSize: 18, lineHeight: 1.1, color: '#fff' }}>
            {champion ? champion.name : '—'}
          </div>
        </div>
        <div style={{ textAlign: 'right' }}>
          <div className="label" style={{ fontSize: 9 }}>24h VOLUME</div>
          <div className="mono" style={{ fontSize: 18, color: 'var(--gold)', fontWeight: 700 }}>
            {fmtVol(dailyVolume)}
          </div>
        </div>
      </div>

      <div style={{ marginTop: 10 }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 10, color: 'var(--t3)', marginBottom: 4 }}>
          <span className="label" style={{ fontSize: 9 }}>FILL PROGRESS</span>
          <span className="mono">{fillPct.toFixed(0)}% · target {fmtVol(dailyTarget)}</span>
        </div>
        <div style={{
          height: 8, borderRadius: 4, background: 'rgba(255,255,255,0.06)',
          overflow: 'hidden', position: 'relative',
        }}>
          <div style={{
            position: 'absolute', inset: 0, width: fillPct + '%',
            background: 'linear-gradient(90deg, #FFF1A0, #F5D020, #A88900)',
            boxShadow: '0 0 12px var(--gold), inset 0 1px 0 rgba(255,255,255,0.5)',
            transition: 'width 1s var(--ease)',
          }} />
        </div>
      </div>
    </div>
  );
};

// ───────── Buyback Soccer Ball ──────────────────────────
const BuybackBall = ({ poolUsd, target = 1_000_000, totalBuybacks = 0, wciMarket }) => {
  const pct = Math.min(100, (poolUsd / target) * 100);
  const market = wciMarket || (
    typeof WCI_MARKET_DATA !== 'undefined' && WCI_MARKET_DATA.getSnapshot
      ? WCI_MARKET_DATA.getSnapshot()
      : (typeof WCI_TOKEN !== 'undefined' ? WCI_TOKEN : {})
  );
  const wciPriceLabel = typeof wciFormatUsdPrice === 'function'
    ? wciFormatUsdPrice(market.priceUsd ?? market.price)
    : (Number(market.priceUsd ?? market.price) > 0 ? `$${Number(market.priceUsd ?? market.price).toFixed(4)}` : '--');
  const [tilt, setTilt] = React.useState({ x: 0, y: 0 });
  const ref = React.useRef(null);

  const handleMove = (e) => {
    if (!ref.current) return;
    const r = ref.current.getBoundingClientRect();
    const cx = (e.clientX - r.left) / r.width - 0.5;
    const cy = (e.clientY - r.top) / r.height - 0.5;
    setTilt({ x: cy * -12, y: cx * 20 });
  };
  const handleLeave = () => setTilt({ x: 0, y: 0 });

  return (
    <div ref={ref} onMouseMove={handleMove} onMouseLeave={handleLeave} style={{
      position: 'relative', borderRadius: 22, padding: 28,
      background: `
        radial-gradient(ellipse 70% 50% at 50% 20%, rgba(159,214,52,0.18), transparent 70%),
        linear-gradient(180deg, rgba(41,31,82,0.6) 0%, rgba(20,16,40,0.95) 100%)`,
      border: '1px solid rgba(159,214,52,0.3)',
      boxShadow: `
        inset 0 1.5px 0 rgba(255,255,255,0.1),
        inset 0 -1px 0 rgba(0,0,0,0.5),
        0 24px 48px -16px rgba(0,0,0,0.8),
        0 0 80px -20px var(--lime)
      `,
      perspective: 1400, overflow: 'hidden',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 14 }}>
        <Chip kind="gold" style={{ background: 'rgba(159,214,52,0.18)', borderColor: 'rgba(159,214,52,0.5)', color: 'var(--lime)' }}>$WCI26 OPS</Chip>
        <div className="label" style={{ marginLeft: 'auto' }}>LIVE OPS</div>
      </div>

      {/* Soccer ball */}
      <div style={{
        position: 'relative', height: 240, margin: '0 auto', width: 240,
        transformStyle: 'preserve-3d',
        transform: `rotateX(${tilt.x}deg) rotateY(${tilt.y}deg)`,
        transition: 'transform 320ms var(--ease)',
      }}>
        <svg viewBox="-120 -120 240 240" width="240" height="240" style={{ position: 'absolute', inset: 0, overflow: 'visible' }}>
          <defs>
            <clipPath id="ballClip">
              <circle cx="0" cy="0" r="100" />
            </clipPath>
            <radialGradient id="ballGlass" cx="0.3" cy="0.3" r="0.9">
              <stop offset="0%" stopColor="rgba(255,255,255,0.5)" />
              <stop offset="35%" stopColor="rgba(255,255,255,0.05)" />
              <stop offset="70%" stopColor="rgba(20,16,40,0.0)" />
              <stop offset="100%" stopColor="rgba(0,0,0,0.4)" />
            </radialGradient>
            <linearGradient id="billStack" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0%" stopColor="#B8E060" />
              <stop offset="50%" stopColor="#7CA82C" />
              <stop offset="100%" stopColor="#3A5611" />
            </linearGradient>
            <filter id="ballGlow">
              <feGaussianBlur stdDeviation="4" />
            </filter>
            <filter id="seamGlow">
              <feGaussianBlur stdDeviation="0.6" />
            </filter>
          </defs>

          {/* Ground shadow */}
          <ellipse cx="0" cy="110" rx="90" ry="6" fill="rgba(0,0,0,0.6)" />

          {/* Outer rim glow (back atmosphere) */}
          <circle cx="0" cy="0" r="100" fill="none" stroke="rgba(159,214,52,0.6)" strokeWidth="2" filter="url(#ballGlow)" />

          {/* Glass shell back — dark */}
          <circle cx="0" cy="0" r="100" fill="rgba(15,12,32,0.5)" stroke="rgba(255,255,255,0.18)" strokeWidth="1" />

          {/* Pile of dollar bills inside, clipped to ball */}
          <g clipPath="url(#ballClip)">
            <rect x="-120" y={100 - (pct / 100) * 200} width="240" height="240" fill="url(#billStack)" style={{ transition: 'y 1.2s var(--ease)' }} />

            {/* Stacks of dollar bills as horizontal lines/rects */}
            {Array.from({ length: 32 }).map((_, i) => {
              const y = 100 - i * 7;
              const wobble = ((i * 13) % 18) - 9;
              const w = 56 + ((i * 7) % 60);
              const fillThreshold = 100 - (pct / 100) * 200;
              if (y < fillThreshold) return null;
              return (
                <g key={i} transform={`translate(${wobble}, ${y}) rotate(${(i * 11) % 14 - 7})`}>
                  <rect x={-w/2} y={-3} width={w} height="5.5" rx="1"
                    fill={i % 3 === 0 ? '#D1E9A0' : '#9FD634'}
                    stroke="rgba(0,0,0,0.25)" strokeWidth="0.3" />
                  <text x="0" y="1.5" fontSize="3.5" textAnchor="middle" fill="rgba(0,0,0,0.5)" fontFamily="monospace" fontWeight="700">$</text>
                </g>
              );
            })}

            {/* Surface bills (top wobble) */}
            {pct > 5 && (() => {
              const surfaceY = 100 - (pct / 100) * 200;
              return Array.from({ length: 5 }).map((_, i) => (
                <g key={'top' + i} transform={`translate(${(i - 2) * 20}, ${surfaceY - 2}) rotate(${(i * 23) % 20 - 10})`}>
                  <rect x="-30" y="-3" width="60" height="6" rx="1"
                    fill="#C8ED7E" stroke="rgba(0,0,0,0.3)" strokeWidth="0.3">
                    <animateTransform attributeName="transform" type="rotate"
                      values={`${(i * 23) % 20 - 10}; ${(i * 23) % 20 - 5}; ${(i * 23) % 20 - 10}`}
                      dur={`${2 + i * 0.4}s`} repeatCount="indefinite" />
                  </rect>
                </g>
              ));
            })()}
          </g>

          {/* Soccer ball pentagon seams — etched into glass surface */}
          <g clipPath="url(#ballClip)">
            {/* Central pentagon — the iconic one */}
            <polygon points="0,-32 30,-10 19,26 -19,26 -30,-10" fill="rgba(15,12,32,0.5)" stroke="rgba(255,255,255,0.8)" strokeWidth="1.8" strokeLinejoin="round" />

            {/* 5 hexagons around the central pentagon (offset) */}
            {[0, 1, 2, 3, 4].map((i) => {
              const ang = (i * 72 - 90) * Math.PI / 180;
              const cx = Math.cos(ang) * 56;
              const cy = Math.sin(ang) * 56;
              // Pentagon points rotated to face center
              const rotAng = (i * 72 - 90 + 180) * Math.PI / 180;
              const pts = [];
              for (let j = 0; j < 5; j++) {
                const a = rotAng + (j / 5) * Math.PI * 2;
                pts.push(`${cx + Math.cos(a) * 22},${cy + Math.sin(a) * 22}`);
              }
              return (
                <polygon key={i} points={pts.join(' ')}
                  fill="rgba(15,12,32,0.35)" stroke="rgba(255,255,255,0.7)" strokeWidth="1.5" strokeLinejoin="round" />
              );
            })}

            {/* Seam lines connecting outward to the rim */}
            {[0, 1, 2, 3, 4].map((i) => {
              const ang = (i * 72 - 90 - 36) * Math.PI / 180;
              const x1 = Math.cos(ang) * 32;
              const y1 = Math.sin(ang) * 32;
              const x2 = Math.cos(ang) * 100;
              const y2 = Math.sin(ang) * 100;
              return (
                <line key={i} x1={x1} y1={y1} x2={x2} y2={y2}
                  stroke="rgba(255,255,255,0.5)" strokeWidth="1.2" />
              );
            })}
          </g>

          {/* Glass refraction overlay */}
          <circle cx="0" cy="0" r="100" fill="url(#ballGlass)" pointerEvents="none" />

          {/* Strong glass highlight (top-left) */}
          <ellipse cx="-32" cy="-38" rx="22" ry="42" fill="rgba(255,255,255,0.25)" transform="rotate(-25 -32 -38)" />
          <ellipse cx="-46" cy="-50" rx="8" ry="14" fill="rgba(255,255,255,0.45)" transform="rotate(-25 -46 -50)" />

          {/* Bottom-right shadow */}
          <ellipse cx="40" cy="50" rx="40" ry="35" fill="rgba(0,0,0,0.25)" />

          {/* Outer rim crisp edge */}
          <circle cx="0" cy="0" r="99" fill="none" stroke="rgba(159,214,52,0.9)" strokeWidth="1.2" />
        </svg>

        {/* Floating $ amount */}
        <div style={{
          position: 'absolute', top: '50%', left: '50%',
          transform: 'translate(-50%, -50%) translateZ(20px)',
          textAlign: 'center', pointerEvents: 'none',
        }}>
          <div className="label" style={{ fontSize: 9, color: 'var(--lime)' }}>POOL</div>
          <div className="display" style={{
            fontSize: 28, color: '#fff', lineHeight: 1,
            textShadow: '0 0 20px rgba(159,214,52,0.6), 0 2px 4px rgba(0,0,0,0.8)',
          }}>{fmtVol(poolUsd)}</div>
        </div>
      </div>

      {/* Stats */}
      <div style={{
        marginTop: 18, padding: '14px 16px', borderRadius: 12,
        background: 'rgba(159,214,52,0.06)',
        border: '1px solid rgba(159,214,52,0.2)',
        display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 12,
      }}>
        <div>
          <div className="label" style={{ fontSize: 9 }}>NEXT OPS</div>
          <div className="mono" style={{ fontSize: 14, fontWeight: 700, color: 'var(--lime)' }}>{fmtVol(target)}</div>
        </div>
        <div>
          <div className="label" style={{ fontSize: 9 }}>OPS LOG</div>
          <div className="mono" style={{ fontSize: 14, fontWeight: 700, color: '#fff' }}>{fmtVol(totalBuybacks)}</div>
        </div>
        <div>
          <div className="label" style={{ fontSize: 9 }}>$WCI26 PRICE</div>
          <div className="mono" style={{ fontSize: 14, fontWeight: 700, color: 'var(--gold)' }}>{wciPriceLabel}</div>
        </div>
      </div>
    </div>
  );
};

// ───────── Trophies tab content ─────────────────────────
const SeasonHub = ({ countries, buybackPool }) => {
  const match = buildTodayMatch(countries);
  const trophies = buildSeasonTrophies(countries, buybackPool, match);
  return (
    <div className="season-hub" style={{ marginTop: 28 }}>
      <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 14, marginBottom: 14 }}>
        <div>
          <div className="label" style={{ color: 'var(--gold)' }}>SEASON HUB</div>
          <div className="display" style={{ fontSize: 24, lineHeight: 1 }}>Daily objectives</div>
        </div>
        <div className="mono" style={{ fontSize: 11, color: 'var(--t3)' }}>4 tracks active</div>
      </div>
      <div className="season-hub-grid" style={{
        display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14,
      }}>
        {trophies.map((trophy) => (
          <div key={trophy.id} style={{
            padding: 16, borderRadius: 14,
            background: 'linear-gradient(180deg, rgba(29,23,64,0.58), rgba(10,6,21,0.86))',
            border: `1px solid ${trophy.accent}44`,
            boxShadow: `0 16px 36px -24px ${trophy.accent}`,
          }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
              {trophy.code ? <FlagRect code={trophy.code} w={30} h={20} /> : (
                <div style={{
                  width: 30, height: 30, borderRadius: 8,
                  border: `1px solid ${trophy.accent}`,
                  background: `${trophy.accent}22`,
                }} />
              )}
              <div style={{ minWidth: 0 }}>
                <div className="label" style={{ fontSize: 8, color: trophy.accent }}>{trophy.label}</div>
                <div className="display" style={{ marginTop: 3, fontSize: 16, color: '#fff', lineHeight: 1.05, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
                  {trophy.title}
                </div>
              </div>
            </div>
            <div className="mono" style={{ marginTop: 12, fontSize: 11, color: 'var(--t2)', fontWeight: 700 }}>{trophy.meta}</div>
            <div style={{ marginTop: 9, height: 6, borderRadius: 999, background: 'rgba(255,255,255,0.06)', overflow: 'hidden' }}>
              <div style={{
                height: '100%', width: `${Math.max(0, Math.min(100, trophy.progress || 0))}%`,
                background: `linear-gradient(90deg, ${trophy.accent}, rgba(255,255,255,0.75))`,
                boxShadow: `0 0 10px ${trophy.accent}`,
              }} />
            </div>
          </div>
        ))}
      </div>
    </div>
  );
};

const TrophiesView = ({ countries, buybackPool }) => {
  const champion = countries[0];
  const totalVolume = countries.reduce((s, c) => s + c.volume24h, 0);

  // Hall of fame: rank tiers
  const ranks = countries.slice(0, 8);

  return (
    <div className="main-scroll" style={{ flex: 1, overflowY: 'auto', minHeight: 0 }}>
      <div style={{ padding: '32px 40px 80px', maxWidth: 1500, margin: '0 auto' }}>
        <div style={{ marginBottom: 28 }}>
          <div className="label" style={{ color: 'var(--gold)' }}>TROPHIES & MILESTONES</div>
          <div className="display" style={{ fontSize: 44, letterSpacing: '-0.03em', lineHeight: 1 }}>The hardware.</div>
          <div style={{ color: 'var(--t2)', marginTop: 6, maxWidth: 720 }}>
            Daily Golden Boot, hourly hot streaks, and live country milestones track the tournament pulse.
          </div>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr', gap: 24 }}>
          <GoldenBoot champion={champion} dailyVolume={champion?.volume24h || 0} dailyTarget={4_500_000} />
        </div>

        <SeasonHub countries={countries} buybackPool={buybackPool} />

        {/* Hall of fame podium */}
        <div style={{ marginTop: 28 }}>
          <div className="display" style={{ fontSize: 24, marginBottom: 14 }}>24h Podium</div>
          <div style={{
            display: 'grid', gridTemplateColumns: 'repeat(8, 1fr)', gap: 12,
            padding: 20, borderRadius: 18,
            background: 'linear-gradient(180deg, rgba(41,31,82,0.4), rgba(20,16,40,0.9))',
            border: '1px solid var(--hair)',
          }}>
            {ranks.map((c, i) => (
              <div key={c.code} style={{
                textAlign: 'center', padding: 12, borderRadius: 12,
                background: i === 0 ? 'rgba(245,208,32,0.1)' : 'rgba(255,255,255,0.03)',
                border: '1px solid ' + (i === 0 ? 'var(--gold)' : 'var(--hair)'),
                position: 'relative',
              }}>
                <div className="display" style={{
                  fontSize: 12, color: i === 0 ? 'var(--gold)' : i < 3 ? 'var(--fifa-yellow)' : 'var(--t3)',
                  letterSpacing: '0.08em',
                }}>#{i + 1}</div>
                <div style={{ margin: '8px 0' }}><FlagRect code={c.code} w={32} h={22} /></div>
                <div className="display" style={{ fontSize: 16, color: '#fff' }}>{c.code}</div>
                <div className="mono" style={{ fontSize: 10, color: 'var(--t3)', marginTop: 4 }}>
                  {typeof wciFormatCountryVolume === 'function' ? wciFormatCountryVolume(c) : fmtVol(c.volume24h)}
                </div>
                <div className="mono" style={{
                  fontSize: 10, fontWeight: 700, marginTop: 4,
                  color: c.change24h >= 0 ? 'var(--lime)' : 'var(--coral)',
                }}>
                  {c.change24h >= 0 ? '+' : ''}{c.change24h.toFixed(1)}%
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
};

window.GoldenBoot = GoldenBoot;
window.BuybackBall = BuybackBall;
window.TrophiesView = TrophiesView;

