:root {
  --navy: #030a37;
  --navy-soft: #25386f;
  --blue: #43578f;
  --ink: #111425;
  --muted: #667085;
  --paper: #ffffff;
  --wash: #f2f4f8;
  --line: #dce1eb;
  --success: #198754;
  --amber: #b26b00;
}

* { box-sizing: border-box; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 12px 16px;
  color: white;
  background: var(--navy);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--wash);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(24px, 5vw, 72px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.96);
  box-shadow: 0 2px 12px rgba(3,10,55,.08);
}
.brand { display: flex; align-items: center; gap: 22px; color: var(--ink); text-decoration: none; }
.brand img { width: 76px; height: 76px; object-fit: contain; }
.brand span { display: flex; flex-direction: column; }
.brand strong { font-size: 25px; letter-spacing: -.02em; }
.brand small { margin-top: 12px; color: #151515; font-size: 16px; font-weight: 700; }
.source-link {
  color: var(--navy);
  text-decoration: none;
  border: 2px solid var(--navy);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  transition: .2s ease;
}
.source-link:hover { color: white; background: var(--navy); }
.legal-back { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.legal-back span { font-size: 20px; line-height: 1; }
.handballnet-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  object-fit: contain;
  vertical-align: middle;
}
.source-link .handballnet-icon { margin-left: 8px; }

main { width: min(1180px, calc(100% - 40px)); margin: auto; }
.scoreboard {
  min-height: 390px;
  margin: 28px 0 24px;
  padding: 46px clamp(26px, 5vw, 66px);
  display: grid;
  grid-template-columns: minmax(0,1.5fr) minmax(300px,.7fr);
  align-items: end;
  gap: 42px;
  color: white;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(90deg, rgba(3,10,55,.96) 0%, rgba(17,35,86,.86) 52%, rgba(31,52,106,.62) 100%),
    url("/assets/spieltag-hintergrund.jpg") center 42% / cover;
}
.scoreboard:after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255,255,255,.35);
  pointer-events: none;
}
.scoreboard-copy, .scoreboard-stats { position: relative; z-index: 1; }
.eyebrow {
  display: inline-block;
  padding: 8px 11px;
  color: var(--navy);
  background: white;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
}
h1, h2 { margin-top: 0; color: inherit; font-family: Arial, Helvetica, sans-serif; }
h1 {
  margin: 28px 0 18px;
  font-size: clamp(52px, 7vw, 88px);
  line-height: .92;
  letter-spacing: -.055em;
}
h1 em { color: white; font-style: normal; font-weight: 400; }
.scoreboard-copy p { max-width: 610px; margin: 0; font-size: 17px; line-height: 1.55; }
.scoreboard-stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  background: white;
  color: var(--navy);
  box-shadow: 0 18px 45px rgba(0,0,0,.2);
}
.scoreboard-stats div { padding: 24px 8px; text-align: center; border-right: 1px solid var(--line); }
.scoreboard-stats div:last-child { border: 0; }
.scoreboard-stats strong { display: block; font-size: 38px; }
.scoreboard-stats span { display: block; margin-top: 4px; color: #5b6380; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }

.controls {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  background: white;
  border-top: 5px solid var(--navy);
  box-shadow: 0 8px 26px rgba(3,10,55,.08);
}
.tabs { display: flex; gap: 4px; overflow: auto; }
.tab {
  border: 0;
  background: transparent;
  color: #646b7c;
  padding: 13px 17px;
  font: 700 14px Arial, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--navy); background: #f3f5f9; }
.tab.active { color: white; background: var(--navy); }
.team-filter { position: relative; display: flex; min-width: 176px; }
.team-filter:after {
  content: "⌄";
  position: absolute;
  right: 13px;
  top: 50%;
  color: var(--navy);
  pointer-events: none;
  transform: translateY(-55%);
}
.team-filter select {
  width: 100%;
  appearance: none;
  border: 1px solid #d7dce7;
  border-radius: 0;
  padding: 12px 36px 12px 14px;
  color: var(--navy);
  background: #f3f5f9;
  font: 700 14px Arial, sans-serif;
  cursor: pointer;
}
.team-filter select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.search {
  width: 300px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  color: var(--navy);
  background: var(--wash);
  border-bottom: 2px solid var(--navy);
}
.search input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 13px 8px;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
}
.search input::placeholder { color: #798091; }
.week-nav {
  margin-top: 14px;
  min-height: 78px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: stretch;
  color: white;
  background: var(--navy);
  box-shadow: 0 8px 26px rgba(3,10,55,.1);
}
.week-nav[hidden] { display: none; }
.week-nav button {
  border: 0;
  color: white;
  background: rgba(255,255,255,.08);
  font: 400 38px/1 Arial, sans-serif;
  cursor: pointer;
}
.week-nav button:hover:not(:disabled) { background: var(--blue); }
.week-nav button:disabled { cursor: default; opacity: .3; }
.week-nav button:focus-visible { outline: 3px solid white; outline-offset: -5px; }
.week-copy { display: grid; place-content: center; gap: 5px; padding: 12px 18px; text-align: center; }
.week-copy span { color: #bfc8e2; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.week-copy strong { font-size: 20px; letter-spacing: -.01em; }
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 22px 2px 10px; color: var(--muted); font-size: 12px; }
.status-row p { display: flex; align-items: center; gap: 9px; }
.status-timestamp { white-space: nowrap; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(25,135,84,.11); }
#refreshBtn { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; border: 0; color: var(--navy); background: none; cursor: pointer; font: 700 12px/1.25 Arial,sans-serif; text-align: right; }
#refreshBtn:disabled { cursor: wait; opacity: .55; }
.refresh-icon { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#refreshBtn.is-refreshing .refresh-icon { animation: refresh-spin .7s ease-in-out; }
@keyframes refresh-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.status-row .error { color: #a42a2a; }
.status-row:has(.error) .pulse { background: #c43939; box-shadow: 0 0 0 4px rgba(196,57,57,.11); }

.data-notice {
  margin: 8px 0 20px;
  padding: 16px 18px;
  color: #5f3b00;
  background: #fff7e6;
  border: 1px solid #e3bd72;
  border-left: 7px solid var(--amber);
}
.data-notice[hidden] { display: none; }
.data-notice strong { display: block; color: #4d3100; }
.data-notice p { margin: 5px 0 0; line-height: 1.5; }
.data-notice.is-error { color: #611a1a; background: #fff5f5; border-color: #e5b7b7; border-left-color: #b42318; }
.data-notice.is-error strong { color: #7f1d1d; }

.api-error {
  margin: 8px 0 20px;
  padding: 20px 22px;
  color: #611a1a;
  background: #fff5f5;
  border: 1px solid #e5b7b7;
  border-left: 7px solid #b42318;
  box-shadow: 0 5px 18px rgba(97,26,26,.08);
}
.api-error[hidden] { display: none; }
.api-error-copy strong { display: block; color: #7f1d1d; font-size: 18px; }
.api-error-copy p { margin: 7px 0 0; line-height: 1.5; }
.api-error details { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e5b7b7; }
.api-error summary { cursor: pointer; color: #7f1d1d; font-weight: 700; }
.api-error details > p { margin: 12px 0; color: #5e2a2a; font-size: 14px; }
.api-error dl { display: flex; flex-wrap: wrap; gap: 12px 30px; margin: 0; }
.api-error dl div { display: grid; gap: 3px; }
.api-error dt { color: #8b5757; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.api-error dd { margin: 0; font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; }
.api-error ul { margin: 14px 0 0; padding-left: 20px; }
.api-error li { margin-top: 8px; }
.api-error li code { display: block; color: #7f1d1d; }
.api-error li span { display: block; margin-top: 2px; color: #6f4545; font-size: 13px; }

.games { display: grid; gap: 10px; padding-bottom: 34px; }
.day-heading {
  margin: 26px 0 5px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--navy);
  font-size: 23px;
  letter-spacing: -.02em;
}
.day-heading:after { content: ""; height: 3px; flex: 1; background: var(--navy); }
.game {
  display: grid;
  grid-template-columns: 150px minmax(0,1fr) 140px minmax(0,1fr) 170px;
  align-items: center;
  gap: 22px;
  padding: 18px 20px;
  background: white;
  border: 1px solid var(--line);
  border-left: 7px solid var(--navy);
  box-shadow: 0 3px 14px rgba(3,10,55,.045);
}
.meta small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.meta strong { color: var(--navy); font-size: 15px; }
.team { display: flex; align-items: center; gap: 12px; min-width: 0; }
.team.hsg { color: var(--navy); font-weight: 800; }
.crest {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: #eef1f7;
  border: 1px solid #d0d6e4;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}
.team.hsg .crest { color: white; background: var(--navy); border-color: var(--navy); }
.crest.has-logo { overflow: visible; background: transparent; border-color: transparent; border-radius: 0; }
.team.hsg .crest.has-logo { background: transparent; border-color: transparent; }
.crest.has-logo .crest-fallback { display: none; }
.crest img { width: 100%; height: 100%; display: block; object-fit: contain; }
.team-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.team-name { overflow: hidden; text-overflow: ellipsis; }
.standing { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.2; white-space: nowrap; }
.score { text-align: center; }
.score-link { display: block; padding: 10px 8px; color: inherit; border: 1px solid transparent; text-decoration: none; transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
.score-link:hover { border-color: var(--blue); background: #f5f7fb; box-shadow: 0 0 0 2px rgba(67,87,143,.14); }
.score-link:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.score strong { display: block; color: var(--navy); line-height: 1; }
.result-value { font-size: 35px; }
.score time { color: var(--muted); font-size: 11px; }
.score.has-kickoff {
  padding: 10px 8px;
  background: #f2f4f9;
  border: 1px solid #d9dfec;
}
.score.has-kickoff .badge { margin-bottom: 9px; }
.score.has-pending-result {
  padding: 10px 8px;
  background: #f2f3f5;
  border: 1px solid #d8dbe2;
}
.score.has-pending-result .badge { margin-bottom: 8px; }
.result-pending { display: block; color: var(--navy); font-size: 15px; line-height: 1.1; }
.result-note { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.2; }
.kickoff-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.kickoff-value { font-size: 23px; letter-spacing: -.02em; }
.kickoff-value small { font-size: 11px; font-weight: 700; letter-spacing: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 7px; font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.badge:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.finished { color: var(--success); }
.badge.upcoming { color: var(--amber); }
.badge.played_no_result { color: #667085; }
.badge.live { color: #c51f32; }
.badge.live:before { animation: live-pulse 1.2s ease-out infinite; }
.place { text-align: right; }
.place strong { display: block; overflow: hidden; color: var(--navy); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.place span { display: flex; align-items: center; justify-content: flex-end; gap: 3px; color: var(--muted); font-size: 11px; }
.details-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--navy); font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.details-link:hover { text-decoration-thickness: 2px; }
.place .handballnet-icon { width: 14px; height: 14px; margin-left: 3px; }
.empty { padding: 70px 20px; color: var(--muted); background: white; border: 1px dashed var(--line); text-align: center; }
.empty strong { display: block; margin-bottom: 8px; color: var(--navy); }

.live-note {
  margin: 42px 0 70px;
  padding: 38px 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: white;
  background: var(--navy);
  border-bottom: 8px solid var(--blue);
}
.live-note>div { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center; }
.live-note h2 { margin: 0; font-size: 32px; }
.live-note p { grid-column: 2; max-width: 650px; margin: 6px 0 0; color: #d7dced; font-size: 14px; }
.live-mark { padding: 9px 10px; color: var(--navy); background: white; font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.live-note a { padding: 14px 18px; display: inline-flex; align-items: center; gap: 8px; color: var(--navy); background: white; font-size: 13px; font-weight: 800; text-decoration: none; white-space: nowrap; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 30px max(20px,calc((100% - 1180px)/2));
  color: white;
  background: var(--navy);
  font-size: 12px;
}
footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
footer a { color: white; text-underline-offset: 3px; }

.legal-main { width: min(900px, calc(100% - 40px)); margin: 44px auto 80px; }
.legal-hero { margin-bottom: 26px; padding: clamp(28px, 6vw, 58px); color: white; background: linear-gradient(120deg, var(--navy), var(--blue)); border-bottom: 8px solid #8fa0ca; }
.legal-hero .eyebrow { margin-bottom: 20px; }
.legal-hero h1 { margin: 0 0 14px; font-size: clamp(42px, 7vw, 72px); }
.legal-hero p { max-width: 680px; margin: 0; color: #e4e8f3; font-size: 16px; line-height: 1.55; }
.legal-card { margin-top: 16px; padding: clamp(22px, 4vw, 38px); background: white; border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(3,10,55,.06); }
.legal-card h2 { margin: 0 0 14px; color: var(--navy); font-size: 25px; }
.legal-card h3 { margin: 26px 0 8px; color: var(--navy); font-size: 18px; }
.legal-card p, .legal-card li { font-size: 16px; line-height: 1.65; }
.legal-card p { margin: 10px 0; }
.legal-card ul { padding-left: 22px; }
.legal-card a { color: var(--navy); text-underline-offset: 3px; }
.legal-card a { overflow-wrap: anywhere; }
.legal-meta { color: var(--muted); font-size: 14px !important; }
.privacy-status { padding: 18px 20px; color: #0f5132; background: #eaf6ef; border-left: 6px solid var(--success); }
.privacy-status strong { display: block; margin-bottom: 5px; }

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(197,31,50,.5); }
  70% { box-shadow: 0 0 0 7px rgba(197,31,50,0); }
  100% { box-shadow: 0 0 0 0 rgba(197,31,50,0); }
}

:where(a, button, input, select, summary):focus-visible {
  outline: 3px solid #5269aa;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .score-link:hover { box-shadow: none; }
}

@media (max-width: 900px) {
  .scoreboard { grid-template-columns: 1fr; }
  .scoreboard-stats { max-width: 520px; }
  .controls { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .game { grid-template-columns: 92px 1fr 86px 1fr; }
  .place { grid-column: 2/5; padding-top: 12px; border-top: 1px solid var(--line); text-align: left; }
  .place span { justify-content: flex-start; }
  .live-note { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .topbar { height: 76px; padding: 0 14px; position: static; }
  .brand { gap: 11px; }
  .brand img { width: 50px; height: 50px; }
  .brand strong { font-size: 17px; }
  .brand small { margin-top: 4px; font-size: 10px; }
  .source-link { width: 42px; height: 42px; display: grid; place-items: center; padding: 0; font-size: 0; }
  .source-link.legal-back { width: auto; min-width: 82px; height: 44px; display: inline-flex; padding: 0 12px; font-size: 13px; }
  .source-link.legal-back span { font-size: 19px; }
  .source-link .handballnet-icon { width: 26px; height: 26px; margin: 0; }
  main { width: min(100% - 24px, 1180px); }
  .scoreboard { min-height: 0; margin: 12px 0; padding: 18px 16px; gap: 0; background-position: 59% center; }
  .scoreboard:after { inset: 8px; }
  .eyebrow { padding: 6px 8px; font-size: 9px; }
  h1 { margin: 15px 0 10px; font-size: 36px; line-height: .9; }
  .scoreboard-copy p { font-size: 14px; line-height: 1.35; }
  .scoreboard-stats { display: none; }
  .scoreboard-stats strong { font-size: 24px; }
  .scoreboard-stats span { font-size: 10px; }
  .scoreboard-stats div { padding: 10px 3px; }
  .controls { padding: 12px; gap: 12px; }
  .week-nav { min-height: 68px; grid-template-columns: 52px minmax(0, 1fr) 52px; }
  .week-copy { padding: 10px 8px; }
  .week-copy strong { font-size: 16px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; overflow: visible; }
  .tab { width: 100%; padding: 11px 6px; font-size: 13px; }
  .team-filter { min-width: 0; }
  .team-filter select { padding: 10px 28px 10px 8px; font-size: 13px; }
  .team-filter:after { right: 9px; }
  .status-row p { max-width: 68%; line-height: 1.4; }
  #refreshBtn { min-width: 44px; min-height: 44px; padding: 6px 0 6px 8px; }
  .game { grid-template-columns: minmax(0,1fr) 108px; gap: 10px 12px; padding: 14px; border-left-width: 5px; }
  .meta { grid-column: 1/3; display: flex; justify-content: space-between; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .meta strong { text-align: right; }
  .team { grid-column: 1; }
  .team.away { grid-column: 1; }
  .crest { width: 40px; height: 40px; }
  .score { grid-column: 2; grid-row: 2/4; align-self: center; padding-right: 2px; }
  .result-value { font-size: 32px; }
  .score.has-kickoff { padding: 10px 6px; }
  .kickoff-value { font-size: 21px; }
  .place { grid-column: 1/3; padding-top: 10px; }
  .live-note { padding: 28px 24px; }
  .live-note>div { display: block; }
  .live-mark { display: inline-block; margin-bottom: 14px; }
  .live-note h2 { font-size: 28px; }
  .live-note p { margin-top: 8px; }
  footer { flex-direction: column; gap: 12px; }
  footer nav { justify-content: flex-start; }
  .legal-main { width: min(100% - 24px, 900px); margin-top: 12px; }
  .legal-hero { padding: 28px 22px; }
  .legal-card { padding: 22px 18px; }
}

@media (max-width: 360px) {
  .status-row { align-items: flex-start; gap: 8px; }
  .status-row p { max-width: none; margin-right: auto; }
  #refreshBtn { max-width: 112px; }
  .day-heading { font-size: 21px; overflow-wrap: anywhere; }
  .game { padding: 12px 10px; grid-template-columns: minmax(0,1fr) 98px; }
  .team { gap: 9px; }
  .crest { width: 38px; height: 38px; }
}
