:root {
  --bg: #0a0e1a;
  --bg2: #11172b;
  --card: #161e35;
  --card2: #1c2542;
  --line: #263056;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #e63946;
  --green: #22c55e;
  --gold: #f5b301;
  --blue: #3b82f6;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: radial-gradient(1200px 600px at 20% -10%, #1b2450 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  min-height: 100vh;
}
.topbar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  background: rgba(10,14,26,.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.ball { font-size: 34px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: #2a0d12; border: 1px solid #7f1d1d; color: #fca5a5;
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 13px;
}
.live-badge .dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(.8);} }
.hidden { display: none !important; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.controls label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 4px; text-transform: uppercase; letter-spacing: .6px;}
select, input[type="search"], button {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 14px; outline: none;
}
select:focus, input:focus, button:focus { border-color: var(--blue); }
button { cursor: pointer; font-weight: 600; }
button:hover { background: var(--card2); }
#refreshBtn { border-color: var(--blue); }
#notifyBtn { min-width: 120px; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  padding: 14px 20px 4px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters button { border-radius: 999px; padding: 7px 14px; }
.filters button.active { background: var(--blue); border-color: var(--blue); color: white; }
.filters button span { opacity: .8; font-weight: 400; margin-left: 4px; }
.fav-only { color: var(--muted); font-size: 14px; display: flex; gap: 6px; align-items: center; margin-left: 6px;}
.search-row { display: flex; gap: 8px; }
.search-row input { min-width: 240px; }

.statusline {
  display: flex; gap: 12px; padding: 6px 20px; color: var(--muted); font-size: 13px;
}

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px; padding: 12px 20px 30px;
}
.card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  cursor: pointer; transition: transform .12s, border-color .12s;
  position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-2px); border-color: #3b4a85; }
.card.fav { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.card.flash { animation: flash 1.6s; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--gold);} 100% { box-shadow: none; } }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 12px; color: var(--muted);}
.status { font-weight: 800; letter-spacing: .5px; padding: 4px 10px; border-radius: 999px; font-size: 12px;}
.status.live { background: #ef4444; color: white; animation: pulse 1.6s infinite; }
.status.final { background: #2b3352; color: #c6ccea; }
.status.pre { background: #12325e; color: #9ec1ff; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 10px; }
.team-row.winner { background: rgba(34,197,94,.09); }
.team-row img { width: 40px; height: 40px; object-fit: contain; }
.team-row .names { flex: 1; min-width: 0;}
.team-row .abbr { font-weight: 800; font-size: 16px; display: flex; gap: 6px; align-items: center;}
.team-row .full { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.team-row .rec { font-size: 11px; color: var(--muted); }
.score { font-size: 26px; font-weight: 800; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums;}
.poss { color: var(--gold); font-size: 13px; }
.meta { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.45;}
.lastplay { background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; font-size: 12.5px;}
.winbar { height: 7px; border-radius: 99px; background: #2a3358; overflow: hidden; margin-top: 10px; display: flex;}
.winbar div { height: 100%; }
.winlabel { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px;}
.card-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; color: var(--muted);}

.empty, .error {
  margin: 20px; padding: 22px; border-radius: 14px; text-align: center;
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
}
.error { border-color: var(--accent); color: #ffb4b4; }
.error button { margin-top: 10px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50;}
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; max-width: 640px; width: 100%; max-height: 88vh; overflow: auto; padding: 20px; position: relative;}
.modal-close { position: absolute; right: 12px; top: 12px; border-radius: 50%; }
.leader { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px;}
.leader img { width: 44px; height: 44px; border-radius: 50%; background: #0b1022; }
.leader small { color: var(--muted); display: block; }

footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 16px 20px 28px; color: var(--muted); font-size: 12.5px;}
footer a { color: #9ec1ff; }

@media (max-width: 640px) {
  .search-row { width: 100%; }
  .search-row input { flex: 1; min-width: 0;}
}
