/* Padel-Turnier
   Farbwelt: Padelcourt bei Flutlicht - tiefes Petrol, weisse Courtlinien,
   Bernstein fuer alles Anfassbare, Mint fuer Siege, Ballgelb nur fuer "laeuft".
   Schrift: Barlow Condensed als Anzeigetafel, Barlow fuer Fliesstext. */

:root {
  --court:     #0B2027;
  --panel:     #12303A;
  --panel-hi:  #1A4351;
  --line:      rgba(203, 232, 226, .13);
  --line-soft: rgba(203, 232, 226, .07);
  --ink:       #EAF4F0;
  --muted:     #8AA7AD;
  --amber:     #F2A93B;
  --amber-ink: #2A1A04;
  --mint:      #6FD6B4;
  --ball:      #E4FF54;
  --loss:      #E8735F;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --gap:  14px;
  --pad:  16px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0 0 88px;
  background: var(--court);
  color: var(--ink);
  font: 400 16px/1.55 "Barlow", system-ui, -apple-system, sans-serif;
  /* angedeutete Courtlinien im Hintergrund */
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 100% 220px, 50% 100%;
  background-position: 0 120px, 0 0;
  background-attachment: fixed;
}

h1, h2, h3 {
  font-family: "Barlow Condensed", "Barlow", sans-serif;
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0 0 10px;
  line-height: 1.1;
}
h1 { font-size: 30px; }
h2 { font-size: 23px; margin-top: 30px; }
h3 { font-size: 19px; }

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

p { margin: 0 0 12px; max-width: 62ch; }

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* --------------------------------------------------------------- Kopfzeile */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px var(--pad) 12px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(11, 32, 39, .93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__main { min-width: 0; flex: 1; }
.topbar__title {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 21px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__meta { display: block; font-size: 13px; color: var(--muted); }

.pill {
  flex: none;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--panel-hi); color: var(--muted);
}
.pill--live { background: rgba(228, 255, 84, .15); color: var(--ball); }
.pill--live::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; margin-right: 6px; border-radius: 50%;
  background: var(--ball); vertical-align: middle;
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .25; } }

.page { padding: 18px var(--pad) 24px; max-width: 720px; margin: 0 auto; }

.flash {
  margin: 12px var(--pad) 0; padding: 11px 14px;
  border-radius: var(--r-md); font-size: 15px;
  background: rgba(111, 214, 180, .14); color: var(--mint);
  border: 1px solid rgba(111, 214, 180, .3);
}
.flash--error { background: rgba(232, 115, 95, .14); color: var(--loss); border-color: rgba(232, 115, 95, .35); }

/* -------------------------------------------------------------- Navigation */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(11, 32, 39, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 10px;
  font-size: 11px; font-weight: 500;
  color: var(--muted); text-decoration: none;
}
.tab svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--amber); }

/* ---------------------------------------------------------------- Match */

.round { margin-bottom: 26px; }

.round__head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.round__no {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 22px; font-weight: 700;
}
.round__state { font-size: 13px; color: var(--muted); margin-left: auto; }

.match {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 12px;
}
.match--live {
  border-color: rgba(228, 255, 84, .45);
  box-shadow: 0 0 0 1px rgba(228, 255, 84, .16);
}
.match--done { opacity: .82; }

.match__teams { display: grid; }

.side {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px;
}
.side + .side { border-top: 1px solid var(--line); }

.side__names {
  flex: 1; min-width: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 20px; font-weight: 600; line-height: 1.25;
}
.side__names span { display: block; }

.side__score {
  flex: none;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 34px; font-weight: 700; line-height: 1;
  min-width: 42px; text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.side--win .side__score { color: var(--mint); }
.side--win .side__names { color: var(--ink); }
.side--lose .side__names { color: var(--muted); }

.match__bye {
  padding: 9px 15px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, .16);
  font-size: 13px; color: var(--muted);
}

.match__actions { padding: 12px 15px 14px; border-top: 1px solid var(--line); }

/* Geplante Runden: nur Text, keine Karte, keine Buttons */
.round--soon .round__no { font-size: 17px; color: var(--muted); font-weight: 600; }
.round--soon .round__head { margin-bottom: 4px; }
.preview {
  display: flex; flex-wrap: wrap; align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px; color: var(--muted);
}
/* Abstaende als margin statt flex-gap: aeltere WebKit-Engines
   (u. a. der Druck-Renderer) kennen gap in Flexboxen nicht. */
.preview > * + * { margin-left: 6px; }
.preview__team { color: var(--ink); }
.preview__vs { font-size: 13px; }
.preview__bye { flex-basis: 100%; margin-left: 0 !important; font-size: 13px; margin-top: 2px; }

.scorepad__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
details summary { cursor: pointer; list-style: none; margin-top: 8px; }
details summary::-webkit-details-marker { display: none; }

