/* Flunky Ball – Basis-Design (modern, iPhone-optimiert) */

:root {
  --bg: #15100a;
  --bg-2: #201811;
  --card: #2a2016;
  --card-hi: #33271b;
  --accent: #e67e22;
  --accent-2: #ffb74d;
  --text: #f5efe6;
  --text-dim: #b9ab98;
  --danger: #e74c3c;
  --ok: #27ae60;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Layout ---------- */
.screen {
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 96px);
  max-width: 640px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px 18px;
}
.app-header .logo {
  width: 40px; height: 40px; border-radius: 11px;
  flex: none;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent);
  overflow: hidden;
}
/* Nur der Titel darf schrumpfen und umbrechen. Icon-Kachel und die rechten
   Symbole behalten ihre feste Breite, sonst laufen sie aus der Seite. */
.app-header > div:not(.logo):not(.header-actions) { min-width: 0; flex: 1 1 auto; }
.app-header .header-actions { flex: none; }
.app-header .logo .hdr-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.app-header h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.app-header p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.header-btn {
  margin-left: auto; flex: none; width: 42px; height: 42px; border-radius: 12px;
  border: none; background: var(--card); color: var(--text); font-size: 20px;
  cursor: pointer; display: grid; place-items: center;
}
.header-btn:active { background: var(--card-hi); }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

/* Fixierte, unscharfe Titelleiste auf der Startseite. Die Turnierliste scrollt
   dahinter durch. */
.home-screen { padding-top: 0; }
.app-header.home-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 -16px 6px;
  padding: calc(var(--safe-top) + 10px) 16px 14px;
  background: rgba(21, 16, 10, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

/* Fixierter Kopf auf Turnier-Detail und Teamverwaltung. Der Inhalt darunter
   scrollt dahinter durch. */
.detail-screen, .teams-screen, .fixed-head-screen { padding-top: 0; }
.topbar-fixed {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 -16px 10px;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background: rgba(21, 16, 10, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar-fixed .app-header { padding: 4px 2px 6px; }
.topbar-fixed .detail-head { padding: 6px 0 2px; }
.topbar-fixed .back-btn { margin-bottom: 4px; }

.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin: 22px 4px 10px;
}

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.05);
  transition: transform .12s ease, background .12s ease;
}
.card:active { transform: scale(.985); background: var(--card-hi); }

.tourney-card { display: flex; align-items: center; gap: 14px; }
.tourney-logo {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  color: #2a1a08; overflow: hidden;
}
.tourney-logo img { width: 100%; height: 100%; object-fit: cover; }
.tourney-info { flex: 1; min-width: 0; }
.tourney-info h3 { margin: 0; font-size: 17px; }
.tourney-meta { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .3px;
}
.badge.running { background: rgba(39,174,96,.18); color: #6ee7a0; }
.badge.prep { background: rgba(255,183,77,.16); color: var(--accent-2); }
.badge.done { background: rgba(255,255,255,.1); color: var(--text-dim); }

.winner-line { margin-top: 6px; font-size: 13px; color: var(--accent-2); font-weight: 600; }

/* ---------- Leerer Zustand ---------- */
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-dim);
}
.empty .big { font-size: 46px; margin-bottom: 8px; }
.empty p { margin: 6px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 600; border: none; cursor: pointer;
  padding: 14px 18px; border-radius: 14px; color: #fff;
  background: rgba(255,255,255,.08); transition: transform .1s ease, filter .1s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(160deg, var(--accent-2), var(--accent)); color: #2a1a08; }
.btn.block { width: 100%; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 20px);
  width: min(560px, calc(100% - 32px));
  z-index: 20; box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- Formular ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin: 0 2px 6px; }
.field input[type="text"],
.field input[type="email"] {
  width: 100%; font-size: 17px; color: var(--text);
  background: var(--card); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 14px; outline: none;
}
.field input:focus { border-color: var(--accent); }

.back-btn {
  background: none; border: none; color: var(--accent-2);
  font-size: 16px; padding: 6px 0; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 92px);
  transform: translateX(-50%) translateY(20px);
  background: #000; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50;
}
.toast.show { opacity: .95; transform: translateX(-50%) translateY(0); }

/* ---------- Chevron auf Karten ---------- */
.chevron { color: var(--text-dim); font-size: 26px; flex: none; padding-left: 4px; }

