/* Stadtjagd – Fahndungskarte im Stil von Verkehrsbeschilderung.
   Layout: Karte füllt den Bildschirm, ein Leitstand-Panel liegt links (mobil: unten). */
:root {
  --paper: #f3f5f1;
  --panel: rgba(252, 253, 250, 0.96);
  --ink: #15212c;
  --muted: #5a6875;
  --line: #d6dcd6;
  --chip: #e8ece6;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --danger: #c2261d;
  --ok: #14804a;
  --roller: #0f9d76;
  --auto: #d99200;
  --bus: #d61f57;
  --boat: #1b82d1;
  --drone: #7c4ddb;
  --hide: #27303a;
  --shadow: 0 10px 30px rgba(20, 33, 44, 0.18), 0 2px 6px rgba(20, 33, 44, 0.12);
  --display: 'Big Shoulders Display', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e161e;
    --panel: rgba(18, 27, 36, 0.96);
    --ink: #e6edf2;
    --muted: #96a5b2;
    --line: #2b3a47;
    --chip: #1f2c38;
    --accent: #6d9bff;
    --accent-ink: #0b1220;
    --danger: #ff6b5e;
    --ok: #4ad38a;
    --roller: #34d399;
    --auto: #fbbf24;
    --bus: #ff5c8d;
    --boat: #55b6ff;
    --drone: #a98bff;
    --hide: #dfe5ea;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--body);
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#map { position: fixed; inset: 0; background: var(--paper); }
.leaflet-container { font-family: var(--body); background: var(--paper); }
.leaflet-control-attribution { font-size: 11px; }

/* --- Panel ----------------------------------------------------------------- */
#panel {
  position: fixed;
  z-index: 1000;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  width: 392px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
#view { overflow-y: auto; padding: 4px 18px 18px; flex: 1; min-height: 0; }
.brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font: 800 26px/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--ink); text-decoration: none;
}
.logo-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(var(--roller) 0 33%, var(--auto) 0 66%, var(--bus) 0);
  box-shadow: inset 0 0 0 5px var(--panel);
  outline: 2px solid var(--ink);
}
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn.on { background: var(--ok); }
.conn.off { background: var(--danger); }

