// prediction-data.jsx — i18n + mock state for the Prediction Hub (پیش‌بینی).
// This sprint snapshot: matchweek 28, 8 matches across 4 competitions, 4 lifecycle
// states represented (open · predicted · locked · settled). Sponsor: همراه اول.
//
// Decisions baked here, sourced from §11 of rakhtkan_design_doc + Wireframes f2:
//   • Prediction questions per match are heterogeneous (score, 3way, range, bool, scorer).
//   • Each question has its OWN reward cap; total = sum of caps (max payout).
//   • States: 'open' | 'predicted' | 'locked' | 'settled' | 'missed' (missed = locked w/o answers)
//   • coin-heavy / XP-light economy: rewards in coins primarily.

// ─── i18n ──────────────────────────────────────────────────────────────────
const PR_I18N = {
  fa: {
    // Page chrome
    pageEyebrow: 'پیش‌بینی هفته',
    pageTitle: (n) => `هفته ${n} · ${n === '۲۸' ? 'لیگ و ملی' : ''}`,
    pageSubtitle: 'با پیش‌بینی، سکه بگیر و پک باز کن.',
    weekOf: 'هفته',
    weekShort: 'هفته',
    deadline: 'مهلت ثبت',
    nextLock: 'قفل بعدی',
    closesIn: 'بسته شدن تا',
    closed: 'بسته شد',
    matchwide: 'بازی‌های این هفته',
    coinShort: 'سکه',
    xpLimited: 'XP محدود',
    sponsoredBy: 'با حمایت',
    sponsorEyebrow: 'پک ویژه فوتبال‌دوستان',

    // Stats strip (3 numbers)
    statsActive: 'بازی فعال',
    statsTotal: 'همه',
    statsDone: 'انجام شده',

    // Reward preview (sticky band)
    rewardPreviewTitle: 'اگه همه رو درست بزنی',
    rewardPreviewSub: 'سکه پاداش حداکثری این هفته',
    rewardSoFar: 'تا الان پیش‌بینی',
    rewardSoFarOf: (n, of) => `${n} از ${of} سوال جواب داده`,

    // Filters
    filterAll: 'همه',
    filterToday: 'امروز',
    filterFeatured: 'ویژه',
    filterFinished: 'پایان‌یافته',
    filterUpcoming: 'پیش‌رو',
    filterLocked: 'قفل',

    // Match card chrome
    vs: 'مقابل',
    matchKick: 'شروع بازی',
    questions: (n) => `${n} سوال`,
    questionsOf: (have, total) => `${have} از ${total} سوال`,
    questionsLeft: (n) => `${n} سوال باقی`,
    rewardUpTo: (coins) => `تا ${coins} سکه`,
    earnedCoins: (coins) => `+${coins} سکه دریافت شد`,
    earnedXP: (xp) => `+${xp} XP محدود`,
    waitingResult: 'منتظر نتیجه',
    locked: 'قفل شد',
    finalScore: (h, a) => `${h} - ${a}`,
    correctAnswers: (correct, total) => `${correct} از ${total} پاسخ درست`,
    autoCredited: 'خودکار به موجودی اضافه شد',
    inCalculation: 'در حال محاسبه',

    // Match state tags
    tagDerby: 'دربی',
    tagClassico: 'الکلاسیکو',
    tagFinal: 'فینال',
    tagFeatured: 'ویژه',
    tagHighlighted: 'برجسته',
    tagNormal: 'عادی',
    tagSettled: 'پایان یافت',
    tagLocked: 'قفل شد',
    tagNew: 'سوال جدید',
    tagNewN: (n) => `${n} سوال جدید`,

    // CTA
    ctaPredict: 'پیش‌بینی کن',
    ctaContinue: 'ادامه',
    ctaSavedView: 'دیدن پاسخ‌ها',
    ctaSettledView: 'دیدن نتایج',
    ctaOpenPack: 'پک باز کن',
    ctaSave: 'ذخیره تغییرات',
    ctaSaved: 'پیش‌بینی ذخیره شد',
    ctaEditable: 'قابل ویرایش تا شروع بازی',
    ctaCollapse: 'بستن',
    ctaExpand: 'باز کردن',

    // Question types (titles + helper)
    qScoreTitle: 'نتیجه نهایی',
    qScoreHelp: 'سکه احتمالی بعد از پایان بازی مشخص می‌شه',
    q3wayTitle: 'تیم برتر بازی',
    q3wayHome: (name) => name,
    q3wayDraw: 'مساوی',
    q3wayAway: (name) => name,
    qTotalGoalsTitle: 'تعداد گل کل',
    qTotalGoalsHelp: 'چند گل در کل بازی زده می‌شه؟',
    qTotalLow: '۰ تا ۱ گل',
    qTotalMid: '۲ تا ۳ گل',
    qTotalHigh: '۴+ گل',
    qBttsTitle: 'هر دو تیم گل می‌زنن؟',
    qBttsYes: 'بله',
    qBttsNo: 'خیر',
    qScorerTitle: 'اولین گل‌زن',
    qScorerHelp: 'کی اولین گل بازی رو می‌زنه؟',
    qScorerOther: 'بازیکن دیگر',
    qScorerNone: 'بدون گل',
    qLocked: 'هنوز قفل · بعد از شروع بازی باز می‌شه',
    qAnswered: 'پاسخ ثبت شد',
    qWaiting: 'منتظر نتیجه',
    qCorrect: 'درست',
    qNear: 'نزدیک',
    qWrong: 'غلط',
    qActual: 'واقعی',
    qYours: 'پیش‌بینی تو',
    qExpand: 'تغییر پاسخ',
    qSubmitted: '✓ ثبت شد',

    // History strip
    historyTitle: 'هفته‌های قبل',
    historySub: 'پیش‌بینی‌های گذشته‌ی تو',
    historyAll: 'همه',
    historyWeekShort: (n) => `هفته ${n}`,
    historyOf: (correct, total) => `${correct}/${total}`,
    historyRewardEarned: (coins) => `+${coins}`,
    historyView: 'مشاهده',

    // Empty / inline help
    emptyTitle: 'هیچ بازی فعالی نیست',
    emptyBody: 'امروز بازی برای پیش‌بینی نداری. بازی‌های پیش‌رو رو ببین یا اعلانش رو روشن کن.',
    emptyCta: 'دیدن بازی‌های پیش‌رو',
    emptyCta2: 'اعلان فعال شدن بازی',
    nextStart: 'شروع بعدی',
  },

  en: {
    pageEyebrow: 'Weekly Predictions',
    pageTitle: (n) => `Matchweek ${n}`,
    pageSubtitle: 'Predict, earn coin, open packs.',
    weekOf: 'Week', weekShort: 'MW',
    deadline: 'Deadline', nextLock: 'Next lock', closesIn: 'Closes in', closed: 'Closed',
    matchwide: 'This week\u2019s matches',
    coinShort: 'coin', xpLimited: 'limited XP',
    sponsoredBy: 'Sponsored by', sponsorEyebrow: 'Football-fan data pack',

    statsActive: 'open matches', statsTotal: 'all', statsDone: 'answered',

    rewardPreviewTitle: 'If you nail every pick',
    rewardPreviewSub: 'max coin payout this week',
    rewardSoFar: 'progress',
    rewardSoFarOf: (n, of) => `${n} of ${of} answered`,

    filterAll: 'All', filterToday: 'Today', filterFeatured: 'Featured',
    filterFinished: 'Finished', filterUpcoming: 'Upcoming', filterLocked: 'Locked',

    vs: 'vs', matchKick: 'Kick-off',
    questions: (n) => `${n} questions`,
    questionsOf: (have, total) => `${have} of ${total}`,
    questionsLeft: (n) => `${n} left`,
    rewardUpTo: (coins) => `up to ${coins} coin`,
    earnedCoins: (coins) => `+${coins} coin earned`,
    earnedXP: (xp) => `+${xp} limited XP`,
    waitingResult: 'Awaiting result', locked: 'Locked',
    finalScore: (h, a) => `${h} \u2013 ${a}`,
    correctAnswers: (correct, total) => `${correct} of ${total} correct`,
    autoCredited: 'Auto-credited to your balance', inCalculation: 'Calculating',

    tagDerby: 'Derby', tagClassico: 'El Clásico', tagFinal: 'Final',
    tagFeatured: 'Featured', tagHighlighted: 'Highlighted', tagNormal: 'Normal',
    tagSettled: 'Settled', tagLocked: 'Locked',
    tagNew: 'New question', tagNewN: (n) => `${n} new`,

    ctaPredict: 'Predict', ctaContinue: 'Continue',
    ctaSavedView: 'View answers', ctaSettledView: 'View results',
    ctaOpenPack: 'Open pack', ctaSave: 'Save changes',
    ctaSaved: 'Prediction saved', ctaEditable: 'Editable until kick-off',
    ctaCollapse: 'Collapse', ctaExpand: 'Expand',

    qScoreTitle: 'Final score', qScoreHelp: 'Coin payout settles after the match',
    q3wayTitle: 'Match winner',
    q3wayHome: (name) => name, q3wayDraw: 'Draw', q3wayAway: (name) => name,
    qTotalGoalsTitle: 'Total goals', qTotalGoalsHelp: 'How many goals in the match?',
    qTotalLow: '0–1 goals', qTotalMid: '2–3 goals', qTotalHigh: '4+ goals',
    qBttsTitle: 'Both teams to score?', qBttsYes: 'Yes', qBttsNo: 'No',
    qScorerTitle: 'First goal scorer', qScorerHelp: 'Who scores first?',
    qScorerOther: 'Another player', qScorerNone: 'No goal',
    qLocked: 'Locked · opens at kick-off', qAnswered: 'Answered', qWaiting: 'Awaiting result',
    qCorrect: 'Correct', qNear: 'Close', qWrong: 'Wrong',
    qActual: 'Actual', qYours: 'Your pick',
    qExpand: 'Change pick', qSubmitted: '\u2713 Saved',

    historyTitle: 'Recent weeks', historySub: 'Your prediction history', historyAll: 'All',
    historyWeekShort: (n) => `MW${n}`,
    historyOf: (correct, total) => `${correct}/${total}`,
    historyRewardEarned: (coins) => `+${coins}`, historyView: 'View',

    emptyTitle: 'No open matches', emptyBody: 'Nothing to predict today. Browse upcoming or get notified.',
    emptyCta: 'Browse upcoming', emptyCta2: 'Notify me', nextStart: 'Next kick-off',
  },

  ar: {
    pageEyebrow: 'توقعات الأسبوع',
    pageTitle: (n) => `الجولة ${n}`,
    pageSubtitle: 'توقع، اربح عملات وافتح حزماً.',
    weekOf: 'الأسبوع', weekShort: 'ج',
    deadline: 'الموعد النهائي', nextLock: 'الإغلاق التالي', closesIn: 'الإغلاق خلال', closed: 'مغلق',
    matchwide: 'مباريات هذا الأسبوع',
    coinShort: 'عملة', xpLimited: 'XP محدود',
    sponsoredBy: 'برعاية', sponsorEyebrow: 'باقة لعشاق كرة القدم',

    statsActive: 'مباريات مفتوحة', statsTotal: 'الكل', statsDone: 'تمت الإجابة',

    rewardPreviewTitle: 'إذا أصبت في الكل',
    rewardPreviewSub: 'أقصى عدد عملات لهذا الأسبوع',
    rewardSoFar: 'تقدمك',
    rewardSoFarOf: (n, of) => `${n} من ${of} سؤال`,

    filterAll: 'الكل', filterToday: 'اليوم', filterFeatured: 'مميز',
    filterFinished: 'منتهٍ', filterUpcoming: 'قادم', filterLocked: 'مغلق',

    vs: 'ضد', matchKick: 'بدء المباراة',
    questions: (n) => `${n} أسئلة`,
    questionsOf: (have, total) => `${have} من ${total}`,
    questionsLeft: (n) => `${n} متبقي`,
    rewardUpTo: (coins) => `حتى ${coins} عملة`,
    earnedCoins: (coins) => `+${coins} عملة`,
    earnedXP: (xp) => `+${xp} XP محدود`,
    waitingResult: 'بانتظار النتيجة', locked: 'مغلق',
    finalScore: (h, a) => `${h} \u2013 ${a}`,
    correctAnswers: (correct, total) => `${correct} من ${total} صحيحة`,
    autoCredited: 'أُضيف تلقائياً للرصيد', inCalculation: 'يُحسب',

    tagDerby: 'ديربي', tagClassico: 'كلاسيكو', tagFinal: 'نهائي',
    tagFeatured: 'مميز', tagHighlighted: 'بارز', tagNormal: 'عادي',
    tagSettled: 'منتهية', tagLocked: 'مغلق',
    tagNew: 'سؤال جديد', tagNewN: (n) => `${n} جديد`,

    ctaPredict: 'توقع الآن', ctaContinue: 'متابعة',
    ctaSavedView: 'عرض الإجابات', ctaSettledView: 'عرض النتائج',
    ctaOpenPack: 'فتح حزمة', ctaSave: 'حفظ التغييرات',
    ctaSaved: 'تم حفظ التوقع', ctaEditable: 'قابل للتعديل حتى البداية',
    ctaCollapse: 'طي', ctaExpand: 'فتح',

    qScoreTitle: 'النتيجة النهائية', qScoreHelp: 'تُحسب العملات بعد المباراة',
    q3wayTitle: 'الفائز بالمباراة',
    q3wayHome: (name) => name, q3wayDraw: 'تعادل', q3wayAway: (name) => name,
    qTotalGoalsTitle: 'إجمالي الأهداف', qTotalGoalsHelp: 'كم هدفاً في المباراة كاملة؟',
    qTotalLow: '٠–١', qTotalMid: '٢–٣', qTotalHigh: '٤+',
    qBttsTitle: 'هل يسجل الفريقان؟', qBttsYes: 'نعم', qBttsNo: 'لا',
    qScorerTitle: 'هدّاف أول هدف', qScorerHelp: 'من يسجل أول هدف؟',
    qScorerOther: 'لاعب آخر', qScorerNone: 'بدون هدف',
    qLocked: 'مغلق · يُفتح عند البداية', qAnswered: 'تمت الإجابة', qWaiting: 'بانتظار النتيجة',
    qCorrect: 'صحيح', qNear: 'قريب', qWrong: 'خطأ',
    qActual: 'الفعلي', qYours: 'توقعك',
    qExpand: 'تغيير الإجابة', qSubmitted: '\u2713 محفوظ',

    historyTitle: 'الأسابيع السابقة', historySub: 'سجل توقعاتك', historyAll: 'الكل',
    historyWeekShort: (n) => `ج${n}`,
    historyOf: (correct, total) => `${correct}/${total}`,
    historyRewardEarned: (coins) => `+${coins}`, historyView: 'عرض',

    emptyTitle: 'لا مباريات مفتوحة', emptyBody: 'لا توجد مباريات للتوقع اليوم. تصفح القادم أو فعّل التنبيهات.',
    emptyCta: 'تصفح القادم', emptyCta2: 'فعّل التنبيه', nextStart: 'البداية التالية',
  },
};

