// ============================================================
// REWARDS & IDENTITY
//
// "Characters" are simple, science-coded glyphs in colored
// circles — the visual mark that follows the student around.
// Frames sit around them on the leaderboard.
// Titles + trophies finish the identity loop.
// ============================================================

// ── Character glyph library ──────────────────────────────────
// Each character has a base color, optional secondary, and a paint
// function. They aim for "video-game icon with personality" — not
// kawaii cute, not flat icon. Faces where they make sense, depth via
// layered fills, signature motif per subject.
const CHARS = {
  atom:    { name: 'Atom',     bg: ['#f4a094','#c4615a'], stroke: '#fff', tag: 'Physics' },
  beaker:  { name: 'Beaker',   bg: ['#8ab896','#456e58'], stroke: '#fff', tag: 'Chemistry' },
  helix:   { name: 'Helix',    bg: ['#9b7eb8','#5b4878'], stroke: '#fff', tag: 'Biology' },
  pi:      { name: 'Pi',       bg: ['#7eb0d8','#3d6b94'], stroke: '#fff', tag: 'Maths' },
  bolt:    { name: 'Volt',     bg: ['#f0c870','#a87f3f'], stroke: '#3d2700', tag: 'Physics' },
  mole:    { name: 'Mole',     bg: ['#d49882','#9c5c4a'], stroke: '#fff', tag: 'Chemistry' },
  cell:    { name: 'Cell',     bg: ['#a3c3e0','#5278a3'], stroke: '#fff', tag: 'Biology' },
  wave:    { name: 'Wave',     bg: ['#d49db0','#9c5c6e'], stroke: '#fff', tag: 'Physics' },
  ph:      { name: 'pH',       bg: ['#b89ddc','#6e4f96'], stroke: '#fff', tag: 'Chemistry' },
  sigma:   { name: 'Sigma',    bg: ['#7593b8','#3d557c'], stroke: '#fff', tag: 'Maths' },
  prism:   { name: 'Prism',    bg: ['#e8b078','#9c6c3a'], stroke: '#fff', tag: 'Physics' },
  leaf:    { name: 'Leaf',     bg: ['#8fb878','#506e3a'], stroke: '#fff', tag: 'Biology' },
};

