:root {
  --bg: #0d1014;
  --panel: rgba(20, 24, 30, 0.86);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8eaed;
  --muted: #8b939e;
  --accent: #8fd14f;
  --accent-dim: rgba(143, 209, 79, 0.18);
  --change: #ffb347;
  --radius: 12px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); overflow: hidden; }
button, select, input { font: inherit; color: inherit; }

#app { position: fixed; inset: 0; }
#map {
  position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
}
#map.dragging { cursor: grabbing; }

.panel {
  position: absolute; background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

/* ---- Kopf ---- */
.top-left { top: 16px; left: 16px; padding: 14px 16px; width: 280px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  background:
    linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.25) 50%),
    conic-gradient(#7fb238 0 25%, #976d4d 0 50%, #4040ff 0 75%, #7fb238 0);
  background-size: 100% 100%, 50% 50%;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: 0.01em; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.selects { display: grid; gap: 8px; }
.selects label { display: grid; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
select {
  appearance: none; background: rgba(255,255,255,0.05) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b939e'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--panel-border); border-radius: 8px; padding: 7px 28px 7px 10px; text-transform: none; letter-spacing: 0; font-size: 13px;
}
select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toggles { display: grid; gap: 6px; border-top: 1px solid var(--panel-border); padding-top: 10px; }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #c9ced5; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---- Info ---- */
.top-right { top: 16px; right: 16px; width: 260px; padding: 14px 16px; max-height: calc(100% - 150px); overflow: auto; }
.date { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.rel { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 14px 0; }
.stats div { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 8px 10px; }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
#infoChanged { color: var(--change); }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.players li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.players li:hover { background: rgba(255,255,255,0.06); }
.players .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.players .pos { margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.players .none { color: var(--muted); cursor: default; }
.players .none:hover { background: none; }

/* ---- Koordinaten & Zoom ---- */
.coords { left: 16px; bottom: 112px; padding: 6px 10px; font: 12px var(--mono); color: #c9ced5; border-radius: 8px; }
.zoom { position: absolute; right: 16px; bottom: 112px; display: grid; gap: 6px; }
.zoom button, .controls button {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--panel-border);
  background: var(--panel); backdrop-filter: blur(12px); cursor: pointer; font-size: 16px; line-height: 1;
}
.zoom button:hover, .controls button:hover { background: rgba(60, 68, 80, 0.9); }

/* ---- Zeitleiste ---- */
.timeline { left: 16px; right: 16px; bottom: 16px; height: 80px; display: flex; align-items: center; gap: 14px; padding: 0 14px; }
.controls { display: flex; gap: 6px; align-items: center; }
.controls select { height: 36px; }
.controls .play { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #102006; border: none; font-size: 16px; }
.controls .play:hover { background: #a3e063; }
.track-wrap { position: relative; flex: 1; height: 56px; }
#track { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }
.track-tip {
  position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); white-space: nowrap;
  background: #000c; border: 1px solid var(--panel-border); padding: 4px 8px; border-radius: 6px; font-size: 12px; pointer-events: none;
}
.counter { font: 12px var(--mono); color: var(--muted); min-width: 64px; text-align: right; }

/* ---- Zustände ---- */
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); pointer-events: none; }
.empty h2 { font-size: 18px; color: var(--text); text-transform: none; letter-spacing: 0; }
.empty code { background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 4px; font-family: var(--mono); }
.loading { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: var(--panel); padding: 6px 12px; border-radius: 99px; font-size: 12px; color: var(--muted); border: 1px solid var(--panel-border); }

@media (max-width: 800px) {
  .top-right { display: none; }
  .top-left { width: calc(100% - 32px); }
  .toggles { display: none; }
  .coords, .zoom { bottom: 104px; }
  .counter { display: none; }
}

/* =================== Benutzer-Menü (Kartenseite) =================== */
.user-row { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--panel-border); padding-top: 10px; font-size: 13px; }
.user-row .who { min-width: 0; color: #c9ced5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .who strong { color: var(--text); font-weight: 600; }
.user-row .links { margin-left: auto; display: flex; gap: 4px; }
.user-row a, .user-row button { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 4px 6px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.user-row a:hover, .user-row button:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* =================== Gemeinsame Formular-Bausteine =================== */
.field { display: grid; gap: 6px; }
.field > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.field > span em { text-transform: none; letter-spacing: 0; font-style: normal; opacity: 0.8; }
input[type="text"], input[type="password"], input:not([type]) {
  width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; transition: border-color .15s, background .15s;
}
input:focus { outline: none; border-color: var(--accent); background: rgba(143,209,79,0.06); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--panel-border); background: rgba(255,255,255,0.05);
  cursor: pointer; font-size: 13px; font-weight: 550; text-decoration: none; white-space: nowrap; color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: transparent; color: #102006; }
.btn-primary:hover { background: #a3e063; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: #ff8a80; border-color: rgba(255,138,128,0.3); }
.btn-danger:hover, .btn-danger.armed { background: #e5534b; color: #fff; border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; height: 42px; font-size: 14px; }

.form-error { margin: 0; padding: 9px 12px; border-radius: 8px; background: rgba(229,83,75,0.12); border: 1px solid rgba(229,83,75,0.35); color: #ffb4ae; font-size: 13px; }

/* =================== Login =================== */
.auth-page { overflow: hidden; }
#backdrop {
  position: fixed; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px);
  image-rendering: pixelated; filter: blur(2px) saturate(0.7) brightness(0.35); transform: scale(1.03);
}
.auth-page::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(13,16,20,0.35) 0%, rgba(13,16,20,0.9) 75%);
}
.auth-center { position: relative; z-index: 1; min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { position: relative; width: min(380px, 100%); padding: 26px 26px 20px; display: grid; gap: 16px; }
.auth-card .brand { margin-bottom: 6px; }
.auth-card .logo { width: 40px; height: 40px; }
.auth-card h1 { font-size: 19px; }
.hint { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

/* =================== Admin =================== */
body.page-scroll { overflow: auto; }
body.page-scroll::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
}
.admin-wrap { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-head h1 { font-size: 20px; }
.head-actions { display: flex; gap: 8px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.admin-grid .panel { position: relative; }
.side { display: grid; gap: 18px; }
.card { padding: 18px 18px 20px; }
.card h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.badge { font: 11px var(--mono); background: rgba(255,255,255,0.08); padding: 2px 7px; border-radius: 99px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.pw-row { display: flex; gap: 6px; }
.pw-row input { font-family: var(--mono); }

.table-wrap { overflow-x: auto; margin: 0 -18px -20px; }
table.users { width: 100%; border-collapse: collapse; font-size: 13px; }
.users th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--panel-border); }
.users td { padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.users tr:last-child td { border-bottom: 0; }
.users tbody tr:hover td { background: rgba(255,255,255,0.025); }
.users .right { text-align: right; }
.users .muted, .muted { color: var(--muted); }
.users td.nowrap { white-space: nowrap; }
.users .name { display: flex; white-space: nowrap; align-items: center; gap: 10px; font-weight: 550; }
.avatar { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: rgba(143,209,79,0.15); color: var(--accent); flex: none; }
.role { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,0.06); color: #c9ced5; }
.role.admin { background: rgba(255,179,71,0.14); color: var(--change); }
.actions { white-space: nowrap; }
.actions .btn + .btn { margin-left: 6px; }
tr.pw-edit td { background: rgba(143,209,79,0.05); }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input { width: 220px; height: 30px; padding: 4px 10px; font-family: var(--mono); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 16px; border-radius: 10px; font-size: 13px; background: #1d2a17; border: 1px solid rgba(143,209,79,0.4); color: #d7f5b8; box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.toast.err { background: #2c1514; border-color: rgba(229,83,75,0.5); color: #ffb4ae; }

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
}

.you { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border: 1px solid var(--panel-border); padding: 1px 5px; border-radius: 4px; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
.user-row .who { display: flex; align-items: center; gap: 8px; }