// ─── Sponsor (reuses Home Hub sponsor brands — kept inline for portability) ──
const PR_SPONSORS = (typeof HH_SPONSORS !== 'undefined') ? HH_SPONSORS : {
  mci:  { brand: { fa: 'همراه اول', en: 'MCI', ar: 'إم سي آي' },
          tag:   { fa: 'با حمایت همراه اول', en: 'Sponsored by MCI', ar: 'برعاية MCI' },
          tagline:{ fa: 'بسته ویژه فوتبال‌دوستان', en: 'Football-fan data pack', ar: 'باقة لعشاق كرة القدم' },
          accent: '#E11D48' },
};

// ─── Week meta ──────────────────────────────────────────────────────────────
// "هفته" lives at the page level; matches are children of the week.
const PR_WEEK = {
  id: 'mw28-2026',
  number: 28,
  competitionLabel: { fa: 'لیگ برتر · لیگ قهرمانان · ملی', en: 'PGPL · UCL · Friendlies', ar: 'الدوري · الأبطال · ودية' },
  // Deadline = earliest match's kick-off. Driven independently for clarity in mock.
  deadline:   { h: 3,  m: 24, s: 10 },
  // Hours until the latest match closes — used to show "بسته شدن کل هفته"
  weekCloses: { h: 102, m: 30, s: 0 },
  // Date range covered (fa primary, en/ar secondaries)
  dateRange: {
    fa: '۲۹ اردیبهشت تا ۲ خرداد ۱۴۰۵',
    en: 'May 19 – May 23, 2026',
    ar: '٢٩ أرديبهشت – ٢ خرداد ١٤٠٥',
  },
};