// Character SVG renderer
// Each motif is drawn inside a 100x100 viewBox over a 2-stop radial bg
// (lighter top-left, darker bottom-right) for soft depth.
function CharGlyph({ kind, size = 56 }) {
  const c = CHARS[kind] || CHARS.atom;
  const [c1, c2] = c.bg;
  const gradId = `gx-${kind}`;
  const highId = `gh-${kind}`;

  const motif = {
    // ─── Atom: nucleus character with orbiting electrons ───
    atom: (
      <g>
        <ellipse cx="50" cy="50" rx="40" ry="13" fill="none" stroke="#fff" strokeWidth="2.5" opacity="0.55"/>
        <ellipse cx="50" cy="50" rx="40" ry="13" fill="none" stroke="#fff" strokeWidth="2.5" opacity="0.55" transform="rotate(60 50 50)"/>
        <ellipse cx="50" cy="50" rx="40" ry="13" fill="none" stroke="#fff" strokeWidth="2.5" opacity="0.55" transform="rotate(-60 50 50)"/>
        {/* electrons */}
        <circle cx="88"  cy="50" r="3.5" fill="#fff"/>
        <circle cx="25"  cy="76" r="3.5" fill="#fff"/>
        <circle cx="32"  cy="22" r="3.5" fill="#fff"/>
        {/* nucleus body */}
        <circle cx="50" cy="50" r="22" fill="#fff"/>
        <circle cx="50" cy="50" r="20" fill="#ffd97a"/>
        <circle cx="45" cy="45" r="6"  fill="#fff" opacity="0.65"/>
        {/* face */}
        <circle cx="43" cy="49" r="3" fill="#3d2700"/>
        <circle cx="57" cy="49" r="3" fill="#3d2700"/>
        <circle cx="42" cy="48" r="1" fill="#fff"/>
        <circle cx="56" cy="48" r="1" fill="#fff"/>
        <path d="M44 56 Q50 60 56 56" stroke="#3d2700" strokeWidth="2.2" fill="none" strokeLinecap="round"/>
        {/* cheeks */}
        <circle cx="39" cy="55" r="2" fill="#ff8b9a" opacity="0.55"/>
        <circle cx="61" cy="55" r="2" fill="#ff8b9a" opacity="0.55"/>
      </g>
    ),
    // ─── Beaker: glass body with face, frothy liquid inside ───
    beaker: (
      <g>
        {/* table line */}
        <line x1="22" y1="84" x2="78" y2="84" stroke="#fff" strokeWidth="2" opacity="0.35" strokeLinecap="round"/>
        {/* beaker body */}
        <path d="M34 28v6l-10 42a4 4 0 0 0 4 5h44a4 4 0 0 0 4-5L66 34v-6z" fill="#fff" opacity="0.18"/>
        <path d="M34 28v6l-10 42a4 4 0 0 0 4 5h44a4 4 0 0 0 4-5L66 34v-6z" fill="none" stroke="#fff" strokeWidth="3" strokeLinejoin="round"/>
        {/* rim */}
        <rect x="32" y="24" width="36" height="6" rx="2" fill="#fff"/>
        {/* liquid */}
        <path d="M27 60l46 0l4 16a4 4 0 0 1-4 5h-46a4 4 0 0 1-4-5z" fill="#3da77a"/>
        <path d="M27 60q12 -4 23 0 t23 0" fill="none" stroke="#fff" strokeWidth="2" opacity="0.7"/>
        {/* bubbles */}
        <circle cx="36" cy="50" r="3" fill="#fff" opacity="0.9"/>
        <circle cx="46" cy="42" r="2.2" fill="#fff" opacity="0.85"/>
        <circle cx="58" cy="48" r="2.6" fill="#fff" opacity="0.85"/>
        <circle cx="65" cy="40" r="1.8" fill="#fff" opacity="0.7"/>
        {/* face on glass */}
        <circle cx="42" cy="72" r="2.6" fill="#1d3527"/>
        <circle cx="58" cy="72" r="2.6" fill="#1d3527"/>
        <circle cx="41" cy="71" r="0.9" fill="#fff"/>
        <circle cx="57" cy="71" r="0.9" fill="#fff"/>
        <path d="M44 76 Q50 80 56 76" stroke="#1d3527" strokeWidth="2" fill="none" strokeLinecap="round"/>
      </g>
    ),
    // ─── Helix: DNA strands as a creature ───
    helix: (
      <g>
        {/* strands */}
        <path d="M30 20 C40 38 60 38 70 20" fill="none" stroke="#fff" strokeWidth="3.5" strokeLinecap="round"/>
        <path d="M30 50 C40 32 60 32 70 50" fill="none" stroke="#fff" strokeWidth="3.5" strokeLinecap="round"/>
        <path d="M30 50 C40 68 60 68 70 50" fill="none" stroke="#fff" strokeWidth="3.5" strokeLinecap="round" opacity="0.55"/>
        <path d="M30 80 C40 62 60 62 70 80" fill="none" stroke="#fff" strokeWidth="3.5" strokeLinecap="round"/>
        {/* base pairs */}
        <line x1="36" y1="30" x2="64" y2="30" stroke="#ffd97a" strokeWidth="3" strokeLinecap="round"/>
        <line x1="34" y1="42" x2="66" y2="42" stroke="#f4a094" strokeWidth="3" strokeLinecap="round"/>
        <line x1="34" y1="58" x2="66" y2="58" stroke="#ffd97a" strokeWidth="3" strokeLinecap="round"/>
        <line x1="36" y1="70" x2="64" y2="70" stroke="#f4a094" strokeWidth="3" strokeLinecap="round"/>
        {/* face at top junction */}
        <circle cx="45" cy="26" r="2.4" fill="#3a285a"/>
        <circle cx="55" cy="26" r="2.4" fill="#3a285a"/>
        <circle cx="44.5" cy="25.5" r="0.8" fill="#fff"/>
        <circle cx="54.5" cy="25.5" r="0.8" fill="#fff"/>
      </g>
    ),
    // ─── Pi: friendly π glyph with eyes on the bar ───
    pi: (
      <g>
        {/* π */}
        <rect x="24" y="34" width="52" height="9" rx="3" fill="#fff"/>
        <rect x="32" y="34" width="9" height="42" rx="3" fill="#fff"/>
        <path d="M59 34v34c0 5 3 8 8 8h2" stroke="#fff" strokeWidth="9" fill="none" strokeLinecap="round"/>
        {/* face on the bar */}
        <circle cx="40" cy="56" r="3.4" fill="#1f3a5a"/>
        <circle cx="60" cy="56" r="3.4" fill="#1f3a5a"/>
        <circle cx="39" cy="55" r="1.1" fill="#fff"/>
        <circle cx="59" cy="55" r="1.1" fill="#fff"/>
        <path d="M44 64 Q50 68 56 64" stroke="#1f3a5a" strokeWidth="2.2" fill="none" strokeLinecap="round"/>
        {/* shine on bar */}
        <rect x="28" y="36" width="40" height="2" rx="1" fill="#fff" opacity="0.55"/>
      </g>
    ),
    // ─── Volt: lightning bolt creature with face ───
    bolt: (
      <g>
        {/* shadow */}
        <ellipse cx="50" cy="84" rx="20" ry="3.5" fill="#3d2700" opacity="0.18"/>
        {/* bolt body */}
        <path d="M58 14L26 56h17l-6 26 30-40H50l8-28z" fill="#fff8d8" stroke="#3d2700" strokeWidth="2.5" strokeLinejoin="round"/>
        {/* inner highlight */}
        <path d="M58 18L34 52h14" fill="none" stroke="#fff" strokeWidth="2" opacity="0.85" strokeLinecap="round"/>
        {/* face on the wide part */}
        <circle cx="42" cy="48" r="3.2" fill="#3d2700"/>
        <circle cx="54" cy="48" r="3.2" fill="#3d2700"/>
        <circle cx="41" cy="47" r="1" fill="#fff"/>
        <circle cx="53" cy="47" r="1" fill="#fff"/>
        <path d="M43 56q3 3 6 0" stroke="#3d2700" strokeWidth="2" fill="none" strokeLinecap="round"/>
        {/* sparks */}
        <circle cx="20" cy="30" r="2.5" fill="#fff8d8"/>
        <circle cx="82" cy="38" r="2" fill="#fff8d8"/>
        <circle cx="78" cy="64" r="2.8" fill="#fff8d8"/>
      </g>
    ),
    // ─── Mole: actual mole creature with the chemistry pun ───
    mole: (
      <g>
        {/* body shadow */}
        <ellipse cx="50" cy="86" rx="26" ry="3.5" fill="#3a1f15" opacity="0.25"/>
        {/* body */}
        <ellipse cx="50" cy="62" rx="30" ry="22" fill="#5a3528"/>
        <ellipse cx="50" cy="60" rx="30" ry="22" fill="#7a4838"/>
        {/* belly */}
        <ellipse cx="50" cy="68" rx="18" ry="13" fill="#d49882"/>
        {/* head */}
        <ellipse cx="50" cy="40" rx="20" ry="18" fill="#7a4838"/>
        <ellipse cx="50" cy="38" rx="20" ry="18" fill="#946048"/>
        {/* paws (digging) */}
        <ellipse cx="30" cy="74" rx="6" ry="4" fill="#f4d8c0"/>
        <ellipse cx="70" cy="74" rx="6" ry="4" fill="#f4d8c0"/>
        {/* claws */}
        <path d="M24 73l-3 1M27 76l-3 2M70 73l3 1M73 76l3 2" stroke="#3a1f15" strokeWidth="1.6" strokeLinecap="round"/>
        {/* eyes (closed, moles are blind) */}
        <path d="M41 38q3 -3 6 0" stroke="#3a1f15" strokeWidth="2" fill="none" strokeLinecap="round"/>
        <path d="M53 38q3 -3 6 0" stroke="#3a1f15" strokeWidth="2" fill="none" strokeLinecap="round"/>
        {/* nose */}
        <ellipse cx="50" cy="46" rx="4" ry="3" fill="#f4a8b8"/>
        <circle cx="50" cy="45" r="1.5" fill="#fff" opacity="0.7"/>
        {/* whiskers */}
        <path d="M44 48l-8 -1M44 50l-8 2M56 48l8 -1M56 50l8 2" stroke="#3a1f15" strokeWidth="1.3" strokeLinecap="round" opacity="0.7"/>
        {/* tiny "mol" subscript */}
        <text x="50" y="92" textAnchor="middle" fontFamily="DM Mono, monospace" fontSize="9" fontWeight="800" fill="#fff" opacity="0.85">mol</text>
      </g>
    ),
    // ─── Cell: blobby cell with nucleus eye + cilia ───
    cell: (
      <g>
        {/* cilia (around edges) */}
        <g stroke="#fff" strokeWidth="2" strokeLinecap="round" opacity="0.8">
          <line x1="50" y1="6"  x2="50" y2="14"/>
          <line x1="78" y1="14" x2="74" y2="22"/>
          <line x1="92" y1="36" x2="84" y2="40"/>
          <line x1="94" y1="62" x2="86" y2="62"/>
          <line x1="86" y1="84" x2="80" y2="78"/>
          <line x1="62" y1="94" x2="60" y2="86"/>
          <line x1="38" y1="94" x2="40" y2="86"/>
          <line x1="14" y1="84" x2="20" y2="78"/>
          <line x1="6"  y1="62" x2="14" y2="62"/>
          <line x1="8"  y1="36" x2="16" y2="40"/>
          <line x1="22" y1="14" x2="26" y2="22"/>
        </g>
        {/* membrane */}
        <circle cx="50" cy="50" r="34" fill="#fff" opacity="0.2"/>
        <circle cx="50" cy="50" r="32" fill="none" stroke="#fff" strokeWidth="3"/>
        {/* organelles */}
        <ellipse cx="32" cy="38" rx="5" ry="3" fill="#fff" opacity="0.45" transform="rotate(30 32 38)"/>
        <ellipse cx="66" cy="64" rx="5" ry="3" fill="#fff" opacity="0.45" transform="rotate(-20 66 64)"/>
        <circle cx="68" cy="36" r="3" fill="#fff" opacity="0.6"/>
        <circle cx="34" cy="64" r="2.5" fill="#fff" opacity="0.5"/>
        {/* nucleus (single big "eye") */}
        <circle cx="50" cy="50" r="14" fill="#fff"/>
        <circle cx="50" cy="50" r="11" fill="#3a4a6e"/>
        <circle cx="46" cy="46" r="3" fill="#fff" opacity="0.85"/>
        <circle cx="54" cy="54" r="1.5" fill="#fff" opacity="0.6"/>
      </g>
    ),
    // ─── Wave: surfing sine wave ───
    wave: (
      <g>
        {/* layered waves */}
        <path d="M8 70q10 -16 21 0 t21 0 t21 0 t21 0" fill="none" stroke="#fff" strokeWidth="3" strokeLinecap="round" opacity="0.55"/>
        <path d="M8 56q10 -22 21 0 t21 0 t21 0 t21 0" fill="none" stroke="#fff" strokeWidth="4.5" strokeLinecap="round"/>
        <path d="M8 56q10 -22 21 0 t21 0" fill="#fff" opacity="0.18"/>
        {/* face on the crest */}
        <circle cx="26" cy="42" r="2.8" fill="#5a2d3e"/>
        <circle cx="38" cy="42" r="2.8" fill="#5a2d3e"/>
        <circle cx="25" cy="41" r="1" fill="#fff"/>
        <circle cx="37" cy="41" r="1" fill="#fff"/>
        <path d="M27 48q5 3 10 0" stroke="#5a2d3e" strokeWidth="2" fill="none" strokeLinecap="round"/>
        {/* foam dots */}
        <circle cx="68" cy="40" r="2"   fill="#fff" opacity="0.85"/>
        <circle cx="82" cy="48" r="1.5" fill="#fff" opacity="0.7"/>
        <circle cx="60" cy="36" r="1.5" fill="#fff" opacity="0.7"/>
      </g>
    ),
    // ─── pH: test-strip character, color-changing ───
    ph: (
      <g>
        {/* strip body */}
        <rect x="36" y="14" width="28" height="74" rx="6" fill="#fff"/>
        <rect x="36" y="14" width="28" height="20" rx="6" fill="#e89b8b"/>
        <rect x="36" y="34" width="28" height="14" fill="#f0c870"/>
        <rect x="36" y="48" width="28" height="14" fill="#8ab896"/>
        <rect x="36" y="62" width="28" height="14" fill="#7eb0d8"/>
        <rect x="36" y="76" width="28" height="12" rx="0" fill="#9b7eb8"/>
        <path d="M36 76h28v6a6 6 0 0 1 -6 6h-16a6 6 0 0 1 -6 -6z" fill="#9b7eb8"/>
        <rect x="36" y="14" width="28" height="74" rx="6" fill="none" stroke="#fff" strokeWidth="2"/>
        {/* pH label */}
        <text x="50" y="28" textAnchor="middle" fontFamily="DM Mono, monospace" fontSize="11" fontWeight="800" fill="#fff">pH</text>
        {/* face mid-strip */}
        <circle cx="46" cy="55" r="2.6" fill="#1f2e1d"/>
        <circle cx="54" cy="55" r="2.6" fill="#1f2e1d"/>
        <circle cx="45.5" cy="54" r="1" fill="#fff"/>
        <circle cx="53.5" cy="54" r="1" fill="#fff"/>
        <path d="M46 62q4 3 8 0" stroke="#1f2e1d" strokeWidth="1.8" fill="none" strokeLinecap="round"/>
      </g>
    ),
    // ─── Sigma: confident Σ with face ───
    sigma: (
      <g>
        {/* Σ shape */}
        <path d="M28 20h44v10l-22 20l22 20v10h-44l16 -30z"
          fill="#fff" stroke="#1f3245" strokeWidth="2.5" strokeLinejoin="round"/>
        {/* face in the V */}
        <circle cx="44" cy="48" r="3" fill="#1f3245"/>
        <circle cx="56" cy="48" r="3" fill="#1f3245"/>
        <circle cx="43" cy="47" r="1" fill="#fff"/>
        <circle cx="55" cy="47" r="1" fill="#fff"/>
        <path d="M45 56q5 3 10 0" stroke="#1f3245" strokeWidth="1.8" fill="none" strokeLinecap="round"/>
        {/* tally marks (counting) */}
        <line x1="22" y1="80" x2="22" y2="88" stroke="#fff" strokeWidth="2" strokeLinecap="round"/>
        <line x1="26" y1="80" x2="26" y2="88" stroke="#fff" strokeWidth="2" strokeLinecap="round"/>
        <line x1="76" y1="80" x2="76" y2="88" stroke="#fff" strokeWidth="2" strokeLinecap="round"/>
        <line x1="80" y1="80" x2="80" y2="88" stroke="#fff" strokeWidth="2" strokeLinecap="round"/>
      </g>
    ),
    // ─── Prism: triangle refracting white light into a rainbow ───
    prism: (
      <g>
        {/* incoming white ray */}
        <line x1="6" y1="50" x2="32" y2="50" stroke="#fff" strokeWidth="3" strokeLinecap="round"/>
        {/* prism */}
        <path d="M50 18L24 76h52z" fill="#fff" opacity="0.92" stroke="#fff" strokeWidth="2.5" strokeLinejoin="round"/>
        {/* refracted rays */}
        <line x1="60" y1="50" x2="92" y2="32" stroke="#ff8b8b" strokeWidth="3" strokeLinecap="round"/>
        <line x1="62" y1="55" x2="94" y2="46" stroke="#ffd47a" strokeWidth="3" strokeLinecap="round"/>
        <line x1="62" y1="60" x2="94" y2="60" stroke="#a3d68a" strokeWidth="3" strokeLinecap="round"/>
        <line x1="62" y1="65" x2="94" y2="74" stroke="#8bd4ff" strokeWidth="3" strokeLinecap="round"/>
        {/* face on prism */}
        <circle cx="44" cy="52" r="2.5" fill="#3a1f00"/>
        <circle cx="55" cy="52" r="2.5" fill="#3a1f00"/>
        <circle cx="43.5" cy="51" r="0.9" fill="#fff"/>
        <circle cx="54.5" cy="51" r="0.9" fill="#fff"/>
        <path d="M44 60q5 3 10 0" stroke="#3a1f00" strokeWidth="1.7" fill="none" strokeLinecap="round"/>
      </g>
    ),
    // ─── Leaf: leaf character with veins ───
    leaf: (
      <g>
        {/* stem */}
        <path d="M52 88L60 70" stroke="#3a4f24" strokeWidth="3" strokeLinecap="round"/>
        {/* leaf body */}
        <path d="M22 60c0 -24 22 -42 56 -42c0 24 -22 42 -56 42z" fill="#a8d68a"/>
        <path d="M22 60c0 -24 22 -42 56 -42c0 24 -22 42 -56 42z" fill="none" stroke="#3a4f24" strokeWidth="2.5" strokeLinejoin="round"/>
        {/* veins */}
        <path d="M22 60L78 18" stroke="#3a4f24" strokeWidth="2" strokeLinecap="round"/>
        <path d="M34 56l8 -16M44 50l10 -20M54 44l12 -22M64 38l10 -20" stroke="#3a4f24" strokeWidth="1.5" strokeLinecap="round" opacity="0.7"/>
        {/* dewdrop highlight */}
        <ellipse cx="38" cy="38" rx="5" ry="3" fill="#fff" opacity="0.45" transform="rotate(-45 38 38)"/>
        {/* face */}
        <circle cx="42" cy="50" r="2.5" fill="#1f2e1d"/>
        <circle cx="54" cy="44" r="2.5" fill="#1f2e1d"/>
        <circle cx="41" cy="49" r="0.9" fill="#fff"/>
        <circle cx="53" cy="43" r="0.9" fill="#fff"/>
        <path d="M44 56q5 2 10 -2" stroke="#1f2e1d" strokeWidth="1.7" fill="none" strokeLinecap="round"/>
      </g>
    ),
  };

  return (
    <svg className="wc-char-svg" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <radialGradient id={gradId} cx="32%" cy="28%" r="80%">
          <stop offset="0%" stopColor={c1}/>
          <stop offset="100%" stopColor={c2}/>
        </radialGradient>
        <radialGradient id={highId} cx="30%" cy="22%" r="40%">
          <stop offset="0%"  stopColor="#fff" stopOpacity="0.45"/>
          <stop offset="100%" stopColor="#fff" stopOpacity="0"/>
        </radialGradient>
      </defs>
      <circle cx="50" cy="50" r="50" fill={`url(#${gradId})`}/>
      <circle cx="50" cy="50" r="50" fill={`url(#${highId})`}/>
      {motif[kind] || motif.atom}
      {/* rim shadow */}
      <circle cx="50" cy="50" r="49" fill="none" stroke="rgba(0,0,0,0.18)" strokeWidth="1"/>
    </svg>
  );
}

