/* ============================================================
   LeagueModule CSS — هم‌شکل با بقیه‌ی ماژول‌ها. پیشوند lg-.
   ============================================================ */

.league-module {
  --lg-c-bg: #f5f5f3;
  --lg-c-surface: #ffffff;
  --lg-c-border: rgba(0,0,0,0.08);
  --lg-c-border-strong: rgba(0,0,0,0.14);
  --lg-c-text: #1a1a18;
  --lg-c-text-2: #5a5a56;
  --lg-c-text-3: #9a9994;
  --lg-c-accent: #2563eb;
  --lg-c-accent-bg: #eff6ff;
  --lg-c-accent-text: #1d4ed8;
  --lg-c-accent-border: #bfdbfe;
  --lg-c-success: #16a34a;
  --lg-c-success-bg: #f0fdf4;
  --lg-c-warning: #d97706;
  --lg-c-warning-bg: #fffbeb;
  --lg-c-danger: #dc2626;
  --lg-c-danger-bg: #fef2f2;
  --lg-radius-sm: 6px;
  --lg-radius: 10px;
  --lg-radius-lg: 14px;
  --lg-transition: 0.15s ease;

  font-family: 'Vazirmatn', system-ui, sans-serif;
  color: var(--lg-c-text);
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}

[data-theme="dark"] .league-module {
  --lg-c-bg: #15161a;
  --lg-c-surface: #1c1d22;
  --lg-c-border: rgba(255,255,255,0.08);
  --lg-c-border-strong: rgba(255,255,255,0.14);
  --lg-c-text: #f1f1ef;
  --lg-c-text-2: #b3b3ad;
  --lg-c-text-3: #76766f;
  --lg-c-accent-bg: rgba(37,99,235,0.14);
}

.league-module * { box-sizing: border-box; }

