:root {
  --bg: #0b0d10;
  --bg-elev: #14171d;
  --bg-elev-2: #1b1f27;
  --line: #262c36;
  --text: #e7eaf0;
  --muted: #8b94a5;
  --accent: #a855f7;
  --accent-soft: rgba(168, 85, 247, .16);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 18px; font-size: 13px; margin: 6px 0 0; }

/* ------------------------------- Login ---------------------------------- */
.login {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px);
}
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-logo {
  width: 76px; height: 76px; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #7c3aed, #a855f7);
  color: #fde047; font-weight: 800; font-size: 30px;
  border-radius: 22px; box-shadow: 0 12px 30px rgba(124, 58, 237, .3);
}
.login h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.2px; }
.login p { margin: 0 0 22px; font-size: 14px; }
.login form { display: grid; gap: 12px; }

input[type=password], input[type=text], input[type=search] {
  width: 100%; padding: 15px 16px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  font-size: 16px; /* < 16px löst auf iOS Auto-Zoom aus */
  outline: none;
}
input:focus { border-color: var(--accent); }

/* ------------------------------- Buttons -------------------------------- */
.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--bg-elev-2); color: var(--text);
  border-radius: 14px; padding: 14px 18px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  min-height: 48px; cursor: pointer;
  transition: opacity .12s;
}
.btn:active { opacity: .6; }
.btn:disabled { opacity: .35; cursor: default; }
.btn-lg { width: 100%; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-danger  { background: var(--err); border-color: transparent; color: #2a0b0b; }
.btn-ok      { background: var(--ok); border-color: transparent; color: #04231a; }
.btn-sm { padding: 9px 13px; min-height: 38px; font-size: 13.5px; border-radius: 11px; }

.icon-btn {
  appearance: none; background: none; border: 0; color: var(--muted);
  padding: 8px; margin: -8px; cursor: pointer; display: grid; place-items: center;
}

/* ------------------------------- Layout --------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 12px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(11, 13, 16, .82);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -.3px; }

main {
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 620px; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(11, 13, 16, .9);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);   /* Home-Indicator freihalten */
}
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  color: var(--muted); font-family: inherit; font-size: 10.5px; font-weight: 600;
  height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  position: relative;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }
.badge {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  background: var(--err); color: #fff; font-style: normal;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 5px; border-radius: 9px; min-width: 16px; text-align: center;
}

/* -------------------------------- Cards --------------------------------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.section-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 22px 4px 9px;
}
.section-title:first-child { margin-top: 4px; }

/* Hero */
.hero { text-align: center; padding: 22px 16px; }
.hero-name { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .05em;
  padding: 6px 13px; border-radius: 999px; text-transform: uppercase;
}
.status-pill.on  { background: rgba(52, 211, 153, .14); color: var(--ok); }
.status-pill.off { background: rgba(248, 113, 113, .14); color: var(--err); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.hero-players { font-size: 40px; font-weight: 700; letter-spacing: -1.5px; margin: 14px 0 2px; }
.hero-players small { font-size: 20px; font-weight: 600; color: var(--muted); }
.hero-sub { font-size: 13px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 10px; text-align: center;
}
.stat-label { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 19px; font-weight: 700; margin-top: 5px; letter-spacing: -.3px; }
.stat-value small { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ------------------------------ Spielerzeile ---------------------------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px;
  width: 100%; text-align: left; font-family: inherit; color: var(--text);
  cursor: pointer; appearance: none;
}
.row:active { background: var(--bg-elev-2); }
.avatar {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 40px;
  background: var(--bg-elev-2); image-rendering: pixelated;
}
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.row-name .dot { width: 7px; height: 7px; flex: 0 0 7px; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-right { text-align: right; font-size: 12.5px; color: var(--muted); flex: 0 0 auto; }
.row-right b { display: block; color: var(--text); font-size: 14px; font-weight: 600; }

/* ------------------------------ Steuerung ------------------------------- */
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls .btn-lg { grid-column: 1 / -1; }

/* ------------------------------ Whitelist ------------------------------- */
.reject-card { border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .05); }
.add-form { display: flex; gap: 8px; }
.add-form input { flex: 1; }

/* ------------------------------- Konsole -------------------------------- */
.console {
  background: #05070a; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; height: 58dvh; overflow-y: auto;
  font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word;
  -webkit-overflow-scrolling: touch;
}
.console div { color: #9fb0c4; padding: 1px 0; }
.console div.warn { color: var(--warn); }
.console div.err { color: var(--err); }
.console-form { display: flex; gap: 8px; margin-top: 10px; }
.console-form input { flex: 1; font-family: ui-monospace, Menlo, monospace; }

/* -------------------------------- Sheets -------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px calc(16px) calc(var(--safe-b) + 16px);
}
.sheet {
  width: 100%; max-width: 420px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 22px; padding: 22px;
  animation: rise .22s cubic-bezier(.32, .72, 0, 1);
}
.sheet-tall { max-height: 82dvh; overflow-y: auto; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.sheet h2 { margin: 0 0 6px; font-size: 18px; }
.sheet p { margin: 0 0 18px; font-size: 14px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-of-type { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-head .avatar { width: 56px; height: 56px; flex-basis: 56px; border-radius: 13px; }
.detail-head h2 { margin: 0; font-size: 20px; }

/* -------------------------------- Toast --------------------------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  z-index: 80; max-width: min(92vw, 420px);
  background: var(--bg-elev-2); border: 1px solid var(--line);
  color: var(--text); padding: 13px 18px; border-radius: 13px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: rise .2s ease;
}
.toast.ok  { border-color: rgba(52, 211, 153, .5); }
.toast.err { border-color: rgba(248, 113, 113, .5); }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 26px 10px; }

/* Filterleiste */
.filters { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; white-space: nowrap; cursor: pointer; font-family: inherit;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.spinner {
  width: 22px; height: 22px; margin: 40px auto;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
