:root {
  /* Цвета СКА Стрельна (из логотипа) */
  --ska-blue: #004a87;
  --ska-blue-dark: #00305a;
  --ska-red: #d2121b;
  --ska-white: #ffffff;

  --bg: #04101f;
  --bg2: #071a31;
  --card: #0a1f3b;
  --card2: #0f2a4f;
  --line: #1a3a66;
  --text: #eaf1fb;
  --muted: #8fa6c6;
  --accent: var(--ska-blue);
  --accent2: #5ea6f2;
  --red: #ef4444;
  --green: #22c55e;
  --amber: #f59e0b;
  --fav: var(--ska-red);
  --fav-soft: #ff5a62;
  --fav-bg: rgba(210, 18, 27, 0.14);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef3fa; --bg2: #e3ebf6; --card: #ffffff; --card2: #f1f5fb; --line: #d6e0ee;
    --text: #06203f; --muted: #50668a; --accent2: var(--ska-blue); --fav-soft: var(--ska-red); --fav-bg: rgba(210, 18, 27, 0.07);
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'PT Sans', sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(0,74,135,.35), transparent 60%),
              radial-gradient(900px 500px at 110% 0%, rgba(210,18,27,.14), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px max(16px, env(safe-area-inset-left)) 10px; max-width: 1240px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.pill b { color: var(--text); font-weight: 600; }
.pill .led { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.pill .led.err { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.pill .led.busy { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; font-weight: 600; font-size: 13px; transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .6; cursor: default; }

/* Tabs */
.tabs {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px max(16px, calc((100vw - 1240px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 0 var(--ska-white), 0 3px 0 0 var(--ska-blue), 0 5px 0 0 var(--ska-red);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; white-space: nowrap; font-size: 14px;
}
.tabs a:hover { background: var(--card); text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--ska-blue); color: #fff; box-shadow: inset 0 -3px 0 var(--ska-red); }
.tabs .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fav); position: absolute; top: 6px; right: 6px; }

.view { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 16px 30px; }

.loading { display: grid; place-items: center; gap: 12px; padding: 80px 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 960px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 .muted { font-weight: 500; font-size: 12.5px; }
.section-title { font-size: 20px; font-weight: 800; margin: 4px 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Hero */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 22px; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--ska-blue) 0%, var(--ska-blue-dark) 70%); color: #fff; box-shadow: var(--shadow);
  border: 2px solid rgba(255,255,255,.12);
}
/* мотив логотипа: красно-белая лента по диагонали и звезда-водяной знак */
.hero::before { content: ''; position: absolute; left: -10%; right: -10%; bottom: 26px; height: 34px; transform: rotate(-6deg);
  background: var(--ska-red); box-shadow: 0 -5px 0 0 #fff, 0 5px 0 0 #fff; opacity: .9; pointer-events: none; }
.hero::after { content: ''; position: absolute; right: -40px; top: -50px; width: 300px; height: 300px; pointer-events: none;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  background: rgba(255,255,255,.06); }
.hero > * { position: relative; z-index: 1; }
.hero-stats .hs { backdrop-filter: blur(4px); }
.hero-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero .logo { width: 84px; height: 84px; background: transparent; padding: 0; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.hero h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; line-height: 1.1; }
.hero .sub { opacity: .8; font-size: 13.5px; margin-top: 4px; }
.hero-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
@media (max-width: 760px) { .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.hs { background: rgba(4,16,31,.45); border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 10px 12px; }
.hs .v { font-size: 24px; font-weight: 800; line-height: 1.1; }
.hs .l { font-size: 11.5px; opacity: .75; text-transform: uppercase; letter-spacing: .04em; }
.place-badge { margin-left: auto; text-align: center; background: var(--ska-red); border: 2px solid #fff; border-radius: 16px; padding: 8px 16px; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.place-badge .v { font-size: 34px; font-weight: 900; line-height: 1; }
.place-badge .l { font-size: 11px; opacity: .8; }

/* Logo */
.logo { width: 28px; height: 28px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; padding: 2px; }
.logo.sm { width: 22px; height: 22px; border-radius: 6px; }
.logo.lg { width: 48px; height: 48px; border-radius: 12px; }
.logo.ph { display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--ska-blue), var(--ska-blue-dark)); }
img.logo[src*="ska-strelna"] { background: transparent; padding: 0; }
.team { display: inline-flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team:hover span { text-decoration: underline; }
.team.fav span { color: var(--fav-soft); font-weight: 700; }

/* Form chips */
.form { display: inline-flex; gap: 3px; }
.fchip { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 800; color: #fff; }
.fchip.W { background: var(--green); }
.fchip.L { background: var(--red); }
.fchip.SW { background: #16a34a; opacity: .75; }
.fchip.SL { background: #f97316; }
.fchip.n { background: var(--line); }

/* Next match */
.next { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; text-align: center; }
.next .side { display: grid; justify-items: center; gap: 6px; font-weight: 700; }
.next .vs { font-size: 13px; color: var(--muted); }
.countdown { display: flex; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.countdown div { background: var(--card2); border-radius: 12px; padding: 8px 10px; min-width: 58px; }
.countdown b { display: block; font-size: 22px; line-height: 1.1; }
.countdown span { font-size: 11px; color: var(--muted); }
.meta { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }

/* Match rows */
.mrow {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) 78px minmax(0, 1fr) 40px; align-items: center; gap: 8px;
  padding: 10px 6px; border-bottom: 1px solid var(--line);
}
.mrow:last-child { border-bottom: 0; }
.mrow .when { font-size: 12.5px; color: var(--muted); line-height: 1.25; }
.mrow .when b { color: var(--text); font-size: 13.5px; }
.mrow .home { justify-self: end; text-align: right; flex-direction: row-reverse; }
.mrow .score { text-align: center; font-weight: 800; font-size: 17px; border-radius: 10px; padding: 4px 0; background: var(--card2); }
.mrow .score small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.mrow .score.W { background: rgba(34,197,94,.18); color: var(--green); }
.mrow .score.L { background: rgba(239,68,68,.16); color: var(--red); }
.mrow .score.up { font-size: 13px; font-weight: 600; color: var(--muted); }
.mrow.fav { background: var(--fav-bg); border-radius: 12px; border-bottom-color: transparent; }
.mrow .act { text-align: center; font-size: 16px; }
.mrow .fresh, .fresh-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-left: 4px; vertical-align: middle; }
@media (max-width: 640px) {
  .mrow { grid-template-columns: 1fr 64px 1fr; row-gap: 4px; }
  .mrow .when { grid-column: 1 / -1; display: flex; gap: 8px; }
  .mrow .act { display: none; }
}
.date-head { position: sticky; top: 56px; z-index: 5; padding: 10px 6px 6px; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--card); }
.date-head.today { color: var(--fav); }

/* Tables */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl th { position: sticky; top: 0; background: var(--card2); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; cursor: pointer; user-select: none; z-index: 1; }
.tbl th:hover { color: var(--text); }
.tbl th.sorted { color: var(--accent2); }
.tbl th.sorted::after { content: ' ▾'; }
.tbl th.sorted.asc::after { content: ' ▴'; }
.tbl td.l, .tbl th.l { text-align: left; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--card2); }
.tbl tr.fav td { background: var(--fav-bg); }
.tbl tr.fav td:first-child { box-shadow: inset 3px 0 0 var(--fav); }
.tbl td.strong { font-weight: 800; }
.tbl .pos { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--card2); font-weight: 700; }
.tbl tr.top .pos { background: var(--accent); color: #fff; }
.pname { font-weight: 600; }
.pname small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--card2); color: var(--muted); }
.tag.c { background: var(--amber); color: #111; }
.bar { position: relative; height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 60px; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar.fav i { background: linear-gradient(90deg, var(--ska-red), var(--fav-soft)); }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search], .filters select {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 0;
}
.filters input[type=search] { flex: 1 1 220px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--ska-blue); color: #fff; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13.5px; cursor: pointer; }

/* Leaders */
.leader { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.leader:last-child { border-bottom: 0; }
.leader .rk { width: 22px; color: var(--muted); font-weight: 700; text-align: center; }
.leader .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader .val { font-weight: 800; font-size: 16px; }
.leader .sub { color: var(--muted); font-size: 12px; }

/* Goalie cards */
.gk { position: relative; display: grid; gap: 10px; }
.gk-head { display: flex; gap: 12px; align-items: center; }
.gk-num { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-weight: 900; font-size: 18px; background: var(--ska-blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--ska-red); color: #fff; flex: none; }
.gk-name { font-weight: 800; font-size: 16px; }
.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--fav) calc(var(--p) * 1%), var(--line) 0); }
.ring > div { width: 70px; height: 70px; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center; }
.ring b { font-size: 17px; line-height: 1; }
.ring span { font-size: 10px; color: var(--muted); }
.gk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gk-stats div { background: var(--card2); border-radius: 10px; padding: 6px; text-align: center; }
.gk-stats b { display: block; font-size: 16px; }
.gk-stats span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; }
.rank-badge { position: absolute; top: 0; right: 0; font-size: 11.5px; padding: 3px 8px; border-radius: 8px; background: var(--card2); color: var(--muted); font-weight: 700; }

/* Tiles */
.tile { background: var(--card2); border-radius: 14px; padding: 12px; }
.tile .v { font-size: 22px; font-weight: 800; }
.tile .l { font-size: 12px; color: var(--muted); }

/* Month calendar */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month .dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.day { min-height: 96px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.day.out { opacity: .35; }
.day.today { outline: 2px solid var(--ska-red); }
.day .dn { font-size: 12px; font-weight: 700; color: var(--muted); }
.ev { font-size: 11.5px; line-height: 1.25; padding: 4px 5px; border-radius: 7px; background: var(--card2); overflow: hidden; cursor: pointer; }
.ev:hover { filter: brightness(1.15); }
.ev.fav { background: var(--fav); color: #fff; }
.ev .t { font-weight: 700; }
.ev .s { font-weight: 800; float: right; }
@media (max-width: 700px) {
  .day { min-height: 58px; padding: 4px; }
  .ev { font-size: 0; padding: 0; height: 7px; border-radius: 4px; }
}
.month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.month-nav h3 { margin: 0; min-width: 160px; text-align: center; text-transform: capitalize; }

/* Timeline */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.tl-item.hasfav::before { background: var(--ska-red); }
.tl-when { font-weight: 800; }
.chg { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.chg:last-child { border-bottom: 0; }
.chg .ic { width: 22px; text-align: center; flex: none; }
.chg.fav { color: var(--text); font-weight: 600; }
.chg.fav .ic { filter: drop-shadow(0 0 4px rgba(210,18,27,.6)); }

/* Drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 41; overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--line); padding: 18px; box-shadow: -20px 0 50px rgba(0,0,0,.35);
  animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer .close { position: sticky; top: 0; float: right; z-index: 2; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.alert { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: var(--text); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.kbd-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* Актуальность данных вратарей */
.fresh-box { border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; display: grid; gap: 4px; border: 1px solid var(--line); background: var(--card); }
.fresh-box.ok { border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.08); }
.fresh-box.warn { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.1); }
.rank-badge.in { background: var(--accent); color: #fff; }
.gk-head { padding-right: 120px; }
.gk-games { display: grid; gap: 2px; }
.gk-game { display: grid; grid-template-columns: 42px minmax(0,1fr) 44px 52px 52px; gap: 6px; font-size: 12.5px; padding: 4px 6px; border-radius: 8px; color: var(--text); background: var(--card2); }
.gk-game:hover { text-decoration: none; filter: brightness(1.15); }
.gk-game .o { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gk-game b { text-align: right; }
.gk-upd { color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.gk-upd b { color: var(--text); }

/* Акценты СКА Стрельна на карточках любимой команды */
.mrow.fav { box-shadow: inset 3px 0 0 var(--ska-red); }
.card h3 { position: relative; }
.btn:not(.ghost) { background: var(--ska-blue); }
.btn:not(.ghost):hover { background: #0560a8; }
.ev.fav { background: var(--ska-red); }
.date-head.today { color: var(--fav-soft); }
.tbl tr.top .pos { background: var(--ska-blue); }
.tabs .dot { background: var(--ska-red); box-shadow: 0 0 0 2px var(--bg); }

/* Плашки «Ближайшие матчи» (синяя) и «Результаты» (красная) */
.mcard { border-top: 4px solid; padding-top: 12px; }
.mcard.up { border-top-color: var(--ska-blue); background: linear-gradient(180deg, rgba(0,74,135,.38) 0, var(--card) 140px); }
.mcard.res { border-top-color: var(--ska-red); background: linear-gradient(180deg, rgba(210,18,27,.2) 0, var(--card) 140px); }
.mcard-title { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px; color: #fff; font-size: 13.5px; }
.mcard.up .mcard-title { background: var(--ska-blue); }
.mcard.res .mcard-title { background: var(--ska-red); }
.mcard .mrow.fav { background: transparent; box-shadow: none; border-radius: 0; border-bottom-color: var(--line); }
.mcard .mrow:last-of-type { border-bottom: 0; }
.mcard.up .mrow .score.up { background: rgba(0,74,135,.35); color: var(--text); }
.res-sum { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: -4px 0 8px; }
.res-toggle { width: 100%; justify-content: center; margin-top: 10px; }

/* Наш клуб: «Стрельна» мельче */
.tsub { font-size: 0.78em; font-weight: inherit; }
.team span.tsub { overflow: visible; }
