:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --line: #e7ebf3;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --live: #e11d48;
  --win: #16a34a;
  --draw: #94a3b8;
  --loss: #e11d48;
  --home: #2563eb;
  --away: #f59e0b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);

  --gutter: 16px;
  --gap: 12px;
  --pad: 16px;
  --radius: 20px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
body.has-sticky { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { display: block; }
.app { max-width: 560px; margin: 0 auto; }
h3 { margin: 0; font-size: 16px; font-weight: 800; }

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .16), transparent 60%),
    linear-gradient(180deg, #14532d 0%, #166534 55%, #15803d 100%);
}
.pitch { position: absolute; inset: 0; opacity: .55; }
.pitch i { position: absolute; border: 1.5px solid rgba(255, 255, 255, .28); }
.pitch .halfway { top: 0; bottom: 0; left: 50%; border-width: 0 0 0 1.5px; }
.pitch .circle { width: 24%; aspect-ratio: 1; border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.player::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 50%;
  background: linear-gradient(to top, rgba(2, 44, 22, .7), transparent); pointer-events: none;
}

.stage { position: absolute; inset: 0; background: #000; display: none; z-index: 4; }
.stage.on { display: block; }
.stage video, .stage iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.player.playing::after, .player.playing .player-center, .player.playing .controls, .player.playing .progress { display: none; }

.player-top {
  position: absolute; top: var(--gap); left: var(--gutter); right: var(--gutter); z-index: 5;
  display: flex; justify-content: space-between; align-items: center; pointer-events: none;
}
.player-league { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 9px; padding: 4px; }
.badge-live {
  background: var(--live); color: #fff; font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 12px rgba(225, 29, 72, .35);
}
.badge-live i { width: 7px; height: 7px; background: #fff; border-radius: 50%; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.player-center { position: absolute; inset: 0; z-index: 2; }
.play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255, 255, 255, .2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .35);
  transition: transform .15s, background .2s;
}
.play svg { width: 24px; fill: #fff; margin-left: 3px; }
.play:active { transform: translate(-50%, -50%) scale(.94); }
.play.ready { background: var(--live); border-color: transparent; animation: pulse 2s infinite; }
.play.muted { opacity: .6; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, .5); }
  70% { box-shadow: 0 0 0 16px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}
