:root {
  color-scheme: dark;
  --bg: #080d16;
  --surface: #111827;
  --surface-2: #182131;
  --line: rgba(255, 255, 255, .09);
  --text: #f8fafc;
  --muted: #9ca8b8;
  --red: #ed1c24;
  --red-dark: #a90f17;
  --gold: #f3c969;
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 13, 22, .92);
  backdrop-filter: blur(18px);
}
.app-brand { display: flex; align-items: center; gap: 10px; }
.app-brand img { width: 42px; height: 42px; object-fit: contain; }
.app-brand span { display: grid; line-height: 1.05; }
.app-brand small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.app-brand strong { font-size: 18px; text-transform: uppercase; }
.install-button {
  border: 1px solid rgba(237, 28, 36, .6);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(237, 28, 36, .13);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.install-button.is-installed { display: none; }

main { width: min(100%, 760px); margin: 0 auto; padding: 16px 16px calc(92px + var(--safe-bottom)); }
.season-picker { margin-bottom: 16px; padding: 16px; border: 1px solid rgba(70, 151, 255, .28); border-radius: 22px; background: linear-gradient(145deg, rgba(27, 49, 82, .75), rgba(17, 24, 39, .95)); }
.season-picker > div:first-child > span { color: #62b0ff; font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.season-picker h2 { margin: 4px 0 13px; font-size: 18px; letter-spacing: -.02em; }
.season-switcher { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.season-switcher button { display: grid; gap: 3px; min-width: 0; border: 1px solid var(--line); border-radius: 16px; padding: 13px; background: rgba(8, 13, 22, .72); color: var(--text); text-align: left; cursor: pointer; }
.season-switcher button span { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.season-switcher button strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.season-switcher button small { color: var(--muted); font-size: 9px; }
.season-switcher button.is-active { border-color: var(--red); background: linear-gradient(145deg, rgba(237, 28, 36, .23), rgba(8, 13, 22, .9)); box-shadow: 0 0 0 1px rgba(237, 28, 36, .15) inset; }
.season-switcher button.is-active span, .season-switcher button.is-active small { color: #ff9da1; }
.app-view { display: none; animation: reveal .22s ease; }
.app-view.is-active { display: block; }
@keyframes reveal { from { opacity: .35; transform: translateY(5px); } }

.hero-card {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr 118px;
  min-height: 230px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(237, 28, 36, .35);
  border-radius: 26px;
  background:
    radial-gradient(circle at 90% 20%, rgba(237, 28, 36, .45), transparent 35%),
    linear-gradient(145deg, #1b2433 0%, #101722 58%, #5f0b10 130%);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .26);
}
.hero-card::after { content: ""; position: absolute; inset: auto -40px -75px 35%; z-index: -1; height: 160px; border: 35px solid rgba(255,255,255,.025); border-radius: 50%; transform: rotate(-12deg); }
.hero-card > div { align-self: center; }
.hero-card .season { display: inline-flex; padding: 6px 9px; border-radius: 999px; background: var(--red); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.hero-card h1 { margin: 14px 0 9px; font-size: clamp(31px, 8vw, 48px); line-height: .98; letter-spacing: -.045em; }
.hero-card p { max-width: 300px; margin: 0; color: #c5cbd5; font-size: 14px; line-height: 1.45; }
.hero-card img { align-self: center; width: 125px; max-width: 30vw; filter: drop-shadow(0 12px 20px rgba(0,0,0,.36)); }
.install-card { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px; margin: 12px 0; padding: 13px; border: 1px solid rgba(243,201,105,.28); border-radius: 19px; background: linear-gradient(135deg, rgba(243,201,105,.11), var(--surface)); }
.install-card img { width: 54px; height: 54px; border-radius: 13px; object-fit: cover; box-shadow: 0 7px 18px rgba(0,0,0,.28); }
.install-card div { display: grid; gap: 2px; min-width: 0; }
.install-card span { color: var(--gold); font-size: 8px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.install-card strong { font-size: 16px; }
.install-card small { color: var(--muted); font-size: 10px; line-height: 1.3; }
.install-card button { border: 0; border-radius: 12px; padding: 10px 12px; background: var(--red); color: #fff; font-size: 11px; font-weight: 900; }
body.is-installed .install-card, body.is-installed [data-install-app] { display: none; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 12px 0 22px; }
.summary-grid article { min-width: 0; padding: 15px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.summary-grid strong { display: block; font-size: 22px; letter-spacing: -.04em; }
.summary-grid span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.2; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }

.app-section { margin-top: 24px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-title span, .page-heading > span { color: var(--red); font-size: 10px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.section-title h2 { margin: 3px 0 0; font-size: 20px; }
.section-title button { border: 0; background: none; color: #d0d6df; font-size: 12px; font-weight: 700; }
.match-list, .round-list { display: grid; gap: 9px; }
.match-card-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.match-card { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 9px; padding: 14px; background: var(--surface); }
.match-card .club { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; font-weight: 750; }
.match-card .club:last-child { justify-content: flex-end; text-align: right; }
.match-card .club img { width: 30px; height: 30px; object-fit: contain; }
.match-card .club:last-child img { order: 2; }
.match-card .club span { overflow: hidden; text-overflow: ellipsis; }
.match-card .score { display: grid; min-width: 62px; place-items: center; }
.match-card .score strong { font-size: 18px; letter-spacing: .03em; }
.match-card .score small { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.match-acta-link { display: block; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--primary); font-size: 10px; font-weight: 800; text-align: center; text-decoration: none; }
.podium-list { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.podium-row { display: grid; grid-template-columns: 26px 40px 1fr auto; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.podium-row:last-child { border-bottom: 0; }
.podium-row > b { color: var(--gold); text-align: center; }
.podium-row img { width: 38px; height: 38px; object-fit: contain; }
.podium-row span { min-width: 0; font-size: 13px; font-weight: 800; }
.podium-row em { color: var(--muted); font-size: 11px; font-style: normal; }
.podium-row em strong { color: #fff; font-size: 17px; }

.page-heading { padding: 13px 4px 18px; }
.page-heading h1 { margin: 5px 0 6px; font-size: 32px; letter-spacing: -.035em; }
.page-heading p { max-width: 500px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.mobile-table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.mobile-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mobile-table th { padding: 12px 8px; color: var(--muted); font-size: 9px; text-align: center; text-transform: uppercase; }
.mobile-table th:nth-child(2) { text-align: left; }
.mobile-table td { padding: 11px 8px; border-top: 1px solid var(--line); text-align: center; }
.mobile-table td:nth-child(2) { text-align: left; }
.table-team { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 750; }
.table-team img { flex: 0 0 auto; width: 30px; height: 30px; object-fit: contain; }
.table-team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-table .position { font-weight: 900; }
.mobile-table .points { color: #fff; font-size: 15px; font-weight: 900; }
.mobile-table tr:first-child .position { color: var(--gold); }

.filter-control, .search-control { display: grid; gap: 6px; margin-bottom: 14px; }
.match-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.filter-control span { color: var(--muted); font-size: 11px; font-weight: 700; }
.filter-control select, .search-control input { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: none; padding: 13px 14px; background: var(--surface); color: #fff; }
.filter-control select:focus, .search-control input:focus { border-color: var(--red); }
.match-filters .filter-control { min-width: 0; }
.round-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.round-card header { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.round-card h2 { margin: 0; font-size: 15px; }
.round-card header span { color: var(--muted); font-size: 10px; }
.round-day > h3 { margin: 0; padding: 9px 15px; border-bottom: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .03em; text-transform: capitalize; }
.round-card .match-card-wrap { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.round-card .match-card-wrap:last-child { border-bottom: 0; }

.teams-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.team-tile { display: grid; min-height: 156px; place-items: center; padding: 17px 10px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(155deg, var(--surface-2), var(--surface)); text-align: center; }
.team-tile img { width: 70px; height: 70px; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0,0,0,.3)); }
.team-tile strong { margin-top: 9px; font-size: 13px; }
.team-tile small { margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.empty-state { grid-column: 1 / -1; padding: 30px; color: var(--muted); text-align: center; }

.players-list { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.app-ranking-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; padding: 5px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.app-ranking-tabs button { border: 0; border-radius: 10px; padding: 9px 5px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 800; }
.app-ranking-tabs button.is-active { background: var(--red); color: #fff; }
.player-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 11px; padding: 14px; border-bottom: 1px solid var(--line); }
.player-row:last-child { border-bottom: 0; }
.player-row > b { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.player-row:first-child > b { background: var(--gold); color: #1d1606; }
.player-row span { display: grid; min-width: 0; }
.player-row strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.player-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.player-row em { color: var(--red); font-size: 17px; font-style: normal; font-weight: 900; }
.player-row em small { color: var(--muted); font-size: 8px; text-transform: uppercase; }
.portal-card { display: grid; gap: 4px; margin-top: 14px; padding: 20px; border: 1px solid rgba(237,28,36,.35); border-radius: 20px; background: linear-gradient(135deg, rgba(237,28,36,.18), var(--surface)); }
.portal-card span { color: var(--red); font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.portal-card strong { font-size: 19px; }
.portal-card small { color: var(--muted); }

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px max(7px, env(safe-area-inset-right)) var(--safe-bottom) max(7px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(12, 18, 29, .96);
  box-shadow: 0 -10px 35px rgba(0,0,0,.3);
  backdrop-filter: blur(20px);
}
.bottom-nav button { display: grid; gap: 3px; place-items: center; border: 0; border-radius: 12px; padding: 7px 2px; background: transparent; color: #7f8b9b; }
.bottom-nav b { height: 16px; font-size: 15px; line-height: 1; }
.bottom-nav span { font-size: 9px; font-weight: 750; }
.bottom-nav button.is-active { background: rgba(237, 28, 36, .12); color: #fff; }
.bottom-nav button.is-active b { color: var(--red); }
.bottom-nav.app-top-nav {
  position: sticky;
  z-index: 19;
  top: 68px;
  right: auto;
  bottom: auto;
  left: auto;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-top: 0;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  transform: none;
}
.bottom-nav.app-top-nav a { display: grid; gap: 3px; place-items: center; border: 0; border-radius: 12px; padding: 7px 2px; background: transparent; color: #7f8b9b; }
.bottom-nav.app-top-nav a.is-active { background: rgba(237, 28, 36, .12); color: #fff; }
.bottom-nav.app-top-nav a.is-active b { color: var(--red); }

.install-dialog { width: min(91vw, 390px); border: 1px solid var(--line); border-radius: 24px; padding: 28px; background: #151d29; color: #fff; text-align: center; }
.install-dialog::backdrop { background: rgba(0,0,0,.74); backdrop-filter: blur(4px); }
.install-dialog img { width: 82px; height: 82px; object-fit: contain; }
.install-dialog h2 { margin: 12px 0 6px; }
.install-dialog p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.install-steps { display: grid; gap: 10px; margin: 20px 0 14px; padding: 0; list-style: none; text-align: left; }
.install-steps li { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 10px; }
.install-steps li > b { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--red); font-size: 12px; }
.install-steps li span { color: #d7dde6; font-size: 12px; line-height: 1.35; }
.install-result { display: block; padding: 10px; border-radius: 12px; background: rgba(243,201,105,.1); color: var(--gold); font-size: 10px; line-height: 1.35; }
.dialog-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; color: #fff; font-size: 26px; }

@media (min-width: 720px) {
  body { background: radial-gradient(circle at 50% -20%, #253044 0, var(--bg) 42%); }
  .app-header { padding-inline: calc((100% - 760px) / 2 + 16px); }
  .bottom-nav { right: 50%; left: auto; width: 760px; transform: translateX(50%); border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
  .teams-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 380px) {
  .hero-card { grid-template-columns: 1fr 85px; padding: 20px; }
  .hero-card h1 { font-size: 29px; }
  .install-card { grid-template-columns: 48px 1fr; }
  .install-card img { width: 46px; height: 46px; }
  .install-card button { grid-column: 1 / -1; width: 100%; }
  .summary-grid article { padding-inline: 8px; }
  .mobile-table th, .mobile-table td { padding-inline: 5px; }
}
