/* Layout: scoreboard-style list on the right (RTL), sticky match detail panel on the left on desktop; on phones the detail opens as a full-screen sheet. */
:root {
  --bg: #07130e;
  --surface: #0e1f18;
  --surface-2: #153027;
  --line: #24453a;
  --fg: #eefaf3;
  --muted: #8db3a1;
  --live: #ff4d2e;
  --accent: #2ee08f;
  --on-accent: #04170d;
  --gold-ink: #ffc83d;
  --gold: #ffc83d;
  --pitch-a: #138a5b;
  --pitch-b: #0f7a4f;
  --font-display: "Lalezar", "Tajawal", system-ui, sans-serif;
  --font-body: "Tajawal", system-ui, sans-serif;
  --font-num: "Barlow Condensed", "Tajawal", system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef6f1; --surface: #ffffff; --surface-2: #e0efe7; --line: #c6ddd0;
    --fg: #0b1f16; --muted: #4b6a5a; --live: #e23a1b; --accent: #0a8a4f; --on-accent: #ffffff; --gold-ink: #b36f00; --gold: #f2b705;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef6f1; --surface: #ffffff; --surface-2: #e0efe7; --line: #c6ddd0;
  --fg: #0b1f16; --muted: #4b6a5a; --live: #e23a1b; --accent: #0a8a4f; --on-accent: #ffffff; --gold-ink: #b36f00; --gold: #f2b705;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-block: 0 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: .02em; }

.wrap { max-width: 1080px; margin: 0 auto; }

/* Header */
.top { display: flex; flex-direction: row-reverse; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 18px 6px; }
.logo { display: flex; align-items: center; gap: 10px; direction: ltr; }
.logo-mark { width: 48px; height: 48px; flex: none; }
.logo-name { font-family: var(--font-num); font-weight: 700; font-size: 30px; line-height: 1; letter-spacing: .01em; direction: ltr; }
.logo-name { display: flex; align-items: center; gap: 6px; }
.logo-name .wm { color: var(--accent); }
.logo-name .wm span { color: var(--gold-ink); }
.ball { width: 24px; height: 24px; flex: none; color: #0b1f16; transform: translateY(1px); }
.logo-sub { font-size: 12px; color: var(--muted); direction: ltr; text-align: left; }
.live-count { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }

.demo-note { margin-block: 10px 0; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px; }

h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 7vw, 60px); line-height: 1.1; margin: 20px 0 6px; text-wrap: balance; }
h1 em { font-style: normal; color: var(--accent); }
.lead { margin: 0 0 18px; color: var(--muted); max-width: 60ch; }

/* Filters */
.sports, .days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.chip { flex: none; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; white-space: nowrap; }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.live-chip[aria-pressed="true"] { background: var(--live); border-color: var(--live); color: #fff; }
.days { margin-block: 6px 16px; }
.day { flex: none; min-width: 74px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: center; line-height: 1.25; }
.day small { display: block; color: var(--muted); font-size: 12px; }
.day[aria-selected="true"] { background: var(--surface-2); border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }

/* Main grid */
.main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 900px) { .main { grid-template-columns: minmax(0, 1fr) 400px; } }

.league { margin-bottom: 18px; }
.league h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 14px; font-weight: 800; color: var(--muted); text-transform: none; letter-spacing: .02em; }
.league h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.rows { display: flex; flex-direction: column; gap: 6px; }
.match { display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; text-align: start; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.match:hover { border-color: var(--accent); }
.match[aria-current="true"] { border-color: var(--accent); background: var(--surface-2); }
.state { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.state .big { font-family: var(--font-num); font-weight: 700; font-size: 20px; color: var(--fg); line-height: 1.1; }
.pill-live { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; background: var(--live); color: #fff; font-size: 12px; font-weight: 800; }
.pill-live .dot { background: #fff; width: 6px; height: 6px; animation: none; }
.live-min { color: var(--live); font-family: var(--font-num); font-weight: 700; font-size: 16px; }
.teams { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.team { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.team .tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.team .sc { font-family: var(--font-num); font-weight: 700; font-size: 22px; min-width: 24px; text-align: end; }
.team.win .tn { font-weight: 800; }
.team.lose .sc { color: var(--muted); }
.badge { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: hsl(var(--h) 62% 40%); }
.sub { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -2px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

/* Detail panel */
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.detail-empty { color: var(--muted); text-align: center; padding: 40px 12px; }
@media (min-width: 900px) { .detail { position: sticky; top: 16px; } .close { display: none; } }
@media (max-width: 899px) {
  .detail { display: none; }
  .detail.open {
    display: block; position: fixed; inset: 0; z-index: 20; overflow-y: auto; border-radius: 0; border: 0; background: var(--bg);
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}
.close { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; margin-bottom: 12px; }
.d-league { font-size: 13px; color: var(--muted); text-align: center; }
.board { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; margin: 12px 0 14px; text-align: center; }
.board .badge { width: 52px; height: 52px; font-size: 22px; margin: 0 auto 6px; }
.board .tn { font-weight: 800; line-height: 1.25; text-wrap: balance; }
.score { font-family: var(--font-num); font-weight: 700; font-size: 52px; line-height: 1; white-space: nowrap; }
.score .sep { color: var(--muted); padding-inline: 6px; }
.d-state { text-align: center; margin-top: 6px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { flex: 1; padding: 10px 6px; background: none; border: 0; border-bottom: 3px solid transparent; font-weight: 700; color: var(--muted); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--live); }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ev { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.ev .m { font-family: var(--font-num); font-weight: 700; font-size: 17px; color: var(--muted); text-align: center; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; }
.tag i { width: 10px; height: 14px; border-radius: 2px; display: inline-block; }
.tag i.goal { width: 12px; height: 12px; border-radius: 50%; background: var(--fg); box-shadow: inset 0 0 0 3px var(--bg); outline: 2px solid var(--fg); }
.tag i.yellow { background: var(--gold); }
.tag i.red { background: var(--live); }
.tag i.sub { background: var(--accent); }
.tag i.note { background: var(--muted); }
.ev .who { color: var(--muted); font-size: 13px; }

.pitch-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.pitch-head .fm { color: var(--muted); font-family: var(--font-num); font-size: 15px; }
.pitch { position: relative; width: 100%; max-width: 380px; margin: 0 auto; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: repeating-linear-gradient(0deg, var(--pitch-a) 0 12.5%, var(--pitch-b) 12.5% 25%); }
.pitch svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pl { position: absolute; transform: translate(-50%, -50%); width: 64px; text-align: center; color: #fff; }
.pl b { display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; font-family: var(--font-num); font-size: 15px; box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.pl.h b { background: #ffffff; color: #0b1f16; }
.pl.a b { background: #ff4d2e; }
.pl span { display: block; font-size: 11px; font-weight: 700; line-height: 1.15; text-shadow: 0 1px 2px rgba(0,0,0,.6); margin-top: 2px; }
.no-lineup { padding: 24px 12px; text-align: center; color: var(--muted); }

.stream { aspect-ratio: 16 / 9; border-radius: 12px; display: grid; place-items: center; text-align: center; padding: 16px; background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, var(--bg) 14px 28px); border: 1px dashed var(--line); }
.stream strong { display: block; font-size: 17px; }
.stream p { margin: 6px 0 0; color: var(--muted); font-size: 13px; max-width: 34ch; }
.stream-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.foot { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; max-width: 70ch; }

@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