.timer {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 15px; font-weight: 600; color: var(--ball);
  font-variant-numeric: tabular-nums;
}

/* Ergebnis-Eingabe */

.scorepad { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scorepad__col { display: grid; gap: 6px; }
.scorepad__label {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scorebtn {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 19px; font-weight: 600;
  padding: 11px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel-hi);
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.scorebtn:active { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }

.manual { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.manual input {
  width: 56px; text-align: center;
  font-family: "Barlow Condensed", sans-serif; font-size: 20px;
}

/* ----------------------------------------------------------------- Buttons */

button, .btn {
  font-family: "Barlow", sans-serif;
  font-size: 16px; font-weight: 600;
  padding: 12px 18px;
  border: 0; border-radius: var(--r-md);
  background: var(--amber); color: var(--amber-ink);
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn--block { display: flex; width: 100%; }
.btn--ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}
.btn--danger { color: var(--loss); border-color: var(--loss); }
.btn--quiet {
  background: none; color: var(--muted);
  border: 0; padding: 8px 0; font-size: 14px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ball); outline-offset: 2px;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

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

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=number], select, textarea {
  width: 100%;
  padding: 11px 13px;
  font: 400 16px "Barlow", sans-serif;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 15px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 15px; font-weight: 500;
  cursor: pointer;
}
.chip input:checked + span {
  background: var(--amber); color: var(--amber-ink); border-color: var(--amber);
}
.chip input:focus-visible + span { outline: 2px solid var(--ball); outline-offset: 2px; }
.chip small { display: block; font-size: 11px; opacity: .7; }

/* -------------------------------------------------------------- Tabellen */

.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-align: right; padding: 0 0 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.board th:nth-child(-n+2) { text-align: left; }
.board td {
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  font-size: 15px;
}
.board td:nth-child(-n+2) { text-align: left; }
.board tr:last-child td { border-bottom: 0; }

.board__rank {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 20px; font-weight: 700; width: 34px;
  color: var(--muted);
}
.board tr:nth-child(1) .board__rank { color: var(--amber); }
.board tr:nth-child(2) .board__rank,
.board tr:nth-child(3) .board__rank { color: var(--ink); }

.board__name { font-weight: 500; }
.board__name b { font-weight: 600; }
.move { font-size: 12px; margin-left: 6px; }
.move--up { color: var(--mint); }
.move--down { color: var(--loss); }

.num-pos { color: var(--mint); }
.num-neg { color: var(--loss); }

.board--wide { display: block; overflow-x: auto; }

/* ------------------------------------------------------------------ Karten */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px;
  margin-bottom: 12px;
}
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card__title { font-family: "Barlow Condensed", sans-serif; font-size: 19px; font-weight: 600; }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.fact { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.fact__value {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 27px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.fact__label { font-size: 13px; color: var(--muted); }

.relations { display: grid; gap: 6px; font-size: 15px; }
.relations div { display: flex; justify-content: space-between; gap: 12px; }

/* Heatmap Partner-/Gegner-Matrix */
.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th {
  font-family: "Barlow Condensed", sans-serif; font-weight: 600;
  color: var(--muted); padding: 6px 4px; text-align: center;
}
.matrix th:first-child { text-align: left; }
.matrix td {
  padding: 8px 4px; text-align: center;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.matrix td.self { color: var(--line); }
.matrix tbody th { text-align: left; white-space: nowrap; }

/* Verlaufsdiagramm */
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .series { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.warn {
  border-left: 3px solid var(--amber);
  padding: 10px 14px; margin: 14px 0;
  background: rgba(242, 169, 59, .1);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: 14px;
}

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-top: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
}
.list li:last-child { border-bottom: 0; }
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 500; }
.list__sub { font-size: 13px; color: var(--muted); }
.list__actions { display: flex; align-items: center; gap: 8px; }
.list__actions form { display: contents; }

.winner {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 15px; font-weight: 600; color: var(--amber);
}

/* --------------------------------------------------------- Anzeigetafel TV */

.tv { text-align: left; }
.tv .board td { font-size: clamp(18px, 4.5vw, 34px); padding: 14px 0; }
.tv .board th { font-size: clamp(12px, 2vw, 18px); }
.tv .board__rank { font-size: clamp(24px, 6vw, 48px); width: 1.6em; }

@media (min-width: 620px) {
  .facts { grid-template-columns: repeat(4, 1fr); }
  h1 { font-size: 36px; }
}

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

@media print {
  .tabbar, .topbar, .match__actions, .actions, .btn { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .card, .match { border-color: #ccc; background: #fff; }
  .board td, .board th { color: #000; }
}

/* ------------------------------------------------------------ Gruppen-Duell
   Sechs Gruppenfarben, bewusst klar unterscheidbar und auf dem dunklen
   Petrol gut lesbar. Jede Farbe steckt in --g und wird ueber .g-0 ... .g-5
   an Punkte, Karten und Balken weitergegeben. */
.g-0 { --g: #F2A93B; }
.g-1 { --g: #6FD6B4; }
.g-2 { --g: #7FB2E8; }
.g-3 { --g: #E8735F; }
.g-4 { --g: #C79BE8; }
.g-5 { --g: #E4FF54; }

.gdot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--g, var(--muted)); margin-right: 7px; flex: none;
  vertical-align: baseline; font-style: normal;
}
.side__names span { display: flex; align-items: center; }

/* Formular */
.toggle, .choice { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input, .choice input { margin-top: 5px; accent-color: var(--amber); width: 20px; height: 20px; flex: none; }
.toggle b, .choice b { display: block; font-weight: 600; }
.toggle small, .choice small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.choice { padding: 10px 0; }

.group-panel { display: none; }
form:has(#type_group:checked) .group-panel { display: block; }

.group-names { display: grid; gap: 9px; margin-bottom: 10px; }
.group-slot { display: flex; align-items: center; gap: 10px; }
.group-slot input { flex: 1; }
.group-slot .gdot { width: 14px; height: 14px; margin: 0; }
.group-slot[hidden], .group-new > [hidden], .assign[hidden] { display: none; }

.assign { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.assign__name { flex: 1; min-width: 0; font-weight: 500; }
.assign select { width: auto; min-width: 140px; }
.group-new { display: grid; gap: 10px; }
.group-new label { display: block; margin-bottom: 3px; }
.group-new textarea { min-height: 0; }

/* Gruppenwertung */
.gboard { margin-bottom: 8px; }
.gboard__mode {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.gbar {
  display: flex; height: 30px; border-radius: var(--r-sm); overflow: hidden;
  gap: 2px; margin-bottom: 12px; background: var(--panel);
}
.gbar__seg {
  flex-basis: 0; min-width: 28px; background: var(--g); color: #0B2027;
  display: flex; align-items: center; justify-content: center;
  font: 700 17px/1 "Barlow Condensed", sans-serif; transition: flex-grow .4s ease;
}
.gcard {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 5px solid var(--g); border-radius: var(--r-md);
  padding: 12px 14px; margin-bottom: 10px;
}
.gcard--lead { background: var(--panel-hi); border-color: var(--g); }
.gcard__head { display: flex; align-items: center; gap: 12px; }
.gcard__rank {
  font: 700 26px/1 "Barlow Condensed", sans-serif; color: var(--g); min-width: 22px; text-align: center;
}
.gcard__title { flex: 1; min-width: 0; }
.gcard__name { display: flex; align-items: center; font: 600 22px/1.15 "Barlow Condensed", sans-serif; }
.gcard__members { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.gcard__main { text-align: right; line-height: 1; }
.gcard__big { display: block; font: 700 34px/1 "Barlow Condensed", sans-serif; color: var(--g); }
.gcard__unit { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.gcard__stats {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px;
  padding-top: 9px; border-top: 1px solid var(--line-soft); font-size: 14px; color: var(--muted);
}
.gcard__stats b { color: var(--ink); font-weight: 600; }
.gcard__stats .num-pos b { color: var(--mint); }
.gcard__stats .num-neg b { color: var(--loss); }

.gwinner { border-left: 5px solid var(--g); }
.gwinner__name { display: flex; align-items: center; font: 700 32px/1.1 "Barlow Condensed", sans-serif; color: var(--g); }
.gwinner__name .gdot { width: 16px; height: 16px; }
.winner .gdot { margin-right: 5px; }

/* Anzeigetafel: Gruppen gross */
.tv .gcard__name { font-size: 30px; }
.tv .gcard__big { font-size: 48px; }
.done{border-color:var(--amber)}
/* Umschalter Spieler / Gruppen: zwei gleich breite Buttons, aktiver leuchtet orange */
.subtabs {
  display: flex; width: 100%; margin: 4px 0 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden;
}
.subtabs a {
  flex: 1 1 50%; text-align: center; padding: 12px 8px;
  font-size: 16px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; background: transparent;
}
.subtabs a.is-on { background: var(--amber); color: var(--amber-ink); }
.subtabs a:focus-visible { outline: 2px solid var(--ball); outline-offset: -2px; }
.done { border-color: var(--amber); }
@media print { .subtabs { display: none; } }

/* Einzelspieler / Gruppen */
.typeswitch { display: flex; margin-bottom: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.typeswitch input { position: absolute; opacity: 0; pointer-events: none; }
.typeswitch label {
  flex: 1 1 50%; margin: 0; text-align: center; padding: 12px 8px; cursor: pointer;
  font-size: 16px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
}
.typeswitch input:checked + label { background: var(--amber); color: var(--amber-ink); }
.typeswitch input:focus-visible + label { outline: 2px solid var(--ball); outline-offset: -2px; }