/* ── Buttons ── */
.lg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 34px; border-radius: var(--lg-radius-sm); border: 1px solid var(--lg-c-border-strong); background: var(--lg-c-surface); color: var(--lg-c-text); font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; }
.lg-btn:hover { background: var(--lg-c-bg); }
.lg-btn-primary { background: var(--lg-c-accent); border-color: var(--lg-c-accent); color: #fff; }
.lg-btn-primary:hover { background: #1d4ed8; }

/* ── Page header ── */
.lg-page-hdr { margin-bottom: 20px; }
.lg-page-title { font-size: 20px; font-weight: 600; }
.lg-page-desc { font-size: 13px; color: var(--lg-c-text-3); margin-top: 3px; }
.lg-formula-hdr { text-align: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; padding: 20px; border-radius: var(--lg-radius-lg); }
.lg-formula-hdr .lg-page-title, .lg-formula-hdr .lg-page-desc { color: #fff; }

/* ── Loading ── */
.lg-loading { display: flex; justify-content: center; padding: 24px 0; }
.lg-spinner { width: 14px; height: 14px; border: 2px solid var(--lg-c-border-strong); border-top-color: var(--lg-c-text-2); border-radius: 50%; display: inline-block; animation: lgSpin 0.7s linear infinite; }
.lg-spinner.large { width: 26px; height: 26px; border-width: 3px; }
@keyframes lgSpin { to { transform: rotate(360deg); } }

/* ── League page shell ── */
.lg-banner { background: url(/images/leagueheader.jpg); background-size: cover; width: 100%; max-width: 700px; height: 60px; border-radius: 8px; margin: 10px auto; }
.lg-period-bar { display: flex; justify-content: center; align-items: center; gap: 8px; max-width: 420px; margin: 10px auto 20px; }
.lg-period-bar .lg-btn { flex: 1; justify-content: center; }
.lg-period-select { height: 34px; border: 1px solid var(--lg-c-border-strong); border-radius: var(--lg-radius-sm); padding: 0 10px; font-size: 12px; background: var(--lg-c-surface); color: var(--lg-c-text); font-family: inherit; flex: 1; }

.lg-chart-card { max-width: 700px; margin: 0 auto 20px; background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius-lg); padding: 14px; }
.lg-chart-title { text-align: center; font-weight: 600; font-size: 12px; background: var(--lg-c-accent); color: #fff; padding: 6px; border-radius: var(--lg-radius-sm); margin-bottom: 10px; }
.lg-chart-canvas { width: 100%; max-width: 100%; background: var(--lg-c-bg); border-radius: var(--lg-radius); }

.lg-content { max-width: 700px; margin: 0 auto; }

/* ── Rank table ── */
.lg-rank-wrap { background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius-lg); overflow: hidden; margin-bottom: 16px; }
table.lg-rank-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.lg-rank-tbl th { text-align: center; padding: 8px 4px; color: var(--lg-c-text-3); font-weight: 600; font-size: 10.5px; background: var(--lg-c-bg); }
table.lg-rank-tbl td { text-align: center; padding: 8px 4px; border-bottom: 1px solid var(--lg-c-border); }
table.lg-rank-tbl tr:last-child td { border-bottom: none; }
table.lg-rank-tbl tr.lg-highlight td { background: var(--lg-c-accent-bg); font-weight: 700; }
.lg-rank-icon { width: 30px; height: 30px; object-fit: contain; }
.lg-user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; margin: 0 auto; }
.lg-diamond-cell { display: inline-flex; align-items: center; gap: 3px; }
.lg-diamond-cell img { width: 14px; }

/* ── Competition banner ── */
.lg-competition-banner { display: flex; justify-content: center; margin: 20px 0; cursor: pointer; border-radius: var(--lg-radius-lg); overflow: hidden; transition: transform var(--lg-transition); }
.lg-competition-banner:hover { transform: translateY(-2px); }
.lg-competition-banner img { width: 100%; max-width: 320px; border-radius: var(--lg-radius-lg); }

.lg-diamond-tip { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 12px; font-size: 11px; }
.lg-diamond-tip img { width: 20px; }
.lg-diamond-tip a { color: var(--lg-c-accent-text); text-decoration: underline; }

/* ── Score formula settings ── */
.lg-formula-info { background: var(--lg-c-accent-bg); border: 1px solid var(--lg-c-accent-border); border-radius: var(--lg-radius); padding: 12px 14px; font-size: 12px; color: var(--lg-c-accent-text); margin: 16px 0; display: flex; gap: 8px; align-items: flex-start; }
.lg-formula-section { background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius-lg); padding: 18px; margin-bottom: 16px; }
.lg-formula-section-title { font-size: 14px; font-weight: 700; color: var(--lg-c-accent-text); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--lg-c-border); }
.lg-formula-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--lg-c-border); gap: 10px; }
.lg-formula-item:last-child { border-bottom: none; }
.lg-formula-item label { font-size: 12.5px; color: var(--lg-c-text-2); flex: 1; }
.lg-formula-item input { width: 110px; height: 32px; border: 1px solid var(--lg-c-border-strong); border-radius: var(--lg-radius-sm); padding: 0 10px; font-size: 12px; text-align: center; background: var(--lg-c-surface); color: var(--lg-c-text); }
.lg-formula-preview { background: var(--lg-c-bg); padding: 14px; border-radius: var(--lg-radius); direction: ltr; text-align: left; font-family: 'Courier New', monospace; font-size: 11px; line-height: 1.9; }
.lg-form-actions { display: flex; gap: 10px; margin: 20px 0; }
.lg-form-actions .lg-btn { flex: 1; justify-content: center; }

/* ── Modal (شل مسابقه) ── */
.lg-modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,15,14,0.5); z-index: 10000; align-items: center; justify-content: center; padding: 20px; }
.lg-modal-backdrop.open { display: flex; }
.lg-modal-box { width: 100%; max-width: 640px; background: var(--lg-c-surface); border-radius: var(--lg-radius-lg); border: 1px solid var(--lg-c-border); box-shadow: 0 24px 64px rgba(0,0,0,0.32); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.lg-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--lg-c-border); }
.lg-modal-title { font-size: 14px; font-weight: 600; }
.lg-modal-close { width: 30px; height: 30px; border: none; background: var(--lg-c-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--lg-c-text-2); cursor: pointer; }
.lg-modal-body { padding: 20px; overflow-y: auto; }

/* ── Confirm dialog ── */
.lg-confirm-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--lg-c-danger-bg); color: var(--lg-c-danger); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 26px; }
.lg-confirm-text { text-align: center; font-size: 13px; color: var(--lg-c-text-2); line-height: 1.7; }
.lg-modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.lg-modal-actions .lg-btn { flex: 1; justify-content: center; }