// ─── Player options for first-goal-scorer (compact) ────────────────────────
function _player(fa, en, ar, code, position) {
  return { name: { fa, en, ar }, code, position };
}
const _scorers = {
  perEst: [
    _player('عبدی', 'Abdi', 'عبدي', 'PER', 'FWD'),
    _player('علی‌پور', 'Alipour', 'علي بور', 'PER', 'FWD'),
    _player('قائدی', 'Ghaedi', 'قائدي', 'EST', 'FWD'),
    _player('مهرداد محمدی', 'Mehrdad', 'مهرداد', 'EST', 'MID'),
  ],
  rmaBar: [
    _player('وینیسیوس', 'Vinícius', 'فينيسيوس', 'RMA', 'FWD'),
    _player('بلینگام', 'Bellingham', 'بلينغهام', 'RMA', 'MID'),
    _player('لواندوفسکی', 'Lewandowski', 'ليفاندوفسكي', 'BAR', 'FWD'),
    _player('یامال', 'Yamal', 'يامال', 'BAR', 'FWD'),
  ],
  mciLiv: [
    _player('هالند', 'Haaland', 'هالاند', 'MCI', 'FWD'),
    _player('فودن', 'Foden', 'فودن', 'MCI', 'MID'),
    _player('صلاح', 'Salah', 'صلاح', 'LIV', 'FWD'),
    _player('نونیز', 'Núñez', 'نونيز', 'LIV', 'FWD'),
  ],
  irnJpn: [
    _player('آزمون', 'Azmoun', 'أزمون', 'IRN', 'FWD'),
    _player('طارمی', 'Taremi', 'طارمي', 'IRN', 'FWD'),
    _player('کوبایاشی', 'Kobayashi', 'كوباياشي', 'JPN', 'FWD'),
    _player('کامادا', 'Kamada', 'كامادا', 'JPN', 'MID'),
  ],
  serieA: [
    _player('لائوتارو', 'Lautaro', 'لاوتارو', 'INT', 'FWD'),
    _player('کوارتسخلیا', 'Kvaratskhelia', 'كفاراتسخيليا', 'NAP', 'FWD'),
  ],
  bundes: [
    _player('کین', 'Kane', 'كين', 'BAY', 'FWD'),
    _player('روسینگ', 'Reus', 'رويس', 'BVB', 'MID'),
  ],
  ucl2: [
    _player('مبپه', 'Mbappé', 'مبابي', 'PSG', 'FWD'),
    _player('هایلاند', 'Højlund', 'هويلوند', 'MUN', 'FWD'),
  ],
  laliga: [
    _player('بنزما', 'Benzema', 'بنزيمة', 'RMA', 'FWD'),
    _player('فلیک', 'Felix', 'فيليكس', 'ATM', 'FWD'),
  ],
};

