/* Farben und Schrift stammen 1:1 aus dem Lehrer-HUD (server/app/index.html im
   Carlsson-Companion), Dark-Palette. Die Light-Variante des HUD entfällt hier:
   FindMyCrew ist eine reine Nacht-App. */
@font-face{font-family:"Geist";src:url("fonts/geist-400.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:"Geist";src:url("fonts/geist-500.woff2") format("woff2");font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:"Geist";src:url("fonts/geist-600.woff2") format("woff2");font-weight:600;font-style:normal;font-display:swap}

:root {
  --bg: #0A0B0E;          /* HUD --ground */
  --bg-2: #14161C;        /* HUD --surface */
  --card: #14161C;        /* HUD --surface */
  --card-2: #1C1F27;      /* HUD --surface-2 */
  --line: #23262F;        /* HUD --hair */
  --text: #F3F5F9;        /* HUD --ink */
  --muted: #9AA1AD;       /* HUD --muted */
  --faint: #5E6675;       /* HUD --faint */
  --accent: #7C8AFF;      /* HUD --accent */
  --accent-2: #5B63E6;    /* HUD --accent (Light) — als Verlaufspartner */
  --accent-soft: #191C2E; /* HUD --accent-soft */
  --ok: #37D19F;          /* HUD --pos */
  --warn: #F2B750;        /* HUD --late */
  --danger: #F76D8A;      /* HUD --beh */
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.4);
  --radius: 16px;         /* HUD --r */
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* RGB-Tripel: damit Flächen mit Alpha dieselbe Palette benutzen. */
  --accent-rgb: 124,138,255;
  --ok-rgb: 55,209,159;
  --warn-rgb: 242,183,80;
  --danger-rgb: 247,109,138;
  --surface-rgb: 20,22,28;

  --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; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { letter-spacing: -.025em; }
.hidden { display: none !important; }

.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- Join ---------- */
.join { align-items: center; justify-content: center; padding: 24px; }
.join-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 26px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.logo { font-size: 26px; margin: 0 0 6px; font-weight: 600; letter-spacing: -.5px; }
.logo span { color: var(--accent); }
.tagline { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; line-height: 1.4; }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.4; }
input[type="text"] {
  width: 100%; padding: 13px 14px; font-size: 16px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }

.emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-row button {
  font-size: 22px; width: 44px; height: 44px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line); cursor: pointer;
}
.emoji-row button.sel { border-color: var(--accent); background: rgba(var(--accent-rgb),.18); }

.btn {
  border: none; border-radius: 12px; padding: 13px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; color: var(--text); background: var(--card-2);
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: rgba(var(--danger-rgb),.14); color: var(--danger); border: 1px solid rgba(var(--danger-rgb),.4); }
.btn.big { width: 100%; padding: 15px; font-size: 16px; margin-top: 6px; }
.btn:active { transform: translateY(1px); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  border-bottom: 1px solid var(--line); background: rgba(var(--surface-rgb),.7); backdrop-filter: blur(8px);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-left strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.crew-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; font-weight: 600;
}
.crew-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.topbar-right { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px;
  background: var(--card); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; padding: 10px 12px 4px; }
.tab {
  flex: 1; padding: 10px; border-radius: 12px; font-size: 14px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--text); border-color: var(--accent); background: rgba(var(--accent-rgb),.14); }
.count { display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 4px;
  border-radius: 999px; background: var(--card-2); font-size: 12px; }

/* ---------- Views ---------- */
.view { flex: 1; overflow: auto; padding: 12px; padding-bottom: 96px; }

/* Karte */
.map-wrap {
  width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--bg-2);
  /* Alle Gesten gehören uns (Pinch/Pan), sonst zoomt der Browser die Seite. */
  touch-action: none;
}
.map-inner { position: relative; width: 100%; transform-origin: 0 0; will-change: transform; }

.zoom-btn {
  position: absolute; right: 22px; z-index: 5; margin-top: 8px;
  background: rgba(var(--surface-rgb),.85); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(6px);
}
.map-hint { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 4px 0; line-height: 1.4; }
#map-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
#markers { position: absolute; inset: 0; }
/* --inv setzt die App auf #markers gegen den Kartenzoom: Pins behalten dadurch
   ihre Größe und bleiben bei jedem Zoom gestochen scharf. */
