/* Benfica.live v1.2.3 - palette and type from slbenfica.org (portal.css), dark first. */
:root {
  --red: #e2001a;
  --red-dark: #b5001a;
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bebas Neue', 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
[data-theme="dark"] {
  --bg: #141416;
  --bg-card: #1c1c1f;
  --bg-elevated: #28282c;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);
  --text: #d4d4d4;
  --text-muted: #8f8f8f;
  --text-bright: #ffffff;
  --red-text: #ff4d5e;
  --yellow: #f5c518;
  --green: #3fb950;
  --shadow: 0 4px 24px rgba(0,0,0,0.45);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f0f0f0;
  --bg-card: #ffffff;
  --bg-elevated: #ececec;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);
  --text: #333333;
  --text-muted: #6b6b6b;
  --text-bright: #111111;
  --red-text: #c40015;
  --yellow: #d9a800;
  --green: #15662d;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  transition: background .3s ease, color .3s ease;
}
a { color: var(--red-text); }
h1, h2, h3 { margin: 0; color: var(--text-bright); font-weight: 700; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 44px; height: auto; display: block; }
.brand-name { font: 400 30px/1 var(--display); letter-spacing: .5px; color: var(--text-bright); }
.brand-name span { color: var(--red-text); }
.theme-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-card); border: 1px solid var(--border-strong);
  color: var(--text-bright); cursor: pointer;
}
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn .i-moon { fill: currentColor; stroke: none; }
[data-theme="dark"] .i-sun, [data-theme="light"] .i-moon { display: none; }
.theme-btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }

.demo-bar {
  max-width: 760px; margin: 0 auto 4px; padding: 8px 16px;
  font-size: 13px; color: var(--text-muted);
}
.demo-bar a { margin-left: 8px; }
.demo-bar a[aria-current] { color: var(--text-bright); font-weight: 700; text-decoration: none; }

/* ---------- replay controls (preview) ---------- */
.replay {
  position: sticky; top: 64px; z-index: 4;
  max-width: 728px; margin: 0 auto 10px; padding: 12px 14px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
@media (max-width: 760px) { .replay { margin: 0 16px 10px; } }
.replay-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rp-btn {
  font: 600 13px var(--font); color: var(--text-bright); cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px;
}
#rp-play { background: var(--red); border-color: var(--red); color: #fff; min-width: 92px; }
.rp-btn[aria-pressed="true"] { border-color: var(--red-text); color: var(--red-text); }
.rp-clock { font: 500 16px var(--mono); color: var(--text-bright); margin-right: auto; }
.rp-speed { display: flex; gap: 6px; }
#rp-range { width: 100%; margin: 12px 0 6px; accent-color: var(--red); }
.rp-jumps { font-size: 13px; color: var(--text-muted); }
.rp-link { font: inherit; background: none; border: 0; padding: 2px 4px; color: var(--red-text); text-decoration: underline; cursor: pointer; }
.rp-btn:focus-visible, .rp-link:focus-visible, #rp-range:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 16px; display: grid; gap: 14px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
main.enter .card { animation: rise .35s ease both; }   /* first paint only, not on refreshes */
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); margin-bottom: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.empty { margin: 0; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.notice { border-color: var(--red); color: var(--text-bright); }
.quiet h1 { font-size: 22px; margin-bottom: 6px; }
.quiet p { margin: 0; color: var(--text-muted); }

/* ---------- scoreboard ---------- */
.board { border-top: 3px solid var(--red); padding-top: 16px; }
.board-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.comp { font-size: 14px; font-weight: 600; color: var(--text); }
.chip {
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: var(--bg-elevated); color: var(--text-muted); white-space: nowrap;
}
.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 6px; font-size: 14px; }
.status-label { color: var(--text-muted); }
.status-label.strong { color: var(--text-bright); font-weight: 600; }
.live-word { color: var(--red-text); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.minute { font: 500 15px var(--mono); color: var(--text-bright); }
.live-dot, .pause-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.live-dot { animation: pulse 1.6s ease-in-out infinite; }
.pause-dot { background: var(--text-muted); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(226,0,26,.55); } 50% { box-shadow: 0 0 0 7px rgba(226,0,26,0); } }

