/* ==========================================================================
   Chase - Real-Life-Manhunt (chase.tagwhy.com)

   Eine Schriftfamilie (IBM Plex Sans, Tabellenziffern für Timer/Codes),
   Icons MIT Wort auf jedem Button (Sprite in index.html), linksbündig,
   Listen mit Haarlinien, 4px-Ecken, Bottom-Sheets.
   Warmes Charcoal, Papierweiß, Ocker als einziger Akzent, Terrakotta für
   Sucher und Warnungen. Keine Glows, keine Verläufe, keine Pulse.
   ========================================================================== */

:root {
  --bg: #16140f;
  --bg-2: #1c1914;
  --surface: #221e18;
  --line: #2e2921;
  --line-strong: #403a2e;
  --text: #efe8d8;
  --muted: #a39a86;
  --accent: #e2b45a;
  --accent-ink: #2a1f08;
  --danger: #c96a4a;
  --danger-ink: #2a120a;
  --ok: #8fa77a;
  --ok-ink: #16200f;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#map { position: fixed; inset: 0; background: var(--bg); }
.maplibregl-ctrl-attrib {
  background: rgba(22, 20, 15, 0.6) !important;
  pointer-events: none !important;
  font-size: 8px !important; line-height: 1.4 !important;
  padding: 1px 5px !important; opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.maplibregl-ctrl-attrib a { color: var(--muted) !important; pointer-events: none !important; font-size: 8px !important; }
.maplibregl-ctrl-bottom-left { left: 50%; transform: translateX(-50%); }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ======= Icons (Sprite in index.html) ======= */
.ic {
  width: 20px; height: 20px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic.big { width: 28px; height: 28px; }
.with-ic { display: inline-flex; align-items: center; gap: 10px; }

/* ======= Typo-Bausteine ======= */
.eyebrow {
  font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.logo {
  font-weight: 600;
  font-size: 46px; line-height: 1; letter-spacing: -0.02em;
  margin: 4px 0 6px;
}
h2 { font-weight: 600; font-size: 24px; line-height: 1.2; }
.end-title { font-weight: 600; font-size: 44px; line-height: 1; letter-spacing: -0.02em; }
.end-title.win { color: var(--ok); }
.end-title.lose { color: var(--danger); }
.end-sub { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); white-space: pre-line; line-height: 1.7; }
.rules { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rules .with-ic { gap: 6px; }
.rules .ic { width: 16px; height: 16px; }
.rules:empty { display: none; }
.stats { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ======= Panels: immer mittig über der Karte ======= */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(22, 20, 15, 0.62);
}
.sheet {
  width: 100%; max-width: 420px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 26px 22px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  display: flex; flex-direction: column; gap: 16px;
  text-align: left;
  animation: sheet-in 0.22s ease;
}
@keyframes sheet-in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
/* Start- und Ende-Screen etwas großzügiger */
.sheet-wrap.center .sheet { padding: 30px 24px; gap: 20px; }
.sheet-wrap.center .logo { font-size: 56px; margin-bottom: 10px; }

/* ======= Felder ======= */
.field {
  width: 100%;
  padding: 10px 0;
  border: 0; border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit; font-size: 18px;
}
.field { user-select: text; -webkit-user-select: text; }
.field::placeholder { color: var(--muted); opacity: 0.6; }
.field:focus { outline: none; border-bottom-color: var(--accent); }
.field.code {
  font-variant-numeric: tabular-nums; font-size: 30px; font-weight: 500;
  letter-spacing: 0.3em; text-transform: uppercase;
}
.code-row { display: flex; align-items: flex-end; gap: 12px; }
.code-row .field { flex: 1; min-width: 0; }

.row { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.row > span { display: flex; justify-content: space-between; align-items: center; }
.row .ic { color: var(--muted); }
.row output { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.check { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15px; padding: 6px 0; }
.check .ic { color: var(--muted); }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }

/* ======= Buttons ======= */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  color: var(--text);
  font-size: 16px; font-weight: 500;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #eabf68; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.big { font-size: 18px; padding: 16px; }
.btn.small { width: auto; min-height: 44px; padding: 10px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.link {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 8px 0; color: var(--muted);
  font-size: 15px; text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }

.opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--r);
  text-align: left;
}
.opt:hover { background: var(--surface); }
.opt b { font-size: 18px; font-weight: 600; }
.opt span { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }

/* Segment: Runner / Sucher */
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg-btn {
  flex: 1; padding: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 16px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn.is-active { background: var(--text); color: var(--bg); }

/* Listen mit Haarlinien */
.list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.list:empty { display: none; }
.list-btn, .game-item, .lp {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  color: var(--text); font-size: 16px; text-align: left;
}
.list-btn:hover, .game-item:hover { background: var(--surface); }
.list-btn .ic, .lp .ic { color: var(--muted); }
.list-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.lp .role { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.lp.off { opacity: 0.4; }
.game-item { font-variant-numeric: tabular-nums; letter-spacing: 0.08em; justify-content: flex-start; }
.game-item .live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.zdel { flex: none; min-height: 44px; padding: 6px 10px; font-size: 13px; color: var(--danger); }
.zone-item { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.zone-item .list-btn { border-bottom: 0; }
.zone-status { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.zone-status.ok { color: var(--accent); }

/* Lobby-Kopf: Code + QR */
.lobby-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.code-big {
  display: inline-flex; align-items: center; gap: 12px; padding: 2px 0;
  font-variant-numeric: tabular-nums; font-size: 34px; font-weight: 500; letter-spacing: 0.16em;
  color: var(--text); text-align: left; line-height: 1.1;
}
.code-big .ic { color: var(--muted); }
.code-big:hover { color: var(--accent); }
.qr { flex: none; line-height: 0; padding: 6px; background: var(--text); border-radius: var(--r); }
.qr img, .qr canvas { display: block; }

#scanVideo {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--r); background: #000;
}

/* ======= HUD ======= */
.hud { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.bar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(22, 20, 15, 0.94);
  border-bottom: 1px solid var(--line-strong);
  pointer-events: auto;
}
.badge {
  font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase;
  min-width: 72px;
}
.badge.runner { color: var(--accent); }
.badge.seeker { color: var(--danger); }
.bar-mid { display: flex; flex-direction: column; align-items: center; gap: 0; }
.bar-phase { font-variant-numeric: tabular-nums; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.bar-timer { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bar-ping { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-ping .ic { width: 14px; height: 14px; }
.bar-ping span { color: var(--accent); }
.bar-btns { display: flex; gap: 6px; justify-content: flex-end; }
.sq {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  color: var(--text);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sq:hover { background: var(--surface); }
.sq.active { color: var(--accent); border-color: var(--accent); }

.catch {
  position: absolute; left: 16px; right: 16px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  pointer-events: auto;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px;
  border: 1px solid var(--danger); border-radius: var(--r);
  background: var(--danger); color: var(--danger-ink);
  font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  transition: opacity 0.2s ease;
}
.catch:disabled { opacity: 0.3; }

/* Warten (Sucher im Vorsprung) */
.wait {
  position: fixed; inset: 0; z-index: 31; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(22, 20, 15, 0.5);
}
.wait-box {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--muted);
  padding: 22px 32px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--bg-2);
}
.wait-count { font-variant-numeric: tabular-nums; font-size: 52px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }

/* Warnungen: Balken unter der Leiste */
.warn {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  box-shadow: inset 0 0 90px rgba(201, 106, 74, 0.35);
}
.warn-box {
  position: absolute; left: 16px; right: 16px;
  top: calc(126px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: var(--r);
  background: var(--danger); color: var(--danger-ink);
  font-size: 15px; font-weight: 500;
}
.warn-count { font-variant-numeric: tabular-nums; font-size: 22px; font-variant-numeric: tabular-nums; }
.exposed {
  position: fixed; left: 16px; right: 16px; z-index: 40;
  top: calc(84px + env(safe-area-inset-top));
  pointer-events: none;
  padding: 8px 12px; border-radius: var(--r);
  border: 1px solid var(--danger); background: var(--bg-2); color: var(--danger);
  font-variant-numeric: tabular-nums; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  text-align: center;
}

/* ======= Öffis (unten links) ======= */
.transit {
  position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 32;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
}
.transit-btn {
  height: 56px; padding: 0 16px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: rgba(22, 20, 15, 0.94); color: var(--text);
  font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; font-variant-numeric: tabular-nums;
  -webkit-touch-callout: none;
}
.transit-btn.riding { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }
.transit-btn.cd { color: var(--muted); }
.transit-chip {
  padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: rgba(22, 20, 15, 0.94);
  font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ok);
}

/* ======= Funk (unten rechts) ======= */
.voice {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 32;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.voice-chips { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.vchip {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: rgba(22, 20, 15, 0.94);
  font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.vchip .vdot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.vchip.talking { color: var(--text); border-color: var(--ok); }
.vchip.talking .vdot { background: var(--ok); }
.ptt {
  width: 60px; height: 60px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  background: rgba(22, 20, 15, 0.94); color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ptt .ic { width: 26px; height: 26px; }
.ptt.talking { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }

/* ======= Zonen-Editor ======= */
.zone-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 35;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(22, 20, 15, 0.94);
  border-top: 1px solid var(--line-strong);
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.zvert {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--text);
  cursor: grab;
}

/* ======= Marker ======= */
.pmark { display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.pmark .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text); }
.pmark--me { color: var(--accent); }
.pmark--me .dot { background: var(--accent); width: 18px; height: 18px; }
.dotwrap { position: relative; width: 18px; height: 18px; }
.dotwrap .dot { position: absolute; inset: 0; }
.hdg { position: absolute; inset: -12px; transform-origin: center; transition: transform 0.25s ease; }
.hdg::before {
  content: ""; position: absolute; left: 50%; top: -6px; margin-left: -6px;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 12px solid var(--accent);
}
.pmark--seeker { color: var(--danger); }
.pmark--seeker .dot { background: var(--danger); }
.plabel {
  font-variant-numeric: tabular-nums; font-size: 10px; color: var(--text);
  background: rgba(22, 20, 15, 0.88); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 3px; white-space: nowrap;
}

.ping { display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.ping .ring {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg);
  position: relative;
}
.ping .ring::after {
  content: ""; position: absolute; inset: -4px;
  border: 1.5px solid var(--text); border-radius: 50%;
  animation: ping-ring 1.8s ease-out infinite;
}
@keyframes ping-ring {
  from { transform: scale(1); opacity: 0.7; }
  to { transform: scale(3); opacity: 0; }
}
.ping.old { opacity: 0.45; }
.ping.old .ring::after { animation: none; }

/* ======= Toast ======= */
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 60;
  bottom: calc(160px + env(safe-area-inset-bottom));
  padding: 12px 14px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--bg-2);
  font-size: 14px; text-align: center;
  animation: sheet-in 0.2s ease;
}
@media (min-width: 600px) {
  .toast { left: 50%; right: auto; transform: translateX(-50%); max-width: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .sheet { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding-top: 16px; }
  .logo { font-size: 32px; }
  .wait-count { font-size: 36px; }
}