// Wrapped character with optional frame
function Character({ kind, frame, size = 'md', initials: ini }) {
  const sizeCls = `size-${size}`;
  const frameCls = frame ? `framed frame-${frame}` : '';
  return (
    <div className={`wc-char ${sizeCls} ${frameCls}`}>
      <div className="wc-char-inner">
        {kind ? <CharGlyph kind={kind}/> : (
          <div style={{ width: '100%', height: '100%', background: 'var(--adv-rose)', color: '#fff', display: 'grid', placeItems: 'center', fontFamily: 'var(--adv-display)', fontWeight: 800, fontSize: size === 'sm' ? 13 : size === 'md' ? 18 : 32 }}>{ini || '?'}</div>
        )}
      </div>
    </div>
  );
}

// Trophy chip (small inline badge)
function Trophy({ icon = 'crown', tone = 'gold', size = 'sm' }) {
  return <span className={`wc-trophy ${tone} ${size === 'lg' ? 'lg' : ''}`}><Icon name={icon}/></span>;
}

// ── Identity-rich leaderboard row ─────────────────────────────
function IdRow({ row }) {
  const rankCls = row.rank === 1 ? 'gold' : row.rank === 2 ? 'silver' : row.rank === 3 ? 'bronze' : '';
  return (
    <div className={`wc-id-row ${row.you ? 'me' : ''} ${row.teacher ? 'teacher' : ''}`}>
      <div className={`wc-rank ${rankCls}`}>{row.rank}</div>
      <div className="wc-id-who">
        <Character kind={row.char} frame={row.frame} size="md"/>
        <div className="wc-id-name-wrap">
          <div className={`wc-id-name ${row.nameStyle || ''}`}>
            {row.name}
            {row.you && <span className="wc-row-chip you-chip" style={{ marginLeft: 6 }}>YOU</span>}
            {row.teacher && <span className="wc-row-chip teacher-chip" style={{ marginLeft: 6 }}>TEACHER</span>}
            {row.trophies && row.trophies.length > 0 && (
              <span className="wc-trophies">
                {row.trophies.map((t, i) => <Trophy key={i} icon={t.icon} tone={t.tone}/>)}
              </span>
            )}
          </div>
          {row.title && (
            <div className="wc-id-meta">
              <span className={`wc-title-chip ${row.titleTone || 'gold'}`}>{row.title}</span>
            </div>
          )}
        </div>
      </div>
      {row.streak >= 5 && (
        <div className="wc-row-streak"><Icon name="flame"/>{row.streak}d</div>
      )}
      <div className="wc-row-score">
        <strong>{row.score.toLocaleString()}</strong>
        <small>pts</small>
      </div>
    </div>
  );
}

