:root{
  --bg: #0b1220;
  --line: rgba(255,255,255,.12);
  --muted: rgba(255,255,255,.72);
  --muted2: rgba(255,255,255,.55);
  --shadow: 0 12px 30px rgba(0,0,0,.35);
  --radius: 18px;

  --green: #1e9e55;
  --green2: rgba(30,158,85,.18);
  --red: #d93a3a;
  --red2: rgba(217,58,58,58,.18);

  /* ✅ Layout-Spaces (Cards / Sections) */
  --space-card: 18px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:#fff;

  background:
    linear-gradient(180deg, #0e1a33 0%, #0b1220 100%),
    radial-gradient(1200px 800px at 50% -200px, rgba(70,110,200,.18), transparent 70%);
  background-attachment: fixed;
}

/* ✅ Noise-Layer gegen Banding (iOS) */
body::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;

  background-image: repeating-linear-gradient(
    0deg,
    rgba(255,255,255,0.012),
    rgba(255,255,255,0.012) 1px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0) 4px
  );
  opacity: .25;
  mix-blend-mode: overlay;
}

/* ✅ sorgt dafür, dass dein Inhalt über dem Noise liegt */
.container{
  position: relative;
  z-index: 1;

  max-width: 1050px;
  margin: 0 auto;
  padding: 18px;
}

.header{
  display:grid;
  gap:14px;
  margin-bottom:18px;
}

.title{
  display:flex;
  gap:12px;
  align-items:center;
}

.title__icon{
  width:44px;height:44px;
  display:grid;place-items:center;
  border-radius:14px;
  background: rgba(255,255,255,.10);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

h1{ margin:0; font-size:22px; line-height:1.1; }
.meta{ margin-top:4px; font-size:13px; color:var(--muted); }

.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  padding:12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}

.spacer{ flex:1; }

.btn{
  appearance:none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.12);
  color:#fff;
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 750;
  cursor:pointer;
  transition: transform .05s ease, background .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:hover{ background: rgba(255,255,255,.16); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.45; cursor:not-allowed; }

.btn--ghost{ background: rgba(255,255,255,.08); }
.btn--primary{
  background: rgba(30,158,85,.22);
  border-color: rgba(30,158,85,.35);
}

.datewrap{ display:flex; align-items:center; }
.date{
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color:#fff;
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 750;
}

/* ✅ Kalender-Icon im Date-Input weiß (Chrome/Edge/Safari) */
.date::-webkit-calendar-picker-indicator{
  filter: invert(1) brightness(1.15);
  opacity: 1;
  cursor: pointer;
}

.card{
  background: rgba(255,255,255,.075);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius);
  padding:12px;

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  box-shadow:
    0 10px 30px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.08);

  /* ✅ Konsistenter Abstand zwischen Cards */
  margin-top: var(--space-card);
}

/* Optional: wenn du NICHT willst, dass die allererste Card im Container oben Abstand hat:
   .container > .card:first-child { margin-top: 0; }
*/

.card__head{
  display:flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.card__title{ font-weight: 950; }
.card__subtitle{ font-size: 12px; color: var(--muted2); text-align:right; }

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

/* Hint oben links in der Chipbox */
.chips__top{
  width: 100%;
  display: flex;
  justify-content: flex-start;
}
.chips__hint{
  font-size: 12px;
  color: var(--muted2);
}
.chips__section-title{
  width: 100%;
  margin-top: 4px;
  margin-bottom: 4px;
}

/* === CHIP STATES === */
.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.18);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  user-select:none;
  white-space: nowrap;
}

.chip__icon{
  width: 18px;
  height: 18px;
  display:grid;
  place-items:center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 1000;
}

.chip--ok{
  border-color: rgba(30,158,85,.35);
  background: var(--green2);
}
.chip--ok .chip__icon{
  background: var(--green);
  color: #fff;
}

.chip--no{
  border-color: rgba(217,58,58,.40);
  background: var(--red2);
}
.chip--no .chip__icon{
  background: var(--red);
  color: #fff;
}

.chip--me{
  outline: 2px solid rgba(255,255,255,.22);
  outline-offset: 2px;
}

.chip--clickable{ cursor: pointer; }
.chip--clickable:hover{ filter: brightness(1.06); }
.chip--locked{ opacity: .92; }

/* Größere Dropzone für "Frei" */
.chip--dropzone{
  min-width: 120px;
  justify-content: center;
  padding: 10px 18px;
  font-size: 14px;
}
@media (max-width: 768px){
  .chip--dropzone{
    min-width: 150px;
    padding: 14px 20px;
  }
}