/* ---------- Format-Picker ---------- */
.format-card { display: flex; align-items: center; gap: 14px; position: relative; }
.format-icon { font-size: 26px; flex: none; width: 40px; text-align: center; }
.format-text { flex: 1; }
.format-text h3 { margin: 0; font-size: 16px; }
.format-text p { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); line-height: 1.35; }
.format-card .check {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  border: 2px solid rgba(255,255,255,.2); color: transparent;
}
.format-card.selected { border-color: var(--accent); background: var(--card-hi); }
.format-card.selected .check { background: var(--accent); border-color: var(--accent); color: #2a1a08; }

/* ---------- Logo-Upload ---------- */
.logo-upload { display: flex; align-items: center; gap: 16px; }
.logo-preview {
  width: 72px; height: 72px; border-radius: 18px; flex: none; overflow: hidden;
  display: grid; place-items: center; font-size: 30px;
  background: var(--card); border: 1px dashed rgba(255,255,255,.2);
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.logo-btn { position: relative; background: rgba(255,255,255,.1); }

/* ---------- Detail-Kopf ---------- */
.detail-head { text-align: center; padding: 10px 0 4px; transition: padding .2s ease, gap .2s ease; }
.detail-titles { min-width: 0; }
.detail-logo {
  width: 88px; height: 88px; border-radius: 24px; margin: 0 auto 12px; overflow: hidden;
  display: grid; place-items: center; font-size: 40px; font-weight: 700; color: #2a1a08;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: width .22s ease, height .22s ease, border-radius .22s ease, margin .22s ease, font-size .22s ease;
}
.detail-logo img { width: 100%; height: 100%; object-fit: cover; }
.detail-name { font-size: 24px; margin: 0 0 6px; transition: font-size .2s ease, margin .2s ease; }
.detail-badges { font-size: 13px; color: var(--text-dim); }

/* Kompakter Turnierkopf beim Hochscrollen: Bild links, Name und Stati rechts. */
.topbar-fixed.compact .detail-head {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  text-align: left; padding: 2px 0;
}
.topbar-fixed.compact .detail-logo {
  width: 44px; height: 44px; border-radius: 12px; margin: 0; font-size: 20px; flex: none;
}
.topbar-fixed.compact .detail-name { font-size: 18px; margin: 0 0 2px; }
.topbar-fixed.compact .detail-titles { text-align: left; overflow: hidden; }
.topbar-fixed.compact .detail-name,
.topbar-fixed.compact .detail-badges { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Aktionsknoepfe im Team-Kopf (Bild waehlen/entfernen). Gross zentriert, kompakt
   links neben dem verkleinerten Bild. */
.team-head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.topbar-fixed.compact .team-head-actions { justify-content: flex-start; margin-top: 2px; flex-wrap: nowrap; }
.team-head-actions .btn { width: auto; }
.team-head-actions .btn.small, .team-head-actions .logo-btn.small { font-size: 12px; padding: 7px 12px; }

/* ---------- Danger-Button ---------- */
.btn-danger { background: rgba(231,76,60,.15); color: #ff8a7a; }

/* ---------- Diagnose-Banner ---------- */
.diag-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 100;
  padding: calc(var(--safe-top) + 10px) 40px 10px 14px;
  font-size: 13px; line-height: 1.4; color: #fff;
}
.diag-banner code { background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 5px; }
.diag-banner.warn { background: #b9541f; }
.diag-banner.ok { background: #1f7a44; }
.diag-close {
  position: absolute; right: 12px; top: calc(var(--safe-top) + 8px);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.25); cursor: pointer;
}

/* ---------- Team-Chips (Vorschau) ---------- */
.team-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.team-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid rgba(255,255,255,.06);
  border-radius: 999px; padding: 5px 12px 5px 5px; font-size: 13px;
}
.chip-avatar {
  width: 22px; height: 22px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.chip-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Team-Karte ---------- */
.team-card { display: flex; align-items: center; gap: 14px; }
.team-avatar {
  width: 48px; height: 48px; border-radius: 14px; flex: none; overflow: hidden;
  display: grid; place-items: center; font-size: 17px; font-weight: 700;
}
.team-avatar img { width: 100%; height: 100%; object-fit: cover; }
.team-info { flex: 1; min-width: 0; }
.team-info h3 { margin: 0; font-size: 17px; }

/* ---------- Spieler-Zeile ---------- */
.player-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.player-row input {
  flex: 1; font-size: 16px; color: var(--text);
  background: var(--card); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.player-row input:focus { border-color: var(--accent); }
.player-del {
  flex: none; width: 40px; height: 40px; border-radius: 12px; border: none;
  background: rgba(231,76,60,.15); color: #ff8a7a; font-size: 16px; cursor: pointer;
}
.player-row.has-warn.soft input { border-color: var(--accent); }
.player-row.has-warn.error input { border-color: var(--danger); }
.warn-badge {
  flex: none; width: 40px; height: 40px; border: none; border-radius: 12px;
  background: transparent; font-size: 18px; cursor: pointer; display: grid; place-items: center;
}
.warn-badge:active { background: var(--card-hi); }

/* ---------- Turnierbaum ---------- */
.screen.wide { max-width: 100%; }
.bracket {
  display: flex; gap: 18px; overflow-x: auto; padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch;
}
.round-col {
  display: flex; flex-direction: column;
  min-width: 172px; flex: none;
}
.round-head {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--accent-2); text-align: center; margin-bottom: 10px; font-weight: 600;
  height: 15px; flex: none;
}
/* Body verteilt die Matches gleichmäßig -> jede Folge-Runde sitzt mittig
   zwischen ihren zwei Vorgänger-Matches (klassischer Bracket-Look). */
.round-body {
  flex: 1 1 auto;
  display: flex; flex-direction: column; justify-content: space-around;
}
.match-card {
  background: var(--card); border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
  margin: 5px 0; flex: none;
}
.slot {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; font-size: 14px;
}
.slot + .slot { border-top: 1px solid rgba(255,255,255,.07); }
.slot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-avatar {
  width: 20px; height: 20px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-size: 9px; font-weight: 700;
}
.slot-avatar img { width: 100%; height: 100%; object-fit: cover; }
.slot.winner { background: rgba(46,204,113,.15); font-weight: 600; }
.slot.tbd, .slot.bye { color: var(--text-dim); }
.slot.tbd span, .slot.bye span { padding-left: 4px; }

/* ---------- Warnhinweis ---------- */
.warn-note {
  background: rgba(230,126,34,.15); border: 1px solid rgba(230,126,34,.4);
  color: var(--accent-2); border-radius: 12px; padding: 12px 14px;
  font-size: 14px; line-height: 1.4; margin: 0 0 12px;
}

/* ---------- klickbare Teams ---------- */
.slot.clickable, .team-chip.clickable { cursor: pointer; }
.slot.clickable:active { background: var(--card-hi); }
.team-chip.clickable:active { background: var(--card-hi); }

/* ---------- Spieler-Overlay (Bottom Sheet) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s ease;
}
.overlay.show { opacity: 1; }
.sheet {
  width: 100%; max-width: 640px;
  background: var(--bg-2); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(var(--safe-bottom) + 22px);
  transform: translateY(100%); transition: transform .25s ease;
  max-height: 80vh; overflow-y: auto;
}
/* Willkommens-Screen beim ersten Start */
.welcome-head { text-align: center; }
.welcome-logo {
  width: 76px; height: 76px; border-radius: 18px; overflow: hidden; margin: 2px auto 12px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}
.welcome-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.welcome-head h2 { margin: 0 0 8px; font-size: 22px; }
.welcome-intro { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin: 0; }
.welcome-note {
  margin: 16px 0 0; padding: 11px 13px; border-radius: 12px;
  background: rgba(255,255,255,.06); color: var(--text-dim);
  font-size: 13px; line-height: 1.45; text-align: center;
}
.overlay.show .sheet { transform: translateY(0); }
.sheet-head { text-align: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 10px 0 2px; }
.player-list { margin-top: 6px; }
.player-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 12px; padding: 13px 14px;
  margin-bottom: 8px; font-size: 16px;
}
.player-item .pnum {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent); color: #2a1a08;
}

/* ---------- Play-Aktion auf Match-Karte ---------- */
.match-act {
  text-align: center; font-size: 12px; font-weight: 600; cursor: pointer;
  height: 28px; line-height: 28px; padding: 0 6px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: var(--accent-2); background: rgba(230,126,34,.08);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.match-act.done { color: var(--ok); background: rgba(46,204,113,.08); }
.match-act.placeholder { visibility: hidden; cursor: default; }
.match-act:active { filter: brightness(1.2); }

/* ---------- Spiel-Ansicht ---------- */
.beer-hint {
  background: var(--card); border-radius: 12px; padding: 11px 14px;
  font-size: 13px; color: var(--text-dim); margin: 0 0 14px; line-height: 1.4;
}
.match-team {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  border-left: 5px solid #888; margin-bottom: 8px;
}
.match-team-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.match-team-head h3 { margin: 0; font-size: 19px; }
.beer-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-top: 1px solid rgba(255,255,255,.06);
}
.beer-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.beer-ctrl { display: flex; align-items: center; gap: 12px; flex: none; }
.beer-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; background: rgba(255,255,255,.1); color: var(--text);
  display: grid; place-items: center;
}
.beer-btn.plus { background: var(--accent); color: #2a1a08; }
.beer-btn:active { transform: scale(.9); }
.beer-count { min-width: 26px; text-align: center; font-size: 19px; font-weight: 700; }
.win-btn { margin-top: 14px; }
.vs { text-align: center; font-weight: 800; color: var(--text-dim); margin: 6px 0; letter-spacing: 2px; }

/* ---------- Statistik ---------- */
.stat-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.stat-rank {
  flex: none; width: 26px; text-align: center; font-size: 15px; font-weight: 700;
  color: var(--text-dim);
}
.stat-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.stat-info { flex: 1; min-width: 0; }

/* ---------- Spieler-Symbole ---------- */
.player-ava, .beer-ava, .stat-ava {
  flex: none; border-radius: 50%; overflow: hidden; color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.player-ava { width: 28px; height: 28px; font-size: 12px; }
.beer-ava { width: 26px; height: 26px; font-size: 11px; }
.stat-ava { width: 34px; height: 34px; font-size: 14px; }
.player-ava img, .beer-ava img, .stat-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.beer-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-ava-btn { flex: none; border: none; background: none; padding: 0; margin: 0; cursor: pointer; }
.stat-name { font-size: 16px; font-weight: 600; }
.stat-total { flex: none; text-align: right; font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-total small { font-size: 13px; }
.stat-break { font-size: 11px; color: var(--text-dim); font-weight: 500; }

/* ---------- Gruppen-Tabelle & Spiele ---------- */
.standings { background: var(--card); border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.st-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 15px; }
.st-row + .st-row { border-top: 1px solid rgba(255,255,255,.05); }
.st-head { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.st-rank { width: 20px; text-align: center; color: var(--text-dim); flex: none; }
.st-team { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.st-team > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-num { width: 34px; text-align: center; flex: none; }
.st-row.qual { background: rgba(46,204,113,.12); }
.st-row.qual .st-rank { color: var(--ok); font-weight: 700; }
.st-head .st-num { color: var(--text-dim); font-size: 13px; }
.legend { text-align: center; opacity: .85; }
.rps-need { display: flex; align-items: center; gap: 12px; }
.rps-need .tourney-info { flex: 1; min-width: 0; }
.rps-need .btn.small { flex: none; }
.rps-note { color: var(--accent); font-weight: 600; }

.fixture { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fx-teams { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font-size: 15px; }
.fx-vs { color: var(--text-dim); font-size: 12px; }
.fx-win { font-weight: 700; color: var(--accent-2); }
.fx-act { color: var(--accent-2); font-size: 13px; font-weight: 600; flex: none; }
.fixture.done .fx-act { color: var(--ok); }

/* ---------- Sieger-Screen ---------- */
.confetti-canvas {
  position: fixed; inset: 0; z-index: 300; pointer-events: none;
}
.winner-screen {
  text-align: center; padding: 24px 16px 20px; margin: 8px 0 20px;
  background: radial-gradient(circle at 50% 0%, rgba(255,183,77,.18), transparent 70%);
}
.winner-crown { font-size: 72px; animation: pop .6s ease, floaty 3s ease-in-out infinite .6s; }
.winner-label {
  text-transform: uppercase; letter-spacing: 3px; font-size: 13px;
  color: var(--accent-2); margin: 4px 0 14px; font-weight: 700;
}
.winner-avatar {
  width: 108px; height: 108px; border-radius: 28px; margin: 0 auto 14px; overflow: hidden;
  display: grid; place-items: center; font-size: 46px; font-weight: 800; color: #2a1a08;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: pop .6s ease .1s both;
}
.winner-avatar img { width: 100%; height: 100%; object-fit: cover; }
.winner-name { font-size: 30px; margin: 0 0 4px; animation: pop .6s ease .2s both; }
.winner-sub { color: var(--text-dim); margin: 0; }
.winner-card {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  background: linear-gradient(160deg, rgba(255,183,77,.22), rgba(230,126,34,.18));
  border: 1px solid rgba(255,183,77,.4); font-size: 17px; color: var(--accent-2);
}
.winner-card .chevron { margin-left: auto; color: var(--accent-2); }

@keyframes pop {
  0% { transform: scale(.3); opacity: 0; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ---------- Backup ---------- */
.backup-text {
  width: 100%; min-height: 100px; resize: vertical;
  background: var(--card); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 12px; color: var(--text); font-size: 13px;
  font-family: ui-monospace, Menlo, monospace; outline: none;
}
.backup-text:focus { border-color: var(--accent); }

/* ---------- Druckbarer Turnierplan ---------- */
.print-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.print-bar .btn { margin-left: auto; }
.print-sheet {
  background: #fff; color: #111; border-radius: 8px; padding: 18px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.print-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 16px; }
.print-head h1 { margin: 0 0 2px; font-size: 22px; color: #111; }
.print-head div { font-size: 12px; color: #444; text-transform: uppercase; letter-spacing: 1px; }
.phead-logo { display: inline-block; width: 34px; height: 34px; border-radius: 7px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.phead-logo img { width: 100%; height: 100%; object-fit: cover; }
.print-bracket { display: flex; gap: 24px; align-items: stretch; min-width: max-content; }
.pcol { display: flex; flex-direction: column; min-width: 200px; }
.phead {
  text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: #333; margin-bottom: 12px; height: 14px; flex: none;
}
.pbody { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: space-around; }
.pmatch {
  border: 1.5px solid #111; border-radius: 6px; overflow: hidden;
  margin: 8px 0; flex: none; width: max-content; min-width: 200px;
  break-inside: avoid; page-break-inside: avoid;
}
.pmatch.champ { border-width: 2.5px; }
.pslot { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 12px; font-size: 15px; color: #111; }
.pslot + .pslot { border-top: 1px solid #888; }
.pmark { flex: none; width: 16px; height: 16px; border: 1.5px solid #111; border-radius: 3px; display: grid; place-items: center; font-size: 12px; }
.pmark.trophy { border: none; font-size: 18px; }
.pthumb { flex: none; width: 22px; height: 22px; border-radius: 4px; overflow: hidden; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pname { flex: 1; min-height: 20px; white-space: nowrap; padding-right: 8px; }

/* Team-/Spieler-Aufstellung im Druck */
.print-roster { margin-top: 24px; }
.print-roster h2 {
  font-size: 18px; color: #111; border-bottom: 2px solid #111;
  padding-bottom: 6px; margin: 0 0 14px;
}
.proster-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.pteam {
  border: 1.5px solid #111; border-radius: 6px; padding: 10px 12px;
  width: calc(33.333% - 10px); box-sizing: border-box;
  break-inside: avoid; page-break-inside: avoid;
}
.pteam-head {
  font-weight: 700; font-size: 15px; color: #111; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #999; padding-bottom: 5px;
}
.pteam-chip { width: 14px; height: 14px; border-radius: 3px; border: 1px solid #111; flex: none; }
.pteam-thumb { width: 22px; height: 22px; border-radius: 4px; overflow: hidden; flex: none; }
.pteam-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pteam-players { margin: 0; padding-left: 20px; font-size: 14px; color: #111; }
.pteam-players li { margin: 3px 0; }
.pteam-empty { font-size: 13px; color: #555; font-style: italic; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  html, body { background: #fff !important; }
  .no-print, .diag-banner, .toast, .fab, .header-btn { display: none !important; }
  .screen { padding: 0 !important; max-width: none !important; margin: 0 !important; }
  .print-sheet { border-radius: 0; padding: 0; overflow: visible; }
  .print-bracket { min-width: 0; }
  .pmatch { break-inside: avoid; page-break-inside: avoid; }
  .pcol { break-inside: avoid; }
  .print-roster { break-before: page; page-break-before: always; }
  .pteam { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------- Eigene Dialoge (Ersatz fuer confirm/prompt/alert) ---------- */
.fb-dialog-back {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px calc(24px + env(safe-area-inset-right, 0px)) 24px calc(24px + env(safe-area-inset-left, 0px));
  background: rgba(0,0,0,0); backdrop-filter: blur(0px);
  transition: background .16s ease, backdrop-filter .16s ease;
}
.fb-dialog-back.fb-dialog-open { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.fb-dialog-back.fb-dialog-closing { background: rgba(0,0,0,0); backdrop-filter: blur(0px); }
.fb-dialog {
  width: 100%; max-width: 340px;
  background: var(--card); color: var(--text);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  padding: 20px 18px 16px;
  transform: scale(.92); opacity: 0;
  transition: transform .18s cubic-bezier(.2,.9,.3,1.2), opacity .16s ease;
}
.fb-dialog-back.fb-dialog-open .fb-dialog { transform: scale(1); opacity: 1; }
.fb-dialog-back.fb-dialog-closing .fb-dialog { transform: scale(.96); opacity: 0; }
.fb-dialog-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.fb-dialog-msg { font-size: 14px; line-height: 1.45; color: var(--text-dim); text-align: center; }
.fb-dialog-input {
  width: 100%; margin-top: 14px; box-sizing: border-box;
  padding: 12px 12px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid rgba(255,255,255,.12);
  color: var(--text); font-size: 16px;
}
.fb-dialog-input:focus { outline: none; border-color: var(--accent); }
.fb-dialog-actions { display: flex; gap: 8px; margin-top: 18px; }
.fb-dialog-btn {
  flex: 1; padding: 12px 10px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--card-hi); color: var(--text);
  transition: transform .08s ease, filter .12s ease;
}
.fb-dialog-btn:active { transform: scale(.97); }
.fb-dialog-btn.primary { background: linear-gradient(160deg, var(--accent-2), var(--accent)); color: #2a1a08; }
.fb-dialog-btn.danger { background: rgba(231,76,60,.18); color: #ff8a7a; }
.fb-dialog-btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid rgba(255,255,255,.12); }
/* Bei nur einem Knopf nicht auf volle Breite strecken wirkt ruhiger */
.fb-dialog-actions .fb-dialog-btn:only-child { flex: 0 1 auto; margin: 0 auto; min-width: 120px; }

/* ---------- Wischbare Listeneintraege ---------- */
.swipe-wrap { position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 12px; }
.swipe-wrap .card { margin-bottom: 0; }
/* Der Aktionsbereich fuellt die GANZE Flaeche (voll bis unter die Karte),
   damit die runde Ecke der Karte beim Wischen nie einen Spalt freilaesst.
   Der eigentliche Knopf sitzt rechts. */
.swipe-actions {
  position: absolute; inset: 0;
  display: flex; justify-content: flex-end;
  background: var(--danger);
}
.swipe-actions.leave { background: #b9772a; }
/* Bei zwei Aktionen (Copy links) fuellt Blau die Flaeche, damit an der
   abgerundeten Ecke links neben Copy kein rotes Artefakt durchscheint. Der
   zweite Knopf (Loeschen/Verlassen) bekommt seine eigene Farbe. */
.swipe-actions.with-copy { background: #2e6da4; }
.swipe-actions.with-copy .swipe-action-btn:not(.copy) { background: var(--danger); }
.swipe-actions.with-copy.leave .swipe-action-btn:not(.copy) { background: #b9772a; }
.swipe-action-btn {
  border: none; width: 104px; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-weight: 700; color: #fff; cursor: pointer;
}
/* Copy-Aktion mit eigener Farbe, damit sie sich vom roten Loeschen abhebt. */
.swipe-action-btn.copy { background: #2e6da4; }
.swipe-action-btn .ico { font-size: 20px; line-height: 1; }
.swipe-fore {
  position: relative;
  background: var(--card); border-radius: var(--radius);
}
/* Der Aktions-Hintergrund liegt nur beim Wischen frei. Ein eigener Stapelkontext
   fasst Vordergrund und Aktion zu einer Ebene zusammen, damit beim Scrollen unter
   dem unscharfen Kopf nichts Rotes durchflackert. */
.swipe-wrap { isolation: isolate; }
/* Kein Zusammenschrumpfen beim Druck, sonst wird der Aktionshintergrund als
   Rand sichtbar. Der undurchsichtige Hintergrund oben verdeckt die Aktion
   vollstaendig, solange nicht gewischt wird. */
.swipe-fore .card:active { transform: none; }

/* Dezenter Bearbeiten-Knopf, inline rechts neben der Teamanzahl */
.edit-inline {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; box-sizing: border-box;
  background: none; border: 1px solid rgba(255,255,255,.18); border-radius: 50%;
  cursor: pointer; color: var(--text-dim); font-size: 11px; line-height: 1;
  padding: 0; margin-left: 6px; opacity: .7;
  vertical-align: middle;
}
.edit-inline:hover { opacity: .95; }
.edit-inline:active { opacity: 1; transform: scale(.94); }

/* ---------- Spielart-Symbole ---------- */
.format-icon svg, .game-symbol svg { display: inline-block; vertical-align: middle; }
.game-line { display: flex; align-items: center; gap: 5px; }
.game-ico { display: inline-flex; }
.game-ico svg { display: block; }

/* Versions-Warnung auf der Turnierkarte */
.compat-warn { color: #ffcc66; font-weight: 600; }

/* Hinweis, dass ein Turnier geteilt ist (Startliste) */
.share-line { color: var(--accent); font-weight: 600; }

/* Rollen-Pille oben rechts im Turnier (Bereitsteller / Schreiber / Leser) */
.role-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--text-dim);
  background: var(--card-hi);
  border: 1px solid rgba(255,255,255,.12);
}
.role-pill.owner {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* Mitgliederverwaltung im Teilen-Fenster */
.member-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 4px 0 10px;
}
.member-add #mPlayer { flex: 1 1 100%; }
.member-add input {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid rgba(255,255,255,.1);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
}
.member-add select, .member-role {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.1);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 8px;
  font-size: 14px;
}
.member-add .btn { width: auto; padding: 10px 14px; }
.member-list { margin: 0 0 4px; }
.member-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  margin-bottom: 8px;
}
.member-mail {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
/* Name plus E-Mail untereinander in der Mitglieder-Zeile. */
.member-idty { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.member-idty .member-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-idty .member-mail { flex: none; font-size: 12px; color: var(--text-dim); }
.member-del {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
}
.member-add-err {
  margin: 0 4px 10px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* Nach unten ziehen zum Aktualisieren (installierte App) */
.ptr-indicator {
  position: fixed;
  top: calc(-44px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  opacity: 0;
  z-index: 60;
  pointer-events: none;
  transition: opacity .15s ease;
}
.ptr-indicator.ready { background: var(--ok); }
.ptr-indicator.spin { animation: ptr-rotate .8s linear infinite; }
@keyframes ptr-rotate { to { transform: translateX(-50%) translateY(58px) rotate(360deg); } }

/* ---------- Sprach-Picker ---------- */
.lang-list { max-height: 52vh; overflow-y: auto; margin: 6px 0; -webkit-overflow-scrolling: touch; }
.lang-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 8px; border: none; background: none; color: var(--text);
  font-size: 16px; text-align: left; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.lang-row:active { background: var(--card-hi); }
.lang-row.active { color: var(--accent-2); font-weight: 600; }
.lang-flag { font-size: 22px; width: 30px; text-align: center; flex: none; }
.lang-name { flex: 1; }
.lang-check { color: var(--accent-2); font-weight: 700; width: 18px; text-align: center; flex: none; }

/* Installationsleiste der Web-App (nur im Browser, nicht in der nativen App) */
.install-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom));
  z-index: 900; display: flex; align-items: center; gap: 10px;
  background: var(--card-hi); color: var(--text);
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  padding: 12px 12px 12px 14px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.install-bar span { flex: 1; line-height: 1.35; }
.install-go {
  flex: none; border: 0; border-radius: 10px; padding: 9px 14px;
  font-weight: 700; font-size: 14px; color: #2a1a08; cursor: pointer;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
}
.install-x {
  flex: none; border: 0; background: transparent; color: var(--text-dim);
  font-size: 16px; padding: 4px 6px; cursor: pointer;
}
