:root {
  --hsg-green: #1f9b3d; --hsg-green-deep: #156628; --hsg-green-light: #4cc466; --hsg-bg: rgba(31,155,61,.12);
  --hsg-blue: #1f5ea8; --hsg-blue-deep: #103e74; --hsg-blue-light: #4787d4;
  --bg: #f4f6f5; --card: #ffffff; --fg: #14201a; --fg-dim: #4b5a52; --fg-mute: #7d8a83; --line: #e2e7e4; --line-strong: #c9d2cd;
  --win: #1f9b3d; --loss: #d23216; --draw: #b7860b; --live: #d23216; --danger: #d23216;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(20,32,26,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1613; --card: #182119; --fg: #f1f5f2; --fg-dim: #b9c6be; --fg-mute: #7f8f86; --line: #263129; --line-strong: #364439; --hsg-bg: rgba(76,196,102,.16); --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: 'Inter', 'Helvetica Neue', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.45; }
a { color: var(--hsg-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }

/* Header */
header.top { background: linear-gradient(135deg, var(--hsg-green-deep), var(--hsg-green) 55%, var(--hsg-blue)); color: #fff; }
header.top .wrap { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
header.top img { width: 52px; height: 52px; border-radius: 50%; background: #fff; padding: 3px; }
header.top h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; }
header.top .sub { font-size: .8rem; opacity: .85; }
header.top a { color: #fff; }
header.top .spacer { flex: 1; }
header.top .status { font-size: .72rem; opacity: .8; text-align: right; }
header.top .status .live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff5a6c; margin-right: 4px; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

nav.crumbs { font-size: .85rem; color: var(--fg-mute); margin: 14px 0 6px; }
nav.crumbs a { color: var(--fg-dim); }

/* Cards & lists */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); margin: 14px 0; }
.card > h2, .card > h3 { margin: 0; padding: 12px 16px; font-size: .95rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.card > h2 .right, .card > h3 .right { margin-left: auto; font-weight: 400; font-size: .8rem; color: var(--fg-mute); }
.card .body { padding: 12px 16px; }
.empty { padding: 18px 16px; color: var(--fg-mute); font-size: .9rem; text-align: center; }
.muted { color: var(--fg-mute); }
.small { font-size: .8rem; }

/* Team grid */
.group-title { margin: 22px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-mute); font-weight: 700; }
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.team-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: block; color: inherit; transition: transform .1s, border-color .1s; }
.team-card:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--hsg-green-light); }
.team-card .name { font-weight: 700; font-size: 1.05rem; }
.team-card .league { color: var(--fg-dim); font-size: .8rem; margin-top: 2px; min-height: 2.4em; }
.team-card .rec { margin-top: 8px; font-size: .8rem; color: var(--fg-mute); display: flex; gap: 10px; }
.team-card .rec b { color: var(--fg); }
.team-card .next { margin-top: 6px; font-size: .8rem; color: var(--hsg-blue); }