/* Courts */
.courts{
  display:grid;
  gap:16px;
  grid-template-columns: 1fr;

  /* ✅ Abstand zum nächsten Card-Block (Ersatzspieler / Upload / Export) */
  margin-bottom: var(--space-card);
}
@media (min-width: 900px){
  .courts{ grid-template-columns: 1fr 1fr; }
}

.court{
  position: relative;
  border-radius: var(--radius);
  padding: 14px;
  min-height: 320px;
  overflow:hidden;

  background:
    linear-gradient(180deg, #2b8c45 0%, #1f6f36 100%);

  border: 1px solid rgba(255,255,255,.18);

  box-shadow:
    0 15px 40px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.12);
}

.court::before{
  content:"";
  position:absolute;
  inset: 14px;
  border-radius: calc(var(--radius) - 4px);
  border: 2px solid rgba(255,255,255,.55);
}

.court::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 40%);
  pointer-events:none;
}

.court__head{
  position: relative;
  z-index: 1;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  margin-bottom: 8px;
}

.court__title{ font-size: 16px; font-weight: 1000; margin-left: 12px; }

.badge{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.2);
}

.net{
  position:absolute;
  left:14px; right:14px;
  top:50%;
  height:2px;
  background: rgba(255,255,255,.7);
}

.vs{
  position:absolute;
  left:50%; top:50%;
  transform: translate(-50%,-50%);
  font-weight: 1100;
  opacity:.9;
  background: rgba(0,0,0,.14);
  border: 1px solid rgba(255,255,255,.18);
  padding: 6px 10px;
  border-radius: 999px;
}

.slot{
  position:absolute;
  width: calc(50% - 26px);
  padding: 10px 12px;
  border-radius: 14px;
  background: transparent;
  border: none;
  backdrop-filter: blur(2px);
}

.tl{ top: 64px; left: 20px; }
.br{ bottom: 22px; right: 20px; text-align:right; }

.names{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  justify-content: flex-start;
}
.br .names{ justify-content: flex-end; }

/* make chips a tad smaller on courts */
.slot .chip{
  padding: 7px 9px;
  font-size: 13px;
  background: rgba(0,0,0,.22);
}

/* Footer */
.footer{
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted2);
}

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

/* Upload */
.upload{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items:center;
  border-radius: var(--radius);
}
.upload__msg{
  color: var(--muted);
  font-size: 13px;
}
.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;
}
.input--small{
  padding: 10px 12px;
  max-width: 220px;
}

.table{
  width: 100%;
  border-radius: var(--radius);
}
.table__row{
  display:grid;
  grid-template-columns: 60px 1fr 120px;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.table__head{
  font-weight: 700;
  opacity: .9;
}

.header__right{
  margin-left:auto;
  flex-shrink: 0;
}

.chip--dropzone.chip--me{
  outline: 2px dashed rgba(255,255,255,.75);
  outline-offset: 2px;
}

/* Warnanzeige in Meta-Zeile */
.meta--warn{
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 200, 70, 0.12);
  border: 1px solid rgba(255, 200, 70, 0.22);
  display: inline-block;
}
.meta__warn{
  color: rgba(255, 220, 130, 1);
  font-weight: 900;
}

/* Emoji-Icon klickbar */
#randomIcon{
  cursor: pointer;
  user-select: none;
}

/* Sort in Statistik */
.sortable{
  cursor: pointer;
  user-select: none;
}
.sortable:hover{
  opacity: .85;
}

/* ===============================
   Dezenter "Beispiel herunterladen"-Link (wie PDF-Text)
   Erwartet: <a class="template-link" ...>Beispiel herunterladen</a>
   Am besten innerhalb von .card__subtitle (oben rechts)
================================= */
.card__subtitle .template-link{
  font-size: inherit;                 /* exakt wie der umgebende Text (z.B. PDF/XLSX Hinweis) */
  color: var(--muted2);               /* kein Standard-Blau */
  text-decoration: none;
  border-bottom: 1px dotted rgba(255,255,255,.22);
  padding-bottom: 1px;
  margin-left: .35rem;
  transition: color .15s ease, border-color .15s ease, opacity .15s ease;
  opacity: .95;
}
.card__subtitle .template-link:hover{
  color: var(--muted);
  border-bottom-color: rgba(255,255,255,.45);
  opacity: 1;
}
.card__subtitle .template-link:focus-visible{
  outline: 2px solid rgba(255,255,255,.28);
  outline-offset: 2px;
  border-bottom-color: transparent;
}

/* Falls Browser-Defaults trotzdem "blau" durchdrücken, nur im Subtitle neutralisieren */
.card__subtitle a{
  color: inherit;
}