.player-msg {
  position: absolute; top: calc(50% + 38px); left: 15%; right: 15%;
  font-size: 13px; color: rgba(255, 255, 255, .92); text-align: center; line-height: 1.5;
}
.player-msg b { display: block; font-size: 24px; font-weight: 800; letter-spacing: 1px; direction: ltr; color: #fff; line-height: 1.2; }

.controls {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: var(--gap); z-index: 3; direction: ltr;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums;
}
.icon { padding: 6px; margin: -6px; }
.icon svg { width: 20px; fill: none; stroke: #fff; stroke-width: 2; display: block; }
.icon .i-exit, .player.is-fs .icon .i-enter { display: none; }
.player.is-fs .icon .i-exit { display: block; }
.fs-float { display: none; position: absolute; top: var(--gap); left: var(--gutter); z-index: 6; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .25); place-items: center; padding: 0; }
.fs-float svg { width: 20px; fill: none; stroke: #fff; stroke-width: 2; display: block; }
.fs-float .i-exit, .player.is-fs .fs-float .i-enter { display: none; }
.player.is-fs .fs-float .i-exit { display: block; }
.player.playing .fs-float { display: grid; }
.player.playing .player-league { display: none; }
.player.is-fs .fs-float { display: none; }

.player:fullscreen { aspect-ratio: auto; width: 100%; height: 100%; }
.player:-webkit-full-screen { aspect-ratio: auto; width: 100%; height: 100%; }
.player.fs-fill, .player.fs-rotate, .player.fs-rotate-ccw { position: fixed; z-index: 100; top: 0; left: 0; aspect-ratio: auto; margin: 0; }
body.fs-lock { background: #000; }
body.fs-lock::before { content: ""; position: fixed; inset: -50vh -50vw; background: #000; z-index: 99; }
.player.fs-fill { top: var(--fs-top, 0px); left: var(--fs-left, 0px); width: var(--fs-w, 100vw); height: var(--fs-h, 100vh); }
.player.fs-rotate {
  width: var(--fs-rot-h, 100vh); height: var(--app-w, 100vw);
  transform-origin: top left; transform: translate(var(--app-w, 100vw), var(--fs-top, 0px)) rotate(90deg);
}
.player.fs-rotate-ccw {
  width: var(--fs-rot-h, 100vh); height: var(--app-w, 100vw);
  transform-origin: top left; transform: translateY(calc(var(--fs-top, 0px) + var(--fs-rot-h, 100vh))) rotate(-90deg);
}
.player.is-fs .controls { bottom: max(var(--gap), env(safe-area-inset-bottom)); left: max(var(--gutter), env(safe-area-inset-left)); right: max(var(--gutter), env(safe-area-inset-right)); }
.player.is-fs .player-msg b { font-size: 32px; }
body.fs-lock { overflow: hidden; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .2); z-index: 3; direction: ltr; }
.progress span { display: block; height: 100%; width: 0; background: var(--live); transition: width .8s; }

.scoreboard {
  position: relative; z-index: 6;
  margin: var(--gap) var(--gutter) 0; padding: var(--pad);
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.sb-league { display: flex; justify-content: center; align-items: center; font-size: 13px; color: var(--muted); min-height: 20px; text-align: center; }
.sb-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--gap); margin-top: var(--gap); }
.team { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.crest {
  width: 60px; height: 60px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line);
}
.crest img { width: 70%; height: 70%; object-fit: contain; }
.team .name { font-size: 15px; font-weight: 700; text-align: center; line-height: 1.35; overflow-wrap: anywhere; }
.sb-center { text-align: center; min-width: 100px; }
.result { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 36px; font-weight: 800; line-height: 1.1; }
.result i { font-style: normal; color: var(--faint); font-size: 26px; }
.result .vs { font-size: 20px; color: var(--faint); font-weight: 700; }
.result.flash span { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { color: var(--win); transform: scale(1.15); } }
.status {
  display: inline-block; margin-top: 6px; padding: 2px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted);
}
.status.live { background: #ffe4e9; color: var(--live); }
.status .clk-min { font-variant-numeric: tabular-nums; }
.status .clk-tick { display: inline-block; margin-inline-start: 1px; animation: clk-blink 1.2s ease-in-out infinite; }
@keyframes clk-blink { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .status .clk-tick { animation: none; } }
.status.ft { background: var(--surface-2); color: var(--muted); }

.scorers {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
  margin-top: var(--gap); padding-top: var(--gap); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.scorers ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.scorers li { direction: ltr; unicode-bidi: isolate; }
.sc-home li { text-align: right; }
.sc-away li { text-align: left; }

.tabs {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  margin-top: var(--gap); padding: 8px var(--gutter);
  background: rgba(244, 246, 251, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tabs button {
  padding: 9px 4px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
}
.tabs button.on { background: var(--surface); color: var(--brand, var(--text)); box-shadow: var(--shadow); }
.panel { display: none; padding: 4px var(--gutter) 0; animation: fade .25s ease; }
.panel.on { display: flex; flex-direction: column; gap: var(--gap); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: var(--surface); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--pad); gap: 8px; }
.hint { font-size: 12px; color: var(--faint); }
.link { font-size: 13px; color: var(--brand, var(--home)); font-weight: 700; }
.empty { color: var(--muted); font-size: 14px; text-align: center; margin: 0; line-height: 1.7; }
p.card.empty { padding: 28px var(--pad); }

.prob-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 4px; }
.prob-bar span { display: block; height: 100%; border-radius: 999px; transition: flex-basis .6s; min-width: 6px; }
.prob-legend { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: var(--gap); text-align: center; }
.prob-legend div { display: flex; flex-direction: column; gap: 2px; }
.prob-legend b { font-size: 20px; font-weight: 800; }
.prob-legend small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stat { padding: 10px 0; }
.stat:first-child { padding-top: 0; }
.stat:last-child { padding-bottom: 0; }
.stat + .stat { border-top: 1px solid var(--line); }
.stat-top { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; direction: ltr; font-size: 15px; }
.stat-top .v { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--faint); }
.stat-top .v.lead { color: var(--text); }
.stat-top .v.a { text-align: left; }
.stat-top .v.h { text-align: right; }
.stat-top .lbl { text-align: center; font-size: 13px; color: var(--muted); direction: rtl; }
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; direction: ltr; margin-top: 8px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; display: flex; overflow: hidden; }
.bar.a { justify-content: flex-end; }
.bar i { display: block; height: 100%; border-radius: 999px; transition: width .6s; opacity: .35; }
.bar.a i { background: var(--away); }
.bar.h i { background: var(--home); }
.bar i.lead { opacity: 1; }
.legend-teams { display: flex; justify-content: space-between; direction: ltr; font-size: 13px; font-weight: 700; margin-bottom: var(--gap); }
.legend-teams span { display: inline-flex; align-items: center; gap: 6px; }
.legend-teams span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--away); }
.legend-teams span.h { flex-direction: row-reverse; }
.legend-teams span.h::before { background: var(--home); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; display: flex; flex-direction: column; gap: 6px; }
.timeline::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 50%; width: 2px; margin-left: -1px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 1fr 48px 1fr; align-items: center; min-height: 44px; position: relative; }
.timeline .min {
  grid-column: 2; justify-self: center; z-index: 1;
  font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; direction: ltr; font-variant-numeric: tabular-nums;
}
.timeline .ev { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 1.35; min-width: 0; }
.timeline .ev small { display: block; color: var(--muted); font-size: 12px; }
.timeline li.home .ev { grid-column: 1; grid-row: 1; padding-left: 10px; }
.timeline li.away .ev { grid-column: 3; grid-row: 1; flex-direction: row-reverse; text-align: left; padding-right: 10px; }
.ico { flex: none; width: 22px; text-align: center; font-size: 15px; }
.card-y, .card-r { display: inline-block; width: 11px; height: 15px; border-radius: 2px; vertical-align: middle; }
.card-y { background: #facc15; } .card-r { background: var(--live); }
.sub-ico { color: var(--win); font-weight: 800; }

.info { margin: 0; display: flex; flex-direction: column; }
.info div { display: flex; justify-content: space-between; gap: var(--gap); font-size: 14px; padding: 10px 0; }
.info div:first-child { padding-top: 0; }
.info div:last-child { padding-bottom: 0; }
.info div + div { border-top: 1px solid var(--line); }
.info dt { color: var(--muted); flex: none; }
.info dd { margin: 0; font-weight: 700; text-align: left; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.seg button { padding: 9px; border-radius: 10px; font-size: 14px; font-weight: 700; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; }
.seg button img { width: 20px; height: 20px; object-fit: contain; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.lineup-head { display: flex; justify-content: space-between; align-items: center; gap: var(--gap); padding-bottom: var(--gap); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.lineup-head b { color: var(--text); font-size: 16px; direction: ltr; unicode-bidi: isolate; }
.pos-title { font-size: 12px; color: var(--faint); font-weight: 700; margin: var(--pad) 0 6px; }
.player-row { display: flex; align-items: center; gap: var(--gap); padding: 6px 0; font-size: 14px; direction: ltr; justify-content: flex-end; }
.player-row .num {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--home); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.subs-toggle { margin-top: var(--pad); width: 100%; padding: 11px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; font-weight: 700; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 14px; padding: var(--gap) 6px; text-align: center; }
.tile b { display: block; font-size: 24px; font-weight: 800; line-height: 1.2; }
.tile small { font-size: 12px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.h b { color: var(--home); } .tile.a b { color: var(--away); } .tile.d b { color: var(--draw); }
.meetings { list-style: none; margin: var(--gap) 0 0; padding: 0; }
.meetings li { padding: var(--gap) 0; border-top: 1px solid var(--line); }
.meetings li:last-child { padding-bottom: 0; }
.meet-meta { font-size: 12px; color: var(--faint); text-align: center; margin-bottom: 6px; }
.meet-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--gap); font-size: 14px; }
.meet-row .t { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; }
.meet-row .t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-row .t.r { flex-direction: row-reverse; }
.meet-row img { width: 22px; height: 22px; object-fit: contain; flex: none; }
.meet-row .sc { display: flex; gap: 6px; font-weight: 800; background: var(--surface-2); border-radius: 10px; padding: 3px 12px; font-variant-numeric: tabular-nums; }
.meet-row .sc i { font-style: normal; color: var(--faint); }
.form-row { display: flex; justify-content: space-between; align-items: center; padding: var(--gap) 0; gap: var(--gap); }
.form-row:first-child { padding-top: 0; }
.form-row:last-child { padding-bottom: 0; }
.form-row + .form-row { border-top: 1px solid var(--line); }
.form-row .who { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; min-width: 0; }
.form-row .who img { width: 26px; height: 26px; object-fit: contain; }
.chips { display: flex; gap: 4px; direction: ltr; }
.chip { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.chip.W { background: var(--win); } .chip.D { background: var(--draw); } .chip.L { background: var(--loss); }
.form-meta { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 400; }

.ad { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.tag {
  font-size: 11px; color: var(--muted); background: var(--surface-2);
  padding: 0 8px; border-radius: 6px; display: inline-block; font-weight: 500; line-height: 1.7;
}
.ad > .tag {
  position: absolute; bottom: 6px; left: 6px; z-index: 1;
  font-size: 9px; line-height: 1.6; padding: 0 5px; border-radius: 5px;
  background: rgba(15, 23, 42, .28); color: rgba(255, 255, 255, .9); font-weight: 500;
}
.sticky > .tag { left: auto; right: 6px; }
.ad.placeholder > .tag { background: var(--surface-2); color: var(--muted); font-size: 11px; padding: 0 8px; }
.ad img { width: 100%; height: 100%; object-fit: cover; }
.ad.clickable { cursor: pointer; }
.ad.placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--faint); font-size: 13px; background: var(--surface); border: 1px dashed var(--line); box-shadow: none;
}
.ad.placeholder > .tag { position: static; }
.banner { aspect-ratio: 16 / 5; }
.ad-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.ad-row .ad { aspect-ratio: 4 / 3; }
.ad-row:not(:has(.ad:not([hidden]))) { display: none; }
.native { display: flex; align-items: center; gap: var(--gap); padding: var(--gap); }
.native .thumb { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2) center / cover no-repeat; flex: none; }
.native .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.native .title { font-size: 15px; font-weight: 700; }
.native .desc { color: var(--muted); font-size: 12px; line-height: 1.5; }
.native .cta { background: var(--brand, var(--home)); color: #fff; font-weight: 700; font-size: 13px; padding: 7px 16px; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; text-align: center; align-self: center; line-height: 1.3; }
.sticky {
  position: fixed; z-index: 30; left: var(--gutter); right: var(--gutter); bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 528px; height: 56px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .15); animation: rise .35s ease;
}
@keyframes rise { from { transform: translateY(120%); } }
.sticky .close {
  position: absolute; top: 50%; left: 10px; transform: translateY(-50%); z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--muted);
  font-size: 16px; line-height: 26px; text-align: center;
}
.sticky.placeholder { flex-direction: row; background: var(--surface); border-style: solid; }

.updated { text-align: center; color: var(--faint); font-size: 12px; margin: var(--pad) 0 0; }
.updated:empty { display: none; }
.toast {
  position: fixed; z-index: 40; top: var(--gap); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 8px 18px; border-radius: 12px; font-size: 14px; font-weight: 700; white-space: nowrap; box-shadow: 0 8px 24px rgba(15, 23, 42, .2);
  animation: drop .25s ease;
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }
.error { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 24px; text-align: center; color: var(--muted); z-index: 50; line-height: 1.8; }

.sk { display: inline-block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, #e5e9f2 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.sk-line { width: 80px; height: 12px; }
.sk-score { width: 90px; height: 32px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
