:root {
  color-scheme: light;
  --ink: #211d1a;
  --ink-soft: #5f5852;
  --paper: #f5f1e8;
  --card: #fffdf8;
  --line: #ddd5c8;
  --brown: #5a2d24;
  --brown-dark: #3d1e19;
  --maps: #236f91;
  --maps-soft: #e4f1f6;
  --red: #c43d3d;
  --red-soft: #f9e2e0;
  --green: #24875a;
  --green-soft: #dff3e8;
  --yellow: #d79a16;
  --yellow-soft: #fff0c8;
  --shadow: 0 12px 34px rgba(43, 31, 23, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, textarea { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.team-intro {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; overflow: hidden;
  background: #000; animation: team-intro-fade 1.8s ease-in forwards;
}
.team-intro img {
  width: min(72vw, 620px); height: auto; display: block;
  animation: team-intro-rush 1.8s cubic-bezier(.45, 0, .9, .62) forwards;
  will-change: transform;
}
@keyframes team-intro-rush {
  0% { transform: scale(.12); }
  72% { transform: scale(1.15); }
  100% { transform: scale(7); }
}
@keyframes team-intro-fade {
  0%, 82% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

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

.site-header {
  min-height: 68px; padding: 10px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--ink); color: white;
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 44px; height: 44px; flex: 0 0 auto; display: block; object-fit: contain;
}
.brand span:last-child { display: grid; line-height: 1.12; }
.brand strong { font-size: 1rem; letter-spacing: .02em; }
.brand small { margin-top: 4px; color: #cfc6bc; font-size: .72rem; }
.header-actions { display: flex; align-items: center; gap: 12px; font-size: .84rem; }
.header-actions a, .link-button { color: inherit; text-decoration: none; }
.header-actions form { margin: 0; }
.link-button { border: 0; padding: 8px 2px; background: none; cursor: pointer; }

.dashboard { width: min(430px, calc(100% - 24px)); margin: 0 auto; padding: 30px 0 80px; }
.admin-shell { width: min(1180px, calc(100% - 24px)); margin: 0 auto; padding: 30px 0 80px; }
.intro { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 6px; color: var(--brown); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.intro h1 { margin-bottom: 4px; font-size: clamp(2rem, 8vw, 2.4rem); line-height: .95; letter-spacing: -.045em; }
.admin-heading h1 { margin-bottom: 4px; font-size: clamp(2rem, 8vw, 3.6rem); line-height: .95; letter-spacing: -.045em; }
.intro-copy { margin: 0; color: var(--ink-soft); }
.sync-state { display: inline-flex; width: fit-content; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .78rem; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.sync-error .sync-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

.identity-bar {
  position: sticky; top: 8px; z-index: 20; padding: 13px 14px; margin: 0 0 16px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  border: 1px solid rgba(90, 45, 36, .18); border-radius: 18px;
  background: rgba(255, 253, 248, .94); box-shadow: 0 8px 24px rgba(45, 31, 24, .12);
  backdrop-filter: blur(12px);
}
.name-field { min-width: 0; flex: 1; display: grid; gap: 4px; }
.name-field > label { font-size: .72rem; font-weight: 800; color: var(--brown); text-transform: uppercase; letter-spacing: .08em; }
.name-picker { position: relative; }
.name-field input { width: 100%; min-height: 44px; padding: 8px 0; border: 0; border-bottom: 2px solid var(--line); background: transparent; font-size: 1.1rem; font-weight: 750; color: var(--ink); outline: none; }
.name-field input:focus { border-color: var(--brown); }
.participant-picker {
  position: absolute; top: calc(100% + 8px); left: -5px; right: -5px; z-index: 40;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  box-shadow: 0 16px 38px rgba(45, 31, 24, .2);
}
.participant-picker > p { margin: 0 2px 9px; color: var(--ink-soft); font-size: .72rem; line-height: 1.35; }
.participant-options { max-height: 260px; display: grid; gap: 6px; overflow-y: auto; }
.participant-option {
  min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: #faf7f0;
  cursor: pointer;
}
.participant-option:hover, .participant-option:focus-within { border-color: var(--brown); background: #f4ece2; }
.participant-option-name { min-width: 0; overflow-wrap: anywhere; font-size: .84rem; font-weight: 750; }
.identity-choice { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; color: var(--brown); font-size: .68rem; font-weight: 800; }
.identity-choice .identity-checkbox { width: 18px; min-height: 18px; height: 18px; padding: 0; border: 1px solid var(--line); accent-color: var(--brown); }
.participant-picker .participant-picker-empty { margin: 4px 2px 0; }

.round-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 5px; margin-bottom: 16px; border-radius: 14px; background: #e8e1d7; }
.round-tabs a { min-height: 42px; display: grid; place-items: center; border-radius: 10px; color: var(--ink-soft); font-size: .82rem; font-weight: 750; text-decoration: none; }
.round-tabs a.active { background: var(--card); color: var(--brown); box-shadow: 0 2px 8px rgba(40, 30, 24, .1); }

.games-head { display: none; }
.games { display: grid; gap: 12px; }
.game-row { position: relative; padding: 18px 18px 18px 35px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: 0 5px 18px rgba(45, 34, 25, .05); }
.game-row.roster-complete { border-color: rgba(36, 135, 90, .52); }
.game-row.roster-incomplete { border-color: rgba(196, 61, 61, .42); }
.game-row.changed { box-shadow: 0 0 0 3px var(--yellow-soft), var(--shadow); }
.game-row.changed::before { content: "Termin geändert"; display: block; width: fit-content; margin: -18px -18px 15px; padding: 6px 12px; border-radius: 0 0 10px 0; background: var(--yellow); color: #2d210d; font-size: .7rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.game-row.locked { background: #eee9e0; }
.roster-status {
  position: absolute; left: 5px; top: 50%; color: var(--red); font-size: .57rem;
  font-weight: 800; letter-spacing: .025em; line-height: 1; writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
}
.roster-complete .roster-status { color: var(--green); }
.game-date-block { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.game-date-block time { display: grid; gap: 2px; }
.game-date-block time strong { font-size: .92rem; }
.game-date-block time span { color: var(--ink-soft); font-size: .82rem; }
.home-away { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; font-size: .66rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.home-away.home { background: var(--brown); color: white; }
.home-away.away { background: #e5ded3; color: var(--ink); }
.game-info h2 { margin: 15px 0 10px; font-size: 1.35rem; line-height: 1.12; letter-spacing: -.025em; }
.venue { margin: 0; color: var(--ink-soft); font-size: .82rem; line-height: 1.35; }
.map-link-shell { position: relative; display: flex; min-width: 0; }
.venue .map-link {
  min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 9px;
  border: 1px solid var(--line); border-radius: 11px; background: #faf7f0; text-decoration: none;
}
.venue .map-link:hover, .venue .map-link:focus-visible { border-color: var(--maps); background: var(--maps-soft); outline: none; }
.has-details .map-link { border-radius: 11px 0 0 11px; }
.map-pin { width: 20px; height: 20px; flex: 0 0 auto; color: var(--maps); }
.map-pin svg { display: block; width: 100%; height: 100%; fill: currentColor; }
.venue-copy { min-width: 0; flex: 1; display: grid; }
.venue-copy strong { overflow: hidden; color: var(--ink); font-size: .8rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.venue-copy small { display: block; overflow: hidden; margin-top: 2px; color: var(--ink-soft); text-overflow: ellipsis; white-space: nowrap; }
.maps-action { flex: 0 0 auto; padding: 4px 7px; border-radius: 8px; background: var(--maps); color: white; font-size: .68rem; font-weight: 800; }
.venue-details-toggle {
  width: 42px; flex: 0 0 auto; border: 1px solid var(--line); border-left: 0;
  border-radius: 0 11px 11px 0; background: #faf7f0; color: var(--maps); font-weight: 900;
  cursor: pointer;
}
.venue-details-toggle:hover, .venue-details-toggle:focus-visible { background: var(--maps-soft); outline: none; }
.venue-popover {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 9px); z-index: 30;
  padding: 12px 14px; border-radius: 12px; background: var(--ink); color: white;
  box-shadow: 0 12px 34px rgba(24, 18, 15, .28); line-height: 1.4;
  opacity: 0; visibility: hidden; transform: translateY(5px); transition: .16s ease;
}
.venue-popover::after {
  content: ""; position: absolute; right: 14px; top: 100%; border: 7px solid transparent;
  border-top-color: var(--ink);
}
.venue-popover strong, .venue-popover span { display: block; }
.venue-popover strong { margin-bottom: 3px; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; }
.details-open .venue-popover { opacity: 1; visibility: visible; transform: translateY(0); }

@media (hover: hover) and (pointer: fine) {
  .has-details:hover .venue-popover, .has-details:focus-within .venue-popover {
    opacity: 1; visibility: visible; transform: translateY(0);
  }
}

.availability { padding: 16px 0; margin-top: 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.availability-details summary { min-height: 44px; display: flex; align-items: center; gap: 14px; list-style: none; cursor: pointer; }
.availability-details summary::-webkit-details-marker { display: none; }
.count-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 1rem; }
.count-chip i { width: 13px; height: 13px; border-radius: 50%; }
.count-chip.yes i { background: var(--green); }
.count-chip.no i { background: var(--red); }
.count-chip.maybe i { background: var(--yellow); }
.count-chip b { min-width: 1ch; font-variant-numeric: tabular-nums; }
.chevron { margin-left: auto; font-size: 1.4rem; transition: transform .2s ease; }
.availability-details[open] .chevron { transform: rotate(180deg); }
.response-details { display: grid; gap: 10px; padding-top: 12px; }
.response-group { display: grid; grid-template-columns: 78px 1fr; gap: 8px; font-size: .82rem; }
.response-group strong { color: var(--ink-soft); }
.response-group p { margin: 0; }

.my-response { padding-top: 16px; }
.response-buttons { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 7px; }
.response-button { min-height: 46px; border: 2px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink); font-weight: 800; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
.response-button:active { transform: scale(.97); }
.response-button.yes.selected { border-color: var(--green); background: var(--green-soft); color: #145c3b; }
.response-button.no.selected { border-color: var(--red); background: var(--red-soft); color: #862727; }
.response-button.maybe.selected { border-color: var(--yellow); background: var(--yellow-soft); color: #76520d; }
.response-button:disabled { opacity: .55; cursor: wait; }
.save-state { min-height: 16px; margin: 5px 2px 0; color: var(--green); font-size: .7rem; text-align: right; }
.locked-note { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; border-radius: 12px; background: #e2dbd0; color: var(--ink-soft); font-size: .82rem; font-weight: 750; }

.parallel-games { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
.parallel-games summary { min-height: 40px; display: flex; align-items: center; gap: 7px; color: var(--brown); font-size: .8rem; font-weight: 800; list-style: none; cursor: pointer; }
.parallel-games summary::-webkit-details-marker { display: none; }
.parallel-games summary .chevron { margin-left: auto; }
.parallel-games[open] summary .chevron { transform: rotate(180deg); }
.parallel-games ul { display: grid; gap: 8px; padding: 10px 0 0; margin: 0; list-style: none; }
.parallel-games li { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 68px 78px; align-items: center; gap: 7px; padding: 9px 10px; border-radius: 10px; background: #f3eee5; font-size: .78rem; }
.parallel-team { min-width: 0; display: grid; }
.parallel-team strong { line-height: 1.2; overflow-wrap: anywhere; }
.parallel-team small { margin-top: 2px; color: var(--ink-soft); }
.parallel-games time { color: var(--ink-soft); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.parallel-games .home-away { width: 78px; display: inline-grid; place-items: center; justify-self: stretch; padding-inline: 0; text-align: center; }

.standings-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 5px 18px rgba(45, 34, 25, .05); }
.standings-scroll { overflow-x: auto; }
.standings-card table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums; }
.standings-card th, .standings-card td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.standings-card thead th { background: #e8e1d7; color: var(--ink-soft); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }
.standings-card tbody th { min-width: 190px; text-align: left; }
.standings-card tbody tr:last-child > * { border-bottom: 0; }
.standings-card tbody tr.own-team > * { background: var(--green-soft); color: #145c3b; }
.standings-card > p { padding: 11px 14px; margin: 0; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .72rem; }

.empty-state { padding: 48px 24px; border: 1px dashed #c8bdae; border-radius: 20px; text-align: center; color: var(--ink-soft); }
.empty-state > span { display: block; margin-bottom: 10px; font-size: 2rem; }
.empty-state h2 { margin-bottom: 6px; color: var(--ink); }

.changes-dialog { width: min(520px, calc(100% - 28px)); max-height: calc(100dvh - 32px); padding: 24px; border: 0; border-radius: 22px; background: var(--card); color: var(--ink); box-shadow: 0 30px 90px rgba(18, 14, 12, .35); }
.changes-dialog::backdrop { background: rgba(24, 20, 18, .72); backdrop-filter: blur(3px); }
.dialog-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 15px; background: var(--yellow-soft); color: #8b5c00; font-size: 1.6rem; }
.changes-dialog h2 { margin-bottom: 8px; font-size: 1.55rem; }
.changes-dialog > p { color: var(--ink-soft); }
.changes-dialog ul { max-height: 42vh; overflow: auto; padding-left: 20px; margin: 18px 0 22px; }
.changes-dialog li { padding: 5px 0; line-height: 1.4; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50; max-width: calc(100% - 28px); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: white; font-size: .85rem; box-shadow: var(--shadow); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.toast[data-kind="error"] { background: #8f2828; }

.primary-button, .secondary-button { min-height: 44px; border-radius: 12px; padding: 9px 16px; font-weight: 800; cursor: pointer; }
.primary-button { border: 1px solid var(--brown); background: var(--brown); color: white; }
.primary-button:hover { background: var(--brown-dark); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
.secondary-button { border: 1px solid var(--line); background: var(--card); color: var(--ink); }

.auth-page { background: #604734; }
.auth-page .site-header { background: transparent; }
.auth-shell { min-height: calc(100vh - 68px); display: grid; place-items: start center; padding: 36px 14px; }
.auth-card { width: min(430px, 100%); padding: 28px 22px; border-radius: 24px; background: var(--card); box-shadow: 0 30px 90px rgba(0, 0, 0, .28); }
.auth-card h1 { margin-bottom: 10px; font-size: clamp(1.8rem, 8vw, 2.5rem); line-height: 1; letter-spacing: -.04em; }
.auth-card > p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.5; }
.stack-form { display: grid; gap: 9px; margin-top: 24px; }
.stack-form label, .admin-form label { font-size: .76rem; font-weight: 800; color: var(--ink-soft); }
.stack-form input, .admin-form input, .admin-form textarea, .participant-row input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); outline: none; }
.admin-form textarea { resize: vertical; }
.stack-form input:focus, .admin-form input:focus, .admin-form textarea:focus, .participant-row input:focus { border-color: var(--brown); box-shadow: 0 0 0 3px rgba(90, 45, 36, .12); }
.form-error { padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: #842727; font-size: .84rem; }
.back-link { display: inline-block; margin-top: 18px; color: var(--ink-soft); font-size: .82rem; }

.flash-stack { position: fixed; top: 76px; left: 50%; z-index: 60; width: min(560px, calc(100% - 24px)); transform: translateX(-50%); }
.flash { padding: 11px 14px; margin-bottom: 7px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: .84rem; }
.flash-success { background: #1c6f49; }
.flash-error { background: #922f2f; }
.flash-warning { background: #8b6417; }

.admin-shell { max-width: 980px; }
.admin-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.admin-card { padding: 20px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 4px 16px rgba(40, 30, 24, .04); }
.admin-card h2 { margin-bottom: 8px; font-size: 1.2rem; }
.admin-card > p, .form-help, .muted { color: var(--ink-soft); font-size: .84rem; line-height: 1.45; }
.sync-card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.sync-card p { margin-bottom: 0; }
.admin-form { display: grid; gap: 12px; margin-top: 18px; }
.admin-form label { display: grid; gap: 5px; }
.form-help { margin: -2px 0 0; }
.participant-list { display: grid; gap: 10px; margin-top: 16px; }
.participant-row { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.participant-row > form:first-child { display: grid; gap: 8px; }
.participant-row > form:first-child > span { color: var(--ink-soft); font-size: .76rem; }
.participant-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.participant-actions form { margin: 0; }
.participant-row.inactive { opacity: .58; background: #eee9e1; }
.danger { color: var(--red); }
.sync-history { display: grid; gap: 8px; margin-top: 14px; }
.sync-history > div { display: grid; grid-template-columns: auto 1fr; gap: 4px 9px; padding: 10px 0; border-top: 1px solid var(--line); font-size: .78rem; }
.sync-history > div > span:nth-of-type(2) { grid-column: 2; color: var(--ink-soft); }
.sync-history small { grid-column: 1 / -1; color: var(--red); white-space: pre-wrap; }
.status-pill { align-self: start; padding: 3px 7px; border-radius: 999px; color: white; font-size: .64rem; font-weight: 800; text-transform: uppercase; }
.status-pill.success { background: var(--green); }
.status-pill.failed { background: var(--red); }
.status-pill.running { background: var(--yellow); color: var(--ink); }

@media (min-width: 620px) {
  .dashboard { width: min(430px, calc(100% - 48px)); padding-top: 42px; }
  .admin-shell { width: min(1180px, calc(100% - 48px)); padding-top: 42px; }
  .auth-shell { place-items: center; padding: 44px 24px; }
  .auth-card { padding: 36px; }
  .admin-heading { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .sync-card { flex-direction: row; align-items: center; justify-content: space-between; }
  .admin-form { grid-template-columns: 1fr 1fr; }
  .admin-form .wide { grid-column: 1 / -1; }
  .participant-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
  .participant-row > form:first-child { grid-template-columns: minmax(180px, 1fr) auto auto; align-items: center; }
  .participant-actions { margin-top: 0; }
}

@media (min-width: 900px) {
  .site-header { padding-inline: 28px; }
}

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