* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #1a1a1a;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 0;
}

.dog-marker {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.65));
}

.hud {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: calc(148px + max(8px, env(safe-area-inset-right)));
  transform: none;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  width: auto;
  min-width: 0;
  max-width: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(6px);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.gps-wait {
  color: #555;
  font-size: 0.9rem;
}

.gps-ok {
  color: #0a7a0a;
  font-size: 0.9rem;
  font-weight: 600;
}

.gps-err {
  color: #b42318;
  font-size: 0.9rem;
  font-weight: 600;
}

.gps-meta {
  color: #666;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

#gps-coords {
  margin-top: 2px;
}

.fab-group {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(72px, calc(56px + env(safe-area-inset-bottom)));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#btn-chase.active {
  background: #ff2d95;
  color: #fff;
}

.fab {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
  font-size: 1.25rem;
  cursor: pointer;
}

.fab:active {
  transform: scale(0.96);
}

.fab.active {
  background: #2563eb;
  color: #fff;
}

.leaflet-top.leaflet-right {
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  max-width: calc(140px + env(safe-area-inset-right));
}

.leaflet-top.leaflet-left {
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
}

.leaflet-bottom.leaflet-right,
.leaflet-bottom.leaflet-left {
  bottom: max(4px, env(safe-area-inset-bottom));
}

.leaflet-control-layers {
  border-radius: 8px !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
  margin: 0 !important;
}

.leaflet-control-layers-toggle {
  display: none !important;
}

.leaflet-control-layers-expanded .leaflet-control-layers-list,
.leaflet-control-layers-list {
  display: block !important;
  position: relative;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  font-size: 13px;
  margin-bottom: 2px;
}

.finish-marker,
.pass-marker {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

.chase-panel {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: 0;
  z-index: 1100;
  max-height: min(70vh, 480px);
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
  transform: translateY(110%);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.chase-panel.open {
  transform: translateY(0);
  pointer-events: auto;
}

.chase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.chase-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.chase-intro {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: #444;
  line-height: 1.45;
}

.chase-pass-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #ff2d95;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}

.chase-pass-btn:active {
  transform: scale(0.99);
}

.chase-formula-note {
  margin: 10px 0 0;
  font-size: 0.72rem;
  color: #888;
  text-align: center;
}

.chase-result {
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 10px;
  background: #fff8fb;
  border: 1px solid #ffcce6;
  border-radius: 10px;
}

.chase-result.hidden {
  display: none;
}

.chase-result-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #c2185b;
}

.chase-result-err {
  color: #b42318;
  font-weight: 600;
}

.chase-result-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: #444;
}

.chase-result-row span {
  color: #777;
  flex-shrink: 0;
}

.chase-result-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chase-result-highlight {
  margin: 8px 0 4px;
  padding: 8px 10px;
  background: #fff0f7;
  border-radius: 8px;
  color: #333;
}

.chase-result-highlight strong {
  color: #c2185b;
}

.chase-result-reward {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 6px 0 2px;
  color: #111;
}

.chase-result-reward strong {
  color: #c2185b;
  font-size: 1.25rem;
}

.chase-result .warn {
  color: #b45309;
  font-size: 0.75rem;
}

.chase-clear-btn {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f5f5f5;
  font-size: 0.85rem;
  cursor: pointer;
}

@media (max-width: 480px) {
  .hud {
    right: calc(132px + max(8px, env(safe-area-inset-right)));
    padding: 6px 10px;
  }

  .hud-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .gps-wait,
  .gps-ok,
  .gps-err {
    font-size: 0.82rem;
  }

  .dog-marker {
    font-size: 24px;
  }

  .leaflet-control-layers-base label,
  .leaflet-control-layers-overlays label {
    font-size: 12px;
  }
}