// ─── Question templates (heterogeneous) ─────────────────────────────────────
// Each question has: id, type, title-i18n-key, rewardMax, optional helpers.
// `lockedUntilKick=true` means the question opens later (after kick-off in a real
// product). For mock we mark some as locked to show that state.
function _qScore(rewardMax = 120)        { return { id: 'score',  type: 'score',  rewardMax }; }
function _q3way(rewardMax = 80)          { return { id: '3way',   type: '3way',   rewardMax }; }
function _qTotal(rewardMax = 60)         { return { id: 'total',  type: 'range',  rewardMax }; }
function _qBtts(rewardMax = 50)          { return { id: 'btts',   type: 'bool',   rewardMax }; }
function _qScorer(rewardMax = 100, options, lockedUntilKick = false) {
  return { id: 'scorer', type: 'scorer', rewardMax, options, lockedUntilKick };
}

// Default user prediction shape for each type — null = not answered yet.
//   score:  { home: 0..9, away: 0..9 }
//   3way:   'home' | 'draw' | 'away'
//   range:  'low' | 'mid' | 'high'
//   bool:   true | false
//   scorer: { code, name } | 'other' | 'none'

// ─── 8 matches for matchweek 28 ────────────────────────────────────────────
//
// Mix is engineered to show the 4 lifecycle states clearly on a single screen:
//   1. Persepolis vs Esteghlal — 'open + featured' (Derby badge)
//   2. Real vs Barcelona       — 'partial' (some answers, more to give)
//   3. Man City vs Liverpool   — 'predicted' (all answered, sufficient time)
//   4. Iran vs Japan           — 'open'
//   5. Inter vs Napoli         — 'predicted'
//   6. Bayern vs Dortmund      — 'locked' (match started)
//   7. PSG vs Man United       — 'settled' (rewards earned)
//   8. Real vs Atlético        — 'settled' (mixed: 2 correct, 1 near, 1 wrong)
const PR_MATCHES = [
  // 1. Tehran Derby — featured/highlighted open
  {
    id: 'mw28-per-est',
    state: 'open',
    featured: true,
    home: { fa: 'پرسپولیس', en: 'Persepolis', ar: 'بيرسبوليس', code: 'PER', color: '#DC2626' },
    away: { fa: 'استقلال',  en: 'Esteghlal',  ar: 'إستقلال',   code: 'EST', color: '#1D4ED8' },
    league:      { fa: 'لیگ برتر · هفته ۲۸', en: 'PGPL · MW28',  ar: 'الدوري · ٢٨' },
    leagueShort: { fa: 'لیگ برتر',           en: 'PGPL',         ar: 'الدوري' },
    venue: { fa: 'تهران · آزادی', en: 'Tehran · Azadi', ar: 'طهران · آزادي' },
    dateJalali:    { fa: '۲۹ اردیبهشت', en: 'Ord 29',  ar: '٢٩ أرديبهشت' },
    dateGregorian: 'May 19, 2026',
    kickoff:  { fa: '۱۹:۳۰', en: '19:30', ar: '١٩:٣٠' },
    hours: 3, minutes: 24, seconds: 10,
    tag: 'derby',
    questions: [_qScore(160), _q3way(100), _qTotal(80), _qBtts(60), _qScorer(160, _scorers.perEst)],
    rewardMax: 560,
    userAnswers: {},   // none yet
    correctness: null,
    settled: null,
  },

  // 2. UCL Semifinal — featured/highlighted partial
  {
    id: 'mw28-rma-bar',
    state: 'partial',
    featured: true,
    home: { fa: 'رئال مادرید', en: 'Real Madrid', ar: 'ريال مدريد', code: 'RMA', color: '#FFFFFF' },
    away: { fa: 'بارسلونا',    en: 'Barcelona',    ar: 'برشلونة',    code: 'BAR', color: '#A50044' },
    league:      { fa: 'لیگ قهرمانان · نیمه‌نهایی', en: 'UCL · Semifinal', ar: 'الأبطال · النصف' },
    leagueShort: { fa: 'لیگ قهرمانان',              en: 'UCL',             ar: 'الأبطال' },
    venue: { fa: 'مادرید · برنابئو', en: 'Madrid · Bernabéu', ar: 'مدريد · بيرنابيو' },
    dateJalali:    { fa: '۳۰ اردیبهشت', en: 'Ord 30',  ar: '٣٠ أرديبهشت' },
    dateGregorian: 'May 20, 2026',
    kickoff:  { fa: '۲۳:۰۰', en: '23:00', ar: '٢٣:٠٠' },
    hours: 27, minutes: 12, seconds: 30,
    tag: 'classico',
    questions: [_qScore(180), _q3way(120), _qTotal(80), _qBtts(60), _qScorer(180, _scorers.rmaBar, true)],
    rewardMax: 620,
    userAnswers: { '3way': 'home', 'btts': true }, // 2 of 5 answered
    correctness: null,
    settled: null,
  },

  // 3. EPL — fully predicted (all answered, time still safe)
  {
    id: 'mw28-mci-liv',
    state: 'predicted',
    featured: false,
    home: { fa: 'منچستر سیتی', en: 'Man City',  ar: 'مانشستر سيتي', code: 'MCI', color: '#6CABDD' },
    away: { fa: 'لیورپول',      en: 'Liverpool', ar: 'ليفربول',      code: 'LIV', color: '#C8102E' },
    league:      { fa: 'لیگ جزیره · هفته ۳۶', en: 'EPL · MW36',  ar: 'البريميرليج · ٣٦' },
    leagueShort: { fa: 'لیگ جزیره',           en: 'EPL',         ar: 'البريميرليج' },
    venue: { fa: 'منچستر · اتحاد', en: 'Manchester · Etihad', ar: 'مانشستر · اتحاد' },
    dateJalali:    { fa: '۱ خرداد',  en: 'Khr 1',   ar: '١ خرداد' },
    dateGregorian: 'May 21, 2026',
    kickoff:  { fa: '۲۲:۳۰', en: '22:30', ar: '٢٢:٣٠' },
    hours: 51, minutes: 0, seconds: 0,
    tag: 'highlighted',
    questions: [_qScore(140), _q3way(100), _qTotal(60), _qBtts(40), _qScorer(120, _scorers.mciLiv)],
    rewardMax: 460,
    userAnswers: {
      score:  { home: 2, away: 1 },
      '3way': 'home',
      total:  'mid',
      btts:   true,
      scorer: { code: 'MCI', name: { fa: 'هالند', en: 'Haaland', ar: 'هالاند' } },
    },
    correctness: null,
    settled: null,
  },

  // 4. International friendly — open
  {
    id: 'mw28-irn-jpn',
    state: 'open',
    featured: false,
    home: { fa: 'ایران', en: 'Iran',  ar: 'إيران',  code: 'IRN', color: '#239F40' },
    away: { fa: 'ژاپن',   en: 'Japan',  ar: 'اليابان', code: 'JPN', color: '#BC002D' },
    league:      { fa: 'دوستانه · ملی',           en: 'Intl Friendly',  ar: 'ودية دولية' },
    leagueShort: { fa: 'دوستانه',                  en: 'Friendly',       ar: 'ودية' },
    venue: { fa: 'تهران · آزادی', en: 'Tehran · Azadi', ar: 'طهران · آزادي' },
    dateJalali:    { fa: '۲ خرداد',  en: 'Khr 2',   ar: '٢ خرداد' },
    dateGregorian: 'May 22, 2026',
    kickoff:  { fa: '۲۰:۰۰', en: '20:00', ar: '٢٠:٠٠' },
    hours: 73, minutes: 30, seconds: 0,
    tag: 'normal',
    questions: [_qScore(100), _q3way(60), _qBtts(40), _qScorer(60, _scorers.irnJpn, true)],
    rewardMax: 260,
    userAnswers: {},
    correctness: null,
    settled: null,
  },

  // 5. Serie A — predicted
  {
    id: 'mw28-int-nap',
    state: 'predicted',
    featured: false,
    home: { fa: 'اینتر',  en: 'Inter',  ar: 'إنتر',     code: 'INT', color: '#1F4E8C' },
    away: { fa: 'ناپولی',   en: 'Napoli', ar: 'نابولي',  code: 'NAP', color: '#2C8AC9' },
    league:      { fa: 'سری آ · هفته ۳۴', en: 'Serie A · MW34', ar: 'الإيطالي · ٣٤' },
    leagueShort: { fa: 'سری آ',           en: 'Serie A',        ar: 'الإيطالي' },
    venue: { fa: 'میلان · سن سیرو', en: 'Milan · San Siro', ar: 'ميلانو · سان سيرو' },
    dateJalali:    { fa: '۲ خرداد', en: 'Khr 2', ar: '٢ خرداد' },
    dateGregorian: 'May 22, 2026',
    kickoff:  { fa: '۲۲:۰۰', en: '22:00', ar: '٢٢:٠٠' },
    hours: 75, minutes: 30, seconds: 0,
    tag: 'normal',
    questions: [_qScore(120), _q3way(70), _qTotal(60), _qBtts(40)],
    rewardMax: 290,
    userAnswers: { score: { home: 1, away: 2 }, '3way': 'away', total: 'mid', btts: true },
    correctness: null,
    settled: null,
  },

  // 6. Bundesliga — LOCKED (match in progress)
  {
    id: 'mw28-bay-bvb',
    state: 'locked',
    featured: false,
    home: { fa: 'بایرن',  en: 'Bayern',   ar: 'بايرن',   code: 'BAY', color: '#DC052D' },
    away: { fa: 'دورتموند', en: 'Dortmund', ar: 'دورتموند', code: 'BVB', color: '#FDE100' },
    league:      { fa: 'بوندس‌لیگا · هفته ۳۲', en: 'Bundesliga · MW32', ar: 'البوندس · ٣٢' },
    leagueShort: { fa: 'بوندس‌لیگا',           en: 'BL1',                ar: 'البوندس' },
    venue: { fa: 'مونیخ · آلیانتس', en: 'Munich · Allianz', ar: 'ميونخ · أليانتس' },
    dateJalali:    { fa: '۲۸ اردیبهشت', en: 'Ord 28', ar: '٢٨ أرديبهشت' },
    dateGregorian: 'May 18, 2026',
    kickoff:  { fa: '۲۱:۳۰', en: '21:30', ar: '٢١:٣٠' },
    // Negative-ish: match started ~30 minutes ago. Show "بازی شروع شده"
    hours: 0, minutes: 0, seconds: 0,
    lockedSince: { h: 0, m: 32, s: 0 }, // 32 min in
    tag: 'locked',
    questions: [_qScore(120), _q3way(80), _qTotal(60), _qBtts(40), _qScorer(100)],
    rewardMax: 400,
    // User submitted all 5 — now waiting for result
    userAnswers: {
      score: { home: 2, away: 2 }, '3way': 'draw', total: 'high', btts: true,
      scorer: { code: 'BAY', name: { fa: 'کین', en: 'Kane', ar: 'كين' } },
    },
    correctness: null,
    settled: null,
  },

  // 7. UCL Semifinal — SETTLED (rewards earned, mostly correct)
  {
    id: 'mw28-psg-mun',
    state: 'settled',
    featured: false,
    home: { fa: 'پاری سن‌ژرمن', en: 'PSG',         ar: 'باريس',        code: 'PSG', color: '#004170' },
    away: { fa: 'منچستر یونایتد', en: 'Man United',  ar: 'مانشستر يونايتد', code: 'MUN', color: '#DA291C' },
    league:      { fa: 'لیگ قهرمانان · نیمه‌نهایی', en: 'UCL · Semifinal', ar: 'الأبطال · النصف' },
    leagueShort: { fa: 'لیگ قهرمانان',              en: 'UCL',              ar: 'الأبطال' },
    venue: { fa: 'پاریس · پارک', en: 'Paris · Parc', ar: 'باريس · بارك' },
    dateJalali:    { fa: '۲۷ اردیبهشت', en: 'Ord 27', ar: '٢٧ أرديبهشت' },
    dateGregorian: 'May 17, 2026',
    kickoff:  { fa: '۲۳:۰۰', en: '23:00', ar: '٢٣:٠٠' },
    hours: 0, minutes: 0, seconds: 0,
    tag: 'settled',
    questions: [_qScore(140), _q3way(100), _qTotal(60), _qBtts(40), _qScorer(120)],
    rewardMax: 460,
    userAnswers: {
      score: { home: 2, away: 1 }, '3way': 'home', total: 'mid', btts: true,
      scorer: { code: 'PSG', name: { fa: 'مبپه', en: 'Mbappé', ar: 'مبابي' } },
    },
    correctness: { score: 'near', '3way': 'correct', total: 'correct', btts: 'correct', scorer: 'correct' },
    settled: {
      actualScore: { home: 3, away: 1 },
      actualWinner: 'home', actualTotal: 'mid', actualBtts: true,
      actualScorer: { code: 'PSG', name: { fa: 'مبپه', en: 'Mbappé', ar: 'مبابي' } },
      coinEarned: 380,
      xpEarned: 120,
      correctCount: 4, totalCount: 5,
    },
  },

  // 8. La Liga — SETTLED with mixed result
  {
    id: 'mw28-rma-atm',
    state: 'settled',
    featured: false,
    home: { fa: 'رئال مادرید', en: 'Real Madrid', ar: 'ريال مدريد', code: 'RMA', color: '#FFFFFF' },
    away: { fa: 'اتلتیکو',     en: 'Atlético',    ar: 'أتلتيكو',    code: 'ATM', color: '#CB3524' },
    league:      { fa: 'لالیگا · هفته ۳۶', en: 'La Liga · MW36', ar: 'الليغا · ٣٦' },
    leagueShort: { fa: 'لالیگا',           en: 'La Liga',        ar: 'الليغا' },
    venue: { fa: 'مادرید · برنابئو', en: 'Madrid · Bernabéu', ar: 'مدريد · بيرنابيو' },
    dateJalali:    { fa: '۲۶ اردیبهشت', en: 'Ord 26', ar: '٢٦ أرديبهشت' },
    dateGregorian: 'May 16, 2026',
    kickoff:  { fa: '۲۲:۰۰', en: '22:00', ar: '٢٢:٠٠' },
    hours: 0, minutes: 0, seconds: 0,
    tag: 'settled',
    questions: [_qScore(120), _q3way(70), _qTotal(60), _qBtts(40)],
    rewardMax: 290,
    userAnswers: { score: { home: 2, away: 0 }, '3way': 'home', total: 'low', btts: false },
    correctness: { score: 'wrong', '3way': 'correct', total: 'correct', btts: 'correct' },
    settled: {
      actualScore: { home: 1, away: 0 },
      actualWinner: 'home', actualTotal: 'low', actualBtts: false,
      coinEarned: 170,
      xpEarned: 60,
      correctCount: 3, totalCount: 4,
    },
  },
];

