/* TuS Roisdorf Alte Herren – Spielerverwaltung */

:root {
  /* Vereinsfarben aus dem Wappen: Schwarz, Gelb, Weiß */
  --club: #141414; /* Kopfleiste */
  --club-dark: #232323; /* Navigation */
  --on-club: #ffffff;
  --accent: #f5d000; /* Wappen-Gelb: Schaltflächen, Markierungen */
  --accent-dark: #e0be00;
  --on-accent: #141414;
  --club-soft: #fdf4c4; /* helles Gelb für Flächen */
  --link: #6f5a00; /* dunkles Gold: auf Weiß gut lesbar */

  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #f0f0ee;
  --text: #171717;
  --muted: #62625e;
  --border: #dededa;

  --win: #1f7a43;
  --win-soft: #dff2e5;
  --draw: #6b7280;
  --draw-soft: #e9ebee;
  --loss: #b3261e;
  --loss-soft: #fbe4e2;
  --info: #1d4f91;
  --info-soft: #e3edf9;
  --warn: #8a5a00;
  --warn-soft: #fdf0d2;

  --yellow: #f2c200;
  --red: #d32f2f;

  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --club: #000000;
    --club-dark: #1a1a1a;
    --club-soft: #3a3206;
    --link: #f5d000;
    --bg: #121212;
    --surface: #1c1c1c;
    --surface-2: #262626;
    --text: #ededed;
    --muted: #a3a3a3;
    --border: #343434;
    --win: #5fce88;
    --win-soft: #16351f;
    --draw: #aab1b9;
    --draw-soft: #2a2f35;
    --loss: #ff8a80;
    --loss-soft: #3d1a18;
    --info: #8ab8f5;
    --info-soft: #16263b;
    --warn: #f0c060;
    --warn-soft: #3a2c0c;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 0.75rem;
}

small,
.small {
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
}

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

/* ---------- Kopf & Navigation ---------- */

.site-header {
  background: var(--club);
  color: var(--on-club);
}

.header-inner,
.nav-inner,
.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  white-space: nowrap;
}

