*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2e3247;
  --accent: #4f8ef7;
  --accent2: #f7c94f;
  --green: #3ecf8e;
  --red: #f56565;
  --text: #e2e8f0;
  --muted: #8892a4;
  --panel-blur: blur(12px);
  --panel-bg: rgba(15,17,28,0.82);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── PHASES ── */
.phase {
  display: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  position: relative;
}
.phase.active { display: block; }

/* ── MAP CONTAINER (Phase 1) ── */
#map-container {
  position: absolute;
  inset: 0;
}
#map {
  width: 100%;
  height: 100%;
}
#selection-overlay {
  position: absolute;
  inset: 10%;
  border: 2px solid var(--accent);
  background: rgba(79,142,247,0.06);
  pointer-events: none;
  border-radius: 4px;
}

/* ── SCHWEBENDES PANEL Phase 1 ── */
#map-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#map-panel > * { pointer-events: auto; }

.panel-top {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 14px;
}
.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent2);
  white-space: nowrap;
}
.panel-top .search-box {
  flex: 1;
}

.panel-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.panel-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-icon {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.16); }
.btn-confirm {
  padding: 8px 16px;
  font-size: 0.88rem;
  width: auto;
  white-space: nowrap;
}

/* ── GAME WRAPPER (Phase 2+3) ── */
#game-wrapper {
  position: absolute;
  inset: 0;
}
#setup-map, #sim-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
#game-canvas, #sim-canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: crosshair;
  z-index: 1;
  background: transparent;
  touch-action: none;
}

/* ── HUD (Phase 2+3) ── */
.hud {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel-bg);
  backdrop-filter: var(--panel-blur);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  padding: 10px 18px;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.hud-info {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.hud-muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
}
.hud-actions {
  display: flex;
  gap: 8px;
}
.btn-hud {
  border: none;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-hud-pri { background: var(--accent); color: #fff; }
.btn-hud-pri:hover { opacity: 0.88; }
.btn-hud-sec { background: rgba(255,255,255,0.12); color: var(--text); }
.btn-hud-sec:hover { opacity: 0.8; }

/* ── BUTTONS (Modal) ── */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { opacity: 0.8; }

/* ── STATUS ── */
.status-msg {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.4em;
  line-height: 1.4;
}

/* ── GAME OVER ── */
#gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#gameover-overlay.hidden { display: none; }

#gameover-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.go-title {
  font-size: 3rem;
}
.go-subtitle {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--red);
}
#go-score, #go-time {
  font-size: 1rem;
  color: var(--muted);
}

/* ── SUCHE ── */
.search-box {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.search-box input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.search-box input:focus {
  border-color: var(--accent);
}
.search-box button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 0.9rem;
}
#search-results {
  width: 100%;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}
#search-results:empty { display: none; }
#search-results li {
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.4;
}
#search-results li:last-child { border-bottom: none; }
#search-results li:hover { background: var(--bg); color: var(--accent); }

/* ── ZOOM HINT ── */
.zoom-hint {
  font-size: 0.75rem;
  color: var(--accent2);
  font-weight: 600;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent2);
  text-align: center;
}
.modal-hint {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.modal-box input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  width: 100%;
}
.modal-box input:focus { border-color: var(--accent); }

/* ── HIGHSCORE TABLE ── */
#highscore-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
#highscore-table th {
  color: var(--muted);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
#highscore-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}
#highscore-table tr:last-child td { border-bottom: none; }
#highscore-table tr:first-child td { font-weight: 700; color: var(--accent2); }

/* ── RESPONSIVE MOBILE ── */
@media (max-width: 600px) {
  /* Panel oben: Logo + Suche stapeln */
  .panel-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .logo { text-align: center; }

  /* Panel unten: Info + Actions stapeln */
  .panel-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .panel-actions {
    justify-content: flex-end;
  }
  .btn-confirm { flex: 1; }

  /* HUD auf Mobile: breiter, unten zentriert */
  .hud {
    left: 12px;
    right: 12px;
    transform: none;
    border-radius: 16px;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .hud-info { gap: 10px; font-size: 0.82rem; }

  /* Modals: volle Breite */
  .modal-box { padding: 24px 16px; width: calc(100vw - 24px); }
  .modal-wide { max-width: calc(100vw - 24px); }

  /* Gameover: Buttons stapeln */
  #gameover-box { padding: 28px 16px; }
  #gameover-box button { width: 100%; }
}

/* ── KARTENVORSCHLÄGE ── */
.map-suggestions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}
.map-suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.map-sug-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.map-sug-meta { color: var(--muted); font-size: 0.8rem; }
.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-sm:hover { background: var(--border); }
.btn-vote { background: var(--bg); }

/* ── LEAFLET OVERRIDES ── */
.leaflet-container {
  background: #1a1d27;
}
