
:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --accent: #f59e0b;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(15,23,42,.04), 0 8px 30px rgba(15,23,42,.06);
  --shadow-md: 0 6px 20px rgba(15,23,42,.08), 0 18px 50px rgba(15,23,42,.12);
}

body.dark {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #0f172a;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary-light: rgba(22, 163, 74, 0.15);
  --shadow: 0 4px 20px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.4);
}

*, ::before, ::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; direction: rtl !important; text-align: right !important; }
body { font-family: 'Tajawal', 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; transition: background 0.3s ease, color 0.3s ease; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1.2em !important; width: 1.2em !important; margin: 0 0.05em 0 0.1em !important; vertical-align: -0.1em !important; background: transparent !important; padding: 0 !important; }

/* --- Navigation & Hero --- */
.nav { height: 72px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.nav-brand { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 24px; letter-spacing: -1px; }
.nav-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; font-size: 20px; }
.theme-btn { background: var(--border); border: none; font-size: 18px; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; transition: transform 0.2s; }
.theme-btn:hover { transform: scale(1.1); }

/* --- Layout & Slider Tabs --- */
.wrap { max-width: 1280px; width: 100%; margin: 0 auto; padding: 30px 20px; flex: 1; }
.date-tabs-wrapper { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 15px auto 25px; width: 100%; max-width: 520px; }
.date-nav-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 50%; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; transition: all 0.2s; flex-shrink: 0; box-shadow: var(--shadow); }
body.dark .date-nav-btn { background: #1e293b; border-color: #334155; box-shadow: none; color: #94a3b8; }
.date-nav-btn:hover { background: var(--surface2); color: var(--primary); border-color: var(--primary); transform: scale(1.05); }
body.dark .date-nav-btn:hover { color: #4ade80; }

.tabs-container { position: relative; display: flex; gap: 4px; background: var(--surface); padding: 5px; border-radius: 999px; border: 1px solid var(--border); box-shadow: var(--shadow); flex: 1; overflow-x: auto; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x mandatory; margin: 0; direction: rtl; }
body.dark .tabs-container { background: #1e293b; border-color: #334155; box-shadow: none; }
.tabs-container::-webkit-scrollbar { display: none; }

.tab-btn { flex: 0 0 calc(33.333% - 2.66px); scroll-snap-align: center; padding: 10px 5px; border: none; background: transparent; color: var(--muted); font-size: 14px; font-weight: 800; cursor: pointer; border-radius: 999px; transition: all 0.2s ease; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.tab-btn:hover { color: var(--text); background: var(--surface2); }
body.dark .tab-btn:hover { color: #fff; background: #2d3748; }
.tab-btn.active { background: var(--primary); color: #ffffff; box-shadow: 0 3px 10px rgba(22, 163, 74, 0.3); }

.tab-content { display: none; animation: yallaTabFade 0.35s ease; }
.tab-content.active { display: block; }
@keyframes yallaTabFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- Advanced Global Controls: Live Switch & Custom Dropdown --- */
.controls-header { display: flex; flex-direction: column; align-items: center; gap: 15px; margin-bottom: 20px; width: 100%; }
.league-filters-wrap { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; flex-wrap: wrap; z-index: 50; position: relative; }

.live-toggle-switch { position: relative; display: inline-flex; align-items: center; width: 68px; height: 38px; flex-shrink: 0; cursor: pointer; }
.live-toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.live-switch-slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--surface2); border: 1px solid var(--border); border-radius: 34px; transition: .3s; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); }
body.dark .live-switch-slider { background-color: #1e293b; border-color: #334155; box-shadow: inset 0 1px 3px rgba(0,0,0,0.2); }
.live-switch-slider::before { content: ""; position: absolute; height: 30px; width: 30px; border-radius: 50%; background-color: var(--muted); right: 3px; bottom: 3px; transition: .3s; z-index: 2; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.live-switch-slider::after { content: "مباشر"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 900; color: var(--muted); transition: .3s; z-index: 1; letter-spacing: 0.5px; }
input:checked + .live-switch-slider { background-color: rgba(239, 68, 68, 0.1); border-color: #ef4444; }
input:checked + .live-switch-slider::before { transform: translateX(-32px); background-color: #ef4444; }
input:checked + .live-switch-slider::after { left: auto; right: 10px; color: #ef4444; }

.custom-dropdown { position: relative; min-width: 220px; max-width: 100%; }
.custom-dropdown-trigger { display: flex; align-items: center; justify-content: space-between; padding: 0 18px; height: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; color: var(--text); box-shadow: 0 2px 5px rgba(0,0,0,0.02); transition: all 0.2s ease; user-select: none; }
body.dark .custom-dropdown-trigger { background: #1e293b; border-color: #334155; color: #f8fafc; box-shadow: none; }
.custom-dropdown-trigger:hover { border-color: var(--primary); }

.selected-league-text { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selected-league-text img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }

.dropdown-arrow { transition: transform 0.3s ease; flex-shrink: 0; margin-right: 10px; margin-left: 0; color: var(--muted); }
body.dark .dropdown-arrow { color: #94a3b8; }
.custom-dropdown.open .dropdown-arrow { transform: rotate(180deg); color: var(--primary); }
.custom-dropdown.open .custom-dropdown-trigger { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1); }

.custom-dropdown-options { position: absolute; top: calc(100% + 8px); right: 0; left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); padding: 8px; z-index: 100; scrollbar-width: thin; }
.custom-dropdown.open .custom-dropdown-options { opacity: 1; visibility: visible; transform: translateY(0); }
body.dark .custom-dropdown-options { background: #1e293b; border-color: #334155; }

.custom-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; border-radius: 10px; transition: all 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.custom-option img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
body.dark .custom-option { color: #e2e8f0; }
.custom-option:hover { background: var(--surface2); color: var(--primary); }
body.dark .custom-option:hover { background: #334155; color: #4ade80; }
.custom-option.active { background: var(--primary) !important; color: #fff !important; }

.tz-dropdown .custom-dropdown-trigger { height: 34px; padding: 0 12px; font-size: 11.5px; font-weight: 800; border-radius: 8px; border: 1px solid rgba(22,163,74,.2); background: var(--primary-light); color: var(--primary-dark); }
body.dark .tz-dropdown .custom-dropdown-trigger { background: rgba(34,197,94,.15); color: #4ade80; border-color: rgba(34,197,94,.25); }
.tz-dropdown:hover .custom-dropdown-trigger { background: var(--primary); color: #fff; border-color: var(--primary); }
.tz-dropdown .custom-dropdown-options { width: 140px; left: 0; right: auto; top: calc(100% + 5px); }

/* --- Cards & Grid Layout --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 20px; align-items: stretch; position: relative; z-index: 10; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; display: flex; flex-direction: column; width: 100%; height: 100%; max-width: 100%; }
a.card:hover { transform: translateY(-6px); border-color: rgba(22,163,74,.4); box-shadow: var(--shadow-md); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--surface2); border-bottom: 1px solid var(--border); }
.league-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.league-img { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
.league-name { font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge { font-size: 11px; font-weight: 800; padding: 6px 12px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.badge-live { background: rgba(239,68,68,.12); color: #dc2626; border: 1px solid rgba(239,68,68,.18); }
.badge-live .dot { display: inline-block; width: 6px; height: 6px; background: #ef4444; border-radius: 50%; animation: blink 1.4s infinite; margin-left: 4px; }
.badge-upcoming { background: rgba(245,158,11,.12); color: #d97706; border: 1px solid rgba(245,158,11,.18); }
.badge-finished { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

.card-body { padding: 20px 14px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: flex-start; gap: 8px; width: 100%; }

/* 🚀 السماح للأعمدة بالتمدد للمنتصف وإلغاء حاجز الـ hidden */
.home-team, .away-team { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-width: 0; overflow: visible; width: 100%; }

.team-logo { width: 54px; height: 54px; object-fit: contain; background: #fff; padding: 6px; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-bottom: 8px; }
body.dark .team-logo { background: #334155; }
.team-name { font-size: 13.5px; font-weight: 800; text-align: center; color: var(--text); width: 100%; white-space: normal; word-wrap: break-word; line-height: 1.3; }

/* --- Live Score & Timers --- */
.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 5px; flex-shrink: 0; min-width: 75px; gap: 5px; }
.live-score-wrapper { display: flex; align-items: center; gap: 12px; }
.score-num { font-size: 26px; font-weight: 800; color: var(--text); min-width: 18px; text-align: center; }
body.dark .score-num { color: #fff; }
.circle-timer-wrap { position: relative; width: 68px; height: 68px; display: flex; align-items: center; justify-content: center; }
.circle-bg { stroke: #e2e8f0; } 
body.dark .circle-bg { stroke: #334155; }
.circle-progress { stroke: #16a34a; stroke-dasharray: 188.5; stroke-dashoffset: 188.5; transition: stroke-dashoffset 0.5s linear, stroke 0.3s ease; }
.card.finished .circle-progress { stroke: #94a3b8; } 
body.dark .card.finished .circle-progress { stroke: #475569; }
.circle-text { position: absolute; font-size: 14px; font-weight: 800; color: #16a34a; text-align: center; letter-spacing: -0.2px; transition: transform 0.2s ease; z-index: 2; }
.stoppage-text { position: absolute; font-size: 11.5px; font-weight: 800; color: #f97316; text-align: center; letter-spacing: -0.2px; margin-top: 14px; display: none; z-index: 2; }
.penalty-score { font-size: 11px; font-weight: 800; color: #ef4444; margin-top: 6px; background: rgba(239, 68, 68, 0.08); padding: 2px 8px; border-radius: 6px; display: inline-block; letter-spacing: 0.5px; text-align: center; }
body.dark .penalty-score { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

/* --- Upcoming Countdown --- */
.kick-time { font-size: 17px; font-weight: 900; color: var(--primary); margin-top: 4px; }
.kick-label { font-size: 10px; letter-spacing: .8px; color: var(--muted); }
.match-countdown { font-size: 11px; font-weight: 700; color: #16a34a; margin-top: 6px; background: rgba(22, 163, 74, 0.06); padding: 2px 10px; border-radius: 6px; display: inline-block; letter-spacing: 0.5px; text-align: center; direction: ltr; }
body.dark .match-countdown { background: rgba(34, 197, 94, 0.12); color: #4ade80; }

/* --- Scorers Dropdown --- */
.scorers-details { width: 100%; margin-top: 10px; position: relative; z-index: 5; display: flex; flex-direction: column; align-items: center; }
.scorers-details summary { display: inline-flex; align-items: center; justify-content: center; padding: 5px 12px 5px 26px; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface2); border-radius: 99px; cursor: pointer; user-select: none; list-style: none; transition: 0.2s ease; border: 1px solid transparent; white-space: nowrap; max-width: 100%; position: relative; }
.scorers-details summary::-webkit-details-marker{display:none;}
.scorers-details summary::after { content: ''; position: absolute; left: 10px; right: auto; top: 50%; transform: translateY(-50%); border-right: 4px solid transparent; border-left: 4px solid transparent; border-top: 5px solid currentColor; transition: transform 0.3s; }
.scorers-details[open] summary::after { transform: translateY(-50%) rotate(180deg); }
.scorers-details summary:hover { background: #e2e8f0; color: var(--text); }
body.dark .scorers-details summary { background: rgba(255,255,255,0.06); color: #94a3b8; }
body.dark .scorers-details summary:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* --- Scorers List (Layout & Alignment) --- */
.scorers-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; width: 100%; animation: slideDown 0.2s ease-out; }

/* 🚀 منع السطر الجديد وإعطاء حرية التمدد (Arabic RTL) مع إمكانية قص النص الطويل بنقاط */
.scorer-item { font-size: 10.5px; color: var(--muted); font-weight: 600; display: flex; gap: 5px; white-space: nowrap !important; line-height: 1.4; width: max-content; max-width: 140%; }
.s-icon { flex-shrink: 0; }
.s-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
body.dark .scorer-item { color: #cbd5e1; }

/* 🚀 Home Team (Right Side in RTL) */
.home-team .scorers-list { align-items: flex-start; padding-right: 6px; } 
.home-team .scorer-item { justify-content: flex-start; text-align: right; flex-direction: row; }

/* 🚀 Away Team (Left Side in RTL) */
.away-team .scorers-list { align-items: flex-end; padding-left: 6px; } 
.away-team .scorer-item { justify-content: flex-end; text-align: left; flex-direction: row-reverse; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* --- Footer, State & SEO Section --- */
.card-foot { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; font-size: 13px; font-weight: 800; margin-top: auto; }
.state { text-align: center; padding: 70px 20px; color: var(--muted); }
.state-icon { font-size: 52px; margin-bottom: 16px; }
.state h3 { font-size: 22px; font-weight: 900; color: var(--text); margin-bottom: 8px; }

.seo-section { background: var(--surface2); border-top: 1px solid var(--border); padding: 45px 22px; margin-top: auto; }
body.dark .seo-section { background: #0f172a; border-top: 1px solid #1e293b; }
.about-content { max-width: 1280px; margin: 0 auto; position: relative; }

.seo-content-container { position: relative; }
.seo-text-wrapper { max-height: 110px; overflow: hidden; transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1); position: relative; }
.seo-text-wrapper.expanded { max-height: 1500px; }

.seo-fade { position: absolute; bottom: 0; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, rgba(248,250,252,0), var(--surface2)); pointer-events: none; transition: opacity 0.4s ease; z-index: 2; }
body.dark .seo-fade { background: linear-gradient(to bottom, rgba(15,23,42,0), #0f172a); }
.seo-text-wrapper.expanded + .seo-fade { opacity: 0; visibility: hidden; }

.show-more-wrapper { text-align: center; margin-top: 15px; position: relative; z-index: 3; }
.show-more-btn { background: var(--surface); color: var(--primary-dark); border: 1px solid rgba(22,163,74,.3); padding: 8px 24px; border-radius: 999px; font-weight: 800; font-size: 13px; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 6px; font-family: inherit; box-shadow: var(--shadow); }
body.dark .show-more-btn { background: #1e293b; color: #4ade80; border-color: rgba(34, 197, 94, 0.3); }
.show-more-btn:hover { background: var(--primary); color: #fff; transform: translateY(-2px); border-color: var(--primary); }
.show-more-btn svg { transition: transform 0.3s ease; }
.show-more-btn.expanded svg { transform: rotate(180deg); }

.seo-text-wrapper h2 { font-size: 24px; font-weight: 900; color: var(--text); margin-bottom: 15px; letter-spacing: -0.5px; }
.seo-text-wrapper h3 { font-size: 18px; font-weight: 800; color: var(--text); margin-top: 25px; margin-bottom: 10px; }
.seo-text-wrapper p { font-size: 14.5px; line-height: 1.8; color: var(--muted); margin-bottom: 15px; }
.seo-text-wrapper strong { color: var(--text); font-weight: 800; }

footer { background: var(--surface); text-align: center; padding: 25px 20px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); }

.yalla-network-toast { position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%); background-color: #ef4444; color: #fff; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 700; box-shadow: 0 10px 25px rgba(0,0,0,.2); transition: bottom .4s cubic-bezier(0.68,-0.55,0.265,1.55), background-color .3s; z-index: 9999999; pointer-events: none; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.yalla-network-toast.show { bottom: 30px; }
.yalla-network-toast.online-mode { background-color: #10b981; }

/* --- Responsive Media Queries --- */
@media(max-width: 640px) {
  .nav { height: 64px; padding: 0 14px; }
  .nav-brand { font-size: 20px; }
  .grid { grid-template-columns: 1fr; }
  .date-tabs-wrapper { padding: 0 5px; gap: 8px; }
  .date-nav-btn { width: 38px; height: 38px; }
  .date-nav-btn svg { width: 16px; height: 16px; }
  .tab-btn { font-size: 13.5px; }
}

@media (max-width: 480px) {
  .nav { padding: 0 10px; gap: 8px; }
  .nav-brand { font-size: 18px; gap: 6px; }
  .nav-icon { width: 32px; height: 32px; font-size: 16px; }
  .theme-btn { width: 34px; height: 34px; font-size: 16px; }
  .card-body { padding: 16px 10px; }
  .teams { gap: 8px; }
  .team-logo { width: 42px; height: 42px; }
  .team-name { font-size: 12px; }
  .score-num { font-size: 22px; }
  .custom-dropdown { min-width: auto; flex-grow: 1; }
  .tz-dropdown .custom-dropdown-trigger { padding: 0 8px; font-size: 10.5px; }
}