:root {
  color-scheme: light dark;
  /* Each color resolves per theme via light-dark(LIGHT, DARK); the active
     color-scheme picks the side. Default follows the OS; the theme control
     forces it via data-theme below. */
  --bg:            light-dark(#eef2f7, #0d1117);
  --bg-elev:       light-dark(#e4eaf2, #161b22);
  --bg-card:       light-dark(#ffffff, #1b2230);
  --bg-card-hover: light-dark(#f1f5fb, #222b3b);
  --line:          light-dark(#d4dce7, #2a3343);
  --text:          light-dark(#16202e, #e8edf4);
  --muted:         light-dark(#566576, #93a1b5);
  --accent:        #00c389;                         /* pitch green (both themes) */
  --accent-strong: light-dark(#07684a, #00c389);    /* green text on surfaces */
  --accent-2:      #ffd24a;                          /* gold (both themes) */
  --gold-ink:      light-dark(#7a5600, #ffd24a);     /* amber text on surfaces */
  --accent-ink:    light-dark(#04130d, #052016);     /* ink on accent fills */
  --selected:      light-dark(#e2f6ee, #1d3a2f);
  --selected-line: light-dark(#15b083, #2bd49a);
  --star:          light-dark(#dd9b00, #ffd24a);     /* filled star glyph */
  --star-empty:    light-dark(#a9b4c3, #5a6982);     /* empty star + off-day num */
  --header-bg:     light-dark(rgba(247,249,252,.82), rgba(13,17,23,.86));
  --toolbar-bg:    light-dark(rgba(237,242,248,.9), rgba(22,27,34,.92));
  --head-bg:       light-dark(rgba(238,243,249,.86), rgba(13,17,23,.85));
  --shadow-color:  light-dark(rgba(30,50,80,.13), rgba(0,0,0,.32));
  --radius: 14px;
  --shadow: 0 6px 22px var(--shadow-color);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur: 180ms;
  font-synthesis: none;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

* { box-sizing: border-box; }

.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;
}

/* One focus language for every control; the ring follows each element's own radius. */
:where(button, a, input, select, [tabindex]):focus-visible {
  outline: none; box-shadow: var(--ring);
}
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(0,195,137,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(255,210,74,.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }

/* Header + toolbar stick together as one unit, so the toolbar can never
   slip under the header regardless of how either wraps. */
.topbar { position: sticky; top: 0; z-index: 30; }

/* Header */
.site-header {
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-ball { font-size: 30px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.brand h1 { font-size: 1.18rem; margin: 0; letter-spacing: .2px; }
.brand-sub { margin: 0; font-size: .78rem; color: var(--muted); }
.header-controls { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.tz-control, .theme-control { display: flex; align-items: center; gap: 9px; font-size: .82rem; color: var(--muted); }
.tz-label { white-space: nowrap; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line);
}
.seg-btn {
  appearance: none; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 600; font-size: .82rem;
  padding: 5px 13px; border-radius: 999px; transition: color var(--dur), background var(--dur);
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { color: var(--accent-ink); background: var(--accent); box-shadow: 0 1px 6px rgba(0,195,137,.35); }

/* Toolbar */
.toolbar {
  background: var(--toolbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.toolbar-inner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 18px; }
.views { display: flex; gap: 6px; flex-wrap: wrap; }
.view-btn {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--muted); padding: 7px 13px; border-radius: 999px; cursor: pointer;
  font-size: .88rem; font-weight: 600; transition: .15s; white-space: nowrap;
}
.view-btn:hover { color: var(--text); background: var(--bg-card); }
.view-btn.is-active { color: var(--accent-ink); background: var(--accent); }
.view-btn--star.is-active { background: var(--accent-2); color: #2a2200; }
.count-badge {
  display: inline-block; min-width: 18px; text-align: center;
  background: rgba(0,0,0,.28); border-radius: 999px; font-size: .72rem; padding: 0 6px; margin-left: 4px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

input[type="search"], select {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px;
  font-size: .86rem; font-family: inherit; outline: none;
}
input[type="search"] { min-width: 200px; }
input[type="search"]:focus, select:focus { border-color: var(--accent); }
.ghost-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: .82rem; font-family: inherit;
}
.ghost-btn:hover { color: var(--text); border-color: var(--muted); }
/* Starred-only filter toggle: gold when active, matching the ★ accent. */
.toggle-btn.is-on {
  color: var(--accent-ink); background: var(--accent-2);
  border-color: var(--accent-2); font-weight: 700;
}
.toggle-btn.is-on:hover { color: var(--accent-ink); border-color: var(--accent-2); }

/* Content layout */
main { padding: 22px 18px 60px; }
.section { margin-bottom: 30px; }
.section-head {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px;
  position: sticky; top: var(--topbar-h, 112px); z-index: 10;
  padding: 7px 10px;
  background: var(--head-bg);
  backdrop-filter: blur(8px);
  border-radius: 10px;
}
.section-title { font-size: 1.02rem; font-weight: 700; margin: 0; }
.section-sub { font-size: .8rem; color: var(--muted); }
.section-rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); align-self: center; }

.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }

/* Match card */
.match {
  position: relative; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px 12px; transition: .15s; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 9px;
}
.match:hover { background: var(--bg-card-hover); transform: translateY(-1px); }
.match.is-selected { background: var(--selected); border-color: var(--selected-line); }
.match-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.match-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: .73rem; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line); font-weight: 600; letter-spacing: .2px;
}
.chip--group { color: var(--accent-strong); border-color: rgba(0,195,137,.35); }
.chip--ko { color: var(--gold-ink); border-color: rgba(255,210,74,.4); }

.star-btn {
  appearance: none; background: transparent; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; font-size: 1.25rem; line-height: 1; color: var(--star-empty);
  padding: 0; transition: transform .12s var(--ease-out), color .12s; flex: none;
}
.star-btn:hover { transform: scale(1.18); color: var(--star); }
.star-btn.on { color: var(--star); text-shadow: 0 0 12px rgba(255,210,74,.5); }

.teams { display: flex; flex-direction: column; gap: 5px; }
.team { display: flex; align-items: center; gap: 9px; font-size: 1.02rem; font-weight: 600; }
.team .flag { font-size: 1.3rem; width: 1.5em; text-align: center; flex: none; }
.team .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team.tbd { color: var(--muted); font-weight: 500; }
.vs { font-size: .7rem; color: var(--muted); letter-spacing: 2px; margin-left: 3px; }

.match-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 9px; }
.kickoff { display: flex; flex-direction: column; gap: 2px; }
.kick-date { font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .2px; }
.kick-time { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; font-size: 1rem; letter-spacing: .2px; }
.kickoff .tz { font-weight: 600; color: var(--accent-strong); font-size: .68em; margin-left: 4px; letter-spacing: .3px; }
.venue { text-align: right; max-width: 56%; }
.venue .city { display: block; font-size: .92em; }

/* Motion: staggered card entrance + tactile star pop. State, not spectacle. */
@media (prefers-reduced-motion: no-preference) {
  .match { animation: card-in .42s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 28ms); }
  .squad[open] .squad-body { animation: card-in .3s var(--ease-out); }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
.star-btn.pop { animation: star-pop .42s var(--ease-out); }
@keyframes star-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.45); }
  60%  { transform: scale(.92); }
  100% { transform: scale(1); }
}

/* Loading skeleton */
.skel-card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 11px;
}
.skel-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--bg-elev) 0%, var(--bg-card-hover) 50%, var(--bg-elev) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel-title { width: 180px; height: 16px; }
.skel-chip { width: 96px; }
.skel-team { width: 70%; height: 18px; }
.skel-team.short { width: 52%; }
.skel-foot { height: 22px; margin-top: 4px; border-top: 1px dashed var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel-line { animation: none; } }

/* Calendar view */
.cal { margin-bottom: 26px; }
.cal-legend { display: flex; gap: 18px; margin: 2px 2px 16px; font-size: .8rem; color: var(--muted); }
.cal-key { display: inline-flex; align-items: center; gap: 7px; }
.cal-swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.cal-swatch.has { background: var(--bg-card-hover); border: 1px solid var(--accent); }
.cal-swatch.star { background: var(--accent-2); }

.cal-months { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.cal-month-name { font-size: 1rem; font-weight: 700; margin: 0 2px 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekdays { margin-bottom: 6px; }
.cal-wd { text-align: center; font-size: .68rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }

.cal-cell {
  aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border-radius: 10px; font: inherit; position: relative;
}
.cal-empty { visibility: hidden; }
.cal-num { font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.cal-off { background: var(--bg-elev); border: 1px solid transparent; }
.cal-off .cal-num { color: var(--star-empty); }

/* days that have matches are buttons */
.cal-has {
  appearance: none; cursor: pointer; border: 1px solid var(--line); background: var(--bg-card);
  color: var(--text); transition: transform .12s var(--ease-out), border-color var(--dur), background var(--dur);
}
.cal-has .cal-num { color: var(--text); font-weight: 600; }
.cal-has:hover { background: var(--bg-card-hover); transform: translateY(-1px); }
.cal-has.cal-starred { border-color: rgba(255,210,74,.55); background: rgba(255,210,74,.08); }
.cal-selected { border-color: var(--accent-strong); box-shadow: 0 0 0 1px var(--accent-strong); }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-strong); opacity: .9; }
.cal-badge {
  font-size: .66rem; font-weight: 800; line-height: 1; color: #2a2200;
  background: var(--accent-2); border-radius: 999px; padding: 2px 6px; white-space: nowrap;
}
.cal-detail { scroll-margin-top: calc(var(--topbar-h, 112px) + 8px); }

.daystrip { font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; font-size: .95rem; }

/* Squad dossier (team view) */
.squad {
  margin: 12px 2px 0; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.squad-summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; cursor: pointer; list-style: none; user-select: none;
}
.squad-summary::-webkit-details-marker { display: none; }
.squad-summary::before {
  content: "▸"; color: var(--accent-strong); font-size: .8rem; transition: transform .15s; flex: none;
}
.squad[open] .squad-summary::before { transform: rotate(90deg); }
.squad-summary:hover { background: var(--bg-card-hover); }
.squad-title { font-weight: 700; font-size: .92rem; }
.squad-meta { font-size: .78rem; color: var(--muted); }
.squad-body {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px 18px; padding: 4px 14px 14px; border-top: 1px solid var(--line);
}
.squad-pos {
  display: flex; align-items: center; gap: 7px; margin: 12px 0 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent-strong);
}
.squad-pos-count {
  font-weight: 600; color: var(--muted); background: var(--bg-elev);
  border-radius: 999px; padding: 0 6px; font-size: .9em; letter-spacing: 0;
}
.squad-list { list-style: none; margin: 0; padding: 0; }
.player {
  display: grid; grid-template-columns: 1.6em 1fr auto; align-items: baseline;
  gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: .86rem;
}
.player:last-child { border-bottom: none; }
.player-num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: .8rem; }
.player-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-club { grid-column: 2; color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-age { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 22px 0 40px; color: var(--muted); font-size: .8rem; }
.site-footer p { margin: 4px 0; }
.muted { color: var(--muted); }

/* Comfortable touch targets on touch devices (44px guideline). */
@media (pointer: coarse) {
  .star-btn { width: 44px; height: 44px; }
  .view-btn { padding-top: 10px; padding-bottom: 10px; }
  .seg-btn { padding-top: 9px; padding-bottom: 9px; }
  .ghost-btn { min-height: 40px; }
  .cal-cell { min-height: 46px; }
}

/* A global brake: honor reduced-motion across every transition and animation. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

@media (max-width: 560px) {
  /* On a phone the combined header+toolbar is tall; let it scroll away so the
     list gets the full screen rather than pinning a big bar to the top. */
  .topbar { position: static; }
  .cal-detail { scroll-margin-top: 12px; }  /* no pinned bar to clear on mobile */
  .toolbar-inner { gap: 9px; }
  /* Search gets its own full-width row above the compact filter buttons. */
  input[type="search"] { min-width: 0; flex: 1 1 100%; order: -1; }
  .filters { width: 100%; }
  .section-head { position: static; }
  .brand-sub { display: none; }
  .header-inner { flex-wrap: wrap; gap: 10px; }
  .tz-control { font-size: .78rem; }
}
