:root {
  --bg: #ffffff; --surface: #f3f5f9; --surface-2: #e8effa; --border: #d5dce6;
  --text: #0f1b2d; --text-muted: #5b6577;
  --brand: #0047ab; --brand-ink: #ffffff;
  --focus: #0047ab; --today: #e8effa;
  --cat-spiele: #0047ab; --cat-spiele-bg: #e8effa;
  --cat-fcl: #00745a; --cat-fcl-bg: #e3f4ef;
  --cat-dritt: #a34700; --cat-dritt-bg: #fceee3;
  --cat-lthal: #8e3b7a; --cat-lthal-bg: #f6e8f2;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --fs-xs: .8125rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;
  --lh: 1.4; --fw-reg: 400; --fw-semi: 600; --fw-bold: 700;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgb(15 27 45 / .08); --sh-2: 0 4px 12px rgb(15 27 45 / .12);
  --dur: 150ms; --ease: cubic-bezier(.2, 0, 0, 1);
  --h-nav: 56px;
  --h-tabbar: 60px;
  --pad: var(--s4);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1421; --surface: #151e2e; --surface-2: #1a2a47; --border: #2a3650;
    --text: #e8edf5; --text-muted: #8691a6;
    --brand: #8ab4ff; --brand-ink: #0d1421; --focus: #ffb800; --today: #1a2a47;
    --cat-spiele: #8ab4ff; --cat-spiele-bg: #1a2a47;
    --cat-fcl: #4fd1b0; --cat-fcl-bg: #12302b;
    --cat-dritt: #ffa35c; --cat-dritt-bg: #33231a;
    --cat-lthal: #e89ad6; --cat-lthal-bg: #2e1e2c;
    --sh-1: none; --sh-2: 0 4px 12px rgb(0 0 0 / .5);
  }
}

@media (min-width: 768px) {
  :root { --pad: var(--s5); }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fw-reg) var(--fs-md) / var(--lh) var(--font);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}

h1, h2, p, ul, dl, dd { margin: 0; }

a { color: var(--brand); }

time, .event__time { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

a, button, summary {
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.skip-link {
  position: absolute;
  top: var(--s2);
  left: var(--s2);
  z-index: 20;
  padding: var(--s3) var(--s4);
  background: var(--bg);
  color: var(--brand);
  font-weight: var(--fw-semi);
  border-radius: var(--r-sm);
  transform: translateY(-200%);
}

.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: var(--brand-ink);
}

.site-header a { color: inherit; }

.site-header :focus-visible { outline-color: var(--brand-ink); }

.site-name {
  max-width: 720px;
  min-height: var(--h-nav);
  margin: 0 auto;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.site-name a { text-decoration: none; }

.month-nav, .detail-nav {
  max-width: 720px;
  min-height: var(--h-nav);
  margin: 0 auto;
  padding: var(--s1) calc(var(--pad) - var(--s2));
  display: grid;
  align-items: center;
}

.month-nav {
  grid-template-columns: 48px 1fr auto 48px;
  grid-template-areas: "prev title today next";
}

.month-nav h1 {
  grid-area: title;
  min-width: 0;
  text-align: center;
  font-size: clamp(.9375rem, 4.2vw, var(--fs-xl));
  font-weight: var(--fw-bold);
  line-height: 1.2;
  overflow-wrap: normal;
}

.month-nav__prev { grid-area: prev; }
.month-nav__next { grid-area: next; }

.month-nav__link {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  font-size: 0;
  text-decoration: none;
}

.month-nav__prev::before { content: "‹"; content: "‹" / ""; }
.month-nav__next::before { content: "›"; content: "›" / ""; }

.month-nav__link::before {
  font-size: var(--fs-2xl);
  line-height: 1;
}

.month-nav__link[aria-disabled="true"] {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  cursor: not-allowed;
}

.month-nav__today {
  grid-area: today;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s2);
  margin: 0 var(--s1);
  border: 1px solid currentColor;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  text-decoration: none;
}

.detail-nav { grid-template-columns: auto 1fr; }

.detail-nav__back {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 var(--s2);
  border-radius: var(--r-md);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  text-decoration: none;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--pad) var(--s4);
}

