/* Scoreboard — Anzeige für Volleyball auf dem iPad */

:root {
  --bg: #0b0b0d;
  --fg: #f4f4f5;
  --gedimmt: #6b6b73;
  --linie: #26262b;
  --flaeche: #1b1b20;
  --links: #e2483d;
  --rechts: #3b82f6;
  --spieleHoehe: max(14vh, 64px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

/* ---------- Grundgerüst ---------- */

/* Kein Innenabstand — die Farbstreifen sollen bis an alle vier Kanten laufen.
   Den sicheren Bereich am iPad berücksichtigt jedes Element für sich. */
#tafel {
  position: relative;
  height: 100%;
}

#feld {
  display: flex;
  height: 100%;
}

#trenner { width: 1px; background: var(--linie); flex: 0 0 auto; }

/* Das Logo liegt ÜBER den Zahlen — so bleibt links und rechts kein Platz ungenutzt.
   Eigene abgerundete Fläche, genau wie das Schildchen unten. */
#kopf {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 12px 26px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 22px;
}

#logo {
  display: block;
  height: min(10vh, 68px);
  width: auto;
}

/* ---------- Eine Spielhälfte ---------- */

.seite {
  flex: 1 1 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.seite[data-seite="links"]  { --farbe: var(--links); }
.seite[data-seite="rechts"] { --farbe: var(--rechts); }

/* Der Farbstreifen an der Außenkante — er ersetzt den Teamnamen */
.balken {
  position: absolute;
  top: 0; bottom: 0;
  width: 22px;
  background: var(--farbe);
}
.seite[data-seite="links"]  .balken { left: 0; }
.seite[data-seite="rechts"] .balken { right: 0; }

.punkte {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.zahl {
  font-size: min(72vh, 36vw);
  line-height: 0.8;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
  color: var(--fg);
  transition: transform 0.11s ease-out, color 0.2s;
}

.seite.matchball .zahl { color: var(--farbe); }
.seite.tippt .zahl { transform: scale(1.05); }

.spiele {
  flex: 0 0 auto;
  height: calc(var(--spieleHoehe) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-top: 1px solid var(--linie);
  color: var(--gedimmt);
}

.spieleLabel { font-size: 15px; letter-spacing: 0.18em; text-transform: uppercase; }

.spieleZahl {
  font-size: min(8vh, 42px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  transition: transform 0.11s ease-out;
}

.spiele.tippt .spieleZahl { transform: scale(1.14); }

/* Kurzes Aufleuchten als Bestätigung — auch wenn der Ton aus ist */
.blitz {
  position: absolute;
  inset: 0;
  background: var(--farbe);
  opacity: 0;
  pointer-events: none;
}
.blitz.plus  { animation: aufblitzen 0.34s ease-out; }
.blitz.minus { animation: abblitzen 0.34s ease-out; }

@keyframes aufblitzen { from { opacity: 0.26; } to { opacity: 0; } }
@keyframes abblitzen  { from { opacity: 0.10; } to { opacity: 0; } }

/* ---------- Schildchen für Matchball / Verlängerung ---------- */

#status {
  position: absolute;
  left: 50%;
  bottom: calc(var(--spieleHoehe) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg);
  white-space: nowrap;
  pointer-events: none;
}
#status[hidden] { display: none; }

/* ---------- Überlagerungen ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 11, 13, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.overlay[hidden] { display: none; }

button {
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  color: var(--fg);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 12px;
  padding: 14px 26px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { background: #26262d; }

/* ---------- Startbildschirm: links Anleitung, rechts Einstellungen ---------- */

.startRaster {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.05fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  width: min(1080px, 94vw);
  max-height: 94vh;
  padding: 20px;
}

.startLinks { text-align: left; }

#startLogo { height: 48px; max-width: 80%; object-fit: contain; margin-bottom: 22px; }
.startTitel { font-size: clamp(30px, 4.4vh, 42px); font-weight: 700; letter-spacing: -0.02em; }
.startHinweis { margin-top: 6px; color: var(--gedimmt); font-size: 16px; }

.anleitung { list-style: none; margin: 26px 0 0; }
.anleitung li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 0;
  color: var(--gedimmt);
  font-size: 15px;
}
.geste {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--linie);
  border-radius: 9px;
  background: var(--flaeche);
  color: var(--fg);
  font-size: 14px;
}

#startKnopf { margin-top: 28px; padding: 17px 44px; font-size: 19px; width: 100%; }

/* Nebenfunktion — bewusst leiser als der Start-Knopf */
button.nebensache {
  margin-top: 10px;
  width: 100%;
  padding: 13px;
  font-size: 15px;
  background: none;
  color: var(--gedimmt);
}
button.nebensache:active { background: var(--flaeche); }

.startRechts {
  max-height: 90vh;
  overflow-y: auto;
  touch-action: pan-y;
  border: 1px solid var(--linie);
  border-radius: 16px;
  padding: 4px 24px 20px;
}

/* Sprachflaggen */
.flaggen { display: flex; gap: 10px; }
.flaggen .flagge {
  font-size: 26px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 10px;
  background: none;
  border: 1px solid transparent;
  opacity: 0.45;
  transition: opacity 0.15s;
}
.flaggen .flagge.aktiv {
  opacity: 1;
  border-color: var(--fg);
  background: var(--flaeche);
}

/* ---------- Sieg ---------- */

#konfetti { position: absolute; inset: 0; width: 100%; height: 100%; }
.siegInhalt { position: relative; text-align: center; padding: 24px; }

#siegOben {
  font-size: 14px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gedimmt);
  margin-bottom: 12px;
}
#siegTitel {
  font-size: min(14vh, 100px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
#siegStand {
  margin-top: 14px;
  font-size: 26px;
  color: var(--gedimmt);
  font-variant-numeric: tabular-nums;
}
.siegKnoepfe { margin-top: 44px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
#siegWeiter { padding: 17px 40px; font-size: 19px; }
button.leise { background: none; border-color: transparent; color: var(--gedimmt); font-size: 15px; }

/* Matchgewinn — das grosse Ende */
#sieg.match #siegOben { color: var(--fg); letter-spacing: 0.4em; }
#sieg.match #siegTitel {
  font-size: min(17vh, 130px);
  animation: pochen 1.6s ease-in-out infinite;
}
#sieg.match .siegInhalt::before {
  content: "";
  position: absolute;
  inset: -14vh -18vw;
  border-radius: 50%;
  background: radial-gradient(circle, var(--siegfarbe, #fff) 0%, transparent 68%);
  opacity: 0.16;
  animation: atmen 2.6s ease-in-out infinite;
  pointer-events: none;
}
#sieg.match #siegZurueck { display: none; }

@keyframes pochen { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes atmen  { 0%, 100% { opacity: 0.10; } 50% { opacity: 0.24; } }

/* ---------- Einstellungen ---------- */

.einstInhalt {
  width: min(560px, 92vw);
  max-height: 94vh;
  overflow-y: auto;
  padding: 0 26px 0;
  touch-action: pan-y;
}

/* Auf dem Startbildschirm braucht es weder Titelzeile noch Fertig-Knopf */
.startRechts .dialogKopf { display: none; }
.startRechts #einstBlock > .zeile:first-of-type { border-top: none; }

.zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-top: 1px solid var(--linie);
  font-size: 16px;
}

.wahl { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.wahl button { padding: 11px 17px; font-size: 15px; border-radius: 10px; min-width: 50px; }
.wahl button.aktiv { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.farbwahl { display: flex; gap: 14px; }
.farbwahl .punkt {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 4px;
}
.farbwahl .punkt.aktiv { outline-color: var(--fg); }

.notiz { color: var(--gedimmt); font-size: 13px; line-height: 1.5; margin: -4px 0 2px; }

.einstKnoepfe { display: flex; gap: 10px; margin-top: 24px; }
.einstKnoepfe button { flex: 1; font-size: 15px; padding: 13px 10px; }
button.warnung { color: #e2483d; }
.schliessen { width: 100%; margin-top: 12px; padding: 16px; }

/* ---------- Takımları kur: Mannschaften auslosen ---------- */

.teamsInhalt {
  display: flex;
  flex-direction: column;
  width: min(880px, 95vw);
  max-height: 94vh;
  overflow-y: auto;
  padding: 0 26px 24px;
  touch-action: pan-y;
}


/* Titelzeile mit Zurück links und Schliessen rechts */
.dialogKopf {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 18px 0 14px;
  margin-bottom: 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--linie);
}
.dialogKopf + .zeile,
.dialogKopf + * > .zeile:first-child { border-top: none; }
.dialogKopf h2 { font-size: 19px; font-weight: 600; text-align: center; white-space: nowrap; }
.dialogKopf .stillKnopf:last-child { justify-self: end; }
.dialogKopf .stillKnopf:first-child { justify-self: start; }

button.stillKnopf {
  background: none;
  border: none;
  color: var(--gedimmt);
  font-size: 15px;
  padding: 8px 6px;
}
button.stillKnopf:active { background: none; color: var(--fg); }

.wahl.gross button { padding: 15px 20px; font-size: 17px; }
#teamsGroesseWahl { justify-content: flex-start; margin-top: 16px; }

.teamsFelder {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.teamsFelder input {
  font: inherit;
  font-size: 16px;
  width: 100%;
  padding: 13px 15px;
  color: var(--fg);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 11px;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
.teamsFelder input:focus { outline: none; border-color: var(--gedimmt); }
.teamsFelder input::placeholder { color: var(--gedimmt); }

.warnton { color: #e2483d; }

/* Schritt 3: links die Mannschaften untereinander, rechts das Feld */
.teamsRaster {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 20px;
  margin-top: 14px;
  align-items: start;
}
.teamsListen { display: flex; flex-direction: column; gap: 12px; }

/* Das Feld steht hochkant: obere Hälfte, Netz quer, untere Hälfte */
.sahaFeld {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 4 / 5;
  /* So hoch wie möglich, aber der Speichern-Knopf muss sichtbar bleiben */
  height: min(64vh, 600px);
  max-width: 100%;
  margin: 0 auto;
  background: #141418;
  border: 1px solid var(--linie);
  border-radius: 14px;
  padding: 12px;
  gap: 4px;
}

.sahaNetz {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-top: 3px dashed #3a3a42;
  margin: 6px 4px 4px;
  height: 0;
}
.sahaNetz span {
  transform: translateY(-50%);
  background: #141418;
  padding: 0 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gedimmt);
}

.sahaHaelfte { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }

.sahaReihe {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sahaPlaetze { flex: 1; display: flex; gap: 6px; min-height: 0; }
.sahaSpieler {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  text-align: center;
  overflow: hidden;
  word-break: break-word;
  min-width: 0;
}

.teamsExtra {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.teamsExtra .klein { padding: 11px 16px; font-size: 14px; }
#teamsTeilen { margin-left: auto; }
#teamsWeiter { flex: 0 0 auto; width: 100%; margin-top: 18px; padding: 16px; font-size: 18px; }
#teamsWeiter[hidden] { display: none; }

/* Frühere Auslosungen und Matches */
#verlaufBereich { margin-top: 26px; border-top: 1px solid var(--linie); padding-top: 16px; }
#verlaufBereich h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gedimmt);
  margin-bottom: 8px;
}
#verlaufListe { display: flex; flex-direction: column; max-height: 32vh; overflow-y: auto; }

button.verlaufZeile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--linie);
  border-radius: 0;
  padding: 12px 4px;
  font-size: 15px;
}
button.verlaufZeile:active { background: var(--flaeche); }
.verlaufPunkte { display: flex; gap: 4px; flex: 0 0 auto; }
.verlaufPunkte i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.verlaufText { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verlaufZeit { flex: 0 0 auto; color: var(--gedimmt); font-size: 13px; }

/* Ein Match aus dem Verlauf */
.macKopf {
  border-left: 4px solid var(--teamfarbe);
  padding: 4px 0 4px 16px;
  margin: 8px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.macKopf strong { font-size: 24px; font-weight: 700; color: var(--teamfarbe); }
.macKopf span { font-size: 19px; font-variant-numeric: tabular-nums; }
.macKopf small { color: var(--gedimmt); font-size: 13px; }
.macFoto { width: 100%; border-radius: 14px; display: block; }

/* Fotoaufforderung nach dem Match */
#fotoBereich { margin-top: 30px; }
#fotoBereich[hidden] { display: none; }
.fotoText {
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gedimmt);
  margin-bottom: 12px;
}
.knopfArtig {
  display: inline-block;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 12px;
  padding: 13px 24px;
  cursor: pointer;
}
#fotoHinweis { margin-top: 10px; }
#fotoVorschau {
  display: block;
  width: min(420px, 70vw);
  margin: 16px auto 0;
  border-radius: 14px;
}
#fotoVorschau[hidden] { display: none; }
#fotoTeilen { margin-top: 12px; }

/* Fragezeichen vor den Erklärungen */
.mitHilfe { display: inline-flex; align-items: center; gap: 8px; }
button.hilfe {
  width: 22px; height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--gedimmt);
  background: none;
  border: 1px solid var(--linie);
}
button.hilfe.offen { color: var(--bg); background: var(--fg); border-color: var(--fg); }

/* Was nur während des Spiels sinnvoll ist */
.startRechts .nurImDialog { display: none; }
button.breit { width: 100%; margin-top: 14px; }
button.gross { padding: 16px; font-size: 18px; }
#einstFertig { margin-top: 18px; margin-bottom: 22px; }

.teamsSpalte {
  border: 1px solid var(--linie);
  border-radius: 14px;
  padding: 16px 18px;
  border-top: 4px solid var(--teamfarbe);
}
.teamsSpalte h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--teamfarbe);
  margin-bottom: 10px;
}
.teamsSpalte ol { list-style: none; }
.teamsSpalte li {
  padding: 7px 0;
  font-size: 17px;
  border-top: 1px solid var(--linie);
}
.teamsSpalte li:first-child { border-top: none; }

.teamsKnoepfe {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}
#teamsWeiter { flex: 1; padding: 16px; font-size: 18px; }

/* ---------- Enge Bildschirme ---------- */

@media (max-width: 900px), (orientation: portrait) {
  .startRaster {
    grid-template-columns: 1fr;
    gap: 20px;
    overflow-y: auto;
    touch-action: pan-y;
  }
  .startRechts { max-height: none; border: none; padding: 0; }
  .zahl { font-size: min(46vh, 40vw); }
}

/* ---------- Vereinsprofil ---------- */

.profilRechts { display: flex; align-items: center; gap: 12px; }
.profilRechts .notiz { margin: 0; white-space: nowrap; }
.profilRechts .klein { padding: 10px 16px; font-size: 14px; }

.profilInhalt {
  width: min(400px, 90vw);
  padding: 30px;
  text-align: left;
}
.profilInhalt h2 { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
#profilFeld {
  font: inherit;
  font-size: 17px;
  width: 100%;
  padding: 14px 16px;
  color: var(--fg);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 12px;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
#profilFeld:focus { outline: none; border-color: var(--gedimmt); }
.profilKnoepfe { display: flex; gap: 10px; margin-top: 20px; }
#profilSenden { flex: 1; }