h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 34px; line-height: 1; font-weight: 800; text-transform: uppercase; }
h2 { font-size: 22px; font-weight: 800; text-transform: uppercase; }
h3 { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p { margin: 0; }
.lead { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.section { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.section + .section { border-top: 1px solid var(--line); margin-top: 6px; }
.small { font-size: 13px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=search] {
  width: 100%; padding: 10px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--paper);
}
input[type=text]:focus, input[type=search]:focus { border-color: var(--accent); outline: none; }
input.code { text-transform: uppercase; letter-spacing: 0.25em; font: 700 20px var(--display); text-align: center; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--panel);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 13px 18px; font-size: 16px; width: 100%; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; align-self: flex-start; }
svg.inline, .small svg, .toggle svg { width: 16px; height: 16px; vertical-align: -3px; flex: none; }

.results { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.results button {
  text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.results button:last-child { border-bottom: 0; }
.results button:hover, .results button:focus-visible { background: var(--chip); }
.results strong { font-weight: 700; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; padding: 8px 4px; background: transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--panel); }
.seg small { font-size: 11px; opacity: 0.75; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.steps li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now::before { border-color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { background: var(--accent); } }

.notice { padding: 10px 12px; border-radius: var(--radius); background: var(--chip); font-size: 14px; }
.notice.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* Verkehrsmittel-Legende und Tickets */
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 8px; }
.swatch { width: 22px; height: 0; border-top: 4px solid var(--c); border-radius: 2px; flex: none; }
.swatch.dash { border-top-style: dashed; }
.tix { display: flex; gap: 6px; flex-wrap: wrap; }
.tix .t {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--ink); font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tix .t svg { width: 16px; height: 16px; color: var(--c); }
.tix .t.zero { opacity: 0.4; }
.mode-roller { --c: var(--roller); } .mode-auto { --c: var(--auto); } .mode-bus { --c: var(--bus); }
.mode-boat { --c: var(--boat); } .mode-drone { --c: var(--drone); } .mode-hide { --c: var(--hide); } .mode-sprint { --c: var(--accent); }

/* Lobby */
.roomcode { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--ink); color: var(--panel); }
.roomcode b { font: 800 34px/1 var(--display); letter-spacing: 0.18em; }
.roomcode .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--panel) 40%, transparent); }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.slot .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.slot .who small { color: var(--muted); font-size: 12px; }
.badge {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--c); color: #fff; font: 800 15px var(--display); border: 2px solid var(--panel); box-shadow: 0 0 0 1.5px var(--c);
}
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--radius); }
.stepper button { border: 0; background: none; width: 34px; height: 34px; font-size: 18px; cursor: pointer; }
.stepper span { min-width: 26px; text-align: center; font-weight: 700; }
.fair { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.fair.bad { color: var(--danger); }

/* Spiel */
.turnbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--chip); }
.turnbar.mine { background: var(--accent); color: var(--accent-ink); }
.turnbar .round { font: 800 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.turnbar .round small { font-size: 16px; opacity: 0.7; }
.turnbar .what { flex: 1; min-width: 0; line-height: 1.25; }
.turnbar .what b { display: block; }

.logbook { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.logbook .cell {
  aspect-ratio: 1; border-radius: 7px; border: 1.5px solid var(--line); display: grid; place-items: center;
  position: relative; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.logbook .cell.reveal { border-color: var(--ink); border-style: dashed; }
.logbook .cell.used { background: var(--c); border-color: var(--c); color: #fff; }
.logbook .cell.used.mode-hide { color: var(--panel); }
.logbook .cell svg { width: 20px; height: 20px; }
.logbook .cell .pos { position: absolute; bottom: -2px; right: -2px; background: var(--ink); color: var(--panel); font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 6px; }
.logbook .cell .rn { position: absolute; top: 1px; left: 3px; font-size: 9px; opacity: 0.8; }
.logbook .cell.now { box-shadow: 0 0 0 2px var(--accent); }

.players { display: flex; flex-direction: column; gap: 6px; }
.player { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius); }
.player.active { background: var(--chip); }
.player .who { flex: 1; min-width: 0; line-height: 1.2; }
.player .who small { color: var(--muted); }
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); max-height: 160px; overflow-y: auto; }
.events li.end { color: var(--ink); font-weight: 700; }
.events li.chat { color: var(--ink); }
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.result { padding: 14px; border-radius: var(--radius); color: #fff; background: var(--c); }
.result h2 { color: #fff; }

/* Leaflet-Marker: Orte */
.node-icon { background: none; border: 0; }
.node {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ring); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.15s;
}
.node .n {
  width: 17px; height: 17px; border-radius: 50%; background: #fff; color: #15212c;
  display: grid; place-items: center; font: 700 9.5px/1 var(--body); font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.node.big .n { width: 16px; height: 16px; }
.z-low .node { width: 12px; height: 12px; }
.z-low .node .n { width: 7px; height: 7px; font-size: 0; }
.node.reach { transform: scale(1.35); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--rc, var(--accent)), 0 0 16px var(--rc, var(--accent)); cursor: pointer; animation: pulse 1.3s ease-in-out infinite; }
.z-low .node.reach { transform: scale(1.6); }
.node.maybe { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 6px rgba(214, 31, 87, 0.55); }
.node.dim { opacity: 0.55; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px #fff, 0 0 0 8px var(--rc, var(--accent)), 0 0 22px var(--rc, var(--accent)); } }
@media (prefers-reduced-motion: reduce) { .node.reach, .steps li.now::before { animation: none; } }

/* Spielfiguren */
.pawn-icon { background: none; border: 0; }
.pawn {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  background: var(--c); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  display: grid; place-items: center; transition: transform 0.2s;
}
.pawn span { transform: rotate(45deg); color: #fff; font: 800 15px/1 var(--display); }
.pawn.active { animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: rotate(-45deg) translate(3px, -3px); } }
.ghost {
  width: 40px; height: 40px; border-radius: 50%; border: 3px dashed var(--hide);
  display: grid; place-items: center; background: color-mix(in srgb, var(--panel) 60%, transparent);
  font: 800 12px/1 var(--display); color: var(--ink);
}
.area-center { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: var(--shadow); cursor: grab; }

/* Zugauswahl auf der Karte */
.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--panel); color: var(--ink); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; font-family: var(--body); }
.pick { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.pick b { font-family: var(--display); font-size: 18px; text-transform: uppercase; }
.pick .btn { justify-content: flex-start; border-color: var(--c); }
.pick .btn svg { color: var(--c); }

#toast {
  position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); font-weight: 600;
}

.sheet-btn { display: none; }
/* Mobil: Panel als Blatt unten */
@media (max-width: 760px) {
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 58%;
    border-radius: 16px 16px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #panel.collapsed { max-height: 64px; }
  .sheet-btn { display: block; width: 36px; height: 30px; border: 1.5px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; position: relative; }
  .sheet-btn::after { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border: solid var(--ink); border-width: 0 2.5px 2.5px 0; transform: translate(-50%, -70%) rotate(45deg); }
  #panel.collapsed .sheet-btn::after { transform: translate(-50%, -25%) rotate(-135deg); }
  #panel.collapsed #view { display: none; }
  .brand { padding: 10px max(16px, env(safe-area-inset-left, 0px)) 8px; cursor: pointer; }
  #view { padding: 4px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
  h1 { font-size: 28px; }
  .leaflet-bottom.leaflet-right { bottom: 58%; }
  #toast { bottom: calc(58% + 12px); }
  .sheet-collapsed .leaflet-bottom.leaflet-right { bottom: 64px; }
  .sheet-collapsed #toast { bottom: 78px; }
}