.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; margin-top: 8px; }
.side { min-width: 0; }
.side.home { text-align: right; }
.side.away { text-align: left; }
.team-name { display: block; font-weight: 700; font-size: 19px; line-height: 1.25; color: var(--text-bright); overflow-wrap: anywhere; padding-top: 14px; }
.team-name.is-benfica { color: var(--red-text); }
.score {
  font: 400 64px/1 var(--display); color: var(--text-bright);
  display: flex; gap: 10px; align-items: center; letter-spacing: 1px;
  padding: 0 4px; border-radius: var(--radius-sm);
}
.score .sep { color: var(--text-muted); }
.score .vs { font-size: 40px; color: var(--text-muted); padding-top: 8px; }
.score.flash { animation: flash 1.6s ease 2; }
@keyframes flash { 0%, 100% { background: transparent; } 40% { background: rgba(226,0,26,.28); } }
.score.small { font-size: 40px; }
.nowrap { white-space: nowrap; }
.scorers { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.board-extra, .meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.board-extra { color: var(--text); }
.nodata { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-elevated); font-size: 14px; color: var(--text); }
.nodata strong { color: var(--text-bright); }
.fresh { margin: -6px 0 0; text-align: center; font-size: 12px; color: var(--text-muted); }
.fresh.stale { color: var(--red-text); }

/* ---------- events ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.period {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); padding: 10px 0 6px; border-top: 1px solid var(--border);
}
.timeline .period:first-child { border-top: 0; padding-top: 0; }
.ev { display: grid; grid-template-columns: 52px 26px 1fr; align-items: start; gap: 10px; padding: 9px 0; }
.ev + .ev { border-top: 1px dashed var(--border); }
.ev-min { font: 500 14px/1.6 var(--mono); color: var(--text-bright); text-align: right; }
.ev-title { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-weight: 600; color: var(--text-bright); }
.ev-team { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.ev-line { font-size: 14px; }
.ev-line.in::before, .ev-line.out::before { display: inline-block; width: 16px; font-weight: 700; }
.ev-line.in::before { content: '\2191'; color: var(--green); }
.ev-line.out::before { content: '\2193'; color: var(--red-text); }
.ev-icon { width: 22px; height: 22px; margin-top: 1px; display: grid; place-items: center; font: 700 9px var(--font); color: var(--text-muted); }
/* goal: a ball drawn in CSS */
.ev-goal .ev-icon, .ev-penalty_goal .ev-icon, .ev-own_goal .ev-icon, .ev-shootout_goal .ev-icon {
  border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--text-bright) 0 28%, transparent 30%), var(--bg-elevated);
  border: 2px solid var(--text-bright);
}
.ev-own_goal .ev-icon { border-color: var(--red-text); }
.ev-goal .ev-title > span:first-child, .ev-penalty_goal .ev-title > span:first-child { color: var(--red-text); }
.ev-missed_penalty .ev-icon, .ev-shootout_miss .ev-icon { border-radius: 50%; border: 2px dashed var(--text-muted); }
.ev-yellow .ev-icon::before, .ev-red .ev-icon::before, .ev-second_yellow .ev-icon::before {
  content: ''; width: 12px; height: 17px; border-radius: 2px; background: var(--yellow);
}
.ev-red .ev-icon::before { background: var(--red); }
.ev-second_yellow .ev-icon::before { background: linear-gradient(135deg, var(--yellow) 50%, var(--red) 50%); }
.ev-sub .ev-icon::before { content: '\21C5'; font-size: 17px; color: var(--text-muted); }
.ev-var .ev-icon { border: 1px solid var(--border-strong); border-radius: 4px; width: 26px; }

/* ---------- lineups ---------- */
.lineups { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lineup h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.lineup h3 .team-name { padding: 0; font-size: 16px; }
.formation { font: 500 13px var(--mono); color: var(--text-muted); }
.players { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; }
.players li { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; padding: 5px 0; align-items: baseline; }
.num { font: 500 13px var(--mono); color: var(--text-muted); text-align: right; }
.pname { color: var(--text-bright); overflow-wrap: anywhere; }
.pos { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.subs { margin-top: 8px; }
.subs summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); padding: 6px 0; }
.coach { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }

/* ---------- statistics ---------- */
.stats-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.stats-head .team-name { padding: 0; font-size: 14px; }
.stats { list-style: none; margin: 0; padding: 0; }
.stats li { padding: 7px 0; }
.stat-row { display: grid; grid-template-columns: 60px 1fr 60px; font-size: 14px; }
.stat-row .v { font: 500 14px var(--mono); color: var(--text-bright); }
.stat-row .v:last-child { text-align: right; }
.stat-row .l { text-align: center; color: var(--text-muted); font-size: 13px; }
.bar { display: flex; gap: 3px; height: 5px; margin-top: 5px; }
.bar span { display: block; height: 100%; border-radius: 3px; background: var(--border-strong); transition: width .6s ease; }
.bar .is-benfica { background: var(--red); }

/* ---------- footer ---------- */
.foot { max-width: 760px; margin: 8px auto 0; padding: 8px 16px 32px; font-size: 13px; color: var(--text-muted); text-align: center; }
.foot p { margin: 4px 0; }
.ver { font-family: var(--mono); font-size: 12px; }

@media (max-width: 560px) {
  .score { font-size: 52px; gap: 6px; }
  .team-name { font-size: 16px; padding-top: 10px; }
  .lineups { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 44px 24px 1fr; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