/* Game rows */
.games { list-style: none; margin: 0; padding: 0; }
.games li { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.games li:first-child { border-top: 0; }
.games li:hover { background: var(--hsg-bg); }
.games .when { font-size: .8rem; color: var(--fg-dim); line-height: 1.3; }
.games .when b { display: block; color: var(--fg); font-size: .85rem; }
.games .teams-line { min-width: 0; }
.games .teams-line .t { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.games .teams-line .t.ours { font-weight: 700; color: var(--hsg-green-deep); }
@media (prefers-color-scheme: dark) { .games .teams-line .t.ours { color: var(--hsg-green-light); } }
.games .meta { font-size: .75rem; color: var(--fg-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.games .score { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; text-align: right; min-width: 64px; }
.games .score .ht { display: block; font-weight: 400; font-size: .7rem; color: var(--fg-mute); }
.games .score.pending { color: var(--fg-mute); font-weight: 400; font-size: .8rem; }
.res-W { color: var(--win); } .res-L { color: var(--loss); } .res-D { color: var(--draw); }
.badge { display: inline-block; font-size: .65rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; vertical-align: middle; margin-left: 4px; letter-spacing: .03em; }
.badge.live { background: var(--live); color: #fff; animation: pulse 1.4s infinite; }
.badge.home { background: var(--hsg-bg); color: var(--hsg-green-deep); }
.badge.friendly { background: #eee; color: #666; }
.badge.status { background: #f0e6c8; color: #7a5a00; }
.day-head { padding: 8px 16px; font-size: .78rem; font-weight: 700; color: var(--fg-mute); background: rgba(127,127,127,.06); border-top: 1px solid var(--line); text-transform: uppercase; letter-spacing: .06em; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin: 14px 0 0; border-bottom: 2px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--fg-dim); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.active { color: var(--hsg-green-deep); border-bottom-color: var(--hsg-green); }
@media (prefers-color-scheme: dark) { .tabs button.active { color: var(--hsg-green-light); } }

/* Team header */
.team-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; padding: 16px; }
.team-head h2 { margin: 0; font-size: 1.4rem; }
.team-head .league { color: var(--fg-dim); }
.team-head .stats { display: flex; gap: 14px; font-size: .85rem; color: var(--fg-mute); }
.team-head .stats b { color: var(--fg); font-size: 1.05rem; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--hsg-green); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 600; cursor: pointer; font-size: .85rem; }
.btn:hover { background: var(--hsg-green-deep); text-decoration: none; }
.btn.secondary { background: var(--card); color: var(--fg); border: 1px solid var(--line-strong); }
.btn.small { padding: 5px 9px; font-size: .78rem; }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th, table.tbl td { padding: 8px 10px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tbl th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-mute); border-top: 0; }
table.tbl th.l, table.tbl td.l { text-align: left; }
table.tbl td.team-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.tbl tr.ours td { background: var(--hsg-bg); font-weight: 700; }
table.tbl td img.logo, .games img.logo, .roster img.photo, .player-head img.logo { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; background: #fff; }
.form { display: inline-flex; gap: 2px; }
.form span { width: 14px; height: 14px; border-radius: 3px; display: inline-block; font-size: 0; }
.form .W { background: var(--win); } .form .L { background: var(--loss); } .form .D { background: var(--draw); }
.tbl-wrap { overflow-x: auto; }

/* Roster */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; padding: 12px 16px; }
.roster .p { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.roster img.photo, .roster .noimg { width: 42px; height: 42px; border-radius: 50%; flex: none; }
.roster .noimg { background: var(--hsg-bg); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--hsg-green-deep); }
.roster .num { font-weight: 700; color: var(--hsg-blue); min-width: 1.6em; }
.roster .nm { font-weight: 600; font-size: .9rem; }
.roster .rl { font-size: .72rem; color: var(--fg-mute); }

/* Match detail */
.match-head { padding: 18px 16px; text-align: center; }
.match-head .league { color: var(--fg-mute); font-size: .8rem; }
.match-head .vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 10px 0; }
.match-head .vs .tn { font-weight: 700; font-size: 1.05rem; display: block; color: inherit; }
.match-head .vs a.tn:hover { text-decoration: underline; }
.match-head .vs .tn.ours { color: var(--hsg-green-deep); }
.match-head .vs img { width: 44px; height: 44px; border-radius: 50%; background: #fff; object-fit: contain; display: block; margin: 0 auto 6px; }
.match-head .big { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.match-head .ht { font-size: .85rem; color: var(--fg-mute); }
.match-head .info { font-size: .85rem; color: var(--fg-dim); margin-top: 6px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 1fr 70px 1fr; align-items: center; border-top: 1px solid var(--line); font-size: .85rem; }
.timeline li:first-child { border-top: 0; }
.timeline li > div { padding: 6px 10px; }
.timeline .h { text-align: right; } .timeline .a { text-align: left; }
.timeline .mid { text-align: center; color: var(--fg-mute); font-size: .75rem; font-variant-numeric: tabular-nums; }
.timeline .mid b { display: block; color: var(--fg); font-size: .85rem; }
.timeline li.goal { background: rgba(31,155,61,.05); }
.timeline li.block { background: rgba(127,127,127,.08); text-align: center; font-weight: 700; font-size: .75rem; color: var(--fg-mute); display: block; padding: 6px; text-transform: uppercase; letter-spacing: .06em; }
.ev-ico { display: inline-block; min-width: 20px; font-size: .8rem; }
.lineups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px; }
@media (max-width: 640px) { .lineups { grid-template-columns: 1fr; } .games li { grid-template-columns: 78px 1fr auto; } .team-head h2 { font-size: 1.2rem; } }
.lineups h4 { margin: 0 0 6px; font-size: .85rem; }
.lineups table { width: 100%; font-size: .8rem; border-collapse: collapse; }
.lineups td { padding: 3px 4px; border-top: 1px solid var(--line); }
.lineups td.n { text-align: right; color: var(--hsg-blue); font-weight: 700; width: 2.2em; }
.lineups td.g { text-align: right; font-variant-numeric: tabular-nums; }

/* iCal box */
.ical-box { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ical-box code { background: rgba(127,127,127,.12); padding: 4px 8px; border-radius: 6px; font-size: .78rem; word-break: break-all; flex: 1 1 260px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: .85rem; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.loading { padding: 24px; text-align: center; color: var(--fg-mute); }
.err { padding: 12px 16px; color: var(--danger); font-size: .85rem; }
footer { margin-top: 32px; font-size: .75rem; color: var(--fg-mute); text-align: center; }

/* PWA */
.install-btn { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 8px; padding: 6px 10px; font-weight: 600; cursor: pointer; font-size: .8rem; margin-right: 10px; }
.install-btn:hover { background: rgba(255,255,255,.3); }
.offline-bar { background: #b7860b; color: #fff; text-align: center; font-size: .8rem; padding: 6px 12px; }
.update-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--hsg-blue-deep); color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; font-size: .85rem; box-shadow: 0 6px 24px rgba(0,0,0,.3); z-index: 50; max-width: calc(100vw - 32px); }
.update-bar button { background: #fff; color: var(--hsg-blue-deep); border: 0; border-radius: 6px; padding: 6px 10px; font-weight: 700; cursor: pointer; }
@media (display-mode: standalone) { header.top { padding-top: env(safe-area-inset-top); } }
.home-body { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: .9rem; }
.plink { color: inherit; border-bottom: 1px dotted var(--fg-mute); }
.plink:hover { color: var(--hsg-blue); text-decoration: none; border-bottom-style: solid; }
.player-head { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; padding: 16px; }
.player-head h2 { margin: 0 0 2px; font-size: 1.4rem; }
.player-head .pphoto { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: #fff; flex: none; }
.player-head .noimg { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.4rem; background: var(--hsg-bg); color: var(--hsg-green-deep); }
.player-head .stats { display: flex; gap: 14px; font-size: .85rem; color: var(--fg-mute); flex-wrap: wrap; margin-left: auto; }
.player-head .stats b { color: var(--fg); font-size: 1.05rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--hsg-bg); }