// ── Identity-rich data (re-skinned school board) ──────────────
const ID_SCHOOL_BOARD = [
  { rank: 1, name: 'PhotonPhoenix', score: 4820, streak: 12, char: 'bolt',   frame: 'champ',  title: 'Apex Predator',   titleTone: 'gold',   nameStyle: 'gradient',
    trophies: [{icon:'crown',tone:'gold'},{icon:'flame',tone:'coral'},{icon:'target',tone:'green'}] },
  { rank: 2, name: 'KineticKira',   score: 4710, streak: 9,  char: 'wave',   frame: 'gold',   title: 'Streak Smasher',  titleTone: 'coral',
    trophies: [{icon:'flame',tone:'coral'},{icon:'sparkles',tone:'plum'}] },
  { rank: 3, name: 'MitoMari',      score: 4650, streak: 6,  char: 'cell',   frame: 'silver', title: 'Cell Splitter',   titleTone: 'green',
    trophies: [{icon:'target',tone:'green'}] },
  { rank: 4, name: 'QuantumQuokka',    score: 4420, streak: 7,  char: 'pi',     frame: 'rose',   title: 'Year 11 Phenom',  titleTone: 'rose',  you: true,
    trophies: [{icon:'flame',tone:'coral'},{icon:'medal',tone:'gold'}] },
  { rank: 5, name: 'ProtonPete',    score: 4380, streak: 4,  char: 'atom',   frame: 'bronze' },
  { rank: 6, name: 'AldolAlex',     score: 4210, streak: 3,  char: 'beaker', frame: 'bronze' },
  { rank: 7, name: 'QuasarQ',       score: 4140, streak: 5,  char: 'prism' },
  { rank: 8, name: 'TitratorT',     score: 4020, streak: 2,  char: 'ph' },
];