.brand-text span {
  font-size: 0.8rem;
  opacity: 0.85;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-name {
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44vw;
}

@media (max-width: 520px) {
  .user-name {
    max-width: 26vw;
  }

  .user-name .badge {
    display: none;
  }

  .nav-inner {
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
}

.site-header .btn-ghost {
  color: var(--on-club);
  border-color: rgb(255 255 255 / 45%);
}

.nav {
  background: var(--club-dark);
}

.nav-inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-inner::-webkit-scrollbar {
  display: none;
}

.nav a {
  flex: none;
  padding: 10px 12px;
  color: rgb(255 255 255 / 80%);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
}

.nav a:hover,
.nav a.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.container {
  flex: 1;
  padding-top: 20px;
  padding-bottom: 40px;
}

.site-footer {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- Bausteine ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head p {
  margin: 4px 0 0;
}

.breadcrumb {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.breadcrumb a {
  text-decoration: none;
}

.section-title {
  margin: 24px 0 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card > h2 {
  margin-bottom: 12px;
}

.card.narrow {
  max-width: 480px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-head a {
  font-size: 0.9rem;
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.grid-2 > .card {
  margin-bottom: 0;
}

@media (min-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-dark) 80%, var(--text));
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-danger {
  color: var(--loss);
  border-color: color-mix(in srgb, var(--loss) 45%, var(--border));
}

.btn-danger:hover {
  background: var(--loss-soft);
}

.btn-ghost {
  background: transparent;
}

.btn-small {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
  white-space: nowrap;
}

.badge-role {
  background: rgb(255 255 255 / 22%);
  color: inherit;
}

.card .badge-role {
  background: var(--club-soft);
  color: var(--link);
}

.badge-win {
  background: var(--win-soft);
  color: var(--win);
}

.badge-planned {
  background: var(--info-soft);
  color: var(--info);
}

.badge-pending,
.badge-verletzt {
  background: var(--warn-soft);
  color: var(--warn);
}

.alert {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert ul {
  margin: 0;
  padding-left: 1.2rem;
}

.alert-success {
  background: var(--win-soft);
  color: var(--win);
  border-color: color-mix(in srgb, var(--win) 30%, transparent);
}

.alert-error {
  background: var(--loss-soft);
  color: var(--loss);
  border-color: color-mix(in srgb, var(--loss) 30%, transparent);
}

.alert-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

.alert-info a {
  color: inherit;
}

.alert-link {
  text-decoration: none;
  font-weight: 600;
}

/* ---------- Kennzahlen ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 760px) {
  .tiles {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.tile-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.record-line {
  margin-top: -4px;
}

/* ---------- Formulare ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field small {
  color: var(--muted);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
input[type='number'],
input[type='date'],
input[type='time'],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 560px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.form-inline {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}

@media (min-width: 760px) {
  .form-inline {
    grid-template-columns: 1.2fr 1fr 1fr auto;
  }
}

.below-form {
  margin-top: 10px;
}

.card + .below-form {
  margin-top: -6px;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.filters .field {
  flex: 1 1 140px;
  max-width: 260px;
}

fieldset {
  min-width: 0;
  margin: 0;
}

.result-fields {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.result-fields legend {
  padding: 0 6px;
  font-weight: 700;
}

.result-fields small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.result-fields.is-off {
  opacity: 0.55;
}

.auth-card {
  max-width: 420px;
  margin: 24px auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-card p {
  margin: 0;
}

.auth-switch {
  text-align: center;
}

.error-code {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px 20px;
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------- Avatare ---------- */

.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
  background: var(--club-soft);
  color: var(--link);
  font-weight: 800;
  overflow: hidden;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.avatar-md {
  width: 52px;
  height: 52px;
  font-size: 1rem;
}

.avatar-lg {
  width: 84px;
  height: 84px;
  font-size: 1.5rem;
}

.avatar-xl {
  width: 128px;
  height: 128px;
  font-size: 2.4rem;
}

.avatar-picker {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-picker input[type='file'] {
  max-width: 100%;
  font: inherit;
  margin-bottom: 4px;
}

.avatar-picker small {
  display: block;
  color: var(--muted);
}

/* ---------- Spieler ---------- */

.player-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .player-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 980px) {
  .player-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

.player-card:hover {
  border-color: var(--accent-dark);
}

.player-card.is-inactive {
  opacity: 0.7;
}

.player-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.player-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.player-card-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.player-card-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.profile {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.profile-body {
  flex: 1 1 260px;
  min-width: 0;
}

.profile-body h1 {
  margin-bottom: 4px;
}

.profile-nickname {
  color: var(--muted);
  font-style: italic;
}

.profile-body .facts {
  margin-top: 12px;
}

.profile-notes {
  margin: 12px 0 0;
  color: var(--muted);
  white-space: pre-line;
}

.profile-actions {
  flex-basis: 100%;
}

.player-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.player-inline small {
  display: block;
  font-weight: 400;
}

/* ---------- Spiele ---------- */

.match-list {
  display: flex;
  flex-direction: column;
}

.match-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'date result'
    'main result';
  gap: 2px 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}

.match-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.match-row:last-child {
  padding-bottom: 0;
}

.match-row:hover .match-opponent {
  color: var(--link);
}

.match-date {
  grid-area: date;
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.match-date strong {
  font-weight: 600;
}

.match-main {
  grid-area: main;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.match-opponent {
  font-weight: 700;
}

.match-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.match-result {
  grid-area: result;
}

.score {
  display: inline-block;
  min-width: 3.2em;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--draw-soft);
  color: var(--draw);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.score-win {
  background: var(--win-soft);
  color: var(--win);
}

.score-loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.scoreboard {
  text-align: center;
}

.scoreboard-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.scoreboard-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}

.scoreboard-team {
  font-weight: 700;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.scoreboard-team:first-child {
  text-align: right;
}

.scoreboard-team:last-child {
  text-align: left;
}

.scoreboard-score {
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--draw-soft);
  color: var(--draw);
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scoreboard-score.score-win {
  background: var(--win-soft);
  color: var(--win);
}

.scoreboard-score.score-loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.scoreboard-actions {
  justify-content: center;
  margin-top: 16px;
}

/* ---------- Aufstellung ---------- */

.lineup-summary {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--club-soft);
  color: var(--link);
  font-weight: 600;
}

.lineup-summary.is-mismatch {
  background: var(--warn-soft);
  color: var(--warn);
}

.lineup-player {
  padding: 0;
  margin-bottom: 8px;
}

.lineup-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
}

.lineup-name {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.lineup-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 14px 14px;
}

.lineup-player:not(:has([data-lineup-on]:checked)) .lineup-stats {
  display: none;
}

.lineup-player:has([data-lineup-on]:checked) {
  border-color: var(--accent-dark);
}

.lineup-cards {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  cursor: pointer;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.cardicon {
  display: inline-block;
  width: 11px;
  height: 15px;
  border-radius: 2px;
  vertical-align: -2px;
  background: var(--yellow);
}

.cardicon-red {
  background: var(--red);
}

.cardicon-yellow-red {
  background: linear-gradient(135deg, var(--yellow) 50%, var(--red) 50%);
}

/* ---------- Tabellen & Ranglisten ---------- */

.table-wrap {
  padding: 0;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table a {
  text-decoration: none;
  font-weight: 600;
}

.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ranking li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.ranking li:first-child {
  border-top: 0;
  padding-top: 0;
}

.ranking li:last-child {
  padding-bottom: 0;
}

.ranking-pos {
  width: 1.6em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ranking-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.ranking-name:hover {
  color: var(--link);
}

.ranking-extra {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.ranking-value {
  min-width: 1.8em;
  text-align: right;
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ranking-cards {
  display: flex;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Benutzerverwaltung ---------- */

.user-card.is-pending {
  border-color: color-mix(in srgb, var(--warn) 50%, var(--border));
}

.user-card-head p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form select,
.inline-form input {
  width: auto;
  min-width: 0;
  flex: 1 1 140px;
}

.user-card-more {
  flex-basis: 100%;
}

.user-card-more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 0;
}

.user-card-more form {
  margin-top: 8px;
}

/* ---------- Excel-Import ---------- */

.import-errors {
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
}