/* ── Waiting room (matchmaking) ── */
.lg-waiting-room { max-width: 420px; margin: 40px auto; text-align: center; }
.lg-waiting-spinner { margin-bottom: 16px; }
.lg-waiting-sub { color: var(--lg-c-text-3); font-size: 12px; margin-bottom: 16px; }
.lg-waiting-timer { font-size: 28px; font-weight: 700; font-family: 'Courier New', monospace; margin-bottom: 20px; color: var(--lg-c-accent); }
.lg-waiting-timeout { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.lg-waiting-timeout p { color: var(--lg-c-warning); font-size: 12.5px; }
.lg-waiting-timeout .lg-btn { width: 100%; justify-content: center; }

/* ── Competition hub ── */
.lg-comp-hub { max-width: 480px; margin: 30px auto; text-align: center; }
.lg-comp-modes { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.lg-comp-mode-btn { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; border: 1px solid var(--lg-c-border-strong); border-radius: var(--lg-radius-lg); background: var(--lg-c-surface); cursor: pointer; text-align: right; font-family: inherit; transition: border-color var(--lg-transition), background var(--lg-transition); }
.lg-comp-mode-btn:hover:not(.disabled) { border-color: var(--lg-c-accent); background: var(--lg-c-accent-bg); }
.lg-comp-mode-btn.disabled { opacity: 0.55; cursor: not-allowed; }
.lg-comp-mode-btn > i:first-child { font-size: 26px; color: var(--lg-c-accent); }
.lg-comp-mode-btn div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lg-comp-mode-btn strong { font-size: 13.5px; }
.lg-comp-mode-btn span { font-size: 11px; color: var(--lg-c-text-3); }
.lg-soon-badge { font-size: 10px; background: var(--lg-c-warning-bg); color: var(--lg-c-warning); padding: 3px 8px; border-radius: 20px; font-weight: 600; }

/* ── Game play ── */
.lg-game { max-width: 640px; margin: 0 auto; }
.lg-game-timer-bar { position: relative; height: 30px; background: var(--lg-c-bg); border-radius: var(--lg-radius-sm); overflow: hidden; margin-bottom: 14px; }
.lg-game-timer-fill { position: absolute; inset: 0; background: linear-gradient(90deg, var(--lg-c-accent), #764ba2); transition: width 1s linear; }
.lg-game-timer-text { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; height: 100%; font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }

.lg-game-scoreboard { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.lg-game-score-item { background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius); padding: 8px 16px; text-align: center; }
.lg-game-score-item span { display: block; font-size: 10.5px; color: var(--lg-c-text-3); }
.lg-game-score-item strong { font-size: 16px; }

.lg-game-section-title { text-align: center; font-size: 14px; margin-bottom: 14px; }
.lg-game-books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.lg-game-book-card { background: var(--lg-c-surface); border: 1px solid var(--lg-c-border-strong); border-radius: var(--lg-radius-lg); padding: 16px 10px; text-align: center; cursor: pointer; transition: transform var(--lg-transition); }
.lg-game-book-card:hover { transform: translateY(-3px); }
.lg-game-book-card.completed { opacity: 0.6; cursor: default; }
.lg-game-book-card.completed:hover { transform: none; }
.lg-game-book-icon { width: 44px; height: 44px; object-fit: contain; margin-bottom: 8px; }
.lg-game-book-title { font-size: 12px; font-weight: 600; }
.lg-game-book-status { font-size: 10px; color: var(--lg-c-success); margin-top: 6px; }

.lg-game-loading { text-align: center; padding: 40px 0; }
.lg-game-loading-sub { font-size: 11px; color: var(--lg-c-text-3); }

.lg-game-question { background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius-lg); padding: 20px; }
.lg-game-question-hdr { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--lg-c-text-3); margin-bottom: 14px; }
.lg-game-book-timer { color: var(--lg-c-warning); font-weight: 600; }
.lg-game-question-text { font-size: 15px; font-weight: 600; margin-bottom: 18px; line-height: 1.8; }
.lg-game-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.lg-game-option { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--lg-c-border-strong); border-radius: var(--lg-radius); background: var(--lg-c-surface); cursor: pointer; text-align: right; font-family: inherit; font-size: 12.5px; }
.lg-game-option:hover { background: var(--lg-c-bg); }
.lg-game-option.selected { border-color: var(--lg-c-accent); background: var(--lg-c-accent-bg); font-weight: 600; }
.lg-game-option-label { width: 24px; height: 24px; border-radius: 50%; background: var(--lg-c-bg); display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; }
.lg-game-actions { display: flex; gap: 8px; margin-top: 12px; }
.lg-game-actions .lg-btn { flex: 1; justify-content: center; }

/* ── Results page ── */
.lg-results-notfound { text-align: center; padding: 60px 20px; }
.lg-results-container { max-width: 560px; margin: 0 auto; }
.lg-results-header { text-align: center; margin-bottom: 24px; }
.lg-result-badge { width: 90px; height: 90px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 44px; }
.lg-result-badge.lg-result-win { background: linear-gradient(135deg, #667eea, #764ba2); }
.lg-result-badge.lg-result-draw { background: linear-gradient(135deg, #f093fb, #f5576c); }
.lg-result-badge.lg-result-loss { background: linear-gradient(135deg, #a8a8a8, #6b6b6b); }
.lg-result-badge.lg-result-withdrawn { background: linear-gradient(135deg, #f6ad55, #dd6b20); }
.lg-result-title { font-size: 18px; font-weight: 700; margin: 0; }
.lg-result-subtitle { color: var(--lg-c-text-3); font-size: 12px; margin-top: 4px; }

.lg-rewards-section { text-align: center; background: linear-gradient(135deg, #ffd700, #ffb700); border-radius: var(--lg-radius-lg); padding: 18px; margin-bottom: 16px; color: #5a3e00; }
.lg-diamond-display { font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px 0; }

.lg-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.lg-stat-card { background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius); padding: 12px; text-align: center; }
.lg-stat-label { font-size: 10.5px; color: var(--lg-c-text-3); }
.lg-stat-value { font-size: 17px; font-weight: 700; margin-top: 4px; }

.lg-section-title { font-size: 13px; margin-bottom: 10px; }
.lg-participants-section, .lg-books-section { margin-bottom: 18px; }
.lg-participant-card { display: flex; justify-content: space-between; align-items: center; background: var(--lg-c-surface); border: 1px solid var(--lg-c-border); border-radius: var(--lg-radius); padding: 10px 14px; margin-bottom: 8px; }
.lg-participant-card.winner { border-color: #ffd700; background: #fffbea; }
.lg-participant-info { display: flex; align-items: center; gap: 10px; }
.lg-rank-badge { width: 26px; height: 26px; border-radius: 50%; background: var(--lg-c-bg); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.lg-participant-score { font-weight: 700; }
.lg-book-result-card { display: flex; justify-content: space-between; padding: 10px 14px; background: var(--lg-c-bg); border-radius: var(--lg-radius-sm); margin-bottom: 6px; font-size: 12px; }
.lg-results-actions { display: flex; gap: 10px; margin-top: 20px; }
.lg-results-actions .lg-btn { flex: 1; justify-content: center; }

/* ── Toast ── */
.lg-toast-wrap { position: fixed; bottom: 24px; left: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.lg-toast { display: flex; align-items: center; gap: 10px; background: var(--lg-c-text); color: #fff; padding: 12px 16px; border-radius: var(--lg-radius); font-size: 13px; font-weight: 500; cursor: pointer; }

@media (max-width: 720px) {
  .lg-modal-backdrop { padding: 0; align-items: flex-end; }
  .lg-modal-box { max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .lg-toast-wrap { bottom: 12px; left: 12px; right: 12px; }
  .lg-toast { width: 100%; }
  .lg-formula-item { flex-direction: column; align-items: stretch; }
  .lg-formula-item input { width: 100%; }
}

/* ── نشانگر «رتبه‌بندی مدرسه‌محور» (۲۶ اوت ۲۰۲۶) ── */
.lg-school-scope-banner {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  background: var(--lg-c-accent-bg); color: var(--lg-c-accent-text);
  border: 1px solid var(--lg-c-accent-border); border-radius: var(--lg-radius-sm);
  padding: 10px 14px; margin-bottom: 14px;
}
.lg-school-scope-banner .ti { font-size: 15px; flex-shrink: 0; }