.place-pin {
  position: absolute;
  transform: translate(-50%, -50%) scale(var(--inv, 1));
  display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none;
}
.place-pin .ring {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.7);
}
.friend-pin {
  position: absolute;
  transform: translate(-50%, -100%) scale(var(--inv, 1));
  transform-origin: 50% 100%;
  display: flex; flex-direction: column; align-items: center; pointer-events: auto;
}
.friend-pin .bubble {
  background: var(--card); border: 2px solid var(--accent);
  border-radius: 999px; padding: 3px 9px 3px 5px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
.friend-pin.gps .bubble { border-color: var(--ok); }
.friend-pin.pinned .bubble { border-color: var(--warn); border-style: dashed; }

/* Selbst gesetzte Nadel im Check-in-Sheet */
.pin-state {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px; padding: 9px 12px; border-radius: 12px;
  background: rgba(var(--warn-rgb), .10); border: 1px solid rgba(var(--warn-rgb), .35);
  font-size: 13px; color: var(--warn); font-weight: 600;
}
.pin-state button {
  background: none; border: none; color: var(--muted); font-size: 12.5px;
  text-decoration: underline; cursor: pointer; flex: 0 0 auto; padding: 2px 0;
}
.friend-pin .em { font-size: 15px; }
.friend-pin .tail { width: 2px; height: 10px; background: var(--accent); }
.friend-pin.gps .tail { background: var(--ok); }
.friend-pin.me .bubble { border-color: var(--warn); }
.friend-pin.me .tail { background: var(--warn); }
.cluster-badge {
  position:absolute; transform: translate(-50%,-50%);
  background: var(--accent); color:#fff; border-radius:999px;
  min-width:22px; height:22px; padding:0 6px; font-size:12px; font-weight: 600;
  display:flex; align-items:center; justify-content:center; pointer-events:none;
}

/* Crew-Liste */
.crew-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.member {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.member.me { border-color: rgba(var(--warn-rgb),.5); background: rgba(var(--warn-rgb),.06); }
.member .avatar {
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  background: var(--bg-2); border: 1px solid var(--line);
}
.member .info { min-width: 0; flex: 1; }
.member .name-row { display: flex; align-items: baseline; gap: 8px; }
.member .name { font-weight: 600; font-size: 15.5px; }
.member .me-tag { font-size: 11px; color: var(--warn); font-weight: 600; }
.member .loc { color: var(--text); font-size: 14px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .loc .src { font-size: 11px; color: var(--muted); }
.member .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.member .note { color: var(--muted); font-size: 12.5px; font-style: italic; margin-top: 3px; }
.age { color: var(--muted); font-size: 12.5px; }
.age.fresh { color: var(--ok); }
.age.old { color: var(--warn); }
.age.stale { color: var(--danger); }
.dist { color: var(--accent); font-weight: 600; }

.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b)); z-index: 30;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  border: none; border-radius: 999px; padding: 15px 26px; font-size: 16px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(var(--accent-rgb),.5); cursor: pointer;
}
.fab:active { transform: translateX(-50%) translateY(1px); }

/* ---------- Sheets ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg-2); border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + var(--safe-b));
  max-height: 88vh; overflow: auto; box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 12px; }
.sheet h2 { margin: 0 0 16px; font-size: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.chip.sel { border-color: var(--accent); background: rgba(var(--accent-rgb),.2); }
.chip .dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align: middle; }

/* ---------- Stage-Board: volle Breite, zeigt wer gerade spielt ---------- */
.stage-board { display: flex; flex-direction: column; gap: 8px; }
.stage-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left; cursor: pointer; font: inherit;
  padding: 12px 14px; border-radius: 14px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line);
  border-left: 4px solid var(--stage, var(--accent));
}
.stage-card.sel { border-color: var(--accent); background: rgba(var(--accent-rgb),.18); border-left-color: var(--stage, var(--accent)); }
/* Fortschritt des laufenden Sets als dezente Füllung im Hintergrund. */
.stage-bar {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0;
  background: var(--stage, var(--accent)); opacity: .13;
  transition: width .6s linear; pointer-events: none;
}
.stage-card > *:not(.stage-bar) { position: relative; z-index: 1; }
.stage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.stage-name {
  font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--stage, var(--accent));
}
.stage-left { font-size: 12px; font-weight: 600; color: var(--muted); flex: 0 0 auto; }
.stage-card.live .stage-left { color: var(--ok); }
.stage-now { font-size: 17px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.stage-card:not(.live) .stage-now { color: var(--muted); font-weight: 600; }
.stage-sub { font-size: 12px; color: var(--muted); }
.stage-next { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Admin: Crew-Verwaltung ---------- */
.admin-list { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow-y: auto; }
.admin-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
}
.admin-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-row-main b { font-size: 15px; overflow-wrap: anywhere; }
.admin-row-main small { font-size: 12px; color: var(--muted); }
.admin-names { opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .btn { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; }

.quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.quick-row:empty { display: none; }
.quick-chip {
  padding: 9px 13px; border-radius: 12px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: rgba(var(--ok-rgb),.12); border: 1px solid rgba(var(--ok-rgb),.4); color: var(--ok);
}

.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; font-size: 14.5px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.gps-status { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; text-align: center; min-height: 16px; }

/* Kalibrierung */
.sheet-intro { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }

.pick-banner {
  position: fixed; left: 12px; right: 12px; top: calc(12px + var(--safe-t)); z-index: 70;
  background: var(--accent-2); color: #fff; border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.pick-banner button {
  background: rgba(255,255,255,.2); border: none; color: #fff; border-radius: 10px;
  padding: 8px 12px; font-weight: 600; cursor: pointer;
}
body.map-picking .map-inner { cursor: crosshair; }
body.map-picking #map-img { outline: 3px dashed var(--warn); outline-offset: -3px; }

.menu-info { margin: 14px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.menu-info > div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.menu-info span { color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + var(--safe-b)); z-index: 60;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

/* ---------- Uhr-Modus ---------- */
body.watch .tabs, body.watch .topbar-right { display: none; }
body.watch .fab { padding: 20px 30px; font-size: 20px; }
body.watch .chip { padding: 14px 18px; font-size: 16px; }
body.watch .quick-chip { padding: 14px 18px; font-size: 16px; }
body.watch .stage-card { padding: 16px; }
body.watch .stage-now { font-size: 20px; }
body.watch .member .avatar { width: 38px; height: 38px; font-size: 19px; }