// ─── Aggregate week stats (derived from the matches above) ─────────────────
const PR_STATS = (() => {
  const totalQs   = PR_MATCHES.reduce((s, m) => s + m.questions.length, 0);
  const answered  = PR_MATCHES.reduce((s, m) => s + Object.keys(m.userAnswers || {}).length, 0);
  const finished  = PR_MATCHES.filter((m) => m.state === 'settled' || m.state === 'locked').length;
  const active    = PR_MATCHES.filter((m) => m.state === 'open' || m.state === 'partial' || m.state === 'predicted').length;
  const rewardMax = PR_MATCHES.reduce((s, m) => s + (m.rewardMax || 0), 0);
  const rewardEarned = PR_MATCHES
    .filter((m) => m.state === 'settled')
    .reduce((s, m) => s + (m.settled?.coinEarned || 0), 0);
  return { totalQs, answered, finished, active, rewardMax, rewardEarned };
})();

// ─── Recent prediction history (3 past weeks) ──────────────────────────────
const PR_HISTORY = [
  { id: 'mw27', week: 27, dateRange: { fa: '۲۲–۲۶ اردیبهشت', en: 'May 12–16', ar: '٢٢–٢٦ أرديبهشت' },
    matches: 6, predicted: 6, correct: 18, totalQs: 24, coinEarned: 1420, xpEarned: 380 },
  { id: 'mw26', week: 26, dateRange: { fa: '۱۵–۱۹ اردیبهشت', en: 'May 5–9',  ar: '١٥–١٩ أرديبهشت' },
    matches: 7, predicted: 7, correct: 15, totalQs: 26, coinEarned: 980,  xpEarned: 240 },
  { id: 'mw25', week: 25, dateRange: { fa: '۸–۱۲ اردیبهشت',  en: 'Apr 28–May 2', ar: '٨–١٢ أرديبهشت' },
    matches: 5, predicted: 4, correct: 8,  totalQs: 18, coinEarned: 620,  xpEarned: 160 },
];

// ─── Default user (reuse Home Hub if available, else lightweight stub) ─────
const PR_USER = (typeof HH_USER !== 'undefined') ? HH_USER : {
  displayName: { fa: 'علی محمدی', en: 'Ali Mohammadi', ar: 'علي محمدي' },
  shortName:   { fa: 'علی', en: 'Ali', ar: 'علي' },
  avatarInitial: 'ع',
  level: 24, xpInLevel: 3200, xpForLevel: 5000,
  globalRank: 324, rankDelta: 18, streak: 7,
  coinBalance: 12450, unreadNotifications: 3,
};

// Export to window so the pieces/app files can read these.
Object.assign(window, {
  PR_I18N, PR_SPONSORS, PR_WEEK, PR_MATCHES, PR_STATS, PR_HISTORY, PR_USER,
});