// teacher entry — with cosmic frame
const TEACHER_ROW = {
  rank: 1, name: 'Dr Park',  score: 5780, streak: 22, char: 'helix', frame: 'cosmic', teacher: true,
  title: 'Apex Educator', titleTone: 'cosmic', nameStyle: 'cosmic',
  trophies: [{icon:'crown',tone:'gold'},{icon:'trophy',tone:'gold'},{icon:'sparkles',tone:'plum'}]
};

// ── Shop items ──────────────────────────────────────────────
const SHOP_CHARS = [
  { kind: 'atom',   price: 250,  rarity: 'common',    status: null },
  { kind: 'beaker', price: 250,  rarity: 'common',    status: 'owned' },
  { kind: 'helix',  price: 500,  rarity: 'rare',      status: 'owned' },
  { kind: 'pi',     price: 500,  rarity: 'rare',      status: 'equipped' },
  { kind: 'bolt',   price: 800,  rarity: 'epic',      status: null },
  { kind: 'cell',   price: 800,  rarity: 'epic',      status: null },
  { kind: 'mole',   price: 1200, rarity: 'legendary', status: 'locked', unlock: 'Lvl 12' },
  { kind: 'wave',   price: 1200, rarity: 'legendary', status: 'locked', unlock: 'Beat a teacher' },
];

const SHOP_FRAMES = [
  { id: 'bronze', name: 'Bronze ring',   price: 150, rarity: 'common',    status: 'owned' },
  { id: 'silver', name: 'Silver ring',   price: 400, rarity: 'rare',      status: 'owned' },
  { id: 'gold',   name: 'Gold ring',     price: 900, rarity: 'epic',      status: null },
  { id: 'rose',   name: 'Rose laurel',   price: 900, rarity: 'epic',      status: 'equipped' },
  { id: 'cosmic', name: 'Cosmic dust',   price: 1800,rarity: 'legendary', status: 'locked', unlock: 'Top 10 NSW' },
  { id: 'champ',  name: 'Champion crown',price: 2500,rarity: 'legendary', status: 'locked', unlock: '#1 weekly' },
];

const SHOP_TITLES = [
  { id: 't1', text: 'Year 11 Phenom',  tone: 'rose',   price: 300,  rarity: 'common',    status: 'equipped' },
  { id: 't2', text: 'Mole Master',     tone: 'gold',   price: 500,  rarity: 'rare',      status: null },
  { id: 't3', text: 'Streak Smasher',  tone: 'coral',  price: 700,  rarity: 'rare',      status: null },
  { id: 't4', text: 'Apex Predator',   tone: 'gold',   price: 1500, rarity: 'legendary', status: 'locked', unlock: '5× weekly #1' },
  { id: 't5', text: 'Cell Splitter',   tone: 'green',  price: 500,  rarity: 'rare',      status: 'owned' },
  { id: 't6', text: 'Northvale Royal', tone: 'plum',   price: 1000, rarity: 'epic',      status: 'locked', unlock: '#1 at your school' },
];