main > h1 {
  margin: var(--s6) 0 var(--s3);
  font-size: var(--fs-2xl);
  line-height: 1.2;
}

main > p { margin-bottom: var(--s3); }

.banner {
  margin: var(--s4) 0 0;
  padding: var(--s3) var(--s4);
  background: var(--cat-dritt-bg);
  color: var(--text);
  border-left: 4px solid var(--cat-dritt);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
}

.tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgb(15 27 45 / .06);
}

body:has(.tabbar) { padding-bottom: calc(var(--h-tabbar) + env(safe-area-inset-bottom)); }

.tabbar__tab {
  flex: 1;
  max-width: 240px;
  min-height: var(--h-tabbar);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  text-decoration: none;
}

.tabbar__icon {
  width: 48px;
  height: 28px;
  padding: 3px 12px;
  border-radius: var(--r-pill);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar__tab[aria-current] {
  color: var(--brand);
  font-weight: var(--fw-bold);
}

.tabbar__tab[aria-current] .tabbar__icon { background: var(--surface-2); }

.tabbar__tab:focus-visible { outline-offset: -3px; }

.empty {
  margin: var(--s5) 0;
  color: var(--text-muted);
}

.empty a {
  display: inline-block;
  min-height: 44px;
  padding: var(--s3) 0;
  font-weight: var(--fw-semi);
}

.past-days {
  margin-top: var(--s3);
  border-bottom: 1px solid var(--border);
}

.past-days > summary {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 48px;
  padding: var(--s2) 0;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  cursor: pointer;
  list-style: none;
}

.past-days > summary::-webkit-details-marker { display: none; }

.past-days > summary::before {
  content: "▸";
  content: "▸" / "";
  flex: none;
  transition: transform var(--dur) var(--ease);
}

.past-days[open] > summary::before { transform: rotate(90deg); }

.day {
  scroll-margin-top: var(--h-nav);
}

.day__header {
  position: sticky;
  top: var(--h-nav);
  z-index: 2;
  padding: var(--s3) 0 var(--s2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  background: var(--bg);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  letter-spacing: .04em;
  scroll-margin-top: var(--h-nav);
}

.pill {
  display: inline-block;
  padding: 2px var(--s2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  line-height: 1.4;
}

.pill--today {
  background: var(--brand);
  color: var(--brand-ink);
}

.day--today {
  margin: var(--s3) calc(-1 * var(--s3)) 0;
  padding: 0 var(--s3) var(--s2);
  background: var(--today);
  border-radius: var(--r-lg);
}

.day--today .day__header {
  background: var(--today);
  color: var(--brand);
  padding-bottom: calc(var(--s2) - 1px);
  border-bottom: 2px solid var(--brand);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.day__status {
  padding: var(--s1) 0;
  font-size: var(--fs-sm);
}

.day__status a {
  padding-block: var(--s2);
  font-weight: var(--fw-semi);
}

.day__empty {
  padding: var(--s4) 0;
  color: var(--text-muted);
}

.events {
  padding: 0;
  list-style: none;
}

.event {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  grid-template-areas: "time body marker";
  align-items: start;
  column-gap: var(--s3);
  min-height: 56px;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.event__time {
  grid-area: time;
  display: flex;
  flex-direction: column;
  font-family: var(--font-num);
}

.event__start {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
}

.event__end {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.event__over {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.event__body {
  grid-area: body;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.event__title {
  font-weight: var(--fw-semi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event__meta {
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event .marker {
  grid-area: marker;
  justify-self: end;
  margin-top: 2px;
}

.marker {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 2px var(--s2);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  white-space: nowrap;
}

.marker--spiele { background: var(--cat-spiele-bg); color: var(--cat-spiele); }
.marker--fcl { background: var(--cat-fcl-bg); color: var(--cat-fcl); }
.marker--dritt { background: var(--cat-dritt-bg); color: var(--cat-dritt); }
.marker--lthal { background: var(--cat-lthal-bg); color: var(--cat-lthal); }

.event--match {
  padding-left: var(--s3);
  padding-right: var(--s3);
  margin-top: var(--s1);
  background: var(--cat-spiele-bg);
  border-left: 4px solid var(--cat-spiele);
  border-bottom-color: transparent;
  border-radius: var(--r-md);
}

.event--match .event__title { font-weight: var(--fw-bold); }

.event--match .marker { border-color: var(--cat-spiele); }

.day--past .event,
.days--past .event,
.event--over {
  color: var(--text-muted);
}

.day--past .marker,
.days--past .marker,
.event--over .marker {
  background: transparent;
  border-color: currentColor;
}

.day--past .event--match,
.days--past .event--match,
.event--match.event--over {
  background: transparent;
  border-left-width: 2px;
}

.day--past .event__title,
.days--past .event__title,
.event--over .event__title {
  font-weight: var(--fw-semi);
}

@media (max-width: 479px) {
  .event {
    grid-template-areas: "time body";
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .event .marker, .event--over :is(.event__info, .event__end) { display: none; }

  .event--over {
    min-height: 48px;
    padding-block: var(--s1);
  }
}

.card {
  margin-top: var(--s5);
  padding: var(--s5);
  background: var(--surface);
  border-top: 4px solid var(--text-muted);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow-wrap: anywhere;
}

.card--spiele { border-top-color: var(--cat-spiele); }
.card--fcl { border-top-color: var(--cat-fcl); }
.card--dritt { border-top-color: var(--cat-dritt); }
.card--lthal { border-top-color: var(--cat-lthal); }

.card h1 {
  margin-top: var(--s3);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: 1.2;
}

.card__subtitle {
  margin-top: var(--s1);
  font-size: var(--fs-lg);
  color: var(--text-muted);
}

.facts { margin-top: var(--s5); }

.facts dd + dt { margin-top: var(--s4); }

.facts dd { margin-top: 2px; }

.facts dt {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.facts dd { font-size: var(--fs-lg); }

.facts__note {
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  white-space: pre-line;
}

.back { margin-top: var(--s5); }

.back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: var(--fw-semi);
}

.cal {
  table-layout: fixed;
  border-collapse: collapse;
  width: calc(100% + 2 * var(--pad) - 2 * var(--s1));
  margin: var(--s2) calc(var(--s1) - var(--pad)) 0;
}

.cal th {
  height: 28px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--text-muted);
}

.cal td {
  height: 52px;
  padding: 1px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.cal__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 50px;
  padding: var(--s1) 0;
  color: var(--text);
}

.cal__num {
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.mark--spiele { color: var(--cat-spiele); }
.mark--fcl { color: var(--cat-fcl); }
.mark--dritt { color: var(--cat-dritt); }
.mark--lthal { color: var(--cat-lthal); }

.cal__day--today .cal__num {
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: var(--fw-semi);
}

.cal__day--past .cal__num { color: var(--text-muted); }

.cal__chips {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chip {
  display: block;
  min-width: 0;
  overflow: hidden;
  padding: 1px 2px;
  border-radius: 3px;
  background: var(--cat-spiele);
  color: var(--brand-ink);
  font-size: .6875rem;
  line-height: 1.2;
  text-align: left;
  overflow-wrap: normal;
}

.cal__day--past .chip {
  background: var(--surface);
  color: var(--text-muted);
}

.chip__time {
  display: block;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
}

.chip__time > span {
  display: block;
  white-space: nowrap;
}

.chip__time--day { hyphens: manual; }

.chip__team {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip__line {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.chip__full { display: none; }

@media (max-width: 359px) {
  .cal td { padding: 1px 0; }
  .chip { padding-inline: 1px; }
  .chip__time { letter-spacing: -.07em; }
}

.cal td[id] { scroll-margin-top: calc(var(--h-nav) + var(--s2)); }

.chip { text-decoration: none; }

.chip:focus-visible { outline-offset: 1px; }

.sheet {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: none;
  max-height: 90dvh;
  margin: 0;
  padding: 0;
  display: none;
  flex-direction: column;
  border: 0;
  border-radius: 14px 14px 0 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--sh-2);
  overscroll-behavior: contain;
}

.sheet[open] { display: flex; }

html:has(.sheet[open]) { overflow: hidden; }

.sheet::backdrop { background: rgb(0 0 0 / .45); }

.sheet__bar {
  position: relative;
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 52px;
  padding: var(--s1) var(--s2) 0;
  touch-action: none;
  cursor: grab;
}

.sheet__grabber {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 40px;
  height: 5px;
  margin-left: -20px;
  border-radius: var(--r-pill);
  background: var(--border);
}

.sheet__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.sheet__close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
}

.sheet__close:active { transform: scale(.94); }

.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--pad) calc(var(--s5) + env(safe-area-inset-bottom));
}

.sheet .card {
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.sheet .card h1 { margin-top: var(--s2); }

.sheet .back { display: none; }

@media (min-width: 768px) {
  .sheet {
    max-width: 560px;
    margin-inline: auto;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (hover: hover) {
  .event:hover { background: var(--surface); }
  .event--match:hover { background: var(--surface-2); }
  .tabbar__tab:not([aria-current]):hover { color: var(--text); }
  .past-days > summary:hover { color: var(--text); }
  .chip:hover { filter: brightness(1.15); }
}

.event:active { background: var(--surface-2); transform: scale(.98); }
.chip:active { transform: scale(.96); }
.month-nav__link:not([aria-disabled]):active { transform: scale(.98); }

@media (min-width: 360px) {
  .month-nav { grid-template-columns: auto 1fr auto auto; }

  .month-nav__link {
    width: auto;
    min-width: 44px;
    padding: 0 var(--s1);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    white-space: nowrap;
  }

  .month-nav__link::before { content: none; }

  .month-nav__today { margin: 0 2px; }
}

@media (min-width: 480px) {
  .event {
    grid-template-areas: "time title marker" "time info marker";
    align-content: start;
  }

  .event__body, .event__meta { display: contents; }

  .event__title { grid-area: title; }

  .event__info {
    grid-area: info;
    font-size: var(--fs-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (min-width: 768px) {
  .cal { width: 100%; margin-inline: 0; }
  .cal td { height: 96px; }
  .cal__day { align-items: stretch; min-height: 94px; padding: var(--s1) var(--s1) var(--s1) var(--s2); }


  .chip {
    padding: 2px var(--s1);
    font-size: var(--fs-xs);
  }

  .chip__time > span { display: inline; }
  .chip__short { display: none; }

  .chip__full {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }

  .month-nav__link {
    padding: 0 var(--s3);
    font-size: var(--fs-md);
  }

  .event {
    grid-template-columns: 72px minmax(0, 1fr) minmax(0, 200px) 11.5rem;
    grid-template-areas: "time title info marker";
  }

  .event__title { white-space: normal; }

  .event__info {
    grid-area: info;
    padding-top: 2px;
  }

}

@media (min-width: 1024px) {
  body:has(.cal) :is(.month-nav, main) { max-width: 1200px; }
}

@media (max-height: 520px), (max-width: 300px) {
  .site-header, .day__header { position: static; }
  .day, .day__header, .cal td[id] { scroll-margin-top: 0; }
}

@media (max-width: 300px) {
  .month-nav {
    grid-template-columns: 48px 1fr 48px;
    grid-template-areas: "title title title" "prev today next";
  }

  .month-nav__today { justify-self: center; }
  .event__title { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