// ── 1) Locker — your equipped setup + slots ──────────────────
function RewardLocker() {
  return (
    <div className="wc-scope">
      <TopBar subtitle="Locker"/>

      <div className="wc-shell">
        <section className="wc-hero" style={{ background: 'linear-gradient(135deg, #2d2640 0%, #4e4068 50%, #c47b8a 100%)' }}>
          <div className="wc-hero-inner" style={{ gridTemplateColumns: '1.4fr 1fr' }}>
            <div>
              <div className="wc-hero-badges">
                <span className="wc-hero-badge"><Icon name="sparkles"/> Identity</span>
                <span className="wc-hero-badge gold"><Icon name="coin"/> 1,240 coins · earn via lessons + challenges</span>
              </div>
              <h1>Your <em>Locker</em></h1>
              <p className="wc-hero-sub">Mix and match a character, frame, title and a trophy to show off. Everything here travels with you onto every leaderboard.</p>
              <div className="wc-hero-actions">
                <button className="wc-cta wc-cta-gold"><Icon name="coin"/> Open shop</button>
                <button className="wc-cta wc-cta-ghost">Earn more coins</button>
              </div>
            </div>
            <div className="wc-countdown" style={{ background: 'rgba(255,255,255,0.1)' }}>
              <div className="wc-cd-ring" style={{ position: 'relative' }}>
                <Character kind="pi" frame="champ" size="lg"/>
              </div>
              <div>
                <div className="wc-cd-label">Equipped</div>
                <div className="wc-cd-title">Pi · Champion crown</div>
                <div className="wc-cd-sub">"Year 11 Phenom" · 2 trophies displayed</div>
              </div>
            </div>
          </div>
        </section>

        <div className="wc-section-label">Your setup</div>

        <div className="wc-locker">
          <div className="wc-locker-preview">
            <div className="wc-locker-eye">How you appear</div>
            <div className="wc-locker-avatar">
              <Character kind="pi" frame="champ" size="xl"/>
            </div>
            <div className="wc-locker-name">QuantumQuokka</div>
            <span className="wc-locker-name-chip"><span className="wc-title-chip rose">Year 11 Phenom</span></span>
            <div className="wc-locker-trophies">
              <Trophy icon="crown" tone="gold" size="lg"/>
              <Trophy icon="flame" tone="coral" size="lg"/>
              <Trophy icon="medal" tone="plum" size="lg"/>
            </div>
          </div>

          <div>
            <div className="wc-slots">
              <div className="wc-slot">
                <div className="wc-slot-icon"><Icon name="users"/></div>
                <div>
                  <div className="wc-slot-label">Character</div>
                  <div className="wc-slot-name">Pi · Rare</div>
                </div>
                <a className="wc-slot-action" href="#">Change</a>
              </div>
              <div className="wc-slot">
                <div className="wc-slot-icon"><Icon name="crown"/></div>
                <div>
                  <div className="wc-slot-label">Frame</div>
                  <div className="wc-slot-name">Champion crown</div>
                </div>
                <a className="wc-slot-action" href="#">Change</a>
              </div>
              <div className="wc-slot">
                <div className="wc-slot-icon"><Icon name="bolt"/></div>
                <div>
                  <div className="wc-slot-label">Title</div>
                  <div className="wc-slot-name">Year 11 Phenom</div>
                </div>
                <a className="wc-slot-action" href="#">Change</a>
              </div>
              <div className="wc-slot">
                <div className="wc-slot-icon"><Icon name="trophy"/></div>
                <div>
                  <div className="wc-slot-label">Trophy display (3)</div>
                  <div className="wc-slot-name">Weekly #1 · 12d streak · Bio Champ</div>
                </div>
                <a className="wc-slot-action" href="#">Pick</a>
              </div>
            </div>

            <div style={{ marginTop: 18, padding: 16, background: 'var(--adv-cream)', border: '1.5px solid var(--adv-gold)', borderRadius: 'var(--adv-r-lg)', display: 'flex', alignItems: 'center', gap: 14 }}>
              <Icon name="bulb" style={{ color: 'var(--adv-gold-deep)', width: 22, height: 22 }}/>
              <div style={{ fontSize: 13.5, color: 'var(--adv-ink)', flex: 1, lineHeight: 1.5 }}>
                <strong>Tip:</strong> the <strong>Mole</strong> character unlocks at <strong>Lvl 12</strong> — you're 3 levels away. Complete this week's challenge for an instant <strong>+250 XP</strong>.
              </div>
              <button className="wc-cta wc-cta-gold" style={{ padding: '10px 16px', fontSize: 13 }}>Play challenge</button>
            </div>
          </div>
        </div>

        <div className="wc-section-label">Owned · 14 items</div>

        <div className="wc-shop-grid" style={{ margin: '0 20px', gridTemplateColumns: 'repeat(6, 1fr)' }}>
          {['beaker','helix','pi','atom','cell','prism'].map((k, i) => (
            <div key={k} className={`wc-item ${k === 'pi' ? 'owned' : ''}`}>
              {k === 'pi' && <div className="wc-item-corner-icon"><Icon name="check"/></div>}
              <div className="wc-item-preview"><Character kind={k} size="md"/></div>
              <div className="wc-item-name">{CHARS[k].name}</div>
              <div className="wc-item-tag">{CHARS[k].tag}</div>
              <span className={`wc-item-status ${k === 'pi' ? 'equipped' : ''}`}>{k === 'pi' ? 'Equipped' : 'Owned'}</span>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

// ── 2) Shop — browse + buy ──────────────────────────────────
function RewardShop() {
  return (
    <div className="wc-scope">
      <TopBar subtitle="Shop"/>

      <div className="wc-shell">
        <div className="wc-section-label" style={{ marginTop: 20 }}>Shop · spend earned coins</div>

        <div className="wc-shop-shell">
          {/* aside */}
          <aside className="wc-shop-aside">
            <div className="wc-balance">
              <div className="wc-balance-label">Your balance</div>
              <div className="wc-balance-amt"><Icon name="coin"/> 1,240</div>
              <div className="wc-balance-sub">Earned · spend on cosmetics only</div>
            </div>

            <h4>Categories</h4>
            <div className="wc-shop-nav">
              <button className="active"><Icon name="users"/> Characters <span className="count">12</span></button>
              <button><Icon name="crown"/> Frames <span className="count">6</span></button>
              <button><Icon name="bolt"/> Titles <span className="count">14</span></button>
              <button><Icon name="sparkles"/> Name effects <span className="count">4</span></button>
              <button><Icon name="trophy"/> Trophy slots <span className="count">2</span></button>
            </div>

            <h4>Filter</h4>
            <div className="wc-shop-nav">
              <button>All</button>
              <button><Icon name="check"/> Affordable now</button>
              <button>New this week</button>
            </div>
          </aside>

          {/* main */}
          <div className="wc-shop-main">
            {/* featured pack */}
            <div className="wc-shop-feature">
              <div>
                <div className="wc-shop-feature-eye">Pack of the week · expires in 3d 14h</div>
                <h3>Champion Bundle</h3>
                <p><strong>Cosmic dust frame</strong> + the <strong>"Apex Predator"</strong> title + one trophy display slot — 35% off until Monday.</p>
                <div className="wc-shop-feature-preview">
                  <Character kind="bolt" frame="cosmic" size="lg"/>
                  <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
                    <span className="wc-title-chip cosmic">Apex Predator</span>
                    <div style={{ display: 'flex', gap: 4 }}>
                      <Trophy icon="crown" tone="gold"/>
                      <Trophy icon="sparkles" tone="plum"/>
                      <Trophy icon="flame" tone="coral"/>
                    </div>
                  </div>
                </div>
              </div>
              <div className="wc-shop-feature-price">
                <div className="wc-shop-feature-price-amt"><Icon name="coin"/> 2,800</div>
                <div className="wc-shop-feature-price-was">was 4,300</div>
                <button className="wc-shop-feature-price-cta">Buy bundle</button>
              </div>
            </div>

            <div className="wc-shop-head">
              <h3>Characters</h3>
              <div className="wc-shop-head-meta">8 of 12 · sorted by price</div>
            </div>

            <div className="wc-shop-grid">
              {SHOP_CHARS.map(c => {
                const ch = CHARS[c.kind];
                return (
                  <div key={c.kind} className={`wc-item ${c.status === 'owned' || c.status === 'equipped' ? 'owned' : ''} ${c.status === 'locked' ? 'locked' : ''}`}>
                    <span className={`wc-item-rarity ${c.rarity}`}>{c.rarity}</span>
                    {(c.status === 'owned' || c.status === 'equipped') && <div className="wc-item-corner-icon"><Icon name={c.status === 'equipped' ? 'star' : 'check'}/></div>}
                    <div className="wc-item-preview"><Character kind={c.kind} size="md"/></div>
                    <div className="wc-item-name">{ch.name}</div>
                    <div className="wc-item-tag">{ch.tag}</div>
                    {c.status === 'equipped' && <span className="wc-item-status equipped">Equipped</span>}
                    {c.status === 'owned' && <span className="wc-item-status">Owned</span>}
                    {c.status === 'locked' && <span className="wc-item-status locked">{c.unlock}</span>}
                    {c.status === null && <span className="wc-item-price"><Icon name="coin"/> {c.price.toLocaleString()}</span>}
                  </div>
                );
              })}
            </div>

            <div className="wc-shop-head" style={{ marginTop: 24 }}>
              <h3>Frames</h3>
              <div className="wc-shop-head-meta">Ring around your character</div>
            </div>
            <div className="wc-shop-grid" style={{ gridTemplateColumns: 'repeat(6, 1fr)' }}>
              {SHOP_FRAMES.map(f => (
                <div key={f.id} className={`wc-item ${f.status === 'owned' || f.status === 'equipped' ? 'owned' : ''} ${f.status === 'locked' ? 'locked' : ''}`}>
                  <span className={`wc-item-rarity ${f.rarity}`}>{f.rarity}</span>
                  <div className="wc-item-preview"><Character kind="pi" frame={f.id} size="md"/></div>
                  <div className="wc-item-name">{f.name}</div>
                  {f.status === 'equipped' && <span className="wc-item-status equipped">Equipped</span>}
                  {f.status === 'owned' && <span className="wc-item-status">Owned</span>}
                  {f.status === 'locked' && <span className="wc-item-status locked">{f.unlock}</span>}
                  {f.status === null && <span className="wc-item-price"><Icon name="coin"/> {f.price.toLocaleString()}</span>}
                </div>
              ))}
            </div>

            <div className="wc-shop-head" style={{ marginTop: 24 }}>
              <h3>Titles</h3>
              <div className="wc-shop-head-meta">Two-word identity tag shown under your name</div>
            </div>
            <div className="wc-shop-grid" style={{ gridTemplateColumns: 'repeat(3, 1fr)' }}>
              {SHOP_TITLES.map(t => (
                <div key={t.id} className={`wc-item title-item ${t.status === 'owned' || t.status === 'equipped' ? 'owned' : ''} ${t.status === 'locked' ? 'locked' : ''}`}>
                  <span className={`wc-item-rarity ${t.rarity}`}>{t.rarity}</span>
                  <div className="wc-item-preview"><span className={`wc-title-chip ${t.tone}`} style={{ fontSize: 13, padding: '5px 14px' }}>{t.text}</span></div>
                  {t.status === 'equipped' && <span className="wc-item-status equipped">Equipped</span>}
                  {t.status === 'owned' && <span className="wc-item-status">Owned</span>}
                  {t.status === 'locked' && <span className="wc-item-status locked">{t.unlock}</span>}
                  {t.status === null && <span className="wc-item-price"><Icon name="coin"/> {t.price.toLocaleString()}</span>}
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}

// ── 3) Boards-with-identity ─────────────────────────────────
function RewardBoards() {
  return (
    <div className="wc-scope">
      <TopBar subtitle="Weekly Boards · with identity"/>

      <div className="wc-shell">
        <div className="wc-section-label" style={{ marginTop: 20 }}>What it actually looks like</div>

        <div style={{ margin: '0 20px 14px', padding: '14px 18px', background: 'var(--adv-panel)', border: '1.5px dashed var(--adv-rule)', borderRadius: 'var(--adv-r-lg)', fontSize: 13, color: 'var(--adv-ink-soft)', display: 'flex', alignItems: 'center', gap: 14 }}>
          <Icon name="sparkles" style={{ color: 'var(--adv-rose-deep)', width: 20, height: 20 }}/>
          <span>Every row now carries the player's <strong style={{ color: 'var(--adv-ink)' }}>character, frame, title and earned trophies</strong>. Hover to inspect, click for their profile.</span>
        </div>

        <div className="wc-card wc-board" style={{ margin: '0 20px' }}>
          <div className="wc-board-head">
            <div className="wc-board-icon rose"><Icon name="school"/></div>
            <div>
              <div className="wc-board-title">Northvale High</div>
              <div className="wc-board-sub">Week 28 · 124 students playing</div>
            </div>
            <div className="wc-board-meta">Updated 4m ago</div>
          </div>
          {ID_SCHOOL_BOARD.map(r => <IdRow key={r.rank} row={r}/>)}
        </div>

        <div className="wc-section-label">Beat the Teacher · what the top of that board looks like</div>

        <div className="wc-card wc-board" style={{ margin: '0 20px' }}>
          <div className="wc-board-head">
            <div className="wc-board-icon gold"><Icon name="crown"/></div>
            <div>
              <div className="wc-board-title">Beat the Teacher</div>
              <div className="wc-board-sub">All ages · all subjects · NSW-wide</div>
            </div>
            <div className="wc-board-meta">Week 28</div>
          </div>
          <IdRow row={TEACHER_ROW}/>
          <IdRow row={{
            rank: 2, name: 'Ms Tanaka', score: 5660, streak: 18, char: 'beaker', frame: 'gold', teacher: true,
            title: 'Titration Tyrant', titleTone: 'gold',
            trophies: [{icon:'crown',tone:'gold'},{icon:'flame',tone:'coral'}]
          }}/>
          <IdRow row={{
            rank: 3, name: 'Mr Whitlock', score: 5510, streak: 14, char: 'bolt', frame: 'gold', teacher: true,
            title: 'Force Wielder', titleTone: 'coral',
            trophies: [{icon:'medal',tone:'gold'},{icon:'sparkles',tone:'plum'}]
          }}/>
          <IdRow row={{
            rank: 4, name: 'ZenithMC', score: 4980, streak: 14, char: 'sigma', frame: 'cosmic',
            title: 'Year 12 · Mathletes', titleTone: 'cosmic', nameStyle: 'cosmic',
            trophies: [{icon:'crown',tone:'gold'}]
          }}/>
        </div>
      </div>
    </div>
  );
}

// ── 4) Achievements / Trophy wall ───────────────────────────
const ACHIEVEMENTS = [
  { name: 'Weekly champion',   tier: 'gold',     icon: 'crown',    prog: [3,5],  got: false, unlock: '3/5' },
  { name: 'Streak guardian',   tier: 'rare',     icon: 'flame',    prog: [12,30],got: false, unlock: '12/30' },
  { name: 'Perfect run',       tier: 'epic',     icon: 'target',   prog: [1,1],  got: true,  unlock: 'Done' },
  { name: 'Teacher slayer',    tier: 'legendary',icon: 'swords',   prog: [0,3],  got: false, unlock: '0/3' },
  { name: 'Bio specialist',    tier: 'rare',     icon: 'helix',    prog: [40,50],got: false, unlock: '40/50' },
  { name: 'Maths specialist',  tier: 'rare',     icon: 'sparkles', prog: [50,50],got: true,  unlock: 'Done' },
  { name: 'Speed demon',       tier: 'epic',     icon: 'bolt',     prog: [1,1],  got: true,  unlock: 'Done' },
  { name: 'Northvale #1',      tier: 'epic',     icon: 'school',   prog: [0,1],  got: false, unlock: 'Locked' },
  { name: 'NSW top 50',        tier: 'legendary',icon: 'star',     prog: [0,1],  got: false, unlock: 'Locked' },
  { name: 'First challenge',   tier: 'common',   icon: 'play',     prog: [1,1],  got: true,  unlock: 'Done' },
  { name: 'Coin collector',    tier: 'rare',     icon: 'coin',     prog: [1240,2500], got: false, unlock: '1.2k/2.5k' },
  { name: 'Comeback kid',      tier: 'epic',     icon: 'arrowUp',  prog: [0,1],  got: false, unlock: 'Drop 5+, climb back' },
];

function RewardAchievements() {
  return (
    <div className="wc-scope">
      <TopBar subtitle="Trophy case"/>

      <div className="wc-shell">
        <section className="wc-hero" style={{ background: 'linear-gradient(135deg, #2d3142 0%, #4e4068 40%, #d6a85f 100%)' }}>
          <div className="wc-hero-inner">
            <div>
              <div className="wc-hero-badges">
                <span className="wc-hero-badge"><Icon name="trophy"/> Earned, not bought</span>
                <span className="wc-hero-badge gold">4 / 24 unlocked</span>
              </div>
              <h1>Trophy <em>Case</em></h1>
              <p className="wc-hero-sub">Pick any 3 to display next to your name on every leaderboard. Some are stackable — the Streak Guardian gets a fancier icon at 30 / 90 / 180 days.</p>
            </div>
            <div className="wc-countdown" style={{ background: 'rgba(255,255,255,0.1)' }}>
              <div style={{ display: 'flex', gap: 8 }}>
                <Trophy icon="crown" tone="gold" size="lg"/>
                <Trophy icon="target" tone="green" size="lg"/>
                <Trophy icon="sparkles" tone="plum" size="lg"/>
              </div>
              <div>
                <div className="wc-cd-label">Currently displayed</div>
                <div className="wc-cd-title">3 of 3 slots used</div>
                <div className="wc-cd-sub">Hover any trophy on a board to see how it was earned</div>
              </div>
            </div>
          </div>
        </section>

        <div className="wc-section-label">All achievements</div>

        <div className="wc-ach-grid">
          {ACHIEVEMENTS.map((a, i) => (
            <div key={i} className={`wc-ach ${a.got ? 'got' : ''} ${a.unlock === 'Locked' ? 'lock' : ''}`}>
              <div className="wc-ach-unlock">{a.tier}</div>
              <div className="wc-ach-icon"><Icon name={a.icon}/></div>
              <div className="wc-ach-name">{a.name}</div>
              <div className="wc-ach-tier">{a.tier}</div>
              <div className="wc-ach-prog"><span style={{ width: `${Math.min(100, a.prog[0]/a.prog[1]*100)}%` }}></span></div>
              <div className="wc-ach-frac">{a.unlock}</div>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

// ── 5) Gallery — all characters at scale so you can compare ─────
function RewardGallery() {
  const all = Object.keys(CHARS);
  return (
    <div className="wc-scope">
      <TopBar subtitle="Character gallery"/>
      <div className="wc-shell">
        <section className="wc-hero" style={{ background: 'linear-gradient(135deg, #2d3142 0%, #4e4068 40%, #c47b8a 90%)' }}>
          <div className="wc-hero-inner">
            <div>
              <div className="wc-hero-badges">
                <span className="wc-hero-badge"><Icon name="sparkles"/> 12 characters · 6 frames</span>
                <span className="wc-hero-badge gold">More dropping monthly</span>
              </div>
              <h1>Character <em>Gallery</em></h1>
              <p className="wc-hero-sub">All characters at large size — this is the source of truth for the look. Picking one gives you instant identity on every board.</p>
            </div>
            <div className="wc-countdown" style={{ background: 'rgba(255,255,255,0.1)' }}>
              <div className="wc-cd-ring" style={{ position: 'relative' }}>
                <Character kind="bolt" frame="champ" size="lg"/>
              </div>
              <div>
                <div className="wc-cd-label">Featured</div>
                <div className="wc-cd-title">Volt · Champion crown</div>
                <div className="wc-cd-sub">This week's most-bought</div>
              </div>
            </div>
          </div>
        </section>

        <div className="wc-section-label">All 12 characters</div>

        <div style={{ margin: '0 20px', display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
          {all.map(k => {
            const c = CHARS[k];
            return (
              <div key={k} className="wc-card" style={{ padding: '24px 16px', textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }}>
                <Character kind={k} size="xl"/>
                <div style={{ fontFamily: 'var(--adv-display)', fontSize: 18, fontWeight: 800, color: 'var(--adv-ink)', marginTop: 6 }}>{c.name}</div>
                <div style={{ fontSize: 11, fontWeight: 700, letterSpacing: 1, textTransform: 'uppercase', color: 'var(--adv-muted)' }}>{c.tag}</div>
              </div>
            );
          })}
        </div>

        <div className="wc-section-label">Frame treatments · same character, different rarity</div>

        <div style={{ margin: '0 20px 20px', display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: 14 }}>
          {[
            { f: null,       label: 'No frame',       sub: 'Default' },
            { f: 'bronze',   label: 'Bronze',         sub: 'Common · 150c' },
            { f: 'silver',   label: 'Silver',         sub: 'Rare · 400c' },
            { f: 'gold',     label: 'Gold',           sub: 'Epic · 900c' },
            { f: 'cosmic',   label: 'Cosmic dust',    sub: 'Legendary · earned' },
            { f: 'champ',    label: 'Champion crown', sub: 'Legendary · earned' },
          ].map((row, i) => (
            <div key={i} className="wc-card" style={{ padding: '20px 14px', textAlign: 'center' }}>
              <div style={{ display: 'flex', justifyContent: 'center', padding: '10px 0 14px' }}>
                <Character kind="atom" frame={row.f} size="lg"/>
              </div>
              <div style={{ fontFamily: 'var(--adv-display)', fontSize: 13, fontWeight: 800, color: 'var(--adv-ink)' }}>{row.label}</div>
              <div style={{ fontSize: 11, color: 'var(--adv-muted)', marginTop: 2, fontWeight: 600 }}>{row.sub}</div>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

Object.assign(window, {
  CHARS, CharGlyph, Character, Trophy, IdRow,
  RewardLocker, RewardShop, RewardBoards, RewardAchievements, RewardGallery,
  ID_SCHOOL_BOARD, TEACHER_ROW,
});
